/* 物质侦探：夜里的实验台，米白档案卡。标题用仓库里自带的衬线子集字体（fonts/font.css，tools/subset-font.mjs 生成），正文用系统无衬线字体。 */
:root {
  --bench: #15201c;
  --bench-2: #1d2b26;
  --paper: #f3eee2;
  --paper-2: #e9e2d1;
  --line: #d8cfbb;
  --ink: #23201b;
  --ink-2: #6b665c;
  /* 说不准的格子里的字：纸上 4.65:1、白底 5.38:1。"说不准"靠～前缀、虚线框和淡图形区分，不靠浅色字 */
  --unsure-ink: #6f6a5f;
  --brass: #c98f2a;
  --brass-ink: #1d1608;
  --good: #2f7d5b;
  --bad: #a8371f;
  --serif: "Detective Serif", "Noto Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bench); color: var(--ink); }
body {
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  background: radial-gradient(120% 60% at 50% 0%, #22332d 0%, var(--bench) 60%) fixed;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.ico { flex: none; display: inline-block; vertical-align: -0.2em; }

/* 按钮 */
.btn {
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--ink);
  background: transparent; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--brass); border-color: #9c6c16; color: var(--brass-ink); box-shadow: 0 2px 0 #8a5e12; }
.btn.primary:active { transform: translateY(2px); box-shadow: none; }
.btn.ghost { border-color: rgba(243, 238, 226, .35); color: var(--paper); background: rgba(255, 255, 255, .04); }
.btn.outline { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.wide { width: 100%; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; min-height: 44px; padding: 0 10px; }

/* 首页 */
.home { padding: 14px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); color: var(--paper); }
.home-head { text-align: center; margin: 4px 0 20px; }
.hero { width: 100%; max-width: 320px; height: 120px; display: block; margin: 0 auto 4px; }
.home-head .start { margin-top: 14px; min-height: 52px; font-size: 17px; }
.daily-later { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.streak { color: #9c6c16; font-weight: 700; white-space: nowrap; }
.brand { font-family: var(--serif); font-size: 40px; font-weight: 700; letter-spacing: .14em; color: var(--paper); }
.brand::after { content: ""; display: block; width: 64px; height: 3px; background: var(--brass); margin: 10px auto 0; border-radius: 2px; }
.tagline { margin: 10px auto 0; color: #d9d2c2; max-width: 22em; text-wrap: balance; }
h1, h2, h3, h4, .brand, .case-title, .sheet-title, .answer { text-wrap: balance; }
.card {
  background: var(--paper); color: var(--ink); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 10px 30px rgba(0, 0, 0, .35); border: 1px solid var(--line);
}
.daily-card { margin-bottom: 22px; background: linear-gradient(180deg, #fbf6ea, var(--paper)); }
.cases + .cases { margin-top: 22px; }
.daily-top { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 19px; font-weight: 700; }
.daily-top .muted { margin-left: auto; font-family: var(--sans); font-size: 14px; font-weight: 400; }
.daily-sub { margin: 6px 0 14px; color: var(--ink-2); }
.section-title { font-family: var(--serif); font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.home .section-title { color: var(--paper); }
.home .section-title .muted { color: #a59f90; font-family: var(--sans); font-size: 13px; font-weight: 400; }
.case-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.case-tile {
  min-height: 92px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 10px; text-align: left;
}
.case-tile .case-no { font-size: 12px; color: var(--ink-2); }
.case-tile .case-title { font-family: var(--serif); font-weight: 700; font-size: 15px; line-height: 1.25; }
.case-tile .case-meta { font-size: 12px; color: var(--ink-2); letter-spacing: .05em; }
.case-tile.done .case-meta { color: #9c6c16; font-size: 14px; }
.case-tile.next { outline: 3px solid var(--brass); outline-offset: 1px; }
.home-foot { margin-top: 24px; display: grid; gap: 12px; }
.fine { font-size: 12px; color: #a59f90; margin: 0; text-align: center; }

/* 结案页 */
.result { padding: 14px max(14px, env(safe-area-inset-right)) 28px max(14px, env(safe-area-inset-left)); display: grid; gap: 12px; }
.result-card { text-align: center; position: relative; padding-top: 18px; }
.stars-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0; }
.stamp {
  font-family: var(--serif); font-weight: 900; font-size: 24px; color: var(--good); flex: none;
  border: 3px solid var(--good); border-radius: 8px; padding: 0 10px; transform: rotate(-12deg); opacity: .9;
  animation: stamp .45s .2s cubic-bezier(.2, 1.6, .4, 1) both;
}
.result-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 8px; }
.fold > summary { cursor: pointer; list-style: none; margin: 0; min-height: 28px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "展开"; margin-left: auto; font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--ink-2); }
.fold[open] > summary::after { content: "收起"; }
.fold[open] > summary { margin-bottom: 10px; }
.codex-name { font-family: var(--serif); font-size: 16px; margin: 10px 0 2px; }
.detail { font-size: 13px; color: #4a463e; margin: 6px 0 0; }
@keyframes stamp { from { transform: rotate(-30deg) scale(2.4); opacity: 0; } to { transform: rotate(-12deg) scale(1); opacity: .9; } }
.result-kicker { margin: 0; color: var(--ink-2); font-size: 13px; }
.answer { font-family: var(--serif); font-size: 28px; margin: 6px 0 0; }
.formula { font-family: "Noto Serif", Georgia, serif; color: var(--ink-2); }
.formula.big { font-size: 18px; margin: 2px 0 8px; }
.mix-clues { font-size: 13.5px; line-height: 1.45; margin: 2px 4px 6px; color: #4a463e; }
.mix-clues b { color: var(--ink); margin-right: 6px; }
.stars { line-height: 1; display: flex; gap: 4px; }
.star { display: inline-block; animation: pop .4s both; }
.star-ico path { fill: var(--brass); stroke: #8a5e12; stroke-width: 1.2; stroke-linejoin: round; transition: fill .2s, stroke .2s; }
.star-ico.off path { fill: none; stroke: #8f8672; stroke-width: 1.6; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.25); } to { transform: scale(1); opacity: 1; } }
.score { margin: 6px 0 2px; }
.score b { font-size: 20px; }
.clues, .par-path { margin: 0 0 14px; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.clues li, .par-path li { background: var(--paper-2); border-radius: 10px; padding: 8px 10px; }
.clues li.unclear { border: 1.5px dashed #7f796c; background: transparent; }
.clues .ico, .par-path .ico { margin-right: 4px; color: var(--ink-2); }
.codex-card p { margin: 6px 0; }
.hazard { color: var(--bad); font-weight: 600; }
.share-box {
  white-space: pre-wrap; font-family: var(--sans); background: var(--bench); color: var(--paper); border-radius: 10px;
  padding: 12px; margin: 0 0 12px; font-size: 15px; line-height: 1.6;
}
.result-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.result-actions .btn:not(.primary) { color: var(--paper); border-color: rgba(243, 238, 226, .45); }

/* 标签 */
.chip { display: inline-block; font-size: 11.5px; line-height: 1; padding: 4px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.chip.clear { background: var(--ink); color: var(--paper); }
.chip.unclear { border: 1.5px dashed #7f796c; color: var(--ink-2); background: transparent; }
.tag.unsure { border: 1.5px dashed #7f796c; color: #6b665c; font-size: 11px; padding: 0 5px; border-radius: 5px; }
.evidence { font-size: 13.5px; color: var(--ink); }
.unsure-line { font-size: 13.5px; color: #6b665c; border-left: 3px dashed #7f796c; padding-left: 8px; }
.untested-line { font-size: 13px; color: #6b4d0f; background: #f5e3b5; border-radius: 8px; padding: 6px 10px; }
.tag { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 6px; margin-right: 6px; vertical-align: 1px; }
.tag.rule { background: #e3dccb; color: #5d574b; }
.tag.untested { background: #f5e3b5; color: #6b4d0f; margin-left: 6px; }
.tag.faint { border: 1px dashed #8b8578; color: var(--ink-2); }

/* 底部弹出卡片 */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 10, .55); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; max-height: 86vh; overflow: auto;
  background: var(--paper); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s ease-out both; box-shadow: 0 -10px 30px rgba(0, 0, 0, .3);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-title { font-family: var(--serif); font-size: 19px; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.sheet-head .sheet-title { margin: 0; }
.sheet-title small { font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--ink-2); }
.cost.big { margin-left: auto; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.procedure { font-size: 16px; background: var(--paper-2); border-radius: 10px; padding: 10px 12px; margin: 12px 0 8px; }
.note { font-size: 13.5px; color: #4a463e; margin: 8px 0; }
.safety { font-size: 13.5px; color: var(--bad); margin: 8px 0; display: flex; gap: 6px; align-items: flex-start; }
.safety .ico { margin-top: 2px; }
.missing-note { color: var(--bad); font-weight: 600; }
.cell-text { font-size: 16px; margin: 12px 0 8px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 14px; }
.codex { display: grid; gap: 10px; margin: 10px 0 14px; }
.codex .codex-card { background: var(--paper-2); border-radius: 10px; padding: 10px 12px; }
.codex .codex-card p { margin: 4px 0; }
.codex-locked { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.codex-card.locked { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--paper-2); border-radius: 10px; padding: 8px 4px; }
.nowrap { white-space: nowrap; display: inline-block; }
.jar rect, .jar path { fill: none; stroke: #8f8672; stroke-width: 2; }
.jar text { fill: #8f8672; font-size: 16px; font-weight: 800; font-family: var(--serif); }
.fingerprint { display: flex; gap: 3px; margin: 6px 0; }
.fp { display: flex; flex-direction: column; align-items: center; gap: 1px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px 1px; flex: 1; }
.fp.unclear { border: 1.5px dashed #7f796c; background: transparent; }
.fp.unclear .glyph * { fill-opacity: .35; }
.fp small { color: var(--ink-2); line-height: 1; }
.codex h4 { margin: 0 0 4px; font-family: var(--serif); }
.notebook { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.nb-item { display: flex; gap: 10px; background: var(--paper-2); border-radius: 10px; padding: 8px 10px; }
.nb-item.unclear { background: transparent; border: 1.5px dashed #7f796c; color: #4a463e; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.examples figure { margin: 0; background: var(--paper-2); border-radius: 10px; padding: 8px; }
.examples figcaption { font-size: 12.5px; margin-top: 6px; color: #4a463e; }
.ex { display: grid; gap: 3px; }
.ex-row { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ex-row.sample .ex-name { color: #9c6c16; font-weight: 700; }
.ex-name { width: 2.4em; }
.ex-cell { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 22px; border-radius: 5px; background: #fff; border: 1px solid var(--ink); font-size: 12px; }
.ex-cell.dashed { background: var(--paper); border: 1.5px dashed #7f796c; color: var(--unsure-ink); }
.ex-row.gone { opacity: .45; text-decoration: line-through; text-decoration-thickness: 2px; }
.next-in { margin: 0; align-self: center; text-align: center; color: var(--ink-2); }
.next-in b { font-variant-numeric: tabular-nums; color: var(--ink); font-size: 18px; }
.nb-item.accuse.bad { border-left: 4px solid var(--bad); }
.nb-item.accuse.ok { border-left: 4px solid var(--good); }
.nb-no { font-family: var(--serif); font-weight: 700; color: var(--ink-2); min-width: 1.2em; }
.nb-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); max-width: min(92vw, 440px); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-pos="top"] { top: 16px; bottom: auto; transform: translate(-50%, -20px); }
.toast[data-pos="top"].show { transform: translate(-50%, 0); }
.toast.bad { background: #a93a24; }
.toast.good { background: #286b4e; }
.toast.warn { background: #3a3326; border: 1.5px solid var(--brass); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
