:root {
  --bg: #f2f0ee;
  --fg: #22272a;
  --muted: #6b6b6b;
  --red: #cc2a41;
  --teal: #567c77;
  --teal-soft: rgba(86, 124, 119, 0.4);
  --card: #f8f7f5;
  --line: #d8d2cc;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { border-top: 2px solid var(--fg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Nunito, sans-serif;
  font-size: 17px;
  line-height: 1.725;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 2rem 16px 6rem; }
.site { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; color: var(--muted); margin-bottom: 3rem; }
.site a { background: none; color: var(--fg); font-weight: 600; }
h1, h2, h3 { font-family: Georgia, Cambria, serif; color: var(--red); letter-spacing: 0.01em; }
h1 { font-size: 2em; line-height: 1.25; margin: 0 0 0.4rem; }
.meta { color: var(--muted); font-size: 0.82rem; font-family: var(--mono); margin-bottom: 2rem; }
h2 { font-size: 1.4rem; line-height: 1.3; margin: 3.2rem 0 0.7rem; position: relative; }
h2::before { content: "#"; position: absolute; left: -1.2rem; color: var(--red); }
@media (max-width: 860px) { h2::before { position: static; margin-right: 0.45rem; } }
p { hyphens: auto; -webkit-hyphens: auto; }
a {
  color: var(--fg); text-decoration: none;
  background-image: linear-gradient(transparent, transparent 5px, var(--fg) 5px, var(--fg));
  background-position: bottom; background-size: 100% 6px; background-repeat: repeat-x;
}
a:hover { background-image: linear-gradient(transparent, transparent 4px, var(--teal-soft) 4px, var(--teal-soft)); }
hr { border: 0; border-top: 1px dashed #666; opacity: 0.5; margin: 2.5rem 0; }
strong { font-weight: 700; }
code { font-family: var(--mono); font-size: 0.84em; background: rgba(34, 39, 42, 0.06); padding: 0.1em 0.35em; border-radius: 4px; }
pre { font-family: var(--mono); font-size: 13.5px; line-height: 1.6; background: #fbfaf8; border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; overflow-x: auto; }
pre code { background: none; padding: 0; font-size: inherit; }
pre .c { color: #8a8a8a; }
pre .k { color: var(--red); }
.hook { font-style: italic; }
blockquote { margin: 1.4rem 10px; padding: 0.2em 10px; color: var(--red); font-weight: 700; }
blockquote::before { content: "\201C"; font-size: 2em; line-height: 0.1em; vertical-align: -0.4em; margin-right: 0.2em; }
blockquote p { display: inline; margin: 0; }
ul, ol { padding-left: 1.4rem; }
li { margin: 0.2rem 0; }
.eq {
  font-family: var(--mono); font-size: 15px; text-align: center; padding: 0.7rem 1rem; margin: 1.2rem 0;
  background: #fbfaf8; border-left: 3px solid var(--red); border-radius: 0 6px 6px 0; overflow-x: auto; white-space: nowrap;
}
.eq .hl { color: var(--red); font-weight: 600; }
.red { color: var(--red); font-weight: 700; }
.teal { color: var(--teal); font-weight: 700; }
.small { font-size: 0.85em; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 1rem 0; }
th { text-align: left; color: var(--red); border-bottom: 1px dashed #666; padding: 6px 8px; font-family: Georgia, serif; }
td { padding: 6px 8px; vertical-align: top; border-bottom: 1px solid rgba(0,0,0,0.05); }
td:first-child { font-weight: 700; white-space: nowrap; }
.tablewrap { overflow-x: auto; }

/* ---------- demos ---------- */
.demo {
  margin: 1.8rem 0; padding: 1rem; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 18px rgba(0,0,0,0.04);
}
.wide { width: min(60rem, calc(100vw - 32px)); position: relative; left: 50%; transform: translateX(-50%); }
.demo figcaption { font-size: 0.84rem; color: var(--muted); margin-top: 0.8rem; line-height: 1.55; }
.demo-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); margin-bottom: 0.6rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.grid-plane { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 680px) { .grid2, .grid-plane { grid-template-columns: minmax(0, 1fr); } }
canvas { display: block; width: 100%; height: auto; border-radius: 6px; touch-action: none; }
canvas.plane { max-width: 360px; cursor: crosshair; box-shadow: inset 0 0 0 1px var(--line); }
.controls { font-size: 0.9rem; }
.sl { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr) 3.4rem; align-items: center; gap: 0.5rem; margin: 0.15rem 0; font-family: var(--mono); font-size: 13px; }
.sl output { text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--red); }
.btns { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; align-items: center; }
.btns > span { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.btns .lbl { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-right: 0.2rem; }
.chk { font-family: var(--mono); font-size: 12px; margin-left: 0.5rem; display: inline-flex; gap: 0.3rem; align-items: center; cursor: pointer; }
.chk input { accent-color: var(--red); }
button {
  font-family: var(--mono); font-size: 12.5px; color: var(--fg); background: transparent;
  border: 1px solid var(--fg); border-radius: 6px; padding: 3px 10px; cursor: pointer; line-height: 1.6;
}
button:hover { background: rgba(34,39,42,0.06); }
button.on { background: var(--fg); color: var(--bg); }
button.primary { border-color: var(--red); color: var(--red); font-weight: 600; }
button.primary.on, button.primary:active { background: var(--red); color: #fff; }
button:disabled { opacity: 0.4; cursor: default; }
button.chip { padding: 1px 8px; font-size: 12px; }
.readout { font-family: var(--mono); font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.55rem 0.7rem; margin-top: 0.6rem; line-height: 1.65; overflow-x: auto; }
.readout.small { font-size: 12px; color: var(--fg); }
.readout .big { font-size: 15px; font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-family: var(--mono); font-size: 13px; margin-top: 0.5rem; }
.stats b { color: var(--red); font-weight: 600; }
.meter { height: 8px; background: #e6e1dc; border-radius: 4px; overflow: hidden; margin: 0.25rem 0 0.1rem; }
.meter > div { height: 100%; background: var(--red); width: 50%; transition: width 0.12s; }
.legend { display: flex; gap: 1rem; font-size: 12px; font-family: var(--mono); color: var(--muted); margin-top: 0.4rem; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot.fg { background: var(--fg); }
.dot.red { background: var(--red); }
.dot.bars { background: rgba(34, 39, 42, 0.55); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* wording for readers with and without WebGPU (DESIGN §6.4: nothing pretends to be live); the nursery sets html.nogpu */
html.nogpu .when-gpu, html:not(.nogpu) .when-nogpu { display: none; }
/* replay.js failed to load (state.js sets html.noreplay): the replay wording gives way to a plain failure */
html.noreplay .replay, html:not(.noreplay) .when-noreplay { display: none; }

/* spam demo */
.nrow { border-top: 1px dashed var(--line); margin-top: 0.6rem; padding-top: 0.4rem; }
.nrow .nname { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.verdict { font-family: var(--mono); font-size: 13px; margin: 0.35rem 0; }
#spam-svg svg, #bp-graph svg { width: 100%; height: auto; display: block; }

/* network view */
.netview { position: relative; width: 100%; }
.netview svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.netview canvas.node { position: absolute; border-radius: 4px; box-shadow: 0 0 0 1px rgba(34,39,42,0.35); background: #fff; }
.netview canvas.node.click { cursor: pointer; }
.netview canvas.node.sel { box-shadow: 0 0 0 2.5px var(--red); }
.netview canvas.node.off { opacity: 0.25; }
.netview .nlabel { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none; }
.netview .lhead { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); top: 0; white-space: nowrap; }

.explain { min-height: 5.5em; }
.todo { background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 0.6rem 1rem 0.6rem 2.2rem; }
.bigpic svg { width: 100%; height: auto; display: block; }
footer { margin-top: 4rem; font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* math & python drawers */
details.panel { margin-top: 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
details.panel > summary {
  cursor: pointer; list-style: none; padding: 0.45rem 0.8rem; font-family: var(--mono); font-size: 13px; font-weight: 600; user-select: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--red); transition: transform 0.15s; }
details.panel[open] > summary::before { transform: rotate(90deg); }
details.panel[open] > summary { border-bottom: 1px dashed var(--line); }
details.panel > :not(summary) { margin-left: 0.9rem; margin-right: 0.9rem; }
details.panel > p { font-size: 0.95rem; }
/* display math: shrink-to-fit (fitMath), else a thin scrollbar below the formula, never over it */
.katex-display { overflow-x: auto; overflow-y: hidden; margin: 0.6em 0; padding: 0.3em 0 0.5em; scrollbar-width: thin; scrollbar-color: rgba(34, 39, 42, 0.25) transparent; }
.katex-display.scrolls { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
.katex-display.scrolls.at-end, .katex-display.scrolls:hover { -webkit-mask-image: none; mask-image: none; }
.ksplit > .ksplit-parts { display: none; }
.ksplit.split > .katex-display { display: none; }
.ksplit.split > .ksplit-parts { display: block; }
.ksplit-parts .katex-display { margin: 0.2em 0; }
.katex-display::-webkit-scrollbar { height: 6px; }
.katex-display::-webkit-scrollbar-thumb { background: rgba(34, 39, 42, 0.25); border-radius: 3px; }
.katex-display::-webkit-scrollbar-track { background: transparent; }
.texlive { background: #fbfaf8; border-radius: 6px; padding: 0.2rem 0.5rem; overflow-x: auto; }
/* editor = colored <pre> underneath a transparent <textarea>; both share exact metrics */
.editor { position: relative; margin-top: 0.7rem; }
textarea.code, pre.hl {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; tab-size: 4; white-space: pre;
  border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.7rem; margin: 0; letter-spacing: normal;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
textarea.code {
  position: relative; z-index: 1; display: block; width: 100%; min-height: 10rem; resize: vertical; overflow: auto;
  color: transparent; caret-color: var(--fg); background: transparent; -webkit-text-fill-color: transparent;
}
textarea.code::selection { background: rgba(86, 124, 119, 0.25); }
textarea.code:focus { outline: 2px solid var(--teal-soft); }
pre.hl { position: absolute; inset: 0; overflow: hidden; background: #fbfaf8; color: var(--fg); pointer-events: none; }
pre.hl code { background: none; padding: 0; font-size: inherit; display: block; }
pre.hl.static { position: static; pointer-events: auto; overflow-x: auto; font-size: 13.5px; line-height: 1.6; padding: 0.9rem 1rem; border-radius: 8px; margin: 1rem 0; }
.hl .t-c { color: #8a8f93; font-style: italic; }
.hl .t-s { color: #2e7d4f; }
.hl .t-n { color: #b0591a; }
.hl .t-k { color: var(--red); font-weight: 600; }
.hl .t-b { color: var(--teal); font-weight: 600; }
.hl .t-f { color: #3355a0; }
.hl .t-o { color: #7a7a7a; }
pre.pyout { margin: 0 0.9rem 0.9rem; min-height: 0; max-height: 22rem; overflow: auto; background: #22272a; color: #e8e4df; border: 0; font-size: 12.5px; }
pre.pyout:empty { display: none; }
pre.pyout .err { color: #ff8a9b; }
.pystatus { margin-left: 0.4rem; }
.pyinfo {
  width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted);
  font-family: Georgia, serif; font-style: italic; font-weight: 700; font-size: 12px; line-height: 16px; text-align: center;
}
.pyinfo:hover, .pyinfo[aria-expanded="true"] { border-color: var(--teal); color: #fff; background: var(--teal); }
.pyhelp { font-size: 0.86rem; line-height: 1.55; background: #fbfaf8; border: 1px dashed var(--line); border-radius: 6px; padding: 0.2rem 0.8rem; margin-bottom: 0.8rem; }
.pyhelp p { margin: 0.5rem 0; }

/* "press this next" pulse, and inline hints */
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(204, 42, 65, 0); } 50% { box-shadow: 0 0 0 5px rgba(204, 42, 65, 0.28); } }
button.nudge { animation: nudge 0.9s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) { button.nudge { animation: none; outline: 2px solid rgba(204, 42, 65, 0.5); outline-offset: 2px; } }
.hint { color: var(--muted); }
.hint b { color: var(--fg); }

/* ▦ Numbers drawers: live matrix tables */
.mats { padding: 0.3rem 0 0.7rem; }
.meq { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.55rem; margin: 0.5rem 0; }
.meq > .mop { font-family: var(--mono, "JetBrains Mono", monospace); color: var(--muted); font-size: 0.9rem; padding-top: 1.1rem; white-space: nowrap; }
.mlayer { font-family: "JetBrains Mono", monospace; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 1.1rem; min-width: 4.5rem; }
.mt { max-width: 100%; overflow-x: auto; }
.mt-h { font-family: "JetBrains Mono", monospace; font-size: 0.78rem; font-weight: 600; margin-bottom: 0.15rem; white-space: nowrap; }
.mt-s { color: var(--muted); font-weight: 400; font-size: 0.7rem; margin-left: 0.4rem; }
.mt-n { font-size: 0.72rem; color: var(--muted); }
.mt-t { border-collapse: separate; border-spacing: 0; font-family: "JetBrains Mono", monospace; font-size: 0.74rem; border-left: 2px solid var(--fg); border-right: 2px solid var(--fg); border-radius: 4px; }
.mt-t td { padding: 0.12rem 0.4rem; text-align: right; min-width: 2.8em; font-variant-numeric: tabular-nums; }
.mt-t th { font-weight: 400; color: #a29a92; font-size: 0.66rem; padding: 0 0.35rem; text-align: right; white-space: nowrap; }
.mt-t tr.gaprow td, .mt-t tr.gaprow th { color: var(--muted); text-align: center; background: none; line-height: 1; }
.mscalar { font-family: "JetBrains Mono", monospace; font-size: 0.74rem; padding: 0.12rem 0.5rem; border-left: 2px solid var(--fg); border-right: 2px solid var(--fg); border-radius: 4px; }
.mt-t th, .mt-t td { border: 0; font-family: "JetBrains Mono", monospace; background-clip: padding-box; }
.mt-t { margin: 0; width: auto; }
/* show() tables under a Python drawer's output */
.pyvals { margin: -0.3rem 0.9rem 0.9rem; }
.pyvals:empty { display: none; }
.pyvals .meq { align-items: flex-start; gap: 0.6rem 1rem; }
.pyvals-h { color: var(--muted); }
.mt-t td.gap { color: var(--muted); text-align: center; min-width: 1em; background: none; }
.sw { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 2px; vertical-align: -0.05em; margin-left: 0.3em; }
.sw.pos { background: rgba(204,42,65,0.42); }
.sw.neg { background: rgba(86,124,119,0.42); }

/* ================= tiny.gpt additions ================= */
.modelchip { display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--mono); font-size: 12px; margin-left: auto; }
.modelchip[hidden] { display: none; }
.modelchip .lbl { color: var(--muted); }
.modelchip .sep { color: var(--muted); }

/* the nursery */
.ntop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 0.6rem 1.2rem; align-items: start; }
@media (max-width: 760px) { .ntop { grid-template-columns: minmax(0, 1fr); } }
.nctl .btns { margin-top: 0; }
.nstatus { font-family: var(--mono); font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.7rem; margin: 0.4rem 0; font-variant-numeric: tabular-nums; min-height: 2.4em; }
.nstatus.warn { color: var(--red); border-color: rgba(204, 42, 65, 0.5); }
.nnotice { font-size: 0.88rem; background: #fff; border: 1px dashed var(--red); border-radius: 6px; padding: 0.45rem 0.7rem; margin: 0.4rem 0; }
.nscrub { display: flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 12.5px; margin-top: 0.5rem; flex-wrap: wrap; }
.nscrub .lbl { color: var(--muted); }
.nscrub input { flex: 1 1 8rem; min-width: 6rem; width: auto; }
.nscrub output { color: var(--muted); min-width: 12ch; font-variant-numeric: tabular-nums; }
.nlosswrap canvas { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.nlosswrap .legend { margin-top: 0.3rem; }

.wide.xwide { width: min(76rem, calc(100vw - 32px)); }
.ngridwrap { margin-top: 0.8rem; max-height: 28rem; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; overscroll-behavior: contain; }
.ngridwrap:focus-visible { outline: 2px solid var(--teal-soft); }
.ngrid { display: grid; grid-template-columns: 3.4rem repeat(8, minmax(6.4rem, 1fr)); min-width: 56rem; font-size: 13.5px; line-height: 1.3; }
.ngrid .nh { position: sticky; top: 0; z-index: 1; background: var(--card); border-bottom: 1px solid var(--line); padding: 0.35rem 0.45rem 0.4rem; text-align: center; }
.ngrid .nh .nemo { font-size: 1.35rem; line-height: 1.2; }
.ngrid .nh .nlab { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.ngrid .nh .meter { margin: 0.25rem auto 0; max-width: 5rem; height: 6px; }
.ngrid .nh .nmv { font-family: var(--mono); font-size: 10px; color: var(--muted); line-height: 1.2; }
.ngrid .nh.nstep { font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-align: right; display: flex; align-items: flex-end; justify-content: flex-end; }
.ngrid .nc { padding: 0.22rem 0.45rem; border-bottom: 1px solid rgba(0, 0, 0, 0.045); overflow-wrap: anywhere; }
.ngrid .nc.nstep { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ngrid .nc.real { color: var(--teal); }
.ngrid .nc.sel { background: rgba(204, 42, 65, 0.08); }
.ngrid .nc.nstep.sel { color: var(--red); font-weight: 600; }
.scrubbable .ngrid .nc { cursor: pointer; }
@media (prefers-reduced-motion: no-preference) { .ngrid .nc { animation: nfade 0.4s ease-out; } }
@keyframes nfade { from { opacity: 0; } to { opacity: 1; } }

.ndetail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.8rem; }
@media (max-width: 760px) { .ndetail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ncard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.6rem 0.5rem; min-width: 0; }
.ncard-h { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 0.15rem; }
.ncard ul { list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.35; }
.ncard li { margin: 0.15rem 0; overflow-wrap: anywhere; }
.badge { display: inline-block; font-family: var(--mono); font-size: 9.5px; line-height: 1.4; border-radius: 4px; padding: 0 0.3rem; margin-left: 0.35rem; vertical-align: 0.1em; border: 1px solid; white-space: nowrap; }
.badge.isnew { color: var(--red); border-color: rgba(204, 42, 65, 0.6); }
.badge.isreal { color: var(--teal); border-color: rgba(86, 124, 119, 0.6); }
.nlosswrap .legend { row-gap: 0.1rem; }
@media (max-width: 600px) {
  .ngrid { grid-template-columns: 2.9rem repeat(8, 6.6rem); min-width: 0; font-size: 12.5px; }
  .ngrid .nc { padding: 0.2rem 0.35rem; }
}

/* growing up at a glance (finished state) */
.nstrip { margin-top: 0.8rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.6rem 0.5rem; }
.nstrip[hidden] { display: none; }
.nstrip-h { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.3rem; }
.nstrip-g { display: grid; gap: 0 0.6rem; font-size: 14px; line-height: 1.35; }
.nstrip-g > div { padding: 0.22rem 0; border-bottom: 1px solid rgba(0, 0, 0, 0.045); overflow-wrap: anywhere; min-width: 0; }
.nstrip-g .ns-k { font-family: var(--mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nstrip-g .ns-e { font-size: 1.15rem; line-height: 1.2; }
.nstrip-g .ns-n.real { color: var(--teal); }
.scrubbable .nstrip-g [data-i] { cursor: pointer; }
@media (max-width: 600px) { .nstrip-g { font-size: 13px; gap: 0 0.45rem; } }

/* §1 the dataset */
.dslast { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.9rem; font-family: var(--mono); font-size: 12.5px; margin: 0.5rem 0; }
.dslast .lbl, .bgtop .lbl, .cxex .lbl { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.dsword, .bgbar { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.dsbar { display: inline-block; height: 8px; background: rgba(204, 42, 65, 0.6); border-radius: 2px; }
.dslist { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 1.2rem; max-height: 15rem; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.7rem; font-size: 14px; line-height: 1.5; overscroll-behavior: contain; }
.dslist > div { overflow-wrap: anywhere; min-width: 0; }
.dslist:focus-visible, #bg-cv:focus-visible { outline: 2px solid var(--teal-soft); outline-offset: 2px; }

/* §2 tokens */
.tkin { font-family: var(--mono); font-size: 15px; width: 100%; padding: 0.4rem 0.6rem; border: 1.5px solid var(--fg); border-radius: 6px; background: #fff; color: var(--fg); margin: 0.2rem 0 0.4rem; }
.tkin:focus { outline: 2px solid var(--teal-soft); }
button.chip.emo { font-size: 16px; padding: 0 6px; line-height: 1.5; }
.tkrow { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; }
.tk { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.9rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 0.1rem 0.3rem 0.05rem; }
.tk-s { font-family: var(--mono); font-size: 15px; line-height: 1.35; white-space: pre; }
.tk-i { font-family: var(--mono); font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.tk.start, .tk.end { background: var(--card); border-style: dashed; border-color: var(--fg); }
.tk.bad { border: 1.5px solid var(--red); color: var(--red); }
.tk.bad .tk-i { color: var(--red); }
.tkmsg { font-size: 0.88rem; color: var(--muted); min-height: 1.5em; }
.tkmsg.warn { color: var(--red); }
.mt-t td.pad { color: var(--muted); opacity: 0.6; }
.mt-t.vocab td { min-width: 1.6em; text-align: center; }

/* §3 the bigram heatmap */
.bgwrap { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 1rem 1.4rem; align-items: start; }
@media (max-width: 860px) { .bgwrap { grid-template-columns: minmax(0, 1fr); } }
#bg-cv { background: #fff; box-shadow: inset 0 0 0 1px var(--line); cursor: crosshair; max-width: 520px; }
.bgside .readout { margin-top: 0; min-height: 7.5em; }
.bgside .readout .big { font-size: 13.5px; }
.bgtop { display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; margin-top: 0.35rem; align-items: center; }
.bggen { font-size: 14.5px; line-height: 1.45; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.7rem; }
.bggen > div { overflow-wrap: anywhere; }
.bge { display: inline-block; width: 1.7em; }

/* §4 the context explosion */
.cxwrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0.8rem 1.2rem; align-items: start; margin-top: 0.6rem; }
@media (max-width: 520px) { .cxwrap { grid-template-columns: minmax(0, 1fr); } }
#cx-cv { max-width: 220px; }
.cxside .stats { flex-direction: column; margin-top: 0; }
.cxex { margin-top: 0.8rem; }
.tk.ctx { background: var(--card); border-style: dashed; color: var(--muted); }
.tk.seen { background: rgba(204, 42, 65, 0.16); border-color: rgba(204, 42, 65, 0.5); }
.tk.miss { border: 1.5px dashed var(--teal); color: var(--teal); }
.mt-t tr.cur th, .mt-t tr.cur td { color: var(--red); font-weight: 600; }

/* §5 the embedding map */
.emwrap { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 0.8rem 1.2rem; align-items: start; }
@media (max-width: 700px) { .emwrap { grid-template-columns: minmax(0, 1fr); } }
#em-map { display: block; width: 100%; max-width: 400px; height: auto; background: #fff; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); touch-action: manipulation; }
.emwrap .readout { margin-top: 0; min-height: 8.5em; }
.emaxes line { stroke: var(--line); stroke-width: 1; }
.emaxes text { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
.emlinks line { stroke: var(--fg); stroke-width: 1; opacity: 0.45; }
.empt { cursor: pointer; outline: none; }
@media (prefers-reduced-motion: no-preference) { .empt { transition: transform 0.5s ease; } }
.empt circle { fill: #fff; stroke: var(--fg); stroke-width: 1; }
.empt text { font-family: var(--mono); font-size: 11.5px; fill: var(--fg); pointer-events: none; }
.empt.near circle { stroke-width: 2; }
.empt.sel circle { fill: rgba(204, 42, 65, 0.4); stroke: var(--red); stroke-width: 2; }
.empt:focus-visible circle { stroke: var(--teal); stroke-width: 3; }
.emstrip { display: grid; grid-template-columns: repeat(32, minmax(0, 1fr)); gap: 1px; margin: 0.35rem 0; max-width: 22rem; }
.emstrip span { height: 11px; border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(34, 39, 42, 0.06); }

/* §6 the attention explorer */
.atrow { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.5rem 0; }
button.tk.attk { border: 1px solid var(--line); background: #fff; color: var(--fg); padding: 0.1rem 0.3rem 0.05rem; line-height: normal; cursor: pointer; }
button.tk.attk:hover { border-color: var(--fg); }
button.tk.attk.start { border-style: dashed; border-color: var(--fg); }
button.tk.attk.q { box-shadow: 0 0 0 2px var(--fg); border-color: var(--fg); }
button.tk.attk.ahead { opacity: 0.35; }
button.tk.attk.pyhl { outline: 2px dashed var(--fg); outline-offset: 2px; }
button.tk.attk .tk-i { min-height: 1.3em; }
button.tk.attk:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
#attention.stale .atrow, #attention.stale .atheads, #attention.stale #at-out { opacity: 0.45; }
#at-out { min-height: 4.4em; }
.atheads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0.7rem; max-width: 30rem; }
button.atmini { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 4px; background: #fff; border: 1px solid var(--line); min-width: 0; }
button.atmini canvas { max-width: 84px; box-shadow: inset 0 0 0 1px var(--line); border-radius: 2px; }
button.atmini.on { border: 2px solid var(--fg); padding: 3px; background: #fff; color: var(--fg); }
.atcap { font-family: var(--mono); font-size: 10px; line-height: 1.35; color: var(--muted); white-space: pre; text-align: center; max-width: 100%; }
button.atmini.on .atcap { color: var(--fg); font-weight: 600; }
.emwrap .readout .big, #at-out .big { font-size: 13.5px; }

/* §7 the block */
.bkwrap { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 0.8rem 1.2rem; align-items: start; margin-top: 0.4rem; }
@media (max-width: 700px) { .bkwrap { grid-template-columns: minmax(0, 1fr); } }
#bk-svg { display: block; width: 100%; max-width: 360px; height: auto; background: #fff; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); touch-action: manipulation; }
.bkbox { fill: #fff; stroke: var(--fg); stroke-width: 1.2; }
.bknode { cursor: pointer; outline: none; }
.bknode:hover .bkbox { stroke-width: 2; }
.bknode.on .bkbox { stroke: var(--red); stroke-width: 2.2; fill: rgba(204, 42, 65, 0.08); }
.bknode:focus-visible .bkbox { stroke: var(--teal); stroke-width: 3; }
.bkdot { fill: var(--red); opacity: 0.85; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) { .bkdot { transition: cx 0.5s ease, cy 0.5s ease; } }
.bkside .btns { margin-top: 0; }
.bkside .readout { margin-top: 0; min-height: 6.6em; }
.bklab { margin-top: 0.7rem; font-family: var(--mono); font-size: 11px; }
#bk-strip { max-width: none; }
.bkstream { display: flex; gap: 0.3rem; margin-top: 0.3rem; }
button.bkbar { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; padding: 2px 3px 1px; background: #fff; border: 1px solid var(--line); line-height: 1.25; }
button.bkbar:hover { border-color: var(--fg); }
button.bkbar.cur { border-color: var(--fg); }
.bkbar-c { display: flex; align-items: flex-end; height: 4.2rem; }
.bkbar-b { display: block; width: 100%; background: rgba(204, 42, 65, 0.3); border-radius: 2px 2px 0 0; min-height: 2px; }
button.bkbar.cur .bkbar-b { background: rgba(204, 42, 65, 0.6); }
.bkbar-v { font-size: 10.5px; text-align: center; }
.bkbar-l { font-size: 9px; color: var(--muted); text-align: center; padding-top: 2px; white-space: normal; overflow-wrap: anywhere; }
#block.stale .bkwrap, #block.stale .atrow { opacity: 0.45; }

/* §8 the next-letter guess, and the keyboard of bars (shared with §10) */
.nlprefix { font-family: var(--mono); font-size: 15px; margin: 0.2rem 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.nlprefix .lbl { color: var(--muted); font-size: 12px; }
.sa-caret { color: var(--red); }
.pkeys { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.9rem, 1fr)); gap: 0.3rem; margin: 0.5rem 0; }
button.pkey { display: flex; flex-direction: column; align-items: stretch; min-width: 0; padding: 2px 3px 1px; background: #fff; border: 1px solid var(--line); line-height: 1.2; }
button.pkey:hover { border-color: var(--fg); }
.pk-s { font-size: 15px; text-align: center; white-space: pre; }
.pk-bar { display: block; height: 5px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 2px 0; }
.pk-bar > span { display: block; height: 100%; background: var(--red); }
.pk-v { font-size: 9.5px; color: var(--muted); text-align: center; }
button.pkey.pend .pk-s { font-size: 12px; line-height: 1.5; }
button.pkey.mark { border: 1.5px dashed var(--fg); }
button.pkey.sel { box-shadow: 0 0 0 2px var(--fg); border-color: var(--fg); }
button.pkey:disabled { opacity: 0.35; }
button.pkey:focus-visible, button.bkbar:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
#nextletter.stale .pkeys, #nextletter.stale .atrow, #nextletter.stale #nl-out { opacity: 0.45; }
button.tk.attk.end { border-style: dashed; border-color: var(--fg); }

/* §10 the sampler */
.sl.satemp { grid-template-columns: 7.4rem minmax(0, 1fr) 2.6rem; max-width: 32rem; }
.salist { list-style: none; padding: 0.4rem 0.7rem; margin: 0.5rem 0 0.3rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0 1.4rem; font-size: 14.5px; line-height: 1.5; min-height: 2.4em; }
.salist li { overflow-wrap: anywhere; min-width: 0; }
.salist .sa-m { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-left: 0.35rem; }
.sa-e { display: inline-block; width: 1.6em; }
.sabe { margin-top: 0.9rem; border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.sabe-h { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); }
.sabe-t { font-family: var(--mono); font-size: 17px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.35rem 0.6rem; margin: 0.4rem 0; min-height: 2.3em; overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- §11 overfit lab, §12 one model or eight ---------- */
.lablosswrap { margin-top: 0.6rem; }
.lablosswrap .legend { row-gap: 0.1rem; margin-top: 0.3rem; }
.lablosswrap canvas { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.ovtable { font-family: var(--mono); font-size: 12.5px; background: #fff; }
.ovtable th, .ovtable td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.ovtable th { font-family: var(--mono); }
.ovtable tr:first-child th { font-size: 11.5px; }
.ovtable td { font-variant-numeric: tabular-nums; }
.ovtable tr:not(:first-child) th { color: var(--fg); font-weight: 400; border-bottom-style: solid; }
.ndetail.ovnames { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .ndetail.ovnames { grid-template-columns: minmax(0, 1fr); } }
.ovseeds { font-family: var(--mono); font-size: 12.5px; }
.ovseeds th { font-family: var(--mono); font-size: 11.5px; }
.ovseeds td { padding: 5px 8px; font-variant-numeric: tabular-nums; }

/* ---------- §14–15: the big ones, download, cheat sheet ---------- */
.bigtable { min-width: 36rem; font-size: 0.86rem; line-height: 1.45; }
.bigtable th { font-size: 0.86rem; }
.bigtable td:first-child { color: var(--muted); font-weight: 600; }
.bigtable td:nth-child(2) { background: rgba(204, 42, 65, 0.06); }
sup a { background: none; color: var(--red); font-family: var(--mono); font-size: 0.75em; padding: 0 1px; }
ol.notes { padding-left: 1.3rem; line-height: 1.55; }
ol.notes li { margin: 0.3rem 0; }
ol.notes li:target { background: rgba(204, 42, 65, 0.08); }
.dlhead { font-size: 12px; }
.dlhead td:first-child { font-weight: 400; }
.dlhead td { word-break: break-all; }
.cheat td { vertical-align: middle; }
.cheat td:last-child { font-size: 0.85rem; color: var(--muted); }
.cheat .cf { overflow-x: auto; overflow-y: hidden; padding: 2px 0; white-space: nowrap; line-height: 2; }
@media (max-width: 600px) {
  .cheat tr:first-child { display: none; }
  .cheat tr, .cheat td { display: block; }
  .cheat td { border: 0; padding: 2px 4px; }
  .cheat tr { border-bottom: 1px solid var(--line); padding: 0.5rem 0; }
  .cheat td:first-child { color: var(--red); }
}
.datanote { margin-top: 2.5rem; border-top: 1px dashed var(--line); padding-top: 0.8rem; }

/* §13 the playground */
textarea.pglist { display: block; width: 100%; box-sizing: border-box; min-height: 10rem; max-height: 22rem; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--fg); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.7rem; }
textarea.pglist:focus { outline: 2px solid var(--teal-soft); }
.pgcount { font-size: 0.86rem; line-height: 1.5; margin: 0.3rem 0; overflow-wrap: anywhere; }
.pgcount.warn > div:first-child { color: var(--red); }
.pgcount .small { font-family: var(--mono); font-size: 12px; }
.pgvocab { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.4rem 0 0.6rem; }
.pgtok { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.7rem; padding: 0.1rem 0.25rem; background: #fff; border: 1px solid var(--line); border-radius: 4px; font-size: 14px; line-height: 1.2; }
.pgtok small { font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.pgtok.special { border-style: dashed; border-color: var(--fg); }

/* §7.1 share a creature: the card, its link, and the shared card near the top */
button.nmlink { all: unset; cursor: pointer; overflow-wrap: anywhere; border-bottom: 1px dashed var(--line); }
button.nmlink:hover { border-bottom-color: var(--red); }
button.nmlink:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.sharebox { margin-top: 0.8rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem 0.4rem; }
.sharebox[hidden], .shared[hidden] { display: none; }
.sb-h { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sb-link { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.5rem; }
.sb-link input { flex: 1 1 14rem; min-width: 0; font-family: var(--mono); font-size: 12px; padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--fg); }
.sb-note { margin: 0.4rem 0 0.2rem; }
.sharecard { background: #fff; border: 1.5px solid var(--fg); border-radius: 10px; padding: 0.7rem 0.9rem; margin-top: 0.5rem; overflow-wrap: anywhere; }
.sharecard .sc-title { font-family: Georgia, serif; font-size: 1.45rem; color: var(--red); line-height: 1.3; }
.sharecard .sc-by { font-size: 0.95rem; margin-top: 0.2rem; }
.sharecard .sc-detail { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 0.3rem; }
.shared { background: var(--card); border: 1px dashed var(--red); border-radius: 8px; padding: 0.6rem 0.8rem 0.3rem; margin: 0 0 1.6rem; }
.shared .sh-lead { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* ---- Try this: one short challenge box at the end of a demo card (challenges.js) ---- */
.try { margin: 0.9rem 0 0.4rem; padding: 0.55rem 0.75rem 0.6rem; border: 1px dashed var(--line); border-radius: 6px; background: #fff; font-size: 0.9rem; line-height: 1.55; }
.try:empty { display: none; }
.try-h { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.try-mark { display: inline-block; min-width: 1.2em; color: var(--muted); font-size: 14px; }
.try.solved { border-color: rgba(204, 42, 65, 0.6); }
.try.solved .try-mark { color: var(--red); font-weight: 700; }
.try-goal { margin: 0.25rem 0 0.35rem; }
.try-status { margin: 0.2rem 0 0; font-family: var(--mono); font-size: 12px; }
.try.solved .try-status { color: var(--red); }
.try-progress { margin: 0.1rem 0 0.4rem; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.try-progress:empty { display: none; }
.try-choices { margin: 0.2rem 0 0.3rem; }
.try-hint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.85rem; }
@media (prefers-reduced-motion: no-preference) {
  .try-mark.pop { animation: trypop 0.5s ease-out; }
  @keyframes trypop { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
}
