/* 图解 Transformer · figure-first layout */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #151922;
  --ink-2: #353c4b;
  --muted: #5d6677;
  --faint: #8a92a1;
  --line: #e3e6ec;
  --line-2: #d0d5de;
  --accent: #2c55c9;
  --accent-tint: #edf2fe;
  --hot: #c2410c;

  --emb: #f4c3bb; --pe: #f0cde4; --attn: #f7c98f; --norm: #efe6a2; --ffn: #b3d4f0; --lin: #d6cbee; --soft: #c3e3c9;
  --good: #1b7442; --bad: #b42318;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 24px rgba(17, 24, 39, .05);
  --sans: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(1360px, 100% - 40px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--faint); }
.katex { font-size: 1.1em; }
.katex-display { margin: 0; }
/* KaTeX draws the radical bar about 0.04em thick, under half a pixel in small text; thicken it so it never disappears. */
.katex .sqrt svg { stroke-width: 34; }

/* ---------- Buttons & controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 16px; border-radius: 9px; border: 1px solid transparent; font-size: 14px; font-weight: 600; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2c3242; }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #b5bdca; }
.btn:disabled { opacity: .4; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.toolbar.inline { padding: 0; border: 0; background: none; margin: 0 0 14px; }
.ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl-label { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #eceef3; border-radius: 9px; flex-wrap: wrap; }
.seg button { min-width: 32px; height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button:hover:not([aria-pressed="true"]) { background: rgba(255, 255, 255, .75); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 0 0 1px rgba(0, 0, 0, .04); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: baseline; gap: 2px; padding: 3px 9px 3px 6px; min-height: 30px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); font-size: 14px; white-space: nowrap; }
.chip:hover { border-color: #9fb0da; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); color: #1d3c96; box-shadow: inset 0 0 0 1px var(--accent); }
.chip-i { font: 10.5px var(--mono); color: var(--faint); margin-right: 4px; align-self: center; }
.tk-special { font: 600 .8em var(--mono); color: #7a6247; background: #f6efe6; border-radius: 4px; padding: 1px 4px; }
.g { color: var(--faint); font-weight: 400; font-size: .86em; margin-right: 1px; }
.sp { display: inline-block; width: .42em; height: .32em; margin-right: .12em; border: 1.5px solid currentColor; border-top: 0; opacity: .38; vertical-align: baseline; }

/* ---------- Top bar & composer ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); display: grid; grid-template-columns: repeat(3, 4px); gap: 3px; place-content: center; align-items: end; padding-bottom: 8px; flex: none; }
.brand-mark i { display: block; width: 4px; border-radius: 1px; }
.brand-mark i:nth-child(1) { height: 8px; background: var(--emb); }
.brand-mark i:nth-child(2) { height: 14px; background: var(--attn); }
.brand-mark i:nth-child(3) { height: 11px; background: var(--ffn); }
.brand-name { font-size: 17px; font-weight: 700; }
.brand-sub { font-size: 13px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-2); overflow: hidden; text-overflow: ellipsis; }
.topbar-meta { display: flex; align-items: center; gap: 20px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.connection { display: inline-flex; align-items: center; gap: 7px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: #c08a1e; box-shadow: 0 0 0 3px rgba(192, 138, 30, .15); }
.connection.ready i { background: #1f9254; box-shadow: 0 0 0 3px rgba(31, 146, 84, .15); }
.connection.offline i { background: var(--bad); }
.paper-link:hover { color: var(--accent); }

.composer { margin-top: 16px; }
.composer-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 10px 10px 16px; }
.lang { font: 600 12px var(--mono); color: #1d3c96; background: var(--accent-tint); padding: 3px 8px; border-radius: 6px; }
#sentence { flex: 1 1 420px; min-width: 0; border: 0; background: transparent; font-size: 17px; padding: 8px 4px; outline: none; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; }
.example { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 999px; padding: 3px 12px; font-size: 13px; color: var(--ink-2); }
.example:hover { border-color: var(--accent); color: #1d3c96; background: var(--accent-tint); }
.error { margin-top: 8px; color: var(--bad); font-size: 14px; }

/* ---------- Pipeline navigation ---------- */
.pipeline-bar { position: sticky; top: 0; z-index: 20; margin-top: 14px; background: rgba(245, 246, 248, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.pipeline { display: flex; align-items: stretch; gap: 4px; padding: 8px 0; overflow-x: auto; scrollbar-width: thin; }
.pipeline > li { display: flex; align-items: center; flex: none; }
.pipe-arrow { color: var(--faint); font-size: 13px; padding: 0 2px; }
.pipe-group { flex-direction: column; align-items: stretch !important; border: 1px dashed var(--line-2); border-radius: 11px; padding: 2px 4px 4px; background: rgba(255, 255, 255, .5); }
.pipe-group-label { font-size: 11px; color: var(--muted); padding: 0 6px; line-height: 1.5; }
.pipe-group-body { display: flex; gap: 4px; }
.pipe-step { display: flex; align-items: center; gap: 6px; padding: 5px 9px 5px 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.pipe-step .pn { font: 600 11px var(--mono); color: var(--ink-2); background: var(--tone, #e5e7eb); border-radius: 5px; padding: 1px 5px; }
.pipe-step:hover:not(:disabled) { border-color: #aeb8cb; }
.pipe-step[aria-current="step"] { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px rgba(21, 25, 34, .08); }
.pipe-step[aria-current="step"] .pn { background: var(--ink); color: #fff; }
.pipe-step:disabled { opacity: .45; }
.t-emb { --tone: var(--emb); } .t-pe { --tone: var(--pe); } .t-attn { --tone: var(--attn); } .t-norm { --tone: var(--norm); }
.t-ffn { --tone: var(--ffn); } .t-lin { --tone: var(--lin); } .t-soft { --tone: var(--soft); } .t-ink { --tone: #9aa3b2; }

/* ---------- Stage frame ---------- */
.stage-root { margin-top: 20px; min-height: 60vh; transition: opacity .15s; }
.stage-root:focus { outline: none; }
.stage-root.is-loading { opacity: .55; }
.stage { display: grid; gap: 20px; }
.stage-error { padding: 30px; background: #fff4f2; border: 1px solid #f3c3bb; border-radius: var(--radius); color: var(--bad); }
.stage-foot { display: flex; justify-content: space-between; gap: 12px; margin: 26px 0 8px; }
.topic-stage, .topic-stage + .stage-foot { width: min(100%, 780px); margin-inline: auto; }

.st-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 36px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 4px; }
.kicker::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--tone, var(--line-2)); }
.st-head h2 { font-size: 26px; font-weight: 700; line-height: 1.3; }
.lede { margin-top: 6px; color: var(--muted); font-size: 15px; max-width: 48em; }
.st-formulas { display: grid; gap: 6px; padding: 12px 20px; background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: 12px; max-width: 100%; min-width: 0; overflow-x: auto; }
.st-head:has(.t-emb) .st-formulas { border-left-color: var(--emb); }
.st-head:has(.t-pe) .st-formulas { border-left-color: var(--pe); }
.st-head:has(.t-attn) .st-formulas { border-left-color: var(--attn); }
.st-head:has(.t-ffn) .st-formulas { border-left-color: var(--ffn); }
.st-head:has(.t-norm) .st-formulas { border-left-color: var(--norm); }
.st-head:has(.t-lin) .st-formulas { border-left-color: var(--lin); }
.st-head:has(.t-soft) .st-formulas { border-left-color: var(--soft); }
.st-formula .katex { font-size: 1.22em; }

/* ---------- Figures ---------- */
.fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; min-width: 0; }
.fig-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.fig-title { font-size: 17px; font-weight: 680; }
.fig-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fig figcaption { margin-top: 14px; font-size: 13.5px; color: var(--muted); line-height: 1.65; max-width: 60em; }
.scroll-x { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; scrollbar-width: thin; }
.fig-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.split { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.split > * { min-width: 0; max-width: 100%; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: start; }
.stack { display: grid; gap: 20px; }
.sub-title { font-size: 14.5px; font-weight: 650; margin: 18px 0 10px; }
.empty-note { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }

.legend { display: inline-flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.legend-note { font-family: var(--sans); }
.ramp { width: 110px; height: 10px; border-radius: 3px; border: 1px solid var(--line); }
.ramp-seq { background: linear-gradient(90deg, #fffbf5, #fde0b6, #f7aa60, #de6426, #a0320e, #5f1808); }
.ramp-div { background: linear-gradient(90deg, #2864ce, #f8f7f4, #d6541e); }
.hatch { display: inline-block; width: 16px; height: 11px; border-radius: 2px; border: 1px solid var(--line); background: repeating-linear-gradient(135deg, #f1f2f5 0 3px, #d5d9e1 3px 4.5px); }

/* ---------- Heatmaps ---------- */
.hm { display: inline-grid; column-gap: 6px; align-items: start; }
.hm-corner { font-size: 11px; color: var(--faint); align-self: end; text-align: right; padding-bottom: 4px; white-space: nowrap; }
.hm-cols { display: grid; height: 66px; align-items: end; }
.hm-cl { display: flex; justify-content: center; align-items: flex-end; height: 100%; font-size: 12px; color: var(--ink-2); overflow: hidden; }
.hm-cl > span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 64px; overflow: hidden; text-overflow: ellipsis; padding-bottom: 3px; }
.hm-cl.on { color: var(--hot); font-weight: 700; }
.hm-rows { display: grid; text-align: right; }
.hm-rl { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; max-width: 150px; overflow: hidden; color: var(--ink-2); line-height: 1; padding: 0 2px 0 4px; border-radius: 4px; }
.hm-rl.is-link { cursor: pointer; }
.hm-rl.is-link:hover { background: var(--surface-2); color: var(--ink); }
.hm-rl.on { background: var(--accent-tint); color: var(--ink); font-weight: 700; }
.rl-t { overflow: hidden; text-overflow: ellipsis; }
.rl-i { font: 10px var(--mono); color: var(--faint); min-width: 2ch; }
.hm-plot { position: relative; }
.hm-plot.is-link { cursor: crosshair; }
.hm-canvas { display: block; border-radius: 2px; }
.hm-band { position: absolute; pointer-events: none; }
.hm-row-band { left: -3px; right: -3px; box-shadow: 0 0 0 2px var(--accent); border-radius: 2px; }
.hm-col-band { top: -3px; bottom: -3px; box-shadow: 0 0 0 1.5px rgba(194, 65, 12, .75); border-radius: 2px; }
.hm-cellbox { position: absolute; pointer-events: none; box-shadow: 0 0 0 2.5px var(--ink), 0 0 0 4px #fff; border-radius: 1px; z-index: 1; }
.hm-tile .hm-canvas, .hm-strip .hm-canvas { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }

/* ---------- Tooltip ---------- */
.tip { position: fixed; left: 0; top: 0; z-index: 100; display: none; pointer-events: none; max-width: 340px; padding: 8px 11px; border-radius: 8px; background: #1b1f29; color: #f3f4f6; font-size: 13px; line-height: 1.55; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.tip b { color: #fff; }
.tip .tip-num { font-family: var(--mono); color: #fdba74; }
.tip .muted { color: #9ca3af; }
.tip .tip-title { font-weight: 650; margin-bottom: 4px; }
.tip .katex { font-size: 1em; color: #fff; }

/* ---------- Connectors ---------- */
svg.links { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
svg.links .link { fill: none; stroke: #8a92a1; stroke-width: 1.4; }
svg.links .link.faint { stroke: #b9c0cc; stroke-dasharray: 4 3; }
svg.links .link.res { stroke: #c89c12; stroke-width: 1.6; stroke-dasharray: 5 3; }
.link-label { display: flex; justify-content: center; align-items: center; height: 100%; font-size: 12px; color: var(--ink-2); text-align: center; }
.link-label .katex { background: rgba(255, 255, 255, .92); padding: 0 4px; border-radius: 4px; font-size: 1.05em; }

/* ---------- Intro ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 36px; }
.intro .kicker::before { background: var(--attn); }
.intro h1 { font-size: 32px; line-height: 1.25; margin: 6px 0 12px; }
.intro .lede { font-size: 16px; }
.intro-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin-top: 22px; font-size: 14.5px; }
.intro-list li { display: flex; align-items: center; gap: 10px; }
.intro-list .dot { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--tone); font: 600 12px var(--mono); }
.intro-cta { margin-top: 24px; font-weight: 600; color: var(--ink-2); }
.intro-cta::before { content: "↑ "; color: var(--accent); }

/* ---------- 01 Tokens ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.stat b { font: 700 24px var(--mono); }
.stat span { color: var(--muted); font-size: 14px; }
.stat small { flex-basis: 100%; color: var(--faint); font-size: 12px; }
.tokflow { display: flex; flex-wrap: wrap; gap: 14px 8px; align-items: flex-start; }
.tword { display: flex; flex-direction: column; align-items: stretch; }
.tword-cols { display: flex; gap: 3px; }
.tcol { display: grid; justify-items: center; gap: 2px; min-width: 46px; padding: 6px 6px 7px; border-radius: 9px; background: var(--tint); }
.tc-text { font-size: 15px; white-space: pre; color: var(--ink-2); min-height: 22px; }
.sp-vis { color: var(--faint); font-size: 12px; }
.tc-arrow { color: var(--faint); font-size: 11px; line-height: 1; }
.tc-piece { font-size: 15px; font-weight: 650; background: #fff; border-radius: 6px; padding: 1px 7px; white-space: nowrap; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.tc-id { font: 600 13px var(--mono); color: var(--ink); }
.tc-pos { font: 10px var(--mono); color: var(--faint); }
.tword-brace { margin-top: 4px; border: 1.5px solid #c2410c; border-top: 0; height: 9px; border-radius: 0 0 6px 6px; position: relative; }
.tword-brace span { position: absolute; top: 9px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: #9a3412; }
.tword.is-multi { margin-bottom: 18px; }
.vocab-label { font-size: 12px; fill: var(--ink-2); }
.axis-text { font: 11px var(--mono); fill: #7b8494; }
.axis-math { font-family: KaTeX_Math, "Cambria Math", serif; font-style: italic; font-size: 15px; fill: #151922; }
.axis-text.strong { fill: #353c4b; font-weight: 600; font-family: var(--sans); font-size: 12px; }

/* ---------- 02 Embedding ---------- */
.lookup { display: flex; align-items: flex-start; overflow-x: auto; }
.lookup-svg { flex: none; }
.vecsum { display: grid; gap: 10px; margin-top: 16px; }
.vs-row { display: grid; grid-template-columns: 34px 250px auto 80px; align-items: center; gap: 12px; }
.vs-op { font: 600 15px var(--mono); color: var(--muted); text-align: center; }
.vs-label { display: grid; gap: 1px; }
.vs-label small { font-size: 12px; color: var(--faint); }
.vs-range { font: 12px var(--mono); color: var(--faint); }
.vs-row.t-ink .vs-label .katex { font-weight: 600; }
.pe-box { display: grid; grid-template-columns: auto auto; grid-template-areas: "y map" ". x"; gap: 4px 8px; justify-content: start; }
.pe-axis-y { grid-area: y; display: flex; flex-direction: column; justify-content: space-between; font: 11px var(--mono); color: var(--faint); text-align: right; white-space: nowrap; }
.pe-map { grid-area: map; position: relative; }
.pe-axis-x { grid-area: x; display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--faint); }
.pe-bracket { position: absolute; left: -3px; right: -3px; top: -3px; border: 2px solid var(--ink); border-radius: 4px; pointer-events: none; }
.pe-bracket span { position: absolute; right: 6px; bottom: -22px; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--ink); }
.curve-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--ink-2); padding-left: 34px; }
.curve-legend span { display: inline-flex; align-items: center; gap: 6px; }
.curve-legend span::before { content: ""; width: 16px; height: 3px; border-radius: 2px; background: var(--c); }
.curves-box { display: grid; gap: 2px; }
.axis-caption { font-size: 12px; color: var(--faint); text-align: center; }

/* ---------- 03 Attention flow ---------- */
.attn-flow { position: relative; display: grid; gap: 40px; padding: 30px 8px 6px 0; width: max-content; }
.af-row { display: flex; align-items: flex-start; gap: 18px; }
.af-gap { width: 70px; flex: none; }
.qkv-group { display: flex; gap: 16px; padding: 10px 12px 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: #fbfbfd; }
.mblock { display: grid; gap: 6px; justify-items: start; }
.mb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 26px; width: 100%; }
.mb-title .katex { font-size: 1.12em; }
.mb-shape { font: 11px var(--mono); color: var(--faint); white-space: nowrap; }
.lines-box { display: grid; gap: 4px; flex: none; }
.lines-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); padding: 0 40px; }
.attn-lines text { font-size: 13px; fill: var(--ink-2); }
.al-tok rect { fill: transparent; }
.al-tok.is-link { cursor: pointer; }
.al-tok.is-link:hover rect { fill: var(--surface-2); }
.al-tok.on rect { fill: var(--accent-tint); }
.al-tok.on text { font-weight: 700; fill: var(--ink); }
.al-key.on rect { fill: #fde8d8; }
.bars-box { flex: 1; min-width: 300px; overflow-x: auto; }
.wbar { cursor: pointer; }
.wbar-fill { fill: #f2a46b; }
.wbar:hover .wbar-fill { fill: #de6426; }
.wbar.on .wbar-fill { fill: var(--hot); }
.tok-text { font-size: 12px; fill: var(--ink-2); font-family: var(--sans); }
.tok-text.special { font-family: var(--mono); fill: #7a6247; }
.tok-text.de { fill: #1d5a31; }
.cellcalc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.cc-strips { display: grid; gap: 10px; }
.cc-row { display: grid; grid-template-columns: 170px auto; gap: 12px; align-items: center; }
.cc-label { display: grid; }
.cc-label small { font-size: 12px; color: var(--faint); }
.cc-eqs { display: grid; gap: 10px; overflow-x: auto; padding: 12px 16px; background: var(--surface-2); border-radius: 10px; }
.cc-eqs .katex { font-size: 1.08em; }
.cc-eqs .katex-display, .score-calc .katex-display { text-align: left; }
.cc-eqs .katex-display > .katex, .score-calc .katex-display > .katex { text-align: left; }

/* ---------- 04 Heads ---------- */
.head-grid { display: grid; gap: 16px; }
.head-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; justify-items: start; border-top: 4px solid var(--hc); }
.head-card.on { box-shadow: 0 0 0 2px var(--ink); }
.hc-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; width: 100%; font-size: 14px; }
.hc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hc); }
.hc-sp { font: 11px var(--mono); color: var(--faint); white-space: nowrap; }
.hc-tag { margin-left: auto; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.hc-foot { width: 100%; text-align: right; }
.side-note { flex: 1; min-width: 260px; max-width: 520px; display: grid; gap: 16px; align-content: start; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.head-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.head-toggle { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 3px 12px 3px 9px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.head-toggle::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--hc); }
.head-toggle[aria-pressed="false"] { opacity: .45; }
.head-toggle[aria-pressed="false"]::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--hc); }
.concat-flow { display: flex; align-items: center; gap: 22px; width: max-content; padding-top: 6px; }
.cf-block { display: grid; gap: 6px; }
.concat { display: flex; gap: 0; margin-top: 18px; }
.concat-part { position: relative; border-top: 4px solid var(--hc); padding-top: 2px; }
.cp-label { position: absolute; top: -21px; left: 50%; transform: translateX(-50%); font: 600 11px var(--mono); color: var(--ink-2); }
.cf-arrow { display: grid; justify-items: center; gap: 2px; font-size: 13px; color: var(--muted); padding: 0 6px; }
.cf-arrow::after { content: "⟶"; font-size: 26px; line-height: 1; color: var(--faint); }
.cf-arrow small { font: 11px var(--mono); color: var(--faint); }

/* ---------- 05 Sublayers ---------- */
.sub-board { position: relative; display: grid; gap: 10px; width: max-content; padding: 6px 4px 10px; }
.sub-label { font-size: 13px; font-weight: 650; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; }
.sub-label::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }
.sub-row { display: flex; align-items: center; gap: 46px; padding: 62px 0 18px; }
.vtile { display: grid; gap: 6px; justify-items: start; }
.vt-title { font-size: 13px; min-height: 22px; display: flex; align-items: flex-end; }
.vt-title .katex { font-size: 1.05em; }
.vt-note { font-size: 12px; color: var(--muted); max-width: 270px; }
.oplus { width: 30px; height: 30px; border-radius: 50%; border: 1.6px solid #6b7280; display: grid; place-items: center; font: 600 18px var(--mono); color: var(--ink-2); background: #fff; flex: none; }
.ln-panel { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ln-col { display: grid; gap: 6px; }
.ln-col h4 { font-size: 14px; font-weight: 650; }
.ln-col p { font-size: 13.5px; color: var(--muted); }
.ln-arrow { padding: 10px 14px; background: var(--surface-2); border-radius: 10px; }
.ln-arrow::after { content: "⟶"; display: block; text-align: center; font-size: 22px; color: var(--faint); }

/* ---------- 06 Stack ---------- */
.stack-grid { display: grid; gap: 10px; align-items: center; width: max-content; }
.sg-col { font-size: 12.5px; font-weight: 650; text-align: center; border-bottom: 3px solid var(--hc); padding-bottom: 2px; }
.sg-row { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.sg-cell { border-radius: 4px; line-height: 0; }
.sg-cell.on { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px #fff; }
.layer-tiles { display: flex; gap: 30px; width: max-content; padding: 4px 0; }
.lt { display: grid; gap: 6px; justify-items: center; position: relative; }
.lt .vt-title { font-size: 12.5px; color: var(--muted); }
.lt + .lt::before { content: "→"; position: absolute; left: -21px; top: 50%; color: var(--faint); }

/* ---------- 07 Decoding ---------- */
.decode-tools { gap: 10px 14px; }
.decode-status { font-size: 13.5px; color: var(--muted); flex: 1 1 300px; }
.tree-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.lg { width: 16px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.lg.active { background: #fff; box-shadow: inset 0 0 0 1.5px #374151; }
.lg.finished { background: #dbe7ff; box-shadow: inset 0 0 0 1.5px #2c55c9; }
.lg.pruned { background: #f3f4f6; box-shadow: inset 0 0 0 1px #c5cad3; }
.lg.win { background: #fde8d8; box-shadow: inset 0 0 0 2px var(--hot); }
.tree-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; scrollbar-width: thin; }
.beam-tree { display: block; }
.tree-edge { fill: none; stroke: #a3abb8; stroke-opacity: .8; }
.tree-edge.e-pruned { stroke: #d7dbe2; stroke-dasharray: 3 3; }
.tree-edge.e-finished { stroke: #7f9ce6; }
.tree-edge.win { stroke: var(--hot); stroke-opacity: 1; }
.tree-node rect { fill: #fff; stroke: #374151; stroke-width: 1.3; }
.tree-node .tn-label { font-size: 13px; font-weight: 600; fill: #1f2430; }
.tree-node .tn-prob { font: 10.5px var(--mono); fill: #7b8494; }
.tree-node.n-root rect { fill: #f6efe6; stroke: #b59a7a; }
.tree-node.n-pruned rect { fill: #f6f7f9; stroke: #cdd2da; stroke-dasharray: 3 2; }
.tree-node.n-pruned .tn-label { fill: #8a92a1; font-weight: 500; }
.tree-node.n-finished rect { fill: #e3ecff; stroke: #2c55c9; }
.tree-node.win rect { fill: #fff1e7; stroke: var(--hot); stroke-width: 2.2; }
.tree-node[role="button"] { cursor: pointer; }
.tree-node[role="button"]:hover rect { stroke-width: 2.4; }
.tree-node.sel rect { stroke: var(--ink); stroke-width: 3; }
.tree-node:focus { outline: none; }
.tree-node:focus-visible rect { stroke: var(--accent); stroke-width: 3; }

.node-detail { display: grid; gap: 16px; }
.nd-title { font-size: 18px; font-weight: 700; margin-top: 4px; }
.node-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 20px; }
.nh-path { font-size: 19px; }
.nh-prefix { color: var(--ink-2); }
.nh-new { font-weight: 700; background: #ede7fb; color: #4c2f9a; border-radius: 6px; padding: 1px 8px; }
.nh-facts { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.nh-fact { display: inline-flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); }
.nh-fact b { font: 600 15px var(--mono); color: var(--ink); }
.badge { display: inline-block; font-size: 12.5px; font-weight: 650; padding: 2px 10px; border-radius: 999px; }
.b-active { background: #e3f4e8; color: var(--good); }
.b-finished { background: var(--accent-tint); color: #1d3c96; }
.b-pruned { background: #f1f2f5; color: var(--faint); }
.dist { display: grid; gap: 5px; }
.dist li { display: grid; grid-template-columns: minmax(80px, 140px) minmax(80px, 1fr) 62px 44px; gap: 10px; align-items: center; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.dist .d-bar { height: 12px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.dist .d-bar i { display: block; height: 100%; background: #9ba6b8; border-radius: 3px; }
.dist .d-p { font: 13px var(--mono); text-align: right; }
.dist .d-tag { font-size: 11.5px; color: var(--muted); }
.dist .cand.c-active .d-bar i { background: #3f9a62; }
.dist .cand.c-finished .d-bar i { background: #2c55c9; }
.dist .cand.c-pruned .d-bar i { background: #c3c9d3; }
.dist .chosen { background: #f3effb; font-weight: 700; }
.dist .rest { color: var(--faint); font-size: 13px; }
.src-heat { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.sh-tok { padding: 3px 7px; border-radius: 6px; font-size: 15px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .05); }
.sh-tok .tk-special { background: rgba(255, 255, 255, .6); }
.score-calc { display: grid; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.score-calc .katex { font-size: 1.05em; }

/* ---------- 08 Output ---------- */
.result-card { background: linear-gradient(180deg, #f4faf5, #fff); border: 1px solid #cfe7d6; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px; display: grid; gap: 12px; }
.rc-src { color: var(--muted); font-size: 15px; }
.rc-src b { font-size: 12.5px; color: var(--ink-2); margin-right: 10px; }
.rc-de { font-size: clamp(22px, 2.4vw, 32px); font-weight: 650; line-height: 1.4; color: #12321e; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 6px; }
.fact { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; }
.fact-label { font-size: 13px; color: var(--muted); }
.fact-value { font: 650 19px var(--mono); margin-top: 2px; }
.fact-value small { font: 12px var(--sans); color: var(--faint); margin-left: 6px; }



/* ---------- Paper figures ---------- */
.paper-fig1 { display: grid; gap: 10px; justify-items: center; }
.pf-wrap { position: relative; width: min(100%, 470px); }
.pf-wrap img { display: block; width: 100%; height: auto; }
.pf-badge { position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: var(--ink); color: #fff; font: 700 13px var(--mono); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); padding: 0; }
.pf-badge:hover:not(:disabled) { background: var(--accent); }
.pf-badge:disabled { background: #9aa3b2; cursor: default; }
.paper-fig1 figcaption { font-size: 12.5px; color: var(--muted); text-align: center; max-width: 470px; line-height: 1.6; }
.paper-ref { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
.pr-img { display: block; height: 300px; width: auto; }
.pr-side { display: grid; gap: 10px; min-width: 0; }
.pr-map { border-collapse: collapse; font-size: 14px; width: 100%; }
.pr-map th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line-2); }
.pr-map td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pr-map td:first-child { white-space: nowrap; color: var(--ink-2); }
.pr-note { font-size: 13px; color: var(--muted); }

/* ---------- Provenance & cut line ---------- */
.cutline { font-size: 22px; line-height: 2.1; margin-bottom: 18px; white-space: pre-wrap; }
.cutline .seg { background: var(--tint); border-radius: 4px; padding: 3px 1px; }
.cutline .seg.cut { box-shadow: inset 2.5px 0 0 var(--hot); border-top-left-radius: 0; border-bottom-left-radius: 0; }


/* ---------- Chapters (talk structure) ---------- */
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 8px; }
.chapters { display: flex; gap: 6px; padding: 8px 0 6px; overflow-x: auto; scrollbar-width: thin; }
.chapter-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.chapter-btn .cn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: #eef0f4; font-size: 13px; }
.chapter-btn:hover:not(:disabled) { border-color: #aeb8cb; }
.chapter-btn[aria-current="page"] { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px rgba(21, 25, 34, .08); }
.chapter-btn[aria-current="page"] .cn { background: var(--ink); color: #fff; }
.chapter-btn:disabled { opacity: .45; }
.pipeline { padding-top: 2px; }
.composer { margin-top: 14px; }
.real-head { font-size: 18px; font-weight: 700; margin-top: 8px; padding-top: 18px; border-top: 2px dashed var(--line-2); display: flex; align-items: center; gap: 10px; }
.real-head::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--hot); }

/* ---------- Slide panels (content from the deck) ---------- */
.slide-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px 18px; display: grid; gap: 16px; min-width: 0; }
.topic-content { display: grid; gap: 14px; min-width: 0; }
.topic-content > .s-lead { font-size: clamp(16px, 2.1vw, 20px); line-height: 1.4; }
.topic-content .pic img { max-height: min(47svh, 410px); }
.sp-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sp-head h3 { font-size: 19px; font-weight: 700; color: #c2410c; }
.s-grid { display: grid; gap: 18px 24px; align-items: start; }
.s-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.s-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.s-73 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.s-grid.tight { gap: 12px; }
.s-stack { display: grid; gap: 12px; align-content: start; min-width: 0; }
.s-card { background: #eef3fa; border-radius: 10px; padding: 12px 16px; display: grid; gap: 6px; font-size: 14.5px; line-height: 1.7; color: #24324a; }
.s-card h4 { font-size: 15px; font-weight: 700; color: #1d2f4f; }
.s-card.warm { background: #fcf0e6; }
.s-card.example { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: center; gap: 14px 28px; font-size: 16px; }
.s-card.example em { color: #c2410c; font-style: normal; font-weight: 700; }
.s-card.split-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 14px; }
.s-card.role-card { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; margin-bottom: 16px; }
.s-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.s-cite { font-size: 12.5px; color: var(--faint); }
.s-lead { font-size: 15.5px; font-weight: 700; color: #1d2f4f; }
.s-lead.accent { color: #c2410c; }
.s-sub { color: #3a63a1; font-size: 14.5px; margin: -4px 0 8px; }
.s-muted { color: var(--muted); font-size: 13.5px; }
.s-muted.small { font-size: 12.5px; }
.s-accent { color: #c2410c; font-size: 14px; }
.s-core { font-size: 17px; font-weight: 650; color: #1d2f4f; margin-bottom: 14px; }
.s-core em { color: #c2410c; font-style: normal; }
.s-table { width: 100%; border-collapse: collapse; font-size: 14.5px; border-radius: 10px; overflow: hidden; }
.s-table th { background: #1d2f4f; color: #fff; text-align: left; font-weight: 650; padding: 10px 12px; }
.s-table td { padding: 12px; border-bottom: 1px solid #dfe5ef; color: #24324a; vertical-align: middle; }
.s-table tr:nth-child(2) td { background: #f3f7fc; }
.s-table td:last-child { text-align: center; white-space: nowrap; }
.fix-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; background: #eef3fa; border-radius: 10px; padding: 12px 16px; font-size: 14.5px; color: #24324a; }
.fix-arrow { color: var(--faint); }
.s-link { border: 0; background: none; padding: 0; color: #c2410c; font-weight: 700; font-size: 15px; text-decoration: underline; text-decoration-color: rgba(194, 65, 12, .35); text-underline-offset: 4px; }
.s-link:hover { text-decoration-color: currentColor; }
.proscons { display: grid; gap: 4px; font-size: 14.5px; }
.proscons .pro { color: #1b7442; }
.proscons .con { color: #b42318; }
.s-bullets { display: grid; gap: 6px; padding-left: 20px; list-style: disc; font-size: 14.5px; line-height: 1.7; color: #24324a; }
.s-bullets li::marker { color: #e8651b; }
.s-steps { display: grid; gap: 4px; padding-left: 22px; list-style: decimal; font-size: 14.5px; }
.s-formulas { display: grid; gap: 6px; justify-items: center; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.s-formulas .katex { font-size: 1.18em; }
.pill { background: #e8651b; color: #fff; font-weight: 700; font-size: 13.5px; border-radius: 8px; padding: 6px 14px; white-space: nowrap; }
.step-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.step-row .step-key { display: grid; place-items: center; background: #1d2f4f; color: #fff; font-weight: 700; border-radius: 9px; font-size: 15px; }
.step-row.last .step-key { background: #e8651b; }
.step-row p { background: #eef3fa; border-radius: 9px; padding: 10px 14px; font-size: 14.5px; margin: 0; }
.kv-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.kv-key { display: grid; place-content: center; text-align: center; gap: 2px; color: #fff; border-radius: 9px; padding: 10px; }
.kv-key small { font-size: 12px; opacity: .85; }
.kv-val { background: #eef3fa; border-radius: 9px; padding: 10px 14px; font-size: 14px; line-height: 1.7; display: grid; gap: 4px; }
.kv-val .katex-display { margin: 4px 0 0; }
.c1 { background: #1d2f4f; } .c2 { background: #3a63a1; } .c3 { background: #e8651b; } .c4 { background: #7a3b4f; } .c5 { background: #2f7a42; }
.att-col { border: 1px solid #dfe5ef; border-radius: 12px; overflow: hidden; display: grid; gap: 10px; align-content: start; padding-bottom: 12px; }
.att-head { color: #fff; text-align: center; padding: 10px; display: grid; gap: 2px; }
.att-head b { font-size: 16px; }
.att-head small { opacity: .85; }
.att-col > p, .att-col > .att-f, .att-col > .pic { margin: 0 14px; font-size: 14px; }
.att-f { background: #eef3fa; border-radius: 8px; padding: 6px; overflow-x: auto; overflow-y: hidden; }
.oneliner { background: #1d2f4f; color: #fff; border-radius: 10px; padding: 12px 18px; text-align: center; font-size: 15.5px; }
.oneliner .katex { color: #fff; }
.s-credit { font-size: 12.5px; color: var(--faint); text-align: right; }
.pic { display: grid; gap: 6px; justify-items: center; margin: 0; min-width: 0; }
.pic img { display: block; max-width: 100%; height: auto; border: 1px solid #e3e6ec; border-radius: 6px; cursor: zoom-in; background: #fff; }
.pic figcaption { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; }
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; place-items: center; background: rgba(15, 18, 26, .82); cursor: zoom-out; padding: 24px; }
.lightbox.open { display: grid; }
.lightbox img { max-width: 96vw; max-height: 92vh; background: #fff; border-radius: 6px; }

.slide-tabs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.st-tabbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; background: #faf6f1; border-bottom: 1px solid #efe4d6; }
.st-tabtitle { font-size: 13.5px; font-weight: 700; color: #9a3412; }
.st-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.st-tabs button { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 5px 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.st-tabs button:hover { background: #fff; }
.st-tabs button[aria-selected="true"] { background: #fff; border-color: #e8c9a8; color: #c2410c; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.tab-pane > .slide-panel, .tab-pane > .fig { border: 0; box-shadow: none; border-radius: 0; }

/* ---------- Overview ---------- */
.overview { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 28px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.overview-side { display: grid; gap: 14px; }
.overview-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ov-card { border-radius: 10px; overflow: hidden; display: grid; grid-template-columns: 110px minmax(0, 1fr); }
.ov-card b { color: #fff; display: grid; place-items: center; font-size: 15px; }
.ov-card.c1 b { background: #1d2f4f; } .ov-card.c2 b { background: #3a63a1; } .ov-card.c3 b { background: #e8651b; } .ov-card.c4 b { background: #7a3b4f; }
.ov-card { background: #eef3fa; }
.ov-card p { padding: 10px 12px; font-size: 13.5px; color: #24324a; margin: 0; }
.overview-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ol-item { width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 6px 10px; font-size: 14px; text-align: left; }
.ol-item:hover:not(:disabled) { border-color: #aeb8cb; }
.ol-item:disabled { opacity: .5; }
.ol-item .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--tone); display: grid; place-items: center; font: 600 12px var(--mono); flex: none; }

/* ---------- Paper table ---------- */
.paper-table { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.paper-table img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Path animation ---------- */
.pa-box { display: grid; gap: 10px; }
.pa-controls { display: flex; align-items: center; gap: 8px; }
.pa-time { margin-left: 8px; font: 600 14px var(--mono); color: var(--ink-2); }
.path-anim .pa-row { font-size: 15px; font-weight: 700; fill: var(--ink); }
.path-anim .pa-sub { font-size: 12px; fill: var(--muted); }
.path-anim .pa-status { font-size: 13px; fill: var(--muted); }
.path-anim .pa-status.done { fill: #1b7442; font-weight: 600; }
.path-anim .pa-edge { stroke: #d0d5de; stroke-width: 1.6; }
.path-anim .pa-edge.on { stroke: #8a92a1; }
.path-anim .pa-node { fill: #f4f5f8; stroke: #c9ced8; stroke-width: 1.2; transition: fill .2s; }
.path-anim .pa-node.done { fill: #dbe7ff; stroke: #2c55c9; }
.path-anim .pa-node.now { fill: #2c55c9; }
.path-anim .pa-word { font-size: 13px; text-anchor: middle; fill: var(--ink-2); }
.path-anim .pa-word.key { font-weight: 700; fill: #c2410c; }
.path-anim .pa-signal { fill: #e8651b; }
.path-anim .pa-cnn-edge { stroke: #e3e6ec; stroke-width: 1; }
.path-anim .pa-cnn-edge.cone { stroke: #7f9ce6; stroke-width: 1.4; }
.path-anim .pa-dot { fill: #f4f5f8; stroke: #c9ced8; }
.path-anim .pa-dot.done { fill: #dbe7ff; stroke: #8aa2e0; }
.path-anim .pa-dot.cone { fill: #2c55c9; stroke: #2c55c9; }
.path-anim .pa-dot.key { stroke: #c2410c; stroke-width: 2; }
.path-anim .pa-layer { font: 10.5px var(--mono); fill: var(--faint); text-anchor: end; }
.path-anim .pa-arc { fill: none; stroke: #b9c4e4; stroke-width: 1.3; }
.path-anim .pa-arc.key { stroke: #e8651b; stroke-width: 3; }

/* ---------- Code panels ---------- */
details.code-panel { background: #fbfbfc; border: 1px solid var(--line); border-radius: var(--radius); }
details.code-panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 18px; font-size: 14px; }
details.code-panel > summary::-webkit-details-marker { display: none; }
.code-tag { font: 600 12.5px var(--mono); background: #1d2f4f; color: #fff; border-radius: 6px; padding: 3px 9px; }
.code-sum { color: var(--ink-2); }
.code-files { margin-left: auto; font: 12px var(--mono); color: var(--faint); }
.code-body { padding: 0 18px 16px; display: grid; gap: 12px; }
.code-note { font-size: 13.5px; color: var(--muted); }
.code-note code { font-family: var(--mono); background: #eef0f4; border-radius: 4px; padding: 0 4px; }
.code-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 2px; }
.code-head span { font-family: var(--mono); color: var(--faint); }
pre.code { margin: 0; background: #1b1f29; color: #e6e8ee; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 13px/1.6 var(--mono); }
.c-com { color: #8b93a7; font-style: italic; }
.c-str { color: #a5d6a7; }
.c-num { color: #f9c98a; }
.c-kw { color: #c792ea; }
.c-fn { color: #82aaff; }
.c-self { color: #f78c6c; }

/* ---------- Training ---------- */
.train-input { flex: 1 1 360px; min-width: 0; border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 12px; font-size: 15px; background: var(--surface-2); }
.train-input:focus { outline: none; border-color: var(--accent); background: #fff; }
.tf-grid { display: grid; gap: 8px 4px; width: max-content; padding: 6px 2px; }
.tf-target { display: grid; justify-items: center; gap: 3px; }
.tf-tok { border-radius: 7px; padding: 3px 7px; font-size: 14.5px; font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.tf-tok.in { background: #f3f4f7; color: var(--ink-2); font-weight: 500; }
.tf-p { font: 12px var(--mono); color: var(--ink-2); }
.tf-top { font-size: 11.5px; color: #b42318; white-space: nowrap; }
.tf-top.ok { color: var(--faint); }
.tf-decoder { background: linear-gradient(90deg, #e9e3f7, #efe6fb); border: 1px solid #d6cbee; border-radius: 10px; padding: 10px 14px; text-align: center; font-size: 14px; font-weight: 600; color: #4c2f9a; }
.tf-input { display: grid; justify-items: center; gap: 3px; }
.tf-arrow { color: var(--faint); line-height: 1; }
.tf-i { font: 10.5px var(--mono); color: var(--faint); }
.tf-eqs { display: grid; gap: 6px; margin-top: 10px; overflow-x: auto; overflow-y: hidden; }
.tf-eqs .katex-display { text-align: left; }
.tf-eqs .katex-display > .katex { text-align: left; }
.tf-check { background: #ecf7ee; border: 1px solid #cfe7d6; border-radius: 10px; padding: 12px 14px; color: #1d4d2c; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .st-head { grid-template-columns: minmax(0, 1fr); }
  .fig-pair, .two-col { grid-template-columns: minmax(0, 1fr); }
  .intro { grid-template-columns: minmax(0, 1fr); }
  .s-2, .s-3, .s-73, .paper-table, .overview { grid-template-columns: minmax(0, 1fr); }
  .overview-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-ref { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .cellcalc { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .wrap { width: calc(100% - 20px); }
  .brand-sub, .paper-link { display: none; }
  .st-head, .fig, .intro { padding: 16px; }
  .st-head h2 { font-size: 21px; }
  .intro h1 { font-size: 24px; }
  .intro-list { grid-template-columns: 1fr; }
  .vs-row { grid-template-columns: 24px minmax(0, 1fr); }
  .vs-row .hm, .vs-row .vs-range { grid-column: 2; }
  .cc-row { grid-template-columns: 1fr; }
  .pr-img { height: 200px; }
  .dist li { grid-template-columns: 90px minmax(60px, 1fr) 56px; }
  .dist .d-tag { display: none; }
  .overview-cards, .s-card.example, .s-card.split-card { grid-template-columns: minmax(0, 1fr); }
  .step-row, .kv-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Findings added on the real-computation pages ---------- */
.emb-share { margin-top: 16px; }
.emb-share .stat small .katex { font-size: 1em; }
.cmp { display: grid; gap: 2px; max-width: 760px; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.cmp-legend i, .cmp-bar .track i { display: inline-block; border-radius: 3px; }
.cmp-legend i { width: 14px; height: 10px; margin-right: 6px; vertical-align: middle; }
.cmp-legend i.real, .cmp-bar.real .track i { background: var(--hot); }
.cmp-legend i.alt, .cmp-bar.alt .track i { background: #a3abb9; }
.cmp-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cmp-row.on .cmp-tok { color: var(--hot); }
.cmp-tok { border: 0; background: none; padding: 0; text-align: right; font-size: 14px; color: var(--ink); cursor: pointer; }
.cmp-bars { display: grid; gap: 5px; }
.cmp-bar { display: grid; grid-template-columns: minmax(0, 1fr) 78px; gap: 10px; align-items: center; }
.cmp-bar .track, .mr-row .track { display: block; height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.cmp-bar .track i, .mr-row .track i { display: block; height: 100%; min-width: 1px; }
.cmp-bar b, .mr-row b { font: 600 13px var(--mono); color: var(--ink-2); }
.cmp .stat-row { margin-top: 14px; }
.merge-rank { display: grid; gap: 6px; min-width: 0; flex: 1 1 340px; max-width: 520px; }
.mr-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 52px; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.mr-row:hover { border-color: var(--line-2); }
.mr-row.on { border-color: var(--hc); background: color-mix(in srgb, var(--hc) 7%, #fff); }
.mr-row .track i { background: var(--hc); }
.merge-pairs { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.merge-pairs li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.merge-pairs li b { font: 700 13px var(--mono); color: var(--hot); margin-left: 4px; }
.recap-chart { display: block; margin-top: 16px; }
.recap-chart .rc-grid { stroke: var(--line); }
.recap-chart .rc-lead { fill: #fdecdf; }
.recap-chart .rc-line { fill: none; stroke: var(--hot); stroke-width: 2.5; stroke-linejoin: round; }
.recap-chart .rc-dot { fill: var(--hot); }
.recap-chart .rc-end { fill: #15803d; font-size: 18px; font-weight: 700; }
