:root {
  --ink: #0e141c;
  --ink-2: #1a222d;
  --paper: #f3eee4;
  --paper-2: #e8e1d3;
  --cream: #faf7f1;
  --copper: #c56a2d;
  --copper-2: #e8b86d;
  --glacier: #2f7a78;
  --glacier-2: #7ebfb8;
  --heat: #c44738;
  --fog: #7d8693;
  --rule: rgba(14, 20, 28, 0.12);
  --rule-strong: rgba(14, 20, 28, 0.22);
  --shadow: 0 24px 60px rgba(14, 20, 28, 0.14);
  --serif-display: "Instrument Serif", "Noto Serif SC", "Songti SC", serif;
  --serif: "Source Serif 4", "Noto Serif SC", "Songti SC", "Times New Roman", serif;
  --sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --measure: 72ch;
  --wide: 1120px;
  --rail: 220px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html[data-lang="zh"] .t.en { display: none !important; }
html[data-lang="en"] .t.zh { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  font-size: clamp(17.5px, 1.15vw, 19.5px);
  line-height: 1.72;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.skip {
  position: absolute;
  left: 16px;
  top: -40px;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  z-index: 100;
}
.skip:focus { top: 16px; }

/* ——— chrome ——— */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  mix-blend-mode: difference;
  color: #f3eee4;
}
.topbar.is-solid {
  mix-blend-mode: normal;
  color: var(--ink);
  background: rgba(243, 238, 228, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
}
.brand svg { width: 22px; height: 22px; }
.brand-mark { color: var(--copper-2); }
.topbar.is-solid .brand-mark { color: var(--copper); }

.top-actions { display: flex; align-items: center; gap: 10px; }

.lang {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid currentColor;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.lang button { padding: 5px 10px; opacity: 0.55; }
.lang button[aria-pressed="true"] {
  opacity: 1;
  background: currentColor;
  color: var(--ink);
}
.topbar:not(.is-solid) .lang button[aria-pressed="true"] { color: #0e141c; }
.topbar.is-solid .lang button[aria-pressed="true"] { color: var(--paper); }

.toc-toggle, .menu-link {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* ——— progress ——— */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--copper), var(--copper-2));
  z-index: 60;
}

/* ——— rail ——— */
.rail {
  position: fixed;
  top: 50%;
  left: 22px;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail a {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(14, 20, 28, 0.35);
  background: transparent;
  text-indent: -999px;
  overflow: hidden;
  opacity: 0.55;
  transition: transform .25s var(--ease), background .25s, opacity .25s;
}
.rail a.is-active, .rail a:hover {
  background: var(--copper);
  border-color: var(--copper);
  opacity: 1;
  transform: scale(1.25);
}
.hero-on .rail a { border-color: rgba(243, 238, 228, 0.45); }
.hero-on .rail a.is-active { background: var(--copper-2); border-color: var(--copper-2); }

/* ——— hero ——— */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--cream);
  background: #070a0e center/cover no-repeat;
  display: grid;
  align-items: end;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7,10,14,0.18) 0%, rgba(7,10,14,0.22) 38%, rgba(7,10,14,0.78) 100%),
    radial-gradient(1200px 500px at 70% 20%, rgba(197,106,45,0.18), transparent 60%);
}
.hero-inner {
  position: relative;
  z-index: 1;
  width: min(var(--wide), calc(100% - 80px));
  margin: 0 auto 9vh;
}
.kicker {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--copper-2);
  margin: 0 0 18px;
}
.hero h1 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(42px, 6.4vw, 92px);
  line-height: 0.96;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
  max-width: 16ch;
}
.hero .lede {
  max-width: 46ch;
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.45;
  color: rgba(243, 238, 228, 0.84);
  margin: 0 0 36px;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 40px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(243, 238, 228, 0.7);
}
.hero-meta b {
  display: block;
  color: var(--cream);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 4px;
}
.scroll-hint {
  position: absolute;
  right: 36px;
  bottom: 36px;
  z-index: 1;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  opacity: 0.7;
}

/* ——— layout ——— */
.wrap {
  width: min(var(--wide), calc(100% - 64px));
  margin: 0 auto;
}
.prose { width: min(var(--measure), 100%); }

section.chapter {
  padding: 108px 0 40px;
  border-top: 1px solid var(--rule);
}
.chapter-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 36px;
}
.chap-no {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--copper);
}
.chapter h2 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(32px, 4.4vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0;
  max-width: 18ch;
}
.deck {
  font-size: 1.12em;
  color: #3a424c;
  max-width: 58ch;
  margin: 10px 0 0;
}

p { margin: 0 0 1.05em; }
.chapter p:last-child { margin-bottom: 0; }

h3 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(24px, 2.4vw, 32px);
  letter-spacing: -0.02em;
  margin: 2.2em 0 0.6em;
}
h4 {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 1.8em 0 0.6em;
  color: var(--glacier);
}

.pull {
  font-family: var(--serif-display);
  font-size: clamp(26px, 2.8vw, 36px);
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  border-left: 2px solid var(--copper);
  padding: 4px 0 4px 22px;
  margin: 2em 0;
  max-width: 28ch;
}

/* ——— metrics ——— */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule-strong);
  border: 1px solid var(--rule-strong);
  margin: 36px 0 44px;
}
.metric {
  background: var(--cream);
  padding: 22px 20px 20px;
}
.metric .n {
  font-family: var(--mono);
  font-size: clamp(26px, 2.6vw, 34px);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}
.metric .u {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  margin-top: 8px;
}
.metric .d {
  font-size: 0.86em;
  color: #4a5360;
  margin-top: 8px;
  line-height: 1.45;
}

/* ——— cards / grids ——— */
.grid-2, .grid-3, .grid-4 {
  display: grid;
  gap: 18px;
  margin: 28px 0 8px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--cream);
  border: 1px solid var(--rule);
  padding: 22px 22px 20px;
  min-height: 100%;
}
.card .tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--copper);
  margin-bottom: 10px;
}
.card h3, .card h4 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.level-1 { border-top: 3px solid #8b939e; }
.level-2 { border-top: 3px solid #3d7ea6; }
.level-3 { border-top: 3px solid var(--glacier); }

/* ——— figure plates ——— */
.plate {
  margin: 48px 0 56px;
}
.plate figure {
  margin: 0;
  background: #fff;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}
.plate img {
  width: 100%;
  cursor: zoom-in;
}
.plate figcaption {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  padding: 16px 20px 18px;
  border-top: 1px solid var(--rule);
  font-size: 0.86em;
  line-height: 1.55;
  color: #3d4550;
}
.plate-id {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--copper);
  padding-top: 3px;
}

/* ——— tables ——— */
.table-wrap {
  overflow-x: auto;
  margin: 28px 0 36px;
  border: 1px solid var(--rule);
  background: var(--cream);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 500;
  background: #efe8da;
}
tr:last-child td { border-bottom: 0; }

/* ——— timeline / roadmap ——— */
.roadmap {
  display: grid;
  gap: 0;
  margin: 28px 0 12px;
}
.road {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  padding: 22px 0;
  border-top: 1px solid var(--rule);
}
.road time {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--copper);
  padding-top: 4px;
}
.road h3 { margin: 0 0 8px; font-size: 26px; }

/* ——— gaps ——— */
.gap-grid { margin-top: 12px; }
.gap .impact {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid var(--rule);
  margin-right: 6px;
}
.hi { color: var(--heat); border-color: rgba(196, 71, 56, 0.35); }

/* ——— equation ——— */
.eq {
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  font-size: 1.15em;
  margin: 28px 0;
  padding: 22px;
  background: var(--cream);
  border: 1px dashed var(--rule-strong);
}
.eq-note {
  font-style: normal;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fog);
  margin-top: 10px;
}

/* ——— callout ——— */
.note {
  background: #ece6d8;
  border-left: 3px solid var(--glacier);
  padding: 16px 18px;
  margin: 28px 0;
  font-size: 0.94em;
}
.note strong { font-family: var(--sans); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }

/* ——— how-to ——— */
.howto {
  background: var(--ink);
  color: var(--cream);
  padding: 88px 0;
}
.howto h2 { color: var(--cream); }
.howto .deck { color: rgba(243, 238, 228, 0.72); }
.howto .card {
  background: #161d27;
  border-color: rgba(243, 238, 228, 0.1);
  color: var(--cream);
}
.howto .card .tag { color: var(--copper-2); }

/* ——— cite ——— */
cite, .cite {
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.92em;
}

/* ——— footer ——— */
footer {
  background: var(--ink);
  color: rgba(243, 238, 228, 0.72);
  padding: 72px 0 40px;
  font-size: 0.92em;
}
footer h2 {
  font-family: var(--serif-display);
  color: var(--cream);
  font-weight: 400;
  font-size: 36px;
  margin: 0 0 12px;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 36px;
  margin-top: 36px;
}
footer a { color: var(--copper-2); text-underline-offset: 3px; }
.colophon {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid rgba(243, 238, 228, 0.12);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* ——— lightbox ——— */
.lb {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 14, 0.92);
  display: none;
  place-items: center;
  z-index: 90;
  padding: 40px;
}
.lb.is-open { display: grid; }
.lb img { max-height: 88vh; max-width: 92vw; box-shadow: 0 20px 80px rgba(0,0,0,.45); }
.lb button {
  position: absolute;
  top: 18px;
  right: 22px;
  color: #fff;
  font-size: 28px;
}

/* ——— drawer TOC ——— */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 92vw);
  height: 100%;
  background: var(--paper);
  z-index: 70;
  transform: translateX(104%);
  transition: transform .45s var(--ease);
  border-left: 1px solid var(--rule);
  padding: 84px 28px 40px;
  overflow: auto;
}
.drawer.is-open { transform: none; }
.drawer ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.drawer a {
  display: grid;
  grid-template-columns: 2.2em 1fr;
  gap: 10px;
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif-display);
  font-size: 22px;
  line-height: 1.2;
}
.drawer a span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--copper);
  padding-top: 6px;
}
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 20, 28, 0.35);
  z-index: 65;
  display: none;
}
.backdrop.is-open { display: block; }

/* ——— 404 ——— */
.err {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}
.err h1 {
  font-family: var(--serif-display);
  font-size: 72px;
  margin: 0 0 12px;
}

/* ——— responsive ——— */
@media (max-width: 980px) {
  .metrics, .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3, .foot-grid { grid-template-columns: 1fr 1fr; }
  .rail { display: none; }
  .wrap, .hero-inner { width: min(100% - 36px, var(--wide)); }
}
@media (max-width: 680px) {
  .metrics, .grid-2, .grid-3, .grid-4, .foot-grid { grid-template-columns: 1fr; }
  .road { grid-template-columns: 1fr; gap: 6px; }
  .hero { align-items: end; }
  .topbar { padding: 12px 16px; }
  .scroll-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .topbar, .rail, .progress, .scroll-hint, .toc-toggle, .lang { display: none !important; }
  .hero { min-height: auto; color: #000; background: none !important; padding: 20px 0; }
  .hero::after { display: none; }
  body { background: #fff; color: #000; }
  .t.en { display: none !important; }
}
