/* ACS landing — design tokens + base */
:root {
  --accent-h: 165;
  --accent-c: 0.18;
  --accent-l: 0.72;
  --accent: oklch(var(--accent-l) var(--accent-c) var(--accent-h));
  --accent-soft: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.12);
  --accent-line: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.35);
  --accent-ink: oklch(0.18 0.04 var(--accent-h));

  --density: 1;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: var(--font-sans);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --tx-1: 11px;
  --tx-2: 13px;
  --tx-3: 15px;
  --tx-4: 18px;
  --tx-5: 22px;
  --tx-6: 28px;
  --tx-7: 40px;
  --tx-8: 56px;
  --tx-9: 80px;

  color-scheme: light dark;
}

/* Helmlab's perceptually uniform neutral scale (--neutral-50..950).
 * Generated by tools/build-palette.mjs in helmgenlch() syntax, then
 * compiled to sRGB + P3 + Rec2020 by postcss-helmlab at build time.
 * Re-run `npm run build:palette` after changing the seed. */
@import "_palette.css";

/* Light theme — written in helm-lab's MetricSpace (helmlch).
 *
 * postcss-helmlab compiles each helmlch() to:
 *   - sRGB rgb() inline (always-valid baseline)
 *   - color(display-p3 …) wrapped in @supports (P3 displays)
 *   - color(rec2020 …) wrapped in @supports (Rec2020 displays)
 *
 * Note on the L scale: helm-lab is calibrated so white sits at L ≈ 1.12
 * (NOT 1.0), neutral mid-grey at L ≈ 0.5, black at 0. The values below
 * were converted from prior oklch() values so that the visual identity
 * stays the same across the migration. */
:root[data-theme="light"] {
  --bg:        rgb(251, 251, 251);   /* near-white */
  --bg-elev:   rgb(255, 255, 255);   /* pure white */
  --bg-sunk:   rgb(246, 246, 246);   /* light surface */
  --ink:       rgb(26, 26, 26);
  --ink-2:     rgb(91, 91, 91);
  --ink-3:     rgb(119, 119, 119);
  --line:      rgb(231, 231, 231);
  --line-2:    rgb(240, 240, 240);
  --code-bg:   rgb(246, 246, 246);
  --code-ink:  rgb(38, 38, 38);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --grid-line: rgba(0, 0, 0, 0.04);
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --grid-line: color(display-p3 0.0000 0.0000 0.0000 / 0.04);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --grid-line: color(rec2020 0.0000 0.0000 0.0000 / 0.04);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --shadow:    0 1px 2px color(display-p3 0.0000 0.0000 0.0000 / 0.04), 0 8px 24px color(display-p3 0.0000 0.0000 0.0000 / 0.06);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --shadow:    0 1px 2px color(rec2020 0.0000 0.0000 0.0000 / 0.04), 0 8px 24px color(rec2020 0.0000 0.0000 0.0000 / 0.06);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --shadow-sm: 0 1px 2px color(display-p3 0.0000 0.0000 0.0000 / 0.04);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --shadow-sm: 0 1px 2px color(rec2020 0.0000 0.0000 0.0000 / 0.04);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --code-ink:  color(display-p3 0.1490 0.1490 0.1490);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --code-ink:  color(rec2020 0.0871 0.0871 0.0871);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --code-bg:   color(display-p3 0.9648 0.9647 0.9647);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --code-bg:   color(rec2020 0.9604 0.9604 0.9603);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --line-2:    color(display-p3 0.9413 0.9412 0.9411);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --line-2:    color(rec2020 0.9341 0.9340 0.9339);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --line:      color(display-p3 0.9060 0.9059 0.9059);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --line:      color(rec2020 0.8946 0.8945 0.8944);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --ink-3:     color(display-p3 0.4667 0.4667 0.4666);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --ink-3:     color(rec2020 0.4145 0.4145 0.4145);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --ink-2:     color(display-p3 0.3569 0.3569 0.3569);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --ink-2:     color(rec2020 0.2988 0.2988 0.2987);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --ink:       color(display-p3 0.1020 0.1020 0.1020);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --ink:       color(rec2020 0.0465 0.0465 0.0465);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --bg-sunk:   color(display-p3 0.9648 0.9647 0.9647);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --bg-sunk:   color(rec2020 0.9604 0.9604 0.9603);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --bg-elev:   color(display-p3 0.9999 0.9999 0.9998);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --bg-elev:   color(rec2020 0.9999 0.9999 0.9998);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="light"] {
  --bg:        color(display-p3 0.9844 0.9843 0.9842);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="light"] {
  --bg:        color(rec2020 0.9824 0.9824 0.9823);
  }
}

/* Dark theme */
:root[data-theme="dark"] {
  --bg:        rgb(26, 26, 26);
  --bg-elev:   rgb(38, 38, 38);
  --bg-sunk:   rgb(13, 13, 13);
  --ink:       rgb(251, 251, 251);
  --ink-2:     rgb(164, 164, 164);
  --ink-3:     rgb(119, 119, 119);
  --line:      rgba(255, 255, 255, 0.06);
  --line-2:    rgba(255, 255, 255, 0.04);
  --code-bg:   rgb(38, 38, 38);
  --code-ink:  rgb(251, 251, 251);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  --grid-line: rgba(255, 255, 255, 0.05);
  --accent-ink: helmlch(0.21 0.04 var(--accent-h));
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --grid-line: color(display-p3 0.9999 0.9999 0.9998 / 0.05);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --grid-line: color(rec2020 0.9999 0.9999 0.9998 / 0.05);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --shadow:    0 1px 2px color(display-p3 0.0000 0.0000 0.0000 / 0.4), 0 12px 32px color(display-p3 0.0000 0.0000 0.0000 / 0.35);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --shadow:    0 1px 2px color(rec2020 0.0000 0.0000 0.0000 / 0.4), 0 12px 32px color(rec2020 0.0000 0.0000 0.0000 / 0.35);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px color(display-p3 0.0000 0.0000 0.0000 / 0.4);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px color(rec2020 0.0000 0.0000 0.0000 / 0.4);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --code-ink:  color(display-p3 0.9844 0.9843 0.9842);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --code-ink:  color(rec2020 0.9824 0.9824 0.9823);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --code-bg:   color(display-p3 0.1490 0.1490 0.1490);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --code-bg:   color(rec2020 0.0871 0.0871 0.0871);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --line-2:    color(display-p3 0.9999 0.9999 0.9998 / 0.04);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --line-2:    color(rec2020 0.9999 0.9999 0.9998 / 0.04);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --line:      color(display-p3 0.9999 0.9999 0.9998 / 0.06);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --line:      color(rec2020 0.9999 0.9999 0.9998 / 0.06);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --ink-3:     color(display-p3 0.4667 0.4667 0.4666);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --ink-3:     color(rec2020 0.4145 0.4145 0.4145);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --ink-2:     color(display-p3 0.6432 0.6432 0.6431);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --ink-2:     color(rec2020 0.6046 0.6045 0.6045);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --ink:       color(display-p3 0.9844 0.9843 0.9842);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --ink:       color(rec2020 0.9824 0.9824 0.9823);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --bg-sunk:   color(display-p3 0.0510 0.0510 0.0509);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --bg-sunk:   color(rec2020 0.0181 0.0181 0.0181);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --bg-elev:   color(display-p3 0.1490 0.1490 0.1490);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --bg-elev:   color(rec2020 0.0871 0.0871 0.0871);
  }
}
@supports (color: color(display-p3 0 0 0)) {
  :root[data-theme="dark"] {
  --bg:        color(display-p3 0.1020 0.1020 0.1020);
  }
}
@supports (color: color(rec2020 0 0 0)) {
  :root[data-theme="dark"] {
  --bg:        color(rec2020 0.0465 0.0465 0.0465);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
}
/* Hard clamp on horizontal scroll — applied ONLY on <html>, not <body>.
 * Putting `overflow-x: hidden` on <body> turns body into the containing
 * block for `position: sticky` descendants, which silently breaks the
 * docs sidebar / TOC. <html> as the clamp keeps the layout viewport
 * tight while leaving body's overflow visible for sticky to attach to
 * the window scroll instead. Modern browsers honour `clip`; the
 * `hidden` fallback comes first so the cascade settles on `clip` where
 * supported.
 *
 * scroll-padding-top: 64px keeps anchor-link jumps clear of the
 * position:fixed nav (56 px tall + 8 px breath). scroll-behavior:
 * smooth animates same-page anchor jumps; cross-page hash navigation
 * is handled in app.jsx because the target may not be rendered yet
 * when the browser does its initial scroll. */
html {
  overflow-x: hidden;
  overflow-x: clip;
  scroll-padding-top: 64px;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--tx-3);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  /* Smooth horizontal scrolling for touch where tables / code blocks
   * still need to scroll INSIDE their container. */
  -webkit-text-size-adjust: 100%;
}

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
code, pre, .mono { font-family: var(--font-mono); font-feature-settings: "calt" 0; }

/* Layout */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}
@media (max-width: 720px) {
  .wrap { padding: 0 20px; }
}

/* ---------- Nav ---------- *
 * Sticky + backdrop-filter is a known scroll-FPS killer because the
 * filter re-rasterizes against the page beneath every scroll frame.
 * Tuned to keep the glass feel but cut GPU cost: bg alpha bumped to
 * 92% (less work for blur to do), blur radius dropped 14px → 8px,
 * saturate removed (it's a second filter pass for almost no visual
 * gain). transform: translateZ(0) keeps the nav on its own compositor
 * layer so scroll only repaints below — not the nav itself. */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  will-change: transform;
  transition: transform 220ms cubic-bezier(0.32, 0.72, 0.32, 1);
}
/* Hidden state — slide up the full nav height + a px so the bottom
 * border doesn't peek through. position:fixed + transform animates
 * cleanly across engines (sticky + animated top was inconsistent). */
.nav.nav-hidden {
  transform: translateY(calc(-100% - 1px));
}
/* The nav is now out of flow (position:fixed) — push the page content
 * down so the hero (or any first section) doesn't slide under it. */
body {
  padding-top: 56px;
}
@media (prefers-reduced-motion: reduce) {
  .nav { transition: none; }
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: var(--tx-3);
  letter-spacing: -0.01em;
}
/* Nav shield: drop the heavy hover transform/shadow it inherits from
 * the hero version — at 28px those animations feel jittery. */
.brand .acs-shield {
  filter: none;
  transition: opacity 150ms;
}
.brand:hover .acs-shield { opacity: 0.85; }
.brand:hover .acs-shield { transform: none; }
.nav-links {
  display: flex;
  gap: 22px;
  margin-left: 8px;
  font-size: var(--tx-2);
  color: var(--ink-2);
  /* On mobile we let the nav scroll horizontally inside its own track
   * rather than pushing the whole page wide. Hide the scrollbar
   * cosmetic-wise; arrow keys / swipe still work. */
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { white-space: nowrap; }
.nav-links a:hover { color: var(--ink); }
/* Hamburger button is hidden by default — only shown on mobile (≤720).
 * Use a compound selector so we beat the .icon-btn{display:grid} rule
 * that comes later in source order at the same (0,1,0) specificity. */
.icon-btn.nav-burger { display: none; }

/* Drawer + backdrop are display:none on desktop. The mobile media query
 * below promotes them. We set the transition properties here so the
 * enter/exit is identical regardless of viewport. */
.nav-backdrop,
.nav-drawer { display: none; }

@media (max-width: 720px) {
  /* Hide the inline nav-links — they're surfaced through the drawer instead. */
  .nav-links { display: none; }
  /* Hide the desktop GitHub icon — drawer carries the link. Compound
   * selector beats the later .icon-btn{display:grid} rule on
   * source-order tie. */
  .icon-btn.nav-github { display: none; }
  /* Hide the v0.9 chip next to the brand — saves ~46 px. */
  .brand > span:last-child { display: none; }

  /* Make every action-row button look identical on mobile: 32 × 32 px
   * square with 8 px radius, content visually centred. The sound
   * toggle's text labels (`sound on` / `sound off`) collapse so only
   * the pulsing dot remains; the rest of the icon buttons stay icon-
   * only. The shared border-radius keeps the row visually rhythmic
   * instead of mixing pill + circle silhouettes. */
  .nav-actions { gap: 6px; }
  .nav-actions .icon-btn,
  .nav-actions .sound-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }
  .sound-toggle > span:not(.dot) { display: none; }

  /* Show the hamburger. Compound selector matches the desktop hide rule
   * so we don't lose to source-order ties. */
  .icon-btn.nav-burger { display: inline-flex; }

  /* Backdrop — full-viewport scrim that fades in. */
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 200;
  }
  @supports (color: color(display-p3 0 0 0)) {
    .nav-backdrop {
    background: color(display-p3 0.0000 0.0000 0.0000 / 0.45);
    }
  }
  @supports (color: color(rec2020 0 0 0)) {
    .nav-backdrop {
    background: color(rec2020 0.0000 0.0000 0.0000 / 0.45);
    }
  }
  .nav-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Drawer — full-screen sheet covering the entire viewport below the
   * nav. Slides down under the sticky header; the header itself stays
   * visible so the user can hit the close (✕) icon and the brand. */
  .nav-drawer {
    display: block;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    padding: 24px 20px 32px;
    z-index: 210;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-drawer.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  .nav-drawer-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 480px;
    margin: 0 auto;
  }
  .nav-drawer-links a {
    display: block;
    padding: 18px 16px;
    border-radius: 12px;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: var(--tx-5);
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: background-color 120ms, transform 120ms;
  }
  .nav-drawer-links a:hover,
  .nav-drawer-links a:focus-visible {
    background: var(--bg-sunk);
  }
  .nav-drawer-links a:active {
    transform: scale(0.985);
  }
  .nav-drawer-divider {
    height: 1px;
    background: var(--line-2);
    margin: 14px 4px;
  }
  /* Backdrop is irrelevant for the full-bleed drawer (drawer covers
   * everything beneath the header), but we keep it as the click-target
   * for the area above the drawer (under the header strip). */
  .nav-backdrop {
    top: 0;
    height: 56px;                   /* only the header strip needs it */
    background: transparent;
  }
}
.nav-spacer { flex: 1; }
.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 8px;
  color: var(--ink-2);
  transition: color 120ms, background 120ms, border-color 120ms;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 14px; height: 14px; }

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 8px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 8px;
  color: var(--ink-2);
  font-size: var(--tx-2);
  font-family: var(--font-mono);
  white-space: nowrap;
  transition: all 120ms;
}
.sound-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.sound-toggle.on {
  color: rgb(48, 84, 48);                          /* sRGB fallback */
  background: var(--accent);
  border-color: var(--accent);
}
@supports (color: color(rec2020 0 0 0)) {
  .sound-toggle.on { color: color(rec2020 0.19 0.33 0.19); }
}
.sound-toggle .dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}
.sound-toggle.on .dot {
  /* Deep forest-green explicitly in Rec2020 wide-gamut space, with an
   * sRGB fallback for displays/browsers without Rec2020. The dot picks
   * up the same green as the button's text label so the whole "ON"
   * pill reads as one tonal family. */
  background: rgb(48, 84, 48);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.18);
  animation: pulse 1.6s ease-in-out infinite;
}
@supports (color: color(rec2020 0 0 0)) {
  .sound-toggle.on .dot { background: color(rec2020 0.19 0.33 0.19); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.7; transform: scale(0.8); }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  height: 32px;
  border-radius: 7px;
  font-size: var(--tx-2);
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 120ms;
  white-space: nowrap;
}
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-3); background: var(--bg-elev); }
.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover { filter: brightness(1.05); }
.btn svg { width: 13px; height: 13px; }

/* ---------- Section helpers ---------- */
.section {
  padding: calc(96px * var(--density)) 0;
  border-top: 1px solid var(--line);
}
.section-tight { padding: calc(64px * var(--density)) 0; }
@media (max-width: 720px) {
  .section { padding: calc(56px * var(--density)) 0; }
  .section-tight { padding: calc(40px * var(--density)) 0; }
}
.section-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 48px;
  max-width: 720px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--tx-1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
}
.section-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}
.section-sub {
  font-size: var(--tx-4);
  color: var(--ink-2);
  margin: 0;
  text-wrap: pretty;
  max-width: 600px;
}

/* ---------- Code ---------- */
.code {
  font-family: var(--font-mono);
  font-size: var(--tx-2);
  line-height: 1.6;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}
.code .tok-sel { color: var(--accent); }
.code .tok-prop { color: oklch(0.55 0.13 280); }
:root[data-theme="dark"] .code .tok-prop { color: oklch(0.78 0.14 280); }
.code .tok-val { color: oklch(0.45 0.16 30); }
:root[data-theme="dark"] .code .tok-val { color: oklch(0.78 0.13 50); }
.code .tok-str { color: oklch(0.5 0.13 150); }
:root[data-theme="dark"] .code .tok-str { color: oklch(0.78 0.13 150); }
.code .tok-com { color: var(--ink-3); font-style: italic; }
.code .tok-at { color: oklch(0.55 0.18 320); font-weight: 500; }
:root[data-theme="dark"] .code .tok-at { color: oklch(0.78 0.16 320); }
.code .tok-num { color: oklch(0.55 0.16 230); }
:root[data-theme="dark"] .code .tok-num { color: oklch(0.78 0.13 230); }
.code .tok-punct { color: var(--ink-3); }

.kbd {
  font-family: var(--font-mono);
  font-size: var(--tx-1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 48px 0 32px;
  color: var(--ink-3);
  font-size: var(--tx-2);
}
.footer-cols {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 48px;
}
.footer h4 {
  font-size: var(--tx-2);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
  letter-spacing: 0.01em;
}
.footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.footer a:hover { color: var(--ink); }
.footer-bottom {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--tx-1);
}
@media (max-width: 720px) {
  .footer-cols { grid-template-columns: 1fr 1fr; gap: 32px; }
}

/* ---------- Misc atoms ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--tx-1);
  white-space: nowrap;
}
.chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 24px 0;
}

/* ============================================================
 * Mobile overflow guards
 * ============================================================
 * Apply broadly so every grid track and inline-code paragraph
 * actually fits the viewport. Three patterns:
 *
 *   1. Grid items default to `min-width: auto` (intrinsic content);
 *      a long inline-code chip pushes the cell wider than its track.
 *      `min-width: 0` on common grid children fixes this.
 *
 *   2. Inline `<code>` chips with padding/border are treated as
 *      unbreakable tokens by some engines. `overflow-wrap: anywhere`
 *      on text containers allows breaks inside.
 *
 *   3. Any rule in this file uses safe defaults; per-component
 *      overrides remain free to opt-out (`overflow-wrap: normal`).
 */
.install-wrap > *,
.compare-grid > *,
.rw-grid > *,
.theme-grid > *,
.feature-grid > *,
.cg-detail-body > *,
.cg-grid > *,
.section-head,
.compare,
.cg-card { min-width: 0; }


/* Text containers that often hold inline `<code>` chips. break-word
 * allows long unbreakable runs (URL, identifier) to break — unlike
 * `anywhere`, it ONLY kicks in as a last resort, so normal prose
 * still wraps at word boundaries. Switched from `anywhere` because
 * the more aggressive value was splitting `<code>` content mid-token
 * (e.g. `window.ACS.devtools.m` / `ount()`). */
.section-sub,
.install-checks li,
.feature-desc,
.cg-detail-sub,
.compare-sub,
.rw-stylesheet-note,
.theme-desc {
  overflow-wrap: break-word;
  word-break: normal;
}

/* Inline code chips stay atomic — `nowrap` keeps a chip on one line so
 * a method name like `window.ACS.devtools.mount()` reads cleanly; the
 * line break still happens at the space BEFORE or AFTER the chip
 * because the parent's `overflow-wrap: break-word` only targets
 * non-breakable runs at the last resort. If a chip is genuinely
 * wider than the viewport, the parent's `min-width: 0` and our
 * `overflow-x: clip` body rule keep the rest of the page from being
 * pushed sideways. */
.section-sub code,
.install-checks li code,
.feature-desc code,
.cg-detail-sub code,
.rw-stylesheet-note code,
.compare-sub code,
.theme-desc code {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

/* Section titles that wrap with `<br/>` — let them break gracefully */
.section-title { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 720px) {
  /* Tighten grid gaps on phones */
  .install-wrap { gap: 24px; }
  .install-checks { margin-top: 20px; }
  .install-checks li { font-size: var(--tx-2); }
  .compare { padding: 16px; }
  .rw-app { padding: 16px; }
  /* Section eyebrows can wrap onto two lines if needed */
  .eyebrow { white-space: normal; }
}
