@font-face { font-family: "InterV"; src: url("../vendor/type/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JBMonoV"; src: url("../vendor/type/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --font: "InterV", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JBMonoV", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --ease: cubic-bezier(.2,.7,.2,1);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fafaf9; --surface: #ffffff; --surface-2: #f3f3f1; --border: rgba(28,29,33,.08); --border-strong: rgba(28,29,33,.14);
  --text: #1c1d21; --text-2: #3d4048; --muted: #6b6f78; --on-strong: #ffffff;
  --q: #2563eb; --k: #d9630b; --v: #0f9d58; --a: #7c3aed;
  --enc: #4f6bd8; --dec: #c43d7a;
  --emb: #db2777; --norm: #b88a00; --ffn: #0891b2; --lin: #64748b;
  --pos: #0e7490; --neg: #c2410c;
  --hl: rgba(124,58,237,.08);
  --shadow: none;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014; --surface: #15181e; --surface-2: #1b1f26; --border: rgba(232,233,236,.10); --border-strong: rgba(232,233,236,.16);
  --text: #e8e9ec; --text-2: #c4c7ce; --muted: #8d939e; --on-strong: #0e1014;
  --q: #6ea8ff; --k: #ffa45c; --v: #4cd494; --a: #b197fc;
  --enc: #8aa2ff; --dec: #f17fb3;
  --emb: #f472b6; --norm: #e8c14a; --ffn: #3fd0ea; --lin: #9aa6b8;
  --pos: #3fd0ea; --neg: #ff9a6b;
  --hl: rgba(177,151,252,.10);
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.68; font-feature-settings: "cv11", "ss01"; transition: background-color .3s var(--ease), color .3s var(--ease); }
a { color: inherit; }
strong { font-weight: 620; }
.mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.tiny { font-size: 13.5px; line-height: 1.55; }
.c-q { color: var(--q); font-weight: 600; } .c-k { color: var(--k); font-weight: 600; } .c-v { color: var(--v); font-weight: 600; }
.c-enc { color: var(--enc); } .c-dec { color: var(--dec); }
.cq { color: var(--q); } .ck { color: var(--k); } .cv { color: var(--v); }

/* progress + floating theme toggle (no nav bar) */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; }
.progress-bar { height: 100%; width: 0; background: var(--text); transition: width .1s linear; }
.theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 80; width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px); color: var(--text); cursor: pointer; transition: border-color .2s, background .2s, right .32s var(--ease); }
.theme-toggle:hover { border-color: var(--border-strong); background: var(--surface); }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
@media (min-width: 901px) { body.panel-open .theme-toggle { right: calc(min(700px, 52vw) + 14px); } }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
.wrap.narrow { max-width: 920px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--text-2); margin-top: 22px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.sw.q { background: var(--q); } .sw.k { background: var(--k); } .sw.v { background: var(--v); } .sw.a { background: var(--a); } .sw.enc { background: var(--enc); } .sw.dec { background: var(--dec); }

/* build section */
.build { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 56px; margin-top: 24px; }
.diagram-pin { position: sticky; top: 16px; height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 8px 0 12px; }
.diagram-svg { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.diagram-svg svg { width: 100%; height: 100%; max-height: 100%; display: block; }
.diagram-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.diagram-status { font: 500 12.5px var(--mono); color: var(--muted); }
.btn-ghost.sm, .btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.steps { list-style: none; margin: 0; padding: 18vh 0 34vh; }
.step { min-height: 58vh; display: flex; align-items: center; }
.step-card { padding: 22px 0; border: none; border-radius: 0; background: transparent; opacity: .42; transform: translateY(6px); transition: opacity .45s var(--ease), transform .45s var(--ease), border-color .3s, background .2s; width: 100%; cursor: pointer; }
.step-card { visibility: hidden; opacity: 0; }
.step.seen .step-card { visibility: visible; opacity: .42; transform: none; }
.step.on .step-card { visibility: visible; opacity: 1; transform: none; }
.step-card:hover, .step.on .step-card:hover { background: transparent; }
.step-card:hover h3 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.step-card:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.step-kicker { font: 500 12px var(--mono); color: var(--muted); display: flex; align-items: center; gap: 8px; }
.step-kicker .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.step-card h3 { margin: 8px 0 8px; font-size: 22px; cursor: pointer; }
.step-card p { color: var(--text-2); font-size: 16px; margin-bottom: 16px; }
.open-hint { display: inline-block; font: 550 12.5px var(--font); color: var(--muted); border-bottom: 1px solid var(--border-strong); padding-bottom: 1px; }

.reveal { opacity: 0; transition: opacity .5s var(--ease); pointer-events: none; }
.reveal.shown { opacity: 1; pointer-events: auto; }
.placeholder { transition: opacity .4s; pointer-events: none; }
.blk { cursor: pointer; outline: none; }
.blk .body { transition: stroke-width .25s, fill .25s; }
.blk text { pointer-events: none; }
.blk:hover .body, .blk:focus-visible .body { stroke-width: 2.4; }
.blk.current .body { stroke-width: 2.4; }
.blk.open .body { stroke-width: 2.8; fill: color-mix(in srgb, var(--a) 22%, var(--surface)) !important; }
.blk-frame { cursor: pointer; }
.blk-frame:hover, .blk-frame.open { stroke-width: 2.4; }

/* detail panel */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(700px, 52vw); z-index: 70; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(0,0,0,.08); transform: translateX(102%); transition: transform .32s var(--ease); display: flex; flex-direction: column; visibility: hidden; --accent: var(--a); }
.panel.open { transform: none; visibility: visible; }
.panel-head { position: relative; padding: 18px 56px 14px 26px; border-bottom: 1px solid var(--border); }
.panel-head::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.panel-grip { display: none; }
.panel-kicker { font: 500 12px var(--mono); color: var(--muted); }
.panel-title { margin: 4px 0 0; font-size: 21px; letter-spacing: -.015em; }
.panel-close { position: absolute; right: 14px; top: 16px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.panel-close:hover { background: var(--surface-2); }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 26px 40px; font-size: 15.5px; }
.panel-body p { color: var(--text-2); }
.d-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 24px 0 8px; font-weight: 650; }
.panel .viz { margin: 8px 0 18px; padding: 14px; box-shadow: none; }
.panel .formula { box-shadow: none; background: var(--bg); margin: 8px 0 14px; }
.panel .symbols > div { grid-template-columns: 110px 1fr; }
.panel .mha-heads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel .cross-grid, .panel .pe-grid { grid-template-columns: minmax(0, 1fr); }
.panel .pe-readout { min-height: 0; }
.panel .attn-split { grid-template-columns: minmax(0, 1fr); }
.panel .attn-lines svg, .panel .cross-lines svg { max-width: 380px; }
.panel .overview-caption { position: static; }
@media (min-width: 901px) { .steps-col { transition: opacity .3s; } body.panel-open .steps-col { opacity: .12; } }
.backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.38); opacity: 0; transition: opacity .25s; }
.backdrop.show { opacity: 1; }

/* shift grid */
.shift-grid { display: grid; gap: 8px 6px; align-items: center; overflow-x: auto; }
.shift-grid .tok { justify-content: center; font-size: 12px; padding: 4px 4px; }
.sg-l { font-size: 12px; color: var(--muted); padding-right: 8px; white-space: nowrap; }
.sg-n { font: 500 11px var(--mono); color: var(--muted); text-align: center; }
.sg-a { text-align: center; color: var(--muted); font-size: 13px; line-height: 1; }

/* resources */
.res { list-style: none; padding: 0; margin: 28px 0 48px; display: grid; gap: 28px; }
.res a { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: transparent; text-decoration: none; }
.res a:hover b { text-decoration: underline; text-underline-offset: 3px; }
.res b { font-weight: 620; font-size: 16px; }
.res span { color: var(--muted); font-size: 14.5px; }

.hero { padding: 56px 28px 8px; }
.eyebrow { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
h1 { font-size: clamp(34px, 5vw, 50px); line-height: 1.08; letter-spacing: -.028em; margin: 0 0 22px; font-weight: 700; }
.lead { font-size: 19px; color: var(--text-2); max-width: 720px; margin: 0 0 14px; }
.lead.small { font-size: 16.5px; }
.tok-inline { font-family: var(--mono); font-size: .86em; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.tok-inline.enc { background: color-mix(in srgb, var(--enc) 13%, transparent); color: var(--enc); }
.tok-inline.dec { background: color-mix(in srgb, var(--dec) 13%, transparent); color: var(--dec); }

.sec { padding-top: 56px; padding-bottom: 8px; margin-top: 40px; }
.sec .sec-head { border-top: 1px solid var(--border); padding-top: 40px; }
.sec-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.sec-num { font-family: var(--mono); font-size: 13px; color: var(--a); }
h2 { font-size: clamp(25px, 3.2vw, 31px); letter-spacing: -.02em; line-height: 1.2; margin: 0; font-weight: 680; }
h3 { font-size: 20px; letter-spacing: -.012em; margin: 40px 0 8px; font-weight: 640; }
p { margin: 0 0 16px; }
.note { font-size: 14.5px; color: var(--muted); }

.qkv-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.pill { display: inline-block; min-width: 64px; text-align: center; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; margin-right: 10px; }
.pill.q { color: var(--q); background: color-mix(in srgb, var(--q) 12%, transparent); }
.pill.k { color: var(--k); background: color-mix(in srgb, var(--k) 12%, transparent); }
.pill.v { color: var(--v); background: color-mix(in srgb, var(--v) 12%, transparent); }

/* formula block */
.formula { margin: 22px 0 26px; padding: 18px 22px 8px; border-left: 1.5px solid var(--a); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.formula .katex-display { margin: .6em 0 .9em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.08em; }
.symbols { margin: 4px 0 10px; display: grid; gap: 7px; font-size: 14.5px; line-height: 1.55; }
.symbols > div { display: grid; grid-template-columns: 128px 1fr; gap: 14px; }
.symbols dt { text-align: right; color: var(--text); }
.symbols dd { margin: 0; color: var(--text-2); }
.symbols .katex { font-size: 1em; }

/* viz shell */
.viz { margin: 26px 0 28px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.viz figcaption { font-size: 13.5px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.viz-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.viz-hint { font-size: 13px; color: var(--muted); }
.btn, .btn-ghost { font: 550 13.5px var(--font); height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer; transition: background .2s, border-color .2s, color .2s, transform .1s; }
.btn { background: var(--text); color: var(--bg); border: 1px solid var(--text); }
.btn:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:active, .btn-ghost:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 220px; }
.field.grow { flex: 1; }
.field input { font: 500 14.5px var(--mono); color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; height: 36px; padding: 0 10px; width: 100%; }
.range { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--muted); min-width: 150px; }
.range b { color: var(--text); font-family: var(--mono); font-weight: 600; }
input[type=range] { accent-color: var(--a); width: 160px; }
.switch { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.switch input { accent-color: var(--a); width: 16px; height: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; background: var(--bg); flex-wrap: wrap; }
.seg button { font: 550 13px var(--font); border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.sub-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.sub-title b { font-family: var(--mono); color: var(--q); }

.scale-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.grad { height: 8px; width: 140px; border-radius: 4px; }
.grad.diverging { background: linear-gradient(90deg, var(--neg), color-mix(in srgb, var(--neg) 0%, var(--surface-2)), var(--pos)); }
.scale-note { margin-left: 8px; }

.worked { margin: 8px 0 24px; padding: 16px 20px; border: 1px dashed var(--border); border-radius: var(--radius); }
.worked-title .katex { text-transform: none; }
.worked-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.worked p { font-size: 15px; margin-bottom: 8px; }
.worked .katex-display { overflow-x: auto; overflow-y: hidden; }

/* tooltip */
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--bg); font: 500 12px var(--mono); padding: 6px 9px; border-radius: 6px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; white-space: nowrap; }
.tooltip.show { opacity: 1; transform: translateY(0); }

/* overview */
.overview-wrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.overview-svg svg { width: 100%; height: auto; display: block; }
.overview-caption { position: sticky; top: 80px; padding: 16px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); min-height: 220px; }
.step-count { font: 500 12px var(--mono); color: var(--muted); }
.step-title { margin: 6px 0 8px; font-size: 17px; font-weight: 640; }
.step-text { font-size: 14.5px; color: var(--text-2); margin-bottom: 12px; }
.step-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.blk { cursor: pointer; }
.blk rect { transition: stroke-width .25s, filter .25s, opacity .3s; }
.blk text { pointer-events: none; }
.blk:hover rect.body { stroke-width: 2.2; }
.blk.active rect.body { stroke-width: 2.6; }
.blk.dim { opacity: .38; }
.flow-dot { transition: opacity .3s; }

/* tokens */
.tok { display: inline-flex; align-items: center; font: 550 13px var(--mono); padding: 4px 9px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); color: var(--text); transition: all .25s var(--ease); }
.tok.enc { border-color: color-mix(in srgb, var(--enc) 50%, transparent); color: var(--enc); background: color-mix(in srgb, var(--enc) 8%, transparent); }
.tok.dec { border-color: color-mix(in srgb, var(--dec) 50%, transparent); color: var(--dec); background: color-mix(in srgb, var(--dec) 8%, transparent); }
.tok.new { animation: pop .45s var(--ease); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* embeddings */
.embed-head, .embed-row { display: grid; grid-template-columns: 96px 64px minmax(0, 1fr); gap: 12px; align-items: center; }
.embed-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.embed-rows { display: grid; gap: 7px; }
.embed-row { opacity: 0; transform: translateX(-6px); animation: slidein .4s var(--ease) forwards; }
@keyframes slidein { to { opacity: 1; transform: none; } }
.embed-row .tok { justify-self: start; max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
.embed-row .id { font: 500 13px var(--mono); color: var(--muted); }
.strip { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 2px; height: 26px; }
.strip i { border-radius: 3px; transition: background-color .35s var(--ease); }

/* PE */
.pe-grid { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 18px; align-items: start; }
.pe-heat-wrap { position: relative; padding-left: 18px; }
.axis-label { font-size: 11.5px; color: var(--muted); }
.axis-label.top { margin-bottom: 4px; }
.axis-label.side { position: absolute; left: -26px; top: 50%; transform: rotate(-90deg); transform-origin: center; white-space: nowrap; }
.pe-canvas-box { position: relative; }
.pe-canvas-box canvas { width: 100%; height: 260px; display: block; border-radius: 6px; cursor: crosshair; image-rendering: pixelated; }
.pe-cross { position: absolute; pointer-events: none; border: 1.5px solid var(--text); border-radius: 2px; display: none; }
.pe-readout { font-size: 13.5px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); line-height: 1.7; min-height: 140px; }
.pe-readout .big { font: 600 22px var(--mono); }
.pe-waves svg { width: 100%; height: auto; display: block; margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 550 12px var(--mono); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; transition: all .2s; }
.chip.on { color: var(--text); border-color: currentColor; }
.chip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* stepper */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.stepper button { font: 550 12.5px var(--font); border: 1px solid var(--border); background: transparent; color: var(--muted); padding: 6px 11px; border-radius: 999px; cursor: pointer; transition: all .2s; }
.stepper button .sn { font-family: var(--mono); margin-right: 6px; opacity: .7; }
.stepper button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.step-desc { font-size: 14.5px; color: var(--text-2); margin-bottom: 14px; min-height: 46px; }
.step-desc .katex { font-size: 1.02em; }

/* matrices */
.mat-stage { overflow-x: auto; padding: 6px 2px 14px; }
.eqrow { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; margin: 6px 0 14px; width: max-content; }
.op { font: 500 18px var(--mono); color: var(--muted); }
.mat { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.mat-name { font: 600 13px var(--mono); }
.mat-shape { font: 500 11px var(--mono); color: var(--muted); }
.mat-grid { display: grid; gap: 2px; position: relative; }
.mat-grid .rl, .mat-grid .cl { font: 500 11px var(--mono); color: var(--muted); display: flex; align-items: center; white-space: nowrap; }
.mat-grid .rl { justify-content: flex-end; padding-right: 6px; }
.mat-grid .cl { justify-content: center; padding-bottom: 2px; max-width: 46px; overflow: hidden; }
.cell { min-width: 44px; height: 30px; display: flex; align-items: center; justify-content: center; font: 500 11.5px var(--mono); border-radius: 4px; transition: background-color .35s var(--ease), color .35s, opacity .35s, transform .35s var(--ease); background: var(--surface-2); }
.cell.sm { min-width: 38px; height: 26px; font-size: 11px; }
.cell.rowhl { box-shadow: inset 0 0 0 1.5px var(--text); }
.cell.pending { opacity: .18; }
.cell.ninf { color: var(--muted); }
.rowsum { font: 500 11px var(--mono); color: var(--muted); display: flex; align-items: center; padding-left: 6px; }

.attn-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.attn-lines svg, .cross-lines svg { width: 100%; height: auto; display: block; }
.tk { cursor: pointer; }
.tk rect { transition: fill .2s, stroke .2s; }
.tk text { pointer-events: none; }
.arc { transition: stroke-width .45s var(--ease), stroke-opacity .45s var(--ease); }
.calc-table table, table.calc { border-collapse: collapse; font: 500 12.5px var(--mono); width: 100%; }
table.calc th { font: 600 11px var(--font); color: var(--muted); text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.calc td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.calc td:first-child, table.calc th:first-child { text-align: left; }
table.calc tr.tot td { border-bottom: 0; color: var(--muted); }
.wbar { display: inline-block; height: 7px; border-radius: 4px; background: var(--a); vertical-align: middle; margin-left: 6px; transition: width .4s var(--ease); }

/* MHA */
.mha-tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.mha-tokens .tok { cursor: pointer; }
.mha-tokens .tok.sel { background: var(--q); color: var(--on-strong); border-color: var(--q); }
.mha-heads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.head { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--bg); }
.head-title { font: 600 12.5px var(--font); display: flex; justify-content: space-between; margin-bottom: 2px; }
.head-title span { font-family: var(--mono); color: var(--muted); font-weight: 500; }
.head-desc { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; min-height: 34px; }
.head svg { width: 100%; height: auto; display: block; }
.mha-shape { margin-top: 22px; }
.mha-shape svg { width: 100%; height: auto; display: block; }

/* mask */
.mask-stage { overflow-x: auto; padding-bottom: 6px; }
.gen-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 34px; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* cross */
.cross-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.cross-heat { overflow-x: auto; }

/* LN */
.ln-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.ln-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--bg); }
.ln-panel svg { width: 100%; height: auto; display: block; touch-action: none; }
.ln-stats { font: 500 12px var(--mono); color: var(--muted); margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.ln-stats b { color: var(--text); font-weight: 600; }
.bar-drag { cursor: ns-resize; }

/* FFN */
.ffn-svg svg { width: 100%; height: auto; display: block; }
.ffn-node { transition: fill .4s var(--ease), r .4s var(--ease), opacity .4s; }
.ffn-edge { transition: stroke-opacity .5s; }

/* stacks */
.stacks-svg svg { width: 100%; height: auto; display: block; }
.stacks-caption { font-size: 14px; color: var(--text-2); margin: 12px 0 0; min-height: 44px; }
.layer rect { transition: fill .35s var(--ease), stroke-width .3s; }
.mem-line { transition: stroke-opacity .4s, stroke-width .4s; }

/* output */
.out-controls { display: flex; gap: 8px; margin-bottom: 14px; }
.out-seq { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; min-height: 30px; }
.out-bars svg { width: 100%; height: auto; display: block; }
.bar-rect { transition: width .45s var(--ease), fill .3s; }
.train-table { overflow-x: auto; }
.loss-cell { color: var(--k); }

/* cheatsheet */
.cheat-formulas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 40px 48px; margin: 36px 0 56px; }
.cheat-item { border: 0; background: transparent; padding: 0; }
.card-k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.cheat-item .katex-display { margin: .55em 0 0; overflow-x: auto; overflow-y: hidden; }
.cheat-item .katex { font-size: 1.05em; }
.table-wrap { overflow-x: auto; border: 0; background: transparent; border-radius: 0; margin: 8px 0 48px; }
table.hp { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.hp th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.hp td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
table.hp tr:last-child td { border-bottom: 0; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px 40px; margin: 20px 0 48px; }
.glossary dt { font-weight: 620; font-size: 15px; }
.glossary dd { margin: 2px 0 0; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }

.scroll-hint { display: none; font-size: 12px; color: var(--muted); margin-top: 6px; }
/* output bars (html) */
.pbars { display: grid; gap: 5px; }
.pbar { display: grid; grid-template-columns: 64px minmax(0, 1fr) 56px; gap: 10px; align-items: center; font: 500 12.5px var(--mono); }
.pbar .w { text-align: right; color: var(--text-2); }
.pbar .track { height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.pbar .fill { height: 100%; width: 0; border-radius: 4px; background: var(--lin); transition: width .45s var(--ease), background-color .3s, opacity .3s; }
.pbar .pct { color: var(--muted); text-align: right; }
.pbar.best .pct { color: var(--text); font-weight: 650; }
.pbar.best .fill { background: var(--dec); }
/* svg text defaults */
svg text { font-family: var(--font); }
svg .mono-t { font-family: var(--mono); }


/* watch section */
.watch-kicker { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 32px 0 16px; }
.watch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px 40px; margin: 0 0 12px; }
.watch-item h4 { font-size: 16.5px; font-weight: 620; letter-spacing: -.01em; margin: 12px 0 4px; line-height: 1.3; }
.watch-item p { margin: 0; }
.yt-box { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--surface-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.yt-facade { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.yt-facade img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 78%, transparent); color: var(--text); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--border); transition: transform .2s var(--ease), background .2s; }
.yt-play svg { margin-left: 3px; }
.yt-facade:hover .yt-play, .yt-facade:focus-visible .yt-play { transform: scale(1.06); background: var(--surface); }
.yt-facade:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
.yt-facade.offline { display: flex; align-items: center; justify-content: center; color: var(--muted); font: 500 13.5px var(--font); }
.yt-facade.offline .yt-play { position: static; margin: 0 10px 0 0; flex-shrink: 0; }
.yt-frame { position: absolute; inset: 0; }
.yt-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* responsive */
@media (max-width: 1100px) {
  .build { gap: 32px; }
  .panel { width: min(620px, 62vw); }
}
@media (max-width: 900px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .hero { padding-top: 48px; padding-right: 48px; }
  .lead { font-size: 17px; }
  .build { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .diagram-col { display: contents; }
  .brand { white-space: nowrap; font-size: 14.5px; }
  .diagram-pin { top: 0; height: 48vh; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); padding: 6px 44px 6px 10px; margin: 0 -16px; }
  .diagram-bar { border-top: 0; padding-top: 4px; }
  .steps { padding: 4vh 0 30vh; }
  .step { min-height: 52vh; align-items: flex-start; padding-top: 8vh; }
  .step-card { padding: 18px 0; }
  .step-card h3 { font-size: 19px; }
  .step-card p { font-size: 15px; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 86vh; border-left: 0; border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; transform: translateY(102%); box-shadow: 0 -10px 40px rgba(0,0,0,.18); }
  .panel.open { transform: none; }
  .panel-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: -8px auto 10px; }
  .panel-head { padding: 16px 54px 12px 18px; }
  .panel-head::before { top: 30px; }
  .panel-body { padding: 4px 16px 40px; }
  .panel .symbols > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .panel .symbols dt { text-align: left; }
  body.panel-open { overflow: hidden; }
  .formula .katex-display, .worked .katex-display { font-size: .78em; }
  .diagram-status { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  #revealAll { white-space: nowrap; flex-shrink: 0; }
  .mha-shape, .ffn-svg, .stacks-svg { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mha-shape svg { min-width: 600px; }
  .ffn-svg svg { min-width: 540px; }
  .stacks-svg svg { min-width: 560px; }
  .scroll-hint { display: block; }
  .ln-panels { grid-template-columns: minmax(0, 1fr); }
  .embed-head, .embed-row { grid-template-columns: 70px 40px minmax(0, 1fr); gap: 8px; }
  .strip { height: 22px; }
  .pe-canvas-box canvas { height: 200px; }
  .field { min-width: 0; width: 100%; flex-basis: 100%; }
  input[type=range] { width: 130px; }
  .range { min-width: 0; }
  .glossary { grid-template-columns: minmax(0, 1fr); }
  .watch-grid { grid-template-columns: 1fr; gap: 28px; }
}
.panel:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
