@font-face {
  font-family: 'Geist'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('./assets/fonts/geist-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('./assets/fonts/geist-mono-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('./assets/fonts/instrument-serif-latin-400-italic.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  --bg: #08090d;
  --surface: #101118;
  --raised: #171821;
  --text: #f1f2f5;
  --muted: #9597a7;
  --accent: #9675ff;
  --signal: #c9baff;
  --line: rgb(196 192 220 / 13%);
  --line-strong: rgb(196 192 220 / 22%);
  --max: 1360px;
  --gutter: clamp(18px, 4.2vw, 72px);
  --sans: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', monospace;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p, dl, dd { margin: 0; }
body { min-width: 280px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, canvas:focus-visible, a:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }
:where(button) svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--signal); color: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.wrap { width: min(var(--max), calc(100% - 2 * var(--gutter))); margin-inline: auto; }
.eyebrow { font: 450 11px/1.35 var(--mono); letter-spacing: .12em; text-transform: uppercase; }

.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { display: block; }
.wordmark { font-size: 19px; font-weight: 650; letter-spacing: .12em; }
.brand-category { margin-left: 13px; padding-left: 19px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; }
.notes-button { display: inline-flex; align-items: center; gap: 10px; padding: 8px 0 8px 10px; border: 0; background: none; color: #ceced8; font-size: 13px; white-space: nowrap; }
.notes-button svg { width: 14px; height: 14px; color: var(--muted); }
.notes-button:hover:not(:disabled), .notes-button:hover:not(:disabled) svg { color: var(--signal); }

.intro { padding: clamp(27px, 4.2vh, 54px) 0 clamp(22px, 3.3vh, 38px); }
.intro h1 { font-size: clamp(58px, 6.1vw, 94px); line-height: .96; font-weight: 530; letter-spacing: -.078em; }
.intro em { font: italic 400 1.12em/.86 'Instrument Serif', Georgia, serif; letter-spacing: -.047em; color: #bec0cd; padding-right: .095em; }
.intro p { margin-top: 17px; color: var(--muted); font-size: clamp(14px, 1.14vw, 17px); line-height: 1.55; }

.workspace {
  display: grid;
  grid-template-columns: minmax(210px, 247px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: 'states viewer' 'details viewer';
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0d0e14;
}
.state-panel { grid-area: states; min-width: 0; padding-top: 27px; }
.state-panel h2 { padding: 0 25px; margin-bottom: 17px; color: var(--muted); }
.state-buttons { display: grid; gap: 2px; }
.state-buttons button {
  position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) 9px; align-items: center;
  gap: 4px; padding: 0 21px 0 25px; min-height: 53px; text-align: left; white-space: nowrap;
  border: 1px solid transparent; border-inline: 0; background: none; color: #aaabba; font-size: 14px; font-weight: 500;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}
.state-buttons button:hover:not(:disabled) { background: rgb(241 242 245 / 4%); color: var(--text); }
.state-buttons button:focus-visible { outline-offset: -4px; z-index: 2; }
.state-buttons button[aria-pressed="true"] { color: var(--text); background: linear-gradient(90deg, rgb(150 117 255 / 13%), rgb(150 117 255 / 5%)); border-block-color: rgb(165 146 223 / 12%); }
.state-buttons button[aria-pressed="true"]::before { content: ''; position: absolute; inset: -1px auto -1px 0; width: 2px; background: var(--accent); }
.state-index { font: 400 11px/1 var(--mono); color: var(--muted); }
.state-buttons button[aria-pressed="true"] .state-index { color: var(--signal); }
.state-indicator { width: 6px; height: 6px; border-radius: 50%; }
.state-buttons button[aria-pressed="true"] .state-indicator { background: var(--signal); box-shadow: 0 0 9px rgb(150 117 255 / 45%); }
.state-details { grid-area: details; padding: 0 25px 22px; margin-top: 26px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 17px; }
#state-detail { width: 100%; padding-top: 23px; border-top: 1px solid var(--line); }
#state-detail-label { color: #c3c1cd; }
#state-description { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.layer-list { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.replay-button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 0; border: 0; background: none; color: var(--signal); font-size: 13px; }
.replay-button:disabled { color: var(--muted); opacity: .6; }
.replay-button:hover:not(:disabled) { color: var(--text); }
.replay-button svg { width: 16px; height: 16px; }

.viewer { grid-area: viewer; min-width: 0; border-left: 1px solid var(--line); }
.viewport {
  isolation: isolate; position: relative; overflow: clip;
  height: clamp(373px, calc(100svh - 410px), 640px); background: #0b0c12; border-radius: 0 12px 0 0;
}
.viewport-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, transparent calc(50% - .5px), rgb(179 172 214 / 9%) 50%, transparent calc(50% + .5px)),
    linear-gradient(0deg, transparent calc(50% - .5px), rgb(179 172 214 / 9%) 50%, transparent calc(50% + .5px)),
    repeating-linear-gradient(90deg, rgb(178 179 214 / 6%) 0 1px, transparent 1px 54px) center / 54px 54px,
    repeating-linear-gradient(0deg, rgb(178 179 214 / 6%) 0 1px, transparent 1px 54px) center / 54px 54px,
    radial-gradient(ellipse at 50% 47%, #171822 0%, #10111a 39%, #0a0b10 76%);
}
.corner { pointer-events: none; position: absolute; width: 12px; height: 12px; border: 1px solid #4b4a60; z-index: 1; }
.corner-nw { top: 13px; left: 13px; border-right: 0; border-bottom: 0; }
.corner-ne { top: 13px; right: 13px; border-left: 0; border-bottom: 0; }
.corner-sw { bottom: 13px; left: 13px; border-right: 0; border-top: 0; }
.corner-se { bottom: 13px; right: 13px; border-left: 0; border-top: 0; }
#brain-canvas, .fallback-image { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#brain-canvas { cursor: grab; touch-action: none; }
#brain-canvas:active { cursor: grabbing; }
#brain-canvas:focus-visible { outline-offset: -5px; }
.fallback-image { object-fit: contain; }
.viewport-header { pointer-events: none; position: absolute; inset: 24px 28px auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
#angle-caption { display: flex; align-items: center; gap: 9px; color: #d2cedd; }
#angle-caption span { height: 1px; width: 18px; background: var(--accent); }
.render-status { text-align: right; color: #a5a4b3; white-space: nowrap; }
.render-status::before { content: ''; display: inline-block; vertical-align: 2px; width: 5px; height: 5px; margin-right: 8px; border-radius: 50%; background: #84869b; }
[data-render="live"][data-paused="false"] .render-status::before { background: var(--signal); box-shadow: 0 0 8px rgb(150 117 255 / 70%); }
.viewport-message { pointer-events: none; position: absolute; left: 50%; bottom: 12%; translate: -50% 0; width: max-content; max-width: 75%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; text-align: center; background: var(--bg); color: #cac8d7; font-size: 13px; }
[data-render="loading"] .viewport-message { bottom: 50%; translate: -50% 50%; }
.orbit-help { pointer-events: none; position: absolute; bottom: 24px; left: 28px; color: #a5a4b3; font-size: 12px; }
[data-render]:not([data-render="live"]) :is(.orbit-help, .axes) { display: none; }
.touch-help { display: none; }
.axes { pointer-events: none; position: absolute; bottom: 24px; right: 21px; width: 62px; height: 57px; }
.axes svg { width: 100%; height: 100%; overflow: visible; }
.axes path { fill: none; stroke: #aaa8bd; stroke-width: 1px; }
.axes [data-axis="z"] { stroke: var(--accent); }
.axes circle { fill: #dfdaea; }
.axes text { fill: #cac5d9; font: 400 10px/1 var(--mono); dominant-baseline: middle; text-anchor: middle; }

.annotations, .annotation-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.annotation-leaders path { fill: none; stroke: #9790b0; stroke-width: 1px; opacity: .68; }
.annotation-leaders circle { fill: var(--signal); }
.annotations span { position: absolute; left: 0; top: 0; padding: 5px 7px; border-radius: 3px; background: rgb(9 10 16 / 80%); color: #ebe6f7; font: 450 10px/1.3 var(--mono); white-space: nowrap; }

.toolbar { display: flex; min-height: 62px; padding: 9px 15px 9px 24px; align-items: center; justify-content: space-between; gap: 9px; border-top: 1px solid var(--line); }
.view-controls, .play-controls { display: flex; align-items: center; gap: 12px; }
.toolbar-label { color: var(--muted); }
.view-options { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 7px; background: #14151e; border: 1px solid var(--line); }
.view-options button { min-width: 55px; min-height: 34px; padding: 4px 9px; border: 1px solid transparent; border-radius: 5px; background: none; color: #b6b4c2; font-size: 13px; }
.view-options button[aria-pressed="true"] { color: var(--text); border-color: var(--line-strong); background: #252431; }
.view-options button:hover:not(:disabled) { color: var(--text); background: rgb(241 242 245 / 8%); }
.play-controls { gap: 9px; }
.play-controls button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); background: #14151e; color: #dbd8e3; font-size: 13px; white-space: nowrap; }
.play-controls button:disabled, .view-options button:disabled { opacity: .48; }
.play-controls .play-control { min-width: 78px; }
.play-controls .orbit-control[aria-pressed="true"] { border-color: rgb(150 117 255 / 30%); background: rgb(150 117 255 / 10%); color: var(--signal); }
.play-controls button:hover:not(:disabled) { border-color: var(--line-strong); background: #232330; }

.footer { padding: 16px 0 24px; color: var(--muted); font-size: 12px; }

dialog { max-width: min(510px, calc(100% - 40px)); max-height: 85vh; padding: 25px 27px 28px; border: 1px solid var(--line-strong); border-radius: 12px; background: #14151c; color: var(--text); }
dialog::backdrop { background: rgb(4 4 8 / 78%); }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.notes-head h2 { font-size: 26px; font-weight: 550; letter-spacing: -.045em; }
.notes-head button { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 6px; border: 1px solid var(--line); background: #1c1d26; }
dialog dl { display: grid; gap: 15px; }
dialog dt { margin-bottom: 4px; font-size: 13px; font-weight: 600; }
dialog dd { color: #b3b2c2; font-size: 14px; line-height: 1.55; }
dialog a, .no-script a { color: var(--signal); text-underline-offset: 2px; }
.no-script { padding: 10px var(--gutter); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(196px, 218px) minmax(0, 1fr); }
  .state-buttons button { grid-template-columns: 25px minmax(0, 1fr) 6px; padding-inline: 17px; font-size: 13px; }
  .state-panel h2, .state-details { padding-inline: 17px; }
  .toolbar-label { display: none; }
  .toolbar { padding-inline: 12px; }
  .annotations span { font-size: 9px; }
}

@media (max-width: 700px) {
  .masthead-inner { min-height: 63px; }
  .brand-category { display: none; }
  .intro { padding: 29px 0 23px; }
  .intro h1 { font-size: clamp(49px, 11vw, 73px); }
  .intro p { margin-top: 12px; max-width: 33ch; }
  .workspace { grid-template-areas: 'viewer' 'states' 'details'; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .viewer { border-left: 0; }
  .viewport { height: clamp(252px, 49svh, 425px); border-radius: 12px 12px 0 0; }
  .viewport-header { inset: 20px 22px auto; }
  .viewport-header .eyebrow { font-size: 9px; }
  .viewport-header #angle-caption span { width: 11px; }
  .orbit-help { left: 21px; bottom: 19px; font-size: 10px; }
  .axes { bottom: 15px; right: 13px; width: 48px; height: 45px; }
  .corner { width: 8px; height: 8px; }
  .annotations span { font-size: 8px; padding: 3px 4px; }
  .toolbar { min-height: 59px; }
  .view-controls, .play-controls { gap: 6px; }
  .view-options button { min-width: 42px; min-height: 34px; padding: 3px 6px; font-size: 12px; }
  .play-controls button { min-height: 38px; padding: 4px 7px; gap: 4px; font-size: 12px; }
  .play-controls .play-control { min-width: 60px; }
  .play-controls svg { width: 15px; height: 15px; }
  .state-panel { padding: 15px 0 2px; border-top: 1px solid var(--line); }
  .state-panel h2 { margin-bottom: 10px; }
  .state-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
  .state-buttons button { min-height: 43px; grid-template-columns: 20px minmax(0, 1fr); padding-inline: 11px 4px; font-size: clamp(11px, 3.1vw, 13px); white-space: normal; }
  .state-buttons button:nth-child(2n) { border-left: 1px solid var(--line); }
  .state-indicator { display: none; }
  .state-details { margin-top: 8px; padding-bottom: 12px; gap: 7px; }
  #state-detail { padding-top: 13px; }
  #state-description { line-height: 1.5; }
}

@media (max-width: 365px) {
  .play-controls .orbit-control span { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
  .play-controls .orbit-control { min-width: 34px; }
}

[data-input="touch"] .pointer-help { display: none; }
[data-input="touch"] .touch-help { display: inline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
