:root {
  --ground: #eef1f4;
  --paper: #ffffff;
  --ink: #16202b;
  --muted: #5c6b78;
  --rule: #ccd6de;
  --signal: #1f6f5c;
  --flag: #a2402c;
  --hold: #8a7430;

  --j0: #1f6f5c;
  --j1: #2f6690;
  --j2: #a2402c;
  --j3: #6b4f8a;
  --j4: #3f7d5c;
  --j5: #8a7430;

  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --wrap: 1140px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
p { margin: 0 0 1rem; max-width: 68ch; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

code { font-family: var(--mono); font-size: 0.82rem; }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(238, 241, 244, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--display);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 3px solid var(--signal);
}

.topbar nav { display: flex; gap: 1.25rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: 0.88rem; }
.topbar nav a:hover { color: var(--ink); }

.repo-link {
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid var(--ink);
  padding: 0.32rem 0.8rem;
  border-radius: 2px;
}
.repo-link:hover { background: var(--ink); color: var(--ground); }

/* ---------- hero ---------- */

.hero {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2.5rem) 2rem;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--signal);
  margin: 0 0 0.9rem;
}

.hero-lede { color: var(--muted); font-size: 1.06rem; margin-top: 1.1rem; }

.hero-links { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.6rem; }

.button {
  display: inline-block;
  text-decoration: none;
  background: var(--ink);
  color: var(--ground);
  padding: 0.6rem 1.15rem;
  border-radius: 2px;
  font-size: 0.9rem;
  border: 1px solid var(--ink);
}
.button:hover { background: #0d1620; }
.button.ghost { background: transparent; color: var(--ink); }
.button.ghost:hover { background: var(--paper); }

.trace {
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.1rem 1.2rem 0.9rem;
}
.trace figcaption {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
#trace-plot svg { display: block; width: 100%; height: auto; }

.trace-key {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.7rem 0 0;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.trace-key li { display: flex; align-items: center; gap: 0.4rem; }
.trace-key i { width: 14px; height: 2px; display: block; }

/* ---------- figures ---------- */

.figures {
  max-width: min(var(--wrap), calc(100% - 2rem));
  margin: 0 auto clamp(2.5rem, 5vw, 4rem);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.figures article { background: var(--paper); padding: 1.1rem 1rem; }
.figures strong {
  display: block;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.figures span { font-size: 0.78rem; color: var(--muted); }

/* ---------- bands ---------- */

.band { padding: clamp(3rem, 6vw, 4.5rem) 0; border-top: 1px solid var(--rule); }
.band.tint { background: #e6ebef; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }

.head { margin-bottom: 2.2rem; }
.head p { color: var(--muted); margin-top: 0.7rem; }

/* ---------- funnel ---------- */

.funnel { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.75rem; margin-bottom: 2.2rem; }

.funnel-step {
  flex: 1 1 200px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--signal);
  border-radius: 2px;
  padding: 1rem 1.1rem;
}
.funnel-step.removed { border-left-color: var(--flag); }
.funnel-step b {
  display: block;
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.funnel-step span { display: block; margin-top: 0.35rem; font-size: 0.9rem; }
.funnel-step small { display: block; margin-top: 0.5rem; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }

/* ---------- checks ---------- */

.checks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.check { background: var(--paper); padding: 1rem 1.1rem; }
.check-top { display: flex; align-items: baseline; gap: 0.55rem; }
.check-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.check-dot.pass { background: var(--signal); }
.check-dot.pending { background: var(--hold); }
.check-dot.fail { background: var(--flag); }
.check-top strong { font-size: 0.92rem; font-weight: 500; }
.check-value { font-family: var(--mono); font-size: 0.82rem; margin: 0.4rem 0 0.3rem; }
.check small { color: var(--muted); font-size: 0.8rem; line-height: 1.5; }

.provenance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  align-items: center;
  margin-top: 1.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: none;
}
.provenance code { background: var(--paper); border: 1px solid var(--rule); padding: 0.15rem 0.45rem; border-radius: 2px; }

/* ---------- run ---------- */

.run-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.4rem;
}
.run-id { display: flex; align-items: center; gap: 0.75rem; }
.pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  background: var(--signal);
  color: #fff;
}
.pill.pending { background: var(--hold); }
.run-id strong { font-family: var(--mono); font-size: 0.88rem; font-weight: 500; }

.run-progress { flex: 1 1 320px; }
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.track { height: 6px; background: #dde4e9; border-radius: 3px; overflow: hidden; }
.bar { height: 100%; background: var(--signal); width: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.metrics article { background: var(--paper); padding: 0.95rem 1.05rem; }
.metrics span { display: block; font-size: 0.78rem; color: var(--muted); }
.metrics strong {
  display: block;
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 0.2rem;
}

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; }
.chart-panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.1rem 1.2rem 1rem;
}
.chart-panel h3 { font-size: 1rem; }
.chart-panel .sub { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); margin: 0.25rem 0 0.9rem; }
.chart-body svg { display: block; width: 100%; height: auto; }

.empty {
  border: 1px dashed var(--rule);
  border-radius: 2px;
  padding: 1.4rem 1.2rem;
  color: var(--muted);
  font-size: 0.86rem;
  background: #fafbfc;
}
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 0.35rem; font-size: 0.92rem; }
.empty code { display: inline-block; margin-top: 0.5rem; background: var(--paper); border: 1px solid var(--rule); padding: 0.2rem 0.45rem; border-radius: 2px; }

/* ---------- joints ---------- */

.joints { display: grid; gap: 0.6rem; }
.joint {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.75rem 1rem;
}
.joint-name { font-family: var(--mono); font-size: 0.82rem; }
.joint-bar { position: relative; height: 8px; background: #e3e9ed; border-radius: 4px; }
.joint-span { position: absolute; top: 0; bottom: 0; background: var(--signal); opacity: 0.35; border-radius: 4px; }
.joint-median { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.joint-figs { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- stages ---------- */

.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }
.stage {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.1rem 1.15rem;
}
.stage-index { font-family: var(--mono); font-size: 0.74rem; color: var(--signal); }
.stage h3 { font-size: 1.05rem; margin: 0.35rem 0 0.4rem; }
.stage p { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.7rem; }
.stage-rate { font-family: var(--mono); font-size: 0.8rem; color: var(--hold); }

/* ---------- access ---------- */

.access { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: clamp(2rem, 5vw, 3.5rem); align-items: start; }
.access p { color: var(--muted); }
.access h2 { margin-bottom: 1rem; }

.spec { margin: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; }
.spec div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--rule); }
.spec div:last-child { border-bottom: 0; }
.spec dt { font-size: 0.82rem; color: var(--muted); }
.spec dd { margin: 0; font-family: var(--mono); font-size: 0.8rem; text-align: right; }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  padding: 1.6rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}
footer p { margin: 0; max-width: none; }
footer a { color: var(--ink); }

.error {
  position: fixed;
  inset: auto 1rem 1rem auto;
  background: var(--paper);
  border: 1px solid var(--flag);
  border-left: 3px solid var(--flag);
  padding: 0.9rem 1.1rem;
  border-radius: 2px;
  max-width: 340px;
  font-size: 0.85rem;
}
.error p { margin: 0.3rem 0 0; color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(3, 1fr); }
  .checks { grid-template-columns: repeat(2, 1fr); }
  .access { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar nav { display: none; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .checks { grid-template-columns: 1fr; }
  .joint { grid-template-columns: 1fr; gap: 0.5rem; }
  .joint-figs { text-align: left; }
}

/* ---------- configuration ---------- */

.config-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
  align-items: start;
}
.config-group h3 { font-size: 1rem; margin-bottom: 0.6rem; }
.config-group .spec div { padding: 0.5rem 0.9rem; }

/* keep long paths inside their box (fixes phone-width overflow) */
.empty code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; word-break: break-all; white-space: normal; }
