/* Atlas of LLM Architectures — editorial layout with 2D/3D architecture views. Light only. */
:root {
  --ink: #0d0d0f;
  --ink2: #3a3a42;
  --muted: #64646f;
  --line: #e6e6ec;
  --soft: #f5f6f9;
  --paper: #ffffff;
  --accent: #2f55e4;
  --attn: #4361ee;
  --win: #45a6f0;
  --latent: #8a5cf6;
  --sparse: #6a4ee0;
  --linear: #1f9d72;
  --cache: #e9b949;
  --expert: #ff5a36;
  --shared: #b2a487;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-heading: 22px;
  --text-body: 17px;
  --text-sm: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav: 60px;
  --col: 680px;
  --wide: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav) + 16px); }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--text-body)/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 30; height: var(--nav);
  display: flex; align-items: center; gap: 28px; padding: 0 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid rgba(230, 230, 236, .85);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}
html:not(.scrolled):not([data-view]) .nav {
  background: transparent;
  border-bottom-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.nav .brand { font-size: 16px; font-weight: 600; text-decoration: none; letter-spacing: -.015em; white-space: nowrap; }
.nav nav { display: flex; gap: 26px; font-size: var(--text-sm); flex: 1; justify-content: center; }
.nav nav a { text-decoration: none; color: var(--ink2); transition: color 160ms var(--ease); }
.nav nav a:hover { color: var(--ink); }
.mode { display: flex; background: #eef0f5; border-radius: 999px; padding: 3px; transition: background-color 180ms var(--ease); }
html:not(.scrolled):not([data-view]) .mode { background: rgba(255, 255, 255, .74); }
.mode button {
  border: 0; background: none; cursor: pointer; font-size: var(--text-sm); font-weight: 600;
  padding: 4px 12px; border-radius: 999px; color: var(--muted);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
html[data-mode="2d"] .mode [data-mode="2d"],
html[data-mode="3d"] .mode [data-mode="3d"] { background: var(--ink); color: #fff; }
html[data-mode="2d"] .only3d, html[data-mode="3d"] .only2d { display: none !important; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; margin-top: calc(-1 * var(--nav)); padding: calc(var(--nav) + 40px) 28px 70px; min-height: 680px; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(520px 420px at 12% 92%, rgba(255, 244, 196, .95), rgba(255, 244, 196, 0) 70%),
    radial-gradient(900px 700px at 30% 40%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%),
    radial-gradient(1200px 800px at 80% 0%, #a9b9f4 0%, #c4cff8 35%, #dfe5fb 70%, #f3f5fe 100%);
}
.hero-bg::after { content: ""; position: absolute; left: -10%; top: 8%; width: 70%; height: 120%; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .7); filter: blur(1px); }
.hero-inner { max-width: var(--wide); margin: 0 auto; display: grid; grid-template-columns: 1fr 1.05fr; gap: 40px; align-items: end; min-height: 560px; }
.hero h1 { font-size: clamp(40px, 5.6vw, 64px); line-height: 1.04; font-weight: 500; letter-spacing: -.03em; margin: 0 0 22px; }
.lede { font-size: var(--text-body); line-height: 1.55; color: var(--ink2); max-width: 52ch; margin: 0; }
.collage { position: relative; height: 560px; }
.collage .repeat {
  position: absolute; left: 0; top: 96px; width: 62%; padding: 12px 18px;
  background: rgba(47, 85, 228, .86); color: rgba(255, 255, 255, .78);
  font-size: var(--text-heading); line-height: 1.42; letter-spacing: -.01em; z-index: 1;
}
.collage .repeat span { display: block; white-space: nowrap; overflow: hidden; }
.collage img { position: absolute; box-shadow: 0 12px 40px rgba(30, 40, 90, .16); }
.collage .c1 { right: 0; top: 0; width: 44%; z-index: 2; }
.collage .c2 { right: 8%; top: 300px; width: 50%; z-index: 3; }
.collage .c3 { left: 18%; top: 210px; width: 34%; z-index: 2; }
.collage .c4 { left: 0; top: 380px; width: 30%; z-index: 4; }

/* ---------- intro + sticky mechanism index ---------- */
.intro { position: relative; padding: 48px 28px 36px; }
.toc { position: absolute; left: 28px; top: 48px; bottom: 36px; width: 196px; font-size: var(--text-sm); }
.toc h2 { font-size: var(--text-sm); font-weight: 600; margin: 0 0 8px; }
.toc ol { position: sticky; top: calc(var(--nav) + 24px); list-style: decimal; margin: 0; padding-left: 20px; color: var(--muted); }
.toc a { display: block; text-decoration: none; color: var(--muted); padding: 4px 0; line-height: 1.35; transition: color 160ms var(--ease); }
.toc a.on, .toc a:hover { color: var(--ink); }
.prose { max-width: var(--col); margin: 0 auto; }
.prose p { margin: 0 0 20px; }
.prose h2 { font-size: clamp(24px, 2.6vw, 28px); font-weight: 500; letter-spacing: -.02em; margin: 48px 0 16px; }
.intro .prose h2:first-child { margin-top: 0; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 26px; margin: 20px 0 30px; font-size: var(--text-sm); color: var(--ink2); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 10px; vertical-align: -2px; }
.note { font-size: var(--text-sm); color: var(--muted); }

/* ---------- four limits map ---------- */
.map-sec { padding: 4px 28px 44px; }
.map-wrap { max-width: var(--col); margin: 0 auto; }
.map-wrap h2 { font-size: clamp(24px, 2.6vw, 28px); font-weight: 500; letter-spacing: -.02em; margin: 0 0 16px; }
.map-wrap > p { margin: 0 0 26px; }
.limits { margin: 0 0 26px; border-bottom: 1px solid var(--line); }
.limits > div { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 4px 28px; padding: 18px 0 20px; border-top: 1px solid var(--line); }
.limits dt { font-size: var(--text-body); font-weight: 600; letter-spacing: -.005em; line-height: 1.4; }
.limits dd { margin: 0; font-size: var(--text-body); color: var(--ink2); }
.limits dd p { margin: 0 0 8px; }
.limits .see { font-size: var(--text-sm); color: var(--muted); margin: 0; }
.limits .see a { color: var(--ink2); text-underline-offset: 3px; }
.limits .see a:hover { color: var(--ink); }
.map-compare > summary { cursor: pointer; font-size: var(--text-sm); text-decoration: underline; text-underline-offset: 3px; }
.map-table-scroll { margin-top: 18px; overflow-x: auto; }
.map-table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.45; }
.map-table th, .map-table td { text-align: left; padding: 11px 18px 12px 0; border-top: 1px solid var(--line); vertical-align: top; color: var(--ink2); font-weight: 400; }
.map-table thead th { border-top: 0; color: var(--muted); padding-bottom: 8px; }
.map-table tbody th { font-weight: 600; color: var(--ink); white-space: nowrap; }
.map-table tbody th a { text-decoration: none; }
.map-table tbody th a:hover { text-decoration: underline; }
@media (min-width: 900px) {
  .map-table-scroll { width: min(var(--wide), calc(100vw - 56px)); margin-left: 50%; transform: translateX(-50%); }
}

/* ---------- shared section heads, keys, grids & cards ---------- */
.chapter, #story, #gallery, #compare, #sources { scroll-margin-top: calc(var(--nav) + 18px); }
.story, .gallery, .compare, .sources { padding: 80px 28px; border-top: 1px solid var(--line); }
.sec-head { max-width: var(--wide); margin: 0 auto 28px; display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }
.sec-head h2 { font-size: clamp(32px, 3.6vw, 40px); font-weight: 500; letter-spacing: -.025em; margin: 0; line-height: 1.1; }
.sec-head p { margin: 8px 0 0; color: var(--ink2); max-width: 58ch; }
.sec-more { display: inline-flex; align-items: baseline; gap: 9px; text-decoration: none; color: var(--ink); font-size: var(--text-body); font-weight: 500; white-space: nowrap; }
.sec-more .arrow { display: inline-block; transition: transform 180ms var(--ease); }
.sec-more:hover { text-decoration: underline; text-underline-offset: 5px; }
.sec-more:hover .arrow { transform: translateX(4px); }
.sec-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.teaser-grid { margin-bottom: 6px; }

.grid { max-width: var(--wide); margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 28px; }
.card { text-decoration: none; color: inherit; text-align: left; padding: 0; cursor: pointer; display: flex; flex-direction: column; }
.card .thumb { aspect-ratio: 5 / 4; border-radius: 12px; background: radial-gradient(500px 300px at 60% 20%, #fff, #eef1f8); display: grid; place-items: center; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.card .thumb img:not([src]) { visibility: hidden; }
.card .thumb svg { width: 92%; height: 92%; }
.card .body { padding: 14px 0 0; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.card h3 { margin: 0; font-size: var(--text-heading); font-weight: 550; letter-spacing: -.015em; line-height: 1.22; text-decoration: underline 1.5px transparent; text-underline-offset: 4px; transition: text-decoration-color 160ms var(--ease); }
.card:hover h3, .card:focus-visible h3 { text-decoration-color: var(--ink); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 12px; }
.card .org { font-size: var(--text-sm); color: var(--muted); margin: 0; }
.card .sum { font-size: var(--text-sm); color: var(--ink2); margin: 4px 0 8px; line-height: 1.5; }
.card .keys { margin-top: auto; }

.ch-card .thumb { aspect-ratio: 16 / 10; background: var(--soft); }
.ch-card .thumb img { object-fit: cover; object-position: 60% 50%; }
.ch-card .top { justify-content: flex-start; color: var(--ink2); }
.ch-card .sum { margin: 2px 0 0; }

/* colour-dot labels & milestone text (plain typography, no decorative pills) */
.keys { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.key { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--ink2); white-space: nowrap; }
.key::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #9a9aa5); }
a.key { text-decoration: underline; text-decoration-color: #c9cad6; text-underline-offset: 3px; transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease); }
a.key:hover { color: var(--ink); text-decoration-color: currentColor; }
.flag { color: var(--ink); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.flag.mainstream { font-weight: 500; }

/* ---------- sentence filters & inline pickers ---------- */
.filters { max-width: var(--wide); margin: 0 auto 34px; }
.f-say { margin: 0; max-width: 1000px; font-size: clamp(22px, 2.4vw, 28px); line-height: 1.5; font-weight: 500; letter-spacing: -.017em; color: var(--muted); }
.pick { position: relative; display: inline-block; color: var(--ink); line-height: 1.24; cursor: pointer; }
.pick-t { text-decoration: underline 1.5px #c9cad6; text-underline-offset: .2em; transition: text-decoration-color 160ms var(--ease); }
.pick:hover .pick-t { text-decoration-color: var(--ink); }
.pick select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; opacity: 0; cursor: pointer; font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none; }
.pick.set { color: #fff; background: var(--accent); padding: 0 .24em; border-radius: 3px; box-shadow: 0 .08em 0 var(--accent), 0 -.08em 0 var(--accent); }
.pick.set .pick-t { text-decoration: none; }
.pick:focus-within { outline: 2px solid var(--accent); outline-offset: .2em; border-radius: 3px; }
.pick.set:focus-within { outline-color: var(--ink); }
.f-foot { display: flex; align-items: baseline; gap: 18px; margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); transition: border-color 160ms var(--ease); }
.f-foot:focus-within { border-bottom-color: var(--ink); }
.f-foot input[type=search] { flex: 1; min-width: 0; border: 0; border-radius: 0; background: none; padding: 12px 0; font: inherit; font-size: var(--text-body); color: var(--ink); outline: none; -webkit-appearance: none; appearance: none; }
.f-foot input[type=search]::placeholder { color: var(--muted); }
.f-foot .count { font-size: var(--text-sm); color: var(--ink2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.f-clear { border: 0; background: none; padding: 0; font: inherit; font-size: var(--text-sm); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.f-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.grid-empty { grid-column: 1 / -1; margin: 30px 0 60px; color: var(--ink2); }

/* ---------- models full view & sticky-column lineage ---------- */
.models-view { display: none; padding: 34px 28px 30px; }
html[data-view="models"] main > section:not(.models-view) { display: none; }
html[data-view="models"] .models-view { display: block; }
.mv-head { max-width: var(--wide); margin: 0 auto; }
.mv-desc { margin: 0 0 40px; font-size: var(--text-body); line-height: 1.55; color: var(--ink2); max-width: 62ch; }

.lineage-host { max-width: var(--wide); margin: 0 auto 48px; }
.lineage { margin: 0; }
.ln-head h3 { font-size: var(--text-heading); font-weight: 500; letter-spacing: -.015em; margin: 0 0 6px; }
.ln-head p { margin: 0 0 18px; font-size: var(--text-sm); color: var(--ink2); max-width: 65ch; }
.ln-frame { position: relative; display: flex; align-items: stretch; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ln-frame.can-scroll::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; pointer-events: none;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--paper));
}
.ln-fams { flex: none; background: var(--paper); z-index: 2; padding-right: 16px; transition: box-shadow 180ms var(--ease); }
.ln-frame.is-scrolled .ln-fams { box-shadow: 8px 0 14px -8px rgba(13, 13, 15, .18); }
.ln-fam-row { display: flex; align-items: center; font-size: var(--text-sm); color: var(--ink2); white-space: nowrap; border-top: 1px solid var(--line); }
.ln-scroll { flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ln-scroll svg { display: block; max-width: none; font-family: var(--sans); }
.ln-year { font-size: 13px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ln-rule { stroke: var(--line); stroke-width: 1; }
.ln-edge { fill: none; stroke: var(--ink); stroke-width: 1; opacity: .17; }
.ln-edge.on { stroke: var(--accent); stroke-width: 1.5; opacity: .9; }
.ln-edge.dim { opacity: .05; }
.ln-node { cursor: pointer; text-decoration: none; outline: none; }
.ln-node text { font-size: 13px; fill: var(--ink2); paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round; }
.ln-node.mainstream text { fill: var(--ink); font-weight: 500; }
.ln-node.introduced text { fill: var(--ink); font-weight: 700; }
.ln-node.dim { opacity: .26; }
.ln-node.rel text { fill: var(--accent); }
.ln-bg { fill: transparent; }
.ln-node:hover .ln-bg, .ln-node:focus-visible .ln-bg, .ln-node.on .ln-bg { fill: var(--accent); }
.ln-node:hover text, .ln-node:focus-visible text, .ln-node.on text { fill: #fff; stroke: none; }
.ln-node:hover circle, .ln-node:focus-visible circle, .ln-node.on circle { fill: #fff; }
.ln-info { margin: 12px 0 0; min-height: 3.1em; max-width: 920px; font-size: var(--text-sm); line-height: 1.5; color: var(--ink2); }
.ln-info b { color: var(--ink); font-weight: 600; }

/* ---------- chapter view ---------- */
.chapter-view { display: none; padding: 34px 28px 30px; }
html[data-view="chapter"] main > section:not(.chapter-view) { display: none; }
html[data-view="chapter"] .chapter-view { display: block; }
.chapter { max-width: var(--wide); margin: 0 auto; }
.ch-back { font-size: var(--text-sm); margin: 0 0 28px; }
.ch-back a, .ch-pager .all { color: var(--ink2); text-underline-offset: 3px; }
.ch-back a:hover, .ch-pager .all:hover { color: var(--ink); }
.ch-num { font-size: var(--text-sm); color: var(--ink2); margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.ch-head h2 { font-size: clamp(30px, 4vw, 46px); line-height: 1.08; letter-spacing: -.025em; font-weight: 550; margin: 6px 0 20px; }
.ch-head h2:focus { outline: none; }
.plate { margin: 0 0 28px; }
.plate img { width: 100%; aspect-ratio: 16 / 7; max-height: 340px; object-fit: cover; object-position: 60% 50%; border-radius: 12px; }
.plate figcaption { font-size: var(--text-sm); font-style: italic; color: var(--ink2); margin-top: 12px; max-width: var(--col); }

.ch-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 10px 56px; align-items: start; }
.ch-grid > .ch-idea { grid-column: 1; min-width: 0; font-size: var(--text-heading); line-height: 1.42; letter-spacing: -.008em; color: var(--ink); margin: 0 0 18px; }
.ch-text { grid-column: 1; min-width: 0; }
.ch-text p { margin: 0 0 18px; }
.ch-text h3, .ch-study h3, .check h3 { font-size: var(--text-heading); font-weight: 500; line-height: 1.25; letter-spacing: -.012em; margin: 36px 0 10px; scroll-margin-top: calc(var(--nav) + 18px); }
.ch-text h3:focus, .ch-study h3:focus { outline: none; }
.ch-toc { margin: 0 0 30px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ch-toc ol { margin: 0; padding-left: 24px; font-size: var(--text-sm); line-height: 1.5; color: var(--muted); }
.ch-toc li { margin: 3px 0; padding-left: 2px; }
.ch-toc a { color: var(--ink2); text-decoration: underline 1px transparent; text-underline-offset: 3px; transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease); }
.ch-toc a:hover { color: var(--ink); text-decoration-color: currentColor; }
.ch-toc + h3 { margin-top: 0; }

.ch-stage { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: calc(var(--nav) + 20px); margin: 0; min-width: 0; }
.stage-box { position: relative; height: min(72vh, 640px); border-radius: 18px; background: radial-gradient(800px 500px at 60% 20%, #fff 0%, #f1f3fa 60%, #e9ecf6 100%); overflow: hidden; }
.stage-box .fig2d { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; overflow: auto; }
.stage-box .fig2d svg { max-width: 100%; height: auto; display: block; }
.fig2d-wrap { width: 100%; }
.fig2d-wrap svg { width: 100%; height: auto; display: block; }
.fig-cap { margin: 12px 4px 0; font-size: var(--text-sm); line-height: 1.5; color: var(--ink2); }
.fig-cap b { color: var(--accent); font-weight: 600; }
.slot3d, .slot3d > div { position: absolute; inset: 0; }
.chapter:not(.has-scene) .guide3d,
.chapter:not(.has-scene) .stage-hint,
.chapter:not(.has-scene) .scene-play,
.chapter.has-scene .guide2d,
.chapter.has-scene .fig2d { display: none; }
.chapter:not(.has-scene) .stage-box { height: auto; overflow: visible; }
.chapter:not(.has-scene) .fig2d { position: relative; display: block; padding: 16px; }
.ch-stage figcaption { margin-top: 10px; font-size: var(--text-sm); color: var(--ink2); }
.ch-stage figcaption p { margin: 0; }
.stage-info { min-height: 48px; margin-top: 10px; font-size: var(--text-sm); color: var(--ink2); }
.ch-stage .stage-info { min-height: 0; }
.stage-info b { color: var(--ink); font-weight: 600; }
.stage-hint { position: absolute; right: 14px; top: 12px; font-size: var(--text-sm); color: var(--muted); pointer-events: none; }
.scene-play { position: absolute; left: 12px; bottom: 12px; padding: 5px 12px; background: #fff; border: 1px solid #bcc1d2; border-radius: 8px; font-size: var(--text-sm); cursor: pointer; }

.ch-study { grid-column: 1; min-width: 0; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
.ch-study p { font-size: var(--text-body); color: var(--ink); margin: 0 0 16px; }
.ch-steps { counter-reset: s; list-style: none; padding: 0; margin: 14px 0 6px 10px; border-left: 2px solid var(--line); }
.ch-steps li { counter-increment: s; position: relative; padding: 0 0 12px 24px; font-size: var(--text-body); color: var(--ink); }
.ch-steps li::before { content: counter(s); position: absolute; left: -11px; top: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink); font-size: 11px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.check summary, .ch-refs summary, .ch-more > summary { cursor: pointer; font-size: var(--text-sm); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.check details p { margin-top: 10px; }
.ch-more { margin: 14px 0 4px; }
.ch-more[open] > summary { margin-bottom: 10px; }
.ch-more p { margin: 0 0 12px; }
.ch-code pre { margin: 6px 0 16px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-x: auto; font: 13px/1.62 var(--mono); color: var(--ink); tab-size: 4; }
.ch-code code { font: inherit; }
.ch-code .code-note { color: var(--muted); }
.ch-code a { color: var(--ink); text-underline-offset: 3px; }
.ch-models { margin: 26px 0 14px; }
.ch-models > span { display: block; font-size: var(--text-sm); color: var(--muted); margin-bottom: 8px; }
.ch-models .keys { gap: 6px 18px; }
.ch-refs { margin-top: 16px; font-size: var(--text-sm); }
.ch-refs li, .srcs li { scroll-margin-top: 84px; }
.refs { font-size: var(--text-sm); color: var(--ink2); padding-left: 22px; margin: 16px 0 0; }
.refs > li { margin-bottom: 12px; }
.refs a { color: var(--ink2); }
.refs ul { list-style: none; padding: 0; margin: 4px 0 0; }
.refs ul li { margin: 0 0 4px; color: var(--muted); scroll-margin-top: 84px; }
.refs .loc { color: var(--ink2); }
.refs q { font-style: italic; }
.refs ul li.hit, .refs ul li.hit .loc { color: var(--ink); }
sup.cite { font-size: 11px; line-height: 0; }
sup.cite a { text-decoration: none; color: var(--accent); padding: 0 1px; cursor: help; }
.chapter sup.cite a { padding: 8px 3px; }

.ch-pager {
  margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px 28px; align-items: start;
  font-size: var(--text-body); line-height: 1.35;
}
.ch-pager .prev, .ch-pager .next { text-decoration: underline 1.5px transparent; text-underline-offset: 4px; color: var(--ink); transition: text-decoration-color 160ms var(--ease); }
.ch-pager a.prev:hover, .ch-pager a.next:hover { text-decoration-color: var(--ink); }
.ch-pager span { display: block; }
.ch-pager a span { font-size: var(--text-sm); color: var(--muted); margin-bottom: 2px; text-decoration: none; }
.ch-pager .next { text-align: right; }
.ch-pager .all { font-size: var(--text-sm); padding-top: 2px; }

/* interactive 2D causal mask figure */
.mask-figure { max-width: 560px; margin: auto; }
.mask-grids { display: flex; justify-content: center; gap: 10px; }
.mask-grids > div { flex: 1; max-width: 260px; min-width: 0; text-align: center; }
.mask-grids strong { font-size: var(--text-sm); }
.mask-grids svg { width: 100%; display: block; }
.mask-figure label { display: flex; gap: 16px; align-items: center; margin: 18px 0 8px; font-size: var(--text-sm); }
.mask-figure input { flex: 1; min-width: 0; accent-color: var(--accent); }
.mask-figure p { font-size: var(--text-sm); margin: 0; }

/* ---------- model detail sheet ---------- */
.sheet { position: fixed; inset: var(--nav) 0 0 0; z-index: 50; background: rgba(15, 18, 30, .32); display: flex; justify-content: flex-end; }
.sheet[hidden] { display: none; }
.sheet-panel { width: min(1180px, 100vw); height: 100%; background: #fff; overflow-y: auto; animation: slide 220ms var(--ease); }
@keyframes slide { from { transform: translateX(36px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 14px 30px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.sheet-head .close { border: 0; background: var(--soft); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.d-hero { padding: 30px 30px 10px; }
.d-hero h2 { font-size: clamp(32px, 4vw, 44px); font-weight: 500; letter-spacing: -.025em; margin: 0 0 10px; line-height: 1.06; }
.d-hero .keys { margin: 0 0 14px; }
.d-hero .summary { font-size: var(--text-body); color: var(--ink2); max-width: 65ch; margin: 0; }
.d-tabs { display: flex; gap: 24px; padding: 20px 30px 10px; font-size: var(--text-sm); color: var(--ink2); }
.d-tabs button { border: 0; background: none; padding: 3px 0; font-size: var(--text-sm); color: var(--muted); cursor: pointer; text-decoration: underline 1.5px transparent; text-underline-offset: 5px; transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease); }
.d-tabs button:hover { color: var(--ink); }
.d-tabs button.on { color: var(--ink); text-decoration-color: var(--ink); }
.d-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.d-stage { margin: 0 30px; }
.d-stage .stage-box { height: min(68vh, 680px); }
.d-diagram { margin: 0 30px; border: 1px solid var(--line); border-radius: 18px; padding: 8px; background: #fff; }
.d-diagram svg { width: 100%; height: auto; display: block; }
.block-controls label { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 12px; font-size: var(--text-sm); font-weight: 600; }
.block-controls select { max-width: 100%; min-width: 0; font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; }
.run-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.run-controls button { padding: 6px 10px; font: inherit; font-size: var(--text-sm); background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.run-controls span { font-size: var(--text-sm); }
.view-evidence { font-size: var(--text-sm); color: var(--ink2); margin: 0 0 16px; }
.view-evidence p { margin: 0 0 6px; max-width: 72ch; }

.d-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 46px; padding: 34px 30px 60px; }
.facts { font-size: var(--text-sm); border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.facts th { text-align: left; font-weight: 400; color: var(--muted); padding: 7px 10px 7px 0; vertical-align: top; width: 46%; }
.facts td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.facts tr:first-child td { border-top: 1px solid var(--line); }
.discovery { margin: 0 0 28px; padding: 16px 0 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.discovery b { display: block; font-size: var(--text-sm); color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.d-text .discovery p { margin: 0; }
.d-text .discovery .adopted { margin-top: 8px; font-size: var(--text-sm); color: var(--ink2); }
.discovery .adopted a { text-underline-offset: 3px; }
.d-text h3 { font-size: var(--text-sm); color: var(--ink); font-weight: 600; margin: 30px 0 8px; }
.d-text h3:first-child { margin-top: 0; }
.d-text p, .d-text li { font-size: var(--text-body); }
.d-text ul { padding-left: 20px; margin: 0; }
.d-text li { margin-bottom: 8px; }
.d-text .d-mech { list-style: none; padding: 0; margin: 0 0 4px; columns: 2; column-gap: 28px; }
.d-text .d-mech li { font-size: var(--text-sm); margin: 0 0 6px; break-inside: avoid; }
.d-mech a { color: var(--ink2); text-underline-offset: 3px; }
.d-mech a:hover { color: var(--ink); }
.origin, .tag { font-size: var(--text-sm); font-weight: 400; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.origin::before, .tag::before { content: "("; }
.origin::after, .tag::after { content: ")"; }
.srcs { font-size: var(--text-sm); color: var(--ink2); padding-left: 20px; }
.srcs li { margin-bottom: 8px; }
.srcs q { display: block; color: var(--muted); font-style: italic; margin-top: 2px; }
.d-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.btn { border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: var(--text-sm); cursor: pointer; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }

/* ---------- compare ---------- */
.cmp-pick { max-width: var(--wide); margin: 0 auto 26px; }
.cmp-stage { max-width: var(--wide); margin: 0 auto; container-type: inline-size; }
.cmp-stage .stage-box { height: min(64vh, 600px); }
.cmp-model-names { display: none; }
@container (max-width: 560px) {
  .cmp-stage .stage-box { height: clamp(280px, 90cqw, 400px); }
  .cmp-stage .lab3 { display: none; }
  .cmp-model-names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 10px; font-size: var(--text-sm); text-align: center; overflow-wrap: anywhere; }
}
.cmp-2d { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cmp-2d > div { text-align: center; }
.cmp-2d svg { width: 100%; height: 420px; }
.diff { max-width: var(--wide); margin: 26px auto 0; width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.diff th, .diff td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.diff thead th { color: var(--muted); font-weight: 500; }
.diff tbody th { color: var(--muted); font-weight: 400; width: 22%; }
.diff tr.changed td { background: #fbfaf2; }
.cache-note { max-width: var(--wide); margin: 12px auto 0; }

/* ---------- sources & footer ---------- */
.src-cols { max-width: var(--wide); margin: 0 auto; columns: 2; column-gap: 50px; list-style: none; padding: 0; font-size: var(--text-sm); }
.src-cols li { break-inside: avoid; margin-bottom: 9px; color: var(--ink2); }
.src-cols a { text-decoration-color: #c9cad6; text-underline-offset: 3px; }
.src-cols a:hover { text-decoration-color: currentColor; }
footer.foot { max-width: var(--wide); margin: 0 auto; padding: 30px 28px 60px; font-size: var(--text-sm); color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- 3D labels + tooltip ---------- */
.lab3 { font: 11px/1.25 var(--mono); color: #30303a; pointer-events: none; white-space: nowrap; }
.lab3 span { display: inline-block; text-align: center; background: rgba(255, 255, 255, .9); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.lab3.r span { transform: translateX(50%); }
.lab3.l span { transform: translateX(-50%); }
.lab3.above span { transform: translateY(-62%); }
.lab3.word span { background: none; border: 0; font: 13px/1 var(--sans); color: var(--ink); }
.lab3.word.future span { color: var(--muted); }
.lab3.word.now span { color: var(--expert); font-weight: 600; }

.tip {
  position: fixed; z-index: 80; pointer-events: none;
  max-width: min(340px, calc(100vw - 16px));
  background: var(--ink); color: #fff; font-size: var(--text-sm); line-height: 1.45;
  border-radius: 9px; padding: 9px 11px; opacity: 0;
  transition: opacity 140ms var(--ease);
}
.tip q { display: block; color: #c9cbe0; font-style: italic; margin-top: 4px; }
.tip .tip-loc { display: block; margin-top: 7px; opacity: .82; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .intro { display: flex; flex-direction: column-reverse; gap: 20px; }
  .toc { position: static; width: min(100%, var(--col)); margin: auto; }
  .toc ol { position: static; columns: 2; column-gap: 30px; }
  .toc li { break-inside: avoid; }
}

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr); }
  .collage { height: 420px; order: -1; }
  .collage .c2 { top: 48%; }
  .collage .c3 { top: 32%; }
  .collage .c4 { top: 65%; }
  .ch-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .ch-stage, .ch-study { grid-column: 1; grid-row: auto; order: 0; }
  .ch-stage { position: relative; top: 0; width: 100%; max-width: 680px; }
  .ch-text { order: 1; }
  .ch-study { order: 2; }
  .ch-grid, .ch-head, .plate, .ch-pager { max-width: 680px; margin-left: auto; margin-right: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .d-body { grid-template-columns: minmax(0, 1fr); }
  .src-cols { columns: 1; }
}

@media (max-width: 680px) {
  :root { --nav: 88px; }
  .nav { padding: 0 16px; flex-wrap: wrap; gap: 0 8px; align-content: center; }
  .nav .brand { flex: 1; font-size: 15px; }
  .nav nav { display: flex; order: 1; flex: 0 0 100%; justify-content: space-between; gap: 6px; padding-top: 6px; }
  .nav nav a { padding: 2px 0; }
  .hero { padding: calc(var(--nav) + 20px) 16px 36px; min-height: 0; }
  .hero-inner { min-height: auto; gap: 20px; }
  .hero-text { order: -2; }
  .collage { height: 296px; }
  .collage .repeat { top: 8px; left: 0; width: 64%; font-size: 14px; padding: 10px 14px; }
  .collage .c1 { right: 0; top: 0; width: 42%; }
  .collage .c3 { left: 8%; top: 104px; width: 38%; }
  .collage .c2 { right: 0; top: 132px; width: 48%; }
  .collage .c4 { left: 0; top: 204px; width: 34%; }
  .intro, .map-sec, .story, .gallery, .compare, .sources { padding-left: 16px; padding-right: 16px; }
  .chapter-view, .models-view { padding: 22px 16px 24px; }
  .ch-back { margin-bottom: 20px; }
  .toc ol { columns: 1; }
  .limits > div { grid-template-columns: minmax(0, 1fr); }
  .legend { grid-template-columns: minmax(0, 1fr); }
  .stage-box { height: 380px; }
  .chapter:not(.has-scene) .fig2d { padding: 12px; }
  .mask-grids { gap: 4px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .ch-pager { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 40px; }
  .ch-pager .all { grid-column: 1 / -1; grid-row: 2; }
  .sheet-head { padding: 10px 12px; gap: 6px; }
  .sheet-head .note { flex: 1; }
  .d-hero, .d-tabs { padding-left: 16px; padding-right: 16px; }
  .d-stage, .d-diagram { margin: 0 12px; }
  .d-diagram { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .d-diagram svg { width: 1120px; max-width: none; }
  .d-body { padding: 26px 16px 50px; }
  .d-text .d-mech { columns: 1; }
  .cmp-2d { grid-template-columns: minmax(0, 1fr); }
  .diff { display: block; overflow-x: auto; }
  .block-view .lab3.r span { transform: translateX(-35%); }
  .block-view .lab3.l span { transform: translateX(35%); }
}

@media (max-width: 560px) {
  .f-say { line-height: 1.6; }
  .pick { white-space: normal; display: inline; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .f-foot { flex-wrap: wrap; gap: 0 18px; padding-bottom: 10px; }
  .f-foot input[type=search] { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sheet-panel { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
