:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --ink: #16202a;
  --muted: #687586;
  --line: #d9e0e8;
  --copy: #344150;
  --panel-copy: #3d4a59;
  --control-bg: #eef2f6;
  --header-bg: #f9fafc;
  --chip-bg: #eef4fb;
  --note-bg: #f7f5fc;
  --note-ink: #312a45;
  --good-bg: #e9f6ef;
  --risk-bg: #fff3e7;
  --bad-bg: #faeaea;
  --raw-bg: #f7ebdf;
  --decoded-bg: #eaf0f8;
  --repaired-bg: #edf7f2;
  --button-ink-on-accent: #ffffff;
  --button-shadow: rgba(22, 32, 42, 0.12);
  --teal: #167a7f;
  --blue: #285d9f;
  --amber: #b86716;
  --red: #b64040;
  --green: #287a50;
  --violet: #6750a4;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #282c34;
  --surface: #21252b;
  --surface-soft: #2c313a;
  --ink: #d7dae0;
  --muted: #8d95a3;
  --line: #3e4451;
  --copy: #abb2bf;
  --panel-copy: #abb2bf;
  --control-bg: #2c313a;
  --header-bg: #252a32;
  --chip-bg: #263747;
  --note-bg: #2b2938;
  --note-ink: #d7dae0;
  --good-bg: #26372d;
  --risk-bg: #3b3024;
  --bad-bg: #3b2930;
  --raw-bg: #3b3024;
  --decoded-bg: #263747;
  --repaired-bg: #26372d;
  --button-ink-on-accent: #1d232a;
  --button-shadow: rgba(0, 0, 0, 0.32);
  --teal: #56b6c2;
  --blue: #61afef;
  --amber: #d19a66;
  --red: #e06c75;
  --green: #98c379;
  --violet: #c678dd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 88px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.16;
}

h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
}

h3 {
  margin: 0;
  font-size: 15px;
}

p {
  line-height: 1.5;
}

.deck-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.slide-count {
  min-width: 56px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  text-align: center;
}

.deck-button {
  min-width: 76px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.deck-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.deck-button-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--button-ink-on-accent);
}

.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.theme-glyph {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

html[data-theme="dark"] .theme-glyph {
  background: currentColor;
  box-shadow: inset -5px 0 0 var(--surface);
}

.deck {
  height: calc(100vh - 88px);
  overflow: hidden;
}

.slide {
  display: none;
  height: 100%;
  overflow: auto;
  padding: 22px;
}

.slide.is-active {
  display: block;
}

.slide-shell {
  display: grid;
  align-content: center;
  gap: 26px;
  width: min(1180px, 100%);
  min-height: 100%;
  margin: 0 auto;
}

.hero-layout {
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  align-items: center;
}

.slide-copy {
  display: grid;
  gap: 16px;
}

.slide-copy p {
  max-width: 760px;
  margin: 0;
  color: var(--copy);
  font-size: 20px;
}

.signal-grid,
.evidence-grid,
.value-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.signal-tile,
.evidence-tile,
.value-tile,
.flow-step {
  min-width: 0;
  min-height: 136px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.signal-tile span,
.evidence-tile span,
.value-tile span,
.flow-step span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
}

.signal-tile strong,
.evidence-tile strong,
.flow-step strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
}

.value-tile p,
.flow-step p,
.evidence-tile p {
  margin: 10px 0 0;
  color: var(--panel-copy);
}

.flow-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.flow-step {
  min-height: 180px;
}

.flow-step strong {
  color: var(--teal);
}

.note-band {
  padding: 16px 18px;
  border-left: 4px solid var(--violet);
  border-radius: 8px;
  background: var(--note-bg);
  color: var(--note-ink);
  font-size: 17px;
  line-height: 1.45;
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stage-card {
  min-height: 236px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stage-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 22px;
}

.stage-card p {
  margin: 0;
  color: var(--muted);
}

.stage-card .stage-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.evidence-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.evidence-tile {
  min-height: 220px;
}

.evidence-tile strong {
  color: var(--green);
  font-size: 34px;
}

.evidence-risk strong {
  color: var(--amber);
  font-size: 28px;
}

.value-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.value-tile {
  min-height: 210px;
}

.value-tile span {
  color: var(--blue);
  font-size: 14px;
  text-transform: none;
}

.explorer-slide {
  padding: 16px;
}

.explorer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto 14px;
}

.explorer-head h2 {
  font-size: 26px;
}

.scenario-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.scenario-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.scenario-tab[aria-pressed="true"] {
  background: var(--surface);
  color: var(--teal);
  box-shadow: 0 1px 2px var(--button-shadow);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(500px, 1.45fr) minmax(300px, 0.9fr);
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
}

.explorer-slide .dashboard {
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  grid-template-areas:
    "comparison comparison"
    "summary orbit";
  align-items: start;
}

.explorer-slide .summary-panel {
  grid-area: summary;
}

.explorer-slide .table-panel {
  grid-area: comparison;
}

.explorer-slide .orbit-panel {
  grid-area: orbit;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  font-size: 18px;
}

.section-head > span,
.status-chip {
  flex: 0 0 auto;
  max-width: 180px;
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--chip-bg);
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.status-chip.is-good {
  background: var(--good-bg);
  color: var(--green);
}

.status-chip.is-risk {
  background: var(--risk-bg);
  color: var(--amber);
}

.status-chip.is-bad {
  background: var(--bad-bg);
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.metric {
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric span,
.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  line-height: 1.1;
}

.insight-box {
  margin: 0 14px 14px;
  padding: 12px;
  border-left: 4px solid var(--violet);
  border-radius: 8px;
  background: var(--note-bg);
  color: var(--note-ink);
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
}

.explorer-slide .table-wrap {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.explorer-slide table {
  table-layout: fixed;
  font-size: 12px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.explorer-slide th,
.explorer-slide td {
  padding: 8px 9px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.explorer-slide th:nth-child(1),
.explorer-slide td:nth-child(1) {
  width: 17%;
}

.explorer-slide th:nth-child(2),
.explorer-slide td:nth-child(2) {
  width: 10%;
}

.explorer-slide th:nth-child(3),
.explorer-slide td:nth-child(3) {
  width: 10%;
}

.explorer-slide th:nth-child(4),
.explorer-slide td:nth-child(4) {
  width: 10%;
}

.explorer-slide th:nth-child(5),
.explorer-slide td:nth-child(5) {
  width: 11%;
}

.explorer-slide th:nth-child(6),
.explorer-slide td:nth-child(6) {
  width: 30%;
}

.explorer-slide th:nth-child(7),
.explorer-slide td:nth-child(7) {
  width: 12%;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--header-bg);
  color: var(--muted);
  font-size: 12px;
}

.solver-name {
  font-weight: 760;
}

.stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--control-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.stage.raw {
  background: var(--raw-bg);
  color: var(--amber);
}

.stage.decoded {
  background: var(--decoded-bg);
  color: var(--blue);
}

.stage.repaired {
  background: var(--repaired-bg);
  color: var(--green);
}

.feasible {
  color: var(--green);
  font-weight: 760;
}

.infeasible {
  color: var(--red);
  font-weight: 760;
}

.pipeline {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.pipeline-stage {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.pipeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pipeline-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini-metric {
  min-height: 58px;
  padding: 8px;
  border-radius: 6px;
  background: var(--control-bg);
}

.mini-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.error-state {
  max-width: 860px;
  margin: 60px auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.error-state h2 {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 24px;
}

.error-state p {
  margin: 0 0 12px;
  color: var(--panel-copy);
}

.error-state code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.error-state pre {
  overflow: auto;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .deck {
    height: auto;
    min-height: calc(100vh - 88px);
  }

  .slide {
    min-height: calc(100vh - 88px);
  }

  .hero-layout,
  .flow-row,
  .stage-strip,
  .evidence-grid,
  .value-grid,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .explorer-slide .dashboard {
    grid-template-areas:
      "comparison"
      "summary"
      "orbit";
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar,
  .explorer-head {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-controls {
    justify-content: space-between;
  }

  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: 27px;
  }

  .slide {
    padding: 16px;
  }

  .slide-copy p {
    font-size: 17px;
  }

  .signal-grid,
  .metric-grid,
  .pipeline-values {
    grid-template-columns: 1fr;
  }

  .scenario-tabs {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head > span,
  .status-chip {
    max-width: 100%;
  }
}
