/* ============================================================
   How an LLM Works — stylesheet
   ============================================================ */

:root {
  --bg:        #090a12;
  --bg-alt:    #0d0f1c;
  --surface:   #12152a;
  --surface-2: #1a1e38;
  --surface-3: #232848;
  --line:      #2c3258;
  --line-soft: #1f2442;
  --text:      #e8eaf8;
  --dim:       #a1a7cd;
  --dimmer:    #6a7099;
  --accent:    #8b7cff;
  --accent-2:  #b49bff;
  --accent-dk: #5b48d6;
  --cyan:      #46dcf0;
  --amber:     #ffbe4f;
  --rose:      #ff6f91;
  --green:     #4fe3a6;
  --glow:      rgba(139, 124, 255, .40);
  --shadow:    0 18px 48px rgba(0, 0, 0, .50);
  --radius:    14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg:        #f5f6fc;
  --bg-alt:    #ecedf8;
  --surface:   #ffffff;
  --surface-2: #f3f4fd;
  --surface-3: #e8eaf8;
  --line:      #d5d8ee;
  --line-soft: #e6e8f6;
  --text:      #12142a;
  --dim:       #5b6087;
  --dimmer:    #8a90b4;
  --accent:    #5a45d8;
  --accent-2:  #7a63e8;
  --accent-dk: #4331b0;
  --cyan:      #0d92aa;
  --amber:     #b07407;
  --rose:      #d33a63;
  --green:     #0c9c6c;
  --glow:      rgba(90, 69, 216, .22);
  --shadow:    0 14px 34px rgba(30, 32, 80, .10);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent-2); }
:root[data-theme="light"] a { color: var(--accent); }

h1, h2, h3 { line-height: 1.18; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.9rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 4vw, 2.5rem); font-weight: 750; }
h3 { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; }

p { margin: 0 0 1.05em; }
code, kbd { font-family: var(--mono); font-size: .88em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── top bar ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 14px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 700;
  letter-spacing: -.01em; white-space: nowrap; flex: none;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(140deg, var(--accent), var(--cyan));
  box-shadow: 0 0 14px var(--glow);
}
.brand-text { font-size: .98rem; }
@media (max-width: 720px) { .brand-text { display: none; } }

.nav {
  display: flex; gap: 2px; overflow-x: auto; flex: 1 1 auto; min-width: 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 9px;
  color: var(--dim); text-decoration: none;
  font-size: .82rem; font-weight: 600; white-space: nowrap;
  transition: background .18s, color .18s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.active .nav-n { background: var(--accent); color: #fff; border-color: transparent; }
.nav-n {
  display: grid; place-items: center;
  width: 19px; height: 19px; border-radius: 6px; flex: none;
  border: 1px solid var(--line); font-family: var(--mono);
  font-size: .68rem; color: var(--dimmer);
}
@media (max-width: 900px) { .nav-t { display: none; } .nav a { padding: 6px; } }

.theme-toggle {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--dim); cursor: pointer; display: grid; place-items: center;
  transition: color .18s, border-color .18s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-icon {
  width: 15px; height: 15px; border-radius: 50%;
  background: currentColor;
  box-shadow: inset -5px -3px 0 0 var(--surface);
}
:root[data-theme="light"] .theme-icon { box-shadow: inset 0 0 0 0 var(--surface); }

.progress { position: sticky; top: 55px; z-index: 99; height: 2px; background: transparent; }
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

/* ── layout ───────────────────────────────────────────────────────────────── */

.wrap { width: min(1080px, 100% - 2 * clamp(16px, 4vw, 34px)); margin-inline: auto; }
.narrow { width: min(720px, 100%); }

main { display: block; }

.section { padding: clamp(56px, 8vw, 104px) 0; border-top: 1px solid var(--line-soft); }
.section:nth-of-type(even) { background: var(--bg-alt); }

.eyebrow {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent-2); margin: 0 0 .7em;
}
:root[data-theme="light"] .eyebrow { color: var(--accent); }

.lede { font-size: clamp(1.02rem, 2vw, 1.2rem); color: var(--dim); }
.copy { max-width: 66ch; }
.copy p { color: var(--dim); }
.copy strong { color: var(--text); font-weight: 650; }

/* Only hide it when JS is alive to reveal it again. */
html.js .reveal { opacity: 0; transform: translateY(16px); }
html.js .reveal.shown { opacity: 1; transform: none; transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.3,1); }
@media (prefers-reduced-motion: reduce) {
  html.js .reveal, html.js .reveal.shown { opacity: 1; transform: none; transition: none; }
}

/* ── hero ─────────────────────────────────────────────────────────────────── */

.hero {
  position: relative; overflow: hidden;
  padding: clamp(64px, 12vw, 140px) 0 clamp(52px, 8vw, 96px);
}
.hero::before {
  content: ""; position: absolute; inset: -30% -10% auto -10%; height: 130%;
  background:
    radial-gradient(48% 46% at 22% 8%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(42% 42% at 82% 26%, color-mix(in srgb, var(--cyan) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.hero .wrap { position: relative; }
.hero h1 { max-width: 16ch; }
.hero .lede { max-width: 60ch; }

.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

.hero-strip {
  margin-top: clamp(34px, 6vw, 56px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  padding: 18px;
}
.strip-label {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dimmer); margin-bottom: 12px;
}
.pipeline { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.pipe-step {
  flex: 1 1 0; min-width: 122px;
  border: 1px solid var(--line-soft); border-radius: 11px;
  background: var(--surface-2); padding: 12px 12px 13px;
  text-decoration: none; color: inherit;
  transition: border-color .2s, transform .2s, background .2s;
}
.pipe-step:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--surface-3); }
.pipe-n {
  font-family: var(--mono); font-size: .7rem; color: var(--accent-2); display: block; margin-bottom: 3px;
}
:root[data-theme="light"] .pipe-n { color: var(--accent); }
.pipe-t { font-weight: 660; font-size: .92rem; display: block; }
.pipe-d { font-size: .76rem; color: var(--dimmer); display: block; line-height: 1.45; margin-top: 3px; }

/* ── panels & callouts ────────────────────────────────────────────────────── */

.panel {
  margin-top: 28px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.panel-title { font-family: var(--mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.panel-head .spacer { flex: 1 1 auto; min-width: 0; }
.panel-body { padding: clamp(14px, 3vw, 22px); }
.panel-foot {
  padding: 12px 18px; border-top: 1px solid var(--line-soft);
  background: var(--surface-2); font-size: .84rem; color: var(--dimmer);
}

.callout {
  margin: 26px 0 0; padding: 16px 18px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; background: var(--surface);
  font-size: .94rem; color: var(--dim);
}
.callout strong { color: var(--text); }
.callout.warn { border-left-color: var(--amber); }
.callout.note { border-left-color: var(--cyan); }
.callout p:last-child { margin-bottom: 0; }

.grid2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid2, .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid2, .grid3, .grid4 { grid-template-columns: minmax(0, 1fr); } }

/* ── controls ─────────────────────────────────────────────────────────────── */

.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.ctl { display: block; flex: 1 1 190px; min-width: 0; }
.ctl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.ctl-label { font-size: .8rem; color: var(--dim); font-weight: 600; }
.ctl-value { font-family: var(--mono); font-size: .82rem; color: var(--accent-2); }
:root[data-theme="light"] .ctl-value { color: var(--accent); }

.ctl-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 4px; background: var(--surface-3);
  cursor: pointer; margin: 6px 0;
}
.ctl-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.ctl-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--bg);
  background: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}

.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.seg-btn {
  border: 0; background: transparent; color: var(--dim);
  font: inherit; font-size: .82rem; font-weight: 600;
  padding: 5px 11px; border-radius: 7px; cursor: pointer;
  transition: background .16s, color .16s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--accent); color: #fff; }
.seg.mono .seg-btn { font-family: var(--mono); font-size: .78rem; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .86rem; font-weight: 640;
  padding: 7px 15px; border-radius: 9px; cursor: pointer;
  transition: border-color .16s, background .16s, transform .1s;
}
.btn:hover { border-color: var(--accent); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.field {
  width: 100%; font-family: var(--mono); font-size: .92rem; line-height: 1.6;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; resize: vertical;
}
.field:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--glow); }

.stat { border: 1px solid var(--line-soft); border-radius: 11px; background: var(--surface-2); padding: 11px 13px; min-width: 0; }
.stat-k { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dimmer); }
.stat-v { font-family: var(--mono); font-size: 1.32rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.stat-v.accent { color: var(--accent-2); }
:root[data-theme="light"] .stat-v.accent { color: var(--accent); }
.stat-n { font-size: .74rem; color: var(--dimmer); line-height: 1.4; }

.hint { font-size: .82rem; color: var(--dimmer); margin-top: 10px; }
.hint:first-child { margin-top: 0; }

/* ── tokens ───────────────────────────────────────────────────────────────── */

.tok-out { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 16px; min-height: 44px; align-content: flex-start; }
.tok {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 7px 4px; border-radius: 7px;
  font-family: var(--mono); font-size: .88rem; line-height: 1.25;
  border: 1px solid transparent; cursor: default;
  transition: transform .12s;
}
.tok:hover { transform: translateY(-2px); }
.tok-txt { white-space: pre; }
.tok-id { font-size: .62rem; opacity: .62; letter-spacing: .02em; }
.tok.space .tok-txt::before { content: "·"; opacity: .45; }

/* ── bars ─────────────────────────────────────────────────────────────────── */

.bars { display: grid; gap: 5px; }
.bar-row {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: minmax(84px, 26%) minmax(0, 1fr) 62px;
}
.bar-lab { font-family: var(--mono); font-size: .84rem; color: var(--text); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 19px; border-radius: 5px; background: var(--surface-3); overflow: hidden; min-width: 0; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent-dk), var(--accent)); transition: width .25s ease; }
.bar-num { font-family: var(--mono); font-size: .78rem; color: var(--dim); text-align: right; }
.bar-row.muted .bar-lab, .bar-row.muted .bar-num { color: var(--dimmer); opacity: .5; }
.bar-row.muted .bar-fill { background: var(--surface-3); }
.bar-row.picked .bar-lab { color: var(--amber); font-weight: 700; }
.bar-row.picked .bar-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--amber) 55%, var(--accent-dk)), var(--amber)); }

/* ── vector strips ────────────────────────────────────────────────────────── */

.vec { display: flex; gap: 2px; align-items: flex-end; height: 56px; }
.vec-cell { flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--surface-3); position: relative; height: 100%; }
.vec-pos, .vec-neg { position: absolute; left: 0; right: 0; border-radius: 2px; }
.vec-pos { bottom: 50%; background: var(--accent); }
.vec-neg { top: 50%; background: var(--rose); }

.axis-list { display: grid; gap: 4px; }
.axis-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px; align-items: center; gap: 10px; font-size: .84rem; }
.axis-name { font-family: var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.axis-val { font-family: var(--mono); text-align: right; color: var(--text); }

/* ── word map ─────────────────────────────────────────────────────────────── */

.map-wrap { position: relative; min-width: 0; }
.map-node { cursor: pointer; }
.map-node text { font-family: var(--mono); font-size: 9.5px; fill: var(--dim); }
.map-node.on text { fill: var(--text); font-weight: 700; }
.map-node circle { transition: r .15s; }

/* ── attention ────────────────────────────────────────────────────────────── */

.sent { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.sent-tok {
  font-family: var(--mono); font-size: .92rem;
  padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--surface-2); color: var(--dim);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.sent-tok:hover { color: var(--text); border-color: var(--accent); }
.sent-tok.q { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.sent-tok.masked { opacity: .32; cursor: not-allowed; }

.heat { display: grid; gap: 2px; min-width: 0; overflow-x: auto; }
.heat-cell {
  aspect-ratio: 1; border-radius: 3px; min-width: 16px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: .58rem; color: #fff;
}
.heat-head { font-family: var(--mono); font-size: .64rem; color: var(--dimmer); display: grid; place-items: center; text-align: center; }

.mathline {
  font-family: var(--mono); font-size: .82rem; color: var(--dim);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 9px; padding: 10px 13px; overflow-x: auto; white-space: pre;
}
.mathline b { color: var(--accent-2); font-weight: 600; }
:root[data-theme="light"] .mathline b { color: var(--accent); }

/* ── layer stack ──────────────────────────────────────────────────────────── */

.stack-layers { display: grid; gap: 4px; }
.layer-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: center;
  padding: 3px 4px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.layer-row:hover { background: var(--surface-2); }
.layer-row.on { background: var(--surface-2); border-color: var(--accent); }
.layer-n { font-family: var(--mono); font-size: .72rem; color: var(--dimmer); text-align: right; }
.layer-bars { display: flex; gap: 4px; min-width: 0; }
.layer-blk { flex: 1 1 0; height: 15px; border-radius: 4px; min-width: 0; display: grid; place-items: center; font-size: .6rem; font-family: var(--mono); color: var(--bg); font-weight: 700; }
.layer-attn { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.layer-mlp { background: color-mix(in srgb, var(--cyan) 62%, transparent); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-family: var(--mono); color: var(--dim); }
.pill::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--accent); }
.pill.mlp::before { background: var(--cyan); }
.pill.res::before { background: var(--amber); }

/* ── generation ───────────────────────────────────────────────────────────── */

.gen-out {
  font-family: var(--mono); font-size: .96rem; line-height: 1.85;
  min-height: 120px; padding: 14px 15px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}
.gen-seed { color: var(--dim); }
.gen-new { color: var(--text); }
.gen-last {
  background: color-mix(in srgb, var(--amber) 26%, transparent);
  border-radius: 4px; padding: 0 2px;
}
.caret {
  display: inline-block; width: 8px; height: 1.05em; vertical-align: -.18em;
  background: var(--accent); border-radius: 1px; animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } }

/* ── training ─────────────────────────────────────────────────────────────── */

.canvas-box {
  position: relative; width: 100%; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.canvas-box canvas { display: block; width: 100%; height: auto; }

.steps { display: grid; gap: 10px; counter-reset: step; }
.step-item {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px;
  align-items: start; font-size: .92rem; color: var(--dim);
}
.step-item::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--surface-3); color: var(--accent-2);
  font-family: var(--mono); font-size: .76rem; font-weight: 700;
}
:root[data-theme="light"] .step-item::before { color: var(--accent); }
.step-item b { color: var(--text); }

/* ── tables ───────────────────────────────────────────────────────────────── */

.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.tbl th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dimmer); font-weight: 650; }
.tbl td { color: var(--dim); }
.tbl td:first-child { color: var(--text); font-weight: 620; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { font-family: var(--mono); text-align: right; color: var(--text); }
.tbl-scroll { overflow-x: auto; }

/* ── footer ───────────────────────────────────────────────────────────────── */

.foot { padding: 46px 0 60px; border-top: 1px solid var(--line-soft); background: var(--bg-alt); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 18px 30px; justify-content: space-between; align-items: flex-start; }
.foot p { color: var(--dimmer); font-size: .86rem; margin: 0; max-width: 54ch; }
.foot a { color: var(--dim); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-family: var(--mono); font-size: .72rem; color: var(--dimmer);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px 10px;
}

/* ── shared two-up layout ─────────────────────────────────────────────────── */

.split { display: grid; gap: clamp(18px, 3vw, 30px); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.lay-split   { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); }
.att-split   { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.train-split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
@media (max-width: 900px) {
  .split, .lay-split, .att-split, .train-split, .gen-split { grid-template-columns: minmax(0, 1fr); }
}

.side { min-width: 0; }
.side-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.side-head h3 { margin: 0; }

/* ── word map extras ──────────────────────────────────────────────────────── */

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--dimmer); font-family: var(--mono); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.map-node:focus-visible { outline: none; }
.map-node:focus-visible circle { stroke: var(--accent); stroke-width: 2; }

.select {
  font-family: var(--mono); font-size: .84rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 9px; min-width: 0; max-width: 100%;
}
.select:focus { border-color: var(--accent); outline: none; }

.ana-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 10px 0 4px; }
.ana-op { font-family: var(--mono); font-size: 1rem; color: var(--accent-2); }
:root[data-theme="light"] .ana-op { color: var(--accent); }

/* ── attention extras ─────────────────────────────────────────────────────── */

/* Rows are required by role=grid, and display:contents keeps the CSS grid flat. */
.heat-row { display: contents; }
.heat-head { padding: 1px 2px; }
.heat-cell, .heat-head[role="rowheader"] { cursor: pointer; }
.heat-head.on { color: var(--amber); font-weight: 700; }

.att-detail { min-width: 0; }
.mix { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.mix-head { margin-bottom: 8px; }
.mix .axis-row { grid-template-columns: 58px minmax(0, 1fr) 42px; }
.mix .bar-track { border-radius: 4px; }

/* ── prediction extras ────────────────────────────────────────────────────── */

.draw-out { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── corpus ───────────────────────────────────────────────────────────────── */

#corpus-panel { margin-top: 38px; }
.corpus-text {
  max-width: 78ch; margin: 0; color: var(--dim);
  font-size: .93rem; line-height: 1.8;
}

/* ── buttons that are links ───────────────────────────────────────────────── */
/* `:root[data-theme] a` outranks `.btn.primary`, which would paint the label
   the same colour as its own background. Match that specificity to settle it. */
a.btn, a.btn:hover { text-decoration: none; color: var(--text); display: inline-flex; align-items: center; }
a.btn.primary, a.btn.primary:hover { color: #fff; }

/* A hairline at zero, so a vector strip reads as signed rather than stacked. */
.vec { position: relative; }
.vec::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--line); pointer-events: none;
}
