/* =========================================================================
   components.css — maths boxes, scrollytelling, playgrounds, controls, hub.
   ========================================================================= */

/* =======================================================================
   1. MATHS BOXES
   Each kind carries a fixed role colour — only in the word of its label, no
   frame, no edge stripe (Labortisch, Root-D183; colour follows the label,
   CA-D45). The script reference sits top-right so it never interrupts the
   reading flow.
   ======================================================================= */
.box {
  --box-accent: var(--c-text-2);
  position: relative;
  margin: var(--sp-6) 0;
  padding: 24px var(--box-pad-x);
  background: var(--c-bg-2);
  border-radius: var(--r-lg);
  max-width: calc(var(--measure) + 2 * var(--box-pad-x));
}
.box__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.box__kind {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--box-accent);
}
.box__title {
  font-family: var(--f-display);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--c-text-0);
}
.box__ref {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--c-text-2);
  white-space: nowrap;
}
.box__body > :last-child { margin-bottom: 0; }
.box p, .box li { color: var(--c-text-1); }
/* Kapitelseiten hell, auch im Kasten (Root-D141). Steht mit Absicht HIER und
   nicht bei den Textlautstaerken am Ende: gleiche Spezifitaet (0,1,1) wie
   `.steps > li` weiter unten, und die Beweisschritte sollen gewinnen — sie
   bleiben leiser, und der aktive Schritt hebt sich ab wie vor Plan 23. */
:where(body[data-chapter]) .box :is(p, li) { color: var(--c-text-0); }

.box--def    { --box-accent: var(--c-z); }
.box--thm    { --box-accent: var(--c-w); }
.box--prop   { --box-accent: color-mix(in srgb, var(--c-w) 62%, var(--c-text-2)); }
.box--proof  { --box-accent: var(--c-vec); background: var(--c-bg-1); }
.box--sketch { --box-accent: var(--c-warn); background: var(--c-bg-1); }
.box--warn   { --box-accent: var(--c-warn); background: color-mix(in srgb, var(--c-warn) 6%, var(--c-bg-2)); }
.box--note   { --box-accent: var(--c-text-2); background: var(--c-bg-1); }

/* Proof-sketch banner: makes the honesty label impossible to miss. */
.box--sketch .box__body::before {
  content: 'Diese Beweisskizze ist nicht vollständig ausgeführt. Der lückenlose Beweis steht im Skript.';
  display: block;
  font-size: var(--fs-small);
  color: var(--c-text-0);
  background: var(--c-warn-dim);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}

/* q.e.d. box at the end of a proof */
.qed::after {
  content: '';
  display: inline-block;
  width: 0.62em; height: 0.62em;
  margin-left: 0.5em;
  vertical-align: -0.02em;
  border: 1.5px solid var(--c-vec);
  border-radius: 2px;
}

/* Numbered proof steps that a scroll scene can highlight */
.steps { list-style: none; counter-reset: st; margin: var(--sp-4) 0 0; padding: 0; }
.steps > li {
  counter-increment: st;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: var(--sp-3);
  color: var(--c-text-1);
  transition: color var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}
.steps > li::before {
  content: counter(st);
  position: absolute;
  left: 0; top: 0.15em;
  width: 1.65rem; height: 1.65rem;
  display: grid; place-items: center;
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  border: 1px solid var(--c-line);
  border-radius: 50%;
  color: var(--c-text-2);
  transition: all var(--dur-2) var(--ease);
}
.steps > li.is-active { color: var(--c-text-0); }
.steps > li.is-active::before {
  border-color: var(--c-vec);
  color: var(--c-vec);
}
/* Same list, lettered (a) (b) (c) instead of 1 2 3.
   Used where the list reproduces a lettered sub-item list from the script —
   otherwise a cross-reference like "Prop. 2.11(b)" points at a marker the
   page never shows. Proof steps keep the digits. (Plan 2/E19) */
.steps--alpha > li::before { content: counter(st, lower-alpha); }

/* Inline script reference pill, e.g. "Satz 4.4" */
.ref {
  font-family: var(--f-mono);
  font-size: 0.82em;
  color: var(--c-text-2);
  border-bottom: 1px dotted var(--c-line);
  cursor: help;
}

/* =======================================================================
   2. KATEX TWEAKS
   ======================================================================= */
.katex { font-size: 1.06em; color: var(--c-text-0); }
.katex-display {
  margin: var(--sp-5) 0;
  padding: var(--sp-2) 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.katex-display > .katex { color: #fff; }
/* In a box the text holds the measure, a displayed formula may use the box's
   inner padding on both sides — still centred on the text (Root-D136). */
.box .katex-display { margin-inline: calc(-1 * var(--box-pad-x)); }
/* Phone: a displayed formula loses the 6 % that .katex adds. A page with
   `data-formel-umbruch` on <body> lets one wider than the column wrap after
   a relation or an operator (KaTeX cuts it into such pieces in display mode
   too) instead of scrolling inside — opt-in, because a break inside
   brackets or a condition reads wrong: every wrap of such a page was looked
   at (K01–K03, Plan 25/E4). A long \text{für alle …} gets a break point with
   \allowbreak in the TeX, which does nothing on a wide screen. */
@media (max-width: 720px) {
  .katex-display > .katex { font-size: 1em; }
  [data-formel-umbruch] .katex-display > .katex,
  [data-formel-umbruch] .katex-display > .katex > .katex-html { white-space: normal; }
  /* the wrapped lines kept KaTeX's 1.2 and almost touched */
  [data-formel-umbruch] .katex-display > .katex > .katex-html { line-height: 1.8; }
}

/* =======================================================================
   3. SCROLLYTELLING
   The stage is CSS-sticky (robust, no pin-spacer surprises); ScrollTrigger
   is used only to compute progress and toggle the active step.
   ======================================================================= */
.story {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.72fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
  margin-block: var(--sp-8);
}
.story[data-story-layout='right'] { grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.05fr); }
.story[data-story-layout='right'] .story__stage { order: 2; }
.story[data-story-layout='right'] .story__steps { order: 1; }

.story__stage {
  position: sticky;
  top: calc(var(--kopf-h) + var(--sp-4));
  height: min(80vh, 860px);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-bg-1);
  box-shadow: var(--shadow-3), var(--inset-hair);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* A side-by-side split needs a more landscape stage: the two halves are
   already narrow, so the view is width-bound and extra height buys nothing
   but empty grid. */
.story__stage[data-stage='split'] { height: min(66vh, 700px); }

.story__canvas-wrap { position: relative; flex: 1; min-height: 0; }
.story__stage canvas { display: block; width: 100%; height: 100%; }
/* Two stacked canvases: WebGL underlay + 2D overlay */
.story__canvas-wrap canvas.layer {
  position: absolute; inset: 0;
}

.story__caption {
  border-top: 1px solid var(--c-line);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-small);
  color: var(--c-text-1);
  min-height: 3.2rem;
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--c-bg-0) 55%, transparent);
}
.story__caption .katex { font-size: 1em; }

/* The trailing padding keeps the sticky stage on screen while the reader
   finishes the last step, instead of yanking it away mid-sentence.
   It has to be at least (stage height − half a viewport); 34vh covers every
   viewport height we care about, and the extra hold on the final image is
   wanted anyway. */
.story__steps { display: flex; flex-direction: column; padding-bottom: 34vh; }
.story__step {
  min-height: 82vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: var(--sp-6);
  opacity: 0.32;
  transform: translateY(6px);
  transition: opacity var(--dur-3) var(--ease), transform var(--dur-3) var(--ease);
}
.story__step.is-active { opacity: 1; transform: none; }
.story__step > * { max-width: var(--measure); }
.story__step h3 { margin-bottom: var(--sp-3); }
.story__step .step-num {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  color: var(--c-text-2);
  margin-bottom: var(--sp-2);
  display: block;
}
.story__step.is-active .step-num { color: var(--c-vec); }
.story__step:last-child { min-height: 74vh; }

/* =======================================================================
   4. LEGEND — every scene with >= 2 colour roles gets one
   ======================================================================= */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  border-top: 1px solid var(--c-line);
  font-size: var(--fs-micro);
  color: var(--c-text-1);
  background: color-mix(in srgb, var(--c-bg-0) 40%, transparent);
}
/* Only the entries themselves: a descendant selector would turn every KaTeX
   span into a flex box with a gap, pushing each index 6-7 px off its base (F-092). */
.legend > span { display: inline-flex; align-items: center; gap: 0.45em; white-space: nowrap; }
.legend i {
  width: 11px; height: 11px; border-radius: 3px;
  background: var(--k, var(--c-text-2));
  flex: none;
}
.legend i.line { height: 3px; border-radius: 2px; width: 16px; }

/* =======================================================================
   5. PLAYGROUND — the free-play visualisations
   ======================================================================= */
.play {
  margin-block: var(--sp-8);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  background: var(--c-bg-1);
  box-shadow: var(--shadow-3), var(--inset-hair);
  overflow: hidden;
}
.play__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-line);
  flex-wrap: wrap;
}
.play__kind {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-vec);
}
.play__title { font-family: var(--f-display); font-size: 1.18rem; font-weight: 600; }
.play__hint {
  margin-left: auto;
  font-size: var(--fs-micro);
  color: var(--c-text-2);
}
.play__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  min-height: 460px;
}
.play__body[data-panel='wide'] { grid-template-columns: minmax(0, 1fr) 360px; }
.play__stage { position: relative; min-height: 460px; background: var(--c-bg-1); }
.play__stage canvas { display: block; width: 100%; height: 100%; }
.play__stage canvas.layer { position: absolute; inset: 0; }
.play__panel {
  border-left: 1px solid var(--c-line);
  padding: var(--sp-5);
  background: var(--c-bg-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  overflow-y: auto;
  max-height: 78vh;
}

/* Two stages side by side (z-plane / w-plane) */
.play__stage.split { display: grid; grid-template-columns: 1fr 1fr; }
.play__stage.split > div { position: relative; }
.play__stage.split > div + div { border-left: 1px solid var(--c-line); }
.play__stage .plane-label {
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.12em;
  color: var(--c-text-2);
  pointer-events: none;
  z-index: 2;
}

/* =======================================================================
   6. CONTROLS
   ======================================================================= */
.ctrl { display: flex; flex-direction: column; gap: var(--sp-2); }
.ctrl__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-micro);
  color: var(--c-text-1);
}
.ctrl__label .name { letter-spacing: 0.03em; }
.ctrl__label .val {
  font-family: var(--f-mess);
  color: var(--c-text-0);
  font-variant-numeric: tabular-nums;
}

/* Regler (Übergabe 1c): Spur 4 px, Füllung und Knopf Blatt, Knopf 22 px mit
   Radius 6, kein Leuchten, kein Wachsen. In einer Spielwiese 44 px hoch
   (Tippziele, unten). */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: grab;
}
input[type='range']:active { cursor: grabbing; }
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--c-text-0) var(--fill, 0%), var(--c-bg-3) var(--fill, 0%));
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -9px;
  border-radius: 6px;
  background: var(--c-text-0);
  border: 0;
}
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--c-bg-3); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--c-text-0); }
input[type='range']::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 6px; background: var(--c-text-0); }

/* Preset / toggle chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  padding: 5px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-line);
  background: var(--c-bg-1);
  color: var(--c-text-1);
  cursor: pointer;
  transition: all var(--dur-1) var(--ease);
  white-space: nowrap;
}
.chip:hover { border-color: var(--c-text-2); color: var(--c-text-0); }
.chip.is-on {
  border-color: var(--c-z);
  color: var(--c-bg-0);
  background: var(--c-z);
}
.chip .katex { font-size: 0.98em; color: inherit; }

/* Ohne Rahmen tragen nur Fläche und Ring die Kante; im Kontrastmodus fallen
   beide weg (Root-D183). */
@media (forced-colors: active) {
  .cta, .card, .pager a, .box { border: 1px solid CanvasText; }
}

.btn {
  font-family: var(--f-body);
  font-size: var(--fs-small);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-line);
  background: var(--c-bg-1);
  color: var(--c-text-0);
  cursor: pointer;
  transition: all var(--dur-1) var(--ease);
}
.btn:hover { border-color: var(--c-text-2); background: var(--c-bg-3); }
.btn--ghost { background: transparent; }

/* Tap targets on a playground (N-05, Plan 25/E3): every chip, slider and
   button takes a 44 px hit, by mouse as by finger. The element itself grows —
   a pseudo-element would be a target nobody measures (tippziele.mjs). The
   slider keeps its 4 px track, centred in the taller input. */
.play :is(.chip, .btn) { min-height: 44px; min-width: 44px; }
.play input[type='range'] { height: 44px; }

/* Readouts: label + big mono number */
.readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-bg-1);
}
.readout .name { font-size: var(--fs-micro); color: var(--c-text-2); }
.readout .val {
  font-family: var(--f-mono);
  font-size: 0.98rem;
  color: var(--c-w);
  font-variant-numeric: tabular-nums;
}
/* Ein Tonwert je Farbrolle aus tokens.css — sonst schreiben Szenen einen
   Tonnamen hin, der stillschweigend wirkungslos bleibt. */
.readout[data-tone='z'] .val { color: var(--c-z); }
.readout[data-tone='w'] .val { color: var(--c-w); }
.readout[data-tone='path'] .val { color: var(--c-path); }
.readout[data-tone='sing'] .val { color: var(--c-sing); }
.readout[data-tone='zero'] .val { color: var(--c-zero); }
.readout[data-tone='warn'] .val { color: var(--c-warn); }
.readout[data-tone='vec'] .val { color: var(--c-vec); }
.readout[data-tone='ok'] .val { color: var(--c-zero); }
.readout[data-tone='bad'] .val { color: var(--c-sing); }

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.ctrl-group__title {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--c-line);
}

/* Status pill: "Wegunabhängig: ja / nein" */
/* Bewusst inline-block und NICHT inline-flex: sobald in einer Statusmeldung
   Formeln stehen, wird jede KaTeX-Spanne im Flex-Container zu einem eigenen
   Flex-Item und die Zeile bricht nicht mehr um — die Meldung schiebt sich
   dann aus dem Bedienfeld heraus. Im normalen Inline-Fluss umbricht der Text
   zwischen den Formeln von selbst. */
.status {
  display: inline-block;
  max-width: 100%;
  font-size: var(--fs-micro);
  font-family: var(--f-mono);
  line-height: 1.55;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-line);
  color: var(--c-text-1);
}
.status::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  margin-right: 0.5em;
  vertical-align: 0.08em;
  background: var(--c-text-2);
}
.status[data-state='ok'] { color: var(--c-zero); border-color: color-mix(in srgb, var(--c-zero) 40%, transparent); }
.status[data-state='ok']::before { background: var(--c-zero); }
.status[data-state='bad'] { color: var(--c-sing); border-color: color-mix(in srgb, var(--c-sing) 40%, transparent); }
.status[data-state='bad']::before { background: var(--c-sing); }

/* =======================================================================
   7. HUB (index.html)
   ======================================================================= */
/* Das Bild beginnt an der Oberkante, hinter der schwebenden Leiste: der Rand
   zieht es um die Höhe der Leiste hoch, das Polster schiebt den Inhalt wieder
   darunter (Johannes, 2026-10-15). */
.hero {
  position: relative;
  min-height: calc(min(92vh, 900px) + var(--topbar-h));
  margin-top: calc(-1 * var(--topbar-h));
  padding-top: var(--topbar-h);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--c-line);
}
.hero__field {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.hero__field canvas { display: block; width: 100%; height: 100%; opacity: 0.5; }
.hero__veil {
  position: absolute;
  inset: 0;
  background:
    /* keeps the headline legible without flattening the field at the sides;
       centred with the headline since it stands on the axis (Plan 23/E9c) */
    radial-gradient(62% 55% at 47% 46%, color-mix(in srgb, var(--c-bg-0) 95%, transparent),
      color-mix(in srgb, var(--c-bg-0) 50%, transparent) 58%, transparent 82%),
    radial-gradient(120% 120% at 50% 50%, transparent 45%, color-mix(in srgb, var(--c-bg-0) 55%, transparent)),
    linear-gradient(180deg, color-mix(in srgb, var(--c-bg-0) 80%, transparent), transparent 26%, transparent 64%, var(--c-bg-0));
}
/* Full width, or the flex row shrinks the column and centres it off the edge. */
.hero__inner { position: relative; z-index: 2; width: 100%; }
.hero h1 {
  font-size: var(--fs-hero);
  max-width: 15ch;
  margin-bottom: var(--sp-5);
}
/* The subject's --c-z, on the Complex Analysis hub the cyan of the z-plane:
   Johannes tried Kaugummi (--c-mark) and went back, "Cyan wie früher"
   (2026-11-03). */
.hero h1 .accent { color: var(--c-z); }
.hero__sub { max-width: 52ch; font-size: 1.2rem; color: var(--c-text-1); }
.hero__meta {
  margin-top: var(--sp-6);
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  /* text-1, not text-2: over the hero field text-2 reached 4.25 (N-12) */
  color: var(--c-text-1);
}
.hero__meta b { color: var(--c-text-0); font-weight: 400; }
.scroll-cue {
  position: absolute;
  left: 50%; bottom: var(--sp-6);
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.scroll-cue::after {
  content: '';
  width: 1px; height: 34px;
  background: linear-gradient(180deg, var(--c-text-2), transparent);
  animation: cue 2.2s var(--ease) infinite;
}
@keyframes cue { 0%,100% { opacity: .25; transform: scaleY(.6); transform-origin: top; } 50% { opacity: 1; transform: scaleY(1); } }
/* With reduced motion the cue stands (Plan 44/E8). */
@media (prefers-reduced-motion: reduce) { .scroll-cue::after { animation: none; } }

/* Chapter grid. Tile rows fill the whole column on the centre axis
   (base.css, Plan 23/E9c). */
.achse > .cardgrid { margin-inline-start: 0; }
.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-6);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--c-bg-2);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: background-color var(--dur-1) var(--ease);
}
/* Kohle, Radius 22, kein Rahmen; Hover nur Fläche (Übergabe 1c, Root-D182). */
.card:hover { background: var(--c-bg-3); color: inherit; }
.card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--c-bg-0);
}
.card__thumb canvas { display: block; width: 100%; height: 100%; }
.card__num {
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  color: var(--c-text-2);
  z-index: 2;
}
.card__body { padding: var(--sp-4) var(--sp-5) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.card__title { font-family: var(--f-display); font-size: var(--fs-h3); font-weight: 600; line-height: 1.25; }
.card__desc { font-size: var(--fs-small); color: var(--c-text-1); line-height: 1.5; flex: 1; }
.card__ref {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  color: var(--c-text-2);
}
.card--bonus { border: 1.5px dashed var(--c-line-2); }
.card--bonus .card__ref { color: var(--c-warn); }
.card--soon { opacity: 0.55; }
/* A pale tile without a link does not react (CA-D78, NU hub). */
div.card--soon:hover { background: var(--c-bg-2); }
/* The status is a word, not a pill (Root-D183). It sits on the charcoal
   body, not on the picture, and in Blatt: the tile's pallor dims it to about
   Asche, Asche itself would fall under 4.5 : 1. */
.card--soon::after {
  content: 'in Arbeit';
  position: absolute; bottom: var(--sp-4); right: var(--sp-5); z-index: 2;
  font-size: var(--fs-small);
  color: var(--c-text-0);
}

/* Colour-key table on the hub */
.colorkey { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); margin-top: var(--sp-5); }
/* On the axis the key stands in the middle, under its centred lead, and so
   does the hero's meta line under its centred sub (Root-D197). */
.achse > .hero__meta { justify-content: center; margin-inline: 0; }
.achse > .colorkey { margin-inline: auto; max-width: var(--achse-text); justify-content: center; }
.colorkey span { display: inline-flex; align-items: center; gap: 0.55em; font-size: var(--fs-small); color: var(--c-text-1); }
.colorkey i { width: 13px; height: 13px; border-radius: 4px; background: var(--k); }

/* =======================================================================
   8. PAGE STRUCTURE: TOC + ACTS
   A chapter page may be long (D17). It stays navigable because it is cut
   into named acts, each carrying exactly one idea, listed up front.
   ======================================================================= */
.toc {
  margin-block: var(--sp-7) var(--sp-8);
  padding: var(--sp-5) var(--sp-6);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-bg-1);
  box-shadow: var(--inset-hair);
  max-width: 78ch;
}
.toc__title {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-2);
}
.toc ol {
  list-style: none;
  margin: var(--sp-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-2) var(--sp-5);
}
.toc a {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  color: var(--c-text-1);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.toc a:hover { color: var(--c-text-0); border-bottom-color: var(--c-line); }
.toc a b {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  color: var(--c-vec);
  font-weight: 500;
  min-width: 2.4em;
  letter-spacing: 0.08em;
}

.act {
  scroll-margin-top: calc(var(--kopf-h) + var(--sp-4));
  padding-block: var(--sp-8) 0;
  border-top: 1px solid var(--c-line);
  margin-top: var(--sp-8);
}
.act:first-of-type { border-top: 0; margin-top: 0; }
/* The wide frame (Root-D136): a page holding acts is as wide as its stages
   need. Text and boxes in an act stand on the centre axis like every other
   page (Plan 23/E9d): the same margin .achse sets in base.css. Stories and
   playgrounds sit symmetric around it and keep the width they had on the
   left edge, frame minus the old edge offset, so no legend wraps anew: half
   of that offset on each side, 0 below the column. */
.page:has(> .act) { max-width: var(--page-wide); }
.page:has(> .act) > .act > * { margin-inline-start: max(0px, (100% - var(--achse-text)) / 2); }
.page:has(> .act) > .act {
  --stage-inset: max(0px, (100% - var(--page-max) + 2 * var(--page-pad)) / 4);
}
.page:has(> .act) > .act > :is(.story, .play) { margin-inline: var(--stage-inset); }
/* Box pairs (Plan 23/E11e, CA-D71): two boxes that belong together, the
   second speaking of the first, share a .box-pair. Below 1440 px it is a
   column like .prose--wide, the boxes' margins collapse through it and
   nothing moves. From 90em on the pair takes the width of a stage, two equal
   columns, top flush. A column is at least 35rem: with a larger browser font
   the stage (px) no longer holds two, and the boxes stack in the middle,
   column wide, instead of scrolling their formulas. Which boxes pair up is a
   judgement per piece, hence the class; no proof box, no .aha, no displayed
   formula wider than 34rem, and no margin note beside it — there is no margin
   beside a stage. */
.box-pair { max-width: calc(var(--measure) + 2 * var(--box-pad-x)); }
@media (min-width: 90em) {
  .page:has(> .act) > .act > .box-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 35rem), 1fr));
    gap: var(--sp-6);
    align-items: start;
    max-width: none;
    margin-block: var(--sp-6);
    margin-inline: var(--stage-inset);
  }
  .box-pair > .box { margin: 0; width: 100%; justify-self: center; }
}
/* The head spans the act, its number and title centred, its lead on the axis
   (Plan 23/E11a, base.css). */
.act__head { margin-bottom: var(--sp-6); }
.page:has(> .act) > .act > .act__head { margin-inline-start: 0; }
.act__n {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-vec);
  margin-bottom: var(--sp-3);
}
.act__n::before {
  content: '';
  width: 22px; height: 1px;
  background: var(--c-vec);
}
.act__head h2 { margin-bottom: var(--sp-3); }
.act__lead { font-size: 1.12rem; color: var(--c-text-1); line-height: 1.6; }
/* The reference line closing an act (Root-D130): what the script also holds
   and the page needs no box for. Numbers only, no formula — a footnote to
   the act, deliberately smaller and quieter than any box. */
.act__skript {
  max-width: var(--measure);
  margin-top: var(--sp-6);
  font-size: var(--fs-small);
  color: var(--c-text-1);
}
/* Margin notes (Plan 23/E11c, CA-D70): with room beside the axis, a note
   marked .randnotiz leaves the column and stands in the right margin, top
   flush with what it hangs on. The reference line from 1440 px on, beside the
   act's last paragraph or box; the long .callout only from 1920 px on, beside
   its box, where the margin holds it in 8-10 lines. Which note may go is a
   judgement per piece, hence the class: never one right under a stage, there
   is no margin beside a stage. The act is the containing block, so each
   anchor name only resolves inside its own act. Below the step, or without
   anchor positioning, the note stays where it always was. The steps are in
   em, 90em and 120em (1440 and 1920 px at 16 px): a larger browser font
   narrows the margin, so it raises the step with it. */
@supports (anchor-name: --a) {
  @media (min-width: 90em) {
    .page:has(> .act) > .act:has(.randnotiz) { position: relative; }
    .page:has(> .act) > .act > :has(+ .act__skript.randnotiz) > :last-child { anchor-name: --randnotiz-verweis; }
    .page:has(> .act) > .act > .act__skript.randnotiz {
      position: absolute;
      position-anchor: --randnotiz-verweis;
      top: anchor(top);
      left: calc(50% + var(--achse-text) / 2 + var(--sp-6));
      width: min(18rem, 50% - var(--achse-text) / 2 - var(--sp-6));
      margin: 0;
    }
  }
  @media (min-width: 120em) {
    .page:has(> .act) > .act > .prose--wide > :has(+ .callout.randnotiz) { anchor-name: --randnotiz-nachsatz; }
    .page:has(> .act) > .act > .prose--wide > .callout.randnotiz {
      position: absolute;
      position-anchor: --randnotiz-nachsatz;
      top: anchor(top);
      left: calc(50% + var(--achse-text) / 2 + var(--sp-6));
      width: min(18rem, 50% - var(--achse-text) / 2 - var(--sp-6));
      margin: 0;
      font-size: var(--fs-small);
    }
    /* A reference line whose anchor is such a note stacks under it. */
    .page:has(> .act) > .act > :has(> .callout.randnotiz:last-child) + .act__skript.randnotiz {
      top: calc(anchor(bottom) + var(--sp-5));
    }
  }
}

/* ---- The act narrative (Plan 31, CA-D73 — the form of every chapter) --
   A second form beside the old one, only under .act--narrative: after the
   head the act holds exactly one .story whose text column carries the whole
   act — narrative steps, boxes, the point, the playground's text — while the
   stage stays pinned until the act ends. Every child of .story__steps is a
   step; a step may name an image state (data-zustand, scroll.js). The stage
   may hold a whole .play: head, canvas, panel in rows below it, legend.
   The story takes the full frame of the page, the text column is the measure,
   the stage the rest. Below 1181 px the act stacks: see "stacked" below. */
.page:has(> .act) > .act--narrative > .story { margin-inline: 0; }
.act--narrative > .story > .story__steps {
  gap: var(--sp-7);
  padding-bottom: 40vh;
}
.act--narrative > .story > .story__steps > * { margin: 0; }
.act--narrative > .story > .story__steps > .story__step {
  min-height: 0;
  padding-block: 0;
  display: block;
}
.act--narrative > .story > .story__steps > .story__step:last-child { min-height: 0; }
@media (min-width: 1181px) {
  .act--narrative > .story {
    grid-template-columns: minmax(0, 1fr) var(--measure);
  }
  .act--narrative > .story > .story__stage { order: 1; }
  .act--narrative > .story > .story__steps { order: 2; }
  /* Sides alternate per act, act I image left; data-story-layout wins. */
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story,
  .act--narrative > .story[data-story-layout='right'] {
    grid-template-columns: var(--measure) minmax(0, 1fr);
  }
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story > .story__stage,
  .act--narrative > .story[data-story-layout='right'] > .story__stage { order: 2; }
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story > .story__steps,
  .act--narrative > .story[data-story-layout='right'] > .story__steps { order: 1; }
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story[data-story-layout='left'] {
    grid-template-columns: minmax(0, 1fr) var(--measure);
  }
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story[data-story-layout='left'] > .story__stage { order: 1; }
  .page:nth-child(even of :has(> .act--narrative)) > .act--narrative > .story[data-story-layout='left'] > .story__steps { order: 2; }
}
/* A playground as the stage (Johannes, 2026-10-04: three zones): under the
   canvas the status lines as its caption, then a thin strip of readouts, then
   only the controls and the reset. CSS only: the groups of the panel dissolve
   (display: contents) and their children are sorted by kind with order, so
   the scenes and controls.js stay as they are. Nothing scrolls inside (Plan
   25 F-094) unless the window is too low: then the canvas keeps its minimum. */
.act--narrative .story__stage--play { background: var(--c-bg-1); }
/* Window high only beside the text column; stacked, see below. */
@media (min-width: 1181px) {
  .act--narrative .story__stage--play { height: calc(100vh - var(--kopf-h) - 2 * var(--sp-4)); }
  /* A stage without controls grows with the window up to a cap and stands
     in the middle of it, not on top with the rest empty (Plan 31/E2, the
     narrative's share of Plan 25 F-104: 45 % empty below at 2560 x 1440).
     A split stays width-bound at its old height and is only centred. */
  .act--narrative > .story > .story__stage:not(.story__stage--play) {
    --buehne-h: min(100vh - var(--kopf-h) - 2 * var(--sp-4), 1100px);
    height: var(--buehne-h);
    top: max(var(--kopf-h) + var(--sp-4), (100vh + var(--kopf-h) - var(--buehne-h)) / 2);
  }
  .act--narrative > .story > .story__stage[data-stage='split'] { --buehne-h: min(66vh, 700px); }
}
.act--narrative .story__stage--play > .play {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.act--narrative .story__stage--play .play__head { padding: var(--sp-3) var(--sp-4); }
/* Two images on one stage (Plan 33/E3): a narrative image (.story__bild:
   canvas, caption, legend) beside the playground; scroll.js marks the one
   out of the picture .is-aus. Beside the text column the stage keeps the
   playground's window height, so it does not jump when the image changes. */
.act--narrative .story__stage--play > .story__bild {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.act--narrative .story__stage--play > .is-aus { display: none; }
.act--narrative .story__stage--play .play__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* The canvas keeps 320 px beside the text column from a 768 px high window
   on, so the domain stays in the picture on a 1366 x 768 laptop (Plan 33/E1:
   it was 240 px); the panel gives way and scrolls in itself (Plan 31/E1). In
   a lower window the floor sinks back to 240 px, so the panel keeps room. */
.act--narrative .story__stage--play .play__stage {
  flex: 1 0 auto;
  min-height: max(clamp(240px, 100vh - 448px, 320px), 45%);
}
.act--narrative .story__stage--play .play__panel {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0;
  padding: 0 0 var(--sp-3);
  border-left: 0;
  border-top: 1px solid var(--c-line);
  max-height: none;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.act--narrative .story__stage--play .ctrl-group { display: contents; }
.act--narrative .story__stage--play .ctrl-group__title { display: none; }
/* Zone 1 — the status lines, read like the caption of a narrative. */
.act--narrative .story__stage--play .status {
  order: 0;
  flex: 1 1 100%;
  max-width: none;
  margin: 0;
  padding: 4px var(--sp-4);
  border: 0;
  border-bottom: 1px solid var(--c-line);
  border-radius: 0;
  font-family: var(--f-body);
  font-size: var(--fs-small);
  line-height: 1.45;
  background: color-mix(in srgb, var(--c-bg-0) 55%, transparent);
}
/* Zone 2 — the readouts as one strip of small mono pairs. */
.act--narrative .story__stage--play .readout {
  order: 2;
  flex: 0 0 auto;
  gap: 0.45em;
  margin: 6px 0 0 var(--sp-4);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.act--narrative .story__stage--play .readout .val { font-size: 0.82rem; }
/* The rule between readouts and controls. */
.act--narrative .story__stage--play .play__panel::before {
  content: '';
  order: 3;
  flex: 1 1 100%;
  height: 1px;
  margin-top: 8px;
  background: var(--c-line);
}
/* Zone 3 — only what the hand moves. */
/* A row of toggles a scene builds by hand (.chips) counts as a control. */
.act--narrative .story__stage--play .ctrl-group > :is(.ctrl, .chip, .chips, .btn) {
  order: 4;
  margin: var(--sp-3) 0 0 var(--sp-4);
}
.act--narrative .story__stage--play .ctrl-group > .ctrl { flex: 1 1 12rem; min-width: 0; margin-right: var(--sp-4); }
.act--narrative .story__stage--play .ctrl-group > :is(.btn, .chips) { flex: 0 0 auto; margin-right: var(--sp-4); }
/* The reset (the last ghost button of a group) closes the readout strip.
   When the panel has to scroll it stays pinned inside the panel's visible
   edge, so the way back is never out of view (Plan 33/E1). Stacked, the
   panel does not scroll in itself and the reset stays where it was. */
@media (min-width: 1181px) {
  .act--narrative .story__stage--play .ctrl-group > .btn--ghost:last-child {
    order: 2;
    position: sticky;
    top: 0;
    bottom: var(--sp-2);
    z-index: 1;
    margin: 6px var(--sp-4) 0 auto;
    background: var(--c-bg-1);
  }
}

/* The counter (Plan 25/E2, V-051, built by scroll.js): dots for the
   numbered steps and "Schritt N von M" on a small tab that hangs from the
   seam under the canvas in the picture, at its right end, inside the top
   padding of the caption; on a playground it stands on the seam under the
   head, inside the head's bottom padding (the status runs full width). The seam
   has no height: a row in the caption made captions wrap and shrank the
   canvas, a pill across the seam covered a read-out of the canvas. Each
   dot is a 24 x 24 px target (::after), off the canvas. Neutral ink: the role colours
   mean mathematics. */
.story__naht { position: relative; flex: 0 0 0; height: 0; z-index: 2; }
.story__zaehler {
  position: absolute;
  top: 0;
  right: var(--sp-4);
  display: flex;
  align-items: center;
  height: 11px;
  padding: 0 var(--sp-2) 0 0;
  border: 1px solid var(--c-line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: var(--c-bg-1);
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  line-height: 11px;
  color: var(--c-text-1);
}
.story__naht--oben .story__zaehler {
  top: auto;
  bottom: 0;
  border-top: 1px solid var(--c-line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.story__punkte { display: flex; }
.story__punkt {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 11px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.story__punkt::before {
  content: '';
  width: 6px;
  height: 6px;
  border: 1px solid var(--c-text-2);
  border-radius: 50%;
}
/* The 24 px target reaches away from the canvas, never into it. */
.story__punkt::after { content: ''; position: absolute; inset: 0 -2px -13px; }
.story__naht--oben .story__punkt::after { inset: -13px -2px 0; }
.story__punkt:hover::before { border-color: var(--c-text-0); }
.story__punkt.is-aktiv::before { background: var(--c-text-0); border-color: var(--c-text-0); }
.story__zahl { margin-left: var(--sp-1); white-space: nowrap; }
.story__zahl-kurz { display: none; }

/* Stacked, up to 1180 px (Plan 31/E2): only the canvas sticks, at most
   min(50vh, 420px) — 40vh in a low window, so text stays beside the header
   — and it sticks until the act ends: no padding after the last step, the
   reading line sits in the free band under the canvas (scroll.js). A
   playground dissolves its frame (display: contents): its head scrolls by
   above the canvas, the canvas sticks, the panel comes after the last step
   and is read with the canvas still above it. A filled legend sticks under
   the canvas inside the same budget, a fixed band that scrolls in itself
   when it holds more. The states keep setting their
   presets, so every image is seen without a control (Root-D3). The column
   is minmax(0, 1fr): a plain 1fr grew to the panel's min-content (424 px
   at 390). */
@media (max-width: 1180px) {
  .act--narrative > .story,
  .act--narrative > .story[data-story-layout] {
    --leinwand-h: min(50vh, 420px);
    --legende-h: 4.5rem;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
  }
  .act--narrative > .story > .story__steps { padding-bottom: 0; }
  /* The collar: the band between header and canvas is page ground, so no
     text shows through above the image. */
  .act--narrative > .story > .story__stage,
  .act--narrative .story__stage--play .play__stage {
    box-shadow: 0 calc(-1 * var(--sp-4)) 0 0 var(--c-bg-0);
  }
  .act--narrative > .story > .story__stage {
    height: var(--leinwand-h);
    margin-bottom: var(--sp-6);
    z-index: 2;
  }
  .act--narrative > .story > .story__stage--play,
  .act--narrative .story__stage--play > .play,
  .act--narrative .story__stage--play .play__body { display: contents; }
  .act--narrative .story__stage--play .play__head { padding: 0 0 var(--sp-3); }
  .act--narrative .story__stage--play .play__stage {
    position: sticky;
    top: calc(var(--kopf-h) + var(--sp-4));
    z-index: 2;
    flex: none;
    height: var(--leinwand-h);
    min-height: 0;
    margin-bottom: var(--sp-6);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    overflow: hidden;
  }
  .act--narrative .story:has([data-legend] > *) .play__stage {
    height: calc(var(--leinwand-h) - var(--legende-h));
    margin-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .act--narrative .story__stage--play [data-legend]:not(:empty) {
    position: sticky;
    top: calc(var(--kopf-h) + var(--sp-4) + var(--leinwand-h) - var(--legende-h));
    z-index: 2;
    height: var(--legende-h);
    margin-bottom: var(--sp-6);
    overflow-y: auto;
    border: 1px solid var(--c-line);
    border-top: 0;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    background: var(--c-bg-1);
  }
  .act--narrative .story__stage--play [data-legend] > .legend { border-top: 0; min-height: 100%; }
  /* Two images, stacked: the narrative image sticks like a canvas of the
     same height (legend inside), so swapping it with canvas and legend of
     the playground moves no step. The playground's head stays in the flow;
     its panel only stands after the last step while it is in the picture. */
  .act--narrative .story__stage--play > .story__bild {
    position: sticky;
    top: calc(var(--kopf-h) + var(--sp-4));
    z-index: 2;
    height: var(--leinwand-h);
    margin-bottom: var(--sp-6);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--c-bg-1);
    box-shadow: 0 calc(-1 * var(--sp-4)) 0 0 var(--c-bg-0);
  }
  .act--narrative .story__stage--play > .play.is-aus { display: contents; }
  .act--narrative .story__stage--play > .play.is-aus :is(.play__stage, [data-legend], .play__panel) { display: none; }
  /* Its head keeps its place in the flow but says nothing while the
     narrative image is in the picture. */
  .act--narrative .story__stage--play > .play.is-aus .play__head { visibility: hidden; }
  /* Long entries wrap as running text, not as flex items: inline-flex broke
     a formula into one piece per line. */
  /* The counter: "2/4" on its pill; a playground's seam scrolls by with
     the frame dissolved, so there it is left out. */
  .story__zahl-voll, .story__stage--play .play .story__naht { display: none; }
  .story__zahl-kurz { display: inline; }
  .act--narrative .story__stage .legend { display: block; line-height: 1.5; }
  .act--narrative .story__stage .legend > span { display: inline; white-space: normal; margin-right: var(--sp-4); }
  .act--narrative .story__stage .legend > span span:not([class]) { display: inline; white-space: normal; }
  .act--narrative .story__stage .legend > span > i { display: inline-block; margin-right: 0.45em; vertical-align: middle; }
  /* Two planes stacked (CA-D74) under caption and legend: at 390 × 844 each
     field kept 143 px of min(50vh, 420px). The story gives a stacked split
     stage more height, so a field gets ~190 px and a band for the text stays
     (Plan 33/E4). A playground's split stage keeps its height: it has no
     caption inside and its fields measured 174 px. Rule below this block. */
  .act--narrative .story__stage--play .play__panel {
    order: 2;
    margin-top: var(--sp-6);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    background: var(--c-bg-1);
    overflow: visible;
  }
}
/* The stacked split rule above, only where the window is not low: its
   specificity would beat the 40vh of the low window (667 x 375 stacks). */
@media (max-width: 1180px) and (min-height: 501px) {
  .act--narrative > .story:has(> .story__stage[data-split-gestapelt]) {
    --leinwand-h: min(62vh, 520px);
  }
}
/* In a low window the legend would take half the canvas: it stays in the
   flow above the text, the canvas keeps the whole 40vh. */
@media (max-width: 1180px) and (max-height: 500px) {
  .act--narrative > .story,
  .act--narrative > .story[data-story-layout] { --leinwand-h: 40vh; --legende-h: 0px; }
  .story__zaehler { display: none; }
  /* Two images: the narrative image keeps the whole 40vh for its canvas,
     and the playground's legend in the flow keeps its height while hidden,
     so swapping the images moves no step. */
  .act--narrative .story__stage--play > .story__bild > :is(.story__caption, .legend) { display: none; }
  .act--narrative .story__stage--play > .play.is-aus [data-legend] { display: block; visibility: hidden; margin-bottom: 0; }
  .act--narrative .story__stage--play [data-legend]:not(:empty) { position: static; height: auto; }
  .act--narrative .story:has([data-legend] > *) .play__stage { border-radius: var(--r-lg); }
}

/* ---- Source notice (Root-D129) -----------------------------------------
   Filled by RQ.fillQuelle in boot.js, which also sets these classes — an
   empty slot without JS carries no class and renders nothing. The notice stands on every page of the
   subject under its statements, on the hub under the hero (Root-D230): a box in the workbench dress (Root-D183) — charcoal, radius
   16, no frame — with a mono label like the contents box below it, not a
   maths box and not in the look of a warning. */
.quelle-kasten {
  max-width: var(--achse-text);  /* edge to edge with the text column above it */
  margin: var(--sp-6) 0;
  padding: 20px var(--box-pad-x) 22px;
  border-radius: var(--r-lg);
  background: var(--c-bg-2);
  font-size: var(--fs-small);
  line-height: 1.6;
}
.quelle-kasten__titel {
  display: block;
  margin-bottom: var(--sp-3);
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-2);
}
.quelle-kasten p { color: var(--c-text-1); margin: 0; }
.quelle-kasten p + p { margin-top: var(--sp-3); }

/* =======================================================================
   8b. FILM — a picture that waits for Start and runs through its shots
   (Complex Analysis, Plan 48, CA-D84; recut in E4, CA-D85). Contract and
   states: mathe/ComplexAnalysis/assets/js/film.js. The film is one dark
   stage: the picture, in it the sentence and the formulas (on a wide stage
   in a column on the right, free of the picture, on a narrow one as a band
   on top), under it one continuous bar and a row with the play button on
   the left and the tempo (E4a). Without the
   script every sentence stands in a list under an empty stage.
   The stage's ground is `--c-bg-film` (tokens.css); the scene paints with it.
   ======================================================================= */
.film {
  margin-block: var(--sp-6) var(--sp-6);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  background: var(--c-bg-film);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
/* The film may be wider than the text column: on a large screen the picture
   is what the page is for. */
.page:has(> .film) { max-width: 1500px; }
.film__bild { position: relative; container-type: inline-size; }
.film__leinwand {
  position: relative;
  aspect-ratio: 16 / 9;
  /* The whole film — picture, bar and row — fits under the top bar. */
  max-height: calc(100vh - 216px);
  min-height: 320px;
  width: 100%;
  background: var(--c-bg-film);
}
.film__leinwand canvas { display: block; width: 100%; height: 100%; }
.film__leinwand canvas.layer { position: absolute; inset: 0; }
/* In a film the picture is no drawing board: a click pauses, so the pointer
   stays plain, not the crosshair of canvas[data-draggable] below (Johannes,
   16.11.); over a handle grab, while dragging grabbing. */
.film .film__leinwand canvas[data-draggable] { cursor: auto; }
.film.hat-griff .film__leinwand canvas.is-over { cursor: grab; }
.film.hat-griff .film__leinwand canvas.is-dragging { cursor: grabbing; }

/* Sentence and Tafel in the picture. The mouse goes through to the canvas. */
.film__text {
  position: absolute;
  /* one pixel over the lower edge: the stage is not a whole number of pixels high */
  inset: 0 0 -1px auto;
  width: 40%;
  /* One measure for type and gaps: the stage's width, or its height where
     a low window makes the stage low — so the column never outgrows it. */
  --m: min(1cqw, calc((100vh - 216px) / 42));
  display: flex;
  flex-direction: column;
  /* should it outgrow the stage after all, the first line stays inside */
  justify-content: safe center;
  gap: clamp(var(--sp-4), calc(2.6 * var(--m)), var(--sp-7));
  /* The text begins 7 % of the stage right of the column's edge: the scene
     lets the picture run out before the column (its SPALTE and SAUM), so
     the words stand free of it (Johannes, 15.11.: „hängt so leicht im
     bild“). */
  padding: var(--sp-5) clamp(var(--sp-4), 3cqw, var(--sp-7)) var(--sp-5) 7cqw;
  pointer-events: none;
}
.film[data-zustand="wartet"] .film__text { visibility: hidden; }
.film__saetze {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  color: var(--c-text-0);
  font-size: clamp(0.8rem, calc(1.5 * var(--m)), 1.3rem);
  font-weight: 500;
  line-height: 1.5;
}
/* Every sentence keeps its place in one grid cell; film.js sets opacity. */
.film__saetze > li { grid-area: 1 / 1; align-self: end; opacity: 0; visibility: hidden; }
.film__saetze > li.is-aktiv { visibility: visible; }
.film__tafeln { display: grid; min-height: 11.5em; font-size: clamp(0.88rem, calc(1.8 * var(--m)), 1.5rem); }
.film__tafel { grid-area: 1 / 1; display: flex; flex-direction: column; gap: 0.5em; opacity: 0; }
.film__tafel p { margin: 0; color: var(--c-text-0); line-height: 1.35; }
.film__tafel [data-ein] { opacity: 0; will-change: opacity, transform; }
.film__tafel span[data-ein] { display: inline-block; }
/* grows from no width to its own while it comes in (film.js sets the width) */
.film__tafel [data-dehnt] { white-space: nowrap; }
/* One object, one colour: the roles of the subject, in picture and formula. */
.film__text .katex { color: inherit; }
.film .f-z { color: var(--c-z); }
.film .f-w { color: var(--c-w); }
.film .f-v { color: var(--c-vec); }
.film .f-p { color: var(--c-path); }
.film__zahl { font-family: KaTeX_Main, 'Times New Roman', serif; font-size: 1.21em; font-variant-numeric: tabular-nums; }

/* Start lies on the waiting picture; the script hides it once the film ran. */
.film__start {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: 168px; min-height: 64px;
  padding: 0 var(--sp-6);
  font-family: var(--f-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--c-bg-0);
  background: var(--c-text-0);
  border: 0;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease);
}
.film__start::before { content: '▶'; margin-right: 0.6em; font-size: 0.8em; }
.film__start:hover { transform: translate(-50%, -50%) scale(1.05); }
.film__start[hidden] { display: none; }

.film__steuer { padding: 0 var(--sp-5) var(--sp-3); }
/* One continuous bar. The element is 44 px tall for pointer and wheel, the
   visible track a line in its middle that grows under the mouse. */
.film__balken {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.film__spur {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--c-line-2);
  transition: height var(--dur-1) var(--ease);
}
.film__balken:hover .film__spur,
.film__balken.is-zieht .film__spur,
.film__balken:focus-visible .film__spur { height: 10px; }
.film__balken:focus-visible .film__spur { outline: 2px solid var(--c-text-0); outline-offset: 4px; }
.film__fuellung {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--c-text-0);
  transform: scaleX(0);
  transform-origin: left center;
}
/* where a shot begins: a fine mark under the track, the track stays whole */
.film__marke {
  position: absolute;
  top: calc(100% + 5px);
  width: 2px; height: 5px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--c-text-2);
  opacity: 0.55;
}
.film__knauf {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--c-text-0);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-1) var(--ease);
}
.film__balken:hover .film__knauf,
.film__balken.is-zieht .film__knauf { transform: scale(1.25); }
.film__reihe { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
/* The play button: a symbol, bottom left; which one, says the film's state. */
.film__lauf {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  padding: 0;
  color: var(--c-text-0);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.film__lauf:hover { background: var(--c-bg-3); }
.film__lauf:focus-visible { outline: 2px solid var(--c-text-0); outline-offset: 2px; }
.film__lauf svg { display: none; width: 30px; height: 30px; fill: currentColor; }
.film:not([data-zustand="spielt"], [data-zustand="ende"]) .film__lauf svg[data-zeichen="los"],
.film[data-zustand="spielt"] .film__lauf svg[data-zeichen="halt"],
.film[data-zustand="ende"] .film__lauf svg[data-zeichen="neu"] { display: block; }
.film__tempo { display: flex; align-items: center; gap: 2px; }
.film__tempo-wort {
  margin-right: var(--sp-3);
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-2);
}
.film__tempo button {
  min-width: 52px; min-height: 44px;
  padding: 0 var(--sp-2);
  font-family: var(--f-mono);
  font-size: var(--fs-small);
  color: var(--c-text-2);
  background: transparent;
  border: 0;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.film__tempo button:hover { color: var(--c-text-0); }
.film__tempo button[aria-pressed="true"] { color: var(--c-text-0); background: var(--c-bg-3); }
.film__tempo button:focus-visible { outline: 2px solid var(--c-text-0); outline-offset: -2px; }

/* Narrow stage: the sentence is a band on top, the Tafel is left out. */
@container (width < 760px) {
  .film__leinwand { aspect-ratio: 4 / 5; }
  .film__text {
    inset: 0 0 auto 0;
    width: auto;
    padding: var(--sp-4) var(--sp-4) var(--sp-6);
    background: linear-gradient(to bottom, var(--c-bg-film) 72%, transparent);
  }
  .film__saetze { font-size: 0.94rem; line-height: 1.42; }
  .film__saetze > li { align-self: start; }
  .film__tafeln { display: none; }
}
@media (max-width: 700px) {
  .film__steuer { padding-inline: var(--sp-3); }
  .film__tempo-wort { display: none; }
  .film__tempo button { min-width: 44px; }
}

/* Without the script, and until the scene is set up (it waits for the
   stage to come into view, so the stage itself must stay): the
   sentences as a list under an empty stage. */
.film:not(.is-bereit) .film__tafeln,
.film:not(.is-bereit) .film__start,
.film:not(.is-bereit) .film__steuer { display: none; }
.film:not(.is-bereit) .film__text {
  position: static;
  width: auto;
  visibility: visible;
  padding: var(--sp-5);
  background: none;
}
.film:not(.is-bereit) .film__saetze { display: block; font-size: var(--fs-body); font-weight: 400; }
.film:not(.is-bereit) .film__saetze > li { opacity: 1; visibility: visible; max-width: 78ch; margin-inline: auto; }
.film:not(.is-bereit) .film__saetze > li + li { margin-top: var(--sp-3); }

/* The statements under a film (Plan 48/E4a; Johannes, 15.11.: „diese Sachen
   kann man auch nebeneinander packen“): in a wide window two columns, the
   first box, the long one, on the left over both rows. Below that one
   column on the page's axis, about as wide as a box in running text
   (Root-D153). The threshold is the page's own width in rem, 72rem, a
   window of about 1280 px at the usual 16 px: the page never grows past
   1500 px, so with a large browser font the boxes stack on any screen
   instead of squeezing their formulas (CA-D71). */
.page:has(> .film-aussagen) { max-width: 1500px; container-type: inline-size; }
.film-aussagen { display: grid; gap: var(--sp-5); margin-block: var(--sp-6); margin-inline: auto; max-width: var(--achse-text); }
.film-aussagen > .box { margin: 0; max-width: none; min-width: 0; }
@container (min-width: 72rem) {
  .film-aussagen { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; max-width: none; }
  .film-aussagen > .box:first-child { grid-row: span 2; }
}

/* A focusable handle over a draggable point (RQ.ui.griff): the mouse goes
   through to the canvas, the keyboard lands here. Moved here from the
   Numerik layer when the film became its second user (Plan 48/E2). */
.griff {
  position: absolute;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
}
.griff:focus-visible { outline: 2px solid var(--c-text-0); outline-offset: 2px; }
.griff[hidden] { display: none; }

/* =======================================================================
   9. MISC
   ======================================================================= */
/* Die labellose Randbemerkung: ein Nachsatz, der an dem haengt, was darueber
   steht — meist ein Hinweis auf die Spielwiese daneben. Bewusst OHNE Kopfzeile
   und Etikett; wer ein Etikett hat, nimmt `.box--note`. In Plan 2/E18 geprueft
   und behalten: die sechs Vorkommen auf K01-K03 haetten als `.box--note` je ein
   erfundenes Etikett gebraucht. */
.callout {
  border-left: 2px solid var(--c-vec);
  padding-left: var(--sp-4);
  margin: var(--sp-6) 0;
  color: var(--c-text-1);
  font-size: 1.08rem;
  max-width: calc(var(--measure) + var(--sp-4) + 2px);
}
.aha {
  margin: var(--sp-6) 0;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--c-w) 30%, var(--c-line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--c-w) 7%, var(--c-bg-2)), var(--c-bg-2));
  max-width: calc(var(--measure) + 2 * var(--sp-5) + 2px);
}
.aha__kind {
  font-family: var(--f-mono); font-size: var(--fs-micro);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--c-w);
  display: block; margin-bottom: var(--sp-2);
}

/* Canvas gets a crosshair cursor when it hosts draggable points */
canvas[data-draggable] { cursor: crosshair; }
canvas[data-draggable].is-over { cursor: grab; }
canvas[data-draggable].is-dragging { cursor: grabbing; }

/* =======================================================================
   FREE PAGES AND THE FUNCTION PLOTTER (Plan 46, Root-D225)
   „nicht im Skript“ stands in the head of every free page; the plotter's
   stage is taller than a playground's, and its formula field is the only
   text input in CA.
   ======================================================================= */
.frei-marke { color: var(--c-warn); }
.card--frei { border: 1.5px dashed var(--c-line-2); }
.card--frei .card__ref { color: var(--c-warn); }
.page:has(> .play--plotter) { max-width: 1500px; }
.play--plotter { margin-block: var(--sp-3) var(--sp-8); }
/* The page opens with the plotter (Plan 49/E3): its name stands in its own head, no text above. */
.play__name { margin: 0; font-family: var(--f-display); font-size: 1.18rem; font-weight: 600; line-height: 1.2; }
.play--plotter .play__kind.frei-marke { color: var(--c-warn); }
.play__trenner { color: var(--c-text-2); }
.play--plotter .play__title { font-size: 1rem; font-weight: 500; color: var(--c-text-1); }
.play__vollbild { flex: none; margin-left: var(--sp-2); }
/* A short text per view, under the view chips; only the chosen view's shows (data-nur). */
.plotter__lesart { margin: var(--sp-3) 0 0; font-size: var(--fs-small); line-height: 1.55; color: var(--c-text-1); }
.plotter__tippen { margin: var(--sp-2) 0 0; font-size: var(--fs-micro); line-height: 1.5; color: var(--c-text-2); }
.plotter__tippen code { font-size: inherit; white-space: nowrap; }
/* From 1181 px the plotter fills the first screen under the top bar: the stage
   takes what head and gaps leave, the panel scrolls inside the same height. */
@media (min-width: 1181px) {
  .play--plotter {
    display: flex;
    flex-direction: column;
    height: clamp(560px, 100svh - var(--topbar-h) - 2 * var(--sp-3), 1120px);
  }
  .play--plotter .play__body { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  /* .play__body raises the weight over the stage's min-height further down */
  .play--plotter .play__body > .play__stage { min-height: 0; }
  .play--plotter .play__panel { max-height: none; min-height: 0; }
}
/* Fullscreen: the plotter alone on the screen, Esc brings it back. */
.play--plotter:fullscreen {
  margin: 0;
  height: 100vh;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.play--plotter:fullscreen .play__body { flex: 1; min-height: 0; }
.play--plotter:fullscreen .play__body > .play__stage { min-height: min(62vh, 560px); }
@media (min-width: 1181px) {
  .play--plotter:fullscreen .play__body { grid-template-rows: minmax(0, 1fr); }
  .play--plotter:fullscreen .play__body > .play__stage { min-height: 0; }
  .play--plotter:fullscreen .play__panel { max-height: none; }
}
.play--plotter::backdrop { background: var(--c-bg-0); }
.play--plotter .play__stage { min-height: min(72vh, 680px); cursor: grab; outline-offset: -3px; }
.play--plotter .play__stage:active { cursor: grabbing; }
/* Panel groups and hints of the other view: `hidden` alone loses against .ctrl-group's display. */
.play--plotter [data-nur][hidden], .play--plotter [data-nur-kurve][hidden] { display: none; }
/* The two planes stacked on a phone (RQ.Split, stapeln): two fields of half the height each. */
.play--plotter .play__stage:is([data-ansicht='ebenen'], [data-ansicht='raten'])[data-split-gestapelt] { min-height: min(88vh, 760px); }
/* The game (Plan 46/E7): the verdict, the hints, a solved puzzle and a used-up button. */
.raten__urteil { margin: 0; font-size: var(--fs-small); color: var(--c-text-1); line-height: 1.45; }
.raten__urteil[data-solved] { color: var(--c-zero); }
.raten__hinweise { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-small); color: var(--c-text-1); line-height: 1.45; }
.raten__hinweise:empty { display: none; }
.play--plotter .chip.is-solved:not(.is-on) { border-color: var(--c-zero); color: var(--c-zero); }
.play--plotter .btn:disabled { opacity: 0.5; cursor: default; }
.formelfeld {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-bg-1);
  padding: 0 var(--sp-3);
  min-height: 44px;
}
.formelfeld:focus-within { border-color: var(--c-z); }
.formelfeld__vor { font-family: var(--f-mono); font-size: var(--fs-small); color: var(--c-text-2); white-space: nowrap; }
.formelfeld__eingabe {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--c-text-0);
  font-family: var(--f-mono);
  font-size: 1rem;
  padding: var(--sp-2) 0;
  outline: none;
}
.formelfeld__eingabe[aria-invalid='true'] { color: var(--c-warn); }
.formelfeld__fehler { margin: 0; font-size: var(--fs-small); color: var(--c-warn); line-height: 1.45; }
.formelfeld__kopiert { align-self: center; font-size: var(--fs-micro); color: var(--c-text-2); }
/* data-panel='wide' outweighs the narrow-window rule further down; the stage
   would keep 0 px beside the panel. */
@media (max-width: 1180px) {
  .play--plotter .play__body[data-panel='wide'] { grid-template-columns: 1fr; }
  .play--plotter .play__stage { min-height: min(62vh, 560px); }
}

/* Narrow windows: collapse the two-column layouts. Mobile is out of scope,
   this only keeps a 1280-wide window usable. */
@media (max-width: 1180px) {
  .story, .story[data-story-layout='right'] { grid-template-columns: 1fr; }
  .story__stage { height: min(62vh, 560px); order: 0 !important; }
  .story__steps { order: 1 !important; }
  .play__body { grid-template-columns: 1fr; }
  .play__panel { border-left: 0; border-top: 1px solid var(--c-line); max-height: none; }
}

/* =======================================================================
   TEXTLAUTSTAERKEN — bewusst als LETZTES im File
   Der Fliesstext steht auf --c-text-1, wie auf jeder Seite (Root-D137) —
   ausser auf den Kapitelseiten: dort liest man lange, und er steht hell auf
   --c-text-0 wie vor Plan 23 (Root-D141).
   Darunter benutzen die Kapitelseiten genau zwei Abstufungen, konsequent:
     .txt-soft   Vorspann einer Spielwiese oder einer Erzaehlung
     .txt-quiet  ein Nachsatz im Kasten — Einschraenkung, Randbemerkung

   Beide standen bis Plan 2/E18 als Inline-Style in den Seiten: 34-mal
   color:var(--c-text-1), 41-mal color:var(--c-text-2), monoton wachsend mit
   dem Alter des Kapitels. Kein Farbfehler, aber 75 Stellen, an denen eine
   Palettenaenderung haette nachgezogen werden muessen.

   WARUM `p.` DAVOR UND WARUM GANZ UNTEN: ein Inline-Style schlaegt alles,
   eine blosse Klasse nicht. `.box p` weiter oben steht auf
   Spezifitaet (0,1,1) und gewinnt gegen ein nacktes `.txt-quiet` (0,1,0) —
   erste Fassung dieser Umstellung hat deshalb 24 Absaetze still auf die
   Grundfarbe zurueckfallen lassen, sichtbar nur an der gerechneten Farbe.
   `p.txt-quiet` steht selbst auf (0,1,1) und gewinnt den Gleichstand ueber
   die Reihenfolge — also gehoert der Block ans Ende und nicht an den Anfang.
   ======================================================================= */
/* Kapitelseiten hell (Root-D141). `:where()` um den Seitenanker, damit die
   Spezifitaet die der Grundregel aus base.css bleibt, (0,0,1) gegen
   `main :where(…)` — jede Rollenklasse gewinnt weiter. Den Kasten regelt
   eine Zeile neben `.box p` weiter oben. */
:where(body[data-chapter]) main :where(p, dd, li:not([class])) { color: var(--c-text-0); }
/* Dort ist der Fließtext selbst Blatt: ein Link trägt deshalb die Linkfarbe,
   sonst unterschiede ihn nur der Strich (Root-D183). */
:where(body[data-chapter]) main a:where(:not([class])) { color: var(--c-link); }
:where(body[data-chapter]) main a:where(:not([class])):hover { color: var(--c-link-hover); }
/* Halbwegs zwischen Fliesstext und Nachsatz, seit der Fliesstext selbst
   auf --c-text-1 steht: 6,6 : 1 auf dem Kasten (Root-D137). Im Kapitel eine
   ganze Stufe unter dem hellen Fliesstext, wie vor Plan 23. */
p.txt-soft,  li.txt-soft  { color: color-mix(in srgb, var(--c-text-1), var(--c-text-2)); }
:where(body[data-chapter]) :is(p, li).txt-soft { color: var(--c-text-1); }
p.txt-quiet, li.txt-quiet { color: var(--c-text-2); }
