:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-press: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --tabbar-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b20; --text: #e8eaed; --muted: #9aa0a6;
    --line: #2a2f37; --primary: #3b82f6; --primary-press: #2563eb;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.wrap { max-width: 560px; margin: 0 auto; padding: 14px 14px 0; }
header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 14px 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
header.top h1 { font-size: 19px; margin: 0; font-weight: 700; }
header.top .sub { color: var(--muted); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }

button, .btn {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  padding: 13px 16px; background: var(--primary); color: #fff; font-weight: 600;
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  touch-action: manipulation;
}
button:active, .btn:active { background: var(--primary-press); }
button.secondary, .btn.secondary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
button.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
button.danger { background: var(--red); }
button.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
button:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

input, select {
  font: inherit; width: 100%; padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--text); outline: none;
}
input:focus { border-color: var(--primary); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* 扫码区 */
.scanbox { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1/1; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanbox .hint { position: absolute; inset: auto 0 0 0; padding: 8px; text-align: center; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); font-size: 13px; }
.scan-flash { animation: flash .35s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.0); } 30% { box-shadow: 0 0 0 6px rgba(22,163,74,.85) inset; } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; word-break: break-all; }
.list .grow { flex: 1; min-width: 0; }
.list .idx { color: var(--muted); font-size: 13px; width: 26px; text-align: right; flex: none; }
.muted { color: var(--muted); }
.sub2 { font-size: 12px; color: var(--muted); }
.count-pill { background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 11px; font-size: 14px; font-weight: 700; }

a.itemcard { display: block; text-decoration: none; color: inherit; }
.itemcard .bn { font-weight: 700; font-size: 16px; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* 结果状态 */
.result { border-radius: var(--radius); padding: 16px; text-align: center; font-weight: 700; font-size: 18px; }
.result.hit { background: rgba(22,163,74,.12); color: var(--green); }
.result.miss { background: rgba(220,38,38,.10); color: var(--red); }

/* 底部 tab */
nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
}
nav.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px;
}
nav.tabbar a span { font-size: 21px; line-height: 1; }
nav.tabbar a.on { color: var(--primary); }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast .t { background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast .t.err { background: var(--red); }
#toast .t.ok { background: var(--green); }
