:root {
  --bg: #f7f7f4;
  --card: #ffffff;
  --ink: #1d1f21;
  --muted: #667085;
  --line: #d6d9dd;
  --accent: #0b6dff;
  --accent-ink: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top right, #eef4ff 0%, var(--bg) 45%);
  color: var(--ink);
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 1rem;
}

.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.hero h1 {
  margin: 0 0 0.4rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1rem;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 0.7rem;
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0s, color 0s, border-color 0s;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.tab.active:hover,
.tab.active:focus-visible,
.tab.active:active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.panel {
  display: none;
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.panel.active {
  display: block;
}

.hint {
  margin-top: 0;
  color: var(--muted);
}

.scanner-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.video-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}

#preview {
  width: 100%;
  min-height: 220px;
  max-height: 360px;
  object-fit: cover;
  display: block;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.18) 0%,
    rgba(0, 0, 0, 0.06) 45%,
    rgba(0, 0, 0, 0.2) 100%
  );
}

.scan-aim-box {
  width: min(82%, 320px);
  aspect-ratio: 3 / 2;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  box-shadow:
    0 0 0 999px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  position: relative;
}

.scan-aim-box::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  border-radius: 999px;
  background: rgba(8, 239, 183, 0.9);
  box-shadow: 0 0 14px rgba(8, 239, 183, 0.75);
  animation: scanSweep 2.1s linear infinite;
}

.scan-aim-box::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  border: 2px solid transparent;
  border-top-color: rgba(8, 239, 183, 0.95);
  border-left-color: rgba(8, 239, 183, 0.95);
}

.scan-overlay-label {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  margin: 0;
  width: calc(100% - 20px);
  max-width: 320px;
  text-align: center;
  line-height: 1.25;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(8, 18, 24, 0.42);
  color: #f0fffa;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

@keyframes scanSweep {
  0% {
    transform: translateY(-38px);
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(38px);
    opacity: 0.65;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scan-aim-box::before {
    animation: none;
  }
}

.controls {
  display: grid;
  gap: 0.65rem;
}

.hidden {
  display: none !important;
}

#cameraControls,
#scannerControls {
  display: grid;
  gap: 0.65rem;
}

label {
  font-weight: 600;
}

input,
select,
button {
  font-size: 1rem;
  border-radius: 10px;
}

input,
select {
  border: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  width: 100%;
}

button {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0.65rem 0.85rem;
  cursor: pointer;
}

button:hover:enabled {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-box {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  display: grid;
  gap: 0.35rem;
}

.result-label {
  color: var(--muted);
  font-size: 0.9rem;
}

#scanResult {
  font-weight: 700;
  word-break: break-all;
}

.scan-meta {
  color: var(--muted);
}

.generator-form {
  display: grid;
  gap: 0.65rem;
}

.generated-wrap {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
  background: #fff;
}

.barcode-list {
  display: grid;
  gap: 0.8rem;
}

.barcode-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  background: #fff;
  display: grid;
  justify-items: center;
}

.barcode-value {
  margin: 0 0 0.5rem;
  font-weight: 700;
  word-break: break-all;
}

.barcode-card svg {
  display: block;
  max-width: 100%;
}

.tool-banner-ad {
  margin-top: 1rem;
  border: 1px solid #d6e3ec;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fcff);
  padding: 12px;
  box-shadow: 0 10px 30px rgba(12, 31, 36, 0.08);
}

.tool-banner-ad .ad-label {
  margin: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tool-banner-ad .ad-box {
  min-height: 110px;
  border: 1px solid #d9e6ef;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
}

@media (min-width: 760px) {
  .scanner-grid {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}

@media (max-width: 480px) {
  .scan-overlay-label {
    bottom: 8px;
    font-size: 0.76rem;
    padding: 4px 7px;
  }
}
