/*
 * Scellis marketing site — stylesheet (the ENTIRE site CSS).
 *
 * Visual language: "the living spec sheet" — the site reads like the engineering
 * datasheet for a compute substrate. The vocabulary is adopted wholesale from
 * the studio app (apps/web): the GitHub-derived palette, Space Grotesk / Sora /
 * mono typefaces, gradient + gloss surfaces, accent glows, shadow tiers, and the
 * cubic-bezier easings — so the marketing surface and the product feel like one
 * instrument. The home page's hero "Fig. 1" is a live WebGL2 compute field
 * (gpu_field.ts); everything else is the calm, precise document.
 *
 * Single-sourcing & drift resistance:
 *  - Every brand COLOR is mirrored from apps/web/src/ui/styles/tokens.css and is
 *    cross-checked at build time by brand_consistency.ts (THROWS on drift).
 *  - The --sans / --display / --mono font stacks mirror apps/web EXACTLY and are
 *    likewise drift-checked. The WebGL field reads its colors from these tokens.
 *  - All non-brand depth (dims, glows, tints) derives from those tokens via
 *    color-mix(), so it tracks the brand and the active theme automatically.
 *
 * Conventions: BEM-like class names; colors via var(--token); a fluid type/space
 * scale (clamp()) so the layout is optimal at every width.
 */

/* ======================================================================
 * Fonts — self-hosted, offline, OFL (see fonts/OFL.txt). Variable WOFF2,
 * Latin subset. These realize the typefaces apps/web's tokens declare.
 * ====================================================================== */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-variable.woff2") format("woff2");
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/sora-variable.woff2") format("woff2");
}

:root {
  /* --- Brand palette (dark — default; mirrors apps/web tokens.css) --- */
  --bg: #0d1117;
  --surface: #161b22;
  --inset: #010409;
  --border: #30363d;
  --border-subtle: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --dim: #7d8590;
  --accent: #2f81f7;
  --accent-emphasis: #1f6feb;
  --on-accent: #ffffff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --viz-purple: #a371f7;
  --viz-pink: #db61a2;
  --viz-cyan: #39c5cf;

  /* --- Light palette — declared ONCE, referenced by the two light triggers
     below. Mirrors apps/web github-light tokens; cross-checked by
     brand_consistency.ts. --- */
  --light-bg: #ffffff;
  --light-surface: #f0f2f5;
  --light-inset: #eaeef2;
  --light-border: #c0c8d0;
  --light-border-subtle: #ccd4dc;
  --light-text: #1f2328;
  --light-muted: #57606a;
  --light-dim: #6e7781;
  --light-accent: #0969da;
  --light-accent-emphasis: #0550ae;
  --light-on-accent: #ffffff;
  --light-success: #1a7f37;
  --light-warning: #9a6700;
  --light-danger: #d1242f;
  --light-viz-purple: #8250df;
  --light-viz-pink: #bf3989;
  --light-viz-cyan: #1b7c83;

  /* --- Derived surfaces / accents (theme-aware via color-mix) --- */
  --accent-dim: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 36%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-wash: color-mix(in srgb, var(--accent) 9%, transparent);
  --surface-translucent: color-mix(in srgb, var(--surface) 70%, transparent);
  --hairline: color-mix(in srgb, var(--text) 8%, transparent);
  --card-gradient: linear-gradient(180deg, color-mix(in srgb, var(--surface) 90%, var(--text)), var(--surface));
  --gloss: linear-gradient(180deg, color-mix(in srgb, var(--text) 4%, transparent), transparent 42%);

  /* --- Shadows (tiers from apps/web; softened for light below) --- */
  --shadow-sm: 0 10px 24px rgba(1, 4, 9, 0.22), 0 2px 8px rgba(1, 4, 9, 0.24);
  --shadow: 0 18px 40px rgba(1, 4, 9, 0.32), 0 6px 18px rgba(1, 4, 9, 0.24);
  --shadow-lg: 0 32px 72px rgba(1, 4, 9, 0.44), 0 12px 32px rgba(1, 4, 9, 0.28);

  /* --- Spacing scale --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 80px;
  --space-10: 112px;
  /* Section rhythm — tightened from the airy 112px max so the page reads as a
     dense, composed precision instrument, not a sparse SaaS landing. A separate
     "tight" step packs related bands closer (e.g. hero → first parameter table). */
  --section-y: clamp(44px, 2.2rem + 3vw, 84px);
  --section-y-tight: clamp(30px, 1.4rem + 2vw, 54px);

  /* --- Radii --- */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 999px;

  /* --- Typography (mirror apps/web tokens.css font stacks EXACTLY) --- */
  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --display: "Sora", "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1.2vw, 2.125rem);
  --text-3xl: clamp(1.9rem, 1.4rem + 2.4vw, 2.875rem);
  --text-display: clamp(2.5rem, 1.5rem + 4.6vw, 4.5rem);
  --line: 1.6;
  --line-tight: 1.08;

  /* --- Layout --- */
  --container: 1120px;
  --container-wide: 1280px;
  --container-prose: 720px;

  /* --- Motion --- */
  --motion: 160ms;
  --motion-slow: 240ms;
  --motion-deliberate: 520ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Instrument chrome (single-sourced; the "precision instrument" look is a
     SYSTEM, so it can never drift between sections). Every value derives from a
     brand token via color-mix, so the whole instrument layer tracks the active
     theme automatically and stays drift-checked through those base tokens. --- */
  --grid-minor: color-mix(in srgb, var(--text) 3.4%, transparent);
  --grid-major: color-mix(in srgb, var(--text) 6%, transparent);
  --grid-step: 30px;           /* fine engineering-grid pitch */
  --grid-major-step: 150px;    /* 5× minor — the heavy rule */
  --tick: color-mix(in srgb, var(--muted) 46%, transparent);
  --reg-color: color-mix(in srgb, var(--accent) 64%, transparent);
  --reg-inset: clamp(12px, 2vw, 26px);
  --reg-arm: 13px;             /* crop/registration-mark arm length */
  --panel-glint: color-mix(in srgb, var(--text) 9%, transparent);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--light-bg);
    --surface: var(--light-surface);
    --inset: var(--light-inset);
    --border: var(--light-border);
    --border-subtle: var(--light-border-subtle);
    --text: var(--light-text);
    --muted: var(--light-muted);
    --dim: var(--light-dim);
    --accent: var(--light-accent);
    --accent-emphasis: var(--light-accent-emphasis);
    --on-accent: var(--light-on-accent);
    --success: var(--light-success);
    --warning: var(--light-warning);
    --danger: var(--light-danger);
    --viz-purple: var(--light-viz-purple);
    --viz-pink: var(--light-viz-pink);
    --viz-cyan: var(--light-viz-cyan);
    --shadow-sm: 0 10px 24px rgba(31, 35, 40, 0.1), 0 2px 8px rgba(31, 35, 40, 0.08);
    --shadow: 0 18px 36px rgba(31, 35, 40, 0.12), 0 6px 16px rgba(31, 35, 40, 0.1);
    --shadow-lg: 0 30px 60px rgba(31, 35, 40, 0.16), 0 12px 24px rgba(31, 35, 40, 0.1);
  }
}

:root[data-theme="light"] {
  --bg: var(--light-bg);
  --surface: var(--light-surface);
  --inset: var(--light-inset);
  --border: var(--light-border);
  --border-subtle: var(--light-border-subtle);
  --text: var(--light-text);
  --muted: var(--light-muted);
  --dim: var(--light-dim);
  --accent: var(--light-accent);
  --accent-emphasis: var(--light-accent-emphasis);
  --on-accent: var(--light-on-accent);
  --success: var(--light-success);
  --warning: var(--light-warning);
  --danger: var(--light-danger);
  --viz-purple: var(--light-viz-purple);
  --viz-pink: var(--light-viz-pink);
  --viz-cyan: var(--light-viz-cyan);
  --shadow-sm: 0 10px 24px rgba(31, 35, 40, 0.1), 0 2px 8px rgba(31, 35, 40, 0.08);
  --shadow: 0 18px 36px rgba(31, 35, 40, 0.12), 0 6px 16px rgba(31, 35, 40, 0.1);
  --shadow-lg: 0 30px 60px rgba(31, 35, 40, 0.16), 0 12px 24px rgba(31, 35, 40, 0.1);
}

/* ======================================================================
 * Base / reset
 * ====================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* The instrument substrate: a fixed, faint engineering grid (graph-paper /
   oscilloscope reticle) behind everything, giving the flat #0d1117 canvas real
   depth and parallax as content scrolls over it. Composited fixed layer (no
   per-scroll bg repaint); masked so it reads as ambient, never busy. The grid
   lines are token-derived, so the substrate tracks the theme + stays in palette. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px);
  background-size:
    var(--grid-step) var(--grid-step),
    var(--grid-step) var(--grid-step),
    var(--grid-major-step) var(--grid-major-step),
    var(--grid-major-step) var(--grid-major-step);
  background-position: center -1px;
  -webkit-mask-image: radial-gradient(135% 100% at 50% -8%, #000 0%, #000 46%, color-mix(in srgb, #000 22%, transparent) 82%, transparent 100%);
  mask-image: radial-gradient(135% 100% at 50% -8%, #000 0%, #000 46%, color-mix(in srgb, #000 22%, transparent) 82%, transparent 100%);
}

h1,
h2,
h3,
h4 {
  font-family: var(--display);
  line-height: var(--line-tight);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

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

/* ======================================================================
 * Layout primitives
 * ====================================================================== */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.container--wide {
  max-width: var(--container-wide);
}

.site-main {
  flex: 1 0 auto;
}

.muted {
  color: var(--muted);
}

/* Visually hidden, still in the a11y tree (skip-link target / headings). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lead {
  font-size: var(--text-lg);
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.55;
}

/* Accent eyebrow (content pages) + mono "spec" variant. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 var(--space-3);
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.eyebrow--mono {
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  color: var(--dim);
}

.eyebrow--mono::before {
  background: var(--accent);
  opacity: 1;
}

/* Datasheet-style emphasis: an accent phrase underscored by a cyan→blue rule —
   reads as a highlighted spec parameter, not a startup gradient-word. */
.hl {
  color: var(--accent);
  position: relative;
  white-space: nowrap;
}

.hl::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.02em;
  height: 0.09em;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--viz-cyan));
}

/* ======================================================================
 * Instrument chrome utilities — the reusable "engineering drawing" details
 * (registration/crop marks, corner brackets) that turn a plain panel into a
 * datasheet figure. Pure CSS, token-colored, decorative (aria-hidden / pointer
 * inert), so they never affect layout or the a11y tree.
 * ====================================================================== */

/* Four CAD corner crop-marks, inset from the parent's edges. Drop one
   absolutely-positioned <span class="crop-frame"> into any positioned box. */
.crop-frame {
  position: absolute;
  inset: var(--reg-inset);
  z-index: 1;
  pointer-events: none;
}

.crop-frame::before,
.crop-frame::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* horizontal arms at all four corners */
.crop-frame::before {
  background:
    linear-gradient(var(--reg-color), var(--reg-color)) left top / var(--reg-arm) 1px no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) right top / var(--reg-arm) 1px no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) left bottom / var(--reg-arm) 1px no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) right bottom / var(--reg-arm) 1px no-repeat;
}

/* vertical arms at all four corners */
.crop-frame::after {
  background:
    linear-gradient(var(--reg-color), var(--reg-color)) left top / 1px var(--reg-arm) no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) right top / 1px var(--reg-arm) no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) left bottom / 1px var(--reg-arm) no-repeat,
    linear-gradient(var(--reg-color), var(--reg-color)) right bottom / 1px var(--reg-arm) no-repeat;
}

/* Bright accent corner-brackets (top-left + bottom-right) on a showpiece panel —
   the per-element craft detail that separates "instrument" from "templated card". */
.framed::before,
.framed::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 2;
}

.framed::before {
  top: -1px;
  left: -1px;
  border-top: 1.5px solid var(--reg-color);
  border-left: 1.5px solid var(--reg-color);
  border-top-left-radius: 3px;
}

.framed::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 1.5px solid var(--reg-color);
  border-right: 1.5px solid var(--reg-color);
  border-bottom-right-radius: 3px;
}

/* ======================================================================
 * Skip link
 * ====================================================================== */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -4rem;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: top var(--motion) var(--ease);
  z-index: 200;
}

.skip-link:focus {
  top: var(--space-3);
}

/* ======================================================================
 * Buttons
 * ====================================================================== */
.btn {
  --btn-pad-y: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--btn-pad-y) var(--space-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--sans);
  font-weight: 600;
  font-size: var(--text-base);
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--motion) var(--ease), border-color var(--motion) var(--ease),
    box-shadow var(--motion) var(--ease), transform var(--motion) var(--ease), color var(--motion) var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn__icon {
  display: inline-flex;
  width: 1.05em;
  height: 1.05em;
  transition: transform var(--motion) var(--ease);
}

.btn--primary {
  background-color: var(--accent-emphasis);
  color: var(--on-accent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--on-accent) 22%, transparent) inset,
    0 8px 24px color-mix(in srgb, var(--accent) 38%, transparent);
}

.btn--primary:hover {
  background-color: var(--accent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--on-accent) 28%, transparent) inset,
    0 12px 30px color-mix(in srgb, var(--accent) 52%, transparent);
  transform: translateY(-1px);
}

.btn--primary:hover .btn__icon {
  transform: translateX(2px);
}

.btn--secondary {
  background-color: var(--surface-translucent);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: blur(6px);
}

.btn--secondary:hover {
  border-color: var(--accent-border);
  background-color: color-mix(in srgb, var(--surface) 80%, transparent);
  transform: translateY(-1px);
}

/* Quiet, mono "control" button — reads as a device control, not a pill. */
.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-inline: var(--space-3);
}

.btn--quiet:hover {
  color: var(--text);
}

.btn--quiet .btn__icon {
  color: var(--accent);
}

.btn--lg {
  --btn-pad-y: 0.85rem;
  padding-inline: var(--space-6);
  font-size: var(--text-lg);
}

/* ======================================================================
 * Header (glass)
 * ====================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color var(--motion) var(--ease), background var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
}

.site-header[data-scrolled="true"] {
  border-bottom-color: var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding-block: var(--space-3);
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  color: var(--text);
  flex: 0 0 auto;
}

.site-header__brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-emphasis));
  color: var(--on-accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

.site-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

/* The header nav is built from native <details> menus so it works with NO JS
   (click a group to open). The OUTER shell is the mobile hamburger: on desktop
   its summary is hidden and the group bar shows — but a closed <details> hides
   its content (UA uses display- OR content-visibility-based hiding), so force it
   visible two ways: a 3-class selector (beats the UA display rule's specificity)
   and `::details-content` (the modern content-visibility mechanism). The ≤900px
   query re-collapses it into the tap menu. */
.site-nav__shell {
  width: 100%;
  display: flex;
  justify-content: center;
}

.site-nav__toggle {
  display: none;
}

.site-header .site-nav__shell > .site-nav__groups {
  display: flex;
}

.site-nav__shell::details-content {
  content-visibility: visible;
}

.site-nav__groups {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* A group dropdown (Product / Learn / Company). */
.navmenu {
  position: relative;
}

.navmenu__summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  transition: color var(--motion) var(--ease), background var(--motion) var(--ease);
}

.navmenu__summary::-webkit-details-marker {
  display: none;
}

.navmenu__summary:hover,
.navmenu--active > .navmenu__summary,
.navmenu[open] > .navmenu__summary {
  color: var(--text);
  background: var(--hairline);
}

/* A caret that flips when the group is open. */
.navmenu__chev {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.55;
  transition: transform var(--motion) var(--ease);
}

.navmenu[open] > .navmenu__summary .navmenu__chev {
  transform: rotate(180deg);
}

.navmenu__panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  min-width: 196px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: var(--shadow-lg);
  z-index: 130;
}

.navmenu__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.navmenu__list a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  transition: color var(--motion) var(--ease), background var(--motion) var(--ease);
}

.navmenu__list a:hover,
.navmenu__list a.is-active {
  color: var(--text);
  background: var(--hairline);
  text-decoration: none;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 0 0 auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-translucent);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--motion) var(--ease), color var(--motion) var(--ease), background var(--motion) var(--ease);
}

.theme-toggle:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

.lang-switcher ul {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}

.lang-switcher a {
  color: var(--muted);
}

.lang-switcher a.is-active {
  color: var(--text);
  font-weight: 600;
}

.nav-toggle-icon {
  display: inline-block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.nav-toggle-icon::before {
  top: -6px;
}

.nav-toggle-icon::after {
  top: 6px;
}

/* ======================================================================
 * Masthead — the cover plate. A live WebGL2 compute field (gpu_field.ts)
 * sits behind the cover content; the field falls back to a static CSS
 * gradient if the canvas is removed.
 * ====================================================================== */
.masthead {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  min-height: min(86vh, 800px);
  padding-block: clamp(22px, 3vh + 1rem, 52px) clamp(22px, 3vh + 1rem, 44px);
  border-bottom: 1px solid var(--border-subtle);
}

.masthead__field {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  display: block;
  /* Fallback paint (shown only if the canvas removes itself): a faint contoured
     wash so the hero never reads as a flat black box without WebGL2. */
  background:
    radial-gradient(120% 90% at 72% 18%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 56%),
    radial-gradient(90% 80% at 28% 74%, color-mix(in srgb, var(--viz-cyan) 12%, transparent), transparent 60%),
    repeating-linear-gradient(118deg, transparent 0 16px, color-mix(in srgb, var(--accent) 5%, transparent) 16px 17px),
    var(--bg);
  /* Fade only the very bottom edge into the page; the field itself stays vivid. */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 86%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 86%, transparent 100%);
}

/* Scrim — protects headline contrast on the left while letting the field stay
   vivid through the center/right, plus a soft top/edge vignette for depth. The
   per-glyph text-shadow halo (below) carries the rest of the contrast. */
.masthead__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--bg) 88%, transparent) 0%, color-mix(in srgb, var(--bg) 60%, transparent) 34%, color-mix(in srgb, var(--bg) 14%, transparent) 60%, transparent 74%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 55%, transparent) 0%, transparent 15%, transparent 84%, color-mix(in srgb, var(--bg) 50%, transparent) 100%),
    radial-gradient(150% 135% at 50% -16%, transparent 60%, color-mix(in srgb, var(--bg) 38%, transparent) 100%);
}

.masthead__inner {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(var(--space-6), 5vh, var(--space-9));
}

/* Top instrument rail: doc id (left) · live telemetry HUD (right). */
.masthead__rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* Telemetry HUD — a glass instrument pill carrying the live iter/loss readout
   and a growing loss sparkline (both driven by gpu_field.ts). */
.hud {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg) 58%, transparent);
  backdrop-filter: blur(8px) saturate(140%);
  box-shadow: var(--shadow-sm);
}

.hud__live {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.hud__live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink 1.8s var(--ease) infinite;
}

.hud__sep {
  width: 1px;
  align-self: stretch;
  margin-block: 3px;
  background: var(--border);
}

.hud__readout {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud__spark {
  display: block;
  width: 76px;
  height: 22px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Cover-plate footer: the engineering-drawing title-block + figure caption,
   pinned to the bottom of the plate. */
.masthead__foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.masthead__foot .fig-caption {
  margin: 0;
}

.masthead__titleblock {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg) 52%, transparent);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.titleblock__cell {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-right: 1px solid var(--border-subtle);
}

.titleblock__cell:last-child {
  border-right: none;
}

.titleblock__k {
  font: 500 var(--text-xs) / 1 var(--mono);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.titleblock__v {
  font: 600 var(--text-xs) / 1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.masthead__top {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, clamp(280px, 26vw, 360px));
  gap: clamp(var(--space-6), 4vw, var(--space-8));
  align-items: center;
  margin: 0;
}

.masthead__copy {
  /* A soft canvas-colored halo behind every glyph guarantees AA contrast over
     the animated field, on either theme (the halo color is the page bg). */
  text-shadow:
    0 1px 22px color-mix(in srgb, var(--bg) 92%, transparent),
    0 1px 3px color-mix(in srgb, var(--bg) 82%, transparent);
}

.masthead__docid {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.masthead__docid::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--accent);
}

.masthead__title {
  font-size: var(--text-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-5);
  max-width: 18ch;
  /* The variable display face "develops into focus" on load — a crafted
     micro-moment that also signals the font is intentional, not static. */
  animation: title-develop var(--motion-deliberate) var(--ease-emphasized) both;
}

@keyframes title-develop {
  from {
    font-variation-settings: "wght" 340;
    letter-spacing: 0.012em;
    opacity: 0.5;
  }
  to {
    font-variation-settings: "wght" 800;
    letter-spacing: -0.03em;
    opacity: 1;
  }
}

.masthead__lead {
  font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.3rem);
  color: var(--muted);
  max-width: 52ch;
  margin: 0 0 var(--space-6);
  line-height: 1.55;
}

.masthead__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.masthead__readout {
  font-family: var(--mono);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  color: var(--dim);
  margin: var(--space-5) 0 0;
}

/* Datasheet parameter table (right column of the cover plate). */
.spec-table {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    var(--gloss),
    color-mix(in srgb, var(--surface) 74%, transparent);
  backdrop-filter: blur(10px);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--panel-glint);
}

.spec-table__title {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.spec-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-sm);
  padding-block: var(--space-2);
}

.spec-row__k {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.spec-row__dots {
  flex: 1 1 auto;
  min-width: 14px;
  align-self: stretch;
  border-bottom: 1px dotted var(--border);
  transform: translateY(-4px);
}

.spec-row__v {
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.spec-row__v--accent {
  color: var(--accent);
}

/* Figure caption + trailing scale-bar rule (Fig. 1 / Fig. 2 / Fig. 3). */
.fig-caption {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-7) 0 0;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.fig-caption::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}

/* ======================================================================
 * Spec section heads (home) — mono §n on a hairline rule.
 * ====================================================================== */
.spec-head {
  margin-bottom: var(--space-6);
  max-width: 66ch;
}

.spec-head__rule {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.spec-head__no {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.spec-head__id {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dim);
}

.spec-head__rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.spec-head__title {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-3);
  max-width: 22ch;
}

.spec-head__lead {
  color: var(--muted);
  font-size: var(--text-lg);
  margin: 0;
}

/* ======================================================================
 * Datasheet tables (capabilities §1, parts manifest §5)
 * ====================================================================== */
.datasheet-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  /* Scroll horizontally on narrow viewports instead of clipping nowrap cells. */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--card-gradient);
  box-shadow: var(--shadow-sm);
}

.datasheet {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: var(--text-sm);
  counter-reset: dsrow;
}

.datasheet thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--inset) 60%, transparent);
  border-bottom: 1px solid var(--border);
}

.datasheet tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.datasheet tbody tr:last-child td {
  border-bottom: none;
}

.datasheet tbody tr {
  /* A faint accent band parked off-screen-right; on hover it sweeps across the
     row (an instrument scan line), then sweeps off on leave. */
  background-image: linear-gradient(90deg, transparent 0%, var(--accent-wash) 50%, transparent 100%);
  background-size: 220% 100%;
  background-position: 130% 0;
  background-repeat: no-repeat;
  transition: background-position 0.7s var(--ease), background-color var(--motion) var(--ease);
}

.datasheet tbody tr:nth-child(even) {
  background-color: color-mix(in srgb, var(--text) 2.5%, transparent);
}

.datasheet tbody tr:hover {
  background-color: var(--hairline);
  background-position: -30% 0;
}

.datasheet tbody tr:hover .datasheet__param::before {
  box-shadow: 0 0 8px var(--row-accent, var(--accent));
}

.datasheet__param {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
  position: relative;
  padding-left: var(--space-5);
}

.datasheet__param::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2em;
  bottom: 0.2em;
  width: 3px;
  border-radius: 2px;
  background: var(--row-accent, var(--accent));
}

.row--blue { --row-accent: var(--accent); }
.row--green { --row-accent: var(--success); }
.row--cyan { --row-accent: var(--viz-cyan); }
.row--purple { --row-accent: var(--viz-purple); }
.row--pink { --row-accent: var(--viz-pink); }
.row--amber { --row-accent: var(--warning); }

.datasheet__value {
  font-family: var(--mono);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.datasheet__note {
  color: var(--muted);
}

.datasheet__source {
  font-family: var(--mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.manifest-note {
  margin: var(--space-4) 0 0;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--dim);
}

/* ======================================================================
 * Lowering triptych (§2) — Workflow → IR → WebGPU
 * ====================================================================== */
.lower {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: stretch;
}

.lower__stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-gradient);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.lower__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--mono);
}

.lower__name {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.lower__sub {
  font-size: var(--text-xs);
  color: var(--dim);
}

.lower__body {
  flex: 1 1 auto;
  min-width: 0;
}

.lower__arrow {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
}

/* Signal connector: a track with a bright pulse travelling down the lowering
   ladder (data visibly flowing Workflow → IR → WebGPU). */
.lower__flow {
  position: relative;
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: var(--border-subtle);
  overflow: hidden;
}

.lower__flow::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
  animation: flow-pulse-v var(--motion-loop) var(--ease) infinite;
}

@keyframes flow-pulse-v {
  from { transform: translateY(-120%); }
  to { transform: translateY(240%); }
}

@keyframes flow-pulse-h {
  from { transform: translateX(-120%); }
  to { transform: translateX(240%); }
}

.lower__arrow svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
  transform: rotate(90deg);
}

.lower__tier {
  display: inline-block;
  margin-right: var(--space-2);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
}

@media (min-width: 880px) {
  .lower {
    grid-template-columns: 1fr 40px 1fr 40px 1fr;
  }
  .lower__arrow {
    flex-direction: row;
  }
  .lower__flow {
    width: 100%;
    min-width: 16px;
    height: 2px;
  }
  .lower__flow::after {
    left: auto;
    top: 0;
    bottom: 0;
    height: auto;
    width: 60%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation-name: flow-pulse-h;
  }
  .lower__arrow svg {
    transform: none;
  }
}

/* Mono code block (IR / WGSL). */
.code {
  font-family: var(--mono);
  font-size: var(--text-sm);
  line-height: 1.65;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin: 0;
  overflow-x: auto;
  color: var(--muted);
  white-space: pre;
}

.tok-k { color: var(--viz-purple); }
.tok-n { color: var(--accent); }
.tok-c { color: var(--dim); }
.tok-s { color: var(--viz-cyan); }
.tok-f { color: var(--success); }

.thread-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  margin-top: var(--space-2);
}

.thread-grid span {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
}

/* ======================================================================
 * Device boundary / shape ledger (§3)
 * ====================================================================== */
.boundary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-6);
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-lg);
  padding: clamp(var(--space-6), 4vw, var(--space-8));
  background: linear-gradient(135deg, var(--accent-wash), transparent 62%);
}

.boundary__label {
  position: absolute;
  top: -11px;
  left: var(--space-5);
  padding: 0 var(--space-3);
  background: var(--bg);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.shape-flow {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* On wide screens, draw a CAD dimension bracket under the whole shape path —
   the tensor flow reads as a measured drawing. Hidden on narrow (the row wraps). */
@media (min-width: 640px) {
  .shape-flow {
    padding-bottom: var(--space-5);
  }
  .shape-flow::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: var(--space-1);
    height: 7px;
    border: 1px solid var(--tick);
    border-top: none;
    border-radius: 0 0 2px 2px;
    pointer-events: none;
  }
}

.shape-pill {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

/* An operator on a shape transition: the op name above an accent arrow — the
   measured transform between tensor shapes (the §3 boundary "drawing"). */
.shape-op {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
}

.shape-op__name {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--dim);
  white-space: nowrap;
}

.shape-op__arrow {
  color: var(--accent);
  font-family: var(--mono);
  font-size: var(--text-lg);
}

.boundary__aside {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
}

.boundary__cloud {
  width: 40px;
  height: 40px;
  color: var(--danger);
  flex: 0 0 auto;
}

.boundary__note {
  color: var(--muted);
  font-size: var(--text-sm);
  max-width: 36ch;
  margin: 0;
}

/* ======================================================================
 * Gauge band (§4) — conic arc-meter dials. Each dial sweeps its fill from 0
 * on reveal (@property --shown) and the value counts up (metrics.ts): a control
 * panel, not a big number with an underline.
 * ====================================================================== */
@property --shown {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.gauge-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-gradient);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--panel-glint);
  overflow: hidden;
}

.gauge {
  /* No-JS / reduced-motion: the dial is filled immediately (correct reading). */
  --shown: var(--val);
  --track: color-mix(in srgb, var(--border) 85%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(var(--space-5), 3vw, var(--space-7)) var(--space-5);
  border-right: 1px solid var(--border-subtle);
}

.gauge:last-child {
  border-right: none;
}

/* Under JS the dials start empty and sweep to --val when the band scrolls in. */
.js-reveal .gauge {
  --shown: 0;
  transition: --shown 1.1s var(--ease-emphasized);
}
.js-reveal .gauge-band.is-visible .gauge {
  --shown: var(--val);
}
.js-reveal .gauge-band.is-visible .gauge:nth-child(2) {
  transition-delay: 90ms;
}
.js-reveal .gauge-band.is-visible .gauge:nth-child(3) {
  transition-delay: 180ms;
}
.js-reveal .gauge-band.is-visible .gauge:nth-child(4) {
  transition-delay: 270ms;
}

.gauge__dial {
  position: relative;
  width: clamp(104px, 11vw, 132px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-4);
}

/* A 270° conic arc: the gauge-color fill up to --shown, then the track, then an
   open bottom; masked to a ring. */
.gauge__arc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 225deg,
    var(--gauge-fill, var(--accent)) calc(var(--shown) * 270deg),
    var(--track) calc(var(--shown) * 270deg) 270deg,
    transparent 270deg 360deg
  );
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
  mask: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
}

/* Minor tick ring just inside the arc. */
.gauge__arc::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 225deg, var(--tick) 0 0.8deg, transparent 0.8deg 27deg);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(closest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  opacity: 0.5;
}

.gauge__value {
  position: relative;
  z-index: 1;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem);
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--gauge-fill, var(--accent)) 26%, var(--text));
}

.gauge__label {
  display: block;
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  max-width: 20ch;
}

@media (max-width: 640px) {
  .gauge-band {
    grid-template-columns: 1fr 1fr;
  }
  .gauge:nth-child(2) {
    border-right: none;
  }
  .gauge:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border-subtle);
  }
}

/* ======================================================================
 * Abstract + convergence + colophon (§6)
 * ====================================================================== */
.abstract {
  border-block: 1px solid var(--border);
  padding-block: var(--space-6);
  max-width: 72ch;
}

.abstract__label {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 var(--space-3);
}

.abstract__text {
  font-size: var(--text-lg);
  line-height: 1.7;
  margin: 0;
  color: color-mix(in srgb, var(--text) 90%, var(--muted));
}

.converge {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-top: var(--space-7);
}

.converge__svg {
  width: 260px;
  max-width: 100%;
  height: 84px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--inset);
  padding: var(--space-2);
}

.converge__line {
  fill: none;
  stroke: var(--success);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.js-reveal .converge__line {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.js-reveal .converge.is-visible .converge__line {
  animation: draw 1.6s var(--ease-emphasized) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.converge__label {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--muted);
}

.converge__label b {
  color: var(--success);
  font-weight: 600;
}

.colophon {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.colophon::before,
.colophon::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ======================================================================
 * Page header (content pages)
 * ====================================================================== */
.page-header {
  position: relative;
  padding-block: clamp(48px, 3.5rem + 3vw, 96px) var(--space-6);
  overflow: hidden;
}

.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 120% at 18% -10%, var(--accent-wash), transparent 60%);
  z-index: 0;
}

.page-header > .container {
  position: relative;
  z-index: 1;
}

.page-header__title {
  font-size: var(--text-3xl);
  margin: 0 0 var(--space-4);
  max-width: 20ch;
}

.page-header__lead {
  margin: 0;
  max-width: 60ch;
}

/* ======================================================================
 * Hero (content pages: pricing, showcase)
 * ====================================================================== */
.hero {
  position: relative;
  padding-block: clamp(48px, 4rem + 3vw, 104px) var(--section-y);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 20%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 20%, #000 0%, transparent 72%);
  mask-image: radial-gradient(70% 70% at 50% 20%, #000 0%, transparent 72%);
  opacity: 0.4;
}

.hero > .container {
  position: relative;
  z-index: 1;
}

.hero--center {
  text-align: center;
}

.hero--center .hero__copy {
  margin-inline: auto;
  max-width: 52ch;
}

.hero--center .hero__actions {
  justify-content: center;
}

.hero__title {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
}

.hero__lead {
  margin: 0 0 var(--space-6);
}

.hero--center .hero__lead {
  margin-inline: auto;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ======================================================================
 * Sections
 * ====================================================================== */
.section {
  padding-block: var(--section-y);
}

.section--muted {
  position: relative;
  background-color: color-mix(in srgb, var(--surface) 55%, var(--bg));
  border-block: 1px solid var(--border-subtle);
}

/* Engraved graph-paper tick ruler along the top edge of a muted band — turns a
   plain section divider into a measured instrument seam (the body grid is hidden
   under the opaque muted surface, so this restores the engineering texture). */
.section--muted::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--tick) 0 1px, transparent 1px var(--grid-step));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  opacity: 0.75;
}

.section__head {
  max-width: 62ch;
  margin-bottom: var(--space-6);
}

.section__head--center {
  margin-inline: auto;
  text-align: center;
}

.section__title {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-3);
}

.section__lead {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-lg);
}

/* ======================================================================
 * Studio-window figure (sc-*) — used in §2 stage 1
 * ====================================================================== */
.showcase__svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
}

.sc-window { fill: var(--surface); stroke: var(--border); }
.sc-titlebar { fill: var(--inset); }
.sc-dot-1 { fill: var(--danger); }
.sc-dot-2 { fill: var(--warning); }
.sc-dot-3 { fill: var(--success); }
.sc-url { fill: color-mix(in srgb, var(--bg) 60%, var(--surface)); stroke: var(--border-subtle); }
.sc-url-text { fill: var(--dim); font-family: var(--mono); }
.sc-node { fill: color-mix(in srgb, var(--surface) 70%, var(--bg)); stroke: var(--border); }
.sc-node-title { fill: var(--text); font-family: var(--sans); font-weight: 600; }
.sc-node-sub { fill: var(--dim); font-family: var(--mono); }
.sc-stripe-cyan { fill: var(--viz-cyan); }
.sc-stripe-blue { fill: var(--accent); }
.sc-stripe-amber { fill: var(--warning); }
.sc-stripe-green { fill: var(--success); }
.sc-stripe-purple { fill: var(--viz-purple); }
.sc-pill { fill: var(--accent-dim); stroke: var(--accent-border); }
.sc-pill-text { fill: var(--accent); font-family: var(--mono); }
.sc-wire { fill: none; stroke: var(--border); stroke-width: 2; opacity: 0.7; }
.sc-flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 6 14;
  opacity: 0.95;
  animation: sc-flow 1.4s linear infinite;
}
.sc-spark { fill: none; stroke: var(--success); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sc-spark-area { fill: color-mix(in srgb, var(--success) 16%, transparent); stroke: none; }
.sc-axis { stroke: var(--border-subtle); stroke-width: 1; }
.sc-panel { fill: var(--inset); stroke: var(--border-subtle); }
.sc-panel-title { fill: var(--muted); font-family: var(--sans); font-weight: 600; }

@keyframes sc-flow {
  to {
    stroke-dashoffset: -40;
  }
}

/* ======================================================================
 * Cards
 * ====================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.card {
  position: relative;
  display: block;
  background: var(--card-gradient);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  height: 100%;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--gloss);
}

.card > * {
  position: relative;
}

.card--link {
  color: inherit;
  transition: border-color var(--motion) var(--ease), transform var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
}

.card--link:hover {
  border-color: var(--accent-border);
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.card__title {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-2);
}

.card__body {
  margin: 0;
  color: var(--muted);
}

.card__arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-4);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-sm);
}

.card__arrow svg {
  width: 16px;
  height: 16px;
  transition: transform var(--motion) var(--ease);
}

.card--link:hover .card__arrow svg {
  transform: translateX(3px);
}

/* ======================================================================
 * Pricing
 * ====================================================================== */
.pricing-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-5);
}

.currency-select label {
  font-size: var(--text-sm);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.currency-select select {
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.price-card {
  position: relative;
  background: var(--card-gradient);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.price-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--gloss);
}

.price-card > * {
  position: relative;
}

.price-card--featured {
  border-color: var(--accent-border);
  box-shadow: var(--shadow), 0 0 0 1px var(--accent-border);
}

.price-card__badge {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

.price-card__name {
  margin: 0;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-sm);
  color: var(--muted);
}

.price-card__price {
  font-family: var(--display);
  font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.price-card__cadence {
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--muted);
  font-family: var(--sans);
}

.price-card__summary {
  margin: 0;
  color: var(--muted);
}

.price-card__features {
  list-style: none;
  margin: var(--space-2) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1 0 auto;
}

.price-card__features li {
  position: relative;
  padding-left: calc(var(--space-5) + var(--space-1));
  color: var(--text);
  font-size: var(--text-sm);
}

.price-card__features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 14px;
  height: 8px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-2px) rotate(-45deg);
}

.pricing-note {
  margin: var(--space-6) auto 0;
  max-width: 60ch;
  text-align: center;
  font-size: var(--text-sm);
}

/* ======================================================================
 * FAQ / disclosures
 * ====================================================================== */
.faq {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 760px;
  margin-inline: auto;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  background: var(--card-gradient);
  transition: border-color var(--motion) var(--ease);
}

.faq-item[open] {
  border-color: var(--accent-border);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-family: var(--display);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  color: var(--accent);
  font-size: var(--text-xl);
  font-weight: 400;
  transition: transform var(--motion) var(--ease);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  margin: var(--space-3) 0 0;
  color: var(--muted);
}

/* ======================================================================
 * Lists: blog / guide / links / releases
 * ====================================================================== */
.post-list,
.link-cards,
.release-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}

/* Blog index entries as cards (cohesive with the rest of the surfaces). */
.post-list__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  background: var(--card-gradient);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--motion) var(--ease), transform var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
}

.post-list__item:hover {
  border-color: var(--accent-border);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.post-list__item .tag-list {
  margin-top: auto;
}

.post-card__date {
  color: var(--dim);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

/* ---- Blog index at scale: filter toolbar, featured card, card meta ---- */
.blog-filters {
  display: none; /* progressive enhancement — blog_filter.ts reveals it */
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.blog-filters[data-enhanced] {
  display: flex;
}

.blog-filter {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-4);
  cursor: pointer;
  transition: color var(--motion) var(--ease), border-color var(--motion) var(--ease), background var(--motion) var(--ease);
}

.blog-filter:hover {
  color: var(--text);
  border-color: var(--accent-border);
}

.blog-filter.is-active {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.post-card__top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0 0 var(--space-1);
}

.post-card__cat {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-full);
  padding: 1px var(--space-3);
  background: var(--accent-dim);
}

.post-card__meta {
  margin: var(--space-3) 0 0;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--dim);
}

.post-card__flag {
  display: inline-block;
  margin-bottom: var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.post-list__item--featured {
  grid-column: 1 / -1;
  border-color: var(--accent-border);
  background: linear-gradient(120deg, var(--accent-wash), transparent 55%), var(--card-gradient);
}

.post-list__item--featured .post-list__title {
  font-size: var(--text-2xl);
  max-width: 28ch;
}

.post-list__item--featured .muted {
  max-width: 64ch;
}

.post-list__empty {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--text-sm);
}

/* ---- Prev/next pager (blog articles; reused by the guide) ---- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

.pager__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-gradient);
  color: var(--text);
  transition: border-color var(--motion) var(--ease), transform var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
}

.pager__link:hover {
  border-color: var(--accent-border);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.pager__link--next {
  text-align: right;
}

.pager__dir {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.pager__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-base);
}

/* An empty grid cell that keeps a lone neighbour in its correct column. */
.pager__spacer {
  display: block;
}

@media (max-width: 560px) {
  .pager {
    grid-template-columns: 1fr;
  }
  .pager__link--next {
    text-align: left;
  }
  .pager__spacer {
    display: none;
  }
}

.post-list__title {
  font-size: var(--text-xl);
  margin: 0;
}

.post-list__title a {
  color: var(--text);
}

.post-list__title a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ======================================================================
 * Guide — nested docs layout (readthedocs philosophy): a sticky sidebar tree,
 * the article, and a sticky in-page table of contents with scroll-spy. The
 * structure IS the navigation. 3 panes → 2 (drop TOC) → 1 (collapsible nav).
 * ====================================================================== */
.doc {
  max-width: var(--container-wide);
  margin-inline: auto;
  padding: clamp(var(--space-6), 4vw, var(--space-8)) var(--space-5) var(--space-9);
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 196px;
  gap: clamp(var(--space-5), 3vw, var(--space-8));
  align-items: start;
}

.doc--no-toc {
  grid-template-columns: 232px minmax(0, 1fr);
}

.doc-main {
  min-width: 0;
}

/* --- Sidebar tree --- */
.doc-sidebar {
  position: sticky;
  top: var(--space-9);
  align-self: start;
  max-height: calc(100vh - var(--space-9) - var(--space-5));
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The disclosure is rendered open; on desktop the summary is hidden so it
   stays a persistent expanded rail (no toggle). The mobile query reveals the
   summary so it can be collapsed there. */
.doc-nav__toggle {
  display: none;
}

.doc-nav__home {
  display: block;
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: var(--space-1) var(--space-2);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
}

.doc-nav__home:hover {
  color: var(--text);
  text-decoration: none;
}

.doc-nav__home.is-current {
  color: var(--accent);
}

.doc-nav__sec {
  margin-bottom: var(--space-5);
}

.doc-nav__sec-title {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.doc-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}

.doc-nav__list a {
  display: block;
  padding: var(--space-1) var(--space-3);
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  transition: color var(--motion) var(--ease), border-color var(--motion) var(--ease);
}

.doc-nav__list a:hover {
  color: var(--text);
  text-decoration: none;
}

.doc-nav__list a.is-current {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* --- Doc head (index) + index overview --- */
.doc-head {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.doc-head__title {
  font-size: var(--text-3xl);
  margin: var(--space-2) 0 var(--space-3);
}

.doc-head__lead {
  margin: 0;
}

.doc-index__sec {
  margin-bottom: var(--space-7);
}

.doc-index__title {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.doc-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.doc-index__link {
  display: block;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-gradient);
  transition: border-color var(--motion) var(--ease), transform var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
}

.doc-index__link:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.doc-index__a-title {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--text);
}

.doc-index__a-desc {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* --- In-page table of contents (scroll-spy active via guide_toc.ts) --- */
.doc-toc {
  position: sticky;
  top: var(--space-9);
  align-self: start;
  max-height: calc(100vh - var(--space-9) - var(--space-5));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.doc-toc__title {
  margin: 0 0 var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.doc-toc__nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}

.doc-toc__nav a {
  display: block;
  padding: var(--space-1) var(--space-3);
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  transition: color var(--motion) var(--ease), border-color var(--motion) var(--ease);
}

.doc-toc__nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.doc-toc__nav a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.doc-toc__sub a {
  padding-left: calc(var(--space-3) + var(--space-4));
}

/* 3 panes → 2 (drop the TOC) on mid widths. */
@media (max-width: 1180px) {
  .doc {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .doc-toc {
    display: none;
  }
}

/* → 1 column: the sidebar collapses into a disclosure at the top. */
@media (max-width: 980px) {
  .doc,
  .doc--no-toc {
    grid-template-columns: 1fr;
  }
  .doc-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .doc-nav {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-gradient);
  }
  .doc-nav__toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    list-style: none;
    padding: var(--space-3) var(--space-4);
    font-family: var(--mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text);
  }
  .doc-nav__toggle::-webkit-details-marker {
    display: none;
  }
  .doc-nav__toggle::after {
    content: "+";
    margin-left: auto;
    color: var(--accent);
    font-size: var(--text-lg);
  }
  .doc-nav[open] .doc-nav__toggle::after {
    content: "–";
  }
  .doc-nav__inner {
    padding: 0 var(--space-4) var(--space-4);
  }
}

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.release-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  max-width: 760px;
}

.release {
  border-left: 2px solid var(--border);
  padding-left: var(--space-5);
  position: relative;
}

.release::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.release__header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.release__version {
  font-family: var(--display);
  font-size: var(--text-xl);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.release__changes {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.release__changes li {
  position: relative;
  padding-left: var(--space-5);
  color: var(--muted);
}

.release__changes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ======================================================================
 * Article / prose
 * ====================================================================== */
.article {
  padding-block: var(--space-7) var(--space-9);
}

.article__header {
  margin-bottom: var(--space-6);
}

.article__title {
  font-size: var(--text-3xl);
  margin: var(--space-4) 0 var(--space-3);
  max-width: 24ch;
}

.article__meta {
  margin: 0;
  font-size: var(--text-sm);
}

.article__back {
  margin-top: var(--space-8);
}

.prose {
  max-width: var(--container-prose);
  font-size: var(--text-lg);
  line-height: 1.7;
}

.prose p,
.prose ul,
.prose ol {
  margin-block: 0 var(--space-5);
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.prose li {
  margin-bottom: var(--space-2);
}

.prose h2 {
  font-size: var(--text-xl);
  margin-block: var(--space-7) var(--space-3);
}

.prose h3 {
  font-size: var(--text-lg);
  margin-block: var(--space-6) var(--space-2);
}

.prose strong {
  color: var(--text);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
}

/* Deep-linkable headings (anchors injected at build time by toc.ts). The
   scroll-margin keeps anchored jumps clear of the sticky header. */
.prose h2,
.prose h3 {
  position: relative;
  scroll-margin-top: calc(var(--space-9) + var(--space-3));
}

.heading-anchor {
  margin-left: 0.4em;
  color: var(--dim);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--motion) var(--ease), color var(--motion) var(--ease);
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent);
  text-decoration: none;
}

.prose blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-2) var(--space-5);
  border-left: 3px solid var(--accent-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: linear-gradient(90deg, var(--accent-wash), transparent 62%);
  color: var(--muted);
  font-style: italic;
}

.prose blockquote > :last-child {
  margin-bottom: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  font-size: var(--text-base);
}

.prose thead {
  background: color-mix(in srgb, var(--inset) 60%, transparent);
}

.prose th,
.prose td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.prose th {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}

/* Fenced code block with a language tab (components.ts codeBlock()). */
.codeblock {
  margin: var(--space-5) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--inset);
  box-shadow: var(--surface-shadow, var(--shadow-sm));
}

.codeblock__lang {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 50%, var(--inset));
}

.code--block {
  border: none;
  border-radius: 0;
  margin: 0;
  background: transparent;
}

/* Callout / admonition (components.ts callout()). */
.callout {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--callout-border, var(--border));
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--callout-bg, var(--surface-translucent));
}

.callout__label {
  margin: 0 0 var(--space-2);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--callout-fg, var(--accent));
}

.callout__body > :last-child {
  margin-bottom: 0;
}

.callout--note {
  --callout-fg: var(--accent);
  --callout-border: var(--accent-border);
  --callout-bg: var(--accent-wash);
}

.callout--tip {
  --callout-fg: var(--success);
  --callout-border: color-mix(in srgb, var(--success) 35%, transparent);
  --callout-bg: color-mix(in srgb, var(--success) 8%, transparent);
}

.callout--warn {
  --callout-fg: var(--warning);
  --callout-border: color-mix(in srgb, var(--warning) 35%, transparent);
  --callout-bg: color-mix(in srgb, var(--warning) 8%, transparent);
}

/* ======================================================================
 * Breadcrumbs
 * ====================================================================== */
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--muted);
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-2);
  color: var(--dim);
}

/* ======================================================================
 * Tags
 * ====================================================================== */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
}

.tag {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px var(--space-3);
  background: var(--surface-translucent);
}

/* ======================================================================
 * CTA band
 * ====================================================================== */
/* Closing CTA — a bordered "console" panel with an accent header rule, not a
   full glowing-blue SaaS banner. */
.cta-band {
  position: relative;
  text-align: center;
  background: var(--card-gradient);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xl);
  padding: clamp(var(--space-7), 6vw, var(--space-10)) var(--space-5);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cta-band::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent), var(--viz-cyan), transparent);
}

.cta-band > * {
  position: relative;
}

.cta-band__title {
  font-size: var(--text-3xl);
  margin: 0 0 var(--space-4);
  max-width: 22ch;
  margin-inline: auto;
}

.cta-band__lead {
  margin: 0 auto var(--space-6);
  max-width: 52ch;
}

.cta-band .hero__actions {
  justify-content: center;
}

/* ======================================================================
 * Error page (404)
 * ====================================================================== */
.error-page {
  text-align: center;
  max-width: 52ch;
  margin-inline: auto;
  padding-block: clamp(var(--space-7), 8vw, var(--space-10));
}

.error-page__code {
  font-family: var(--mono);
  font-size: clamp(4rem, 3rem + 8vw, 9rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--accent);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .error-page__code {
    background-image: linear-gradient(120deg, var(--accent), var(--viz-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.error-page__title {
  font-size: var(--text-3xl);
  margin: var(--space-4) 0 var(--space-3);
}

.error-page__lead {
  margin-inline: auto;
}

.error-page__actions {
  justify-content: center;
  margin-top: var(--space-6);
}

/* ======================================================================
 * Footer
 * ====================================================================== */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  padding-block: var(--space-7) var(--space-6);
  margin-top: var(--space-9);
}

/* Slim footer: brand + tagline on one row (the pages live in the top-bar
   dropdowns; the footer is not a sitemap), then the © / legal line. */
.site-footer__bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
}

.site-footer__tagline {
  margin: 0;
  max-width: 54ch;
  font-size: var(--text-sm);
}

.site-footer__meta {
  margin: var(--space-6) 0 0;
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--dim);
}

.contact-note {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}

/* ======================================================================
 * TEMPORARY — dev-preview notice overlay (injected by src/internal/dev_notice.ts).
 * Remove this whole block together with dev_notice.ts and its emit in seo.ts to
 * delete the notice entirely.
 * ====================================================================== */
.dev-notice {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: color-mix(in srgb, var(--inset) 80%, transparent);
  backdrop-filter: blur(8px) saturate(120%);
  animation: dev-notice-in var(--motion-slow) var(--ease-emphasized) both;
}

.dev-notice__dialog {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: var(--space-7) var(--space-6) var(--space-6);
  background: var(--card-gradient);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dev-notice__dialog::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--viz-cyan), transparent);
}

.dev-notice__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--warning);
}

.dev-notice__badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.dev-notice__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-2xl);
}

.dev-notice__body {
  margin: 0 0 var(--space-6);
  color: var(--muted);
  line-height: 1.6;
}

.dev-notice__actions {
  display: flex;
  justify-content: flex-end;
}

@keyframes dev-notice-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ======================================================================
 * Scroll reveal (progressive enhancement; see reveal.ts). Content is fully
 * visible without JS; the hidden start state only applies under .js-reveal.
 * ====================================================================== */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease-emphasized), transform 0.7s var(--ease-emphasized);
}

.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: none;
}

.js-reveal .reveal[data-reveal-delay="1"] { transition-delay: 80ms; }
.js-reveal .reveal[data-reveal-delay="2"] { transition-delay: 160ms; }
.js-reveal .reveal[data-reveal-delay="3"] { transition-delay: 240ms; }

/* ======================================================================
 * Responsive
 * ====================================================================== */
@media (max-width: 960px) {
  /* Let stacked content size the hero (no forced tall plate → no void), and
     drop the datasheet to a full-width card below the headline. */
  .masthead {
    min-height: auto;
  }
  .masthead__inner {
    justify-content: flex-start;
  }
  .masthead__top {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 900px) {
  .site-header__inner {
    gap: var(--space-3);
  }

  .site-nav {
    flex: 0 0 auto;
    order: 3;
  }

  /* Hamburger: the shell summary becomes the toggle button. */
  .site-nav__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-translucent);
    color: var(--text);
    cursor: pointer;
    list-style: none;
  }

  .site-nav__toggle::-webkit-details-marker {
    display: none;
  }

  .site-nav__shell {
    position: relative;
    width: auto;
  }

  /* Collapsed by default; open reveals a panel of stacked group accordions. */
  .site-nav__shell:not([open]) > .site-nav__groups {
    display: none;
  }

  .site-nav__groups {
    position: absolute;
    top: calc(100% + var(--space-3));
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    min-width: 244px;
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 120;
  }

  /* Groups expand inline (accordion), not as floating dropdowns. */
  .navmenu {
    position: static;
  }

  .navmenu__summary {
    width: 100%;
    justify-content: space-between;
  }

  .navmenu__panel {
    position: static;
    transform: none;
    min-width: 0;
    padding: var(--space-1) 0 var(--space-2) var(--space-4);
    border: none;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }

  .site-header__brand {
    margin-right: auto;
  }

  .lang-switcher {
    display: none;
  }

  .boundary__aside {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding-inline: var(--space-4);
  }

  .masthead__actions .btn,
  .cta-band .btn {
    flex: 1 1 auto;
  }

  /* Keep the telemetry HUD compact on phones (sparkline drops, tighter gaps). */
  .hud {
    gap: var(--space-2);
    padding-inline: var(--space-3);
  }

  .hud__spark {
    display: none;
  }
}

/* ======================================================================
 * Reduced motion
 * ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .js-reveal .reveal {
    opacity: 1;
    transform: none;
  }

  .js-reveal .converge__line {
    stroke-dashoffset: 0;
  }
}
