/* Layout: 左侧为项目与章节导航（像一份报告的目录），右侧为当前章节的工作台 */
:root {
  --paper: #f4f6f4;
  --surface: #ffffff;
  --sunk: #eceff0;
  --ink: #16212a;
  --muted: #5a6870;
  --line: #d9dfdd;
  --accent: #0d6a62;
  --accent-ink: #ffffff;
  --accent-soft: #dcece9;
  --strong: #2d7a49;
  --mid: #a7801a;
  --weak: #c05f1e;
  --missing: #a63a3a;
  --danger: #b03a2e;
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-body: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f161a; --surface: #162026; --sunk: #1c282f; --ink: #e3eae8; --muted: #95a5aa; --line: #2a383f;
    --accent: #4db3a5; --accent-ink: #08201d; --accent-soft: #173936;
    --strong: #5cb87c; --mid: #d4ad48; --weak: #e48a4a; --missing: #e06a6a; --danger: #e06a5c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f161a; --surface: #162026; --sunk: #1c282f; --ink: #e3eae8; --muted: #95a5aa; --line: #2a383f;
  --accent: #4db3a5; --accent-ink: #08201d; --accent-soft: #173936;
  --strong: #5cb87c; --mid: #d4ad48; --weak: #e48a4a; --missing: #e06a6a; --danger: #e06a5c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.65; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; line-height: 1.3; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font-family: var(--font-display); font-size: 18px; letter-spacing: .02em; }
.brand span { color: var(--muted); font-size: 12px; }
.brand .home-link { margin-top: 6px; font-size: 12px; color: var(--accent); text-decoration: none; }
.brand .home-link:hover { text-decoration: underline; }
.proj { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 11px; letter-spacing: .08em; color: var(--muted); }
select, input[type=text], input[type=number], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 9px; width: 100%; }
textarea { resize: vertical; line-height: 1.6; }
nav.toc { display: flex; flex-direction: column; gap: 1px; }
nav.toc a { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 4px; padding: 6px 8px; border-radius: var(--r); color: var(--ink); text-decoration: none; }
nav.toc a:hover { background: var(--sunk); }
nav.toc a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.toc .no { font-family: var(--font-display); color: var(--muted); font-size: 13px; }
nav.toc a.on .no { color: var(--accent); }
nav.toc .grp { font-size: 11px; letter-spacing: .08em; color: var(--muted); padding: 12px 8px 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line); }
.dot.draft { background: var(--mid); border-color: var(--mid); }
.dot.approved { background: var(--strong); border-color: var(--strong); }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); }

main { padding-block: 28px 64px; padding-left: 32px; padding-right: max(32px, env(safe-area-inset-right, 0px)); min-width: 0; }
.wrap { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.banner { background: var(--accent-soft); color: var(--ink); border-radius: var(--r); padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: 13px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.head h1 { font-size: 26px; }
.head .eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .06em; margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.chip.draft { background: color-mix(in srgb, var(--mid) 16%, transparent); color: var(--mid); }
.chip.approved { background: color-mix(in srgb, var(--strong) 16%, transparent); color: var(--strong); }
.chip.err { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-size: 12px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 6px 13px; border-radius: var(--r); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 3px 9px; font-size: 12px; }
a.btn { color: inherit; text-decoration: none; text-align: center; }

.brief { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.brief dt { color: var(--muted); font-size: 12px; padding-top: 7px; }
.brief dd { margin: 0; min-width: 0; padding-top: 6px; }
.brief dd input { margin-top: -6px; }
.brief a { color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }

.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 26px; min-width: 0; }
.doc.empty { color: var(--muted); text-align: center; padding: 40px 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.md { max-width: 72ch; }
.md h2 { font-size: 19px; margin: 6px 0 12px; }
.md h3 { font-size: 16px; margin: 20px 0 8px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 10px; }
.md strong { color: var(--ink); }
.md table, .tbl { border-collapse: collapse; width: 100%; font-size: 13px; margin: 6px 0 14px; }
.md th, .md td, .tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th, .tbl th { background: var(--sunk); font-weight: 600; font-size: 12px; }
.scroll { overflow-x: auto; max-width: 100%; }
.md .scroll { margin: 6px 0 14px; }
.streaming::after { content: "▍"; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .streaming::after { animation: none; } }
.note { font-size: 12px; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-family: var(--font-mono); font-size: 22px; font-weight: 500; }
.tile .s { font-size: 12px; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.panel h3 { font-size: 14px; margin-bottom: 10px; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: 74px minmax(0, 1fr) 64px; gap: 8px; align-items: center; font-size: 12px; }
.bar .track { display: block; height: 10px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar .n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.chain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stage { background: var(--sunk); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stage h3 { font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; }
.stage h3 small { font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--muted); }
.link { background: var(--surface); border-radius: var(--r); padding: 8px 10px; border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.link b { font-size: 13px; }
.link .d { font-size: 12px; color: var(--muted); }
.link .p { font-size: 12px; }
.link.l-强 { border-left-color: var(--strong); }
.link.l-中 { border-left-color: var(--mid); }
.link.l-弱 { border-left-color: var(--weak); }
.link.l-缺失 { border-left-color: var(--missing); border-left-style: dashed; }
.lv { align-self: flex-start; border: 0; cursor: pointer; font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.lv.l-强 { background: color-mix(in srgb, var(--strong) 18%, transparent); color: var(--strong); }
.lv.l-中 { background: color-mix(in srgb, var(--mid) 18%, transparent); color: var(--mid); }
.lv.l-弱 { background: color-mix(in srgb, var(--weak) 18%, transparent); color: var(--weak); }
.lv.l-缺失 { background: color-mix(in srgb, var(--missing) 18%, transparent); color: var(--missing); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); align-items: center; }

.scorewrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.radar text { fill: var(--muted); font-size: 11px; }
.radar .ax { stroke: var(--line); fill: none; }
.radar .area { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 2; }
.radar .pt { fill: var(--accent); }
.total { display: flex; align-items: baseline; gap: 10px; }
.total .v { font-family: var(--font-mono); font-size: 40px; font-weight: 500; }
.grade { font-family: var(--font-display); font-size: 20px; padding: 0 10px; border-radius: var(--r); background: var(--accent-soft); color: var(--accent); }
.dimrow td:first-child { width: 34%; }
.sc { width: 64px; padding: 3px 4px; }
.ev { min-height: 34px; font-size: 12px; padding: 4px 6px; }
.dimhead th { background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-size: 14px; }
.tip { font-size: 11px; color: var(--muted); display: block; }

.mat { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mat:last-child { border-bottom: 0; }
.mat .nm { font-weight: 600; overflow-wrap: anywhere; }
.drop { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.step b { font-family: var(--font-display); }
.step .note { flex: 1; }
.confirm { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; }
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--r); font-size: 13px; z-index: 20; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  nav.toc { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  nav.toc a { display: flex; gap: 6px; white-space: nowrap; }
  nav.toc a .dot { display: none; }
  nav.toc .grp { display: none; }
  .side .foot { display: none; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px 48px; }
  .chain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scorewrap { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 16px; }
}
@media (max-width: 480px) {
  .chain { grid-template-columns: minmax(0, 1fr); }
  .brief { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .brief dt { padding-top: 8px; }
}
