@layer reset, base, layout, components, stage, motion;

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@property --screen {
  syntax: "<color>";
  inherits: true;
  initial-value: #000;
}

:root {
  color-scheme: dark;
  --bg: oklch(0.13 0.008 265);
  --bg-raised: oklch(0.17 0.01 265);
  --bg-inset: oklch(0.1 0.006 265);
  --line: oklch(1 0 0 / 0.09);
  --line-strong: oklch(1 0 0 / 0.17);
  --text: oklch(0.96 0.005 265);
  --muted: oklch(0.72 0.015 265);
  --faint: oklch(0.55 0.015 265);
  --accent: oklch(0.86 0.17 168);
  --accent-2: oklch(0.8 0.13 230);
  --accent-ink: oklch(0.2 0.05 168);
  --warn: oklch(0.82 0.16 75);
  --bad: oklch(0.7 0.2 25);
  --radius: 18px;
  --radius-sm: 10px;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: clamp(16px, 4vw, 40px);
  --screen: #000;
  --screen-ink: #fff;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; transition: --screen 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
  body, h1, h2, h3, p, dl, dd, figure { margin: 0; }
  button, input, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  canvas, svg { display: block; }
  [hidden] { display: none !important; }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  }
}

@layer base {
  body {
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background:
      radial-gradient(1200px 520px at 50% -180px, oklch(0.86 0.17 168 / 0.1), transparent 70%),
      radial-gradient(900px 480px at 85% 10%, oklch(0.8 0.13 230 / 0.06), transparent 70%),
      var(--bg);
    background-attachment: fixed;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }
  body::before {
    /* faint engineering grid */
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
      linear-gradient(var(--line) 1px, transparent 1px),
      linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 0%, transparent 75%);
    opacity: 0.45;
    pointer-events: none;
  }
  html.stage-open, html.stage-open body { overflow: hidden; }

  h1, h2, h3 { font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; text-wrap: balance; }
  h1 { font-size: clamp(2.3rem, 6.4vw, 4.6rem); }
  h2 { font-size: clamp(1.6rem, 3.6vw, 2.5rem); }
  h3 { font-size: 1.15rem; letter-spacing: -0.01em; }
  p { text-wrap: pretty; }
  a { color: inherit; }
  kbd {
    font-family: var(--mono);
    font-size: 0.78em;
    padding: 0.15em 0.5em;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    background: oklch(1 0 0 / 0.05);
    color: var(--text);
    white-space: nowrap;
  }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
  ::selection { background: oklch(0.86 0.17 168 / 0.35); }

  .visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .skip {
    position: absolute; left: 12px; top: -60px; z-index: 50;
    background: var(--accent); color: var(--accent-ink);
    padding: 8px 14px; border-radius: 8px; font-weight: 600; text-decoration: none;
    &:focus { top: 12px; }
  }
  .noscript { text-align: center; padding: 24px; color: var(--warn); }
}

@layer layout {
  .top {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 20px;
    padding: 14px var(--gutter);
    background: oklch(0.13 0.008 265 / 0.72);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--line);
  }
  .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
  .brand-mark {
    width: 22px; height: 22px; border-radius: 6px; background: #000;
    border: 1.5px solid var(--text);
    box-shadow: 0 0 0 3px oklch(0.86 0.17 168 / 0.18), 0 0 18px oklch(0.86 0.17 168 / 0.5);
  }
  .brand-name { font-weight: 600; letter-spacing: -0.02em; font-size: 1.05rem; b { font-weight: 600; color: var(--accent); } }
  .nav {
    display: flex; gap: 4px; margin-inline: auto;
    a {
      padding: 7px 12px; border-radius: 999px; font-size: 0.92rem; color: var(--muted);
      text-decoration: none; transition: color 0.2s, background 0.2s;
      &:hover { color: var(--text); background: oklch(1 0 0 / 0.06); }
    }
  }
  .chip-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 8px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--muted); font-size: 0.88rem;
    transition: border-color 0.2s, color 0.2s;
    &:hover { border-color: var(--line-strong); color: var(--text); }
  }
  @media (max-width: 760px) {
    .nav { display: none; }
    .chip-btn { margin-left: auto; }
  }

  main { width: min(1180px, 100%); margin-inline: auto; padding-inline: var(--gutter); }
  .hero { padding-block: clamp(36px, 7vw, 84px) clamp(28px, 4vw, 48px); text-align: center; }
  .section { padding-block: clamp(44px, 7vw, 92px); }
  .section-head { max-width: 720px; margin-bottom: clamp(22px, 3vw, 36px); display: grid; gap: 12px; p:not(.eyebrow) { color: var(--muted); } }

  .eyebrow {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--accent);
    .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  }
  .hero h1 { margin-top: 18px; }
  @media (max-width: 600px) { .eyebrow .wide { display: none; } }
  .grad {
    background: linear-gradient(100deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .lede { max-width: 620px; margin: 20px auto 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.14rem); }

  .foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 28px;
    padding: 28px var(--gutter) calc(28px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); color: var(--faint); font-size: 0.88rem;
    .foot-keys { display: inline-flex; align-items: center; gap: 6px; }
  }
}

@layer components {
  .panel {
    background: linear-gradient(180deg, oklch(1 0 0 / 0.04), oklch(1 0 0 / 0.015));
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .spacer { flex: 1 1 auto; }

  /* ── Launch screen ── */
  .launch-wrap {
    margin-top: clamp(28px, 4.5vw, 52px);
    padding: clamp(8px, 1.2vw, 14px);
    border-radius: calc(var(--radius) + 12px);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, oklch(1 0 0 / 0.06), oklch(1 0 0 / 0.01));
    box-shadow: 0 40px 120px -40px oklch(0.86 0.17 168 / 0.28), 0 0 0 1px oklch(0 0 0 / 0.6) inset;
  }
  .launch {
    position: relative; display: grid; place-items: center;
    width: 100%; aspect-ratio: 16 / 9; max-height: min(66dvh, 680px); min-height: 280px;
    border-radius: var(--radius);
    background: var(--screen); color: var(--screen-ink);
    border: 1px solid var(--line-strong);
    overflow: hidden;
    transition: color 0.35s var(--ease), transform 0.5s var(--ease), box-shadow 0.4s;
    container-type: inline-size;
    &:hover { transform: scale(1.004); box-shadow: 0 0 0 1px var(--accent), 0 0 60px -10px oklch(0.86 0.17 168 / 0.45); }
    &:active { transform: scale(0.997); }
    &:hover .launch-icon { transform: scale(1.14); }
    &:hover .bracket { --inset: 14px; opacity: 1; }
  }
  .bracket {
    --inset: 20px;
    position: absolute; width: 26px; height: 26px; opacity: 0.55;
    border: 0 solid currentColor;
    transition: inset 0.4s var(--ease), opacity 0.3s;
    &.tl { top: var(--inset); left: var(--inset); border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 6px; }
    &.tr { top: var(--inset); right: var(--inset); border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 6px; }
    &.bl { bottom: var(--inset); left: var(--inset); border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 6px; }
    &.br { bottom: var(--inset); right: var(--inset); border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 6px; }
  }
  .launch-meta {
    position: absolute; top: 26px;
    font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.6;
    &.launch-meta-l { left: 62px; }
    &.launch-meta-r { right: 62px; }
  }
  .launch-core { display: grid; justify-items: center; gap: clamp(10px, 2cqi, 20px); padding: 24px; }
  .launch-icon { width: clamp(40px, 7cqi, 72px); height: auto; opacity: 0.9; transition: transform 0.5s var(--ease); }
  .launch-title { font-size: clamp(1.35rem, 4.6cqi, 3.2rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; text-wrap: balance; }
  .launch-sub { font-size: clamp(0.85rem, 1.6cqi, 1.02rem); opacity: 0.66; kbd { color: inherit; border-color: currentColor; background: transparent; opacity: 0.9; } }
  @media (max-width: 560px) { .launch-meta-r { display: none; } .launch { aspect-ratio: 4 / 5; } }

  /* ── Controls ── */
  .controls { margin-top: 16px; padding: 16px; display: grid; gap: 14px; text-align: left; }
  .swatches { display: flex; flex-wrap: wrap; gap: 8px; }
  .swatch {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 7px 13px 7px 8px; border-radius: 999px;
    border: 1px solid var(--line); font-size: 0.9rem; color: var(--muted);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 1px solid oklch(1 0 0 / 0.28); }
    kbd { font-size: 0.66rem; padding: 0.05em 0.4em; border-bottom-width: 1px; opacity: 0.6; }
    &:hover { border-color: var(--line-strong); color: var(--text); }
    &[aria-checked="true"] { border-color: var(--accent); color: var(--text); background: oklch(0.86 0.17 168 / 0.1); }
  }
  .swatch-custom {
    position: relative;
    i { background: conic-gradient(from 0deg, red, yellow, lime, cyan, blue, magenta, red); }
    &[aria-checked="true"] i { background: var(--c); }
    input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
  }
  .control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }

  .toggle {
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; color: var(--muted);
    input { position: absolute; opacity: 0; }
    .track {
      width: 36px; height: 21px; border-radius: 999px; background: oklch(1 0 0 / 0.12); position: relative; flex: none;
      transition: background 0.25s;
      &::after {
        content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%;
        background: var(--text); transition: translate 0.25s var(--ease);
      }
    }
    &:has(input:checked) { color: var(--text); .track { background: var(--accent); &::after { translate: 15px 0; background: var(--accent-ink); } } }
    &:has(input:focus-visible) .track { outline: 2px solid var(--accent); outline-offset: 3px; }
  }
  .select select {
    appearance: none; padding: 9px 34px 9px 14px; border-radius: 999px;
    border: 1px solid var(--line); background: transparent; font-size: 0.9rem; color: var(--muted);
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px; background-repeat: no-repeat;
    option { background: var(--bg-raised); color: var(--text); }
  }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: 999px; font-size: 0.92rem; font-weight: 550;
    background: var(--accent); color: var(--accent-ink);
    transition: filter 0.2s, border-color 0.2s, background 0.2s, color 0.2s;
    svg { width: 17px; height: 17px; }
    &:hover { filter: brightness(1.08); }
    &.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); &:hover { background: oklch(1 0 0 / 0.06); } }
    &.icon { padding: 9px; }
  }

  /* ── Pattern cards ── */
  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
  .card {
    display: grid; gap: 6px; align-content: start; text-align: left; padding: 12px 12px 18px;
    border-radius: var(--radius); border: 1px solid var(--line);
    background: linear-gradient(180deg, oklch(1 0 0 / 0.04), oklch(1 0 0 / 0.012));
    transition: translate 0.35s var(--ease), border-color 0.25s, box-shadow 0.35s;
    &:hover { translate: 0 -3px; border-color: oklch(0.86 0.17 168 / 0.55); box-shadow: 0 22px 50px -28px oklch(0.86 0.17 168 / 0.5); }
  }
  .card-title { font-weight: 600; letter-spacing: -0.01em; padding: 8px 6px 0; }
  .card-text { color: var(--muted); font-size: 0.92rem; padding-inline: 6px; em { color: var(--warn); font-style: normal; } }
  .thumb {
    display: flex; aspect-ratio: 16 / 8; border-radius: 11px; overflow: hidden;
    border: 1px solid var(--line); background: #000;
    i { flex: 1; }
  }
  .t-gradient {
    background:
      linear-gradient(90deg, #000, #fff) 0 0 / 100% 25% no-repeat,
      linear-gradient(90deg, #000, #f00) 0 33.33% / 100% 25% no-repeat,
      linear-gradient(90deg, #000, #0f0) 0 66.66% / 100% 25% no-repeat,
      linear-gradient(90deg, #000, #00f) 0 100% / 100% 25% no-repeat;
  }
  .t-nearblack { padding: 14% 8%; gap: 5%; i { border-radius: 3px; } i:nth-child(1) { background: #0a0a0a; } i:nth-child(2) { background: #111; } i:nth-child(3) { background: #181818; } i:nth-child(4) { background: #202020; } i:nth-child(5) { background: #292929; } i:nth-child(6) { background: #333; } }
  .t-nearwhite { background: #fff; padding: 14% 8%; gap: 5%; i { border-radius: 3px; } i:nth-child(1) { background: #cfcfcf; } i:nth-child(2) { background: #d9d9d9; } i:nth-child(3) { background: #e2e2e2; } i:nth-child(4) { background: #ebebeb; } i:nth-child(5) { background: #f3f3f3; } i:nth-child(6) { background: #f9f9f9; } }
  .t-grid {
    background:
      radial-gradient(circle at 50% 50%, transparent 0 27%, #fff 27% 28.2%, transparent 28.2%),
      repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 16px),
      repeating-linear-gradient(90deg, #fff 0 1px, transparent 1px 16px), #000;
  }
  .t-bars {
    background:
      linear-gradient(90deg, #000 0 12.5%, #242424 0 25%, #494949 0 37.5%, #6d6d6d 0 50%, #929292 0 62.5%, #b6b6b6 0 75%, #dbdbdb 0 87.5%, #fff 0) 0 100% / 100% 26% no-repeat,
      linear-gradient(90deg, #fff 0 12.5%, #ff0 0 25%, #0ff 0 37.5%, #0f0 0 50%, #f0f 0 62.5%, #f00 0 75%, #00f 0 87.5%, #000 0);
  }
  .t-noise {
    background:
      repeating-conic-gradient(from 0deg, #f00 0 25%, #0f0 0 50%, #00f 0 75%, #fff 0) 50% 50% / 12px 12px no-repeat padding-box,
      #000;
    background-size: 12px 12px, auto;
    background-repeat: repeat, no-repeat;
    mask-image: radial-gradient(circle at 50% 50%, #000 0 26%, transparent 27%);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0 26%, transparent 27%);
    background-color: #000;
  }

  /* ── Display readout ── */
  .readout {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1px;
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line);
    > div { background: var(--bg-inset); padding: 22px 22px 20px; display: grid; gap: 4px; }
    dt { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
    dd { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
    small { color: var(--muted); font-size: 0.85rem; }
  }

  /* ── FAQ ── */
  .faq { display: grid; gap: 10px; max-width: 820px; }
  .faq details {
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: oklch(1 0 0 / 0.025);
    transition: border-color 0.2s;
    &[open] { border-color: var(--line-strong); }
    summary {
      list-style: none; cursor: pointer; padding: 16px 48px 16px 18px; font-weight: 550; position: relative;
      &::-webkit-details-marker { display: none; }
      &::after {
        content: ""; position: absolute; right: 20px; top: 50%; width: 9px; height: 9px;
        border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
        translate: 0 -70%; rotate: 45deg; transition: rotate 0.25s var(--ease), translate 0.25s var(--ease);
      }
    }
    &[open] summary::after { rotate: -135deg; translate: 0 -20%; }
    p { padding: 0 18px 18px; color: var(--muted); max-width: 68ch; }
  }

  /* ── Popover + dialog ── */
  .pop {
    width: min(440px, calc(100vw - 32px)); padding: 24px; border-radius: var(--radius);
    border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--text);
    box-shadow: 0 40px 100px -20px #000;
    h3 { margin-bottom: 14px; }
    p { color: var(--muted); }
    &::backdrop { background: oklch(0 0 0 / 0.6); backdrop-filter: blur(4px); }
    &[popover] { inset: 0; margin: auto; }
    &:popover-open, &[open] { animation: pop-in 0.25s var(--ease); }
  }
  .keys { display: grid; gap: 10px; margin-bottom: 20px; > div { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px; } dd { color: var(--muted); font-size: 0.94rem; } }
  .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
  @keyframes pop-in { from { opacity: 0; scale: 0.96; translate: 0 8px; } }
}

@layer stage {
  .stage {
    position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100dvh;
    background: var(--screen); color: var(--screen-ink);
    touch-action: manipulation; user-select: none; -webkit-user-select: none;
    &.idle { cursor: none; }
    &:fullscreen { width: 100%; height: 100%; }
    &[data-mode="pattern"] { background: #000; transition: none; }
  }
  #stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
  .stage[data-mode="pattern"] #stage-canvas { display: block; }
  #stage-noise {
    position: absolute; width: 192px; height: 192px; left: 50%; top: 50%; translate: -50% -50%;
    image-rendering: pixelated; cursor: grab; border-radius: 4px;
  }
  .stage-clock {
    position: absolute; left: 50%; top: 50%;
    translate: calc(-50% + var(--dx, 0px)) calc(-50% + var(--dy, 0px));
    font-family: var(--mono); font-weight: 300; font-size: clamp(3rem, 14vw, 11rem); letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums; opacity: 0.16; pointer-events: none; white-space: nowrap;
    transition: translate 6s ease-in-out;
  }
  .stage-hint {
    position: absolute; left: 50%; top: 9%; translate: -50% 0; text-align: center;
    font-size: 0.95rem; padding: 10px 18px; border-radius: 999px; white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis;
    background: oklch(0.2 0.01 265 / 0.82); color: #fff; border: 1px solid oklch(1 0 0 / 0.18);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    opacity: 0; transition: opacity 0.5s; pointer-events: none;
    &.show { opacity: 1; }
    &:empty { display: none; }
  }
  .hud {
    position: absolute; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); translate: -50% 0;
    display: flex; align-items: center; gap: 4px; padding: 6px;
    border-radius: 999px; color: #fff;
    background: oklch(0.2 0.01 265 / 0.82); border: 1px solid oklch(1 0 0 / 0.18);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px -8px oklch(0 0 0 / 0.6);
    transition: opacity 0.4s, translate 0.4s var(--ease);
  }
  .stage.idle .hud { opacity: 0; translate: -50% 10px; pointer-events: none; }
  .hud-btn {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    transition: background 0.2s;
    svg { width: 20px; height: 20px; }
    &:hover { background: oklch(1 0 0 / 0.14); }
    &[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
  }
  .hud-label { min-width: 132px; text-align: center; font-size: 0.92rem; font-weight: 550; padding-inline: 6px; }
  .hud-sep { width: 1px; height: 22px; background: oklch(1 0 0 / 0.2); margin-inline: 4px; }
}

@layer motion {
  .lab { padding: 14px; display: grid; gap: 14px; }
  .lab-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .seg {
    display: inline-flex; padding: 4px; border-radius: 999px; background: oklch(0 0 0 / 0.35); border: 1px solid var(--line);
    button {
      padding: 7px 14px; border-radius: 999px; font-size: 0.9rem; color: var(--muted); white-space: nowrap;
      transition: background 0.25s, color 0.25s;
      &:hover { color: var(--text); }
      &[aria-selected="true"], &[aria-checked="true"] { background: oklch(1 0 0 / 0.12); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong) inset; }
    }
  }
  #lab-toggle { .i-play { display: none; } &[aria-pressed="true"] { .i-play { display: block; } .i-pause { display: none; } } }
  .lab-view {
    position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #000;
    height: clamp(300px, 50dvh, 480px);
  }
  #lab-canvas { width: 100%; height: 100%; }
  .lab-start {
    position: absolute; inset: 0; margin: auto; width: max-content; height: max-content;
    display: inline-flex; align-items: center; gap: 10px; padding: 14px 22px; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink); font-weight: 600;
    box-shadow: 0 0 60px oklch(0.86 0.17 168 / 0.5);
    svg { width: 18px; height: 18px; }
  }
  .lab-foot { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
  @media (max-width: 860px) { .lab-foot { grid-template-columns: 1fr; } }
  .stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line);
    border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
    > div { background: var(--bg-inset); padding: 14px 16px; display: grid; gap: 2px; }
    dt { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
    dd { font-size: clamp(1.25rem, 2.4vw, 1.7rem); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
    small { font-size: 0.74rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
  }
  @media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }
  .graph {
    position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-inset); min-height: 74px;
    canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  }
  .graph-label { position: absolute; left: 12px; top: 8px; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
  .lab-note { color: var(--muted); font-size: 0.92rem; padding: 0 4px 4px; min-height: 1.5em; }

  .lab:fullscreen {
    border-radius: 0; border: 0; padding: 14px; background: var(--bg);
    grid-template-rows: auto 1fr auto auto;
    .lab-view { height: auto; min-height: 0; }
  }

  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      .section-head, .cards, .lab, .readout, .faq {
        animation: rise linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 32%;
      }
    }
  }
  @keyframes rise { from { opacity: 0; translate: 0 28px; } to { opacity: 1; translate: 0 0; } }
}
