:root {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: #17202a;
  --surface-2: #1e2935;
  --line: #2b3847;
  --text: #e9eef4;
  --muted: #9aa9ba;
  --sand: #d9b66c;
  --sand-dim: #8f7a4c;
  /* status (never used for anything else; always paired with icon + label) */
  --go: #0ca30c;
  --marginal: #fab219;
  --nogo: #d03b3b;
  --unknown: #6b7785;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(217, 182, 108, 0.08), transparent 60%),
    linear-gradient(#0f141b, #0c1016);
  background-color: var(--bg);
  color: var(--text);
  font: 15px/1.5 "IBM Plex Sans", system-ui, sans-serif;
  min-height: 100vh;
}

a { color: var(--sand); }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.page { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 27, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-family: Oswald, sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}
.brand-mark { color: var(--sand); }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.active { color: var(--bg); background: var(--sand); }

/* ---------- intro + controls ---------- */

.intro {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
  align-items: end;
  padding: 36px 0 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--sand);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 600;
}
h1, h2, h3 { font-family: Oswald, sans-serif; font-weight: 500; letter-spacing: 0.02em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); line-height: 1.1; margin: 0 0 10px; }
.lede { margin: 0; color: var(--muted); max-width: 60ch; }

.controls { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.field select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.month-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.month-tabs a {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.month-tabs a:hover { border-color: var(--sand-dim); }
.month-tabs a.active { background: var(--sand); color: var(--bg); border-color: var(--sand); font-weight: 600; }

/* ---------- status chip ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 8px 2px 3px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
.chip-icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.66rem;
  color: #0f141b;
  background: var(--unknown);
}
.chip-go .chip-icon { background: var(--go); }
.chip-marginal .chip-icon { background: var(--marginal); }
.chip-no-go .chip-icon { background: var(--nogo); color: #fff; }

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tile-hero { border-color: var(--sand-dim); background: linear-gradient(160deg, rgba(217, 182, 108, 0.12), var(--surface) 60%); }
.tile-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.tile-value { font-family: Oswald, sans-serif; font-size: 1.55rem; line-height: 1.15; }
.tile-row { display: flex; align-items: center; gap: 10px; }
.tile-sub { font-size: 0.85rem; color: var(--text); }
.tile-sub .muted, .tile .muted { color: var(--muted); }
.count-row { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.count-row strong { font-size: 1.3rem; margin-right: 2px; }
.stackbar { display: flex; gap: 2px; height: 8px; margin-top: auto; border-radius: 4px; overflow: hidden; }
.seg { display: block; height: 100%; }
.seg-go { background: var(--go); }
.seg-marginal { background: var(--marginal); }
.seg-no-go { background: var(--nogo); }

/* ---------- panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.35rem; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.78rem; color: var(--muted); }

.board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.board .panel { margin-bottom: 16px; }

/* ---------- calendar ---------- */

.cal { display: flex; flex-direction: column; gap: 6px; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head div { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 4px; }

.cell {
  --tone: var(--unknown);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 92px;
  padding: 7px 8px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--tone);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface-2));
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.cell:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--tone) 60%, var(--line)); }
.cell:focus-visible, .cell.is-selected { outline: 2px solid var(--sand); outline-offset: 1px; }
.cell-go { --tone: var(--go); }
.cell-marginal { --tone: var(--marginal); }
.cell-no-go { --tone: var(--nogo); }
.cell-empty { background: transparent; border: 1px dashed rgba(43, 56, 71, 0.5); cursor: default; }
.cell.is-past { opacity: 0.55; }
.cell.is-past.is-selected { opacity: 0.85; }
.cell.is-today { box-shadow: inset 0 0 0 1px var(--sand); }
.cell.is-today .cell-day::after { content: " today"; font-size: 0.62rem; color: var(--sand); text-transform: uppercase; letter-spacing: 0.08em; }
.src-outlook { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 6px, transparent 6px 12px); }

.cell-top { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.cell-day { font-weight: 600; }
.cell-src { font-size: 0.56rem; letter-spacing: 0.08em; color: var(--muted); }
.cell-rating { display: flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; }
.cell-rating .dot { display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; background: var(--tone); color: #0f141b; font-size: 0.55rem; flex: none; }
.cell-no-go .cell-rating .dot { color: #fff; }
.cell-score { font-size: 1.25rem; line-height: 1.1; }
.cell-meta { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 0.7rem; color: var(--muted); margin-top: auto; }

.cal-note { font-size: 0.78rem; color: var(--muted); margin: 12px 0 0; }
.cal-note strong { color: var(--text); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.06em; }

/* ---------- detail panel ---------- */

.detail { position: sticky; top: 72px; }
.detail-empty { color: var(--muted); }
.detail-date { font-family: Oswald, sans-serif; font-size: 1.35rem; }
.detail-rating { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.detail-score { font-size: 1.8rem; }
.detail-score small { font-size: 0.85rem; color: var(--muted); }
.detail-src { font-size: 0.82rem; color: var(--muted); }
.detail h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--sand); margin: 18px 0 8px; }
.alert { margin-top: 12px; padding: 10px 12px; border-radius: 8px; border-left: 3px solid var(--nogo); background: rgba(208, 59, 59, 0.12); font-size: 0.86rem; }
.alert-soft { border-left-color: var(--marginal); background: rgba(250, 178, 25, 0.1); }
.odds { font-size: 0.86rem; margin: 12px 0 0; }

.factors { display: flex; flex-direction: column; gap: 10px; }
.factor-top { display: flex; justify-content: space-between; font-size: 0.82rem; }
.factor-name { font-weight: 600; }
.factor-weight { color: var(--muted); font-size: 0.72rem; }
.factor-val { font-size: 0.82rem; color: var(--muted); margin: 1px 0 4px; }
.factor.is-off { opacity: 0.55; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; background: var(--sand); }

.timeline { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.86rem; }
.timeline dt { color: var(--muted); }
.timeline dd { margin: 0; }

/* ---------- score chart ---------- */

.scorechart { width: 100%; height: auto; display: block; }
.scorechart .grid { stroke: var(--line); stroke-width: 1; }
.scorechart .thresh { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.scorechart .axis { fill: var(--muted); font-size: 10px; font-family: "IBM Plex Mono", monospace; }
.scorechart .hit { fill: transparent; }
.scorechart .bar { cursor: pointer; outline: none; }
.scorechart .fill { fill: var(--unknown); }
.scorechart .bar-go .fill { fill: var(--go); }
.scorechart .bar-marginal .fill { fill: var(--marginal); }
.scorechart .bar-no-go .fill { fill: var(--nogo); }
.scorechart .bar.is-past .fill { opacity: 0.4; }
.scorechart .bar:hover .hit, .scorechart .bar:focus-visible .hit, .scorechart .bar.is-selected .hit { fill: rgba(217, 182, 108, 0.14); }

/* ---------- ranked + compare ---------- */

.two-col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }

.ranked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto 36px;
  grid-template-areas: "n date chip score" "n facts facts facts";
  align-items: center;
  gap: 2px 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rank-row:hover, .rank-row.is-selected { border-color: var(--sand-dim); }
.rank-n { grid-area: n; color: var(--sand); font-size: 1.05rem; }
.rank-date { grid-area: date; font-weight: 600; display: flex; flex-direction: column; }
.rank-date small { font-weight: 400; color: var(--muted); font-size: 0.74rem; }
.rank-row .chip { grid-area: chip; }
.rank-score { grid-area: score; text-align: right; font-size: 1.1rem; }
.rank-facts { grid-area: facts; font-size: 0.78rem; color: var(--muted); }
.hindsight { margin: 12px 0 0; }

.compare { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.compare th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.compare td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.compare td small { display: block; color: var(--muted); font-size: 0.72rem; }
.compare td a { color: var(--text); text-decoration: none; font-weight: 500; }
.compare td a:hover { color: var(--sand); }
.compare .num { text-align: right; }
.compare tr.is-current td { background: rgba(217, 182, 108, 0.08); }
.compare tr.is-current td:first-child { box-shadow: inset 3px 0 0 var(--sand); }

.stamp { margin: 4px 0 24px; }

/* ---------- about ---------- */

.prose { max-width: 760px; padding: 32px 0 16px; }
.prose h1 { margin-bottom: 16px; }
.prose h2 { font-size: 1.4rem; margin: 32px 0 8px; color: var(--sand); }
.prose p, .prose li { color: #d3dbe4; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 8px 0; }
.prose th, .prose td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--muted); font-weight: 500; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; padding: 18px 0 32px; margin-top: 8px; }

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

@media (max-width: 1000px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .board { grid-template-columns: 1fr; }
  .detail { position: static; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .intro { grid-template-columns: 1fr; gap: 18px; padding-top: 24px; }
  .tiles { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .cal-row { gap: 3px; }
  .cal { gap: 3px; }
  .cell { min-height: 64px; padding: 4px 4px 5px; border-radius: 7px; }
  .cell-src, .cell-meta, .cell-rating-text { display: none; }
  .cell-score { font-size: 0.95rem; }
  .cell.is-today .cell-day::after { content: ""; }
  .cal-head div { font-size: 0.62rem; padding: 0; text-align: center; }
  .rank-row { grid-template-columns: 22px minmax(0, 1fr) auto 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .cell { transition: none; }
}
