/* ==========================================================================
   A Life in LLM Development — OpenEuroLLM public pretraining explainer
   Design tokens follow the validated data-viz reference palette so that page
   chrome and chart marks come from one system. Chart surface = --surface.
   ========================================================================== */

:root {
  color-scheme: light;

  /* planes & ink */
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f2f1ec;
  --surface-3:   #e9e8e1;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --ink-3:       #898781;
  --rule:        #e1e0d9;
  --baseline:    #c3c2b7;
  --ring:        rgba(11, 11, 11, 0.10);
  --shadow:      0 1px 2px rgba(11,11,11,.04), 0 8px 24px -12px rgba(11,11,11,.10);

  /* categorical slots (fixed order — never cycled) */
  --series-1: #2a78d6;  /* blue    */
  --series-2: #eb6834;  /* orange  */
  --series-3: #1baf7a;  /* aqua    */
  --series-4: #eda100;  /* yellow  */
  --series-5: #e87ba4;  /* magenta */
  --series-6: #008300;  /* green   */
  --series-7: #4a3aa7;  /* violet  */
  --series-8: #e34948;  /* red     */

  /* sequential blue ramp (ordinal use starts at step 250) */
  --seq-250: #86b6ef;
  --seq-300: #6da7ec;
  --seq-350: #5598e7;
  --seq-400: #3987e5;
  --seq-450: #2a78d6;
  --seq-500: #256abf;
  --seq-550: #1c5cab;
  --seq-600: #184f95;
  --seq-650: #104281;
  --seq-700: #0d366b;

  /* status (fixed, never themed, always with icon + label) */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;

  /* placeholder ("still to fill in") — deliberately not a series slot */
  --tbd:      #b04a16;
  --tbd-bg:   rgba(235, 104, 52, .10);

  --accent: var(--series-1);

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 34rem;
  --wide: 72rem;
  --gutter: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:      #0d0d0d;
    --surface:   #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --ink-3:     #898781;
    --rule:      #2c2c2a;
    --baseline:  #383835;
    --ring:      rgba(255, 255, 255, 0.10);
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --seq-250: #184f95;
    --seq-300: #1c5cab;
    --seq-350: #256abf;
    --seq-400: #2a78d6;
    --seq-450: #3987e5;
    --seq-500: #5598e7;
    --seq-550: #6da7ec;
    --seq-600: #86b6ef;
    --seq-650: #9ec5f4;
    --seq-700: #b7d3f6;

    --good-text: #0ca30c;
    --tbd:    #f0946a;
    --tbd-bg: rgba(235, 104, 52, .14);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:      #0d0d0d;
  --surface:   #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --ink:       #ffffff;
  --ink-2:     #c3c2b7;
  --ink-3:     #898781;
  --rule:      #2c2c2a;
  --baseline:  #383835;
  --ring:      rgba(255, 255, 255, 0.10);
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --seq-250: #184f95;
  --seq-300: #1c5cab;
  --seq-350: #256abf;
  --seq-400: #2a78d6;
  --seq-450: #3987e5;
  --seq-500: #5598e7;
  --seq-550: #6da7ec;
  --seq-600: #86b6ef;
  --seq-650: #9ec5f4;
  --seq-700: #b7d3f6;

  --good-text: #0ca30c;
  --tbd:    #f0946a;
  --tbd-bg: rgba(235, 104, 52, .14);
}

/* --------------------------------------------------------------- reset -- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

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

h1, h2, h3, h4 { line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--surface); padding: .6rem 1rem; border-radius: 6px;
  border: 1px solid var(--rule);
}
.skip:focus { left: 1rem; top: 1rem; }

.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* -------------------------------------------------------------- layout -- */

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wide));
  margin-inline: auto;
}
.prose { max-width: var(--measure); }
.prose p:last-child { margin-bottom: 0; }

section[id] { scroll-margin-top: 5rem; }

/* ------------------------------------------------------------ top bar -- */

.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.3);
  border-bottom: 1px solid var(--rule);
}
.topbar__in {
  display: flex; align-items: center; gap: 1rem;
  height: 3.25rem;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .01em;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.brand__dot {
  width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--ink-3); flex: none;
}
.brand__dot--live { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.topbar__spacer { flex: 1 1 auto; }

.switch {
  display: inline-flex; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); padding: 2px; flex: none;
}
.switch button {
  border: 0; background: none; cursor: pointer;
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  padding: .22rem .5rem; border-radius: 999px; color: var(--ink-3);
  min-width: 2rem;
}
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--page); }

/* ---------------------------------------------------------------- hero -- */

.hero { padding: clamp(3rem, 9vw, 7rem) 0 clamp(2rem, 5vw, 4rem); position: relative; }
.hero__eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 1.25rem;
}
.hero h1 {
  font-size: clamp(2.2rem, 6.2vw, 4.2rem);
  letter-spacing: -0.03em; max-width: 18ch; margin-bottom: 1.25rem;
}
.hero__lede { font-size: clamp(1.05rem, 2.1vw, 1.3rem); color: var(--ink-2); max-width: 44ch; }
.hero__meta { font-size: .82rem; color: var(--ink-3); margin-top: 1.5rem; }

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); margin-top: 2.5rem; }

.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  padding: 1.15rem 1.25rem 1.25rem; box-shadow: var(--shadow);
}
.card__top { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .1rem; }
.card__name { font-size: 1.15rem; font-weight: 600; }
.card__where { font-size: .78rem; color: var(--ink-3); font-family: var(--mono); }
.card__state { margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 999px;
  border: 1px solid var(--ring); color: var(--ink-2); background: var(--surface-2);
}
.pill__dot { width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; flex: none; }
.pill--live   { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.pill--work   { color: var(--series-1); border-color: color-mix(in srgb, var(--series-1) 40%, transparent); background: color-mix(in srgb, var(--series-1) 10%, transparent); }
.pill--idle   { color: var(--ink-3); }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.pill--live .pill__dot { animation: pulse 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .pill--live .pill__dot { animation: none } }

.meter { margin: 1rem 0 .55rem; }
.meter__track {
  height: 8px; border-radius: 999px; background: var(--surface-3);
  overflow: hidden; position: relative;
}
.meter__fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .8s cubic-bezier(.2,.7,.3,1); }
.meter__fill--alt { background: var(--series-3); }
.meter__labels { display: flex; justify-content: space-between; font-size: .76rem; color: var(--ink-3); margin-top: .4rem; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .85rem 1rem; margin-top: 1rem; padding-top: .95rem; border-top: 1px solid var(--rule); }
.kv__k { font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.kv__v { font-size: 1.02rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.kv__v small { font-weight: 400; font-size: .78rem; color: var(--ink-3); }

/* ------------------------------------------------------------- figures -- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.stat { background: var(--surface); padding: 1rem 1.1rem; }
.stat__v { font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.stat__v small { font-size: .55em; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.stat__k { font-size: .76rem; color: var(--ink-2); margin-top: .35rem; }
.stat__note { font-size: .72rem; color: var(--ink-3); margin-top: .15rem; }

figure { margin: 0; }
.fig {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  padding: 1.1rem 1.15rem 1.15rem; margin: 1.75rem 0;
}
.fig__head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .2rem; flex-wrap: wrap; }
.fig__title { font-size: .95rem; font-weight: 600; }
.fig__sub { font-size: .8rem; color: var(--ink-3); margin-top: .1rem; }
.fig__tools { margin-left: auto; display: flex; gap: .35rem; flex-wrap: wrap; }
.fig__body { margin-top: 1rem; }
figcaption { font-size: .78rem; color: var(--ink-3); margin-top: .85rem; line-height: 1.5; }

.tag {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .18rem .42rem; border-radius: 4px; border: 1px solid var(--ring); color: var(--ink-3);
  white-space: nowrap;
}
.tag--sch { border-style: dashed; }
.tag--ill { border-style: dashed; }
.tag--real { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

.tbd {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--mono); font-size: .74em; font-weight: 500;
  color: var(--tbd); background: var(--tbd-bg);
  border: 1px dashed color-mix(in srgb, var(--tbd) 55%, transparent);
  border-radius: 4px; padding: 0 .35rem; white-space: nowrap;
  cursor: help;
}
.tbd::before { content: "?"; font-weight: 700; opacity: .75; }

/* chart chrome */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--ink-3); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .axlabel { font-size: 11px; fill: var(--ink-3); }
.chart .lbl { font-size: 12px; fill: var(--ink-2); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .9rem; font-size: .78rem; color: var(--ink-2); }
.legend__i { display: inline-flex; align-items: center; gap: .4rem; }
.legend__sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend__sw--line { height: 2px; border-radius: 2px; width: 14px; }

.tooltip {
  position: fixed; z-index: 90; pointer-events: none; opacity: 0;
  transition: opacity .1s linear;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 8px;
  box-shadow: var(--shadow); padding: .5rem .65rem; font-size: .78rem;
  max-width: 17rem; line-height: 1.45;
}
.tooltip[data-show="1"] { opacity: 1; }
.tooltip b { font-variant-numeric: tabular-nums; }
.tooltip__k { color: var(--ink-3); }

/* small controls */
.btn {
  border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: .28rem .7rem; font-size: .78rem; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn[aria-pressed="true"], .btn--on { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); background: var(--accent); color: #fff; }

.seg { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: none; cursor: pointer; font-size: .76rem; padding: .22rem .6rem; border-radius: 999px; color: var(--ink-3); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* data table (the accessible alternative to every chart) */
.tablewrap { overflow-x: auto; margin-top: .9rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .82rem; }
table.data th, table.data td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--rule); }
table.data th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
details.tablewrap-d > summary { cursor: pointer; font-size: .76rem; color: var(--ink-3); margin-top: .75rem; list-style: none; }
details.tablewrap-d > summary::-webkit-details-marker { display: none; }
details.tablewrap-d > summary::before { content: "▸ "; }
details.tablewrap-d[open] > summary::before { content: "▾ "; }

/* ------------------------------------------------------------ chapters -- */

.chapter__head { border-top: 2px solid var(--ink); padding-top: 1rem; margin-bottom: 2rem; }
.chapter__num { font-family: var(--mono); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.chapter h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -0.025em; margin: .35rem 0 .7rem; max-width: 20ch; }
.chapter__lede { font-size: clamp(1rem, 1.9vw, 1.12rem); color: var(--ink-2); max-width: 46ch; }

details.tech {
  margin-top: 1.25rem; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
details.tech > summary {
  cursor: pointer; padding: .6rem .9rem; font-size: .82rem; font-weight: 600;
  color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: .5rem;
}
details.tech > summary::-webkit-details-marker { display: none; }
details.tech > summary::before { content: "+"; font-family: var(--mono); color: var(--ink-3); }
details.tech[open] > summary::before { content: "−"; }
details.tech > summary:hover { background: var(--surface-2); }
.tech__body { padding: 0 .9rem 1rem; font-size: .88rem; color: var(--ink-2); border-top: 1px solid var(--rule); padding-top: .85rem; }
.tech__body code, code.c { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }
.tech__body dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; margin: 0; }
.tech__body dt { color: var(--ink-3); font-size: .82rem; }
.tech__body dd { margin: 0; font-variant-numeric: tabular-nums; }

/* pull quote / aside note */
.note {
  border-left: 2px solid var(--accent); padding: .1rem 0 .1rem 1rem;
  margin: 1.5rem 0; color: var(--ink-2); font-size: .95rem;
}
.note--warn { border-left-color: var(--warning); }

/* ------------------------------------------------ specific interactives -- */

/* tokenizer */
.tok { display: flex; flex-wrap: wrap; gap: 4px; font-family: var(--mono); }
.tok__t {
  display: inline-flex; flex-direction: column; align-items: center;
  border-radius: 6px; padding: .3rem .45rem .2rem; font-size: .9rem;
  border: 1px solid var(--ring); background: var(--surface-2); cursor: default;
  line-height: 1.2;
}
.tok__t span.id { font-size: .6rem; color: var(--ink-3); margin-top: .15rem; }
.tok__t.w { background: color-mix(in srgb, var(--series-1) 12%, var(--surface)); border-color: color-mix(in srgb, var(--series-1) 35%, transparent); }
.tok__t.p { background: color-mix(in srgb, var(--series-2) 12%, var(--surface)); border-color: color-mix(in srgb, var(--series-2) 35%, transparent); }
.tok__sp { color: var(--ink-3); }

/* node grid */
.nodegrid { display: grid; gap: 2px; grid-template-columns: repeat(32, 1fr); }
.nodegrid .n { aspect-ratio: 1; border-radius: 2px; background: var(--seq-400); transition: background .25s, opacity .25s; cursor: crosshair; }
.nodegrid .n:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.nodegrid .n.down { background: var(--critical) !important; }
.nodegrid .n.dim { opacity: .18; }

/* incident list */
.feed { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.feed__row { background: var(--surface); padding: .75rem .9rem; display: grid; grid-template-columns: 4.5rem 1fr; gap: .85rem; align-items: start; }
@media (max-width: 40rem) { .feed__row { grid-template-columns: 1fr; gap: .25rem; } }
.feed__t { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: .1rem; }
.feed__h { font-size: .92rem; font-weight: 600; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.feed__d { font-size: .86rem; color: var(--ink-2); margin-top: .15rem; }
.feed__who { font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; padding: .12rem .38rem; border-radius: 4px; border: 1px solid var(--ring); color: var(--ink-3); }
.sev { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 600; }
.sev__i { width: .95rem; height: .95rem; flex: none; }

/* day timeline */
.day { display: grid; gap: 0; }
.day__row { display: grid; grid-template-columns: 4.2rem 1.4rem 1fr; gap: .6rem; }
.day__time { font-family: var(--mono); font-size: .8rem; color: var(--ink-3); text-align: right; padding-top: .55rem; font-variant-numeric: tabular-nums; }
.day__rail { position: relative; }
.day__rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--rule); transform: translateX(-50%); }
.day__dot { position: absolute; left: 50%; top: .8rem; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px var(--page); }
.day__card { padding: .5rem 0 1.1rem; }
.day__h { font-size: .95rem; font-weight: 600; }
.day__d { font-size: .88rem; color: var(--ink-2); margin-top: .15rem; }

/* sources */
.srcs { display: grid; gap: .1rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.src { display: flex; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.src__n { font-size: .92rem; font-weight: 600; }
.src__d { font-size: .8rem; color: var(--ink-3); }

/* placeholder register */
.reg { display: grid; gap: .5rem; }
.reg__i { display: flex; gap: .7rem; align-items: baseline; font-size: .88rem; padding: .45rem .6rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
.reg__where { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); white-space: nowrap; }

footer.foot { padding: 4rem 0 5rem; border-top: 1px solid var(--rule); margin-top: 4rem; color: var(--ink-2); font-size: .88rem; }
footer.foot h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: .7rem; }
.foot__grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }

@media print {
  .topbar, .fig__tools, .btn, .seg { display: none !important; }
  body { background: #fff; }
}

/* badge alignment inside day + feed headings */
.day__h { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.step__main > .fig:first-child { margin-top: 1.25rem; }
.prose ol, .prose ul { padding-left: 1.2rem; margin: 0 0 1em; }
.prose li { margin-bottom: .45rem; }
.prose ul li::marker, .prose ol li::marker { color: var(--ink-3); }

/* ==========================================================================
   Opening, overview map, in-practice notes
   ========================================================================== */

.hero__hook {
  font-size: clamp(1.05rem, 2.3vw, 1.35rem);
  color: var(--ink-2); margin-bottom: .4rem; font-weight: 500;
}
.hero h1 { max-width: 16ch; }
.hero__lede + .hero__lede { margin-top: 1rem; }

.ticker {
  display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: .74rem; letter-spacing: .04em;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px;
  padding: .3rem .7rem .3rem .55rem; margin-bottom: 1.5rem;
}
.ticker b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.ticker__note { color: var(--ink-3); font-size: .95em; }
.ticker__dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--good); flex: none; }
.ticker__dot--stale { background: var(--ink-3); }
.ticker--live .ticker__dot { animation: pulse 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ticker--live .ticker__dot { animation: none } }

.hero__cta { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.6rem; }

/* ------------------------------------------------------------- overview -- */

.mapsec { padding: clamp(2.5rem, 6vw, 4.5rem) 0 0; }
.map { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: stretch; }
.mapgroup {
  display: flex; flex-direction: column; min-width: 14rem;
  border-top: 2px solid var(--ink); padding-top: .7rem;
}
.mapgroup__head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .7rem; }
.mapgroup__name { font-size: .88rem; font-weight: 600; }
.mapgroup__meta { font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.mapgroup__steps { display: grid; gap: 5px; grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr)); flex: 1; }

.mapstep {
  position: relative; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 9px;
  padding: .55rem .6rem .5rem; display: flex; flex-direction: column; gap: .1rem;
  transition: border-color .15s, background .15s, transform .15s;
}
.mapstep:hover { border-color: var(--ink-3); background: var(--surface-2); transform: translateY(-1px); }
.mapstep[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mapstep__n { font-family: var(--mono); font-size: .66rem; color: var(--ink-3); }
.mapstep__t { font-size: .84rem; font-weight: 600; line-height: 1.25; }
.mapstep__d { font-size: .68rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.mapstep__pins { display: flex; gap: 3px; position: absolute; top: -7px; right: .45rem; }
.pin {
  font-size: .6rem; font-weight: 700; letter-spacing: .02em;
  padding: .08rem .3rem; border-radius: 999px; color: #fff; white-space: nowrap;
  box-shadow: 0 0 0 2px var(--page);
}
.pin--32 { background: var(--series-1); }
.pin--9  { background: var(--series-3); }
.mapstep--here { border-color: var(--baseline); }

.map__legend { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: 1.1rem; font-size: .78rem; color: var(--ink-3); }

/* ------------------------------------------------------ in-practice note -- */

.pnote {
  margin: 1.75rem 0; padding: 1.05rem 1.2rem;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--ink); border-radius: 0 10px 10px 0;
}
.pnote__k {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .45rem;
  display: flex; gap: .6rem; align-items: baseline;
}
.pnote__d { font-size: 1rem; line-height: 1.6; color: var(--ink); }
.pnote__date { color: var(--ink-3); font-weight: 500; }

/* room for the second sticky row (the step rail) */
section[id] { scroll-margin-top: 6.5rem; }
.step { scroll-margin-top: 7rem; }
@media (min-width: 62rem) { .step__aside { top: 6.4rem; } }

/* ==========================================================================
   Interactive controls
   ========================================================================== */

.split { display: grid; gap: 1.4rem; grid-template-columns: minmax(0,1fr); margin-top: 1.4rem; }
@media (min-width: 52rem) { .split { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }

.slgrid { display: grid; gap: .9rem; align-content: start; }
.sl { display: grid; gap: .2rem; }
.sl__top { display: flex; align-items: baseline; gap: .5rem; font-size: .8rem; }
.sl__k { color: var(--ink-2); font-weight: 500; }
.sl__v { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.sl__flag {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tbd); border: 1px dashed color-mix(in srgb, var(--tbd) 55%, transparent);
  border-radius: 4px; padding: 0 .28rem;
}
.sl input[type="range"] { width: 100%; accent-color: var(--series-1); margin: 0; }
.sl__ends { display: flex; justify-content: space-between; font-size: .68rem; color: var(--ink-3); }

.rogrid { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule);
          border-radius: 10px; overflow: hidden; align-content: start;
          grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); margin-top: 1.2rem; }
.ro { background: var(--surface); padding: .7rem .8rem; }
.ro__k { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.ro__v { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: .1rem; line-height: 1.2; }
.ro__n { font-size: .72rem; color: var(--ink-3); margin-top: .15rem; }
.ro--good .ro__v { color: var(--good-text); }
.ro--warning .ro__n { color: var(--ink-2); }
.ro--critical .ro__v { color: var(--critical); }

.fnrow { display: grid; grid-template-columns: 9.5rem 1fr 3.4rem; gap: .6rem; align-items: center; }
.fnrow__k { font-size: .8rem; color: var(--ink-2); }
.fnrow__v { font-size: .8rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
@media (max-width: 40rem) { .fnrow { grid-template-columns: 7rem 1fr 3rem; } .fnrow__k { font-size: .74rem } }

.txtin {
  width: 100%; font: inherit; font-size: .98rem; padding: .55rem .7rem;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.txtin:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.exline { padding: .85rem 0; border-top: 1px solid var(--rule); }

.stack { display: flex; height: 34px; border-radius: 6px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.stack__s { min-width: 2px; transition: flex-grow .2s; }

.effgrid { display: grid; gap: .55rem; }
.eff { display: grid; grid-template-columns: 9.5rem 1fr 3rem; gap: .6rem; align-items: center; font-size: .8rem; }
.eff__k { color: var(--ink-2); }
.eff__track { position: relative; height: 10px; background: var(--surface-2); border-radius: 999px; }
.eff__mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--baseline); }
.eff__fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; transition: left .2s, width .2s; }
.eff__v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
@media (max-width: 40rem) { .eff { grid-template-columns: 7rem 1fr 2.6rem; } }

.cmp { display: grid; gap: .45rem; margin-top: 1.3rem; }
.cmp__row { display: grid; grid-template-columns: 8rem 1fr; gap: .6rem; align-items: center; font-size: .78rem; color: var(--ink-2); }
.cmp__t { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.cmp__f { height: 100%; border-radius: 4px; transition: width .2s; }

/* one training step */
.phases { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.phase[data-on="1"] { opacity: 1; border-color: var(--ink); transform: translateY(-2px); }
.phase[data-on="2"] { opacity: .85; }
.phase__bar { height: 3px; border-radius: 2px; margin-bottom: .55rem; opacity: .45; }
.phase[data-on="1"] .phase__bar { opacity: 1; }
.phase__k { font-size: .9rem; font-weight: 600; margin-bottom: .2rem; }
.phase__d { font-size: .8rem; color: var(--ink-2); line-height: 1.45; }

/* the week simulation */
.sim__status { display: flex; align-items: center; gap: .5rem; font-size: .92rem; margin-bottom: .7rem; }
.sim__status .ticker__note { margin-left: auto; font-family: var(--mono); font-size: .76rem; }
.sim__track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sim__fill { height: 100%; width: 0; border-radius: 999px; transition: width .2s linear, background .2s; }
.sim__act { margin-top: 1rem; min-height: 2rem; display: flex; align-items: center; }
.sim__log { margin-top: 1rem; display: grid; gap: 1px; background: var(--rule);
            border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.sim__log:empty { display: none; }
.sim__row { background: var(--surface); padding: .45rem .7rem; display: flex; align-items: center;
            gap: .55rem; font-size: .84rem; }
.sim__t { font-family: var(--mono); font-size: .74rem; color: var(--ink-3); white-space: nowrap; }

/* keyboard hint */
.keys { font-size: .74rem; color: var(--ink-3); margin-top: 2rem; }
.keys kbd {
  font-family: var(--mono); font-size: .9em; border: 1px solid var(--rule);
  border-bottom-width: 2px; border-radius: 4px; padding: .05rem .3rem; background: var(--surface);
}

.cmp__k { color: var(--ink-3); }
.sim { display: block; }

/* ==========================================================================
   Canvas — the diagram that folds
   ========================================================================== */

body { background: var(--page); }

.topbar__in {
  display: flex; align-items: center; gap: .75rem; height: 3.25rem;
  width: min(100% - 2rem, 78rem); margin-inline: auto;
}
#canvas { padding-bottom: 5rem; }
#canvas > .wrap { width: min(100% - 2rem, 78rem); }

/* ---------------------------------------------------------------- intro -- */
.intro { padding: 3rem 0 1rem; max-width: 48rem;
         transition: padding .3s cubic-bezier(.2,.7,.3,1); }
.intro__eyebrow { font-family: var(--mono); font-size: .68rem; letter-spacing: .18em;
                  text-transform: uppercase; color: var(--ink-3); margin-bottom: 1.4rem; }
.intro__h1 { font-size: 2.75rem; letter-spacing: 0;
             line-height: 1.08; margin: 0 0 1rem; font-weight: 500; }
.intro__lede { font-size: 1.1rem; color: var(--ink-2); margin: 0; max-width: 60ch; }
.intro__byline { font-size: .95rem; color: var(--ink-2); max-width: 70ch; margin: 1rem 0 0; }
.opening-runs { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 2rem; }
.run-measured { width: 100%; font-size: .75rem; color: var(--ink-3); }
.lesson { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 1.75rem 0; margin-bottom: 2.5rem; }
.lesson__heading h2, .overview-title { font-size: 1.35rem; margin: 0 0 .5rem; letter-spacing: 0; }
.lesson__heading p { max-width: 70ch; color: var(--ink-2); margin: 0 0 1.25rem; }
.lesson__tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); }
.lesson__tabs button { min-height: 48px; padding: .75rem .5rem; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--ink-2); font: inherit; cursor: pointer; }
.lesson__tabs button[aria-selected="true"] { border-bottom-color: var(--series-3); color: var(--ink); background: var(--surface); }
.lesson__scene { min-height: 290px; padding: 1.5rem 0; }
.lesson__sentence { font-size: 1.35rem; margin: 0 0 1.25rem; }
.lesson__explanation { max-width: 75ch; color: var(--ink-2); margin: 1.25rem 0 .75rem; }
.lesson__predictions { max-width: 34rem; display: grid; gap: .45rem; }
.lesson__prediction { display: grid; grid-template-columns: 6rem minmax(0, 1fr) 3rem; gap: .75rem; align-items: center; font-family: var(--mono); font-size: .85rem; }
.lesson__bar { height: 12px; background: var(--surface-2); }
.lesson__bar > span { display: block; height: 100%; background: var(--series-3); }
.lesson__update { padding: 1rem 0; color: var(--series-3); font-size: 1.15rem; }
.lesson__footer { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.lesson__footer p { max-width: 65ch; font-size: .85rem; color: var(--ink-2); margin: 0; }
.mobile-stations { display: none; }
button:focus-visible { outline: 2px solid var(--series-3); outline-offset: 3px; }
#intro[data-min="1"] .lesson, #intro[data-min="1"] .opening-runs, #intro[data-min="1"] .intro__byline { display: none; }
@media (max-width: 48rem) {
  .intro { padding-top: 2rem; }
  .intro__h1 { font-size: 2rem; }
  .lesson__tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson__scene { min-height: 380px; }
  .mobile-stations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
  .mobile-stations button { display: flex; align-items: center; gap: .6rem; text-align: left; min-height: 64px; background: none; border: 0; border-bottom: 1px solid var(--rule); color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer; padding: .6rem 0; }
  .mobile-stations button > span:first-child { color: var(--series-3); font-family: var(--mono); }
  .mobile-stations button[aria-current="true"] { background: var(--surface); }
  #toptick { display: none; }
  .brand { white-space: normal; font-size: .8rem; min-width: 0; }
  .topbar__in { height: auto; min-height: 3.25rem; gap: .4rem; }
}

#intro[data-min="1"] .intro { padding: 1.6rem 0 1rem; }
#intro[data-min="1"] .intro__h1 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; color: var(--ink-2); }
#intro[data-min="1"] .intro__eyebrow, #intro[data-min="1"] .intro__lede { display: none; }

/* --------------------------------------------------------- the pipeline -- */
/* The drawing does the talking: only numbers and one word per station. */

/* one sweep of the band per training step */

#pipe { padding-top: .5rem; }
#pipe, #acts { transition: opacity .25s; }
#pipe[data-dim="1"], #acts[data-dim="1"] { opacity: .4; }
#pipe[data-dim="1"]:hover, #acts[data-dim="1"]:hover { opacity: 1; }

/* -------------------------------------------------------- the activities -- */
#acts { margin-top: clamp(2.5rem, 6vw, 4rem); border-top: 1px solid var(--rule); padding-top: 1.4rem; }
.acts { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; }
.acts__k { font-family: var(--mono); font-size: .68rem; letter-spacing: .16em;
           text-transform: uppercase; color: var(--ink-3); margin-right: .6rem; }
.acts__sep { color: var(--ink-3); opacity: .5; }
.actl { background: none; border: 0; padding: .15rem .1rem; cursor: pointer;
        color: var(--ink-2); font-size: .95rem; display: inline-flex; align-items: baseline; gap: .35rem; }
.actl:hover { color: var(--ink); }
.actl__t { border-bottom: 1px solid transparent; transition: border-color .12s; }
.actl:hover .actl__t { border-bottom-color: var(--ink-3); }
.actl__s { font-family: var(--mono); font-size: .62rem; color: var(--ink-3); opacity: 0; transition: opacity .15s; }
.actl:hover .actl__s, .actl[aria-current="true"] { color: var(--ink); font-weight: 600; }
.actl[aria-current="true"] .actl__t { border-bottom-color: var(--series-3); }

/* the two live runs, kept small */
.runs { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1.6rem; }
.runs__k { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
           text-transform: uppercase; color: var(--ink-3); margin-right: .3rem; }
.mchip {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  background: none; border: 1px solid var(--rule); border-radius: 999px;
  padding: .28rem .7rem .28rem .55rem; color: var(--ink-2); font-size: .78rem;
  transition: border-color .15s, color .15s;
}
.mchip:hover { border-color: var(--ink-3); color: var(--ink); }
.mchip__dot { width: .45rem; height: .45rem; border-radius: 50%; flex: none; }
.mchip--32 .mchip__dot { background: var(--series-1); }
.mchip--9 .mchip__dot { background: var(--series-3); }
@media (prefers-reduced-motion: reduce) { .mchip--32 .mchip__dot { animation: none } }
.mchip__n { font-weight: 600; color: var(--ink); }
.mchip__s { color: var(--ink-3); }
.mchip__bar { width: 3rem; height: 3px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mchip__fill { display: block; height: 100%; border-radius: 999px; }
.mchip--32 .mchip__fill { background: var(--series-1); }
.mchip--9 .mchip__fill { background: var(--series-3); }
.mchip__p { font-family: var(--mono); font-size: .68rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- the unfolded part -- */
#detail { overflow: hidden; }
#detail[data-open="0"] { display: none; }
#detail[data-open="1"] { margin-top: 1.2rem; }
.detail__in {
  border: 1px solid var(--rule); border-top: 2px solid var(--accent);
  border-radius: 0 0 14px 14px; background: var(--surface);
  padding: clamp(1.2rem, 3vw, 2rem);
  animation: unfold .28s cubic-bezier(.2,.7,.3,1);
}
@keyframes unfold { from { opacity: 0; transform: translateY(-10px) scaleY(.985); transform-origin: top; }
                    to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .detail__in { animation: none } }

.dhead { margin-bottom: 1.5rem; }
.dhead__k { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
            font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
            text-transform: uppercase; color: var(--ink-3); }
.dhead__n { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 7px;
            background: var(--accent); color: #fff; font-size: .8rem; letter-spacing: 0; }
.dhead__pins { display: flex; gap: 4px; margin-left: .2rem; }
.dhead__t { font-size: clamp(1.5rem, 3.4vw, 2.1rem); letter-spacing: -.025em; margin: .7rem 0 .5rem; max-width: 22ch; }
.dhead__l { font-size: 1.05rem; color: var(--ink-2); max-width: 48ch; margin: 0; }
.dot { opacity: .5; }

.jump { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 1.5rem 0; }
.jump__k { font-size: .76rem; color: var(--ink-3); }
.jump__b { display: flex; gap: .35rem; flex-wrap: wrap; }

.footbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
           margin-top: 3.5rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.footbar__x { font-size: .78rem; color: var(--ink-3); flex: 1 1 18rem; }

/* pieces shared by the unfolded panels */
.sech { font-size: clamp(1.15rem, 2.4vw, 1.45rem); letter-spacing: -.02em; margin: 2.4rem 0 .8rem; }

.cardgrid {
  display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule);
  border-radius: 12px; overflow: hidden; margin-top: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}
.minicard { background: var(--surface-2); padding: 1rem 1.1rem; }
.minicard__t { font-weight: 600; font-size: .98rem; margin-bottom: .25rem; color: var(--ink); }
.minicard__d { font-size: .9rem; color: var(--ink-2); }

.vnav { display: flex; gap: .6rem; margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.vnav button {
  flex: 1 1 0; min-width: 0; text-align: left; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface-2);
  padding: .65rem .85rem; color: var(--ink-2);
}
.vnav button:hover { border-color: var(--ink-3); background: var(--surface-3); }
.vnav .k { display: block; font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
           text-transform: uppercase; color: var(--ink-3); }
.vnav .t { display: block; font-size: .9rem; font-weight: 600; color: var(--ink); margin-top: .1rem;
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vnav .next { text-align: right; }

.reg__group {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin: 1.1rem 0 .4rem;
}
.reg__group b { font-family: var(--font); font-size: .82rem; letter-spacing: 0;
                text-transform: none; color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------- progressive detail, in order -- */
.facts { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule);
         border-radius: 10px; overflow: hidden;
         grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); margin-bottom: 1.6rem; }
.fact { background: var(--surface-2); padding: .8rem .9rem; }
.fact__k { font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.fact__v { font-size: 1.15rem; font-weight: 600; margin-top: .15rem; color: var(--ink);
           font-variant-numeric: tabular-nums; line-height: 1.25; }

.exp { border-top: 1px solid var(--rule); }
.exp__s {
  cursor: pointer; list-style: none; padding: .75rem 0;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); display: flex; align-items: center; gap: .5rem;
}
.exp__s::-webkit-details-marker { display: none; }
.exp__s::after { content: "+"; margin-left: auto; font-size: .95rem; }
.exp[open] > .exp__s::after { content: "\2212"; }
.exp__s:hover { color: var(--ink); }
.exp__b { padding-bottom: .6rem; }

/* a figure that starts folded shut */
.fig--fold { padding: 0; }
.fig--fold > .fig__head { cursor: pointer; list-style: none; padding: .95rem 1.15rem; margin: 0; }
.fig--fold > .fig__head::-webkit-details-marker { display: none; }
.fig--fold > .fig__head::after { content: "+"; margin-left: .6rem; color: var(--ink-3); font-family: var(--mono); }
.fig--fold[open] > .fig__head::after { content: "\2212"; }
.fig--fold > .fig__head:hover { background: var(--surface-2); }
.fig--fold > .fig__body { padding: 0 1.15rem; }
.fig--fold > figcaption, .fig--fold > details { padding: 0 1.15rem; }
.fig--fold[open] { padding-bottom: 1.15rem; }

/* the way out of an open panel */
.closeb {
  position: absolute; top: .9rem; right: 1rem; width: 1.9rem; height: 1.9rem;
  border-radius: 7px; border: 1px solid var(--rule); background: var(--surface-2);
  color: var(--ink-3); cursor: pointer; line-height: 1; font-size: .8rem;
}
.closeb:hover { color: var(--ink); border-color: var(--ink-3); }
.detail__in { position: relative; }
.dhead__t { padding-right: 2.5rem; }

/* the "here now" marker, reused in the open panel header */
.srow__now { font-family: var(--mono); font-size: .6rem; letter-spacing: .04em;
             padding: .1rem .35rem; border-radius: 999px; white-space: nowrap; }
.srow__now--32 { color: var(--series-1); background: color-mix(in srgb, var(--series-1) 16%, transparent); }
.srow__now--9 { color: var(--series-3); background: color-mix(in srgb, var(--series-3) 16%, transparent); }

/* Process drawing. Colour identifies data, model, update and finishing work. */
.project-subtitle { margin: .5rem 0 0; color: var(--ink-2); font-size: .95rem; }
#intro[data-min="1"] .project-subtitle { display: none; }
.project-role { display: flex; gap: 1rem; align-items: baseline; border-left: 2px solid var(--series-4); padding: .5rem 1rem; margin: 1rem 0; }
.project-role__label { flex: none; font-size: .75rem; color: var(--series-4); }
.project-role p { margin: 0; max-width: 65ch; font-size: .9rem; color: var(--ink-2); }
.project-measurement { color: var(--ink-3); font-size: .75rem; }
.project-evidence { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; border-top: 1px solid var(--rule); margin-top: 1rem; padding-top: 1rem; }
.project-evidence__item { display: flex; flex-direction: column; gap: .35rem; text-align: left; padding: .25rem 0; background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; }
.project-evidence__label { font-family: var(--mono); font-size: .65rem; color: var(--series-4); }
.project-evidence__title { font-size: .95rem; }
.project-evidence__detail { font-size: .75rem; color: var(--ink-3); }
.project-evidence__item:hover .project-evidence__title { text-decoration: underline; }
@media (min-width: 90rem) {
  #canvas[data-exploring="1"] > .wrap { display: grid; grid-template-columns: minmax(0, 1fr) 450px; column-gap: 2rem; align-items: start; }
  #canvas[data-exploring="1"] #intro, #canvas[data-exploring="1"] #acts, #canvas[data-exploring="1"] #foot { grid-column: 1 / -1; }
  #canvas[data-exploring="1"] #pipe { grid-column: 1; grid-row: 2; position: sticky; top: 4.5rem; }
  #canvas[data-exploring="1"] #detail { grid-column: 2; grid-row: 2; margin-top: 0; min-width: 0; }
  #canvas[data-exploring="1"] .dhead__t { font-size: 1.5rem; letter-spacing: 0; }
  #canvas[data-exploring="1"] .dhead__l { font-size: .95rem; }
  #canvas[data-exploring="1"] .project-role { display: block; }
  #canvas[data-exploring="1"] .facts { grid-template-columns: 1fr; }
  #canvas[data-exploring="1"] .fact { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
  #canvas[data-exploring="1"] .fact__v { font-size: 1.2rem; }
}
#pipe[data-folded="1"] .project-evidence { display: none; }
@media (max-width: 48rem) { .project-evidence { grid-template-columns: 1fr; gap: 1rem; } }
@media (max-width: 48rem) { .project-role { display: block; } .project-role p { margin-top: .4rem; } }
#toptick { display: none; }
.mchip__bar, .mchip__p { display: none; }
/* Folded: the diagram shrinks so the panel gets the room — except in the
   side-by-side layout, where the diagram keeps its own column and its height.
   This selector must out-specify the cap above, not merely follow it. */
.detail__in { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; background: none; padding-inline: 0; }
@media (prefers-reduced-motion: reduce) { .process-motion { display: none; } }
@media (max-width: 48rem) {
  .opening-runs .mchip { border: 0; padding: .15rem 0; border-radius: 0; }
}

/* The process is the opening surface; prose belongs to an opened component. */
#canvas > .wrap, .topbar__in { width: min(100% - 3rem, 100rem); }
.intro { max-width: none; padding: 2rem 0 1.25rem; }
.intro__eyebrow { margin: 0 0 .5rem; letter-spacing: 0; }
.intro__h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; letter-spacing: 0; }
.opening-runs { gap: .7rem 1.5rem; align-items: center; margin: 0; padding: .85rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.run-stat { display: flex; align-items: baseline; gap: .45rem; font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.run-stat strong { font-family: var(--mono); font-size: .9rem; color: var(--ink); font-weight: 500; }
.run-measured { width: auto; margin-left: auto; }
#pipe { padding-top: 1.5rem; }
#acts { margin-top: 1rem; padding-top: 1rem; }
#foot { margin-top: 1.5rem; }
@media (max-width: 48rem) {
  #canvas > .wrap, .topbar__in { width: calc(100% - 2rem); }
  .intro { padding: 1.25rem 0 1rem; }
  .intro__h1 { font-size: 1.2rem; }
  .opening-runs { gap: .6rem 1rem; }
  .run-measured { margin-left: 0; width: 100%; font-size: .65rem; }
}


/* ==========================================================================
   The opening diagram
   ========================================================================== */

.process { position: relative; }
.process-desktop { width: 100%; height: auto; display: block; }
.process-mobile { display: none; }
.process-desktop text, .process-mobile text { font-family: var(--font); letter-spacing: 0; }

/* type inside the drawing */
.process-heading { font-size: 15px; fill: var(--ink); font-weight: 600; }
.process-colnum { font-family: var(--mono); font-size: 10px; fill: var(--ink-3); letter-spacing: .1em; }
.process-label { font-size: 12px; fill: var(--ink-2); }
.process-small { font-size: 10.5px; fill: var(--ink-3); }
.process-sentence { font-size: 17px; fill: var(--ink); }
.process-pending { font-size: 10.5px; fill: var(--series-5); }

/* connectors */
.process-stem { stroke: var(--rule); stroke-width: 1.5; fill: none; }
.process-feed { stroke: var(--series-4); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.process-bridge { stroke: var(--rule); stroke-width: 1.5; fill: none; stroke-linejoin: round; }

/* 01 — the text */
.process-doc { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.process-docline { fill: var(--ink-3); opacity: .55; }
.process-keep { fill: var(--series-4); }
.process-drop { fill: var(--ink-3); opacity: .35; }
.process-dots { fill: var(--series-4); opacity: .85; }
.process-token { fill: none; stroke: var(--series-4); stroke-width: 1.5; }
.process-tokentext { font-family: var(--mono); font-size: 10.5px; fill: var(--series-4); }
.process-mixline { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.process-mix1 { stroke: var(--series-4); }
.process-mix2 { stroke: var(--series-2); }
.process-mix3 { stroke: var(--series-5); }
.process-mix4 { stroke: var(--series-1); }
.process-mix5 { stroke: var(--series-3); }
.process-axis { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.process-scatter { fill: var(--series-1); }
.process-trend { fill: none; stroke: var(--series-1); stroke-width: 1.5; stroke-dasharray: 4 3; opacity: .8; }
.process-design-link { fill: none; stroke: var(--series-1); stroke-width: 1; stroke-dasharray: 4 5; opacity: .4; }
.process-feedback { fill: none; stroke: var(--series-5); stroke-width: 1; stroke-dasharray: 3 5; opacity: .5; }
.process-monitor-ring { fill: none; stroke: var(--series-1); stroke-width: 1.5; }
.process-motion { fill: var(--series-3); }
.process-backprop { fill: none; stroke: var(--series-4); stroke-width: 4; stroke-dasharray: 8 5; opacity: 0; }
.process[data-phase="backward"] .process-backprop, .process[data-phase="update"] .process-backprop { opacity: .85; }
.process[data-phase="predict"] [data-training-stage="predict"] .process-label,
.process[data-phase="compare"] [data-training-stage="compare"] .process-label,
.process[data-phase="update"] [data-training-stage="update"] .process-label { fill: var(--series-4); font-weight: 600; }
.process[data-phase="backward"] .process-card { animation: layer-error .35s var(--layer-delay) both; }
@keyframes layer-error { from { stroke: var(--series-1); } to { stroke: var(--series-4); } }
.process[data-phase="update"] .process-weight { fill: var(--series-3); }
.process-weight { transition: opacity .4s, fill .4s; }
.process-base { font-size: 17px; fill: var(--ink); font-weight: 600; }
.process-boundary { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; }
.process-stage-label { min-width: 14rem; color: var(--ink-2); }
.process-caption { flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .process-weight { transition: none; } .process[data-phase="backward"] .process-card { animation: none; stroke: var(--series-4); } }
.process-zone-hit { fill: transparent; stroke: transparent; }
.process-zone:hover .process-zone-hit { stroke: var(--rule); }

/* 02 — the training loop */
.process-card { fill: var(--surface); stroke: var(--series-1); stroke-width: 2; }
.process-card--back { fill: var(--page); opacity: .9; }
.process-weight { fill: var(--series-1); }
.process-loop { fill: none; stroke: var(--series-3); stroke-width: 2.5; }
.process-loophead { fill: none; stroke: var(--series-3); stroke-width: 2.5;
                    stroke-linecap: round; stroke-linejoin: round; }
.process-bar { fill: var(--ink-3); opacity: .45; }
.process-bar--on { fill: var(--series-1); opacity: 1; }
.process-diff { fill: var(--series-4); }
.process-diffmark { stroke: var(--page); stroke-width: 2.5; stroke-linecap: round; }
.process-delta { fill: var(--series-3); }

.process-progress-value { font-size: 18px; fill: var(--series-1); font-weight: 500;
                          font-variant-numeric: tabular-nums; }
.process-progress-track { fill: var(--surface-3); }
.process-progress-fill { fill: var(--series-1); transition: width .6s cubic-bezier(.2,.7,.3,1); }

.process-gpu { fill: var(--series-1); opacity: .75; }
.process-ckpt { fill: none; stroke: var(--series-1); stroke-width: 1.5; }
.process-ckptmark { stroke: var(--series-1); stroke-width: 1.5; opacity: .8; }

/* 03 — finishing */
.process-anneal { fill: none; stroke: var(--series-5); stroke-width: 2.5; stroke-linejoin: round; }
.process-quiet { stroke: var(--ink-3); stroke-width: 2.5; opacity: .6; stroke-linecap: round; }
.process-tuned { stroke: var(--series-5); stroke-width: 2.5; stroke-linecap: round; }
.process-evalbar { fill: var(--series-5); opacity: .9; }

/* clickable regions */
.training-arrow { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linejoin: round; }
.training-model { fill: var(--bg); stroke: var(--ink-2); stroke-width: 1.5; }
.training-target { fill: none; stroke: var(--series-3); stroke-opacity: .65; }
.training-gradient { stroke: var(--series-5); stroke-dasharray: 4 3; opacity: .35; }
.training-update { stroke: var(--series-3); opacity: .35; }
.process[data-phase="backward"] .training-gradient,
.process[data-phase="update"] .training-update { opacity: 1; stroke-width: 2.5; }
.process[data-phase="update"] .training-model { stroke: var(--series-3); stroke-width: 3; }
.process[data-phase="predict"] [data-training-stage="predict"] .process-token { stroke: var(--accent); }
.process[data-phase="compare"] .training-target { stroke-opacity: 1; stroke-width: 2; }
.secondary-run { font-size: .75rem; color: var(--ink-3); margin: .8rem 0; }
.process-zone { cursor: pointer; }
.process-zone:focus { outline: none; }
.process-zone > * { transition: opacity .15s; }
.process-zone:hover { opacity: .78; }
.process-zone:focus-visible .process-label,
.process-zone[aria-current="true"] .process-label { fill: var(--accent); font-weight: 600; }
.process-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.process-zone[aria-current="true"] .process-small { fill: var(--ink-2); }

.process-caption { display: flex; align-items: center; justify-content: flex-end;
                   gap: .6rem; font-size: .76rem; color: var(--ink-3); margin-top: .5rem; }
.process-pause { min-width: 2.1rem; padding: .18rem .5rem; font-size: .7rem; line-height: 1.4; }

/* Folded: the drawing gives room to the panel, except in the side-by-side
   layout where it keeps its own column. This must out-specify the cap. */
#pipe[data-folded="1"] .process-desktop { max-height: 240px; }
@media (min-width: 90rem) {
  #canvas[data-exploring="1"] #pipe[data-folded="1"] .process-desktop { max-height: none; }
}

@media (max-width: 62rem) {
  .process-desktop { display: none; }
  .process-mobile { display: grid; gap: 1.75rem; }
  .process-mobile-section { width: 100%; height: auto; display: block;
                            border-bottom: 1px solid var(--rule); padding-bottom: 1rem; }
  .process-mobile-section:last-child { border-bottom: 0; }
}
