:root {
  --bg: #0a0f0c;
  --bg-soft: #101712;
  --card: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef5ee;
  --muted: #93a396;
  --accent: #a4f16d;
  --accent-ink: #0d1a08;
  --danger: #ff6b6b;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(164, 241, 109, 0.10), transparent 60%),
    radial-gradient(700px 380px at 110% 10%, rgba(80, 200, 255, 0.06), transparent 55%),
    var(--bg);
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---------- Header ---------- */

.topbar { margin-bottom: 18px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: var(--accent);
  background: rgba(164, 241, 109, 0.10);
  border: 1px solid rgba(164, 241, 109, 0.25);
  flex: none;
}

.brand-icon svg { width: 26px; height: 26px; }

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(6px);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2 { margin: 0; }

/* ---------- Scanner ---------- */

.scanner-stage {
  position: relative;
  aspect-ratio: 10 / 7;
  min-height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #050806;
  border: 1px solid var(--border);
}

.reader {
  width: 100%;
  height: 100%;
}

#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: 14px;
}

#reader img[alt="Info icon"] { display: none !important; }

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(600px 220px at 50% 0%, rgba(164, 241, 109, 0.06), transparent 70%), #070b08;
}

.placeholder[hidden] { display: none; }

.placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 300px;
  line-height: 1.45;
}

.placeholder-icon {
  width: 54px;
  height: 54px;
  color: rgba(164, 241, 109, 0.55);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:active:not(:disabled) { background: #8fe05a; }

.btn.accent {
  background: rgba(164, 241, 109, 0.12);
  border-color: rgba(164, 241, 109, 0.35);
  color: var(--accent);
}

.btn.danger { color: #ffb3b3; }

.btn.danger:active:not(:disabled) { background: rgba(255, 107, 107, 0.12); }

.link-danger {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  cursor: pointer;
  padding: 4px 0;
}

/* ---------- Status ---------- */

.status {
  margin: 10px 2px 0;
  min-height: 18px;
  font-size: 0.8rem;
  color: var(--muted);
}

.status.error { color: #ffb3b3; }

/* ---------- Result ---------- */

.result-card {
  border-color: rgba(164, 241, 109, 0.35);
  background: linear-gradient(160deg, rgba(164, 241, 109, 0.07), rgba(255, 255, 255, 0.03) 55%);
  animation: pop 0.18s ease;
}

@keyframes pop {
  from { transform: scale(0.98); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(164, 241, 109, 0.12);
  border: 1px solid rgba(164, 241, 109, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
}

.time {
  font-size: 0.76rem;
  color: var(--muted);
}

.code {
  margin: 0 0 14px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: clamp(1.35rem, 6vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  word-break: break-all;
  line-height: 1.25;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions .btn { flex: 1 1 auto; }

/* ---------- History ---------- */

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.history-code {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-all;
}

.history-meta {
  margin: 3px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.history-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mini-btn:active { background: rgba(255, 255, 255, 0.12); }

.mini-btn.remove { color: #ffb3b3; }

.empty {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

/* ---------- Manual form ---------- */

.manual-form {
  display: flex;
  gap: 8px;
}

.manual-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}

.manual-form input:focus {
  border-color: rgba(164, 241, 109, 0.5);
  box-shadow: 0 0 0 3px rgba(164, 241, 109, 0.12);
}

.manual-form input::placeholder { color: #6d7d70; }

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  font-size: 0.72rem;
  color: #66756a;
  margin-top: 26px;
}

/* ---------- Small phones ---------- */

@media (max-width: 380px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .btn.danger { grid-column: 1 / -1; }
}
