/* deepcheaptokens — dark, white + racing-yellow, big readable type (body >= 17px)
   Type: DeepSeek's own webfont stack, self-hosted (all SIL OFL 1.1 — license
   texts in fonts/). Host Grotesk = display, DM Sans = body, Fragment Mono =
   prices/numbers, matching deepseek.com's --ds-font-display/body/mono. */
@font-face {
  font-family: "Host Grotesk"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url("fonts/host-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Host Grotesk"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url("fonts/host-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fragment Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/fragment-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fragment Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/fragment-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
  --bg: #0c0e12;
  --panel: #14171d;
  --panel-2: #1a1e26;
  --line: #262c37;
  --text: #e8ebf0;
  --muted: #98a2b3;
  --muted-soft: #b6bfcc;
  --accent: #ffcc00;
  --accent-light: #ffe680;   /* "cheap" — lighter than tokens.com so the
                                two halves of the wordmark read separately */
  --accent-dim: #b39200;
  --good: #34d399;
  /* one brand hue: the domain and the primary action are the same yellow as
     "cheap". Yellow is a light colour, so anything ON it needs dark text. */
  --brand-on-accent: #111;   /* 11.4:1 on --accent */
  --bad: #f87171;
  --og: #7dd3fc;
  --font-display: "Host Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Fragment Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.45;
}
header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 20px 28px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
h1 { font-size: 1.7rem; margin: 0; color: var(--text); letter-spacing: 0.5px; font-family: var(--font-display); font-weight: 700; }
/* the wordmark split mirrors the loader mark: deep white, cheap a lighter
   yellow, tokens.com the brand yellow — three distinct tones in one word */
h1 .accent-word { color: var(--accent-light); }
h1 .domain-word { color: var(--accent); }
.tagline { color: var(--muted); font-size: 0.95rem; margin-inline-start: 12px; }
#manage-btn, #lang-btn {
  border-radius: 8px; padding: 9px 18px; font-size: 1rem; font-weight: 600;
  cursor: pointer; min-height: 30px; border: none;
  /* one height for the whole control row so nothing sits proud of its
     neighbours (the lang button is icon-only and would otherwise shrink) */
  height: 40px; box-sizing: border-box;
}
#manage-btn:disabled { opacity: 0.55; cursor: wait; }
#manage-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); margin-inline-end: 10px; }
/* language toggle: ONE flag — the language you would switch TO, which is
   what the tooltip says. Official Wikimedia artwork, unmodified. */
#lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
  margin-inline-end: 10px; padding: 0 12px;
  /* a bare <button> does not inherit type: without this the control renders
     at the UA's 13.3px */
  font: inherit;
}
#lang-btn:hover { border-color: var(--accent-dim); }
#lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#lang-btn .flag {
  display: block; height: 18px; width: auto; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.45);
}
#manage-btn:hover { border-color: var(--accent); color: var(--accent); }
.controls { display: flex; align-items: center; }

#status-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 28px; color: var(--muted); font-size: 0.92rem; flex-wrap: wrap;
}
#source-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px;
  font-size: 0.85rem; background: var(--panel);
}
.chip.ok { border-color: var(--good); color: var(--good); }
.chip.down { border-color: var(--bad); color: var(--bad); }

#workload-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 28px; margin: 0; background: var(--panel);
  border-block: 1px solid var(--line); font-size: 0.92rem; color: var(--muted);
}
#workload-bar label { font-weight: 600; color: var(--text); }
#hit-slider { width: 220px; accent-color: var(--accent); height: 22px; cursor: pointer; }
#hit-value { color: var(--accent); font-weight: 700; min-width: 46px; }
#hit-hint { font-size: 0.8rem; }

main { padding: 6px 28px 20px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; min-width: 1180px; }
col.c-rank { width: 44px; } col.c-model { width: 15.5%; } col.c-idx { width: 12%; }
col.c-in { width: 7.5%; } col.c-cache { width: 8%; } col.c-out { width: 7.5%; }
col.c-blend { width: 10%; } col.c-value { width: 7.5%; } col.c-src { width: 17%; } col.c-ctx { width: 8%; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: end; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px;
     font-family: var(--font-display);
     position: sticky; top: 0; background: var(--bg); cursor: pointer; user-select: none; }
th.left, td.left { text-align: start; }
th.sorted { color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel-2); }
td.rank { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
td.model .mname { font-weight: 600; }
td.model .msub { color: var(--muted-soft); font-size: 0.82rem; display: block; overflow-wrap: anywhere; }
.idx-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.idx-num { font-variant-numeric: tabular-nums; font-weight: 600; font-family: var(--font-mono); }
.idx-bar { width: 64px; height: 7px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.idx-bar i { display: block; height: 100%; background: var(--accent); }
.est { color: var(--muted); font-size: 0.78rem; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.92em; }
.money { font-weight: 600; }
.best { color: var(--good); }
td.cache { color: var(--og); }
td.src { font-size: 0.9rem; }
td.src .lane-wrap { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow-wrap: normal; min-width: 0; }
td.src .prov { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.badge { font-size: 0.78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; margin-inline-start: 6px; display: inline-block; }
.delta { font-size: 0.75rem; color: var(--bad); margin-inline-start: 6px; display: inline-block; }
.badge.openw { color: var(--accent-dim); border-color: var(--accent-dim); }
.badge.lane { margin-inline-start: 0; font-weight: 600; letter-spacing: 0.3px; }
.badge.lane-direct { color: var(--accent); border-color: var(--accent-dim); }
.badge.lane-openrouter { color: var(--og); border-color: var(--og); }
.badge.lane-reference { color: var(--muted); }
.badge.manual-src { color: var(--accent); border-color: var(--accent-dim); }
/* subscription badge: a plan covers this model — distinct from lane colors */
.badge.sub { color: var(--good); border-color: var(--good); font-weight: 600; letter-spacing: 0.3px; }
#detail-body tr.lane-row.lane-sub td:first-child { color: var(--good); }
#detail-body .sub-notes { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
#detail-body .sub-src { font-size: 0.82rem; }
#detail-body .sub-src a { color: var(--good); }
.unpriced td, .missing td, .index_only td { color: var(--muted); }
.unpriced .badge, .missing .badge, .index_only .badge { color: var(--bad); border-color: var(--bad); }

/* --- model groups: the lanes of one model stay side by side ------------- */
/* A group's rows share one left rail; a new group starts a new rail and a
   heavy top rule, so the blocks are unmistakable. */
td.model { border-inline-start: 3px solid transparent; padding-inline-start: 14px; }
/* the rail runs the WHOLE height of a model's block — one model, one rail;
   the heavy top rule is what separates one block from the next */
tr.grp-lead td.model, tr.grp-follow td.model { border-inline-start-color: var(--accent-dim); }
tr.grp-lead td { border-bottom: 1px solid var(--line); }
tr.grp-lead:not(:first-child) td { border-top: 3px solid var(--line); }
tr.grp-follow td { background: rgba(255, 255, 255, 0.03); }
tr.grp-follow td.model { background: rgba(255, 255, 255, 0.03); }
tr.grp-follow td.model .mname-cont { color: var(--muted-soft); font-weight: 500; }
tr.grp-follow td.model .msub { color: var(--muted-soft); }
tr.grp-follow td.rank { color: var(--muted); }
tr.grp-lead:hover td, tr.grp-follow:hover td { background: var(--panel-2); }

#detail-panel, #manage-panel {
  margin: 14px 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px;
}
#detail-panel.hidden, #manage-panel.hidden, .hidden { display: none; }
#detail-title, #manage-panel h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--accent); }
#detail-body table, #manage-panel table { min-width: 0; }
#detail-body td, #detail-body th { text-align: start; }
#detail-body tr.lane-row td { border-bottom: 1px solid var(--line); }
#detail-body tr.lane-active td { color: var(--accent); font-weight: 600; }
#detail-body tr.lane-row.lane-direct td:first-child { color: var(--accent); }
#detail-body tr.lane-row.lane-openrouter td:first-child { color: var(--og); }
#detail-close, #manage-close {
  margin-top: 10px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 16px; cursor: pointer;
  min-height: 30px;
}
#detail-close:hover, #manage-close:hover { border-color: var(--accent); color: var(--accent); }

.hint { color: var(--muted); font-size: 0.9rem; }
#manage-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.manage-item {
  display: flex; align-items: center; gap: 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.manage-item .mname { font-weight: 600; flex: 1; }
.manage-item .msub { color: var(--muted); font-size: 0.82rem; flex: 2; overflow-wrap: anywhere; }
.rm-btn {
  background: transparent; color: var(--bad); border: 1px solid var(--bad);
  border-radius: 7px; padding: 5px 12px; cursor: pointer; min-height: 30px;
}
.rm-btn:hover { background: var(--bad); color: #111; }
.rm-btn:disabled { opacity: 0.5; cursor: wait; }
.manage-item .restore { border-color: var(--good); color: var(--good); }
.manage-item .restore:hover { background: var(--good); color: #111; }
.manage-foot { display: flex; gap: 10px; margin-top: 14px; }
#restore-btn { background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 14px; font: inherit; cursor: pointer; }
#restore-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.add-row { display: flex; gap: 10px; }
#search-input, #manual-id {
  flex: 1; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; font-size: 0.95rem; min-height: 30px;
}
#search-input:focus, #manual-id:focus { outline: 2px solid var(--accent); border-color: transparent; }
#manual-id { margin-top: 8px; width: 100%; }
#add-btn {
  background: var(--accent); color: #111; border: none; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; cursor: pointer; min-height: 30px;
}
#add-btn:disabled { opacity: 0.5; cursor: wait; }
#search-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
#search-results li {
  padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 0.92rem;
}
#search-results li:hover { background: var(--panel-2); }
#search-results li.picked { background: var(--panel-2); color: var(--accent); }
#search-results li.picked::before { content: "✓ "; }
#search-results li.none { color: var(--muted); cursor: default; }
#manage-msg { margin-top: 8px; font-size: 0.9rem; }
.msg-ok { color: var(--good); }
.msg-bad { color: var(--bad); }

/* ---------- first-launch loader overlay ---------- */
.loader {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px;
  background: radial-gradient(720px 340px at 50% 30%, rgba(255, 204, 0, 0.07), transparent 70%), var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.loader.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-mark {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.8rem, 9vw, 5.4rem); letter-spacing: -0.02em; color: var(--text);
  animation: dc-glow 2.2s ease-in-out infinite;
}
.loader-y { color: var(--accent-light); }
.loader-p { color: var(--accent); }
@keyframes dc-glow {
  0%, 100% { text-shadow: 0 0 0 rgba(255, 204, 0, 0); }
  50% { text-shadow: 0 0 28px rgba(255, 204, 0, 0.38); }
}
.loader-table { width: min(680px, 88vw); display: flex; flex-direction: column; gap: 13px; }
.lrow { display: flex; gap: 12px; align-items: center; }
.lb {
  height: 13px; border-radius: 6px; flex: none;
  background: linear-gradient(90deg, var(--panel-2) 0%, #242b36 50%, var(--panel-2) 100%);
  background-size: 240% 100%;
  animation: dc-shimmer 1.4s linear infinite;
}
.lb-rank { width: 30px; } .lb-name { flex: 2.2; } .lb-idx { flex: 1; }
.lb-p { flex: 0.8; } .lb-blend { flex: 1; } .lb-src { flex: 1.5; }
@keyframes dc-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.lrow:nth-child(2) .lb { animation-delay: 0.14s; }
.lrow:nth-child(3) .lb { animation-delay: 0.28s; }
.lrow:nth-child(4) .lb { animation-delay: 0.42s; }
.lrow:nth-child(5) .lb { animation-delay: 0.56s; }
.loader-status {
  font-family: var(--font-mono); font-size: 0.95rem; color: var(--muted);
  min-height: 1.5em; text-align: center; padding: 0 20px;
}
.loader-bar {
  width: min(420px, 80vw); height: 4px; border-radius: 2px;
  background: var(--panel-2); overflow: hidden;
}
#loader-pct {
  height: 100%; width: 0%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.loader-retry {
  margin-top: -8px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--accent-dim); border-radius: 8px;
  padding: 8px 18px; font-size: 0.95rem; cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .loader, .loader-mark, .lb { animation: none; transition: none; }
}

.legend { color: var(--muted); font-size: 0.88rem; margin-top: 14px; }
.legend h2 { font-size: 0.95rem; color: var(--text); margin: 0 0 6px; }
.legend ul.legend-lines { list-style: none; margin: 0; padding: 0; }
.legend ul.legend-lines li { padding: 3px 0; line-height: 1.45; }
.legend ul.legend-lines li + li { border-top: 1px solid rgba(38, 44, 55, 0.5); }
/* scope note: an aside about what we do NOT cover, set apart from the
   per-badge definitions above it */
.legend ul.legend-lines li.legend-note {
  margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted-soft); line-height: 1.55;
}
.legend ul.legend-lines li.legend-note strong { color: var(--text); }
footer {
  border-top: 1px solid var(--line); padding: 14px 28px; color: var(--muted);
  font-size: 0.88rem; display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between;
}
footer a { color: var(--accent); text-decoration: none; }
footer .site-credit a { font-weight: 600; }
#stale-warn { color: var(--bad); }
@media (max-width: 720px) {
  :root { font-size: 16px; }
  main, header, footer, #status-bar, #workload-bar { padding-inline: 14px; }
  #hit-slider { width: 140px; }
}
