:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --accent: #111827;
  --soft: #e5e7eb;
  --success: #166534;
  --warning: #92400e;
  --danger: #991b1b;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.topbar {
  background: var(--ink);
  color: white;
  padding: 20px max(18px, env(safe-area-inset-right)) 20px max(18px, env(safe-area-inset-left));
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
}
.topbar h1 { margin: 2px 0; font-size: clamp(1.45rem, 4vw, 2.1rem); }
.subhead, .muted, .hint { color: var(--muted); }
.topbar .subhead { color: #d1d5db; margin: 0; }
.eyebrow { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; font-weight: 800; }
.token-box { min-width: min(100%, 310px); }
.token-box label { color: #e5e7eb; }

main { max-width: 1180px; margin: 0 auto; padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stats article { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.stats span { display: block; font-size: 1.7rem; font-weight: 800; }
.stats small { color: var(--muted); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 3px 0 12px; }
.tab { white-space: nowrap; border: 1px solid var(--line); background: white; padding: 10px 13px; border-radius: 999px; }
.tab.active { background: var(--ink); color: white; border-color: var(--ink); }
.panel { display: none; }
.panel.active { display: block; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(17,24,39,.04); }
.card h2 { margin: 2px 0 10px; font-size: 1.2rem; }
.card-head { display: flex; gap: 12px; align-items: start; justify-content: space-between; margin-bottom: 12px; }

label { display: block; font-weight: 700; font-size: .86rem; margin-bottom: 6px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: white;
  min-height: 44px;
}
input:focus, select:focus { outline: 3px solid rgba(17,24,39,.12); border-color: var(--ink); }

button { border: 0; border-radius: 10px; padding: 11px 14px; background: var(--accent); color: white; min-height: 44px; font-weight: 750; }
button.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--ink); }
.primary-large { padding: 13px 18px; min-width: 150px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline.wrap, .action-row { flex-wrap: wrap; }
.action-row { display: flex; gap: 10px; margin-top: 15px; }

.pill { display: inline-block; border-radius: 999px; padding: 6px 10px; background: var(--soft); color: var(--ink); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.pill.success { background: #dcfce7; color: var(--success); }
.pill.warning { background: #fef3c7; color: var(--warning); }
.pill.danger { background: #fee2e2; color: var(--danger); }

.reader { width: 100%; min-height: 80px; border-radius: 12px; overflow: hidden; background: #111827; margin: 10px 0; }
.reader:empty::before { content: "Camera preview appears here"; color: #9ca3af; display: grid; place-items: center; min-height: 80px; }
.manual { margin-top: 14px; }
.hidden { display: none !important; }
.result { margin-top: 12px; min-height: 22px; font-weight: 650; }
.result.ok { color: var(--success); }
.result.error { color: var(--danger); }
.callout { padding: 13px; background: #f9fafb; border-left: 4px solid var(--ink); margin: 14px 0; }

.list { display: grid; gap: 10px; }
.list-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.list-item h3 { margin: 0 0 5px; font-size: 1rem; }
.meta { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); font-size: .82rem; }
.variant-row { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); }
.media-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
.media-thumb { width: 150px; height: 150px; object-fit: contain; background: #f9fafb; border: 1px solid var(--line); border-radius: 10px; }
.media-copy { min-width: 0; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }

@media (max-width: 760px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
  .inline { align-items: stretch; }
  .manual .inline { display: grid; grid-template-columns: 1fr auto; }
  .card-head { flex-direction: column; }
  .media-row { grid-template-columns: 96px 1fr; }
  .media-thumb { width: 96px; height: 96px; }
}

@media (max-width: 420px) {
  main { padding: 12px; }
  .card { padding: 14px; }
}
