/* 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;
  /* the footer (Sources block and everything under it) sits on a deep black
     field, one step below the app body — deliberate: attribution and the
     credit line must read as a separate, quieter band. Every text token was
     re-measured against this value, not against --bg. */
  --footer-bg: #000000;
  --panel: #14171d;
  --panel-2: #1a1e26;
  --line: #262c37;
  --text: #e8ebf0;
  --muted: #98a2b3;
  --muted-soft: #b6bfcc;
  --accent: #ffcc00;
  --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;
  /* the footer is the page's last band and paints deep black, so it must
     reach the bottom of the viewport even when the watch-list is empty and
     the table is short — otherwise --bg shows through under a black strip */
  display: flex; flex-direction: column; min-height: 100vh;
}
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; }
/* wordmark: deep and tokens.com in white, cheap in racing yellow — the two
   white spans bracket the yellow middle */
h1 { color: var(--text); }                  /* "deep" (bare text node) */
/* the wordmark is the home link: inherit the brand colours, no link chrome */
h1 a {
  color: inherit; text-decoration: none;
  /* a hairline outline hugging the letters: each span is traced in the other
     brand colour, so the wordmark reads as one object without a box around it.
     Kept thin and low-alpha — at full strength a stroke fattens the glyphs and
     reads as a different typeface. */
  -webkit-text-stroke: 0.5px rgba(255, 204, 0, 0.30);
  text-shadow: 0 0 22px rgba(255, 204, 0, 0.07);
}
h1 .accent-word { -webkit-text-stroke-color: rgba(232, 235, 240, 0.28); }
h1 a:hover, h1 a:focus-visible { text-decoration: none; }
h1 a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1 .accent-word { color: var(--accent); }   /* "cheap" */
h1 .domain-word { color: var(--text); }     /* "tokens.com" */
.tagline { color: var(--muted); font-size: 0.95rem; margin-inline-start: 12px; }
#manage-btn, #export-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;
  /* a label is a phrase, never two lines: a squeezed button used to wrap
     "Manage models" into 53px of text inside a 40px box */
  white-space: nowrap; flex: 0 0 auto;
}
#manage-btn:disabled, #export-btn:disabled { opacity: 0.55; cursor: wait; }
#manage-btn, #export-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); margin-inline-end: 10px; }
/* Export sits beside Manage and is the one control that PRODUCES something:
   a faint accent wash keeps it findable without competing with the table. */
#export-btn { background: rgba(255, 204, 0, 0.08); border-color: var(--accent-dim); color: var(--accent); }
#export-btn:hover { border-color: var(--accent); background: rgba(255, 204, 0, 0.14); }
#export-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* a phone header carries three controls now: tighten them so a 390px screen
   keeps ONE row (measured 363px of buttons in a 362px row at the default
   padding — 1px is enough to break the row) */
@media (max-width: 480px) {
  #manage-btn, #export-btn { padding: 9px 14px; margin-inline-end: 8px; }
}
/* language toggle: ONE flag — the language you would switch TO, which is
   what the tooltip says. Official Wikimedia artwork, unmodified.
   It sits at the inline-END of the row (the far corner past Manage models),
   so it carries no trailing margin — nothing follows it. */
#lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
  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); }
/* the control row may wrap on a narrow phone (a fold's cover screen is ~344):
   the labels stay whole and the last button moves to a second line instead of
   being squeezed into two-line text inside a 40px box */
.controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }

#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;
}

#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; flex: 1 0 auto; }
.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: 9%; } col.c-task { width: 9%; }
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; }
/* How many providers OpenRouter lists for the model. Makes an absent
 * third-party lane a stated fact instead of a missing row: "1 provider" is
 * the whole market, so there is nothing else to show. */
td.src .prov-count { color: var(--muted); opacity: 0.75; font-size: 0.78rem; white-space: nowrap; }
.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; }
/* "unrated": Artificial Analysis has no score for this model. Deliberately
   NOT red — nothing failed, the model is simply outside AA's coverage. */
.badge.unrated {
  color: var(--muted); border-color: var(--line); border-style: dashed;
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
}
#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 {
  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 { border-color: var(--accent); color: var(--accent); }
/* #manage-close is styled by .btn-neutral inside .manage-actions: the old
   standalone rule carried margin-top:10px, which pushed Done 5px below the
   rest of the action bar */

.hint { color: var(--muted); font-size: 0.9rem; }
#manage-list { display: flex; flex-direction: column; gap: 6px; margin-top: 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;
  transition: border-color .12s, background .12s;
}
/* hover: a brighter field + the accent ring, matching the search-results
   rows. box-shadow paints outside the border so nothing shifts. */
.manage-item:hover {
  background: #202632; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.manage-item:hover .mname { color: var(--text); }
.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; }
/* one action bar under the list: Add (primary) left, Clear + Done right */
.manage-actions { display: flex; gap: 10px; margin-top: 6px; margin-bottom: 12px;
  align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.actions-spacer { flex: 1; }
.btn-primary, .btn-neutral, .btn-quiet, .btn-danger {
  font: inherit; cursor: pointer; border-radius: 7px; padding: 7px 14px; min-height: 34px;
}
.btn-primary { background: var(--accent); color: #111; border: 1px solid var(--accent); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-neutral { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-neutral:hover { border-color: var(--accent); color: var(--accent); }
.btn-quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-quiet:hover { color: var(--bad); border-color: var(--bad); }
.btn-danger { background: var(--bad); color: #111; border: 1px solid var(--bad); font-weight: 700; }
.btn-danger:hover { filter: brightness(1.08); }
#restore-btn[aria-expanded="true"] { color: var(--bad); border-color: var(--bad); }

/* the clear confirmation: an inline block, not a browser confirm() */
#clear-confirm {
  margin-top: 10px; padding: 10px 12px; border: 1px solid var(--bad);
  border-radius: 8px; background: var(--panel-2);
}
#clear-confirm.hidden { display: none; }
.clear-warn { margin: 0 0 8px; color: var(--text); font-size: 0.9rem; line-height: 1.45; }
.clear-buttons { display: flex; gap: 10px; }
.add-row { display: flex; gap: 10px; }
#search-input {
  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 { outline: 2px solid var(--accent); border-color: transparent; }
#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;
  display: flex; align-items: baseline; gap: 10px;
}
/* the unrated tag leads the row; the id/price line takes the rest */
#search-results .badge.unrated { flex: 0 0 auto; margin-inline-start: 0; }
#search-results li > span:not(.badge) { flex: 1; }
/* hover: the accent edge + a brighter field make the target unmistakable;
   picked keeps the same edge plus the yellow text so the two states read as
   "on deck" vs "committed" */
#search-results li:hover {
  background: var(--panel-2); border-inline-start: 2px solid var(--accent);
  padding-inline-start: 10px; color: var(--text);
}
#search-results li.picked { background: var(--panel-2); color: var(--accent); }
#search-results li.picked::before { content: "✓ "; }
/* a hovered picked row must not lose its committed look */
#search-results li.picked:hover { color: var(--accent); }
#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);                       /* "deep" — mirrors the h1 */
  animation: dc-glow 2.2s ease-in-out infinite;
}
.loader-y { color: var(--accent); }         /* "cheap" — yellow, mirrors the h1 */
.loader-p { color: var(--text); }
@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 {
  background: var(--footer-bg);
  border-top: 1px solid var(--line); padding: 18px 28px 20px; color: var(--muted);
  font-size: 0.85rem; display: flex; flex-direction: column;
  align-items: center; text-align: center; gap: 10px;
}
/* centered block: sources, disclaimer, rights, then the personal credit LAST */
footer .credits { display: flex; flex-direction: column; gap: 6px; max-width: 68ch; align-items: center; }
footer .credits-title {
  margin: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); font-family: var(--font-body);
}
footer .source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; align-items: center; }
footer .source-list li { color: var(--muted-soft); line-height: 1.5; }
footer .source-list a { color: var(--accent); font-weight: 600; }
/* the independence disclaimer and the rights note must be readable, not
   legal fine print: body-ish size, real contrast, set apart from the list */
footer .disclaimer {
  margin: 2px 0 0; font-size: 0.82rem; line-height: 1.55; color: var(--muted);
  max-width: 62ch; font-style: italic;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .site-credit {
  white-space: nowrap; color: var(--muted-soft);
  padding-top: 10px; border-top: 1px solid var(--line); width: 100%;
  display: flex; justify-content: center; gap: 8px;
}
footer .site-credit a { font-weight: 600; }
footer .copyright { color: var(--muted); }
#stale-warn { color: var(--bad); }
/* the rank note sits next to the 20/20 line: quieter than the numbers,
   slightly smaller, and never the thing the eye lands on first */
#min-idx { font: inherit; font-size: 0.85rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; margin-inline-start: 6px; }
/* the text filter sits after the "showing N of M" note, same ribbon as the
   cache slider — small, quiet, and it wraps with the bar on narrow screens */
#text-filter { font: inherit; font-size: 0.85rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; width: 280px; }
#text-filter::placeholder { color: var(--muted); opacity: .8; }
.filter-note { color: var(--muted); font-size: 0.8rem; margin-inline-start: 8px; }
#rank-note { color: var(--muted); font-size: 0.8rem; opacity: .85; }
#rank-note::before { content: "· "; opacity: .7; }
/* ---------- phones and foldables: a row is a card, never a sideways grid ---
   The desktop table needs 1180px for ten fixed columns. A phone has 390 and a
   folded foldable 280-344, so the table only ever showed its first two columns
   there: to read a price the visitor had to swipe the row away from the model
   name, and each row still wrapped to ~130px of name-and-badges. To 860px
   every row becomes a CARD that states each number in place, and the <th> row
   survives as a chip strip — those chips ARE the sort controls, so a phone
   would otherwise have no way to re-order the table. Labels come from app.js
   (data-label, translated), never from a hard-coded string here. */
@media (max-width: 860px) {
  /* no horizontal scroller is left to have: an overflow ancestor would also
     trap the sticky sort chips below */
  .table-wrap { overflow: visible; }
  #rank-table { display: block; min-width: 0; }
  #rank-table colgroup { display: none; }

  /* --- the header row, as sort chips ----------------------------------- */
  #rank-table thead { display: block; position: sticky; top: 0; z-index: 30;
    background: var(--bg); padding: 6px 0 8px; }
  /* the strip is a CONTROL, not a column header: say so, or it reads as a
     header that does not line up with the cards below it */
  #rank-table thead::before { content: attr(data-hint); display: block;
    font-family: var(--font-display); font-size: 0.58rem; font-weight: 700;
    letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
    margin: 0 0 5px 2px; }
  #rank-table thead tr { display: flex; gap: 8px; overflow-x: auto;
    scrollbar-width: none;
    /* the strip scrolls; fade the edge it runs off, or a clipped pill reads
       as broken overflow instead of "there is more of this" */
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%); }
  #rank-table thead tr::-webkit-scrollbar { display: none; }
  /* Arabic reads right-to-left, so the overflow edge is the other side */
  html[dir="rtl"] #rank-table thead tr {
    -webkit-mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(270deg, #000 0, #000 calc(100% - 26px), transparent 100%); }
  #rank-table th { position: static; flex: 0 0 auto; white-space: nowrap;
    border: 1px solid var(--line); background: var(--panel);
    border-radius: 999px; padding: 5px 11px; font-size: 0.66rem;
    letter-spacing: 0.06em; }
  #rank-table th.sorted { border-color: var(--accent-dim); }
  /* Cost / Task is the ranking and the DEFAULT order, so its chip opens the
     strip. In DOM order it is the eighth <th> (it is the eighth column), which
     parked the control that defines the default order at the far right of a
     scrolling strip — off-screen on a 390px phone. `order` re-places it
     visually only: the desktop table's columns are positional, so the DOM
     order of the <th> row must stay exactly as it is. */
  #rank-table th[data-sort="task"] { order: -1; }

  /* --- one card per row ------------------------------------------------ */
  #rank-table tbody { display: block; }
  #rank-table tbody tr { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 6px; align-items: start; background: var(--panel);
    border: 1px solid var(--line); border-radius: 12px;
    padding: 9px 12px 10px; margin: 0 0 10px; }
  #rank-table td { display: block; border: 0; padding: 0; text-align: start;
    min-width: 0; }
  /* the column header, moved onto the value it describes */
  #rank-table td[data-label]::before { content: attr(data-label); display: block;
    font-family: var(--font-display); font-size: 0.6rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
    line-height: 1.3; margin-bottom: 1px; }
  #rank-table .idx-bar { width: 40px; }
  /* the id line is secondary here: one truncated line keeps the card tight,
     and the detail panel shows it whole */
  #rank-table td.model .msub { white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  #rank-table td.model .mname { font-size: 0.98rem; line-height: 1.3; }
  #rank-table td.model .badge { font-size: 0.72rem; }

  /* row 1: rank | model | index */
  #rank-table td.rank { grid-column: 1 / 2; grid-row: 1; font-size: 0.9rem; }
  #rank-table td.model { grid-column: 2 / 9; grid-row: 1;
    border-inline-start: 0; padding-inline-start: 0; }
  #rank-table td.idx { grid-column: 9 / 13; grid-row: 1;
    justify-self: end; text-align: end; }
  /* row 2: the four prices side by side, so they compare at a glance */
  #rank-table td.in { grid-column: 1 / 4; grid-row: 2; }
  #rank-table td.cache { grid-column: 4 / 7; grid-row: 2; }
  #rank-table td.out { grid-column: 7 / 10; grid-row: 2; }
  #rank-table td.blend { grid-column: 10 / 13; grid-row: 2; }
  /* row 3: the number the table ranks on, given the width to be read.
     Both cells keep the columns above them: the task spans the first three
     price columns, Context starts exactly under BLENDED — an arbitrary offset
     (it used to start 28px left of that column) makes the eye hunt for an edge
     that isn't there. */
  #rank-table td.task { grid-column: 1 / 10; grid-row: 3; font-size: 1.02rem;
    color: var(--accent); }
  /* label stays ABOVE the value on every money cell. An inline label before
     "$0.0455" makes the leading "$" an ET at the start of an RTL run, and the
     Arabic card then renders "0.0455$" — measured, not assumed. */
  #rank-table td.ctx { grid-column: 10 / 13; grid-row: 3; font-size: 0.86rem; }
  /* row 4: the lane — provenance, small, last, and allowed the full width so
     the provider name and its count stay on one line */
  #rank-table td.src { grid-column: 1 / 13; grid-row: 4; font-size: 0.82rem;
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
    color: var(--muted); }
  #rank-table td.src[data-label]::before { display: inline;
    margin-inline-end: 2px; }
  /* the count is a fact about the provider list, not another provider name */
  #rank-table td.src .prov-count::before { content: "· "; }

  /* the group rail moves from the model cell to the card edge, so a model's
     lanes still read as one block */
  #rank-table tbody tr.grp-lead, #rank-table tbody tr.grp-follow {
    border-inline-start: 3px solid var(--accent-dim); }
  #rank-table tbody tr.grp-follow { background: #171b22; }
  #rank-table tbody tr.grp-follow td,
  #rank-table tbody tr.grp-lead:hover td, #rank-table tbody tr.grp-follow:hover td {
    background: transparent; }
  #rank-table tbody tr:hover { border-color: var(--accent-dim); }
  #rank-table tbody tr.grp-lead:not(:first-child) { margin-top: 16px; }
  #rank-table tbody tr.grp-lead:not(:first-child) td { border-top: 0; }
}

/* phone chrome: the type scale, the padding and the slider all shrink here,
   and two lines that only earn their space on a wide screen step aside */
@media (max-width: 720px) {
  :root { font-size: 16px; }
  main, header, footer, #status-bar, #workload-bar { padding-inline: 14px; }
  #hit-slider { width: 140px; }
  #text-filter { width: 270px; }
  h1 { font-size: 1.5rem; }
  .tagline { display: block; font-size: 0.86rem; margin: 4px 0 0; }
  /* the cache hint is the least load-bearing line on the screen, and above
     the table it costs a whole row at this width */
  #hit-hint { display: none; }
  /* the credit line is nowrap so it holds one line on a desktop; on a phone
     that overflows the viewport by ~11px and gives the whole page a sideways
     shift, so it wraps instead */
  footer .site-credit { white-space: normal; flex-wrap: wrap; row-gap: 4px; }
}
