:root {
  --bg: #0b0b0b;
  --ink: #f3efe6;
  --muted: rgba(243, 239, 230, 0.55);
  --faint: rgba(243, 239, 230, 0.12);
  --line: rgba(243, 239, 230, 0.14);
  --accent: #c9b896;
  --accent-2: #8ea4c8;
  --luna: #9aa3ad;
  --terra: #6b4f3a;
  --sol: #e0a06a;
  --good: #9bb89a;
  --paper: #f2eee4;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --display: "IBM Plex Sans", system-ui, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* —— HOME —— */
.view-home { min-height: 100vh; }

.top {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 11, 11, 0.92);
  backdrop-filter: blur(10px);
}
.top__inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.top__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.top__mark {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}
.top__rule {
  width: 1.5rem;
  height: 1px;
  background: var(--line);
}
.top__tag {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.top__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.top__nav a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 0.1rem;
}
.top__nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.hero {
  border-bottom: 1px solid var(--line);
}
.hero__grid {
  max-width: 78rem;
  margin: 0 auto;
  padding: 3.25rem 1.5rem 2.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 0.9fr);
  gap: 2.5rem 3rem;
  align-items: end;
}
.kicker {
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0 0 1.1rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.lede {
  margin: 0 0 1rem;
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}
.fineprint {
  margin: 0;
  max-width: 38rem;
  color: rgba(243, 239, 230, 0.38);
  font-size: 0.78rem;
  line-height: 1.5;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 1.15rem;
}
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #0b0b0b;
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cta:hover {
  background: transparent;
  color: var(--ink);
}
.cta--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.cta--ghost:hover {
  color: var(--ink);
  border-color: rgba(243, 239, 230, 0.35);
}

.hero__metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.metric {
  padding: 1rem 1.05rem 1.1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric__label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}
.metric__value {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.metric__hint {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.strip {
  border-bottom: 1px solid var(--line);
}
.strip__inner {
  max-width: 78rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.model-col {
  padding: 1.35rem 1.5rem 1.5rem;
  border-right: 1px solid var(--line);
}
.model-col:last-child { border-right: 0; }
.model-col h3 {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.model-col dl {
  margin: 0;
  display: grid;
  gap: 0.45rem;
}
.model-col .row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
.model-col .row dt { color: var(--muted); }
.model-col .row dd { margin: 0; }

.block {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1rem;
}
.block--flush { padding-bottom: 2rem; }
.block__head {
  margin-bottom: 1.25rem;
  max-width: 40rem;
}
.block__head--row {
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem 1.5rem;
}
.block__head h2 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
}
.block__head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.sort-hint {
  color: rgba(243, 239, 230, 0.35) !important;
  font-size: 0.78rem !important;
}

.block--charts {
  max-width: 90rem;
}

.chart-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.chip-btn:hover { color: var(--ink); border-color: rgba(243, 239, 230, 0.35); }
.chip-btn.is-active {
  color: var(--ink);
  border-color: var(--ink);
  background: rgba(243, 239, 230, 0.06);
}
.chip-btn--luna.is-active { border-color: var(--luna); color: var(--luna); }
.chip-btn--terra.is-active { border-color: var(--terra); color: #c4a484; }
.chip-btn--sol.is-active { border-color: var(--sol); color: var(--sol); }

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 1.75rem;
}
.charts--stack {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
.chart {
  margin: 0;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  position: relative;
}
.chart--wide .chart__svg {
  min-height: 22rem;
}
.chart--half .chart__svg {
  min-height: 18rem;
}
.chart__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.chart figcaption,
.chart__head figcaption {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chart__actions {
  display: flex;
  gap: 0.5rem;
}
.chart-action {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.chart-action:hover {
  color: var(--ink);
  border-color: rgba(243, 239, 230, 0.35);
}
.chart__svg {
  width: 100%;
  overflow: visible;
  position: relative;
}
.chart__svg svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  /* crisp edges when scaled */
  shape-rendering: geometricPrecision;
}
.chart-bar {
  fill: var(--accent-2);
  opacity: 0.88;
  transition: opacity 0.12s, filter 0.12s;
  cursor: pointer;
}
.chart-bar:hover,
.chart-bar.is-hot {
  opacity: 1;
  filter: brightness(1.12);
}
.chart-bar.is-dim { opacity: 0.22; }
.chart-bar--luna { fill: var(--luna); }
.chart-bar--terra { fill: var(--terra); }
.chart-bar--sol { fill: var(--sol); }
.chart-axis { stroke: var(--faint); stroke-width: 1; }
.chart-grid {
  stroke: rgba(243, 239, 230, 0.06);
  stroke-width: 1;
}
.chart-label {
  fill: rgba(243, 239, 230, 0.48);
  font-size: 11px;
  font-family: var(--mono);
}
.chart-value {
  fill: rgba(243, 239, 230, 0.72);
  font-size: 11px;
  font-family: var(--mono);
}
.chart-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 0;
}
.chart-hint {
  margin: 1rem 0 0;
  color: rgba(243, 239, 230, 0.38);
  font-size: 0.78rem;
}

/* Floating tooltip */
.chart-tip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  padding: 0.65rem 0.8rem;
  background: #141414;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.4;
  max-width: 16rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  transform: translate(-10%, calc(-100% - 12px));
}
.chart-tip[hidden] { display: none !important; }
.chart-tip__title {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.chart-tip__meta {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}
.chart-tip__cta {
  display: block;
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* Lightbox / expand */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.82);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.lightbox[hidden] { display: none !important; }
.lightbox__panel {
  width: min(96vw, 1200px);
  max-height: 92vh;
  background: #0c0c0c;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lightbox__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.lightbox__top h3 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
}
.lightbox__top-actions {
  display: flex;
  gap: 0.5rem;
}
.lightbox__body {
  padding: 1rem 1.1rem 1.25rem;
  overflow: auto;
  min-height: 50vh;
}
.lightbox__body .chart__svg {
  min-height: min(70vh, 640px);
}
.lightbox__body svg {
  width: 100%;
  height: auto;
  min-height: 28rem;
}

.hl-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.hl-item {
  display: block;
  padding: 1rem 1.05rem 1.15rem;
  text-decoration: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}
.hl-item:hover { background: rgba(255, 255, 255, 0.03); }
.hl-item__kind {
  display: block;
  color: var(--accent);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.hl-item__title {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.hl-item__meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.table-shell {
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.matrix th,
.matrix td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
.matrix th {
  /* Not sticky: sticky thead was covering the first body row after sort,
     so one run always looked "missing" depending on sort order. */
  position: relative;
  z-index: 1;
  background: #0f0f0f;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  user-select: none;
  border-bottom: 1px solid var(--line);
}
.matrix th.sortable {
  cursor: pointer;
}
.matrix th.sortable:hover { color: var(--ink); }
.matrix th .sort-ind {
  margin-left: 0.35rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
}
.matrix tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.matrix tbody tr:hover { background: rgba(142, 164, 200, 0.06); }
.matrix .muted { color: var(--muted); }
.matrix .mono { font-family: var(--mono); font-size: 0.84rem; }
.badge {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--good);
}
.badge--miss { color: #d09090; }
.row-open {
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.foot {
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  color: rgba(243, 239, 230, 0.35);
  font-size: 0.75rem;
  border-top: 1px solid var(--line);
}

/* —— DETAIL —— */
.view-detail {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
}
.view-detail[hidden] { display: none !important; }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #0d0d0d;
}
.bar__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.9rem;
  min-width: 0;
  flex: 1 1 18rem;
}
.home-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.home-link:hover { color: var(--ink); }
.brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex-shrink: 0;
}
.mark {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}
.sub {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}
.bar__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.85rem;
  min-width: 0;
  flex: 1 1 12rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--line);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 0.65rem;
  flex-shrink: 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.field select {
  min-width: 9.25rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--line);
  background: #121212;
  color: var(--ink);
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.84rem;
}
.field select:focus {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.ghost {
  align-self: end;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.35rem 0.1rem;
  border-bottom: 1px solid transparent;
}
.ghost:hover {
  color: var(--ink);
  border-bottom-color: var(--line);
}
.ghost[aria-disabled="true"] {
  opacity: 0.35;
  pointer-events: none;
}

/* Compact inline stats inside the top bar */
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat__k {
  color: var(--muted);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat__v {
  font-family: var(--mono);
  font-size: 0.74rem;
}

.stage {
  position: relative;
  min-height: 0;
  background: #050505;
}
.stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--paper);
}
.stage iframe.is-hidden {
  visibility: hidden;
  position: absolute;
  inset: 0;
}
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
}
.empty[hidden] { display: none; }
.empty-title { margin: 0; font-size: 1.2rem; font-weight: 400; }
.empty-body { margin: 0; color: var(--muted); max-width: 34rem; line-height: 1.5; }
.empty-path { margin-top: 0.75rem; color: var(--accent); font-size: 0.85rem; }

@media (max-width: 1100px) {
  .bar__stats {
    border-left: 0;
    padding-left: 0;
    flex-basis: 100%;
    order: 3;
    width: 100%;
    padding-top: 0.35rem;
    border-top: 1px solid var(--faint);
  }
  .bar__left { flex-basis: auto; }
}

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; gap: 2rem; }
  .charts { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .chart--wide .chart__svg { min-height: 16rem; }
  .strip__inner { grid-template-columns: 1fr; }
  .model-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .model-col:last-child { border-bottom: 0; }
}
@media (max-width: 720px) {
  .top__nav { display: none; }
  .matrix th:nth-child(n+5):not(:last-child),
  .matrix td:nth-child(n+5):not(:last-child) {
    /* keep core cols on small screens: model, reasoning, duration, cost */
  }
  .matrix th:nth-child(5),
  .matrix td:nth-child(5),
  .matrix th:nth-child(6),
  .matrix td:nth-child(6),
  .matrix th:nth-child(7),
  .matrix td:nth-child(7) {
    display: none;
  }
}
