/* VOICE   work, shown live in a talk: calm, exact, a little theatrical
   IDEA    the exchange itself is a ring: families sit on a turning 3D ring, swaps are loops across it
   PICTURE the live pool, drawn as a 3D ring of families with the chosen swaps lit up
   COLOUR  black ground, white ink at a few strengths, black glass panels, one blood red for focus
   TYPE    SF Pro on Apple devices (Inter elsewhere), light display + tracked uppercase micro labels; SF Mono for ring tuples
   LAYOUT  laptop: controls | live ring | results, turning carousel along the bottom;
           phone: title, ring, controls, results, carousel stacked */

:root {
  color-scheme: dark;
  --bg: #030304;
  --ink: #f3f3f1;
  --ink-2: rgba(243, 243, 241, 0.64);
  --ink-3: rgba(243, 243, 241, 0.38);
  --ink-4: rgba(243, 243, 241, 0.16);
  --line: rgba(255, 255, 255, 0.085);
  --line-2: rgba(255, 255, 255, 0.16);
  --glass: rgba(16, 16, 18, 0.46);
  --glass-solid: rgba(14, 14, 16, 0.82);
  --red: #ff3b2f;
  --red-soft: rgba(255, 59, 47, 0.16);
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "JetBrains Mono", Consolas, monospace;
  --spring: linear(0, 0.046, 0.159, 0.307, 0.465, 0.618, 0.752, 0.863, 0.95, 1.012, 1.052, 1.074, 1.083, 1.082, 1.074, 1.062, 1.049, 1.036, 1.024, 1.014, 1.006, 1, 0.997, 0.994, 0.993, 0.993, 0.994, 0.994, 0.996, 0.997, 0.998, 0.999, 0.999, 1, 1, 1, 1.001, 1.001, 1.001, 1, 1);
  --soft: linear(0, 0.027, 0.095, 0.188, 0.291, 0.396, 0.498, 0.592, 0.676, 0.749, 0.81, 0.861, 0.903, 0.935, 0.961, 0.98, 0.993, 1.003, 1.009, 1.013, 1.015, 1.015, 1.015, 1.014, 1.012, 1.011, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.001, 1.001, 1.001, 1, 1, 1, 1, 1);
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --bar: 56px;
  --gutter: max(3vw, 16px);
}
:root[data-theme=light], :root[data-theme=dark] { color-scheme: dark; }

* { box-sizing: border-box; min-width: 0; border-radius: 0 !important; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 300 15px/1.5 var(--display); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--red); color: #fff; }

/* ---------- shared pieces ---------- */
.micro { font: 500 12px/1.25 var(--display); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }
.micro.on { color: var(--ink); }
.var { text-transform: none; letter-spacing: 0.02em; font-style: italic; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-weight: 400; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.hair { height: 1px; background: var(--line); border: 0; margin: 0; }
.glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012) 40%), var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(1.35);
  backdrop-filter: blur(26px) saturate(1.35);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.square-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line-2); transition: background 0.25s, border-color 0.25s, transform 0.5s var(--spring); }
.square-btn:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--ink-3); }
.square-btn:active { transform: scale(0.9); }
.square-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.text-btn { height: 44px; padding: 0 20px; border: 1px solid var(--line-2); font: 500 12px/1 var(--display); letter-spacing: 0.22em; text-transform: uppercase; transition: background 0.25s, border-color 0.25s, transform 0.5s var(--spring); }
.text-btn:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--ink-3); }
.text-btn:active { transform: scale(0.96); }
.text-btn[disabled] { opacity: 0.4; cursor: default; }

/* Segmented switch with a sliding white block */
.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-2); }
.seg button { position: relative; z-index: 1; height: 44px; padding: 0 22px; font: 500 12px/1 var(--display); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2); transition: color 0.35s; white-space: nowrap; }
.seg button.on { color: #050505; }
.seg .seg-block { position: absolute; top: 0; bottom: 0; left: 0; background: var(--ink); transition: transform 0.6s var(--spring), width 0.6s var(--spring); }

/* ---------- backdrop ---------- */
#backdrop { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: 0; transition: opacity 2s var(--out); }
body.ready #backdrop { opacity: 0.22; }
body.ready.inside #backdrop { opacity: 0.14; }
.glow { position: fixed; z-index: 0; pointer-events: none; width: 70vmax; height: 70vmax; }
.glow.g1 { left: -20vmax; top: -30vmax; background: radial-gradient(closest-side, rgba(190, 200, 255, 0.075), transparent); animation: drift1 26s ease-in-out infinite alternate; }
.glow.g2 { right: -25vmax; bottom: -35vmax; background: radial-gradient(closest-side, rgba(255, 59, 47, 0.085), transparent); animation: drift2 32s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax); } }
@keyframes drift2 { to { transform: translate(-16vmax, -10vmax); } }

/* ---------- intro: blur to sharp, tracking tightens ---------- */
#intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); transition: opacity 0.9s var(--out), filter 0.9s var(--out), visibility 0s 0.9s; cursor: pointer; }
#intro.gone { opacity: 0; filter: blur(14px); visibility: hidden; pointer-events: none; }
.intro-inner { display: grid; justify-items: center; gap: 22px; }
.intro-word { font: 200 clamp(38px, 9vw, 132px)/1 var(--display); color: var(--ink); animation: sharpen 1.7s var(--out) both; white-space: nowrap; }
.intro-sub { animation: fade-up 1.2s var(--out) 0.9s both; }
.intro-line { width: min(320px, 60vw); height: 1px; background: var(--line-2); transform-origin: left; animation: line-grow 1.4s var(--out) 0.5s both; }
@keyframes sharpen { from { filter: blur(22px); letter-spacing: 0.7em; opacity: 0; } 60% { opacity: 1; } to { filter: none; letter-spacing: -0.035em; opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes line-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- top bar ---------- */
.topbar { position: fixed; z-index: 20; left: 0; right: 0; top: 0; height: calc(var(--bar) + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) var(--gutter) 0; display: flex; align-items: center; gap: 24px; border-width: 0 0 1px 0; }
.brand { font: 500 12px/1 var(--display); letter-spacing: 0.32em; text-transform: uppercase; white-space: nowrap; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 14px; height: 14px; border: 1px solid var(--ink); position: relative; transform: rotate(45deg); }
.brand-mark::after { content: ""; position: absolute; inset: 3px; background: var(--red); }
.nav { position: relative; display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button { height: var(--bar); padding: 0 16px; font: 500 12px/1 var(--display); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); transition: color 0.3s; white-space: nowrap; }
.nav button:hover, .nav button.on { color: var(--ink); }
.nav-mark { position: absolute; bottom: 0; left: 0; height: 1px; background: var(--ink); transition: transform 0.7s var(--spring), width 0.7s var(--spring), opacity 0.3s; }

/* ---------- views ---------- */
.view { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; top: calc(var(--bar) + env(safe-area-inset-top, 0px)); padding: 22px var(--gutter) calc(18px + env(safe-area-inset-bottom, 0px)); display: none; overflow-x: hidden; overflow-y: auto; }
.view.active, .view.leaving { display: grid; }
.view.leaving { pointer-events: none; animation: view-out 0.45s var(--out) both; }
@keyframes view-out { to { opacity: 0; transform: scale(0.985) translateY(-8px); filter: blur(10px); } }
.view.active [data-in] { animation: rise 1s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 70ms + 120ms); }
.view.active .reveal { animation: sharpen-small 1.25s var(--out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(22px) scale(0.985); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes sharpen-small { from { filter: blur(14px); letter-spacing: 0.3em; opacity: 0; } to { filter: none; letter-spacing: -0.03em; opacity: 1; } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.view-head .micro { margin: 0 0 10px; }
.title { font: 200 clamp(34px, 4vw, 60px)/1.02 var(--display); letter-spacing: -0.03em; margin: 0; }
.head-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- home: landing ---------- */
#view-home.active, #view-home.leaving { display: block; padding: 0; scroll-snap-type: y proximity; }
#view-home:focus { outline: none; }
.hero { position: relative; height: calc(100svh - var(--bar) - env(safe-area-inset-top, 0px)); min-height: 560px; overflow: hidden; scroll-snap-align: start; cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.hero.spinning { cursor: grabbing; }
#kidney-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.hero.no-gl #kidney-canvas { display: none; }
.kidney-floor { position: absolute; z-index: 0; left: 0; right: 0; margin: auto; top: 70%; width: min(56vw, 700px); height: 30%; background: radial-gradient(closest-side, rgba(255, 59, 47, 0.15), rgba(255, 59, 47, 0.035) 55%, transparent); pointer-events: none; }
.hero-words { position: absolute; inset: 0; z-index: 1; margin: 0; pointer-events: none; font: inherit; }
.hero-words.front { z-index: 3; }
.hw { position: absolute; display: inline-block; font: 300 min(15vw, 25vh)/0.9 var(--display); letter-spacing: -0.045em; white-space: nowrap; color: var(--ink); }
.hw-1 { left: var(--gutter); top: 11%; }
.hw-2 { left: 16vw; top: 36%; }
.hw-3 { left: 42vw; top: 60%; }
.view.active .hw.reveal { animation: sharpen-hero 1.7s var(--out) both; }
@keyframes sharpen-hero { from { filter: blur(18px); letter-spacing: 0.25em; opacity: 0; } to { filter: none; letter-spacing: -0.045em; opacity: 1; } }
.hero-q { position: absolute; z-index: 4; left: var(--gutter); top: 4.5%; }
.hero-answer { position: absolute; z-index: 4; right: var(--gutter); top: 4.5%; display: grid; justify-items: end; text-align: right; gap: 10px; }
.answer-num { font: 200 clamp(44px, 5.6vw, 92px)/0.9 var(--display); letter-spacing: -0.04em; white-space: nowrap; }
.answer-num .p { color: var(--ink-3); }
.scroll-cue { position: absolute; z-index: 4; left: var(--gutter); bottom: 20px; display: grid; justify-items: start; gap: 12px; padding: 8px 0; }
.scroll-cue i { width: 1px; height: 44px; background: linear-gradient(var(--ink), transparent); transform-origin: top; animation: cue 2.4s var(--out) infinite; }
.scroll-cue:hover .micro { color: var(--ink); }
.hero-credit { position: absolute; z-index: 4; right: var(--gutter); bottom: 22px; margin: 0; max-width: min(300px, calc(100% - 2 * var(--gutter))); text-align: right; font: 400 11px/1.4 var(--display); letter-spacing: 0.02em; color: var(--ink-4); }
.hero-credit a { color: inherit; text-decoration: none; transition: color 0.3s; }
.hero-credit a:hover { color: var(--ink-2); }
.hero.looking { cursor: crosshair; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- home: the story, one step per screen ---------- */
.step { position: relative; z-index: 1; min-height: calc(100svh - var(--bar) - env(safe-area-inset-top, 0px)); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 80px); align-items: center; padding: clamp(40px, 6vh, 72px) var(--gutter); border-top: 1px solid var(--line); scroll-snap-align: start; }
.step::before { content: ""; position: absolute; z-index: -1; right: 6%; top: 14%; width: min(44vw, 640px); aspect-ratio: 1; background: radial-gradient(closest-side, rgba(255, 59, 47, 0.13), transparent); pointer-events: none; }
.step:nth-of-type(even)::before { right: 28%; top: 34%; background: radial-gradient(closest-side, rgba(200, 210, 255, 0.09), transparent); }
.step-text { display: grid; gap: 22px; align-content: center; justify-items: start; }
.step-title { font: 300 clamp(36px, 4.4vw, 68px)/1.02 var(--display); letter-spacing: -0.035em; margin: 0; max-width: 14ch; }
.step-line { font: 300 clamp(18px, 1.55vw, 24px)/1.45 var(--display); color: var(--ink-2); margin: 0; max-width: 32ch; }
.step-visual { position: relative; padding: clamp(18px, 2.4vw, 32px); min-height: min(62vh, 560px); display: grid; align-content: center; gap: 18px; }
.story-svg { width: 100%; height: auto; max-height: 56vh; overflow: visible; }
.story-svg .node { fill: rgba(255, 255, 255, 0.035); stroke: var(--ink-2); stroke-width: 1.5; }
.story-svg .node.patient { stroke: var(--ink); }
.story-svg .letter { font: 200 58px var(--display); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.story-svg .label { font: 500 15px var(--display); letter-spacing: 0.2em; fill: var(--ink-3); text-anchor: middle; }
.story-svg .role { font: 500 11px var(--display); letter-spacing: 0.14em; fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }
.story-svg .arrow { fill: none; stroke: var(--ink); stroke-width: 2; }
.story-svg .head { fill: var(--ink); }
.story-svg .no { stroke: var(--red); stroke-width: 2.5; }
.story-svg .dash { stroke: var(--ink-4); stroke-width: 1.5; stroke-dasharray: 3 6; }
.story-svg .token { fill: var(--red); }
.step.in .story-svg .arrow { animation: draw-line 1.4s var(--out) 0.35s both; }
.step.in .story-svg .head, .step.in .story-svg .no { animation: fade-in 0.6s var(--out) 1.2s both; }
.step:not(.in) .story-svg .token { visibility: hidden; }
.step.in .story-svg .token { animation: fade-in 0.6s var(--out) 1.4s both; }
@keyframes draw-line { from { stroke-dashoffset: var(--len, 600); } to { stroke-dashoffset: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.fx { transition: opacity 0.9s var(--out), filter 0.9s var(--out), translate 1.1s var(--spring); transition-delay: calc(var(--i, 0) * 90ms); }
.step:not(.in) .fx, .takeaway:not(.in) .fx { opacity: 0; filter: blur(10px); translate: 0 28px; }

/* 3D glass: panels tilt towards the pointer and catch a moving highlight */
[data-tilt] { transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.9s var(--spring); }
.fx[data-tilt] { transition: opacity 0.9s var(--out), filter 0.9s var(--out), translate 1.1s var(--spring), transform 0.9s var(--spring); transition-delay: calc(var(--i, 0) * 90ms), calc(var(--i, 0) * 90ms), calc(var(--i, 0) * 90ms), 0s; }
[data-tilt]::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(480px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.085), transparent 62%); opacity: var(--sheen, 0); transition: opacity 0.6s; }

.step-stats { display: flex; gap: clamp(28px, 4vw, 64px); padding-top: 22px; border-top: 1px solid var(--line); }
.step-stats div { display: grid; gap: 12px; }
.step-stats b { font: 200 clamp(64px, 7vw, 112px)/0.85 var(--display); letter-spacing: -0.05em; color: var(--ink-3); }
.step-stats div:last-child b { color: var(--ink); }

.risk-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.risk-top b { font: 200 clamp(64px, 7vw, 112px)/0.85 var(--display); letter-spacing: -0.05em; }
.risk-row { display: grid; grid-template-columns: minmax(130px, 0.8fr) minmax(0, 2fr) minmax(8ch, auto); gap: 20px; align-items: center; padding: 22px 0; border-top: 1px solid var(--line); }
.risk-label { display: grid; gap: 12px; }
.tests { display: flex; gap: 6px; }
.tests i { width: 14px; height: 14px; border: 1px solid var(--ink); background: rgba(255, 255, 255, 0.08); }
.risk-row.red .tests i { border-color: var(--red); background: var(--red-soft); }
.risk-bar { height: 12px; background: rgba(255, 255, 255, 0.06); position: relative; overflow: hidden; }
.risk-bar i { position: absolute; inset: 0 auto 0 0; width: 50%; background: var(--ink); transition: width 0.8s var(--spring); }
.risk-row.red .risk-bar i { background: var(--red); }
.risk-nums { display: grid; justify-items: end; gap: 8px; }
.risk-nums b { font: 200 clamp(40px, 4vw, 64px)/0.9 var(--display); letter-spacing: -0.04em; }
.risk sup { font-size: 0.75em; }

.facts { display: grid; width: 100%; border-top: 1px solid var(--line); }
.fact { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px 14px; padding: 18px 0; border-bottom: 1px solid var(--line); align-items: center; }
.fact i { width: 22px; height: 2px; background: var(--ink); grid-row: 1 / 3; }
.fact.red i { background: var(--red); }
.fact b { font: 300 clamp(20px, 1.8vw, 28px)/1.25 var(--display); letter-spacing: -0.015em; grid-column: 2; }
.fig.story-fig { min-height: min(46vh, 440px); }

.takeaway { position: relative; z-index: 1; min-height: 72svh; display: grid; align-content: center; justify-items: start; gap: 26px; padding: 80px var(--gutter); border-top: 1px solid var(--line); scroll-snap-align: start; }
.takeaway-line { font: 300 clamp(42px, 6.2vw, 108px)/1 var(--display); letter-spacing: -0.04em; margin: 0; max-width: 15ch; }

.explore { position: relative; z-index: 1; padding: 48px var(--gutter) 64px; border-top: 1px solid var(--line); scroll-snap-align: start; }
.explore-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.explore .arrows { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

/* ---------- 2.5D turning ring carousel ---------- */
.carousel { position: relative; perspective: 1100px; perspective-origin: 50% 40%; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
.carousel.dragging { cursor: grabbing; }
.carousel-floor { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.card3d { position: absolute; left: 0; top: 0; will-change: transform, opacity; backface-visibility: hidden; }
.card3d-face {
  width: 100%; height: 100%; position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.015) 45%, rgba(255, 255, 255, 0.03)), rgba(12, 12, 14, 0.78);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transition: border-color 0.4s, box-shadow 0.4s;
}
.card3d.front .card3d-face { border-color: rgba(255, 255, 255, 0.42); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 30px 60px -30px rgba(0, 0, 0, 0.9); }
.card3d-face::before { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.07) 50%, transparent 65%); transform: translateX(var(--sheen, 0%)); pointer-events: none; }
.carousel-empty { position: absolute; inset: 0; display: grid; place-items: center; }

/* home cards */
#home-carousel { height: 400px; }
.module-card { display: grid; grid-template-rows: auto 1fr auto; height: 100%; padding: 20px; gap: 12px; }
.module-card .glyph { display: grid; place-items: center; }
.module-card .glyph svg { width: 100%; max-width: 150px; height: auto; overflow: visible; }
.module-card .big { font: 200 44px/1 var(--display); letter-spacing: -0.04em; }
.module-card .row { display: flex; justify-content: space-between; align-items: end; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ring cards */
.ring-carousel { height: 236px; margin-top: 14px; border-top: 1px solid var(--line); }
.ring-card { display: grid; grid-template-rows: auto 1fr auto; height: 100%; padding: 14px; gap: 6px; }
.ring-card .ring-top { display: flex; justify-content: space-between; align-items: center; }
.ring-card svg { width: 100%; height: 100%; max-height: 74px; overflow: visible; }
.ring-card .tuple { font: 400 15px/1 var(--mono); white-space: nowrap; }
.ring-card .val { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 8px; }
.ring-card .val b { font: 300 24px/1 var(--display); letter-spacing: -0.02em; }
.tags { display: flex; gap: 4px; }
.tag { font: 500 9.5px/1 var(--display); letter-spacing: 0.18em; padding: 4px 5px 3px; border: 1px solid var(--line-2); color: var(--ink-3); }
.tag.on { background: var(--ink); color: #050505; border-color: var(--ink); }
.tag.red { background: var(--red); color: #fff; border-color: var(--red); }

/* small drawings inside cards */
.ring-card .edge { fill: none; stroke: var(--ink-2); stroke-width: 1; transition: stroke 0.4s; }
.ring-card .head { fill: var(--ink-2); transition: fill 0.4s; }
.ring-card rect { fill: var(--bg); stroke: var(--ink); stroke-width: 1; }
.ring-card text { font: 400 7px var(--mono); fill: var(--ink); text-anchor: middle; dominant-baseline: middle; }
.card3d.front .ring-card .edge { stroke: var(--red); }
.card3d.front .ring-card .head { fill: var(--red); }
.module-card svg path, .module-card svg ellipse { fill: none; stroke-width: 1; }
.module-card .g-faint { stroke: var(--ink-4); }
.module-card .g-ink { stroke: var(--ink); stroke-width: 1.4; }
.module-card .g-red { stroke: var(--red); stroke-width: 1.4; }
.module-card svg rect { fill: var(--bg); stroke: var(--ink); stroke-width: 1; }
.module-card svg rect.g-fill { fill: var(--ink); stroke: none; opacity: 0.85; }
.module-card svg rect.g-fill-red { fill: var(--red); stroke: none; }
.card3d.front .module-card .g-red, .card3d.front .module-card .g-ink { animation: trace 2.4s var(--out) both; stroke-dasharray: 400; }
@keyframes trace { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }

/* ---------- stage: panel | live ring | panel ---------- */
#view-demo, #view-lab { grid-template-rows: auto minmax(0, 1fr) auto; }
.stage-grid { display: grid; grid-template-columns: minmax(230px, 290px) minmax(0, 1fr) minmax(250px, 320px); gap: 16px; min-height: 0; }
.panel { padding: 22px; display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.panel-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stage { position: relative; min-height: 300px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.stage canvas:active { cursor: grabbing; }
.stage-corner { position: absolute; display: flex; gap: 14px; pointer-events: none; }
.stage-corner.tl { left: 4px; top: 2px; }
.stage-corner.bl { left: 4px; bottom: 2px; }
.stage-corner.br { right: 4px; bottom: 2px; }
.key { display: inline-flex; align-items: center; gap: 7px; }
.key i { width: 14px; height: 1.5px; background: var(--ink); display: inline-block; }
.key i.red { background: var(--red); }
.key i.faint { background: var(--ink-4); }

/* family rows */
.fam-head, .fam-row { display: grid; grid-template-columns: 26px 1fr 18px 1fr; align-items: center; gap: 8px; }
.fam-row { height: 38px; border-top: 1px solid var(--line); padding: 0 4px; transition: background 0.3s; }
.fam-row:hover, .fam-row.hot { background: rgba(255, 255, 255, 0.05); }
.fam-row .id { font: 400 12px/1 var(--mono); color: var(--ink-3); }
.blood { font: 300 20px/1 var(--display); letter-spacing: -0.02em; }
.fam-row .giv { color: var(--ink-4); font-size: 12px; text-align: center; }

/* solver blocks (demo) and policy rows (lab) */
.solver { display: grid; gap: 8px; padding: 14px; text-align: left; border: 1px solid var(--line); transition: border-color 0.35s, background 0.35s, transform 0.6s var(--spring); }
.solver:hover { border-color: var(--line-2); }
.solver:active { transform: scale(0.98); }
.solver.on { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.045); }
.solver .top { display: flex; justify-content: space-between; align-items: center; }
.solver .big { font: 200 52px/0.9 var(--display); letter-spacing: -0.04em; }
.solver .plan { font: 400 12.5px/1.5 var(--mono); color: var(--ink-2); min-height: 19px; }
.delta { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; border-top: 1px solid var(--line); }
.delta b { font: 300 28px/1 var(--display); letter-spacing: -0.03em; }

.policy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px; text-align: left; border: 1px solid var(--line); transition: border-color 0.35s, background 0.35s, transform 0.6s var(--spring); }
.policy:hover { border-color: var(--line-2); }
.policy:active { transform: scale(0.98); }
.policy.on { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.045); }
.policy .v { font: 200 30px/1 var(--display); letter-spacing: -0.03em; text-align: right; }
.policy .bar { grid-column: 1 / -1; height: 2px; background: var(--ink-4); position: relative; overflow: hidden; }
.policy .bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); width: 0; transition: width 0.9s var(--spring); }
.policy.count .bar i { background: var(--red); }
.policy .gain { font: 400 11px/1 var(--mono); color: var(--ink-3); }
#lab-policies { gap: 10px; }
#lab-policies .policy { padding: 10px 12px; gap: 6px 10px; }

/* lab controls */
.control { display: grid; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.control:last-child { border-bottom: 0; }
.control-top { display: flex; justify-content: space-between; align-items: baseline; }
.control-top b { font: 200 34px/1 var(--display); letter-spacing: -0.03em; }
.seed-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px 44px; gap: 6px; }
.seed-row input { height: 44px; background: transparent; border: 1px solid var(--line-2); text-align: center; font: 400 16px/1 var(--mono); width: 100%; }
.seed-row input:focus { border-color: var(--ink-2); outline: none; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--ink) var(--fill, 50%), var(--line-2) var(--fill, 50%)); }
input[type=range]::-moz-range-track { height: 2px; background: linear-gradient(90deg, var(--ink) var(--fill, 50%), var(--line-2) var(--fill, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -9px; background: var(--bg); border: 1px solid var(--ink); transition: transform 0.4s var(--spring), background 0.3s; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; background: var(--bg); border: 1px solid var(--ink); }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.25) rotate(45deg); }
input[type=range]:active::-webkit-slider-thumb { background: var(--red); border-color: var(--red); transform: scale(1.35) rotate(45deg); }
.stats { display: flex; gap: 22px; flex-wrap: wrap; }
.stat { display: grid; gap: 6px; }
.stat b { font: 200 26px/1 var(--display); letter-spacing: -0.03em; }

/* ---------- sweep ---------- */
#view-sweep, #view-proof { grid-template-rows: auto minmax(0, 1fr); }
.sweep-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 16px; min-height: 0; }
.chart-panel { position: relative; padding: 18px 18px 12px; display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; gap: 10px; }
.fig { position: relative; min-height: 260px; }
.fig > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.fig text { font: 500 10.5px var(--display); letter-spacing: 0.14em; fill: var(--ink-3); }
.fig .axis { stroke: var(--line); }
.fig .zero { stroke: var(--line-2); }
.fig .line { fill: none; stroke-width: 1.6; stroke-linejoin: round; transition: stroke-dashoffset 1.6s var(--out); }
.p-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.p-chip { padding: 10px 4px 2px; display: grid; gap: 6px; justify-items: center; color: var(--ink-3); transition: color 0.3s; }
.p-chip b { font: 300 16px/1 var(--display); color: var(--ink-2); transition: color 0.3s; }
.p-chip.on, .p-chip.on b { color: var(--ink); }
.read-big { font: 200 clamp(64px, 8vw, 112px)/0.85 var(--display); letter-spacing: -0.05em; }
.read-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.read-row i { height: 2px; background: var(--ink); }
.read-row i.red { background: var(--red); }
.read-row i.dash { background: repeating-linear-gradient(90deg, var(--ink-3) 0 3px, transparent 3px 6px); }
.read-row b { font: 300 22px/1 var(--display); letter-spacing: -0.02em; white-space: nowrap; }

/* ---------- proof ---------- */
.proof-grid { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) minmax(220px, 290px); gap: 16px; min-height: 0; }
.cells-wrap { display: grid; place-items: center; min-height: 280px; }
.cells { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; width: min(100%, 62vh, 560px); }
.cell { aspect-ratio: 1; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.13); transition: transform 0.5s var(--spring), background 0.35s, border-color 0.35s; }
.cell:hover, .cell.on { transform: scale(1.18); z-index: 1; background: var(--ink); }
.proof-big { font-size: clamp(48px, 5.2vw, 84px); white-space: nowrap; }
.cell.on { outline: 1px solid var(--ink); outline-offset: 3px; }
.cell.bad { background: var(--red); border-color: var(--red); }
.cell.scan { background: var(--red); border-color: var(--red); transform: scale(0.7); }
.cell.ok { background: var(--ink); }
.cell.idle { background: transparent; }
.detail-table { display: grid; grid-template-columns: auto 1fr 1fr; }
.detail-table > * { padding: 10px 0; border-top: 1px solid var(--line); }
.detail-table b { font: 300 20px/1 var(--display); letter-spacing: -0.02em; text-align: right; }
.empty-note { display: grid; gap: 10px; align-content: center; justify-items: start; height: 100%; }
.empty-note code { font: 400 12.5px/1.5 var(--mono); color: var(--ink-2); padding: 8px 10px; border: 1px solid var(--line-2); overflow-wrap: anywhere; }

/* tooltip */
.tip { position: fixed; z-index: 40; pointer-events: none; padding: 9px 11px; opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.4s var(--spring); display: grid; gap: 4px; background: var(--glass-solid); }
.tip.show { opacity: 1; transform: none; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .stage-grid { grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); }
  .stage-grid > .panel:last-child { grid-column: 1 / -1; }
  .proof-grid { grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); }
  .proof-grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .view { display: none; }
  .view.active { display: block; }
  .view.leaving { display: none; }
  .view > * + * { margin-top: 16px; }
  .stage-grid, .sweep-grid, .proof-grid { display: flex; flex-direction: column; }
  .stage { order: -1; min-height: 360px; height: 52vh; }
  #view-demo .stage-grid > .panel:first-child { order: 1; }
  .panel { overflow: visible; }
  #view-home > * + * { margin-top: 0; }
  .hw { font-size: 17vw; }
  .hw-1 { top: 17%; }
  .scroll-cue { display: none; }
  .hw-2 { left: 7vw; top: 47%; }
  .hw-3 { left: 30vw; top: 59%; }
  .hero-answer { top: auto; bottom: 84px; right: auto; left: var(--gutter); justify-items: start; text-align: left; }
  .step { grid-template-columns: minmax(0, 1fr); min-height: auto; align-content: start; }
  .step-visual { min-height: 0; }
  .risk-row { grid-template-columns: minmax(0, 1fr) auto; }
  .risk-bar { grid-column: 1 / -1; grid-row: 2; }
  #home-carousel { height: 360px; }
  .chart-panel { min-height: 420px; }
  .nav button { padding: 0 9px; letter-spacing: 0.16em; }
  .brand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
  .glow { animation: none; }
}
