:root {
  --bg: #080a09;
  --panel: #0d100e;
  --panel-2: #121613;
  --line: #222924;
  --line-2: #323b34;
  --ink: #e9eee4;
  --ink-2: #b4bdb2;
  --muted: #8d978e;
  --up: #b8f34a;
  --down: #ff6a45;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 3.6vw, 56px);
  --bar-h: 48px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); overflow-x: clip; scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-h) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--sans); overflow-x: clip; }
h1, h2, h3, p, dl, dd, pre { margin: 0; }
a { color: inherit; }
canvas { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--up); outline-offset: 2px; }

.skip { position: fixed; left: 12px; top: -60px; z-index: 30; padding: 8px 12px; background: var(--up); color: #10140a; font: 500 13px var(--mono); }
.skip:focus { top: 8px; }

/* Status bar */
.bar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 var(--gutter);
  background: rgba(8, 10, 9, .9); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font: 400 12px var(--mono);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: .14em; white-space: nowrap; }
.brand svg { color: var(--up); }
.brand b { font-weight: 400; color: var(--muted); margin-left: .7em; }
.clocks { display: flex; gap: 22px; }
.clocks div { display: flex; gap: 7px; }
.clocks dt { color: var(--muted); }
.clocks dd { font-variant-numeric: tabular-nums; }
.state { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); white-space: nowrap; }
.state i { width: 7px; height: 7px; background: var(--up); animation: pulse 1.8s steps(2, jump-none) infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* Hero */
.hero { position: relative; isolation: isolate; min-height: max(640px, calc(100svh - var(--bar-h) - 41px)); display: flex; overflow: hidden; }
#terrain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hero-inner { width: 100%; padding: clamp(28px, 5vh, 56px) var(--gutter) clamp(24px, 4vh, 44px); display: flex; flex-direction: column; }
.eyebrow { font: 400 12px var(--mono); letter-spacing: .08em; color: var(--ink-2); }
.eyebrow span { color: var(--up); padding: 0 .35em; }

.wordmark { margin: auto 0; padding: 28px 0; font: 600 clamp(64px, 19vw, 300px)/.9 var(--mono); letter-spacing: -.02em; text-transform: uppercase; }
#wordmark { display: none; width: 100%; aspect-ratio: 490 / 114; }
.js .wordmark-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.js #wordmark { display: block; }

.hero-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 430px); gap: 32px; align-items: end; }
.lede { max-width: 33em; }
.lede p { font-size: clamp(17px, 1.5vw, 20px); line-height: 1.45; text-shadow: 0 0 14px var(--bg), 0 0 4px var(--bg); }
.lede em { font-style: italic; color: var(--up); }
.cta {
  display: inline-flex; gap: 10px; margin-top: 20px; padding: 11px 16px;
  background: var(--up); color: #10140a; text-decoration: none; font: 500 13px var(--mono);
  transition: background .15s;
}
.cta:hover { background: #d2ff78; }

.mission { background: rgba(13, 16, 14, .94); border: 1px solid var(--line-2); padding: 14px 16px; font: 400 13px/1.6 var(--mono); }
.mission .prompt { color: var(--ink); overflow-wrap: anywhere; }
.mission .prompt span { color: var(--up); }
.mission .col { margin-top: 10px; padding-bottom: 3px; border-bottom: 1px solid var(--line-2); color: var(--muted); }
.mission .null { padding-top: 4px; font-size: 20px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.mission .null i { width: 9px; height: 19px; background: var(--up); animation: pulse 1.1s steps(2, jump-none) infinite; }
.mission .rows { color: var(--muted); }

/* Tape */
.tape { border-block: 1px solid var(--line); overflow: hidden; background: var(--panel); height: 41px; }
.tape-track { display: flex; width: max-content; animation: tape 70s linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
.tape-item { display: inline-flex; gap: 9px; padding: 10px 22px; border-right: 1px solid var(--line); font: 400 13px/20px var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tape-item b { font-weight: 500; }
@keyframes tape { to { transform: translateX(-50%); } }

.is-up { color: var(--up); }
.is-down { color: var(--down); }

/* Sandbox */
.sandbox { padding: clamp(56px, 8vw, 104px) var(--gutter) clamp(40px, 5vw, 64px); }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 32px; align-items: end; margin-bottom: 28px; }
.section-head h2 { font: 500 clamp(26px, 3.4vw, 44px)/1.1 var(--mono); letter-spacing: -.03em; }
.section-head p { color: var(--ink-2); max-width: 36em; justify-self: end; }

.console { display: grid; grid-template-columns: 190px minmax(0, 1fr) minmax(320px, 400px); border: 1px solid var(--line); background: var(--panel); }
.panel { min-width: 0; padding: 14px; border-right: 1px solid var(--line); }
.panel:last-child { border-right: 0; }
.panel-title { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font: 400 12px var(--mono); color: var(--muted); }
.status { text-align: right; font-variant-numeric: tabular-nums; }

.schema-group + .schema-group { margin-top: 18px; }
.schema-name { font: 400 12px var(--mono); color: var(--muted); margin-bottom: 4px; }
.schema-btn { display: flex; width: 100%; justify-content: space-between; gap: 8px; min-height: 36px; align-items: center; padding: 6px 8px; font: 400 13px var(--mono); color: var(--ink-2); text-align: left; border-left: 2px solid transparent; }
.schema-btn:hover { background: var(--panel-2); color: var(--ink); }
.schema-btn[aria-pressed="true"] { background: var(--panel-2); color: var(--ink); border-left-color: var(--up); }
.schema-btn small { font-size: 11px; color: var(--muted); }

.sql { min-height: 104px; padding: 12px; background: var(--bg); border: 1px solid var(--line); font: 400 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.sql .kw { color: var(--up); }
.sql .str { color: #ffb199; }
.sql::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 3px; vertical-align: -2px; background: var(--ink-2); animation: pulse 1.1s steps(2, jump-none) infinite; }

.result-wrap { margin-top: 12px; overflow-x: auto; }
.result { width: 100%; border-collapse: collapse; font: 400 13px var(--mono); font-variant-numeric: tabular-nums; }
.result th { padding: 7px 10px; text-align: right; font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.result td { padding: 0 10px; height: 34px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.result th.l, .result td.l { text-align: left; }
.result tbody tr[data-sym] { cursor: pointer; }
.result tbody tr[data-sym]:hover { background: var(--panel-2); }
.result tr.sel { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--up); }
.result .sym-btn { font-weight: 500; min-height: 30px; padding: 0 2px; }
.result .sym-btn:hover { color: var(--up); }
.result .null-cell { font-size: 20px; font-weight: 500; height: 56px; }

.quote-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.quote-head strong { font-weight: 500; font-size: 14px; }
.quote-head .big { font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.quote-head .chg { font-size: 13px; }

.chart-wrap { position: relative; height: 230px; margin-top: 10px; touch-action: pan-y; }
#chart { width: 100%; height: 100%; cursor: crosshair; }
.tip { position: absolute; top: 6px; z-index: 2; pointer-events: none; min-width: 124px; padding: 7px 9px; background: var(--panel-2); border: 1px solid var(--line-2); font: 400 12px/1.5 var(--mono); font-variant-numeric: tabular-nums; }
.tip div { display: flex; justify-content: space-between; gap: 14px; }
.tip span { color: var(--muted); }
.chart-key { display: flex; align-items: center; gap: 6px; margin-top: 6px; font: 400 12px var(--mono); color: var(--muted); }
.chart-key span { width: 8px; height: 12px; display: inline-block; }
.chart-key .k-up { background: var(--up); }
.chart-key .k-down { border: 1px solid var(--down); margin-left: 8px; }
.chart-key em { margin-left: auto; font-style: normal; }

.ladder { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; font: 400 12px/22px var(--mono); font-variant-numeric: tabular-nums; }
.lvl { position: relative; display: flex; justify-content: space-between; padding: 0 6px; }
.lvl i { position: absolute; inset: 1px 0 1px auto; width: 100%; transform-origin: right; opacity: .17; }
.lvl.ask i { background: var(--down); }
.lvl.bid i { background: var(--up); }
.lvl span { position: relative; }
.lvl .sz { color: var(--ink-2); }
.spread { display: flex; justify-content: space-between; padding: 2px 6px; margin-block: 2px; color: var(--muted); border-block: 1px solid var(--line); }

/* Telemetry */
.telemetry { padding: 0 var(--gutter) clamp(56px, 7vw, 88px); }
.telemetry h2 { font: 400 12px var(--mono); color: var(--muted); margin-bottom: 10px; }
.telemetry dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.telemetry dl div { padding: 14px 16px 0 0; }
.telemetry dt { font-size: 13px; color: var(--ink-2); }
.telemetry dd { font: 500 clamp(22px, 2.8vw, 34px)/1.3 var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px 32px; padding: 24px var(--gutter) 32px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.foot-brand { font-family: var(--mono); color: var(--ink-2); }

@media (max-width: 1180px) {
  .console { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); }
  .schema { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--line); }
  .schema-groups { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 2px; }
  .schema-group + .schema-group { margin-top: 0; }
  .schema-group > div { display: flex; gap: 4px; }
  .schema-btn { width: auto; white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .schema-btn[aria-pressed="true"] { border-bottom-color: var(--up); }
  .schema-btn small { display: none; }
}
@media (max-width: 860px) {
  .clocks div:not(:first-child) { display: none; }
  .hero-foot, .section-head, .foot { grid-template-columns: minmax(0, 1fr); }
  .section-head p { justify-self: start; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .query { border-right: 0; border-bottom: 1px solid var(--line); }
  .telemetry dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .brand b, .clocks { display: none; }
  .hero { min-height: max(600px, calc(100svh - var(--bar-h) - 41px)); }
  .mission { font-size: 12px; }
  .result td, .result th { padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .state i, .mission .null i, .sql::after { animation: none; }
  .tape { overflow-x: auto; height: auto; }
  .tape-track { animation: none; }
}
