:root {
  --bg: #0b0c0e;
  --panel: #101114;
  --text: #ecebe6;
  --muted: #8e9096;
  --faint: #5d6066;
  --line: #22252a;
  --line-strong: #33363c;
  --accent: #a9c1ff;
  --live: #86dcaa;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --gutter: clamp(20px, 5vw, 80px);
  --side: 312px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

.wrap { width: min(100%, 1280px); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; color: var(--muted); }
.eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); flex: none; }
.icon-arrow { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; vertical-align: 1px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--text); color: var(--bg); padding: 8px 12px; z-index: 10; }

/* ---------- header ---------- */
.site-header { display: flex; align-items: center; gap: 28px; padding-top: 32px; padding-bottom: 32px; }
.wordmark { font-weight: 600; font-size: 26px; letter-spacing: -.06em; line-height: 1; }
.wordmark span { color: var(--accent); }
.header-name { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; line-height: 1.5; }
.header-name span { display: block; color: var(--muted); font-size: 10px; }
.header-nav { margin-left: auto; display: flex; gap: 28px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.header-nav a { color: var(--muted); transition: color .15s; }
.header-nav a:hover, .header-nav .arrow-link { color: var(--text); }

/* ---------- lab / hero ---------- */
.lab { padding-top: 40px; }
.lab-intro { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 56px; align-items: end; padding-bottom: 44px; }
h1 {
  margin-top: 24px;
  font-size: clamp(2.7rem, 5.6vw, 5.3rem); line-height: .96; font-weight: 500; letter-spacing: -.055em;
}
.nowrap { white-space: nowrap; }
h1 em, h2 em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -.02em; }
.lede { display: grid; gap: 18px; max-width: 440px; padding-bottom: 8px; }
.lede p:first-child { color: #c4c5c9; font-size: 17px; }
.lede .mono { line-height: 1.7; }

.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); border: 1px solid var(--line); }
.stage { position: relative; height: clamp(440px, 58vh, 580px); border-right: 1px solid var(--line); background: var(--bg); overflow: hidden; }
#dice-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#dice-canvas[data-cursor='grab'] { cursor: grab; }
#dice-canvas[data-cursor='grabbing'] { cursor: grabbing; }
#dice-canvas:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.stage-label, .badge, .stage-hint, .last-roll { position: absolute; pointer-events: none; }
.stage-label { top: 22px; left: 24px; text-transform: uppercase; letter-spacing: .12em; font-size: 10px; }
.stage-label span { display: block; margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 30px; letter-spacing: -.01em; text-transform: none; color: var(--text); line-height: 1; }
.badge { top: 22px; right: 22px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-strong); background: rgba(11, 12, 14, .7); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text); }
.badge .dot { background: var(--faint); }
.badge[data-state='live'] .dot { background: var(--live); box-shadow: 0 0 0 3px rgba(134, 220, 170, .14); }
.badge[data-state='off'] .dot { background: #e0806f; }
.stage-hint { left: 24px; bottom: 22px; line-height: 1.7; font-size: 11px; }
.last-roll { right: 24px; bottom: 20px; display: grid; justify-items: end; gap: 2px; text-align: right; }
.last-roll > .mono:first-child { text-transform: uppercase; letter-spacing: .12em; font-size: 10px; }
.last-roll strong { font-size: 54px; font-weight: 500; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.last-roll .state { color: var(--text); font-size: 11px; }
.fallback { position: absolute; inset: 0; display: grid; align-content: center; gap: 14px; padding: 48px; max-width: 620px; color: #c4c5c9; }
.fallback .mono { color: var(--faint); }
.fallback[hidden] { display: none; }
.no-gpu .stage-hint { display: none; }

.panel { padding: 24px; display: flex; flex-direction: column; gap: 22px; background: var(--panel); }
.field { display: grid; gap: 10px; }
.field-label { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field-label output { color: var(--text); font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-strong); }
.seg button { background: none; border: 0; padding: 8px 0; cursor: pointer; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-checked='true'] { background: var(--text); color: var(--bg); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatches button { display: grid; justify-items: center; gap: 8px; padding: 10px 4px 8px; background: none; border: 1px solid var(--line); cursor: pointer; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.swatches button[aria-checked='true'] { border-color: var(--text); color: var(--text); }
.swatches i { width: 22px; height: 22px; border-radius: 5px; background: radial-gradient(circle, var(--p) 0 2.2px, transparent 2.6px) center / 100% 100% no-repeat, var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: none; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 1px; background: var(--line-strong); }
input[type='range']::-moz-range-track { height: 1px; background: var(--line-strong); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--text); border: 0; }
input[type='range']::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 0; }
.buttons { display: grid; gap: 8px; }
.btn { display: inline-flex; justify-content: center; align-items: center; padding: 11px 18px; border: 1px solid var(--line-strong); background: none; font-size: 14px; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); }
.toggles { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--text); margin: 0; }
.text-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); border-bottom: 1px solid var(--line-strong); font-family: var(--mono); font-size: 11px; }
.text-btn:hover, .text-btn[aria-pressed='true'] { color: var(--text); border-color: var(--text); }

.lab-data { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); border: 1px solid var(--line); border-top: 0; }
.cell { padding: 24px; }
.cell + .cell { border-left: 1px solid var(--line); }
.cell-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.histogram { display: block; width: 100%; height: auto; }
.histogram .bar { fill: #d9d8d2; transition: y .25s ease, height .25s ease; }
.histogram .expected { stroke: var(--accent); stroke-width: 2; }
.histogram .grid { stroke: var(--line); stroke-dasharray: 3 5; }
.histogram .base { stroke: var(--line-strong); }
.histogram .axis { fill: var(--faint); font-family: var(--mono); font-size: 10px; }
.histogram .sum { fill: var(--muted); font-size: 11px; }
@media (prefers-reduced-motion: reduce) { .histogram .bar { transition: none; } }
.legend { display: flex; gap: 22px; margin-top: 12px; font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 12px; }
.key.obs { height: 10px; background: #d9d8d2; }
.key.exp { height: 2px; background: var(--accent); }
.stats dl { margin: 18px 0 0; display: grid; }
.stats dl div { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); }
.stats dt { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stats dd { margin: 0; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-align: right; }
.stats dd small { display: block; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--faint); letter-spacing: .02em; }
.verdict { margin-top: 16px; font-size: 13px; line-height: 1.55; color: #c4c5c9; }
.excluded { margin-top: 8px; font-size: 11px; color: var(--faint); }
.excluded:empty { display: none; }

.lab-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; padding: 20px 0 0; align-items: start; }
.lab-foot > .mono { font-size: 11px; line-height: 1.7; color: var(--faint); max-width: 520px; }
details { justify-self: end; max-width: 560px; }
summary { cursor: pointer; list-style: none; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--text); text-align: right; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ' +'; color: var(--muted); }
details[open] summary::after { content: ' −'; }
.details-body { display: grid; gap: 12px; margin-top: 16px; padding: 20px; border: 1px solid var(--line); font-size: 14px; line-height: 1.6; color: #c4c5c9; }
.details-body strong { color: var(--text); font-weight: 500; }

/* ---------- sections ---------- */
.section { padding-top: 112px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding-bottom: 28px; }
.section-head h2 { margin-top: 12px; }
h2 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 500; line-height: 1.08; letter-spacing: -.04em; }
.meta { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; text-align: right; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.metric { padding: 26px 24px 24px; display: grid; gap: 14px; align-content: start; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric .eyebrow { color: var(--muted); font-size: 10px; }
.metric strong { font-size: clamp(2.4rem, 4vw, 3.4rem); font-weight: 500; letter-spacing: -.055em; line-height: 1; }
.metric .mono { font-size: 11px; }

.table { border-top: 1px solid var(--line); }
.table-head { display: grid; grid-template-columns: minmax(0, 1fr) 180px 150px; gap: 32px; padding: 12px 0; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; color: var(--faint); }
.table-head span:nth-child(n+2), .row > .mono { text-align: right; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 180px 150px; gap: 32px; align-items: baseline; padding: 24px 0; border-bottom: 1px solid var(--line); }
.row h3 { font-size: 19px; font-weight: 500; letter-spacing: -.02em; line-height: 1.35; }
.row p { margin-top: 6px; max-width: 680px; color: var(--muted); font-size: 14px; }
.link-row { transition: background .15s; }
.row p.cta { margin-top: 14px; color: var(--accent); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.link-row h3 .icon-arrow { color: var(--muted); margin-left: 4px; transition: transform .15s, color .15s; }
.link-row:hover h3 .icon-arrow { color: var(--text); transform: translate(2px, -2px); }
.link-row:hover h3 { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 5px; }
.tag { display: inline-block; margin-left: 10px; padding: 2px 7px; vertical-align: 3px; border: 1px solid var(--line-strong); font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.tag.live { color: var(--live); border-color: rgba(134, 220, 170, .35); }

.stack { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); }
.stack > div { padding: 24px; }
.stack > div + div { border-left: 1px solid var(--line); }
.stack .eyebrow { color: var(--muted); font-size: 10px; }
.stack ul { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; font-size: 16px; }

.person { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 64px; align-items: start; }
.person h2 { margin-top: 12px; }
.person-body { display: flex; gap: 20px; margin-top: 28px; align-items: flex-start; }
.person-body img { border-radius: 50%; filter: grayscale(1) contrast(1.05); flex: none; }
.person-body p { color: #c4c5c9; max-width: 520px; }
.follow { border-top: 1px solid var(--line); margin-top: 8px; }
.follow a { display: grid; grid-template-columns: 1fr auto 20px; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.follow a .icon-arrow { justify-self: end; color: var(--muted); transition: transform .15s, color .15s; }
.follow a:hover .icon-arrow { color: var(--text); transform: translate(2px, -2px); }

.contact { display: flex; justify-content: space-between; align-items: end; gap: 40px; padding-bottom: 32px; }
.contact h2 { margin-top: 12px; max-width: 640px; }
.contact-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.site-footer { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 36px; margin-top: 80px; border-top: 1px solid var(--line); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; }
.site-footer a:hover { color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  :root { --side: 280px; }
  .header-nav a:not(.arrow-link) { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .lab-intro { grid-template-columns: 1fr; gap: 28px; padding-bottom: 32px; }
  .lab-grid, .lab-data { grid-template-columns: 1fr; }
  .stage { height: min(78vw, 440px); border-right: 0; border-bottom: 1px solid var(--line); }
  .cell + .cell { border-left: 0; border-top: 1px solid var(--line); }
  .lab-foot { grid-template-columns: 1fr; gap: 16px; }
  details, summary { justify-self: start; text-align: left; }
  .row, .table-head { grid-template-columns: 1fr; gap: 6px; }
  .table-head { display: none; }
  .row > .mono { text-align: left; }
  .row > .mono + .mono::before { content: '· '; }
  .row { grid-template-columns: auto auto 1fr; }
  .row > div { grid-column: 1 / -1; }
  .stack { grid-template-columns: 1fr; }
  .stack > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .person { grid-template-columns: 1fr; gap: 40px; }
  .contact { flex-direction: column; align-items: start; }
  .section { padding-top: 80px; }
  .section-head { flex-direction: column; align-items: start; }
  .meta { text-align: left; }
}
@media (max-width: 520px) {
  .site-header { gap: 16px; padding-top: 22px; padding-bottom: 22px; }
  .header-name span { display: none; }
  .nowrap { white-space: normal; }
  .stage-label span { font-size: 24px; }
  .stage-hint { display: none; }
  .last-roll strong { font-size: 40px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 20px 16px; }
  .panel, .cell { padding: 20px; }
}
