/* ============================================================
   看得见的大模型 - design tokens  (喜茶风 · 浅色为主)
   light default + dark, accent: 茶色/酱红, radius: 16/10/pill
   ============================================================ */

:root {
  --bg:        #fdfbf7;   /* 奶白 */
  --bg-2:      #f7f3ec;   /* 浅奶油 */
  --surface:   #ffffff;   /* 白卡 */
  --surface-2: #f9f5ee;   /* 暖米色 */
  --line:      #ece5da;   /* 极浅暖灰 */
  --line-soft: #f2ecdf;

  --text:      #3a332c;   /* 深棕黑 */
  --read:      #4e463e;   /* 正文，比 dim 够读 */
  --dim:       #8b8177;   /* 暖灰 */
  --faint:     #b7ada2;   /* 浅暖灰 */

  --accent:      #9c4a2f;  /* 酱红/普洱 */
  --accent-ink:  #7c3a24;
  --accent-on:   #fff8f0;
  --accent-soft: rgba(156, 74, 47, .10);
  --accent-line: rgba(156, 74, 47, .28);
  --accent-deep: #7c3a24;

  --heat:   156, 74, 47;
  --serieB: #c7864a;   /* 奶茶色 */

  --r: 22px;
  --r-sm: 10px;
  --r-pill: 999px;
  --rail-w: 220px;
  --top-h: 64px;

  --font-head: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
                Georgia, "Times New Roman", serif;   /* Claude 衬线大标题 */
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #16130f;
  --bg-2:      #1e1a14;
  --surface:   #262019;
  --surface-2: #2f2820;
  --line:      #3a322a;
  --line-soft: #2e2820;

  --text:      #f2ede6;
  --read:      #e6dfd6;
  --dim:       #b5aba0;
  --faint:     #7d7368;

  --accent:      #c7864a;
  --accent-ink:  #d99a63;
  --accent-on:   #1a130c;
  --accent-soft: rgba(199, 134, 74, .16);
  --accent-line: rgba(199, 134, 74, .38);
  --accent-deep: #a56a35;

  --heat:   199, 134, 74;
  --serieB: #7fb8e0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .3s, color .3s;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.accent { color: var(--accent-ink); }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line-soft);
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font-weight: 600; letter-spacing: .01em;
}
.brand-mark {
  width: 20px; height: 20px; border-radius: var(--r-sm);
  background: linear-gradient(140deg, var(--accent), var(--serieB));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
}
.brand-name { font-size: 15px; font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.pagelinks { display: flex; align-items: center; gap: 8px; }
.pagelink {
  padding: 7px 16px; border-radius: var(--r-pill);
  color: var(--dim); text-decoration: none;
  font-size: 13.5px; transition: color .18s, background .18s;
}
.pagelink-sep {
  width: 1px;
  height: 14px;
  margin: 0 4px;
  flex: 0 0 1px;
  background: var(--faint);
  opacity: .7;
}
.pagelink:hover { color: var(--text); background: var(--surface-2); }
.pagelink.is-on { color: var(--accent-on); background: var(--accent); font-weight: 600; }

.theme-btn {
  appearance: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--dim);
  display: grid; place-items: center;
  transition: all .18s;
}
.theme-btn:hover { color: var(--text); border-color: var(--faint); }
.theme-btn:focus-visible,
.pagelink:focus-visible,
.chap-jump:focus-visible,
.btn:focus-visible,
.rail-list a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-btn:active { transform: scale(.94); }
.theme-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.progress i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .1s linear; }
.progress-chap {
  position: fixed; right: 18px; top: 78px;
  font-family: var(--font-head); font-size: 14px; font-weight: 620;
  color: var(--faint); letter-spacing: -.01em;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 42ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.progress-chap.show { opacity: 1; transform: none; }
@media (max-width: 900px) { .progress-chap { max-width: 60vw; } }

/* ============================================================
   RAIL
   ============================================================ */
.rail {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--rail-w);
  padding: 26px 0 40px 22px; overflow-y: auto; z-index: 30;
  border-right: 1px solid var(--line-soft);
}
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { margin: 0 0 1px; }
.rail-list a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 10px 7px 12px; margin-left: -12px;
  color: var(--dim); text-decoration: none;
  font-size: 14.5px; line-height: 1.5;
  border-left: 2px solid transparent;
  transition: color .18s, border-color .18s;
}
.rail-list a b {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--dim); letter-spacing: .04em; transition: color .18s;
}
.rail-list a:hover { color: var(--text); }
.rail-list a:hover b { color: var(--accent-ink); }
.rail-list a.is-on { color: var(--text); border-left-color: var(--accent); }
.rail-list a.is-on b { color: var(--accent-ink); }

.chap-jump { display: none; }
.rail-sep {
  margin: 22px 0 10px; padding-left: 0;
  font-size: 12.5px; letter-spacing: .1em; color: var(--dim);
  text-transform: uppercase; font-family: var(--mono); font-weight: 600;
}
.rail-sep-tight { margin-top: 12px; }

/* ============================================================
   LAYOUT
   ============================================================ */
main { margin-left: var(--rail-w); padding-top: var(--top-h); }
.ch, .hero, .foot-in { max-width: 900px; margin: 0 auto; padding: 0 48px; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center;
  min-height: calc(100dvh - var(--top-h) - 70px);
  max-width: 1160px; padding-top: 40px;
}
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(44px, 5.8vw, 72px); line-height: 1.06;
  letter-spacing: -.02em; font-weight: 600; margin: 0 0 24px;
}
.hero-sub { color: var(--dim); font-size: 17px; line-height: 1.75; max-width: 40ch; margin: 0 0 34px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-viz {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(135deg, var(--surface), var(--bg-2));
  overflow: hidden; aspect-ratio: 720 / 520;
  box-shadow: 0 16px 48px -24px rgba(156, 74, 47, .28);
}
.hero-viz canvas { width: 100%; height: 100%; display: block; }
.hero-glyphs {
  display: grid; place-items: center; height: 100%;
  font-size: 48px; color: var(--accent); font-family: var(--mono);
}

.hero-quiet {
  margin: 22px 0 0;
  font-size: 14px; color: var(--faint); line-height: 1.6;
}
.hero-sub a,
.hero-quiet a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding-bottom: 1px;
  transition: border-color .15s ease, color .15s ease;
}
.hero-sub a:hover,
.hero-quiet a:hover {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

/* ============================================================
   JOURNEY MAP  — 大站 + 展开，不是导航条
   ============================================================ */
.journey {
  max-width: 1160px; margin: 0 auto; padding: 56px 48px 80px;
}
.journey-head {
  text-align: center;
  margin-bottom: 52px;
}
.journey-label {
  display: block;
  font-family: var(--font-head);
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.02em;
}
.journey-sub {
  display: block;
  margin-top: 12px;
  font-size: 14px;
  color: var(--faint);
}
.journey-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  position: relative;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  overflow: visible;
}
.journey-track::before {
  content: "";
  position: absolute;
  left: 10%; right: 10%;
  top: 22px;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}
.j-link { display: none; }
.journey-hub {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 10px;
}
.journey-hub-btn,
.journey-stop {
  appearance: none; cursor: pointer; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 0; background: transparent; padding: 0;
  text-align: center; font-family: inherit;
}
.journey-stop i {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-bottom: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  font-style: normal; font-size: 12px; font-family: var(--mono);
  color: var(--faint);
  transition: border-color .2s, color .2s;
}
.journey-stop b {
  font-family: var(--font-head);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 620;
  color: var(--text);
  letter-spacing: -.02em;
}
.journey-stop small {
  font-size: 12.5px; color: var(--faint); line-height: 1.45;
  max-width: 16ch;
}
.journey-stop:hover b { color: var(--accent-ink); }
.journey-hub.is-on .journey-stop i,
.journey-hub.is-open .journey-stop i {
  border-color: var(--accent);
  color: var(--accent-ink);
}
.journey-hub.is-on .journey-stop b,
.journey-hub.is-open .journey-stop b { color: var(--accent-ink); }
.journey-subs {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 18px;
}
.journey-hub.is-open .journey-subs { display: flex; }
.journey-substop {
  appearance: none; cursor: pointer;
  border: 0; background: none;
  font-family: inherit; font-size: 13px; color: var(--dim);
  padding: 5px 0;
  transition: color .15s;
}
.journey-substop:hover { color: var(--accent-ink); }

/* ============================================================
   CHAPTER BRIDGE — 一行浅字，不是胶囊条
   ============================================================ */
.bridge {
  display: block;
  margin: -4px 0 28px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--faint);
}
.bridge-arrow { color: var(--faint); margin: 0 8px; }
.bridge-from { color: var(--faint); }
.bridge-to { color: var(--dim); }
.bridge-note { color: var(--faint); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  padding: 12px 26px; border-radius: var(--r-pill);
  font-family: inherit; font-size: 14.5px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(156, 74, 47, .05);
  transition: all .2s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); font-weight: 650; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost { background: transparent; color: var(--dim); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ============================================================
   CHAPTER
   ============================================================ */
.ch { padding-top: 48px; padding-bottom: 36px; }
.ch-head {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 28px;
}
.ch-num {
  font-family: var(--font-head); font-size: 15px; font-weight: 620;
  color: var(--accent-ink); letter-spacing: .08em;
  background: none; border: 0; padding: 0;
  flex-shrink: 0;
}
.ch h2 {
  font-family: var(--font-head);
  font-size: clamp(30px, 3.6vw, 44px); line-height: 1.15; letter-spacing: -.015em;
  font-weight: 620; margin: 0;
}
.ch h3.sub {
  font-family: var(--font-head);
  font-size: 22px; font-weight: 620; margin: 56px 0 16px;
  padding-top: 26px; border-top: 1px solid var(--line-soft);
  letter-spacing: -.01em;
}
.lead { font-size: 18px; line-height: 1.8; color: var(--read); max-width: 60ch; margin: 0 0 40px; }
.ch p { max-width: 64ch; }
.ch > p { color: var(--read); font-size: 16.5px; line-height: 1.9; }
.ch > p a, .lead a {
  color: var(--accent-ink); text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}
.ch > p a:hover, .lead a:hover { border-bottom-color: var(--accent); }

/* ---------- note：只留左边强调线 ---------- */
.note {
  border: none;
  border-left: 2px solid var(--accent);
  background: transparent;
  padding: 2px 0 2px 22px; border-radius: 0;
  margin: 32px 0; font-size: 15.5px; line-height: 1.82; color: var(--text);
  box-shadow: none;
}
.note > b:first-child {
  display: flex; align-items: center; gap: 8px;
  color: var(--accent-ink);
  font-size: 13.5px; font-weight: 620; letter-spacing: .02em; margin-bottom: 6px;
}
.note > b:first-child::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.note p { margin: 0 0 10px; }
.note p:last-child { margin-bottom: 0; }

/* ---------- compare ---------- */
.compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; margin: 32px 0;
  box-shadow: 0 12px 36px -20px rgba(156, 74, 47, .14);
}
.cmp-col { background: var(--surface); padding: 24px 26px; }
.cmp-col h4 { margin: 0 0 12px; font-size: 14px; font-weight: 620; color: var(--text); }
.cmp-col ul { margin: 0; padding-left: 17px; }
.cmp-col li { color: var(--dim); font-size: 14.5px; line-height: 1.85; }
.cmp-col li::marker { color: var(--accent-deep); }

/* ============================================================
   DEMO SHELL
   ============================================================ */
.demo {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  margin: 34px 0; overflow: hidden;
  box-shadow: 0 12px 40px -18px rgba(156, 74, 47, .16);
}
.demo-wide { width: 100%; margin-left: 0; }
.demo-head {
  padding: 24px 28px 18px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.demo-head h3 { font-family: var(--font-head); margin: 0 0 4px; font-size: 19px; font-weight: 620; }
.demo-head p { margin: 0; font-size: 13.5px; color: var(--faint); line-height: 1.65; }
.demo-body { padding: 22px 24px; }
canvas { display: block; max-width: 100%; }

.ctl-row {
  display: grid; grid-template-columns: 86px 1fr 52px;
  align-items: center; gap: 12px; margin: 10px 0; font-size: 13px; color: var(--dim);
}
.ctl-row.inline { display: inline-grid; grid-template-columns: auto 130px 42px; margin: 0 0 0 8px; }
.ctl-row output { text-align: right; font-size: 12.5px; color: var(--text); }

input[type="range"] {
  appearance: none; width: 100%; height: 3px;
  background: var(--line); border-radius: var(--r-pill); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg);
}

select, .text-input {
  font-family: inherit; font-size: 13.5px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; outline: none; width: 100%;
}
select:focus, .text-input:focus { border-color: var(--accent-line); }

.btn-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.btn-row.center { justify-content: center; padding: 4px 24px 20px; }

.stat-row { display: flex; gap: 26px; margin-top: 16px; flex-wrap: wrap; }
.stat-row.col { flex-direction: column; gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat span { font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }
.stat b { font-size: 17px; font-weight: 600; }

/* pretrain (ch7) */
.pretrain-body { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
.pretrain-left canvas, .pretrain-right canvas { max-width: 100%; }
.pretrain-left .ctl-row, .pretrain-left .btn-row { max-width: 460px; }

.tip { font-size: 12.5px; color: var(--faint); line-height: 1.7; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }

/* ============================================================
   CH1 / CH2 / CH3
   ============================================================ */
.grad-body { display: grid; grid-template-columns: 1fr 320px; gap: 26px; align-items: start; }
.grad-left canvas, .grad-right canvas {
  border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  background: var(--bg-2); width: 100%; height: auto;
}
.grad-left .ctl-row:first-of-type { margin-top: 16px; }

.mlp-body { display: grid; grid-template-columns: 380px 1fr; gap: 26px; align-items: start; }
#mlpCanvas { border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--bg-2); }

.tok-out { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 16px; min-height: 34px; }
.tok { font-family: var(--mono); font-size: 13px; padding: 4px 8px; border-radius: var(--r-sm); border: 1px solid transparent; }
.tok i { font-style: normal; font-size: 9.5px; opacity: .55; margin-left: 5px; }

.emb-body { display: grid; grid-template-columns: 1fr 220px; gap: 24px; align-items: start; }
#embCanvas { border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--bg-2); width: 100%; height: auto; cursor: crosshair; }
.emb-picked { display: flex; flex-direction: column; gap: 2px; }
.emb-picked span { font-size: 11.5px; color: var(--faint); }
.emb-picked b { font-size: 19px; font-weight: 620; color: var(--accent-ink); }
.emb-near { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.emb-near div { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--dim); }
.emb-near em { font-style: normal; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.vecmath-title { font-size: 11.5px; color: var(--faint); margin-bottom: 7px; }
.vecmath-eq { font-size: 13px; color: var(--dim); margin-bottom: 12px; line-height: 1.6; }
.vecmath-eq b { color: var(--accent-ink); }

/* ============================================================
   CH4 attention
   ============================================================ */
.head-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.head-tab {
  appearance: none; cursor: pointer; padding: 6px 13px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--dim);
  font-family: inherit; font-size: 12.5px; transition: all .18s;
}
.head-tab:hover { color: var(--text); border-color: var(--faint); }
.head-tab.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.head-tab em { font-style: normal; opacity: .65; margin-left: 6px; font-size: 11px; }

.attn-wrap { display: grid; grid-template-columns: 1fr 268px; gap: 24px; align-items: start; }
.attn-arcs { grid-column: 1 / -1; }
.attn-arcs svg { width: 100%; height: auto; display: block; }
.attn-grid-wrap { overflow-x: auto; }
.attn-grid { display: grid; gap: 2px; min-width: 340px; }
.ag-cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg-2); cursor: crosshair; outline: 1px solid transparent; outline-offset: 1px; transition: outline-color .1s; }
.ag-cell:hover, .ag-cell.is-hot { outline-color: var(--text); }
.ag-cell.is-masked { background: var(--surface-2); opacity: .5; cursor: not-allowed; }
.ag-lab { font-size: 11px; color: var(--faint); font-family: var(--mono); display: flex; align-items: center; justify-content: flex-end; padding-right: 7px; white-space: nowrap; overflow: hidden; }
.ag-lab.col { justify-content: center; padding: 0 0 5px 0; align-items: flex-end; writing-mode: vertical-rl; text-orientation: mixed; height: 52px; }
.ag-lab.is-hot { color: var(--accent-ink); }

.attn-detail { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 16px 18px; font-size: 13px; min-height: 210px; }
.ad-empty { color: var(--faint); font-size: 12.5px; line-height: 1.7; }
.ad-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.ad-title span { color: var(--accent-ink); }
.ad-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--dim); }
.ad-row:last-child { border-bottom: 0; }
.ad-row b { font-family: var(--mono); color: var(--text); font-weight: 500; }
.ad-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 10px; overflow: hidden; }
.ad-bar i { display: block; height: 100%; background: var(--accent); }
.ad-note { font-size: 12px; color: var(--faint); line-height: 1.65; margin-top: 12px; }

.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.step-btn { appearance: none; cursor: pointer; text-align: left; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg-2); color: var(--dim); font-family: inherit; font-size: 12.5px; transition: all .18s; }
.step-btn:hover { color: var(--text); }
.step-btn.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.step-btn u { text-decoration: none; font-family: var(--mono); opacity: .55; margin-right: 6px; }

.step-panel { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 20px 22px; min-height: 132px; }
.sp-h { font-size: 15px; font-weight: 620; margin: 0 0 8px; }
.sp-p { font-size: 14px; color: var(--dim); line-height: 1.8; margin: 0 0 14px; max-width: 66ch; }
.sp-shape { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 13px; color: var(--dim); }
.sp-shape b { color: var(--accent-ink); font-weight: 500; }
.sp-formula { font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 14px; margin-top: 12px; overflow-x: auto; }

/* ============================================================
   CH5 - 3D transformer
   ============================================================ */
.viz3d-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }

/* ============================================================
   FLOW (ch10 全链路回放)
   ============================================================ */
.flow-body { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.flow-stage {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  background: radial-gradient(120% 90% at 50% 0%, var(--surface), var(--bg-2));
  overflow: hidden; height: 620px;
  box-shadow: inset 0 0 0 1px rgba(156,74,47,.05), 0 10px 34px -22px rgba(156,74,47,.16);
  cursor: grab; touch-action: none;
}
.flow-stage.dragging { cursor: grabbing; }
.flow-stage canvas { width: 100%; height: 100%; display: block; }
.flow-badge {
  position: absolute; right: 12px; top: 10px;
  font-size: 11px; color: var(--accent-ink); font-family: var(--mono);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  padding: 3px 9px; border-radius: var(--r-pill); pointer-events: none;
}
.flow-side { display: flex; flex-direction: column; gap: 14px; }
.flow-detail {
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  padding: 20px 22px; min-height: 250px;
}
.flow-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--faint); }
.flow-name { font-family: var(--font-head); font-size: 20px; font-weight: 620; margin: 6px 0 10px; }
.flow-shape {
  display: inline-block; font-family: var(--mono); font-size: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 11px; color: var(--accent-ink); margin-bottom: 12px;
}
.flow-desc { margin: 0; font-size: 14.5px; color: var(--dim); line-height: 1.8; }
.flow-step {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; margin-top: 10px; overflow-x: auto;
}

.viz3d-stage {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  background: radial-gradient(120% 90% at 50% 0%, var(--surface), var(--bg-2));
  overflow: hidden; cursor: grab; touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(156,74,47,.05), 0 10px 34px -22px rgba(156,74,47,.16);
  height: 600px;
}
.viz3d-stage.dragging { cursor: grabbing; }
.viz3d-stage canvas { width: 100%; height: 100%; display: block; }
.viz3d-hint {
  position: absolute; left: 12px; bottom: 10px;
  font-size: 11px; color: var(--faint); font-family: var(--mono);
  pointer-events: none; opacity: .85;
}
.viz3d-badge {
  position: absolute; right: 12px; top: 10px;
  font-size: 11px; color: var(--accent-ink); font-family: var(--mono);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  padding: 3px 9px; border-radius: var(--r-pill); pointer-events: none;
}
.viz3d-side { display: flex; flex-direction: column; gap: 14px; }
.v3-detail { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 16px 18px; min-height: 250px; }
.v3-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--faint); }
.v3-name { font-family: var(--font-head); font-size: 18px; font-weight: 620; margin: 4px 0 10px; }
.v3-shape { display: inline-block; font-family: var(--mono); font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 11px; color: var(--accent-ink); margin-bottom: 12px; }
.v3-desc { font-size: 13.5px; color: var(--dim); line-height: 1.8; margin: 0 0 12px; }
.v3-math { font-size: 13px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.v3-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 11.5px; color: var(--faint); }
.v3-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ============================================================
   CH6 sampling
   ============================================================ */
.samp-ctl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-bottom: 22px; }
.samp-ctl .ctl-row { grid-template-columns: 60px 1fr 44px; margin: 0; }
.samp-bars { display: flex; flex-direction: column; gap: 5px; }
.sb-row { display: grid; grid-template-columns: 78px 1fr 62px; align-items: center; gap: 12px; }
.sb-word { font-size: 13.5px; text-align: right; transition: color .2s; }
.sb-track { height: 22px; background: var(--bg-2); border-radius: var(--r-sm); overflow: hidden; }
.sb-fill { height: 100%; background: var(--accent); border-radius: var(--r-sm); transition: width .32s cubic-bezier(.16,1,.3,1), background .2s; min-width: 2px; }
.sb-pct { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.sb-row.is-cut .sb-word { color: var(--faint); text-decoration: line-through; }
.sb-row.is-cut .sb-fill { background: var(--line); }
.sb-row.is-cut .sb-pct { color: var(--faint); }
.sb-row.is-picked .sb-word { color: var(--accent-ink); font-weight: 620; }
.samp-result { font-size: 14px; color: var(--dim); margin-left: 6px; }
.samp-result b { color: var(--accent-ink); font-size: 16px; }

/* ============================================================
   CH7 lora
   ============================================================ */
.lora-body { display: grid; grid-template-columns: 1fr 210px; gap: 24px; align-items: center; }
#loraCanvas { width: 100%; height: auto; }

/* ============================================================
   CH8 rlhf
   ============================================================ */
.rlhf-flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.rf-card { padding: 16px 16px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; transition: all .18s; }
.rf-card:hover { border-color: var(--faint); }
.rf-card.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.rf-stage { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: .08em; }
.rf-card.is-on .rf-stage { color: var(--accent-ink); }
.rf-name { font-size: 14.5px; font-weight: 600; margin: 5px 0 4px; }
.rf-desc { font-size: 12.5px; color: var(--dim); line-height: 1.6; }

.rlhf-panel { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 20px 22px; min-height: 190px; }
.rp-h { font-size: 15px; font-weight: 620; margin: 0 0 10px; }
.rp-p { font-size: 14px; color: var(--dim); line-height: 1.8; margin: 0 0 16px; max-width: 66ch; }
.rp-io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.rp-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.rp-box span { font-size: 11px; color: var(--faint); display: block; margin-bottom: 5px; }
.rp-box p { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.65; }

.pref-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.pref-opt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; cursor: pointer; transition: all .18s; }
.pref-opt:hover { border-color: var(--accent-line); }
.pref-opt.picked { border-color: var(--accent); background: var(--accent-soft); }
.pref-opt p { margin: 0 0 8px; font-size: 13px; line-height: 1.7; color: var(--dim); }
.pref-score { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.pref-opt.picked .pref-score { color: var(--accent-ink); }
.pref-fb { font-size: 13px; color: var(--dim); line-height: 1.7; margin-top: 12px; min-height: 24px; }

/* ============================================================
   CH9 graph
   ============================================================ */
.graph-body { display: grid; grid-template-columns: 1fr 1fr 250px; gap: 20px; align-items: start; }
.graph-pane { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 14px; }
.graph-title { font-size: 12px; color: var(--faint); margin-bottom: 8px; text-align: center; }
.graph-pane svg { width: 100%; height: auto; display: block; }
.gnode rect { fill: var(--surface); stroke: var(--line); stroke-width: 1; transition: all .25s; }
.gnode text { fill: var(--dim); font-size: 11px; font-family: var(--sans); transition: fill .25s; }
.gnode.active rect { fill: var(--accent-soft); stroke: var(--accent); }
.gnode.active text { fill: var(--accent-ink); }
.gnode.done rect { stroke: var(--accent-deep); }
.gedge { stroke: var(--line); stroke-width: 1.4; fill: none; transition: stroke .25s; }
.gedge.active { stroke: var(--accent); }
.gedge-lab { fill: var(--faint); font-size: 9.5px; font-family: var(--mono); }
.graph-state { margin-bottom: 14px; }
.gs-title { font-size: 11.5px; color: var(--faint); margin-bottom: 7px; }
#graphState { margin: 0; font-size: 11.5px; line-height: 1.65; color: var(--dim); background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 11px 13px; overflow-x: auto; }
.graph-log { font-family: var(--mono); font-size: 11.5px; line-height: 1.8; color: var(--faint); max-height: 150px; overflow-y: auto; border-top: 1px solid var(--line-soft); padding-top: 10px; min-height: 60px; }
.graph-log div { opacity: 0; animation: fadeUp .3s forwards; }
.graph-log b { color: var(--accent-ink); font-weight: 500; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ============================================================
   MATH BLOCKS (shared with math.html)
   ============================================================ */
.eq {
  background: transparent;
  border: none;
  border-left: 2px solid var(--accent);
  border-radius: 0;
  padding: 4px 0 8px 22px; margin: 28px 0; overflow-x: auto;
  width: 100%; margin-left: 0;
  box-shadow: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.eq::-webkit-scrollbar { display: none; height: 0; }
.eq-label {
  font-family: var(--mono); font-size: 11px; color: var(--accent-ink);
  letter-spacing: .06em; margin-bottom: 10px; font-weight: 500;
}
.eq .katex-display {
  margin: 6px 0;
  overflow: visible;
}
.eq .katex-display > .katex { white-space: normal; }
.eq-why { font-size: 13.5px; color: var(--read); line-height: 1.75; margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.eq-xref {
  font-size: 13px; color: var(--faint); line-height: 1.6;
  margin: 8px 0 0;
}
.eq-xref a {
  color: var(--accent-ink); text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}
.eq-xref a:hover { border-bottom-color: var(--accent); }

.derive { counter-reset: dstep; margin: 24px 0; }
.derive-step { position: relative; padding: 0 0 20px 34px; border-left: 1px solid var(--line); }
.derive-step:last-child { border-left-color: transparent; padding-bottom: 0; }
.derive-step::before {
  counter-increment: dstep; content: counter(dstep);
  position: absolute; left: -11px; top: 0;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--accent-line);
  color: var(--accent-ink); font-family: var(--mono); font-size: 10.5px;
  display: grid; place-items: center;
}
.derive-step h5 { margin: 0 0 6px; font-size: 13.5px; font-weight: 620; color: var(--text); }
.derive-step p { margin: 0 0 10px; font-size: 13.5px; color: var(--dim); line-height: 1.8; }
.derive-step .katex-display { margin: 10px 0; }

.symtable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: 0 8px 26px -20px rgba(156, 74, 47, .14);
  border: 1px solid var(--line);
}
.symtable th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .07em;
  color: var(--faint);
  font-weight: 500;
  padding: 14px 16px;
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
  text-transform: uppercase;
  font-family: var(--mono);
}
.symtable th:first-child { width: 86px; }
.symtable th:nth-child(2) { width: 150px; }
.symtable td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--dim);
  vertical-align: top;
  line-height: 1.7;
  transition: all 0.2s ease;
}
.symtable td:first-child {
  width: 86px;
  color: var(--text);
  font-weight: 500;
  font-size: 16px;
}
.symtable td:nth-child(2) {
  width: 150px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}
.symtable tbody tr:hover td {
  background: var(--bg-2);
}
.symtable tbody tr:last-child td {
  border-bottom: none;
}
.symtable .katex { font-size: 1.06em; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; margin: 24px 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px 24px;
  box-shadow: 0 6px 20px -14px rgba(156, 74, 47, .14);
}
.card h4 { font-family: var(--font-head); margin: 0 0 10px; font-size: 16px; font-weight: 620; }
.card p { margin: 0; font-size: 14px; color: var(--dim); line-height: 1.75; }
.card .katex { font-size: .98em; }

/* ============================================================
   MATH VIZ CARDS  (interactive demos embedded in math chapters)
   ============================================================ */
.math-viz {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 12px 0;
  margin: 28px 0;
  text-align: left;
  box-shadow: none;
}
.math-viz.is-still .viz-ctl { display: none; }
.math-viz.is-still .viz-grid,
.math-viz.is-still .viz-grid3 { grid-template-columns: 1fr; max-width: 520px; }
.math-viz.is-still .viz-head h3 { font-size: 1.05em; color: var(--dim); font-weight: 500; }
.math-viz.is-still .viz-head h3::after {
  content: "静图";
  margin-left: 10px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--faint);
  font-weight: 400;
  letter-spacing: .08em;
}
.math-viz .viz-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.math-viz .viz-head .viz-emoji { font-size: 1.5em; line-height: 1; }
.math-viz .viz-head h3 { font-family: var(--font-head); margin: 0; font-size: 1.3em; font-weight: 620; color: var(--text); }
.math-viz .viz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.math-viz .viz-grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  align-items: center;
}
.math-viz canvas {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  max-width: 100%;
  background: var(--surface);
  display: block;
}
.math-viz .viz-ctl { margin-bottom: 18px; }
.math-viz .viz-ctl label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--dim);
}
.math-viz .viz-ctl input[type="range"] { width: 100%; }
.math-viz .viz-ctl .viz-val {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.math-viz .viz-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  border-radius: var(--r-sm);
  font-weight: 500;
  cursor: pointer;
}
.math-viz .viz-note {
  background: transparent;
  border: none;
  padding: 4px 0 0;
  border-radius: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--dim);
}
.math-viz .viz-note strong { color: var(--text); }
.math-viz .viz-center { text-align: left; }
.math-viz .viz-legend { padding: 14px 18px; border-radius: var(--r-sm); font-size: 14px; text-align: left; }

.katex { font-size: 1.04em; }
.katex-display > .katex { white-space: normal; }

/* ============================================================
   FOOT
   ============================================================ */
/* ---------- 章与章之间的空气 ---------- */
.ch-air {
  max-width: 900px;
  margin: 0 auto;
  padding: 96px 48px 40px;
  text-align: center;
}
.ch-air p {
  font-family: var(--font-head);
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 500;
  color: var(--faint);
  letter-spacing: .01em;
  margin: 0;
  line-height: 1.5;
}

/* ---------- 接下来 ---------- */
.next {
  max-width: 900px;
  margin: 0 auto;
  padding: 120px 48px 80px;
}
.next-kicker {
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--faint);
  text-transform: uppercase;
  font-family: var(--mono);
  margin: 0 0 18px;
}
.next h2 {
  font-family: var(--font-head);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 52px;
  line-height: 1.15;
}
.next-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.next-list li {
  font-size: 17px;
  line-height: 1.75;
  color: var(--dim);
  max-width: 52ch;
}
.next-list b {
  display: block;
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 620;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -.015em;
}
.next a {
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}
.next a:hover { border-bottom-color: var(--accent); }

.foot { border-top: 1px solid var(--line-soft); margin-top: 90px; padding: 34px 0 60px; }
.foot p { margin: 0 0 5px; font-size: 13px; color: var(--dim); }
.foot .foot-dim { color: var(--faint); font-size: 12.5px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1180px) {
  .demo-wide, .eq { width: 100%; margin-left: 0; }
  .attn-wrap, .viz3d-wrap { grid-template-columns: 1fr; }
  .graph-body { grid-template-columns: 1fr 1fr; }
  .graph-side { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .rail { display: none; }
  main { margin-left: 0; padding-top: calc(var(--top-h) + 40px); }
  html { scroll-padding-top: 124px; }
  .chap-jump {
    display: block;
    position: fixed;
    top: var(--top-h);
    left: 0; right: 0;
    z-index: 35;
    height: 40px;
    padding: 0 36px 0 16px;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
    background-color: color-mix(in srgb, var(--bg) 94%, transparent);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%238b8177' stroke-width='1.4' d='M1.5 1.5L6 6l4.5-4.5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--text);
    font: 13.5px/40px var(--sans);
    appearance: none;
    -webkit-appearance: none;
  }
  .progress-chap { top: 118px; }
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 30px; padding-bottom: 40px; }
  .hero-viz { order: -1; }
  .grad-body, .mlp-body, .emb-body, .lora-body { grid-template-columns: 1fr; }
  .samp-ctl { grid-template-columns: 1fr; gap: 4px; }
  .math-viz .viz-grid, .math-viz .viz-grid3 { grid-template-columns: 1fr; }
  .math-viz { padding: 20px 18px; }
  .rlhf-flow, .compare, .rp-io, .pref-pair, .graph-body, .cards, .pretrain-body { grid-template-columns: 1fr; }
  .flow-body { grid-template-columns: 1fr; }
  .flow-stage { height: 480px; }
  .viz3d-stage { height: 520px; }
  .demo-body { padding: 16px 16px; }
  .ch, .hero, .foot-in { padding: 0 20px; }
  .hero { padding-top: 18px; padding-bottom: 40px; }
  .ch { padding-top: 40px; }
  .topbar { padding: 0 14px; }
  .brand-name { display: none; }
  .symtable td:first-child { width: 70px; }
  .symtable td:nth-child(2) { width: auto; }
  .journey { padding: 32px 16px 48px; }
  .journey-head { margin-bottom: 32px; }
  .journey-track { grid-template-columns: 1fr; gap: 28px; }
  .journey-track::before { display: none; }
  .journey-hub { text-align: left; padding: 0; }
  .journey-stop { align-items: flex-start; }
  .ch-air, .next { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 36px; }
  .pagelinks { gap: 6px; }
  .pagelink { padding: 6px 10px; font-size: 12.5px; }
  .pagelink-sep { height: 12px; margin: 0 2px; }
}

/* ============================================================
   BASICS PAGE
   ============================================================ */
/* basics page extras — also kept in basics-extra.css */

.ch pre, .demo pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  overflow-x: auto;
  color: var(--text);
  margin: 18px 0 28px;
}
.ch p code, .lead code, .note code, .cmp-col code, .card code,
.demo-head code, .ch li code, .tip code, .tree-detail code, .sp-p code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-ink);
}
.ch pre code, .demo pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

.compare-3 { grid-template-columns: 1fr 1fr 1fr; }

.tree {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
  align-items: start;
}
.tree-list { display: flex; flex-direction: column; gap: 4px; }
.tree-item {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--dim);
  border-radius: var(--r-sm); padding: 8px 12px;
  font-family: var(--mono); font-size: 13px;
  transition: all .15s;
}
.tree-item:hover { color: var(--text); border-color: var(--faint); }
.tree-item.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.tree-detail {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: 18px 20px; min-height: 180px;
}
.tree-detail h4 { margin: 0 0 8px; font-size: 16px; font-family: var(--font-head); }
.tree-detail p { margin: 0 0 8px; font-size: 14px; color: var(--dim); line-height: 1.75; }
.tree-detail p:last-child { margin-bottom: 0; }

.perm {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.perm-g {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: 14px;
}
.perm-g h4 {
  margin: 0 0 10px; font-size: 12px; color: var(--faint);
  font-family: var(--mono); letter-spacing: .08em; font-weight: 600;
}
.perm-bits { display: flex; gap: 6px; }
.perm-bit {
  flex: 1; appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--faint);
  border-radius: var(--r-sm); padding: 10px 0;
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  transition: all .15s;
}
.perm-bit.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

.join-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--mono); }
.mini-table th {
  text-align: left; font-size: 11px; color: var(--faint); font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid var(--line);
  letter-spacing: .06em; text-transform: uppercase;
}
.mini-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); color: var(--dim); }
.mini-table tr.is-hit td { background: var(--accent-soft); color: var(--accent-ink); }
.mini-table tr.is-miss td { opacity: .38; }
.mini-table caption {
  caption-side: top; text-align: left; font-size: 12.5px; color: var(--faint);
  padding-bottom: 8px; font-family: var(--sans);
}

.loop-track { display: flex; flex-direction: column; gap: 12px; }
.loop-task {
  display: grid; grid-template-columns: 78px 1fr 72px; gap: 10px; align-items: center;
  font-size: 13px; color: var(--dim);
}
.loop-bar { height: 10px; background: var(--line); border-radius: var(--r-pill); overflow: hidden; }
.loop-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: var(--r-pill); }

.dock-stack { display: flex; flex-direction: column; gap: 8px; }
.dock-layer {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px;
  background: var(--surface); cursor: pointer; transition: all .18s;
}
.dock-layer:hover { border-color: var(--faint); }
.dock-layer.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.dock-layer h4 { margin: 0 0 4px; font-size: 14px; }
.dock-layer p { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.65; }

.term {
  font-family: var(--mono); font-size: 13px; line-height: 1.75;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 14px 16px; color: var(--text);
  min-height: 84px; white-space: pre-wrap;
}
.term b { color: var(--accent-ink); font-weight: 500; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--dim);
  border-radius: var(--r-pill); padding: 6px 12px; font-size: 12.5px; font-family: inherit;
  transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.cells { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; }
.cell {
  font-family: var(--mono); font-size: 13px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px; padding: 6px 10px; color: var(--text);
}
.cell kbd { font-size: 10px; color: var(--faint); margin-left: 6px; font-family: var(--mono); }

.bc-row { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 10px; align-items: center; }
.bc-op { color: var(--faint); font-family: var(--mono); font-size: 18px; text-align: center; }
.bc-grid {
  display: grid; gap: 4px; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: 12px; min-height: 120px; align-content: center;
}
.bc-cell {
  width: 36px; height: 28px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.bc-cell.ghost { opacity: .35; }
.bc-err { color: var(--accent-ink); font-size: 13px; text-align: center; }

.symtable.wide th:first-child, .symtable.wide td:first-child { width: auto; }
.symtable.wide th:nth-child(2), .symtable.wide td:nth-child(2) { width: auto; }
.symtable.wide td:first-child { font-family: var(--mono); font-size: 13.5px; color: var(--accent-ink); }

@media (max-width: 900px) {
  .tree, .join-wrap, .grid2, .compare-3, .bc-row { grid-template-columns: 1fr; }
  .perm { grid-template-columns: 1fr; }
  .loop-task { grid-template-columns: 64px 1fr 64px; }
}
