:root {
  --bg: #111114;
  --card: #1c1c21;
  --card2: #26262d;
  --text: #f2f2f5;
  --muted: #9a9aa5;
  --line: #2f2f37;
  --primary: #e60012;
  --jp: #e60012;
  --hk: #f08c00;
  --ot: #1c7ed6;
  --ok: #2fb344;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", system-ui, sans-serif; }
body { padding-bottom: calc(24px + var(--safe-bottom)); }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar { padding: calc(10px + var(--safe-top)) 16px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
@media (max-width: 420px) { .brand .sub { display: none; } }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.stats { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.3; }

.tabs { display: flex; margin: 0 16px 12px; background: var(--card); border-radius: 10px; padding: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--card2); color: var(--text); }

main { padding: 0 16px; }
.tab { display: none; }
.tab.active { display: block; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .primary { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer; text-align: center; }
.btn.big { padding: 16px; font-size: 17px; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn:active { opacity: .8; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 2px; }

.card { background: var(--card); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.preview { position: relative; background: #000; border-radius: 10px; overflow: hidden; touch-action: none; }
.preview canvas { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
.crop-box { position: absolute; border: 2px solid #ffd43b; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.toolbar .primary { margin-left: auto; }
.seg { display: inline-flex; background: var(--card2); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 9px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.seg button.active { background: var(--bg); color: var(--text); }

.progress { position: relative; height: 22px; background: var(--card2); border-radius: 8px; margin-top: 10px; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ot); transition: width .2s; }
.progress .label { position: relative; font-size: 12px; line-height: 22px; padding: 0 8px; }

#barcode-reader { border-radius: 10px; overflow: hidden; }
#barcode-reader video { border-radius: 10px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: 12px; padding: 8px 10px; cursor: pointer; border: 1px solid transparent; }
.item:active { border-color: var(--line); }
.item .thumb { width: 54px; height: 54px; flex: none; border-radius: 6px; background: var(--card2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; overflow: hidden; }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .alt { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item .regions { display: flex; gap: 4px; flex: none; }
.score { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--card2); color: var(--muted); }
.score.hi { background: rgba(47,179,68,.2); color: #7bd88f; }
.score.mid { background: rgba(240,140,0,.2); color: #ffb84d; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--card2); color: var(--muted); }
.pill.s2 { background: rgba(28,126,214,.2); color: #74c0fc; }

.dot { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; opacity: .28; }
.dot.on { opacity: 1; box-shadow: 0 0 0 2px var(--ok) inset; }
.dot.jp { background: var(--jp); } .dot.hk { background: var(--hk); } .dot.ot { background: var(--ot); }

.owned { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 7px; }
.owned.yes { background: rgba(47,179,68,.18); color: #7bd88f; }
.owned.no { background: var(--card2); color: var(--muted); }

.section-title { font-size: 13px; color: var(--muted); margin: 14px 2px 6px; display: flex; justify-content: space-between; align-items: center; }
.ocr-text { font-size: 12px; color: var(--muted); white-space: pre-wrap; max-height: 120px; overflow: auto; background: var(--card2); border-radius: 8px; padding: 8px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

.searchbar input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; -webkit-appearance: none; }
.filters { display: flex; gap: 14px; margin: 8px 2px 10px; font-size: 13px; color: var(--muted); }

.prose h3 { margin: 10px 0 6px; font-size: 15px; }
.prose p, .prose li { font-size: 14px; color: #d5d5dc; }
.prose ol { padding-left: 20px; }
.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 5px; color: #fff; }
.tag.jp { background: var(--jp); } .tag.hk { background: var(--hk); } .tag.ot { background: var(--ot); }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; }
.sheet-inner { position: relative; width: 100%; max-height: 92vh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--safe-bottom)); }
.sheet .close { position: absolute; top: 10px; right: 12px; border: 0; background: var(--card2); color: var(--text); width: 32px; height: 32px; border-radius: 50%; font-size: 15px; }
.detail-head { display: flex; gap: 12px; align-items: flex-start; }
.detail-head .num { color: var(--muted); font-size: 13px; }
.detail-head h2 { margin: 2px 0 4px; font-size: 20px; line-height: 1.25; padding-right: 36px; }
.detail-head .alt { color: var(--muted); font-size: 13px; }
.verdict { margin: 14px 0 6px; padding: 12px; border-radius: 12px; font-weight: 700; font-size: 17px; text-align: center; }
.verdict.yes { background: rgba(47,179,68,.18); color: #7bd88f; }
.verdict.no { background: rgba(230,0,18,.12); color: #ff8a93; }
.regions3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rcard { background: var(--card2); border-radius: 12px; padding: 8px; text-align: center; border-top: 4px solid; }
.rcard.jp { border-color: var(--jp); } .rcard.hk { border-color: var(--hk); } .rcard.ot { border-color: var(--ot); }
.rcard .rname { font-weight: 700; font-size: 14px; }
.rcard .rstate { font-size: 13px; margin: 4px 0 6px; }
.rcard .rstate.yes { color: #7bd88f; font-weight: 700; } .rcard .rstate.no { color: var(--muted); }
.rcard img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; border-radius: 6px; background: #000; }
.rcard .nocover { width: 100%; aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; background: #000; border-radius: 6px; }
.rcard .rlabel { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kv { font-size: 13px; color: var(--muted); margin-top: 12px; }
.kv div { padding: 3px 0; border-top: 1px solid var(--line); }
.kv b { color: var(--text); font-weight: 600; }
.detail-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(30px + var(--safe-bottom)); transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 99; max-width: 90vw; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }

/* 挑战模式 */
.quiz-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.quiz-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.qs { background: var(--card); border-radius: 10px; padding: 8px 4px; text-align: center; }
.qs b { display: block; font-size: 20px; line-height: 1.1; }
.qs span { font-size: 11px; color: var(--muted); }
.qs-sync { grid-column: 1 / -1; font-size: 12px; text-align: right; }
.qs-sync .ok { color: #7bd88f; } .qs-sync .warn { color: #ffb84d; }
#quiz-views { align-self: center; }
.quiz-card { margin-top: 0; }
.quiz-cover { position: relative; background: #000; border-radius: 10px; overflow: hidden; text-align: center; }
.quiz-cover img { max-height: 46vh; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; }
.quiz-stage { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 8px; }
.quiz-q { margin: 12px 2px 8px; font-weight: 700; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.opt { text-align: left; border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 16px; font-weight: 600; line-height: 1.3; }
.opt:active { opacity: .8; }
.opt.right { background: rgba(47,179,68,.22); border-color: var(--ok); }
.opt.wrong { background: rgba(230,0,18,.18); border-color: var(--primary); }
.opt:disabled { opacity: .85; }
.quiz-feedback { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.fb-line { font-size: 14px; margin: 4px 0; }
.fb-line.ok { color: #7bd88f; font-weight: 700; font-size: 16px; } .fb-line.bad { color: #ff8a93; font-weight: 700; font-size: 16px; }
.archive-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.arch { background: var(--card); border-radius: 10px; padding: 6px; text-align: center; cursor: pointer; }
.arch img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #000; border-radius: 6px; }
.arch-name { font-size: 12px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arch-date { font-size: 11px; color: var(--muted); }
.hist-days { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.hist-days div { background: var(--card2); border-radius: 8px; padding: 4px 8px; }
.hist-days b { margin-left: 6px; }
.toolbar input { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 13px; }
