/* ─────────────────────────────────────────────────────────────────
   Computable Secrets — dark "screen" theme.
   Shares the type system of samuelschlesinger.com; the palette is
   that site's manim figure palette promoted to a full page theme,
   matching the look of the videos themselves.
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Type stacks. No webfonts — fast, private, reliable. */
  --font-serif: ui-serif, "Iowan Old Style", "Apple Garamond", Garamond, Georgia, "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  /* Type scale (modular, ratio ~1.333) */
  --step--2: 0.78rem;
  --step--1: 0.89rem;
  --step-0:  1.0625rem;   /* body — 17px */
  --step-1:  1.25rem;
  --step-2:  1.5rem;
  --step-3:  1.953rem;
  --step-4:  2.441rem;
  --step-5:  3.052rem;
  --step-6:  3.815rem;

  --leading-snug:  1.35;
  --leading-base:  1.65;

  /* Layout */
  --measure-prose: 68ch;
  --measure-full:  min(96vw, 1280px);

  /* Color — manim palette, dark canvas */
  --bg:           #0B0B0F;
  --bg-elevated:  #14141B;
  --fg:           #F4F3EE;
  --fg-muted:     #A6A49B;
  --fg-subtle:    #8A8881;  /* ≥4.5:1 on --bg for small mono meta text */
  --accent:       #58C4DD;
  --accent-hover: #8AD8EA;
  --danger:       #FC6255;  /* manim RED; ≥4.5:1 on --bg for button text */
  --border:       #1F1F26;
  --selection:    rgba(88, 196, 221, 0.25);

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 160ms;
  --dur-base: 280ms;

  color-scheme: dark;
}

/* ─────────────────────────────────────────────────────────────────
   Reset / baseline
   ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute must beat author display rules (flex panels etc.). */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
}

/* Smooth scrolling only for in-page jumps the visitor initiates (clicking a
   same-page link focuses it, so :focus-within matches). Anchor positioning on
   page load — the post-redirect #progress fragment after marking an article,
   or arriving at /#videos from another page — stays instant, instead of
   rendering at the top and visibly gliding down. */
html:focus-within { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  *, *::before, *::after {
    /* Zero delay too, so fill-mode:forwards animations (the hero tape)
       land on their final frame immediately instead of after the delay. */
    animation-duration: 0ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--step-0)/var(--leading-base) var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--selection); color: var(--fg); }

img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────────
   Layout containers
   ───────────────────────────────────────────────────────────────── */

.container {
  width: var(--measure-full);
  margin-inline: auto;
  padding-inline: max(1.25rem, env(safe-area-inset-left));
}

/* ─────────────────────────────────────────────────────────────────
   Header / Footer
   ───────────────────────────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.85rem;
}

.site-mark {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.site-mark:hover { color: var(--fg); text-decoration: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-nav a {
  color: var(--fg-muted);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.site-nav a:hover { color: var(--fg); text-decoration: none; }

@media (max-width: 720px) {
  .site-header__inner { flex-wrap: wrap; }
  .site-nav { gap: 1rem; }
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-block: 2.5rem;
  color: var(--fg-muted);
  font-size: var(--step--1);
}
.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: baseline;
}
.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--fg); }

/* ─────────────────────────────────────────────────────────────────
   Hero
   ───────────────────────────────────────────────────────────────── */

.hero {
  padding-block: clamp(4rem, 8vw, 7rem) clamp(2.5rem, 6vw, 5rem);
  background:
    radial-gradient(circle at 12% -10%, rgba(88, 196, 221, 0.12), transparent 26rem),
    radial-gradient(circle at 88% 0%, rgba(154, 119, 207, 0.10), transparent 22rem);
}

/* ── Hero animation: a real Turing machine decodes the tape ──
   The machine is simulated server-side (crates/web/src/tm.rs) and the
   trace arrives as SMIL, so the only CSS here is paint. SMIL ignores
   prefers-reduced-motion, so reduced-motion users get the statically
   rendered final frame (.tm-static) instead of the live run. */

.hero__tape {
  display: block;
  width: 100%;
  max-width: 64rem;
  height: auto;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}

.tm-static { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tm-live { display: none; }
  .tm-static { display: block; }
}

.tape-cell {
  fill: none;
  stroke: #1F1F26;
  stroke-width: 1;
}

.tm-cipher {
  font: 13px var(--font-mono);
  fill: var(--fg-muted);
}

.tm-sep {
  font: 13px var(--font-mono);
  fill: var(--fg-subtle);
}

.tm-plain {
  font: 600 14px var(--font-mono);
  fill: #FFEC5C;
}

.tm-carry {
  font: 600 12px var(--font-mono);
  fill: #FFEC5C;
}

.tm-phase {
  font: 13px var(--font-mono);
  letter-spacing: 0.08em;
  fill: var(--fg-subtle);
}

.tm-phase--halt { fill: #83C167; }

/* Too small to read once the SVG scales down. */
@media (max-width: 720px) {
  .tm-phase { display: none; }
}

.hero__stats {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  color: var(--fg-subtle);
  margin: 0 0 2rem;
}

.hero__title {
  font-family: var(--font-serif);
  font-size: clamp(var(--step-4), 6.5vw, var(--step-6));
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 1rem;
}

.hero__tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(var(--step-1), 2.2vw, var(--step-2));
  line-height: 1.35;
  color: var(--fg-muted);
  margin: 0 0 2.25rem;
  max-width: 40ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.button:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}
/* Destructive actions (delete account) read apart from the accent buttons. */
.button--danger { border-color: var(--danger); color: var(--danger); }
.button--danger:hover { background: var(--danger); color: var(--bg); }

/* ─────────────────────────────────────────────────────────────────
   Sections / video grid
   ───────────────────────────────────────────────────────────────── */

.section {
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
  border-top: 1px solid var(--border);
}
.section__title {
  font-family: var(--font-serif);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin: 0 0 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Manim-colored tick before each section title */
.section__title::before {
  content: "";
  width: 1.6rem;
  height: 2px;
  background: var(--fg-subtle);
}
.section--videos .section__title::before { background: #58C4DD; }
.section--lab    .section__title::before { background: #9A72AC; }
.section--about  .section__title::before { background: #83C167; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 2rem 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Feature the newest video: double-width card with a larger title. */
@media (min-width: 760px) {
  .video-grid .video-card:first-child { grid-column: span 2; }
  .video-grid .video-card:first-child h3 { font-size: var(--step-2); }
}

.video-card a {
  display: block;
  color: var(--fg);
}
.video-card a:hover { text-decoration: none; }

.video-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.video-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-base) var(--ease-out);
}
.video-card a:hover .video-card__thumb img { transform: scale(1.03); }

.video-card__duration {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(11, 11, 15, 0.85);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--step--2);
}

.video-card h3 {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  line-height: var(--leading-snug);
  font-weight: 500;
  margin: 0.8rem 0 0.25rem;
}
.video-card a:hover h3 { color: var(--accent); }

.video-card__meta {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.video-card__progress { color: var(--accent); }

.section__more {
  margin: -1.25rem 0 2rem;
  font-size: var(--step--1);
}
.section__more a { color: var(--fg-muted); }
.section__more a:hover { color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────
   Library (sort/filter controls are links, one URL per combination)
   ───────────────────────────────────────────────────────────────── */

/* The library grid is a query result: no featured first card. */
.video-grid--library .video-card:first-child { grid-column: auto; }
.video-grid--library .video-card:first-child h3 { font-size: var(--step-1); }

.library__count {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--fg-muted);
  margin: -1.25rem 0 1.5rem;
}
.library__controls { margin: 0 0 2.25rem; }
.library__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.6rem;
  margin: 0 0 0.7rem;
}
.library__label {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  min-width: 3.2rem;
}
.library__control {
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.8rem;
  font-size: var(--step--1);
}
.library__control:hover {
  color: var(--fg);
  border-color: var(--fg-subtle);
  text-decoration: none;
}
.library__control--active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.library__control--active:hover {
  color: var(--bg);
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.library__hint { color: var(--fg-muted); font-size: var(--step--1); }
.library__empty { color: var(--fg-muted); font-style: italic; }

/* Two-tone completion meter (SVG rects; understood over read over track). */
.meter {
  display: block;
  width: 100%;
  max-width: 28rem;
  height: 6px;
  margin: 0 0 1.5rem;
}
.meter__track { fill: var(--border); }
.meter__read { fill: rgba(88, 196, 221, 0.35); }
.meter__understood { fill: var(--accent); }

/* ─────────────────────────────────────────────────────────────────
   The lab (workbenches; evaluators run in-browser via wasm)
   ───────────────────────────────────────────────────────────────── */

.lab { padding-block: clamp(2.5rem, 5vw, 4rem); }
.lab__inner { max-width: var(--measure-prose); }
.lab__title {
  font-family: var(--font-serif);
  font-size: var(--step-4);
  line-height: var(--leading-snug);
  margin: 0 0 0.75rem;
}
.lab__lede { color: var(--fg-muted); margin: 0 0 2rem; }

.lab__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.25rem; }
.lab__list li {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.lab__list a { font-family: var(--font-serif); font-size: var(--step-1); }
.lab__list p { margin: 0.35rem 0 0; color: var(--fg-muted); }
.lab__soon { opacity: 0.65; }
.lab__soon span { font-family: var(--font-serif); font-size: var(--step-1); }

/* Early-20th-century materials, all CSS: typewritten paper, brass plates,
   steel, bakelite. No image assets (the CSP admits none anyway). */
.lab {
  --paper: #f0e6cf;
  --paper-dim: #e4d7ba;
  --ink: #2b2418;
  --ink-red: #a03123;
  --brass-hi: #d6b877;
  --brass-lo: #8a6b3a;
  --steel-hi: #c3c7cf;
  --steel-lo: #585b63;
  --wood-hi: #4a3423;
  --wood-lo: #2c1d12;
  --bakelite: #221c17;
  --font-type: "American Typewriter", "Courier Prime", "Courier New", Courier, monospace;
}

.lab__label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin: 1.25rem 0 0.4rem;
}

/* The program sheet: a typed page, red margin rule and all. */
.lab__editor textarea,
.lab__editor input {
  width: 100%;
  padding: 0.85rem 0.85rem 0.85rem 2.4rem;
  background:
    linear-gradient(90deg, transparent 1.7rem, var(--ink-red) 1.7rem, var(--ink-red) calc(1.7rem + 1px), transparent calc(1.7rem + 1px)),
    linear-gradient(180deg, var(--paper), var(--paper-dim));
  border: 1px solid #b3a583;
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55), inset 0 0 30px rgba(120, 96, 55, 0.12);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: var(--step--1);
  line-height: 1.6;
  resize: vertical;
}
.lab__editor textarea:focus-visible,
.lab__editor input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lab__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.lab__note { color: var(--fg-subtle); font-size: var(--step--1); }
/* Save controls: a name field and the one true submit button. */
.lab__save {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}
.lab__save input {
  flex: 1 1 12rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
  font-size: var(--step--1);
}
.lab__save input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lab__card-row { display: flex; gap: 0.5rem; align-items: center; }

/* Errors come back as a typed rejection slip. */
.lab__error {
  color: var(--ink-red);
  background: linear-gradient(180deg, var(--paper), var(--paper-dim));
  border: 1px solid #b3a583;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  padding: 0.75rem 1rem;
  font-family: var(--font-type);
  font-size: var(--step--1);
  white-space: pre-wrap;
  margin: 1rem 0 0;
}

/* ---- the apparatus ---------------------------------------------------- */

.apparatus {
  margin-top: 2.25rem;
  padding: 1.25rem 1.25rem 1.5rem;
  border-radius: 10px;
  background:
    repeating-linear-gradient(94deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(88deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 11px),
    linear-gradient(180deg, var(--wood-hi), var(--wood-lo));
  border: 1px solid #1b120a;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -6px 14px rgba(0, 0, 0, 0.45),
    0 6px 24px rgba(0, 0, 0, 0.5);
}

.apparatus__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.apparatus__plate,
.apparatus__counter {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
}
/* Engraved brass */
.apparatus__plate {
  background: linear-gradient(165deg, var(--brass-hi), var(--brass-lo));
  border: 1px solid #5f4a26;
  box-shadow: inset 0 1px 0 rgba(255, 250, 230, 0.55), 0 2px 5px rgba(0, 0, 0, 0.55);
}
.apparatus__plate-label {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4a3417;
  text-shadow: 0 1px 0 rgba(255, 248, 225, 0.5);
}
.apparatus__plate-value {
  font-family: var(--font-type);
  font-size: var(--step-0);
  color: #33240f;
  text-shadow: 0 1px 0 rgba(255, 248, 225, 0.45);
}
/* Mechanical counter: white digits on black wheels */
.apparatus__counter {
  background: linear-gradient(180deg, #15130f, #23201a);
  border: 1px solid #000;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.07);
}
.apparatus__counter .apparatus__plate-label { color: #8d8570; text-shadow: none; }
.apparatus__digits {
  font-family: var(--font-type);
  font-size: var(--step-0);
  color: #efe6d0;
  letter-spacing: 0.12em;
}
.apparatus__verdict { display: flex; align-items: center; gap: 0.55rem; margin-left: auto; }
/* Dome indicator lamp: dark until the machine halts. */
.apparatus__lamp {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4d4238, #241d16 70%);
  border: 2px solid #6e6353;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.apparatus__lamp--good {
  background: radial-gradient(circle at 35% 30%, #d8ffd0, #48a34c 60%, #235c2a);
  box-shadow: 0 0 10px rgba(120, 220, 130, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.5);
}
.apparatus__lamp--bad {
  background: radial-gradient(circle at 35% 30%, #ffd4c9, #b23a2b 60%, #5f1c14);
  box-shadow: 0 0 10px rgba(230, 110, 90, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.5);
}
.apparatus__lamp--warn {
  background: radial-gradient(circle at 35% 30%, #ffedbf, #bd8f2e 60%, #6b4d13);
  box-shadow: 0 0 10px rgba(235, 190, 90, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.5);
}
.apparatus__outcome {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cdbf9f;
}

/* Tape transports: one row per tape, each a fixed steel gate over a paper
   strip sliding beneath it. */
.apparatus__rack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border-radius: 6px;
  padding: 0.65rem 0.4rem;
  background: linear-gradient(180deg, #17130e, #0d0a07);
  border: 1px solid #000;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.85);
}
.apparatus__viewport {
  position: relative;
  overflow: hidden;
  height: 4.4rem;
  /* Shade the strip away from the gate, like lamplight falling off. */
  mask-image: linear-gradient(90deg, transparent, black 12%, black 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 12%, black 88%, transparent);
}
.apparatus__strip {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  gap: 2px;
  transition: transform 130ms cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .apparatus__strip { transition: none; }
}
/* Punched paper cells: sprocket holes above and below each glyph. */
.apparatus__cell {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 3.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f3e9d2, #e6d9bc);
  border-left: 1px solid rgba(120, 96, 55, 0.25);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: var(--step-1);
}
.apparatus__cell::before,
.apparatus__cell::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #0a0805, #1c150c);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.9);
}
.apparatus__cell::before { top: 5px; }
.apparatus__cell::after { bottom: 5px; }

/* The read/write gate: a riveted steel frame fixed over the center cell. */
.apparatus__gate {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  pointer-events: none;
  border: 3px solid transparent;
  border-image: linear-gradient(180deg, var(--steel-hi), var(--steel-lo)) 1;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.7),
    0 0 14px rgba(88, 196, 221, 0.18);
}
.apparatus__gate::before,
.apparatus__gate::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 8px;
  background: linear-gradient(180deg, var(--steel-hi), var(--steel-lo));
  border: 1px solid #23252a;
}
.apparatus__gate::before { top: -9px; border-radius: 3px 3px 0 0; }
.apparatus__gate::after { bottom: -9px; border-radius: 0 0 3px 3px; }
.apparatus__gate-screw {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8eaee, #6a6d75 65%, #3c3e44);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.8);
}
.apparatus__gate-screw--l { left: -14px; transform: translateY(-50%); }
.apparatus__gate-screw--r { right: -14px; transform: translateY(-50%); }

/* The reduction feed: typed lines on continuous paper (lambda workbench). */
.apparatus__feedwrap {
  max-height: 22rem;
  overflow-y: auto;
  border-radius: 4px;
  background:
    repeating-linear-gradient(180deg, transparent 0 1.9rem, rgba(120, 96, 55, 0.16) 1.9rem calc(1.9rem + 1px)),
    linear-gradient(180deg, #f3e9d2, #e6d9bc);
  border: 1px solid #b3a583;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.25);
}
.apparatus__feed {
  list-style: none;
  margin: 0;
  /* Left padding clears the tractor-feed sprocket strip drawn below. */
  padding: 0.4rem 0.9rem 0.4rem 1.9rem;
  position: relative;
}
/* Continuous-feed printer paper: a perforated sprocket strip down the left,
   tying the reduction printout to the punched tape of the other benches. */
.apparatus__feed::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1.4rem;
  border-right: 1px dashed rgba(120, 96, 55, 0.35);
  background-image: radial-gradient(circle, rgba(10, 8, 5, 0.85) 2.5px, transparent 3px);
  background-size: 100% 1.9rem;
  background-position: center 0.55rem;
}
.apparatus__feed-line {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  min-height: 1.9rem;
  font-family: var(--font-type);
  font-size: var(--step--1);
  color: rgba(43, 36, 24, 0.62);
  overflow-wrap: anywhere;
}
.apparatus__feed-line--now { color: var(--ink); font-size: var(--step-0); }
.apparatus__feed-no {
  flex: 0 0 2.4rem;
  text-align: right;
  color: var(--ink-red);
  font-size: var(--step--2);
}
.apparatus__feed-gap {
  font-family: var(--font-type);
  font-size: var(--step--2);
  color: rgba(43, 36, 24, 0.5);
  padding-left: 3.2rem;
}
.apparatus__redex {
  background: transparent;
  color: var(--ink-red);
  border-bottom: 2px solid var(--ink-red);
  font-weight: 600;
}

/* The drafting table: white line work on cyanotype paper (automata). */
.apparatus__blueprint {
  border-radius: 4px;
  margin-bottom: 0.8rem;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 24px),
    radial-gradient(circle at 30% 20%, #23517d, #16324f 70%);
  border: 1px solid #0c1e30;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.bp { display: block; width: 100%; height: auto; }
.bp__wire {
  fill: none;
  stroke: rgba(240, 248, 255, 0.85);
  stroke-width: 1.4;
}
.bp__wire--start { stroke-dasharray: 4 3; }
.bp__arrowhead { fill: rgba(240, 248, 255, 0.85); }
.bp__ring {
  fill: rgba(22, 50, 79, 0.4);
  stroke: rgba(240, 248, 255, 0.9);
  stroke-width: 1.6;
  transition: fill var(--dur-base) var(--ease-out), filter var(--dur-base) var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .bp__ring { transition: none; }
}
.bp__ring--accept { fill: none; }
.bp__name {
  fill: #eaf2fb;
  font-family: var(--font-mono);
  font-size: 13px;
}
.bp__label {
  fill: #bcd3e8;
  font-family: var(--font-type);
  font-size: 13px;
  font-style: italic;
}
.bp__state--active .bp__ring {
  fill: #f0f8ff;
  stroke: #fff;
  filter: drop-shadow(0 0 6px rgba(240, 248, 255, 0.9));
}
.bp__state--active .bp__name { fill: #16324f; font-weight: 700; }
.apparatus__bp-note {
  display: block;
  padding: 1rem;
  color: #bcd3e8;
  font-family: var(--font-mono);
  font-size: var(--step--1);
}
/* The consumed-input strip: spent symbols fade, the next one waits. */
.apparatus__consume {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0.15rem;
}
.apparatus__cell--spent { opacity: 0.35; }
.apparatus__cell--next {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Bakelite transport keys with engraved cream glyphs. */
.apparatus__controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.lab__ctl {
  background: linear-gradient(180deg, #322a23, var(--bakelite) 55%, #15100c);
  border: 1px solid #000;
  border-radius: 6px;
  color: #e4d7ba;
  font: inherit;
  font-family: var(--font-mono);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 4px rgba(0, 0, 0, 0.6);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
.lab__ctl:hover { color: #fff; }
.lab__ctl:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
}
.lab__ctl--play { color: var(--accent); min-width: 5.5rem; }
.lab__ctl--speed { min-width: 3.4rem; color: #cdbf9f; }

/* Keyboard-transport hint under the controls. */
.apparatus__hint {
  margin: 0.8rem 0 0;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: rgba(228, 215, 186, 0.6);
}
.apparatus__hint kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: linear-gradient(180deg, #322a23, var(--bakelite));
  border: 1px solid #000;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: #e4d7ba;
}
.lab__ctl:focus-visible,
.lab__load:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The library shelf: tested machines rendered from the Rust examples. */
.lab__subtitle {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  margin: 2.5rem 0 0.4rem;
}
.lab__library .lab__note { display: block; margin-bottom: 1rem; }
.lab__shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
.lab__card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.lab__card a { font-family: var(--font-serif); font-size: var(--step-0); }
.lab__card p { margin: 0; color: var(--fg-muted); font-size: var(--step--1); flex: 1; }
.lab__card .lab__load { align-self: flex-start; }

.lab__format { margin-top: 2.5rem; color: var(--fg-muted); }
.lab__format summary { cursor: pointer; color: var(--fg); }
.lab__format pre {
  background: linear-gradient(180deg, var(--paper), var(--paper-dim));
  color: var(--ink);
  border: 1px solid #b3a583;
  border-radius: 2px;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-type);
  font-size: var(--step--1);
}

/* ─────────────────────────────────────────────────────────────────
   Companion articles
   ───────────────────────────────────────────────────────────────── */

.article__inner {
  max-width: var(--measure-prose);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.article__kicker {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin: 0 0 1.25rem;
}
.article__kicker a { color: var(--fg-subtle); }
.article__kicker a:hover { color: var(--fg); }

.article__title {
  font-family: var(--font-serif);
  font-size: clamp(var(--step-3), 5vw, var(--step-5));
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.article__meta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--fg-subtle);
  margin: 0 0 2rem;
}

.article__watch {
  position: relative;
  display: block;
  margin: 0 0 2.5rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.article__watch img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
.article__watch-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: rgba(11, 11, 15, 0.82);
  color: var(--accent);
  font: 600 var(--step--1) var(--font-sans);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.article__watch:hover .article__watch-label {
  background: var(--accent);
  color: var(--bg);
}

.article__body {
  font-size: var(--step-0);
  line-height: var(--leading-base);
  color: var(--fg-muted);
}
.article__body h2 {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: var(--leading-snug);
  color: var(--fg);
  margin: 2.25rem 0 0.8rem;
  scroll-margin-top: 1.5rem;
}
.article__body h3 {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--fg);
  margin: 1.75rem 0 0.6rem;
  scroll-margin-top: 1.5rem;
}
/* Section permalink: hidden until the heading is hovered or focused. */
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--fg-subtle);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.article__body h2:hover .heading-anchor,
.article__body h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }
.article__body p { margin: 0 0 1.1em; }
.article__body strong { color: var(--fg); }
.article__body li { margin: 0 0 0.4em; }
.article__body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.08em 0.35em;
  color: var(--fg);
}
.article__body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.2em;
}
.article__body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg);
}
.article__body blockquote {
  margin: 0 0 1.1em;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  color: var(--fg-muted);
  font-style: italic;
}
.article__body math { color: var(--fg); }
/* Never override `display` on <math>: the UA's `block math` value is what
   keeps MathML rows laid out as rows. */
.article__body math[display="block"] {
  margin: 1.2em 0;
  font-size: 1.1em;
}

/* CSS-only interactivity: pause-and-try blocks */
.article__body details {
  margin: 0 0 1.2em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  padding: 0.7rem 1rem;
}
.article__body details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.02em;
}
.article__body details[open] summary { margin-bottom: 0.6rem; }
.article__body details summary:hover { color: var(--accent-hover); }

.article__footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--fg-subtle);
}

/* About */
.about { max-width: var(--measure-prose); }
.about p { margin: 0 0 1.1em; color: var(--fg-muted); }
.about strong { color: var(--fg); font-weight: 600; }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--fg);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ─────────────────────────────────────────────────────────────────
   Membership: sign-in and account pages
   ───────────────────────────────────────────────────────────────── */

.member__inner {
  max-width: var(--measure-prose);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.member__title {
  font-family: var(--font-serif);
  font-size: clamp(var(--step-3), 5vw, var(--step-4));
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.member__lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--step-1);
  line-height: var(--leading-snug);
  color: var(--fg-muted);
  margin: 0 0 1.5rem;
  max-width: 44ch;
}

.member__line { color: var(--fg-muted); margin: 0 0 1.1em; }
.member__line strong { color: var(--fg); font-weight: 600; }

.member__status {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--fg-subtle);
}

.member__welcome {
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  color: var(--fg);
  margin: 0 0 1.5rem;
}

.member__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 2rem;
}
.member__actions form { margin: 0; }

.member__delete-list {
  margin: 0 0 1.5rem;
  padding-left: 1.2rem;
  color: var(--fg-muted);
  line-height: 1.6;
}
.member__delete-list li { margin: 0.3rem 0; }

.field { margin: 0 0 1.25rem; }
.field label {
  display: block;
  font-size: var(--step--1);
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
}
.field input {
  width: 100%;
  max-width: 28rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
}
.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* <button class="button"> shares the anchor button look. */
button.button {
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

/* ─────────────────────────────────────────────────────────────────
   Member player
   ───────────────────────────────────────────────────────────────── */

.watch__inner {
  max-width: 62rem;
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.watch__title {
  font-family: var(--font-serif);
  font-size: clamp(var(--step-2), 4vw, var(--step-4));
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 1.25rem;
}

.watch__player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.watch__note {
  margin: 1rem 0 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--fg-subtle);
}

.article__member-link {
  margin: -1.5rem 0 2.5rem;
  font-size: var(--step--1);
}

/* ─────────────────────────────────────────────────────────────────
   Comments (account-gated discussion on video pages)
   ───────────────────────────────────────────────────────────────── */
.field textarea {
  width: 100%;
  max-width: 44rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
  line-height: var(--leading-base);
  resize: vertical;
}
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Self-assessed reading progress strip under an article. */
.progress {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  max-width: var(--measure-prose);
}
.progress__state { color: var(--fg-muted); margin: 0 0 1rem; }
.progress__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.progress__signin { color: var(--fg-muted); margin: 0; }
.progress__next { color: var(--fg-muted); margin: 1.25rem 0 0; }

.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  max-width: var(--measure-prose);
}
.comments__title {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  color: var(--fg);
  margin: 0 0 1.5rem;
}
.comments__empty { color: var(--fg-muted); font-style: italic; margin: 0 0 1.5rem; }
.comments__list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.comment {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
}
.comment--hidden { opacity: 0.55; }
.comment__head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.4rem; }
.comment__author { color: var(--fg); font-weight: 600; }
.comment__date {
  font-size: var(--step--1);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}
.comment__flag {
  font-size: var(--step--1);
  color: var(--fg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.4rem;
}
.comment__body {
  margin: 0;
  color: var(--fg-muted);
  line-height: var(--leading-base);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment__mod { margin-top: 0.5rem; }
.comment__mod-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--fg-subtle);
  font-size: var(--step--1);
  padding: 0.15rem 0.6rem;
  cursor: pointer;
}
.comment__mod-btn:hover { color: var(--fg); border-color: var(--fg-subtle); }
.comments__as { color: var(--fg-muted); font-size: var(--step--1); margin: 0 0 0.75rem; }
.comments__as strong { color: var(--fg); }
.comments__signin {
  color: var(--fg-muted);
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.comments__form { margin-top: 0.5rem; }

.member__notify,
.member__progress {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.member__subtitle {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  color: var(--fg);
  margin: 0 0 0.6rem;
}
.member__admin { margin-top: 1.25rem; }
.member__sent { color: var(--fg-subtle); font-style: italic; }
