:root {
  --regolith: #0a0a0c;
  --basalt: #131316;
  --ridge: #25252a;
  --ash: #9a968f;
  --moon: #f1e6d3;
  --gold: #e9c996;
  --ok: #5fe61f;
  --alert: #ff3d40;
  --warn: #f0a93a;
  --earthshine: #3aa0ff;
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--regolith);
  color: var(--moon);
  font: 400 1.0625rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.08; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.75rem, 3.4vw, 2.6rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px var(--gutter);
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ridge);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 1.15rem var(--display); }
.bar nav { display: flex; gap: 22px; font-size: 0.95rem; }
.bar nav a { text-decoration: none; color: var(--ash); padding: 6px 0; }
.bar nav a:hover { color: var(--moon); }

/* nav current page */
.bar nav a[aria-current="page"] { color: var(--moon); box-shadow: inset 0 -2px 0 var(--gold); }

/* contact page */
.contact .block { min-height: 70vh; }
.contact h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; margin-bottom: 14px; }
.contact-grid { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: clamp(28px, 5vw, 80px); align-items: start; }
/* Statiq contact widget, themed through its own variables */
.form-slot .statiq {
  --sq-bg: var(--basalt); --sq-fg: var(--moon); --sq-muted: var(--ash);
  --sq-border: var(--ridge); --sq-border-dark: #3a3a40;
  --sq-accent: var(--gold); --sq-on-accent: #1a1409;
  --sq-button: var(--gold); --sq-on-button: #1a1409; --sq-button-hover: #f4d8aa;
  --sq-error: #ff6b6e;
  --sq-success: #5fe61f; --sq-success-bg: rgba(95, 230, 31, 0.08); --sq-success-border: rgba(95, 230, 31, 0.35);
  --sq-radius: 20px; --sq-radius-sm: 12px; --sq-shadow-card: none;
  font-family: var(--body);
}
.form-slot .statiq.statiq-contact-form { padding: 24px; gap: 18px; }
.form-slot .statiq .sq-label { font-size: 0.95rem; font-weight: 500; color: var(--ash); }
.form-slot .statiq .sq-input { background: var(--regolith); font-size: 1rem; padding: 12px 14px; }
.form-slot .statiq textarea.sq-input { min-height: 140px; resize: vertical; }
.form-slot .statiq .sq-input::placeholder { color: #5f5c57; }
.form-slot .statiq .sq-submit { border-radius: 999px; box-shadow: none; padding: 12px 24px; font: 500 1rem var(--body); }
.form-slot .statiq .sq-submit:focus-visible { outline: 2px solid var(--moon); outline-offset: 3px; }

.contact-side h2 { font-size: 1.3rem; margin-bottom: 12px; }
.team { list-style: none; margin: 0 0 36px; padding: 0; }
.team li { padding: 10px 0; border-bottom: 1px solid var(--ridge); font: 600 1.15rem var(--display); }
.project div { padding: 10px 0; border-bottom: 1px solid var(--ridge); }
.project dt { color: var(--ash); font-size: 0.88rem; }
.project dd { margin: 2px 0 0; }

/* hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  min-height: calc(100vh - 56px);
  padding: 32px var(--gutter);
}
.kicker { color: var(--gold); font-size: 0.95rem; margin-bottom: 20px; }
.hero h1 {
  font-size: clamp(2.5rem, 5.6vw, 4.9rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  margin-bottom: 24px;
}
.lede { font-size: 1.2rem; color: #d9d0c1; max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-block; padding: 12px 20px; border-radius: 999px;
  border: 1px solid var(--ridge); text-decoration: none; font-weight: 500;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #1a1409; border-color: var(--gold); }
.btn.primary:hover { background: #f4d8aa; }

.stage {
  position: relative;
  height: min(78vh, 720px);
  min-height: 420px;
  border-radius: 28px;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(233, 201, 150, 0.16), transparent 70%),
    linear-gradient(#0e0e12, #08080a);
  border: 1px solid var(--ridge);
  overflow: hidden;
}
#viewer { width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
#viewer:active { cursor: grabbing; }
.stage-status {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ash); pointer-events: none; transition: opacity .4s;
}
.stage-status.done { opacity: 0; }
.stage-tools {
  position: absolute; left: 16px; right: 16px; bottom: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 0.85rem; color: var(--ash);
}
.stage-tools button {
  font: inherit; color: var(--moon); background: rgba(19, 19, 22, 0.8);
  border: 1px solid var(--ridge); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.stage-tools button:hover { border-color: var(--gold); }

/* facts strip */
.facts { border-block: 1px solid var(--ridge); background: var(--basalt); padding: 0 var(--gutter); }
.facts dl { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; }
.facts div { padding: 28px 24px 28px 0; }
.facts dd { margin: 0 0 6px; font: 600 clamp(1.7rem, 3vw, 2.4rem)/1 var(--display); color: var(--gold); order: -1; }
.facts div { display: flex; flex-direction: column; }
.facts dt { color: var(--ash); font-size: 0.92rem; max-width: 16em; }

/* generic blocks */
.block { padding: clamp(56px, 9vw, 120px) var(--gutter); max-width: 1280px; margin: 0 auto; }
.block.narrow { max-width: 1000px; display: grid; grid-template-columns: 4fr 5fr; gap: clamp(24px, 5vw, 80px); }
.block-head { max-width: 46em; margin-bottom: 40px; }
.block-head h2 { margin-bottom: 14px; }
.block-head p { color: var(--ash); margin: 0; }
.prose p { font-size: 1.12rem; color: #d9d0c1; }

/* loop steps: genuine sequence */
.steps {
  list-style: none; margin: 0; padding: 0; counter-reset: s;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  border-top: 1px solid var(--ridge);
}
.steps li {
  counter-increment: s; padding: 24px 22px 28px 0; margin-right: 22px;
  border-bottom: 1px solid var(--ridge);
}
.steps li::before {
  content: counter(s); display: block; margin-bottom: 14px;
  font: 600 2.4rem/1 var(--display); color: var(--gold);
}
.steps li:last-child { grid-column: span 2; }
.steps h3 { margin-bottom: 8px; }
.steps p { color: var(--ash); font-size: 0.98rem; margin: 0; }

/* signal lab */
.lab { max-width: none; background: var(--basalt); border-block: 1px solid var(--ridge); }
.lab > * { max-width: 1280px; margin-inline: auto; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: clamp(20px, 3vw, 48px); align-items: start; }
.chart-wrap { background: var(--regolith); border: 1px solid var(--ridge); border-radius: 20px; padding: 18px 18px 8px; }
#chart { width: 100%; height: auto; display: block; }
#chart text { fill: var(--ash); font: 12px var(--body); }
#chart .line { fill: none; stroke: var(--ridge); stroke-width: 3; }
#chart .line-live { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.scrub { display: block; padding: 8px 6px 14px; }
.scrub span { display: block; font-size: 0.92rem; color: var(--ash); margin-bottom: 6px; }
.scrub input { width: 100%; accent-color: var(--gold); height: 28px; }

.readout { border: 1px solid var(--ridge); border-radius: 20px; padding: 24px; background: var(--regolith); }
.state {
  display: inline-block; padding: 4px 14px; border-radius: 999px; margin-bottom: 18px;
  font: 600 1rem var(--display); color: #08140a; background: var(--ok);
}
.state[data-level="warn"] { background: var(--warn); color: #1c1203; }
.state[data-level="alarm"] { background: var(--alert); color: #1d0405; }
.readout dl { margin: 0 0 16px; }
.readout dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--ridge); }
.readout dt { color: var(--ash); font-size: 0.95rem; }
.readout dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.action { margin: 0; font-size: 1rem; min-height: 5.5em; }

/* AI vs rules */
.compare-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.compare-chart { margin: 0; background: var(--basalt); border: 1px solid var(--ridge); border-radius: 20px; padding: 18px; }
.compare-chart figcaption { color: var(--ash); font-size: 0.85rem; margin-top: 10px; }
.legend { list-style: none; display: flex; gap: 20px; margin: 0 0 8px; padding: 0; font-size: 0.92rem; color: var(--ash); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }
.dot.rules { background: #9a968f; }
.dot.ml { background: var(--gold); }
#compare-svg { width: 100%; height: auto; display: block; }
#compare-svg text { fill: var(--ash); font: 12px var(--body); }
.stats { margin: 0 0 20px; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--ridge); }
.stats dt { color: var(--ash); font-size: 0.95rem; }
.stats dd { margin: 0; font: 600 1.6rem var(--display); color: var(--gold); white-space: nowrap; }
.compare-notes h3 { margin: 22px 0 10px; }
.adds { margin: 0 0 16px; padding-left: 1.1em; color: #d9d0c1; }
.adds li { margin-bottom: 6px; }
.muted { color: var(--ash); font-size: 0.95rem; }

/* method */
.method-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: clamp(24px, 4vw, 64px); align-items: start; }
.method { list-style: none; margin: 0; padding: 0; counter-reset: m; border-top: 1px solid var(--ridge); }
.method li { counter-increment: m; position: relative; padding: 22px 0 22px 56px; border-bottom: 1px solid var(--ridge); }
.method li::before { content: counter(m); position: absolute; left: 0; top: 20px; font: 600 1.9rem/1 var(--display); color: var(--gold); }
.method h3 { margin-bottom: 6px; }
.method p { margin: 0; color: #d9d0c1; font-size: 1rem; }
.limits { background: var(--basalt); border: 1px solid var(--ridge); border-radius: 20px; padding: 24px; position: sticky; top: 84px; }
.limits h3 { margin-bottom: 12px; }
.limits .adds { margin: 0; }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--ridge); border-radius: 16px; }
table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 0.98rem; }
th, td { text-align: left; padding: 14px 18px; vertical-align: top; border-bottom: 1px solid var(--ridge); }
thead th { color: var(--ash); font-weight: 500; background: var(--basalt); font-size: 0.9rem; }
tbody th { font-weight: 600; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
td { color: #d9d0c1; }

/* tiers */
.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tiers article { background: var(--basalt); border: 1px solid var(--ridge); border-radius: 20px; padding: 26px; }
.tiers h3 { margin-bottom: 10px; }
.tiers p { color: #d9d0c1; font-size: 0.98rem; }
.tiers .eg { color: var(--ash); font-size: 0.92rem; margin: 0; }
.callout {
  margin: 28px 0 0; padding: 18px 22px; max-width: 52em;
  border-left: 3px solid var(--gold); background: rgba(233, 201, 150, 0.07);
  border-radius: 0 12px 12px 0;
}

/* state machine: genuine sequence */
.states {
  list-style: none; margin: 0 0 56px; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.states li {
  position: relative; padding: 18px 16px; border: 1px solid var(--ridge); border-radius: 14px; background: var(--basalt);
  display: flex; flex-direction: column; gap: 4px;
}
.states li:not(:last-child)::after {
  content: ""; position: absolute; right: -11px; top: 50%; width: 12px; height: 2px; background: var(--gold);
}
.states b { font: 600 1.05rem var(--display); }
.states span { color: var(--ash); font-size: 0.9rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 5vw, 80px); }
.two-col h3 { margin-bottom: 12px; }
.two-col p { color: #d9d0c1; }

/* tests */
.tests { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 clamp(24px, 5vw, 80px); }
.tests li { padding: 20px 0; border-top: 1px solid var(--ridge); color: #d9d0c1; }
.tests b { display: block; font: 600 1.15rem var(--display); color: var(--moon); margin-bottom: 4px; }

/* app */
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.app-grid article { background: var(--basalt); border: 1px solid var(--ridge); border-radius: 20px; padding: 24px; }
.app-grid h3 { margin-bottom: 8px; }
.app-grid p { margin: 0; color: var(--ash); font-size: 0.98rem; }

footer {
  display: flex; align-items: center; gap: 16px;
  padding: 40px var(--gutter); border-top: 1px solid var(--ridge); color: var(--ash); font-size: 0.92rem;
}
footer p { margin: 0; }
footer strong { color: var(--moon); }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .stage { height: 60vh; }
  .facts dl { grid-template-columns: repeat(2, 1fr); }
  .block.narrow, .lab-grid, .compare-grid, .method-grid, .contact-grid, .two-col, .tests { grid-template-columns: 1fr; }
  .tiers, .app-grid { grid-template-columns: 1fr; }
  .limits { position: static; }
  .states { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .steps li:last-child { grid-column: auto; }
  .states li:not(:last-child)::after { right: auto; left: 24px; top: auto; bottom: -11px; width: 2px; height: 12px; }
}
@media (max-width: 600px) {
  .table-wrap { border: 0; overflow: visible; }
  table, tbody, tr, th, td { display: block; min-width: 0; width: 100%; }
  thead { position: absolute; left: -9999px; }
  tbody tr { border: 1px solid var(--ridge); border-radius: 14px; margin-bottom: 12px; padding: 6px 0; background: var(--basalt); }
  tbody th { white-space: normal; border: 0; padding: 12px 16px 4px; font-size: 1.05rem; }
  tbody td { border: 0; padding: 4px 16px; }
  tbody td::before { content: attr(data-label); display: block; color: var(--ash); font-size: 0.8rem; }
  tbody tr:last-child > * { border-bottom: 0; }
  #chart text { font-size: 21px; }
  #compare-svg text { font-size: 19px; }
  .facts dd { font-size: 1.6rem; }
  .facts div { padding-right: 12px; }
  .stage { height: 56vh; min-height: 380px; }
  .stage-tools span { display: none; }
  .hero-actions .btn { text-align: center; flex: 1 1 100%; }
  .footer-note, footer { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
