/* 暗房 + 案卷：冷灰绿底色，安全灯琥珀红作为唯一强调色 */
:root {
  --paper: #EEF0EE;
  --surface: #FAFBFA;
  --ink: #1A2120;
  --muted: #5C6866;
  --line: #D3D9D6;
  --safelight: #B93A0E;
  --safelight-soft: #F6E3D9;
  --ok: #2B7348;
  --ok-soft: #DDEFE3;
  --warn: #9A6412;
  --warn-soft: #F5EAD3;
  --none: #6B7471;
  --none-soft: #E3E7E5;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-body: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121615; --surface: #1B2120; --ink: #E4E9E7; --muted: #95A19E; --line: #2C3533;
    --safelight: #F07A3A; --safelight-soft: #3A2318;
    --ok: #6CC48F; --ok-soft: #173024; --warn: #E2B05A; --warn-soft: #33281A; --none: #9AA4A1; --none-soft: #252C2B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121615; --surface: #1B2120; --ink: #E4E9E7; --muted: #95A19E; --line: #2C3533;
  --safelight: #F07A3A; --safelight-soft: #3A2318;
  --ok: #6CC48F; --ok-soft: #173024; --warn: #E2B05A; --warn-soft: #33281A; --none: #9AA4A1; --none-soft: #252C2B;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--font-body);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--safelight); outline-offset: 2px; }
[hidden] { display: none !important; }

.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* 顶部 */
.top {
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 50%, var(--safelight) 0 30%, transparent 32%), var(--ink);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--line);
}
h1 { margin: 0; font: 700 22px/1.2 var(--font-display); letter-spacing: .06em; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.engine {
  flex: none; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; white-space: nowrap;
}
.engine.demo { color: var(--warn); border-color: currentColor; }

main { max-width: 560px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }

/* 上传区：胶片框 */
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 250px; padding: 28px 20px; text-align: center; cursor: pointer;
  background: var(--surface); border-radius: 6px;
  border: 1.5px dashed var(--line);
  transition: border-color .2s, background .2s;
}
.drop:hover, .drop.over { border-color: var(--safelight); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--safelight); outline-offset: 2px; }
.drop-icon { color: var(--safelight); margin-bottom: 6px; }
.drop strong { font: 600 18px/1.3 var(--font-display); letter-spacing: .04em; }
.drop-hint { color: var(--muted); font-size: 13px; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border-radius: 6px; overflow: hidden; }
.rules li { background: var(--surface); padding: 12px 14px; color: var(--muted); font-size: 13px; display: grid; gap: 2px; }
.rules b { color: var(--ink); font-size: 14px; font-weight: 600; }

/* 证物：剧照预览 */
.exhibit { background: var(--surface); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.exhibit-head { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.exhibit img { width: 100%; max-height: 52vh; object-fit: contain; background: #0B0E0D; }
.exhibit-actions { display: flex; gap: 10px; padding: 12px; }
.exhibit-actions .btn { flex: 1; }

.btn {
  appearance: none; border: 0; border-radius: 6px; padding: 12px 16px; min-height: 46px;
  font-weight: 600; font-size: 15px; cursor: pointer; letter-spacing: .02em;
}
.btn.primary { background: var(--safelight); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

.section-title { margin: 0 0 10px; font: 600 13px/1 var(--font-body); color: var(--muted); letter-spacing: .12em; }

/* 侦查步骤 */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.step { position: relative; padding: 0 0 16px 28px; }
.step::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.step:last-child::before { display: none; }
.dot { position: absolute; left: 0; top: 3px; width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); }
.step.running .dot { border-color: var(--safelight); animation: pulse 1.2s ease-in-out infinite; }
.step.done .dot { border-color: var(--ok); background: var(--ok); }
.step.failed .dot { border-color: var(--warn); background: var(--warn); }
.step-title { font-weight: 600; font-size: 14.5px; }
.step-sub { color: var(--muted); font-size: 13px; }
.step-body { margin-top: 8px; display: grid; gap: 8px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--safelight-soft); } }
@media (prefers-reduced-motion: reduce) { .step.running .dot { animation: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); max-width: 100%; overflow-wrap: anywhere; }
.chip i { font-style: normal; color: var(--muted); margin-right: 4px; }
.chip.key { border-color: var(--safelight); }

.query { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.query summary { list-style: none; cursor: pointer; display: flex; gap: 8px; align-items: baseline; padding: 8px 10px; }
.query summary::-webkit-details-marker { display: none; }
.query .q { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.query .n { flex: none; color: var(--muted); font-size: 12px; }
.query .n.fail { color: var(--warn); }
.query ul { margin: 0; padding: 0 10px 8px; list-style: none; display: grid; gap: 6px; }
.query li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; }
.query li a { overflow-wrap: anywhere; text-decoration: none; }
.query li a:hover { text-decoration: underline; }
.query li small { grid-column: 2; color: var(--muted); }

.sid {
  display: inline-block; font: 600 10.5px/1 var(--font-mono); padding: 3px 4px; border-radius: 3px;
  background: var(--safelight-soft); color: var(--safelight); text-decoration: none; vertical-align: 2px; margin-left: 2px;
}

.note { font-size: 13px; color: var(--muted); background: var(--surface); border-left: 2px solid var(--line); padding: 8px 10px; }

/* 破案卡 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 4px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px dashed var(--line); color: var(--muted); }
.card-main { padding: 18px 14px 6px; display: grid; gap: 4px; position: relative; }
.stamp {
  justify-self: start; font: 700 13px/1 var(--font-display); letter-spacing: .2em; padding: 6px 10px 6px 12px;
  border: 2px solid currentColor; border-radius: 3px; transform: rotate(-3deg); margin-bottom: 8px;
}
.stamp.confirmed { color: var(--ok); background: var(--ok-soft); }
.stamp.uncertain { color: var(--warn); background: var(--warn-soft); }
.stamp.not_found { color: var(--none); background: var(--none-soft); }
.card-title { margin: 0; font: 700 26px/1.25 var(--font-display); letter-spacing: .03em; text-wrap: balance; overflow-wrap: anywhere; }
.card-meta { color: var(--muted); font-size: 13px; }
.card-sec { padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.card-sec h3 { margin: 0; font-size: 12px; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.card-sec p { margin: 0; }
.hits, .people, .others, .srcs, .unknowns { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hits li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; font-size: 14px; }
.hits .mk { font-weight: 700; }
.hits .mk.y { color: var(--ok); }
.hits .mk.n { color: var(--none); }
.hits small { grid-column: 2; color: var(--muted); }
.people li { display: grid; gap: 2px; padding: 10px; border-radius: 4px; background: var(--paper); }
.people .who { font-size: 12.5px; color: var(--muted); }
.people .role { font-weight: 600; }
.people .basis { font-size: 13px; color: var(--muted); }
.people .unsure .role { color: var(--muted); font-weight: 500; }
.others li, .unknowns li { font-size: 13.5px; }
.others b { font-weight: 600; }
.srcs li { display: grid; grid-template-columns: 30px 1fr; gap: 6px; font-size: 13.5px; align-items: baseline; scroll-margin-top: 16px; }
.srcs li.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 40% { background: var(--safelight-soft); } }
.srcs a { overflow-wrap: anywhere; }
.srcs small { grid-column: 2; color: var(--muted); }
.card-foot { padding: 10px 14px; border-top: 1px dashed var(--line); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }

.after { display: flex; gap: 10px; }
.after .btn { flex: 1; }

.error { color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 12px 14px; font-size: 14px; }

.foot { max-width: 560px; margin: 0 auto; padding-block: 8px 24px; color: var(--muted); font-size: 12px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 6px; font-size: 14px; z-index: 20;
}
