:root {
  --paper: #f7f4ee;
  --paper-2: #efeae1;
  --card: #fffdf9;
  --ink: #1f2328;
  --ink-soft: #5d636c;
  --ink-faint: #8a8f96;
  --rule: #e2dccf;
  --accent: #3f6178;        /* 雪峰蓝灰 */
  --accent-soft: #e3eaef;
  --warm: #c96442;          /* 系列主色 */
  --t1: #3f6178;
  --t2: #6f7f5a;
  --t3: #9a8a72;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --kai: "Kaiti SC", "STKaiti", "Songti SC", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* progress */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; }
.progress i { display: block; height: 100%; width: 0; background: var(--warm); transition: width .08s linear; }

/* top bar */
.top { position: sticky; top: 0; z-index: 50; background: rgba(247, 244, 238, .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--rule); }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.seal { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 20px; }
.brand strong { display: block; font-family: var(--serif); font-size: 17px; letter-spacing: .06em; }
.brand em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink-faint); letter-spacing: .08em; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.topnav a { color: var(--ink-soft); font-size: 14px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.topnav a:hover { background: var(--paper-2); text-decoration: none; color: var(--ink); }
.topnav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* doc layout */
.doc-shell { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 56px; }
.toc { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 88px); overflow: auto; padding: 28px 0 40px; scrollbar-width: thin; }
.toc-head { font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--ink); padding: 0 0 12px 12px; display: flex; justify-content: space-between; align-items: center; }
.toc-close { display: none; border: 0; background: none; font-size: 24px; color: var(--ink-soft); cursor: pointer; }
.toc-body a { display: block; color: var(--ink-soft); font-size: 13.5px; line-height: 1.45; padding: 6px 10px 6px 12px; border-left: 2px solid transparent; }
.toc-body a:hover { color: var(--ink); text-decoration: none; background: var(--paper-2); }
.toc-body a.toc-l3 { padding-left: 26px; font-size: 12.5px; color: var(--ink-faint); }
.toc-body a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.doc { min-width: 0; max-width: 760px; padding: 40px 0 80px; }

.doc-hero { margin: 8px 0 36px; padding-bottom: 28px; border-bottom: 1px solid var(--rule); }
.kicker { font-size: 12.5px; letter-spacing: .22em; color: var(--warm); margin: 0 0 10px; }
.doc-hero h1 { font-family: var(--serif); font-size: 40px; line-height: 1.25; margin: 0 0 14px; letter-spacing: .02em; }
.lede { color: var(--ink-soft); font-size: 15.5px; line-height: 1.8; margin: 0 0 10px; }
.meta { color: var(--ink-faint); font-size: 13px; margin: 0; }

/* prose */
.prose { font-size: 17px; line-height: 1.95; letter-spacing: .01em; }
.prose h2 { font-family: var(--serif); font-size: 27px; line-height: 1.4; margin: 64px 0 20px; padding-top: 8px; color: var(--ink); }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-family: var(--serif); font-size: 21px; line-height: 1.5; margin: 44px 0 14px; color: var(--ink); }
.prose h4 { font-size: 17px; margin: 32px 0 10px; }
.prose p { margin: 0 0 1.15em; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose hr { border: 0; height: 1px; background: var(--rule); margin: 48px auto; width: 40%; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.prose li { margin: .35em 0; }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--rule); color: var(--ink-soft); }
.prose p.q { font-family: var(--kai); font-size: 17.5px; line-height: 1.9; color: #2b3138; background: var(--card); border-left: 3px solid var(--accent); padding: 14px 18px 14px 20px; margin: 1.3em 0; border-radius: 0 8px 8px 0; box-shadow: 0 1px 0 var(--rule); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 1.4em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: 8px 10px; text-align: left; vertical-align: top; line-height: 1.6; }
.prose th { font-weight: 650; background: var(--paper-2); }
.prose code { font-size: .88em; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }

/* citation chip */
.cite { display: inline-block; font-family: var(--sans); font-size: 11.5px; line-height: 1; padding: 3px 6px 3px; margin: 0 2px; border-radius: 4px; vertical-align: 2px; letter-spacing: .02em; color: #fff; white-space: nowrap; }
.cite:hover { text-decoration: none; filter: brightness(1.12); }
.cite.t1 { background: var(--t1); }
.cite.t2 { background: var(--t2); }
.cite.t3 { background: var(--t3); }
.ed-note { font-size: 13px; color: var(--ink-faint); }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 72px; }
.pager a { display: block; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); color: var(--ink); font-family: var(--serif); font-size: 17px; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { display: block; font-family: var(--sans); font-size: 12px; color: var(--ink-faint); margin-bottom: 4px; }
.pager .next { text-align: right; }

/* mobile toc */
.toc-fab { display: none; position: fixed; right: 18px; bottom: 22px; z-index: 55; border: 0; border-radius: 22px; padding: 11px 18px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer; }
.scrim { position: fixed; inset: 0; background: rgba(20, 22, 26, .35); z-index: 56; }

/* home */
.home { max-width: 1040px; margin: 0 auto; padding: 56px 24px 40px; }
.hero { max-width: 760px; margin-bottom: 48px; }
.hero h1 { font-family: var(--serif); font-size: 64px; margin: 6px 0 12px; letter-spacing: .08em; }
.role { color: var(--ink-soft); font-size: 15.5px; line-height: 1.8; margin: 0 0 28px; }
.epigraph { font-family: var(--kai); font-size: 20px; line-height: 1.85; margin: 0; padding: 20px 24px; background: var(--card); border-left: 3px solid var(--warm); border-radius: 0 10px 10px 0; color: #2b3138; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 56px; }
.doc-card { position: relative; display: flex; flex-direction: column; padding: 26px 22px 20px; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; color: var(--ink); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.doc-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 28px rgba(63, 97, 120, .12); text-decoration: none; }
.doc-card .num { font-family: var(--serif); font-size: 15px; color: var(--warm); letter-spacing: .1em; }
.doc-card h3 { font-family: var(--serif); font-size: 24px; margin: 8px 0 12px; }
.doc-card h3 small { display: block; font-size: 14px; color: var(--ink-faint); font-weight: 400; margin-top: 4px; }
.doc-card p { color: var(--ink-soft); font-size: 14.5px; line-height: 1.8; margin: 0 0 18px; flex: 1; }
.card-meta { font-size: 12px; color: var(--ink-faint); border-top: 1px dashed var(--rule); padding-top: 12px; }
.howto, .method { max-width: 760px; margin-bottom: 44px; }
.howto h2, .method h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 14px; }
.howto ul { margin: 0; padding-left: 1.2em; line-height: 2; color: var(--ink-soft); font-size: 15.5px; }
.method p { color: var(--ink-soft); font-size: 15px; line-height: 1.9; }
.method .note { font-size: 13px; color: var(--ink-faint); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 18px; }
.facts div { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 14px 12px; }
.facts b { display: block; font-family: var(--serif); font-size: 22px; color: var(--accent); }
.facts span { font-size: 12.5px; color: var(--ink-faint); }

/* plain pages */
.plain { max-width: 900px; margin: 0 auto; padding: 40px 24px 60px; }
.src-group { margin: 0 0 40px; }
.src-group h2 { font-family: var(--serif); font-size: 21px; display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.src-group h2 small { font-family: var(--sans); font-size: 13px; color: var(--ink-faint); font-weight: 400; }
.tier { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; color: #fff; font-size: 13px; font-family: var(--sans); }
.tier.t1 { background: var(--t1); } .tier.t2 { background: var(--t2); } .tier.t3 { background: var(--t3); }
.src { display: grid; grid-template-columns: 108px minmax(0, 1fr) 150px; gap: 14px; padding: 11px 8px; border-bottom: 1px solid var(--rule); font-size: 14.5px; line-height: 1.6; scroll-margin-top: 80px; }
.src:target { background: var(--accent-soft); border-radius: 6px; }
.src-date { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 13px; }
.src-main small { display: block; color: var(--ink-faint); font-size: 12.5px; }
.src-cited { color: var(--ink-soft); font-size: 12.5px; text-align: right; }

/* footer */
.foot { border-top: 1px solid var(--rule); }
.foot-inner { max-width: 1240px; margin: 0 auto; padding: 22px 24px 30px; display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--ink-faint); flex-wrap: wrap; }

@media (max-width: 980px) {
  .doc-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 320px); max-height: none; background: var(--paper); z-index: 57; padding: 20px 8px 40px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 4px 0 24px rgba(0,0,0,.12); }
  .toc.open { transform: none; }
  .toc-close { display: block; }
  .toc-fab { display: block; }
  .doc { padding-top: 24px; margin: 0 auto; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .topnav { display: none; }
}
@media (max-width: 560px) {
  .prose { font-size: 16.5px; line-height: 1.9; }
  .doc-hero h1 { font-size: 30px; }
  .prose h2 { font-size: 23px; margin-top: 52px; }
  .prose h3 { font-size: 19px; }
  .hero h1 { font-size: 46px; }
  .epigraph { font-size: 17.5px; padding: 16px 18px; }
  .src { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .src-cited { text-align: left; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { text-align: left; }
}
@media print {
  .top, .toc, .toc-fab, .progress, .pager, .foot { display: none !important; }
  .doc-shell { display: block; }
  body { background: #fff; }
}
