:root {
  --paper: #eceae3;
  --paper-2: #e4e1d8;
  --paper-3: #dcd8cc;
  --ink: #1b1a17;
  --ink-soft: #4a463d;
  --ink-faint: #7c766a;
  --rule: #cbc7bb;
  --rule-soft: #d9d5ca;
  --accent: #20347e;
  --accent-soft: #34489a;
  --accent-tint: #dde1ef;
  --gain: #1c7038;
  --loss: #a51e1e;
  --gold:   #a07d2c;
  --silver: #8a857a;
  --bronze: #93602f;
  --display: "Archivo Expanded", "Archivo", -apple-system, sans-serif;
  --sans: "Archivo", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.shell { position: relative; z-index: 1; }

/* ---- masthead ---- */

.masthead {
  border-bottom: 2px solid var(--ink);
  background: rgba(236, 234, 227, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.masthead-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 24px;
  padding: 16px 32px;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.brand em { font-style: normal; color: var(--accent); }
.masthead-meta {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
}
.masthead-meta a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.masthead-meta a:hover { color: var(--accent); border-bottom-color: var(--accent-soft); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.82); } }

.wrap { max-width: 1240px; margin: 0 auto; padding: 56px 32px 32px; }

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

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}
.eyebrow .bar { display: inline-block; width: 26px; height: 2px; background: var(--accent); vertical-align: middle; margin-right: 10px; }

h1.headline {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin: 0 0 28px;
  color: var(--ink);
}
h1.headline em { font-style: normal; color: var(--accent); }

.lede {
  max-width: 720px;
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 40px;
}
.lede strong { color: var(--ink); font-weight: 700; }
.lede em { font-style: normal; color: var(--ink); font-weight: 600; }
.lede a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); padding-bottom: 1px; }
.lede a:hover { background: var(--accent-tint); }

/* ---- stats: one ruled strip, not a card grid ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin-bottom: 56px;
}
.stat { padding: 16px 24px 16px 0; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: 0; }
.stat:not(:first-child) { padding-left: 24px; }
.stat-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 8px;
}
.stat-value {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

/* ---- section head ---- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
  margin: 0 0 24px;
}
.section-head h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.section-head h2 em { font-style: normal; color: var(--accent); }
.section-head .sort-hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- provider chips ---- */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 13px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--accent); color: var(--paper); border-color: var(--accent); }

/* ---- leaderboard ---- */

.board { border: 1px solid var(--ink); border-top: 0; }
.board-head, .row {
  display: grid;
  grid-template-columns: 46px minmax(150px, 1.2fr) 88px 66px 72px 90px 96px 86px 74px 74px 74px;
  align-items: center;
  padding: 14px 18px;
  gap: 10px;
}
.board-head {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: default;
  padding: 12px 20px;
  border-bottom: 2px solid var(--ink);
  border-top: 2px solid var(--ink);
}
.board-head .col { cursor: pointer; user-select: none; transition: color 0.12s; }
.board-head .col:hover { color: var(--ink); }
.board-head .col.active { color: var(--accent); }
.board-head .col.text-right, .row .text-right { text-align: right; }
/* Forecast metrics for models below the scored-forecast floor render as "—"
   (their skill/log-loss/CRPS would be small-sample noise, and the economic
   "resolved" count is a different, larger n that shouldn't imply these are
   well-sampled). Faint so it reads as "no score", not a value. */
.row .score-na { color: var(--ink-faint); }

.row {
  position: relative;
  transition: background 0.14s ease;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--rule);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--paper-2); }
.row.champion { box-shadow: inset 4px 0 0 var(--accent); }
.row.champion .rank::after {
  content: "†";
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.5em;
  vertical-align: super;
  margin-left: 2px;
}

.rank {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink-faint);
}
.rank.gold   { color: var(--accent); }
.rank.silver { color: var(--ink); }
.rank.bronze { color: var(--ink-soft); }

.model-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.model-name {
  font-family: var(--sans);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row:hover .model-name { color: var(--accent); }
.model-meta {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.provider-tag {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  background: var(--paper-3);
  color: var(--ink-soft);
  border-radius: 2px;
  display: inline-block;
  border: 1px solid var(--rule);
}

.est-mark {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  margin-left: 3px;
  cursor: pointer;
}

.cost-note {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 14px;
}
.cost-note .est-mark { margin-left: 0; margin-right: 2px; }
.cost-note a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }

.num {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.num.num-primary {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.row.champion .num.num-primary { color: var(--accent); }

.pnl.positive { color: var(--gain); }
.pnl.negative { color: var(--loss); }

.loading {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 80px 0;
  text-align: center;
}

/* ---- how it works ---- */

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--ink);
  border-top: 0;
}
.how-stage { padding: 32px 28px; position: relative; border-right: 1px solid var(--rule); }
.how-stage:last-child { border-right: 0; }
.how-num {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.4rem;
  letter-spacing: -0.04em;
  color: var(--accent);
  margin: 0 0 16px;
  line-height: 0.9;
}
.how-stage h3 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.how-stage p {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}

/* ---- versus table ---- */

.vs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  border: 1px solid var(--ink);
  border-top: 0;
}
.vs-table thead th {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: left;
  padding: 14px 20px;
  border-bottom: 2px solid var(--ink);
  font-weight: 500;
}
.vs-table tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  vertical-align: top;
}
.vs-table tbody tr:last-child td { border-bottom: 0; }
.vs-table tbody td:first-child { color: var(--ink); }
.vs-table tbody td a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--rule); }
.vs-table tbody td a:hover { color: var(--accent); border-bottom-color: var(--accent-soft); }
.vs-table tr.vs-self { box-shadow: inset 4px 0 0 var(--accent); background: var(--paper-2); }
.vs-table tr.vs-self td { color: var(--ink); }
.vs-table tr.vs-self td strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.02rem;
}

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

footer {
  max-width: 1240px;
  margin: 80px auto 32px;
  padding: 32px;
  border-top: 2px solid var(--ink);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  line-height: 1.65;
}
footer .caveat { max-width: 560px; }
footer .caveat strong { color: var(--ink); font-weight: 600; }
footer em { font-style: normal; color: var(--ink-soft); }
footer .colophon { text-align: right; }
footer .colophon strong { display: block; font-family: var(--display); font-weight: 700; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
footer a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }

[x-cloak] { display: none !important; }

.fade-in { opacity: 0; transform: translateY(10px); animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.fade-in:nth-child(1)  { animation-delay: 0.03s; }
.fade-in:nth-child(2)  { animation-delay: 0.06s; }
.fade-in:nth-child(3)  { animation-delay: 0.09s; }
.fade-in:nth-child(4)  { animation-delay: 0.12s; }
.fade-in:nth-child(5)  { animation-delay: 0.15s; }
.fade-in:nth-child(6)  { animation-delay: 0.18s; }
.fade-in:nth-child(7)  { animation-delay: 0.21s; }
.fade-in:nth-child(8)  { animation-delay: 0.24s; }
.fade-in:nth-child(9)  { animation-delay: 0.27s; }
.fade-in:nth-child(10) { animation-delay: 0.30s; }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* ---- model drill page ---- */

.back-link {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 32px;
}
.back-link:hover { color: var(--accent); }
.back-link::before { content: "← "; }

.drill-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 64px; align-items: start; }
.drill-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
  word-break: break-word;
}
.drill-provider {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 40px;
}
.drill-hero-num {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(4.5rem, 13vw, 10rem);
  line-height: 0.88;
  letter-spacing: -0.05em;
  color: var(--accent);
  margin: 0;
}
.drill-hero-label {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 12px 0 0;
}
.drill-hero-sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 6px;
}

.kv-section {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 36px 0 6px;
  font-weight: 500;
}
.kv-section:first-of-type { margin-top: 24px; }
.kv-section-blurb {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
  line-height: 1.5;
}
.kv-section-blurb strong { color: var(--ink); font-weight: 700; }

.kv-table { border-top: 2px solid var(--ink); margin-top: 12px; }
.kv-row { display: grid; grid-template-columns: 1fr auto; padding: 13px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.kv-label {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.kv-label strong { color: var(--ink); font-weight: 700; }
.kv-value {
  font-family: var(--mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kv-value.pnl.positive, .kv-value.pnl.negative {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ---- methodology prose ---- */

.prose { max-width: 760px; margin-top: 32px; }
.prose h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin: 56px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}
.prose h2 em { font-style: normal; color: var(--accent); }
.prose p { font-size: 1.02rem; line-height: 1.7; color: var(--ink-soft); margin: 0 0 16px; }
.prose em { font-style: normal; color: var(--ink); font-weight: 600; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--paper-3);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid var(--rule);
}
.prose pre code { background: none; padding: 0; border: 0; border-radius: 0; color: inherit; font-size: 1em; }
.prose ul { padding-left: 0; list-style: none; }
.prose li {
  font-size: 1.0rem;
  line-height: 1.6;
  color: var(--ink-soft);
  padding: 8px 0 8px 26px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.prose li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 15px;
  width: 8px;
  height: 8px;
  background: var(--accent);
}
.prose li strong { color: var(--ink); }
.prose pre {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--ink);
  color: var(--paper);
  padding: 20px 24px;
  overflow-x: auto;
  border-left: 4px solid var(--accent);
  line-height: 1.55;
}

/* ---- leaderboard sub-lede + column-header tooltips ---- */

.lede.lede-compact {
  font-size: 0.9rem;
  margin: -8px 0 24px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.lede.lede-compact strong { color: var(--ink); }
.lede.lede-compact em {
  font-family: var(--mono);
  font-size: 0.85em;
  font-style: normal;
  color: var(--accent);
}

.board-head .col[data-tip] { position: relative; cursor: help; }
.board-head .col[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  width: max-content;
  max-width: 320px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.45;
  text-align: left;
  border-left: 3px solid var(--accent);
  box-shadow: 0 8px 24px rgba(27, 26, 23, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
  white-space: normal;
}
.board-head .col[data-tip]:hover::after,
.board-head .col[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.board-head .col.text-right[data-tip]::after { left: auto; right: 0; transform: translateY(-4px); }
.board-head .col.text-right[data-tip]:hover::after,
.board-head .col.text-right[data-tip]:focus-visible::after { transform: translateY(0); }
.board-head .col:focus { outline: none; }
.board-head .col:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

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

@media (max-width: 980px) {
  .board-head, .row {
    grid-template-columns: 40px minmax(160px, 1fr) 80px 100px 92px 84px;
    padding: 12px 14px;
    gap: 10px;
  }
  .board-head .col-provider, .board-head .col-cost, .board-head .col-total,
  .board-head .col-skill, .board-head .col-crps,
  .row .col-provider, .row .col-cost, .row .col-total,
  .row .col-skill, .row .col-crps { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--ink); }
  .stat { border-bottom: 1px solid var(--rule); }
  .drill-grid { grid-template-columns: 1fr; gap: 32px; }
  .how-grid { grid-template-columns: 1fr; }
  .how-stage { border-right: 0; border-bottom: 1px solid var(--rule); }
  .how-stage:last-child { border-bottom: 0; }
  footer { grid-template-columns: 1fr; }
  footer .colophon { text-align: left; }
  .board-head .col[data-tip]::after { max-width: 240px; font-size: 0.72rem; }
}
@media (max-width: 640px) {
  .wrap { padding: 40px 20px; }
  .board-head, .row {
    grid-template-columns: 36px 1fr 110px;
    padding: 14px 16px;
    gap: 10px;
  }
  .board-head .col-provider, .board-head .col-calls, .board-head .col-cost,
  .board-head .col-total, .board-head .col-unwind-perdollar, .board-head .col-token-eff,
  .board-head .col-skill, .board-head .col-crps,
  .row .col-provider, .row .col-calls, .row .col-cost,
  .row .col-total, .row .col-unwind-perdollar, .row .col-token-eff,
  .row .col-skill, .row .col-crps { display: none; }
  .board-head .col[data-tip]::after { display: none; }
}
