/* =========================================================================
   Portable Video Compressor - main.css
   Visual direction: "Signal Deck" (dark control-surface), with a light theme.
   All styling is external (CSP style-src 'self'); no inline styles anywhere.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Design tokens
   Light is the :root default; dark applies via prefers-color-scheme AND via
   an explicit [data-theme] override set by the theme toggle. Double coverage
   means the site respects the browser setting with no JS, and the manual
   switch still works.
   ------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces and text (light) */
  --bg:          oklch(0.965 0.008 256);
  --bg-2:        oklch(0.935 0.011 256);
  --surface:     oklch(0.992 0.004 256);
  --surface-2:   oklch(0.905 0.014 256);
  --border:      oklch(0.865 0.014 258);
  --border-soft: oklch(0.905 0.012 258);
  --text:        oklch(0.21 0.022 262);
  --text-dim:    oklch(0.40 0.022 260);
  --text-faint:  oklch(0.53 0.018 258);

  /* Cold scheme: blue primary accent, red secondary for key figures. */
  --accent:        #3061d8;
  --accent-ink:    #2b57c9;   /* accent used as text on --bg */
  --accent-2:      #e23b3b;    /* red, for readouts and emphasis */
  --btn-bg:        #3061d8;
  --btn-bg-hover:  #2547a8;
  --btn-text:      oklch(0.99 0.012 256);
  --link:          #2b57c9;
  --focus:         #3061d8;
  --readout:       #e23b3b;

  /* Grid texture line (control-surface) */
  --grid-line:   oklch(0.905 0.012 258);

  /* Status tints (echo the app's queue colors) */
  --ok:     oklch(0.52 0.15 252);
  --notice: oklch(0.60 0.13 75);
  --warn:   oklch(0.58 0.16 40);

  /* Spacing scale (8px base) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px; --s10: 128px;

  /* Radius (technical, squared-ish) */
  --r-sm: 4px; --r: 6px; --r-lg: 10px;

  /* Type scale (fluid) */
  --fs-hero:  clamp(2.6rem, 1.6rem + 4.6vw, 5rem);
  --fs-h1:    clamp(2rem, 1.5rem + 2.2vw, 3.1rem);
  --fs-h2:    clamp(1.5rem, 1.2rem + 1.4vw, 2.2rem);
  --fs-h3:    clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);
  --fs-body:  clamp(1rem, 0.97rem + 0.18vw, 1.125rem);
  --fs-small: 0.875rem;
  --fs-mono:  0.82rem;

  --lh-tight: 1.05;
  --lh-snug:  1.25;
  --lh-body:  1.62;

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

  /* Motion */
  --dur: 220ms;
  --dur-fast: 150ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Shadows (used sparingly; depth mostly from borders) */
  --shadow-1: 0 1px 2px oklch(0.30 0.05 262 / 0.10);
  --shadow-2: 0 12px 40px oklch(0.28 0.06 262 / 0.16);

  --header-h: 64px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --bg:          oklch(0.175 0.018 264);
    --bg-2:        oklch(0.205 0.020 264);
    --surface:     oklch(0.225 0.020 264);
    --surface-2:   oklch(0.255 0.022 264);
    --border:      oklch(0.36 0.016 262);
    --border-soft: oklch(0.30 0.013 262);
    --text:        oklch(0.95 0.010 256);
    --text-dim:    oklch(0.78 0.015 256);
    --text-faint:  oklch(0.60 0.015 256);

    --accent:        #3061d8;
    --accent-ink:    #7e9cf5;
    --accent-2:      #e23b3b;
    --btn-bg:        #3061d8;
    --btn-bg-hover:  #3f6ee0;
    --btn-text:      oklch(0.99 0.01 256);
    --link:          #7e9cf5;
    --focus:         #3061d8;
    --readout:       #e23b3b;

    --grid-line:   oklch(0.27 0.016 264);

    --ok:     oklch(0.74 0.15 252);
    --notice: oklch(0.82 0.14 80);
    --warn:   oklch(0.72 0.16 40);

    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
    --shadow-2: 0 16px 48px oklch(0 0 0 / 0.5);
  }
}

/* Explicit manual override (wins over the media query) */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:          oklch(0.175 0.018 264);
  --bg-2:        oklch(0.205 0.020 264);
  --surface:     oklch(0.225 0.020 264);
  --surface-2:   oklch(0.255 0.022 264);
  --border:      oklch(0.36 0.016 262);
  --border-soft: oklch(0.30 0.013 262);
  --text:        oklch(0.95 0.010 256);
  --text-dim:    oklch(0.78 0.015 256);
  --text-faint:  oklch(0.60 0.015 256);
  --accent:        #3061d8;
  --accent-ink:    #7e9cf5;
  --accent-2:      #e23b3b;
  --btn-bg:        #3061d8;
  --btn-bg-hover:  #3f6ee0;
  --btn-text:      oklch(0.99 0.01 256);
  --link:          #7e9cf5;
  --focus:         #3061d8;
  --readout:       #e23b3b;
  --grid-line:   oklch(0.27 0.016 264);
  --ok:     oklch(0.74 0.15 252);
  --notice: oklch(0.82 0.14 80);
  --warn:   oklch(0.72 0.16 40);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 16px 48px oklch(0 0 0 / 0.5);
}

/* -------------------------------------------------------------------------
   2. Reset and base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
/* In-page scrolling is animated in JS (js/app.js) with a fixed-target rAF tween.
   CSS smooth is intentionally omitted so the two never compound and overshoot. */

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
strong { font-weight: 600; }
ul, ol { padding-left: 1.2em; }

h1, h2, h3, h4 { line-height: var(--lh-snug); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

::selection { background: var(--accent); color: var(--btn-text); }

/* Visible focus, never hidden behind the sticky header (2.4.11) */
:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: var(--s3); top: -120px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r);
  padding: var(--s2) var(--s4); z-index: 200;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: var(--s3); }

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

/* -------------------------------------------------------------------------
   3. Scrollbar, matched to the desktop (Fluent) app and the PVC-Webapp header:
   neutral gray pill on a transparent track, darkening + thickening on hover.
   ------------------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklab, var(--text) 38%, transparent) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--text) 38%, transparent);
  border-radius: 999px;
  border: 3px solid var(--bg);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in oklab, var(--text) 60%, transparent); border-width: 2px; }
::-webkit-scrollbar-corner { background: transparent; }

/* -------------------------------------------------------------------------
   4. Layout helpers
   ------------------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s5); }
.section { padding-block: clamp(var(--s8), 6vw, var(--s10)); }
.section--tight { padding-block: clamp(var(--s7), 4vw, var(--s8)); }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-mono); font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: var(--s2);
}
.eyebrow::before {
  content: ""; width: 22px; height: 2px; background: var(--accent-2); border-radius: 2px;
  display: inline-block;
}
.lead { font-size: clamp(1.05rem, 1rem + 0.5vw, 1.3rem); color: var(--text-dim); line-height: 1.5; }
.muted { color: var(--text-dim); }

/* -------------------------------------------------------------------------
   5. Buttons
   ------------------------------------------------------------------------- */
.btn {
  --pad-y: 13px; --pad-x: 22px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 46px; padding: var(--pad-y) var(--pad-x);
  font-family: var(--font-sans); font-size: 1rem; font-weight: 600;
  border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--btn-bg); color: var(--btn-text); }
.btn--primary:hover { background: var(--btn-bg-hover); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); background: color-mix(in oklab, var(--accent) 8%, transparent); transform: translateY(-2px); }
.btn--block { width: 100%; }
.btn--lg { min-height: 54px; font-size: 1.05rem; padding-inline: 28px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .ico { width: 18px; height: 18px; flex: none; }

/* -------------------------------------------------------------------------
   6. Header / nav
   ------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.2);
}
.site-header__inner {
  height: 100%; display: flex; align-items: center; gap: var(--s5);
  max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s5);
}
.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--text); flex: none; }
.brand__mark {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--btn-text);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.02em;
}
.brand__name { font-weight: 600; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand__name small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); }

.nav { display: flex; align-items: center; gap: var(--s1); margin-left: auto; }
.nav a {
  font-size: 0.95rem; font-weight: 500; color: var(--text-dim); text-decoration: none;
  padding: 8px 12px; border-radius: var(--r-sm); line-height: 1;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--accent-ink); }
.header-actions { display: flex; align-items: center; gap: var(--s2); }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.icon-btn .ico { width: 18px; height: 18px; }
.theme-toggle .ico--moon { display: none; }
[data-theme="dark"] .theme-toggle .ico--sun,
:root:not([data-theme="light"]) .theme-toggle .ico--sun { }
.nav-toggle { display: none; }

/* Floating theme toggle (bottom-right) */
.theme-fab {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: 240;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-fab:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-2px); }
.theme-fab:active { transform: translateY(0); }
.theme-fab .ico { width: 20px; height: 20px; }
@media (max-width: 560px) { .theme-fab { right: var(--s4); bottom: var(--s4); width: 46px; height: 46px; } }

/* Compact header on small phones: tighter padding, shrinkable brand, no tagline */
@media (max-width: 480px) {
  .site-header__inner { padding-inline: var(--s4); gap: var(--s3); }
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand__name { font-size: 0.88rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand__name small { display: none; }
  .nav a { padding: 14px 16px; }
}
/* Narrow screens: compact one-line buttons (labels never split onto two rows) */
@media (max-width: 560px) {
  .btn { white-space: nowrap; }
  .btn--lg { min-height: 48px; font-size: 0.95rem; padding-inline: 16px; }
  .btn--lg .ico { width: 16px; height: 16px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico--sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .ico--moon { display: block; }
}
[data-theme="dark"] .theme-toggle .ico--sun { display: none; }
[data-theme="dark"] .theme-toggle .ico--moon { display: block; }
[data-theme="light"] .theme-toggle .ico--sun { display: block; }
[data-theme="light"] .theme-toggle .ico--moon { display: none; }

/* Mobile nav (engages at 1000px, before the full desktop header would overflow ~937px).
   Staggered fold-out menu, ported from the PVC-Webapp header: items fold down
   from the header one after another (3D fold) instead of one solid panel.
   Each link is its own opaque bar; the container is transparent so nothing
   appears except the bars themselves. Bar height is EXACTLY 50px (14+14
   padding + 21px line + 1px border): the perspective keeps each bar on its
   own GPU layer, and fractional heights show hairline seams between bars on
   high-density phones. If a nav link is added or removed, extend BOTH
   nth-child delay lists (open cascade top-down, close cascade bottom-up). */
@media (max-width: 1000px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0; z-index: 99;
    flex-direction: column; align-items: stretch; gap: 0;
    background: transparent; border-bottom: 0;
    padding: 0; margin: 0; box-shadow: none;
    visibility: hidden;
    transition: visibility 0s linear 0.42s;
    max-height: calc(100vh - var(--header-h)); overflow-y: auto;
    perspective: 900px;
  }
  .nav.is-open { visibility: visible; transition: visibility 0s; }
  .nav a {
    padding: 14px 24px; font-size: 16px; line-height: 21px; border-radius: 0;
    background: var(--bg); border-bottom: 1px solid var(--border-soft);
    opacity: 0; transform: rotateX(-72deg); transform-origin: 50% 0;
    transition: transform 0.16s var(--ease), opacity 0.13s var(--ease);
  }
  .nav a:last-child { border-bottom: 1px solid var(--border); }
  /* Closing plays the cascade backwards: last item folds up first, first item last. */
  .nav a:nth-child(1) { transition-delay: 0.25s; }
  .nav a:nth-child(2) { transition-delay: 0.20s; }
  .nav a:nth-child(3) { transition-delay: 0.15s; }
  .nav a:nth-child(4) { transition-delay: 0.10s; }
  .nav a:nth-child(5) { transition-delay: 0.05s; }
  .nav a:nth-child(6) { transition-delay: 0s; }
  /* Opening cascades top-down. */
  .nav.is-open a { opacity: 1; transform: rotateX(0); transition: transform 0.26s var(--ease), opacity 0.18s var(--ease); }
  .nav.is-open a:nth-child(1) { transition-delay: 0.02s; }
  .nav.is-open a:nth-child(2) { transition-delay: 0.07s; }
  .nav.is-open a:nth-child(3) { transition-delay: 0.12s; }
  .nav.is-open a:nth-child(4) { transition-delay: 0.17s; }
  .nav.is-open a:nth-child(5) { transition-delay: 0.22s; }
  .nav.is-open a:nth-child(6) { transition-delay: 0.27s; }
  @media (prefers-reduced-motion: reduce) {
    .nav, .nav a { transition: none !important; }
    .nav a { transform: none !important; }
  }
  .header-actions .btn--primary { display: none; }
}

/* -------------------------------------------------------------------------
   7. Hero (control-surface)
   ------------------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; padding-block: clamp(var(--s8), 7vw, 132px); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(120% 90% at 70% 0%, #000 30%, transparent 78%);
          mask-image: radial-gradient(120% 90% at 70% 0%, #000 30%, transparent 78%);
  opacity: 0.6;
}
.hero__grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(var(--s6), 5vw, var(--s9));
  align-items: center;
}
.hero__title { font-size: var(--fs-hero); line-height: var(--lh-tight); letter-spacing: -0.03em; font-weight: 600; }
.hero__title .em { color: var(--accent-2); }
.hero__sub { margin-top: var(--s5); max-width: 46ch; }
.hero__cta { margin-top: var(--s6); display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.hero__meta { margin-top: var(--s5); display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }

/* Readout panel */
.readout {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s6); box-shadow: var(--shadow-2);
}
.readout__head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: var(--fs-mono); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint);
  padding-bottom: var(--s3); border-bottom: 1px dashed var(--border);
}
.readout__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); padding-block: var(--s4); }
.readout__label { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.readout__val { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.readout__from { font-size: 1.4rem; color: var(--text-dim); }
.readout__to { font-size: clamp(2.4rem, 5vw, 3.4rem); color: var(--readout); line-height: 1; }
.readout__to span { font-size: 0.42em; color: var(--text-dim); margin-left: 4px; }
.readout__bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: var(--s2); }
.readout__bar i { display: block; height: 100%; width: 4%; border-radius: 999px; background: var(--accent); }
.readout__foot { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s4); font-size: var(--fs-small); color: var(--text-dim); }
.readout__foot .pct { font-family: var(--font-mono); font-weight: 600; color: var(--accent-ink); }

@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; gap: var(--s7); }
  .readout, .hero__media { order: 2; }
}

/* Compact inline readout (hero left column) */
.hero-readout {
  display: inline-flex; align-items: center; gap: var(--s3);
  flex-wrap: nowrap; white-space: nowrap; max-width: 100%;
  margin-top: var(--s5); padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); font-family: var(--font-mono);
}
.hero-readout .hr-from { color: var(--text-dim); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.hero-readout .ico { width: 18px; height: 18px; color: var(--text-faint); }
.hero-readout .hr-to { color: var(--readout); font-weight: 600; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.hero-readout .hr-tag { font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); border-left: 1px solid var(--border); padding-left: var(--s3); }
/* Compact readout on small phones (after the base child rules so it wins) */
@media (max-width: 480px) {
  .hero-readout { gap: var(--s2); padding: 8px 12px; }
  .hero-readout .hr-from { font-size: 0.88rem; }
  .hero-readout .hr-to { font-size: 1.2rem; }
  .hero-readout .hr-tag { font-size: 0.56rem; padding-left: var(--s2); }
  .hero-readout .ico { width: 14px; height: 14px; }
}

/* Hero screenshot (LCP image) */
.hero__media { position: relative; }
.hero__media .frame { transform: perspective(1500px) rotateY(-5deg) rotateX(1.5deg); transition: transform var(--dur) var(--ease); }
.hero__media .frame:hover { transform: perspective(1500px) rotateY(-2deg) rotateX(0.5deg); }
@media (max-width: 860px) { .hero__media .frame, .hero__media .frame:hover { transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero__media .frame, .hero__media .frame:hover { transform: none; } }

/* Two-up showcase */
.showcase { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: var(--s5); align-items: end; }
@media (max-width: 820px) { .showcase { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------------
   8. Generic content blocks
   ------------------------------------------------------------------------- */
.section-head { max-width: 64ch; margin-bottom: var(--s7); }
.section-head h2 { margin-top: var(--s3); }
.section-head p { margin-top: var(--s3); color: var(--text-dim); }

/* Numbered ladder (replaces the three-equal-cards trope) */
.ladder { display: grid; gap: var(--s2); counter-reset: step; }
.ladder__item {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s5);
  align-items: start; padding: var(--s5) var(--s2);
  border-top: 1px solid var(--border);
}
.ladder__item:last-child { border-bottom: 1px solid var(--border); }
.ladder__num {
  counter-increment: step; font-family: var(--font-mono); font-weight: 600;
  font-size: 0.95rem; color: var(--accent-ink);
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-2);
}
.ladder__num::before { content: counter(step, decimal-leading-zero); }
.ladder__body h3 { font-size: var(--fs-h3); }
.ladder__body p { margin-top: var(--s2); color: var(--text-dim); max-width: 60ch; }

/* Spec list (key/value, mono) */
.specs { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.specs__row { display: grid; grid-template-columns: 220px 1fr; gap: var(--s4); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }
.specs__row:first-child { border-top: 0; }
.specs__row dt { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.specs__row dd { color: var(--text); }
@media (max-width: 620px) { .specs__row { grid-template-columns: 1fr; gap: var(--s1); } }

/* Feature panels grid (bordered, not nested) */
.panel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); }
.panel {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s6);
  background: var(--surface); position: relative; text-decoration: none; color: inherit; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.panel:hover {
  border-color: color-mix(in oklab, var(--accent) 62%, var(--border));
  transform: translateY(-3px);
  background: color-mix(in oklab, var(--accent) 6%, var(--surface));
  box-shadow: 0 12px 32px color-mix(in oklab, var(--accent) 24%, transparent);
}
.panel__cta {
  margin-top: var(--s5); display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: var(--fs-mono); font-weight: 600;
  letter-spacing: 0.03em; color: var(--accent-ink);
}
.panel__cta::after { content: "\2192"; transition: transform var(--dur) var(--ease); }
.panel:hover .panel__cta::after { transform: translateX(5px); }
@media (max-width: 880px) { .panel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .panel-grid { grid-template-columns: 1fr; } }
.panel__tag { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-ink); }
.panel h3 { margin-top: var(--s2); font-size: var(--fs-h3); color: var(--text); transition: color var(--dur-fast) var(--ease); }
.panel:hover h3 { color: var(--accent-ink); }
.panel p { margin-top: var(--s3); color: var(--text-dim); }
.panel__list { margin-top: var(--s4); list-style: none; padding: 0; display: grid; gap: var(--s2); }
.panel__list li { position: relative; padding-left: var(--s5); color: var(--text-dim); font-size: 0.95rem; }
.panel__list li::before { content: "\2192"; position: absolute; left: 0; color: var(--accent-ink); font-family: var(--font-mono); }

/* Framed screenshot */
.frame {
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-2);
}
.frame__bar { display: flex; align-items: center; gap: 6px; padding: 10px var(--s4); border-bottom: 1px solid var(--border); background: var(--bg-2); }
.frame__bar .d { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.frame__bar .t { margin-left: var(--s3); font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); letter-spacing: 0.04em; }
.frame img { width: 100%; height: auto; }
.figcap { margin-top: var(--s3); font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-faint); text-align: center; }

/* Callout / band */
.band {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 60%),
    var(--surface);
  padding: clamp(var(--s6), 5vw, var(--s8));
}
.band__grid { display: grid; grid-template-columns: 1.4fr auto; gap: var(--s6); align-items: center; }
@media (max-width: 720px) { .band__grid { grid-template-columns: 1fr; } }

/* Q&A / docs prose */
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--s8); scroll-margin-top: calc(var(--header-h) + var(--s5)); }
.prose h3 { margin-top: var(--s6); scroll-margin-top: calc(var(--header-h) + var(--s5)); }
.prose p { margin-top: var(--s4); color: var(--text); }
.prose ul, .prose ol { margin-top: var(--s4); display: grid; gap: var(--s2); }
.prose li { color: var(--text); }
.prose code {
  font-family: var(--font-mono); font-size: 0.85em; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px;
}
.anchor-h { scroll-margin-top: calc(var(--header-h) + var(--s5)); }

/* Doc section card with target highlight for cross-page search jumps */
.doc-section { scroll-margin-top: calc(var(--header-h) + var(--s4)); padding-top: var(--s2); }
.flash { animation: flash 1.6s var(--ease) 1; }
@keyframes flash {
  0%, 100% { background: transparent; }
  12% { background: color-mix(in oklab, var(--accent) 18%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* -------------------------------------------------------------------------
   9. Footer
   ------------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-2); margin-top: var(--s7); }
.site-footer__inner { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: var(--s7); padding-block: var(--s8) var(--s6); }
.site-footer h4 { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; margin-bottom: var(--s3); }
.site-footer ul { list-style: none; padding: 0; display: grid; gap: var(--s2); }
.site-footer a { color: var(--text-dim); text-decoration: none; }
.site-footer a:hover { color: var(--accent-ink); }
.footer-about p { color: var(--text-dim); margin-top: var(--s3); max-width: 40ch; font-size: 0.95rem; }
.footer-bottom {
  border-top: 1px solid var(--border); padding-block: var(--s4) var(--s6);
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: center; justify-content: space-between;
  font-size: var(--fs-small); color: var(--text-faint);
}
.footer-bottom .mono { font-size: var(--fs-mono); }
@media (max-width: 760px) { .site-footer__inner { grid-template-columns: 1fr 1fr; gap: var(--s6); } .footer-about { grid-column: 1 / -1; } }

/* -------------------------------------------------------------------------
   10. Search overlay
   ------------------------------------------------------------------------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 300; display: none;
  background: oklch(0.15 0.01 248 / 0.55);
  padding: clamp(var(--s6), 12vh, 140px) var(--s5) var(--s5);
}
.search-overlay.is-open { display: block; }
.search-box {
  max-width: 640px; margin-inline: auto; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden;
}
.search-field { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.search-field .ico { width: 20px; height: 20px; color: var(--text-faint); flex: none; }
.search-field input {
  flex: 1; border: 0; background: transparent; color: var(--text);
  font-family: var(--font-sans); font-size: 1.1rem; outline: none; min-height: 28px;
}
.search-field kbd {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px;
}
.search-results { max-height: min(56vh, 460px); overflow-y: auto; padding: var(--s2); }
.search-results:empty::after { content: "Type to search features and docs..."; display: block; padding: var(--s5); color: var(--text-faint); font-family: var(--font-mono); font-size: var(--fs-small); }
.search-result {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center;
  width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
  padding: var(--s3) var(--s4); border-radius: var(--r); color: var(--text);
}
.search-result:hover, .search-result.is-active { background: var(--surface); }
.search-result__kind { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); border: 1px solid var(--border); border-radius: 4px; padding: 3px 7px; }
.search-result__txt b { display: block; font-weight: 600; font-size: 0.98rem; }
.search-result__txt span { display: block; color: var(--text-faint); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42ch; }
.search-result__go { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-faint); }
.search-empty { padding: var(--s5); color: var(--text-faint); font-family: var(--font-mono); font-size: var(--fs-small); }

/* -------------------------------------------------------------------------
   12. Scroll reveal (site animations). Stagger via delay utility classes.
   ------------------------------------------------------------------------- */
html.js .reveal { transform: translateY(22px); transition: transform 0.55s var(--ease); }
html.js .reveal.is-visible { transform: none; }
.d-1 { transition-delay: 60ms; }
.d-2 { transition-delay: 120ms; }
.d-3 { transition-delay: 180ms; }
.d-4 { transition-delay: 240ms; }
.d-5 { transition-delay: 300ms; }
.d-6 { transition-delay: 360ms; }
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { transform: none; transition: none; }
  .reveal, .d-1, .d-2, .d-3, .d-4, .d-5, .d-6 { transition-delay: 0ms; }
}

/* Page-to-page navigation fade (JS-driven; no-JS and reduced motion load instantly).
   Out: body.is-leaving fades to 0, then the browser navigates.
   In: html.page-enter holds the new page at 0 until app.js releases it. */
html.js.page-enter body { opacity: 0; }
body.page-fading { transition: opacity 0.26s var(--ease); }
html.js body.is-leaving { opacity: 0; transition: opacity 0.22s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  html.js.page-enter body { opacity: 1; }
  body.page-fading, html.js body.is-leaving { transition: none; }
}

/* Hero load-in (one orchestrated moment). Transform-only so content is always
   at full opacity, even if the animation timeline never advances. */
html.js .hero .load-in { transform: translateY(16px); animation: loadIn 0.62s var(--ease) forwards; }
.hero .load-in.l-1 { animation-delay: 0.05s; }
.hero .load-in.l-2 { animation-delay: 0.14s; }
.hero .load-in.l-3 { animation-delay: 0.23s; }
.hero .load-in.l-4 { animation-delay: 0.32s; }
.hero .load-in.l-5 { animation-delay: 0.42s; }
@keyframes loadIn { from { transform: translateY(16px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  html.js .hero .load-in { transform: none; animation: none; }
}

/* -------------------------------------------------------------------------
   13. Page hero (interior pages)
   ------------------------------------------------------------------------- */
.page-hero { padding-block: clamp(var(--s7), 6vw, var(--s9)) var(--s6); border-bottom: 1px solid var(--border); position: relative; }
.page-hero h1 { margin-top: var(--s3); max-width: 18ch; }
.page-hero p { margin-top: var(--s4); max-width: 56ch; }
.breadcrumb { display: flex; gap: var(--s2); font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-faint); list-style: none; padding: 0; }
.breadcrumb a { color: var(--text-faint); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-ink); }
.breadcrumb li::after { content: "/"; margin-left: var(--s2); color: var(--border); }
.breadcrumb li:last-child::after { content: ""; }

/* Two-column docs layout with sticky TOC */
.doc-layout { display: grid; grid-template-columns: 230px 1fr; gap: clamp(var(--s6), 5vw, var(--s8)); align-items: start; }
.toc { position: sticky; top: calc(var(--header-h) + var(--s4)); }
.toc h4 { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--s3); }
.toc ul { list-style: none; padding: 0; display: grid; gap: 1px; border-left: 1px solid var(--border); position: relative; }
.toc a { display: block; padding: 6px var(--s4); color: var(--text-dim); text-decoration: none; font-size: 0.9rem; border-left: 2px solid transparent; margin-left: -1px; transition: color var(--dur-fast) var(--ease); }
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--accent-ink); }
/* Single sliding indicator (built in js/app.js). Animates its position and
   height to the active item, so it scrolls along the list as you navigate. */
.toc__marker { position: absolute; left: -1px; width: 2px; top: 0; height: 0; background: var(--accent); border-radius: 2px; opacity: 0; transform: translateY(0); transition: transform 0.5s var(--ease), height 0.5s var(--ease), opacity var(--dur) var(--ease); pointer-events: none; }
.toc__marker.is-ready { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toc__marker { transition: opacity var(--dur) var(--ease); } }
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; } .toc { position: static; margin-bottom: var(--s5); } }

/* Download mirror cards */
.mirrors { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
@media (max-width: 720px) { .mirrors { grid-template-columns: 1fr; } }
.mirror { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s6); background: var(--surface); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.mirror--primary { border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); }
.mirror__kind { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-ink); }
.mirror h3 { font-size: var(--fs-h3); }
.mirror p { color: var(--text-dim); font-size: 0.95rem; flex: 1; }
.mirror__meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-faint); min-width: 0; }
.mirror__meta span { overflow-wrap: anywhere; }
.cooldown-note { font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--notice); min-height: 1.2em; }

/* Donate tiers */
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.tier { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: var(--s5); text-align: center; cursor: pointer; transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); font-family: var(--font-mono); }
.tier:hover { border-color: var(--accent); transform: translateY(-2px); }
.tier b { display: block; font-size: 1.4rem; color: var(--readout); }
.tier span { display: block; font-size: 0.78rem; color: var(--text-faint); margin-top: 4px; }
.processor-row { display: flex; flex-wrap: wrap; gap: var(--s3); }
.processor {
  flex: 1 1 180px; display: flex; align-items: center; gap: var(--s3);
  border: 1px dashed var(--border); border-radius: var(--r); padding: var(--s4) var(--s5);
  color: var(--text-dim); background: var(--bg-2);
}
.processor .ph { width: 30px; height: 30px; border-radius: var(--r-sm); background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--bg-2) 6px, var(--bg-2) 12px); flex: none; }

/* Forms */
.form { display: grid; gap: var(--s4); max-width: 540px; }
.field { display: grid; gap: var(--s2); }
.field label { font-size: 0.9rem; font-weight: 500; }
.field .req { color: var(--warn); }
.field input, .field textarea, .field select {
  font-family: var(--font-sans); font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; min-height: 46px; width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); outline: none; }
.field--hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-note { font-size: var(--fs-small); color: var(--text-faint); }
.form-status { font-family: var(--font-mono); font-size: var(--fs-small); padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid var(--border); display: none; }
.form-status.is-show { display: block; }
.form-status.is-ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 45%, var(--border)); }

/* Inline status tag dots echoing the app queue */
.tagline-list { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); list-style: none; padding: 0; font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-dim); }
.tagline-list li { display: inline-flex; align-items: center; gap: var(--s2); }
.tagline-list .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tagline-list .sw--ok { background: var(--ok); }
.tagline-list .sw--skip { background: var(--text-faint); }
.tagline-list .sw--fail { background: var(--warn); }
.tagline-list .sw--notice { background: var(--notice); }

/* Utilities */
.stack-lg > * + * { margin-top: var(--s5); }
.center { text-align: center; }
.mt-block { margin-top: var(--s7); }
.error-404 { max-width: 62ch; margin-inline: auto; padding-block: var(--s6); }
.error-404 .eyebrow { justify-content: center; }
.error-404 #four04 { font-size: clamp(4.5rem, 13vw, 9rem); line-height: 1; margin-block: var(--s4) var(--s2); }
.error-404 .lead { margin-inline: auto; max-width: 48ch; }
.hero__cta.center-cta { justify-content: center; }

/* Closing call-to-action bands: tighter rhythm above and below */
.section:has(.band) { padding-block: clamp(var(--s6), 4vw, var(--s7)); }

/* 404: all three actions identical size */
.error-404 .hero__cta { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); max-width: 620px; margin: var(--s6) auto 0; }
@media (max-width: 600px) { .error-404 .hero__cta { grid-template-columns: 1fr; max-width: 300px; } }

/* Search filters follow the viewport once scrolled past, on mobile widths
   only (JS-gated at 900px); on desktop both bars stay in place. */
.feat-filter.is-stuck {
  position: fixed;
  top: calc(var(--header-h) + var(--s3));
  left: var(--s5); right: var(--s5);
  width: auto; /* let the left/right insets size it; base width:100% would overflow */
  max-width: 560px; margin: 0 auto;
  z-index: 90;
  box-shadow: var(--shadow-2);
}
html.has-banner .feat-filter.is-stuck { top: calc(var(--header-h) + var(--banner-h, 44px) + var(--s3)); }
/* Higher specificity than the sidebar docking rule (.toc .feat-filter), which
   sets width:100% and margin-top and would otherwise win and overflow phones. */
.toc .feat-filter.is-stuck { width: auto; max-width: 560px; margin: 0 auto; }

/* Mobile notice banner: slides in under the header; overlays, no layout shift */
.notice-banner {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 95;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transform: translateY(calc(-100% - var(--header-h)));
  transition: transform var(--dur) var(--ease);
}
.notice-banner.is-open { transform: none; }
.notice-banner__inner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "icon text btn close";
  align-items: center; gap: var(--s3);
  max-width: var(--maxw); margin-inline: auto; padding: 10px var(--s4);
}
.notice-banner__inner > .ico { grid-area: icon; }
.notice-banner p { grid-area: text; }
.notice-banner .btn { grid-area: btn; }
.notice-banner__close { grid-area: close; }
/* Phone: text row on top; X sits directly under the phone icon, button past it */
@media (max-width: 560px) {
  .notice-banner__inner { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon text" "close btn"; }
  .notice-banner__inner > .ico, .notice-banner__close { justify-self: center; }
  .notice-banner .btn { justify-self: start; }
}
.notice-banner .ico { width: 20px; height: 20px; color: var(--accent-ink); flex: none; }
.notice-banner p { margin: 0; font-size: 0.86rem; line-height: 1.4; color: var(--text-dim); flex: 1 1 200px; min-width: 0; }
.notice-banner p strong { color: var(--text); display: block; }
.notice-banner .btn { min-height: 36px; padding: 6px 14px; font-size: 0.86rem; }
.notice-banner__close {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  border: 0; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: var(--r-sm);
}
.notice-banner__close:hover { color: var(--text); background: var(--bg-2); }
.notice-banner__close .ico { width: 16px; height: 16px; color: currentColor; }
@media (prefers-reduced-motion: reduce) {
  .notice-banner { transition: opacity var(--dur) ease; transform: none; opacity: 0; visibility: hidden; }
  .notice-banner.is-open { opacity: 1; visibility: visible; }
}
.divider { height: 1px; background: var(--border); border: 0; margin-block: var(--s7); }
.tag-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tag { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.big-num { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--readout); }

/* -------------------------------------------------------------------------
   14. Features / reference layout
   ------------------------------------------------------------------------- */
.jump { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.jump a {
  font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px;
  text-decoration: none; transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.jump a:hover { border-color: var(--accent); color: var(--accent-ink); }
.feat-section {
  scroll-margin-top: calc(var(--header-h) + 24px);
  padding-block: clamp(var(--s7), 5vw, var(--s8));
  border-top: 1px solid var(--border);
}
.feat-grid { display: grid; grid-template-columns: 300px 1fr; gap: clamp(var(--s6), 5vw, var(--s8)); align-items: start; }
@media (max-width: 860px) { .feat-grid { grid-template-columns: 1fr; gap: var(--s5); } }
.feat-aside { position: sticky; top: calc(var(--header-h) + var(--s4)); }
@media (max-width: 860px) { .feat-aside { position: static; } }
.feat-aside h2 { font-size: var(--fs-h2); margin-top: var(--s3); }
.feat-aside p { margin-top: var(--s3); color: var(--text-dim); font-size: 0.95rem; }
.feat-num { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.14em; color: var(--text-faint); }
.sub { scroll-margin-top: calc(var(--header-h) + 24px); padding-block: var(--s5); border-top: 1px dashed var(--border); }
.sub:first-child { border-top: 0; padding-top: 0; }
.sub h3 { font-size: var(--fs-h3); }
.sub > p { margin-top: var(--s2); color: var(--text-dim); max-width: 64ch; }
.how {
  margin-top: var(--s3); font-family: var(--font-mono); font-size: var(--fs-small);
  color: var(--text-faint); display: flex; gap: var(--s2); align-items: baseline;
}
.how b { color: var(--accent-ink); font-weight: 500; flex: none; }
.note {
  display: flex; gap: var(--s3); margin-top: var(--s4); padding: var(--s4) var(--s5);
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r);
  background: var(--surface); font-size: 0.95rem; color: var(--text-dim);
}
.note svg { width: 18px; height: 18px; color: var(--accent-ink); flex: none; margin-top: 2px; }

/* =========================================================================
   15. v2 refinement: warmth, depth, hierarchy, per-page identity
   ========================================================================= */

/* Extra tokens (light defaults) */
:root {
  --surface-hi: oklch(0.99 0.004 256);
  --accent-2-ink: #cf2f2f;
  --elev: color-mix(in oklab, var(--surface) 55%, var(--bg));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-hi: oklch(0.30 0.020 264);
    --accent-2-ink: #f2706f;
    --elev: color-mix(in oklab, var(--surface) 70%, var(--bg));
  }
}
[data-theme="dark"] {
  --surface-hi: oklch(0.30 0.020 264);
  --accent-2-ink: #f2706f;
  --elev: color-mix(in oklab, var(--surface) 70%, var(--bg));
}

/* Ambient warmth + depth behind all content (cool glow top-right, warm bottom-left) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(54% 46% at 92% -12%, color-mix(in oklab, var(--accent) 20%, transparent), transparent 70%),
    radial-gradient(46% 42% at -12% 114%, color-mix(in oklab, var(--accent-2) 16%, transparent), transparent 70%);
}
[data-theme="light"] body::before { opacity: 0.5; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) body::before { opacity: 0.5; } }

/* Page accent identity: Docs runs warm (ember/red), Home + Features stay cool (blue).
   Scoped to <main> so the header brand, nav and footer stay consistent. */
main.theme-warm {
  --accent: var(--accent-2);
  --accent-ink: var(--accent-2-ink);
  --link: var(--accent-2-ink);
  --focus: var(--accent-2);
  --btn-bg: var(--accent-2);
  --btn-bg-hover: color-mix(in oklab, var(--accent-2) 80%, var(--text));
  --btn-text: oklch(0.99 0.01 27);
}
[data-theme="dark"] main.theme-warm, :root:not([data-theme="light"]) main.theme-warm { --btn-text: oklch(0.99 0.01 27); }

/* Card depth: subtle top sheen + inset highlight, richer hover */
.panel, .mirror, .cap, .meta-card, .stat-card {
  box-shadow: inset 0 1px 0 color-mix(in oklab, var(--surface-hi) 55%, transparent), var(--shadow-1);
}

/* Section variety */
.section--alt { background: var(--elev); border-block: 1px solid var(--border); }
.rule-accent { width: 34px; height: 2px; background: var(--accent); border: 0; margin: 0 0 var(--s4); border-radius: 2px; }

/* Icon tiles + inline icons */
.ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.ic-tile {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border-radius: 9px; color: var(--accent-ink);
  background: color-mix(in oklab, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
}
.ic-tile .ic { width: 21px; height: 21px; }

/* Stat / figures band */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.stat { background: var(--surface); padding: var(--s5) var(--s5) var(--s5) var(--s5); }
.stat b { display: block; font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; font-size: clamp(1.5rem, 1rem + 2vw, 2.2rem); color: var(--readout); line-height: 1.05; }
.stat:nth-child(odd) b { color: var(--accent-ink); }
.stat:nth-child(even) b { color: var(--accent-2-ink); }
.stat span { display: block; margin-top: 6px; color: var(--text-dim); font-size: 0.88rem; }

/* Callouts (richer than .note) */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s4); align-items: start;
  padding: var(--s5); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); margin-top: var(--s5);
}
.callout h4 { font-size: 1rem; }
.callout p { margin-top: 4px; color: var(--text-dim); font-size: 0.95rem; }
.callout--tip { border-left: 3px solid var(--accent); }
.callout--warn { border-left: 3px solid var(--warn); }
.callout--warn .ic-tile { color: var(--warn); background: color-mix(in oklab, var(--warn) 14%, var(--surface)); border-color: color-mix(in oklab, var(--warn) 30%, var(--border)); }

/* Capability cards (Features: scannable, icon + benefit) */
.cap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.cap-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .cap-grid--3 { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .cap-grid { grid-template-columns: 1fr; } }

/* Search trigger (Features hero): looks like a search field, opens the overlay */
.search-trigger {
  display: flex; align-items: center; gap: var(--s3); width: 100%; max-width: 560px;
  margin-top: var(--s6); padding: 14px var(--s4); min-height: 52px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: var(--text-faint); font-family: var(--font-sans); font-size: 1rem; cursor: text; text-align: left;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.search-trigger:hover { border-color: color-mix(in oklab, var(--accent) 50%, var(--border)); }
.search-trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); outline: none; }
.search-trigger .ico { width: 20px; height: 20px; color: var(--accent-ink); flex: none; }
.search-trigger .st-label { flex: 1; }
.search-trigger kbd { font-family: var(--font-mono); font-size: 0.7rem; border: 1px solid var(--border); border-radius: 5px; padding: 3px 7px; color: var(--text-faint); flex: none; }
@media (max-width: 520px) { .search-trigger kbd { display: none; } }

/* In-page feature filter */
.feat-filter {
  display: flex; align-items: center; gap: var(--s3); width: 100%; max-width: 560px;
  margin-top: var(--s6); padding: 8px var(--s4); min-height: 52px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.feat-filter:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.feat-filter .ico { width: 20px; height: 20px; color: var(--accent-ink); flex: none; }
.feat-filter input { flex: 1; border: 0; background: transparent; color: var(--text); font-family: var(--font-sans); font-size: 1rem; outline: none; min-height: 30px; }
.feat-filter input::placeholder { color: var(--text-faint); }
.feat-filter input::-webkit-search-cancel-button { -webkit-appearance: none; }
.feat-filter__clear { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: 7px; }
.feat-filter__clear[hidden] { display: none; }
.feat-filter__clear:hover { color: var(--text); background: var(--bg-2); }
.feat-filter__clear .ic { width: 16px; height: 16px; }
.feat-filter__status { margin-top: var(--s3); font-family: var(--font-mono); font-size: var(--fs-small); color: var(--text-dim); min-height: 1.3em; }
.cap.is-hidden, .group.is-hidden { display: none; }
/* Docs in-page filter */
.dsec-hidden { display: none !important; }
.toc li.is-hidden { display: none; }
/* Docs filter docked at the bottom of the sticky TOC. Same shape, font, and
   size as the Features bar (base .feat-filter); only the accent color (via
   the page's warm theme) and the placeholder text differ. */
.toc .feat-filter { margin-top: var(--s5); }
.cap {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s4); align-items: start;
  padding: var(--s5); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.cap:hover { border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); transform: translateY(-2px); }
.cap h3 { font-size: 1.06rem; letter-spacing: -0.01em; }
.cap p { margin-top: 5px; color: var(--text-dim); font-size: 0.93rem; line-height: 1.5; }

/* Feature group heading */
.group { margin-top: clamp(var(--s7), 5vw, var(--s9)); }
.group:first-of-type { margin-top: 0; }
.group__head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s5); }
.group__n { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: var(--accent-ink); border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border)); border-radius: 7px; padding: 4px 9px; }
.group__head h2 { font-size: var(--fs-h3); }
.group__head .line { flex: 1; height: 1px; background: var(--border); }

/* Distinct interior heroes */
.page-hero { overflow: hidden; }
.page-hero > .wrap { position: relative; z-index: 1; }
.page-hero--features::before, .page-hero--docs::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
}
.page-hero--features::before { background: radial-gradient(58% 90% at 100% 0%, color-mix(in oklab, var(--accent) 15%, transparent), transparent 62%); }
.page-hero--docs::before {
  background:
    radial-gradient(50% 90% at 100% 0%, color-mix(in oklab, var(--accent-2) 16%, transparent), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 44px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent);
          mask-image: linear-gradient(180deg, #000, transparent);
}

/* Docs masthead (two-column with a metadata card) */
.masthead { display: flex; flex-wrap: wrap; gap: clamp(var(--s5), 3vw, var(--s7)); align-items: flex-end; }
.masthead > div { flex: 1 1 280px; min-width: 0; }
.masthead > .meta-card { flex: 1 1 230px; }
.meta-card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: var(--s5); }
.meta-card h4 { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--s3); }
.meta-card dl { display: grid; gap: 0; }
.meta-card .row { display: flex; justify-content: space-between; gap: var(--s4); padding: 9px 0; border-top: 1px solid var(--border-soft); font-family: var(--font-mono); font-size: 0.82rem; }
.meta-card .row:first-of-type { border-top: 0; }
.meta-card dt { color: var(--text-faint); }
.meta-card dd { color: var(--text); text-align: right; }

/* Features hero spec trio */
.hero-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; margin-top: var(--s6); max-width: 520px; }
.hero-trio div { background: var(--surface); padding: var(--s4) var(--s5); }
.hero-trio b { display: block; font-family: var(--font-mono); font-weight: 600; color: var(--readout); font-size: 1.15rem; }
.hero-trio span { display: block; font-size: 0.78rem; color: var(--text-faint); margin-top: 3px; }

/* Mechanism "flow" (Docs: explain how it works as numbered steps) */
.flow { display: grid; gap: 0; margin-top: var(--s5); }
.flow__step { display: grid; grid-template-columns: auto 1fr; gap: var(--s4); padding: var(--s4) 0; position: relative; }
.flow__step:not(:last-child) .flow__n::after { content: ""; position: absolute; top: 34px; left: 50%; width: 1px; height: calc(100% - 24px); background: var(--border); transform: translateX(-0.5px); }
.flow__n { position: relative; width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: color-mix(in oklab, var(--accent) 16%, var(--surface)); border: 1px solid color-mix(in oklab, var(--accent) 32%, var(--border)); color: var(--accent-ink); font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; }
.flow__body { padding-top: 3px; }
.flow__body h4 { font-size: 1rem; }
.flow__body p { margin-top: 4px; color: var(--text-dim); font-size: 0.95rem; }

/* Docs prose niceties */
.prose h2 .anchor-num { font-family: var(--font-mono); font-size: 0.6em; color: var(--accent-ink); margin-right: 10px; font-weight: 600; vertical-align: middle; }
.prose .lede { font-size: 1.1rem; color: var(--text); }
.prose hr.divider { margin-block: var(--s6); }
.term { font-family: var(--font-mono); font-size: 0.85em; color: var(--accent-ink); }
kbd.key { font-family: var(--font-mono); font-size: 0.8em; background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; color: var(--text); }

@media (max-width: 560px) {
  .hero-trio { grid-template-columns: 1fr; }
  .stat b { font-size: 1.6rem; }
}

/* -------------------------------------------------------------------------
   16. Feature detail overlays (Features page)
   Every capability card is clickable and opens an expanded detail view
   with a media slot (GIF or screenshot, added later per feature).
   ------------------------------------------------------------------------- */
.cap[data-detail] { cursor: pointer; position: relative; padding-right: 48px; }
.cap[data-detail]::after {
  content: "+";
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 16px; font-weight: 500; line-height: 1;
  color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 7px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.cap[data-detail]:hover::after, .cap[data-detail]:focus-visible::after {
  color: var(--btn-text); background: var(--btn-bg); border-color: var(--btn-bg);
}
.feat-hint { margin-top: var(--s3); font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-faint); }

.cap-overlay {
  position: fixed; inset: 0; z-index: 300; display: none;
  background: oklch(0.15 0.01 262 / 0.55);
  padding: clamp(var(--s5), 8vh, 90px) var(--s5) var(--s7);
  overflow-y: auto;
}
.cap-overlay.is-open { display: block; }
.cap-modal {
  max-width: 700px; margin: 0 auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); overflow: hidden;
}
.cap-modal__head { display: flex; align-items: center; gap: var(--s4); padding: var(--s5) var(--s6); border-bottom: 1px solid var(--border); }
.cap-modal__titles { flex: 1; min-width: 0; }
.cap-modal__tag { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-ink); }
.cap-modal__titles h3 { font-size: 1.3rem; margin-top: 2px; }
.cap-modal__close {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: transparent;
  color: var(--text-dim); cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.cap-modal__close:hover { color: var(--text); border-color: var(--accent); }
.cap-modal__close .ic { width: 16px; height: 16px; }
.cap-modal__media {
  margin: var(--s5) var(--s6) 0; aspect-ratio: 16 / 9;
  display: grid; place-items: center; text-align: center; padding: var(--s4);
  border: 1px dashed var(--border); border-radius: var(--r);
  background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 10px, var(--bg-2) 10px, var(--bg-2) 20px);
}
.cap-modal__media span { font-family: var(--font-mono); font-size: var(--fs-mono); color: var(--text-faint); max-width: 36ch; }
.cap-modal__body { padding: var(--s5) var(--s6) var(--s6); }
.cap-modal__body p { margin-top: var(--s3); color: var(--text); }
.cap-modal__body p:first-child { margin-top: 0; }
.cap-modal__body .cap-modal__how { display: flex; gap: var(--s3); align-items: baseline; margin-top: var(--s4); font-size: 0.95rem; color: var(--text-dim); }
.cap-modal__how b { font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); font-weight: 500; flex: none; }
@media (max-width: 560px) {
  .cap-overlay { padding: var(--s4) var(--s3) var(--s5); }
  .cap-modal__head, .cap-modal__body { padding-inline: var(--s5); }
  .cap-modal__media { margin-inline: var(--s5); }
}
