:root {
  --bg: #111315;
  --panel: #1a1d21;
  --border: #2a2f36;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #5b9fd4;
  --good: #3ecf8e;
  --bad: #f07178;
  --warn: #e6b450;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.loading { padding: 2rem; color: var(--muted); }
header.app-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem 1.1rem;
  background: var(--bg);
}
header h1 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, monospace;
}
header .tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 62ch;
  line-height: 1.45;
}
header p { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 70ch; }
.meta { margin-top: 0.55rem; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-start;
  margin-top: 0.65rem;
}
.mission-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  max-width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #14181e;
}
.mission-selector.header-mission {
  flex: 1 1 18rem;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 159, 212, 0.15);
}
.mission-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.mission-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.mission-seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.mission-seg-btn:last-child {
  border-right: none;
}
.mission-seg-btn:hover {
  color: var(--text);
  background: rgba(91, 159, 212, 0.08);
}
.mission-seg-btn.active {
  background: rgba(91, 159, 212, 0.18);
  color: var(--accent);
  font-weight: 600;
}
.mission-hint {
  flex: 1 1 14rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 48ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.active-mission-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #14181e;
}
.active-mission-chip strong {
  color: var(--accent);
  font-weight: 600;
}
.matrix-mission-row {
  align-items: center;
  margin-bottom: 0.65rem;
}
.env-filters {
  margin: 0.5rem 0 0.65rem;
  gap: 0.4rem;
}
.env-chip {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.env-chip.active {
  border-color: var(--accent);
  color: var(--accent);
}
.env-scheme-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  margin: 0 0 0.85rem;
}
.env-scheme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  user-select: none;
}
.env-scheme-toggle.on {
  color: var(--text);
  background: #14181e;
}
.env-scheme-toggle input {
  margin: 0;
}
.env-swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  flex: 0 0 auto;
}
.env-swatch.inline {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.data-table-toolbar {
  gap: 0.75rem 1rem;
  margin-bottom: 0.65rem;
  align-items: flex-end;
}
.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.toolbar-field.grow {
  flex: 1 1 12rem;
  min-width: 10rem;
}
.toolbar-field input[type="search"],
.toolbar-field select {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
  min-width: 8rem;
}
.toolbar-field.grow input {
  width: 100%;
}
.toolbar-count {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.4rem;
}
.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}
.data-table-wrap.scroll-y {
  max-height: min(28rem, 60vh);
}
table.data-table {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}
table.data-table th,
table.data-table td {
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
}
table.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  color: var(--muted);
}
table.data-table th.sortable:hover {
  color: var(--accent);
}
table.data-table th.sorted {
  color: var(--accent);
}
table.data-table td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 0.8rem;
}
table.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
table.data-table tbody tr.row-fail {
  color: #e8a0a0;
}
table.data-table tbody tr:hover {
  background: rgba(91, 159, 212, 0.08);
}
table.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a1d21;
  box-shadow: 0 1px 0 var(--border);
}
.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill.ok {
  background: rgba(62, 207, 142, 0.15);
  color: var(--good);
}
.pill.fail {
  background: rgba(240, 113, 120, 0.15);
  color: var(--bad);
}
.plot-card {
  overflow: hidden;
}
nav.tabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border);
}
nav.tabs button {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.4rem 0.85rem; cursor: pointer; font-size: 0.85rem;
}
nav.tabs button.active { border-color: var(--accent); color: var(--accent); }
main { padding: 1rem 1.5rem 2.5rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem;
}
.card h2, .card h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.stat { font-size: 1.4rem; font-weight: 600; }
.stat span { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 400; }
table.metrics { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.metrics th, table.metrics td {
  text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border);
}
table.metrics th { color: var(--muted); font-weight: 500; }
.ok { color: var(--good); }
.fail { color: var(--bad); }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
select, input[type="range"] {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0.5rem;
}
.compare-controls {
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}
.compare-pick {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: min(100%, 16rem);
  flex: 1 1 14rem;
}
.compare-pick-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.compare-pick select {
  width: 100%;
  max-width: 28rem;
  font-size: 0.88rem;
}
.btn-swap {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  margin-bottom: 0.05rem;
}
.btn-swap:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* Plotly: captions live outside the SVG so the modebar never covers titles */
.plot-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.plot-caption {
  margin: 0;
  padding: 0 0.15rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  /* Reserve the right edge so hover modebar doesn't sit on long titles */
  padding-right: 5.5rem;
}
.plot {
  width: 100%;
  min-height: 240px;
  background: #0a0e16;
  border-radius: 8px;
  position: relative;
}
.plot-flight,
.plot-vehicle {
  min-height: 480px;
  border: 1px solid rgba(91, 159, 212, 0.12);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
}

/* Flight tab: dual-pane trajectory + vehicle attitude */
.flight-tab { display: flex; flex-direction: column; gap: 0.85rem; }
.flight-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  padding: 0.85rem 1rem;
}
.flight-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
}
.flight-time { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.flight-scrub {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1 1 16rem;
  min-width: min(100%, 14rem);
}
.flight-scrub label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flight-scrub input[type="range"] {
  flex: 1 1 auto;
  min-width: 8rem;
  accent-color: var(--accent);
}
.flight-frame { font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flight-keys {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  opacity: 0.85;
  user-select: none;
  white-space: nowrap;
}
.flight-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 960px) {
  .flight-stage { grid-template-columns: 1fr; }
}
.flight-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.85rem 0.9rem 1rem;
  background:
    linear-gradient(165deg, rgba(91, 159, 212, 0.06) 0%, transparent 42%),
    var(--panel);
}
.flight-panel-vehicle {
  background:
    linear-gradient(200deg, rgba(230, 180, 80, 0.05) 0%, transparent 40%),
    var(--panel);
}
.panel-title {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-sub {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}
.muted { color: var(--muted); }
.mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* Numeric wrench / attitude HUD under vehicle plot */
.wrench-hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
@media (max-width: 520px) {
  .wrench-hud { grid-template-columns: 1fr; }
}
.hud-block {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem 0.55rem;
  min-width: 0;
}
.hud-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}
.hud-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.hud-value.accent-f { color: #4fd1ff; }
.hud-value.accent-t { color: #e6b450; }
.hud-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.25rem;
}
.hud-sub {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-bar {
  margin-top: 0.35rem;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.hud-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.08s linear;
}
/* Modebar only on hover (config) — keep it compact when visible */
.plot .modebar-container,
.plot .modebar {
  top: 4px !important;
  right: 4px !important;
}
.plot .modebar-btn path {
  fill: #9aa0a6 !important;
}
.footer {
  padding: 1rem 1.5rem 2rem; color: var(--muted); font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--accent); }

/* Cross-demo links (Pages: / + /intercept/) */
.site-demos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  margin: 0.45rem 0 0.35rem;
  font-size: 0.8rem;
}
.site-demos-label {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
.site-demo-link {
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  background: rgba(255, 255, 255, 0.03);
}
.site-demo-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.site-demo-link.is-current {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(126, 200, 255, 0.12);
  pointer-events: none;
}
.badge {
  display: inline-block; padding: 0.15rem 0.45rem; border-radius: 4px;
  font-size: 0.7rem; background: var(--border);
}
.badge.lqr { background: #1e3a5f; color: #7ec8ff; }
.badge.lqg { background: #3a3218; color: #e6c86e; }
.badge.naive { background: #4a2020; color: #f0a0a0; }
.badge.ahrs { background: #1e3040; color: #9ec8e8; }
.badge.weak { background: #3a3020; color: #d0b090; }
.badge.pid { background: #3a2a1e; color: #ffc07e; }
.badge.ndi { background: #1e3a2a; color: #7ee6b0; }


.badge.mc { background: #1e3a2f; color: #7dffb3; }
.badge-row { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; vertical-align: middle; }

/* Controller × sensor overview matrix — equal column gaps & card sizes */
.matrix-wrap { overflow: hidden; }
.matrix-scroll {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
table.controller-matrix {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0.65rem;
  font-size: 0.85rem;
  /* Prefer horizontal scroll over squeezing uneven columns */
  min-width: 1120px;
}
table.controller-matrix col.row-head {
  width: 6.75rem;
}
table.controller-matrix col.sensor {
  /* Equal share of remaining width (6 sensor columns) */
  width: calc((100% - 6.75rem) / 6);
}
table.controller-matrix th.corner,
table.controller-matrix th.row-label {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  vertical-align: middle;
  padding: 0 0.15rem;
  box-sizing: border-box;
}
table.controller-matrix thead th {
  text-align: center;
  color: var(--text);
  font-weight: 600;
  padding: 0.15rem 0.25rem 0.45rem;
  vertical-align: bottom;
  box-sizing: border-box;
}
table.controller-matrix thead th .col-label {
  line-height: 1.25;
  min-height: 2.4em; /* two lines of title → uniform header band */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
}
table.controller-matrix thead th .col-sub {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.2;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.controller-matrix td {
  vertical-align: top;
  padding: 0;
  height: 1px; /* lets .matrix-cell height:100% fill the row */
}
table.controller-matrix tbody th.row-label {
  vertical-align: middle;
}
.matrix-cell {
  margin: 0;
  height: 100%;
  min-height: 8.75rem;
  box-sizing: border-box;
  padding: 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
  transition: border-color 0.12s ease;
}
.matrix-cell:hover { border-color: var(--accent); }
.matrix-cell.cell-fail { border-color: #6a3030; }
.matrix-cell.empty {
  opacity: 0.35;
  min-height: 8.75rem;
  align-items: center;
  justify-content: center;
}
.matrix-cell-head {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 2.1rem; /* one line method + badges without shifting RMSE */
}
.matrix-method {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.matrix-cell-head .badge-row {
  flex: 0 0 auto;
  max-width: 48%;
  justify-content: flex-end;
}
.matrix-rmse {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.matrix-rmse span {
  margin-top: 0.15rem;
}
.matrix-meta {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matrix-meta-sec {
  color: var(--muted);
  opacity: 0.85;
}
.matrix-lead {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.65rem;
  line-height: 1.45;
  max-width: 72ch;
}
.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.legend-item .lg {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: inline-block;
}
.legend-item .lg.pass {
  background: rgba(62, 207, 142, 0.25);
  border-color: var(--good);
}
.legend-item .lg.fail {
  background: rgba(240, 113, 120, 0.2);
  border-color: #6a3030;
}
.legend-item .lg.teach {
  background: rgba(91, 159, 212, 0.2);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 159, 212, 0.35);
}
.legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  cursor: pointer;
  color: var(--text);
  font-size: 0.78rem;
}
.matrix-cell.cell-teach {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 159, 212, 0.35);
  background: linear-gradient(180deg, rgba(91, 159, 212, 0.07), transparent 55%), var(--panel);
}
table.controller-matrix th.th-teach .col-label {
  color: var(--accent);
}

/* Sticky header + story strip */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(17, 19, 21, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.5rem;
  align-items: flex-start;
  justify-content: space-between;
}
.header-brand {
  flex: 1 1 18rem;
  min-width: min(100%, 16rem);
}
header .value-prop {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 500;
  max-width: 42ch;
  line-height: 1.4;
}
.about-toggle {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.about-panel {
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #14181e;
  max-width: 52rem;
}
.about-panel p {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}
.about-panel p:last-child {
  margin-bottom: 0;
}
.desktop-note {
  color: var(--muted) !important;
  font-size: 0.8rem !important;
}

.story-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(42, 47, 54, 0.85);
}
.story-strip-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.35rem;
}
.story-arrow {
  color: var(--muted);
  opacity: 0.5;
  font-size: 0.85rem;
  user-select: none;
}
.story-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  text-align: left;
}
.story-step:hover {
  border-color: var(--accent);
}
.story-step.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 159, 212, 0.25);
  background: rgba(91, 159, 212, 0.1);
}
.story-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: #0c1018;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  flex: 0 0 auto;
}
.story-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.15;
}
.story-title {
  font-size: 0.8rem;
  font-weight: 600;
}
.story-blurb {
  font-size: 0.68rem;
  color: var(--muted);
}

/* Suggested-first-look CTA */
.hero-cta {
  background:
    linear-gradient(120deg, rgba(91, 159, 212, 0.12) 0%, transparent 48%),
    linear-gradient(300deg, rgba(230, 180, 80, 0.06) 0%, transparent 40%),
    var(--panel);
  border-color: rgba(91, 159, 212, 0.35);
}
.hero-cta-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.hero-cta-title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}
.hero-cta-copy {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 70ch;
}
.hero-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn-primary,
.btn-ghost {
  appearance: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.btn-primary {
  border: 1px solid var(--accent);
  background: rgba(91, 159, 212, 0.2);
  color: #d6ebfa;
}
.btn-primary:hover {
  background: rgba(91, 159, 212, 0.32);
}
.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.tab-toolbar {
  margin-bottom: 0.75rem;
  gap: 0.65rem 1rem;
}
.run-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.run-pick select {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 0.88rem;
}
.compare-caption {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
}
.collapse-toggle {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.15rem 0;
  text-align: left;
}
.collapse-toggle:hover {
  color: var(--accent);
}
.collapse-meta {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}
.collapse-body {
  margin-top: 0.75rem;
}
table.data-table td.td-notes {
  max-width: 18rem;
  white-space: normal;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
table.data-table tr.row-click:hover {
  background: rgba(91, 159, 212, 0.1);
}
.table-sub {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}
.readout-list {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  padding-left: 1.15rem;
}
.readout-list li {
  margin-bottom: 0.4rem;
}
.readout-list strong {
  color: var(--text);
}

nav.tabs button[aria-selected="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* —— System tab: closed-loop stack provenance —— */
.stack-tab {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.stack-muted {
  color: var(--muted);
}
.stack-empty code {
  font-size: 0.88em;
}

/* Simulink-style SVG block diagram */
.stack-diagram-wrap {
  margin-top: 0.35rem;
}
.bd-caption-row {
  margin: 0 0 0.45rem;
}
.bd-caption {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.bd-svg {
  display: block;
  width: 100%;
  max-width: 1000px;
  height: auto;
  background: #0a0e16;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
}
.bd-wire {
  fill: none;
  stroke: #7a93b0;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bd-arrow-head {
  fill: #7a93b0;
  stroke: none;
}
.bd-sig {
  fill: #a8b8cc;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-style: italic;
  pointer-events: none;
  user-select: none;
}
.bd-sum-circle {
  fill: #12161c;
  stroke: #8ab4e8;
  stroke-width: 1.75;
}
.bd-sum-plus,
.bd-sum-minus {
  fill: #e7ecf3;
  font-size: 14px;
  font-weight: 600;
  font-family: system-ui, sans-serif;
  pointer-events: none;
}
.bd-block {
  cursor: pointer;
  outline: none;
}
.bd-block .bd-block-rect {
  fill: #141a22;
  stroke: #3a4a60;
  stroke-width: 1.6;
  transition: fill 0.12s ease, stroke 0.12s ease, filter 0.12s ease;
}
.bd-block:hover .bd-block-rect {
  stroke: #5b9fd4;
  fill: #1a2430;
}
.bd-block.is-active .bd-block-rect {
  stroke: #5b9fd4;
  stroke-width: 2.2;
  fill: rgba(91, 159, 212, 0.16);
  filter: drop-shadow(0 0 4px rgba(91, 159, 212, 0.35));
}
.bd-block.is-missing {
  cursor: not-allowed;
  opacity: 0.45;
}
.bd-block.is-missing .bd-block-rect {
  stroke-dasharray: 4 3;
}
.bd-block-title {
  fill: #e7ecf3;
  font-size: 13px;
  font-weight: 600;
  font-family: system-ui, -apple-system, sans-serif;
  pointer-events: none;
}
.bd-block-sub {
  fill: #8a96a8;
  font-size: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  pointer-events: none;
}
/* Kind accent strokes (left edge via thicker stroke color) */
.bd-block.kind-controller .bd-block-rect {
  stroke: #5b9fd4;
}
.bd-block.kind-observer .bd-block-rect {
  stroke: #e6c86e;
}
.bd-block.kind-plant .bd-block-rect {
  stroke: #3ecf8e;
}
.bd-block.kind-sensors .bd-block-rect {
  stroke: #9ec8e8;
}
.bd-block.kind-mission .bd-block-rect,
.bd-block.kind-guidance .bd-block-rect {
  stroke: #8a93a0;
}
.bd-block.kind-actuators .bd-block-rect {
  stroke: #ffc07e;
}
.bd-block.kind-metrics .bd-block-rect {
  stroke: #7dffb3;
}
.bd-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.55rem 0 0;
  padding: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.bd-legend span::before {
  content: "· ";
  color: #5b9fd4;
}
.stack-detail-card {
  min-height: 8rem;
}
.stack-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.35rem;
}
.stack-detail-head h3 {
  margin: 0;
  font-size: 1.05rem;
}
.stack-detail-kind {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.stack-detail-summary {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.stack-equations {
  margin: 0 0 1rem;
  border: 1px solid rgba(232, 121, 249, 0.28);
  border-radius: 8px;
  background: rgba(232, 121, 249, 0.06);
  overflow: hidden;
}
.stack-equations-caption {
  padding: 0.45rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e879f9;
  border-bottom: 1px solid rgba(232, 121, 249, 0.2);
  background: rgba(0, 0, 0, 0.2);
}
.stack-equations-body {
  margin: 0;
  padding: 0.75rem 0.85rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #e7ecf3;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.stack-detail-empty {
  padding: 0.25rem 0;
}
.stack-kv {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr;
  gap: 0.35rem 0.85rem;
  margin: 0;
  font-size: 0.85rem;
}
.stack-kv dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.stack-kv dd {
  margin: 0;
  min-width: 0;
}
.stack-kv-nested {
  margin-top: 0.15rem;
  padding: 0.4rem 0.5rem;
  border-left: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 6px 6px 0;
}
.stack-gains {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.stack-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.stack-matrix-caption {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}
table.stack-matrix {
  border-collapse: collapse;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
}
table.stack-matrix td {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  text-align: right;
  background: #12161c;
  white-space: nowrap;
}
.stack-vector {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin: 0.15rem 0;
}
.stack-vector-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}
.stack-vector-vals {
  font-size: 0.78rem;
  color: var(--text);
  word-break: break-all;
  background: #12161c;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}
.stack-list {
  margin: 0.15rem 0;
  padding-left: 1.1rem;
  color: var(--text);
}
.stack-list-inline {
  word-break: break-word;
}
.stack-scalar {
  word-break: break-word;
}
.stack-identity {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.75rem 1rem;
}
.stack-identity-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.stack-identity-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
}
.stack-id-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
  font-size: 0.78rem;
}
.stack-id-key {
  color: var(--muted);
  font-weight: 500;
}
.stack-id-item code {
  font-size: 0.78rem;
  color: var(--text);
  background: #12161c;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  word-break: break-all;
}

@media (max-width: 720px) {
  .story-blurb {
    display: none;
  }
  .header-top {
    flex-direction: column;
  }
  .legend-toggle {
    margin-left: 0;
  }
  .stack-kv {
    grid-template-columns: 1fr;
    gap: 0.15rem 0;
  }
  .stack-kv dt {
    margin-top: 0.35rem;
  }
  .bd-legend {
    gap: 0.25rem 0.65rem;
  }
}
