/* ==========================================================================
   VibeSet — design system (minimal).

   One stylesheet, no framework, no external fonts. Two themes driven by
   [data-theme] on <html>: "dark" (default) and "light"; the preference is
   "system" unless the user picks otherwise.

   The direction is minimal: a single accent colour used sparingly, flat
   surfaces (a 1px border plus a faint tint, never blur or translucency),
   no colour ramps, no decorative backdrop layers, no glow. Hierarchy comes
   from type size, weight and spacing; monospace is kept for numbers,
   model ids, coefficients and code because it genuinely reads better.

   Sections, in order:
     1. Tokens          6. Buttons & forms      11. Landing: coding ranks
     2. Reset & type    7. Tables               12. Landing: calculator
     3. Chrome          8. Badges               13. Landing: FAQ & misc
     4. Layout          9. Model cards          14. Toasts
     5. Stat cards     10. Landing: hero        15. Motion & print
  ========================================================================== */

/* ==================== 1. Tokens ==================== */

:root {
  /* Radii — small and consistent; nothing here should read as a bubble. */
  --radius-lg: 12px;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;

  /* Spacing scale */
  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4.5rem;

  /* Type */
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;

  /* Easing — only ever used on short, functional transitions. */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Dark (default) ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d0e12;
  --bg-soft: #13141a;
  --panel: #16171e;
  --panel-2: #1c1e26;
  --panel-3: #23252f;
  --line: #2b2d38;
  --line-soft: #22242d;

  --fg: #e8e9ee;
  --fg-dim: #a4a8b5;
  --fg-faint: #83879a;

  /* The single accent, plus the fill used by primary buttons. The text
     accent is light enough to read on the dark surfaces; the fill is dark
     enough to carry white text. */
  --accent: #9aa2ff;
  --accent-fill: #4b57e0;
  --accent-fill-hover: #5b66e8;
  --accent-soft: #1a1d33;
  --btn-fg: #ffffff;

  --shadow: 0 1px 2px rgba(0, 0, 0, .45);

  /* Token composition bar: four distinct, flat colours. */
  --tk-in: #6b78f0;
  --tk-out: #8b93a8;
  --tk-cr: #3fb37a;
  --tk-cw: #d9a53a;

  /* Semantic */
  --good: #38d39f;
  --warn: #f0b429;
  --bad: #ff6b6b;
  --cache: #38d39f;
  --gold: #f0b429;
  --silver: #a9b4cc;
  --bronze: #d08a4a;

  --err-bg: #2a1618; --err-line: #57292f; --err-fg: #ffb3b3;
  --ok-bg: #14302a;  --ok-line: #235c4b; --ok-fg: #b6f0da;
  --warn-bg: #302713; --warn-line: #5c4a20; --warn-fg: #ffdd9e;
}

/* ---------- Light ---------- */
[data-theme="light"] {
  color-scheme: light;

  --bg: #f7f8fa;
  --bg-soft: #f1f2f6;
  --panel: #ffffff;
  --panel-2: #f6f7fa;
  --panel-3: #eceef3;
  --line: #dcdee6;
  --line-soft: #e8eaef;

  --fg: #16181f;
  --fg-dim: #565c6b;
  --fg-faint: #6b7180;

  --accent: #3a45c8;
  --accent-fill: #3a45c8;
  --accent-fill-hover: #2f39b0;
  --accent-soft: #e9eaff;
  --btn-fg: #ffffff;

  --shadow: 0 1px 2px rgba(20, 24, 48, .07);

  --tk-in: #4b57e0;
  --tk-out: #7b8496;
  --tk-cr: #147a4d;
  --tk-cw: #8a6100;

  /* Deeper than the dark theme's set so each reads at 4.5:1 on white. */
  --good: #0f7a4d;
  --warn: #8a6100;
  --bad: #b3261e;
  --cache: #0f7a4d;
  --gold: #8a6100;
  --silver: #5b6270;
  --bronze: #8a4b1e;

  --err-bg: #fdeeee; --err-line: #f0c4c4; --err-fg: #a8333a;
  --ok-bg: #e8f8f2;  --ok-line: #bfe8d8;  --ok-fg: #14795a;
  --warn-bg: #fdf6e3; --warn-line: #ecd9a0; --warn-fg: #85681a;
}

/* ==================== 2. Reset & typography ==================== */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}

/* Sticky footer: the content column stretches so short pages still pin the
   footer to the bottom of the viewport instead of floating mid-page. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .14s var(--ease);
}
a:hover { color: var(--accent); text-decoration: none; }
a:not(.btn):not([data-link]):hover { text-decoration: underline; text-underline-offset: 3px; }

/* Type carries the hierarchy: no colour, no effects. */
h1, h2, h3, h4 {
  margin: 0 0 .6rem;
  font-weight: 660;
  letter-spacing: -.02em;
  line-height: 1.25;
  text-wrap: balance;
}
h1 { font-size: 1.8rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .92rem; }
p { margin: 0 0 .9rem; }
p:last-child { margin-bottom: 0; }

code, .mono { font-family: var(--mono); font-size: .92em; font-variant-ligatures: none; }

/* Selection uses the accent, flat. */
::selection { background: var(--accent-soft); color: var(--fg); }

/* One focus ring for every interactive element. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Scrollbars, theme aware. */
* { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); background-clip: padding-box; }

/* ==================== 3. Chrome (top bar) ==================== */

#topbar {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .6rem clamp(.9rem, 3vw, 1.75rem);
  min-height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: .04em;
  color: var(--fg);
  margin-right: .9rem;
}
.brand:hover { color: var(--fg); text-decoration: none; }

/* Flat accent tile. No glow, no rotation on hover. */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: var(--radius-xs);
  background: var(--accent-fill);
}
.brand-mark svg { width: 18px; height: 18px; display: block; }

.brand-name { color: var(--fg); font-weight: 800; }

#mainnav { display: flex; gap: .15rem; flex-wrap: wrap; }
#mainnav a {
  padding: .42rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-weight: 500;
  font-size: .9rem;
  white-space: nowrap;
  transition: color .14s var(--ease), background-color .14s var(--ease);
}
#mainnav a:hover { background: var(--panel-2); color: var(--fg); }
/* Active nav is the one place the accent shows in the chrome. */
#mainnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.spacer { flex: 1; }

#userbox { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: nowrap; }
#userbox .who {
  color: var(--fg-dim);
  font-size: .88rem;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#userbox .who strong { color: var(--fg); font-weight: 620; }

.chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  box-sizing: border-box;
  background: var(--panel-2);
  color: var(--fg-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 .6rem;
  font: inherit;
  font-size: .8rem;
  font-weight: 620;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: color .14s var(--ease), border-color .14s var(--ease), background-color .14s var(--ease);
}
.chrome-btn:hover {
  color: var(--fg);
  border-color: var(--fg-faint);
  background: var(--panel-3);
}

/* Balance pill. */
[hidden], .chip[hidden], #balance-chip[hidden] {
  display: none !important;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: .84rem;
  font-weight: 600;
  line-height: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0 .8rem;
  border-radius: 999px;
  white-space: nowrap;
}
.chip.low {
  border-color: var(--err-line);
  color: var(--err-fg);
  background: var(--err-bg);
}

/* ==================== 4. Layout ==================== */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(1.6rem, 4vw, 2.75rem) clamp(.9rem, 3vw, 1.75rem) 6rem;
}

.center-wrap {
  max-width: 430px;
  margin: 7vh auto 0;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
  transition: border-color .16s var(--ease);
}
.panel:hover { border-color: var(--fg-faint); }
.panel > h1:first-child,
.panel > h2:first-child { margin-top: 0; }
.grid .panel { margin-bottom: 0; }

.panel-head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}
.panel-head h2 { margin: 0; }
.panel-head .hint { color: var(--fg-faint); font-size: .84rem; }

/*
 * Explicit column counts, not auto-fit. auto-fit packs as many tracks as will
 * fit, which left a six-card section as 4 + 2 on a wide screen; a fixed count
 * per breakpoint always divides the card counts we actually use (2, 3, 4, 6).
 */
.grid { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }
.grid > * { min-width: 0; }
.grid > * > .tablewrap { max-width: 100%; }

/*
 * A grid is a block-level sibling of panels, so it needs the same bottom
 * margin panels carry — without it the section after a card grid sat flush
 * against it. Nested grids (inside a panel, or inside another grid) get their
 * spacing from the parent's padding/gap instead, so reset there.
 */
.panel .grid:last-child,
.grid .grid { margin-bottom: 0; }

.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1120px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > * { min-width: 0; }
.row.gap { gap: 1rem; align-items: center; }
.row:has(label.field),
.row.align-end { align-items: flex-end; }
.row > label.field { margin-bottom: 0; }

.muted { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.small { font-size: .86rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.good { color: var(--good); }

/* Divider. A plain 1px rule. */
.rule {
  height: 1px;
  border: none;
  margin: var(--sp-6) 0;
  background: var(--line);
}

/* ==================== 5. Stat cards ==================== */

.stat {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  transition: border-color .16s var(--ease);
}
.stat:hover { border-color: var(--fg-faint); }
.stat .label {
  color: var(--fg-faint);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .5rem;
}
.stat .value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 620;
  letter-spacing: -.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.stat .sub { color: var(--fg-dim); font-size: .82rem; margin-top: .35rem; overflow-wrap: anywhere; }
.stat .value.good { color: var(--good); }
.stat .value.bad { color: var(--bad); }

/* The headline card — the one number the page is really about. Weight and
   size, plus an accent label; no tinted fill, no glow. */
.stat.hero {
  border-color: var(--accent);
}
.stat.hero .label { color: var(--accent); }
.stat.hero .value {
  font-size: 2.3rem;
  font-weight: 660;
}
.stat.hero .value.bad { color: var(--bad); }

/* ==================== 6. Buttons & forms ==================== */

label.field { display: block; margin-bottom: 1rem; }
label.field > span {
  display: block;
  color: var(--fg-dim);
  font-size: .82rem;
  font-weight: 500;
  margin-bottom: .35rem;
}
label.field > span.faint { margin-top: .3rem; margin-bottom: 0; font-weight: 400; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .6rem .7rem;
  font: inherit;
  font-size: .92rem;
  line-height: 1.35;
  box-sizing: border-box;
  transition: border-color .14s var(--ease), background-color .14s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--fg-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
}
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input[type="checkbox"] { width: auto; accent-color: var(--accent-fill); }
input[type="number"] { font-family: var(--mono); }
textarea { resize: vertical; min-height: 74px; }
select[multiple] { min-height: 124px; padding: .3rem; }
select[multiple] option { padding: .22rem .4rem; border-radius: var(--radius-xs); }

.inline-field { flex: 1 1 160px; }
.inline-field.narrow { flex: 0 1 130px; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--accent-fill);
  color: var(--btn-fg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6rem 1.05rem;
  min-height: 38px;
  line-height: 1.35;
  box-sizing: border-box;
  font: inherit;
  font-weight: 620;
  font-size: .92rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .14s var(--ease);
}
.btn:hover { background: var(--accent-fill-hover); color: var(--btn-fg); }
.btn:active { background: var(--accent-fill-hover); }
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--accent-fill);
}

.btn-ghost {
  background: var(--panel-2);
  color: var(--fg-dim);
  border-color: var(--line);
}
.btn-ghost:hover {
  color: var(--fg);
  background: var(--panel-3);
  border-color: var(--fg-faint);
}

.btn-danger {
  background: transparent;
  color: var(--err-fg);
  border-color: var(--err-line);
}
.btn-danger:hover { background: var(--err-bg); color: var(--err-fg); }

.btn-small {
  padding: .3rem .72rem;
  font-size: .82rem;
  font-weight: 560;
  min-height: 32px;
  line-height: 1;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--accent-fill);
  color: #ffffff;
  font-weight: 620;
  border-color: transparent;
}
.btn-primary:hover { background: var(--accent-fill-hover); }

/* Oversized call to action, used in the hero. */
.btn-hero {
  font-size: 1.02rem;
  padding: .8rem 1.7rem;
  min-height: 48px;
  border-radius: var(--radius);
  box-sizing: border-box;
}
.hero .cta .btn {
  font-size: 1.02rem;
  padding: .8rem 1.7rem;
  min-height: 48px;
  border-radius: var(--radius);
  box-sizing: border-box;
}

.formerr, .formok {
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  margin-bottom: .9rem;
  font-size: .9rem;
  border: 1px solid;
}
.formerr { color: var(--err-fg); background: var(--err-bg); border-color: var(--err-line); }
.formok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }

/*
 * Informational callout. Distinct from .formerr/.formok: it reports a state of
 * the system rather than the outcome of a form submission, so it uses the
 * accent tone and never implies something failed.
 */
.notice {
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  margin-bottom: .9rem;
  font-size: .9rem;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  color: var(--fg);
}
.notice b { font-weight: 640; }


/* ==================== 7. Tables ==================== */

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
th, td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  background: var(--bg-soft);
  color: var(--fg-dim);
  font-weight: 620;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom-color: var(--line);
}
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
td.mono { font-family: var(--mono); font-size: .85rem; }

tr.detail-row > td { background: var(--bg-soft); padding: 1rem 1.1rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-3); }

/* The active supplier inside an expanded pool: a solid accent edge. */
tr.chosen-pool {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
tr.chosen-pool td { border-bottom-color: var(--line-soft); }

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--fg-faint);
  font-size: .9rem;
}

.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .9rem; }

.tabs {
  display: flex;
  gap: .2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-dim);
  padding: .55rem .9rem;
  font: inherit;
  font-weight: 540;
  cursor: pointer;
  transition: color .14s var(--ease), border-color .14s var(--ease);
}
.tabs button:hover { color: var(--fg); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 620; }

details.raw summary {
  cursor: pointer;
  color: var(--fg-dim);
  font-size: .86rem;
  font-weight: 540;
  padding: .35rem 0;
  transition: color .14s var(--ease);
}
details.raw summary:hover { color: var(--accent); }
details.raw[open] summary { margin-bottom: .5rem; }

/* Key/value line used by the request detail rows. The value side holds long
   monospace ids and must wrap rather than push the label around. */
.kv {
  display: flex;
  gap: .5rem;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line-soft);
  padding: .35rem 0;
}
.kv:last-child { border-bottom: none; }
.kv > span:first-child { flex: 0 0 auto; }
.kv > span:last-child {
  min-width: 0;
  flex: 1 1 auto;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ==================== 8. Badges ==================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .16rem .5rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-dim);
  white-space: nowrap;
}
.badge.ok { color: var(--ok-fg); border-color: var(--ok-line); background: var(--ok-bg); }
.badge.err { color: var(--err-fg); border-color: var(--err-line); background: var(--err-bg); }
.badge.warn { color: var(--warn-fg); border-color: var(--warn-line); background: var(--warn-bg); }
.badge.info {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.badge.mut { color: var(--fg-faint); }

/* ==================== 8b. Token bars, legend, sparkline ==================== */

.tokbar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-3);
  min-width: 90px;
}
.tokbar span { display: block; height: 100%; }
.tokbar .t-in { background: var(--tk-in); }
.tokbar .t-out { background: var(--tk-out); }
.tokbar .t-cr { background: var(--tk-cr); }
.tokbar .t-cw { background: var(--tk-cw); }

.legend {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--fg-dim);
  margin-bottom: .8rem;
}
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .35rem; }
.legend .t-in { background: var(--tk-in); }
.legend .t-out { background: var(--tk-out); }
.legend .t-cr { background: var(--tk-cr); }
.legend .t-cw { background: var(--tk-cw); }

.spark { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 68px; }
.spark .bar {
  flex: 1;
  min-width: 3px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background-color .12s var(--ease);
}
.spark .bar:hover { background: var(--accent-fill-hover); }
.spark-tip {
  position: absolute;
  left: 0;
  top: -4px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .35rem .6rem;
  font-size: .8rem;
  color: var(--fg);
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 5;
}

/* ==================== 8c. Copy box & code ==================== */

.copybox {
  display: flex;
  gap: .5rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .45rem .5rem .45rem .8rem;
  margin: .6rem 0;
}
.copybox-value {
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: .86rem;
  scrollbar-width: none;
}
.copybox-value::-webkit-scrollbar { display: none; }
.copybox-btn { flex: 0 0 auto; }

pre.code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.65;
  color: var(--fg-dim);
  margin: .6rem 0 0;
}

/* ==================== 14. Toasts ==================== */

#toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 100;
  max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  box-shadow: var(--shadow);
  font-size: .89rem;
  animation: toast-in .18s var(--ease-out);
}
.toast.ok { border-left-color: var(--good); }
.toast.err { border-left-color: var(--bad); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ==================== 9. Model cards ==================== */

.modelcard {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color .16s var(--ease);
}
.modelcard:hover { border-color: var(--fg-faint); }
.modelcard.featured { border-color: var(--accent); }
/* Featured cards get an accent bar along the top edge. */
.modelcard.featured::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 2px;
  background: var(--accent);
}

.modelcard .mc-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.modelcard .mc-name { font-weight: 640; font-size: 1rem; letter-spacing: -.01em; }
.modelcard .mc-id {
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--fg-faint);
  overflow-wrap: anywhere;
  margin-top: -.3rem;
}
.modelcard .mc-desc { color: var(--fg-dim); font-size: .855rem; margin: 0; line-height: 1.55; }
.modelcard .mc-ctx {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  margin: .45rem 0 0; font-size: .855rem;
}

/* Coefficient list — the price tag. Dotted leaders tie label to figure. */
.modelcard .mc-coeffs {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .7rem;
  font-size: .855rem;
  margin: .2rem 0 0;
  padding-top: .8rem;
  border-top: 1px solid var(--line-soft);
}
.modelcard .mc-coeffs dt { color: var(--fg-dim); }
.modelcard .mc-coeffs dd { margin: 0; font-family: var(--mono); font-weight: 620; text-align: right; }
.modelcard .mc-coeffs dd.cache { color: var(--cache); }

.mc-strengths { display: flex; flex-wrap: wrap; gap: .32rem; }
.strength {
  font-size: .745rem;
  font-weight: 600;
  padding: .16rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-dim);
  background: var(--panel-2);
}

/* ==================== 10. Landing: hero ==================== */

.hero {
  position: relative;
  text-align: center;
  padding: clamp(3.5rem, 9vw, 6.5rem) 1rem clamp(2.4rem, 5vw, 3.5rem);
}

/* Small pill above the headline: what this is, in three words. */
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .32rem .85rem .32rem .6rem;
  margin-bottom: 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-dim);
  font-size: .82rem;
  font-weight: 540;
}
.hero-eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
}
.hero-eyebrow strong { color: var(--fg); font-weight: 640; }

/* The headline is plain text — size and weight do the work. */
.hero h1 {
  font-size: clamp(2rem, 5.4vw, 3.4rem);
  font-weight: 680;
  line-height: 1.1;
  letter-spacing: -.032em;
  margin: 0 auto 1.1rem;
  max-width: 20ch;
}
.hero p.lead {
  color: var(--fg-dim);
  font-size: clamp(.98rem, 1.6vw, 1.14rem);
  line-height: 1.65;
  max-width: 60ch;
  margin: 0 auto 2.2rem;
  text-wrap: pretty;
}
.hero .cta { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }

/* Trust strip under the buttons: the three facts that answer "is it real?" */
.hero-facts {
  display: flex;
  justify-content: center;
  gap: clamp(1.2rem, 4vw, 3rem);
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.hero-fact { text-align: center; min-width: 96px; }
.hero-fact .hf-value {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 660;
  letter-spacing: -.03em;
}
.hero-fact .hf-label {
  color: var(--fg-faint);
  font-size: .76rem;
  font-weight: 540;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: .25rem;
}

/* ==================== 10b. Landing: section headings ==================== */

.section-title {
  font-size: clamp(1.4rem, 2.8vw, 1.9rem);
  font-weight: 660;
  letter-spacing: -.026em;
  margin: clamp(3.2rem, 7vw, 4.5rem) 0 .6rem;
  text-align: center;
}
.section-subtitle {
  text-align: center;
  color: var(--fg-dim);
  font-size: .95rem;
  max-width: 62ch;
  margin: 0 auto 2rem;
  text-wrap: pretty;
}

/* ==================== 10c. Landing: advantages & use cases ==================== */

.advantage, .use-case {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  position: relative;
  transition: border-color .16s var(--ease);
}
.advantage:hover, .use-case:hover { border-color: var(--fg-faint); }
.advantage h3, .use-case h3 { margin: 0; font-size: 1rem; }
.advantage p, .use-case p { margin: 0; }

/* Icon in a flat tinted tile rather than bare emoji. */
.advantage-icon, .use-case-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

/* ==================== 11. Landing: ranked coding picks ==================== */

/*
 * The ranked picks are the page's centrepiece, so they get their own grid:
 * four across on a desktop, two on a tablet, one on a phone. Never a stray
 * single card on a row of its own.
 */
.coding-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1rem;
}
@media (max-width: 1180px) { .coding-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .coding-grid { grid-template-columns: minmax(0, 1fr); } }

.coding-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1.9rem 1.35rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  transition: border-color .16s var(--ease);
}
.coding-card:hover { border-color: var(--fg-faint); }

/* Tone drives the top rule, so rank reads at a glance. A solid 3px bar. */
.coding-card::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--tone, var(--accent));
}
.coding-card.tone-gold {
  --tone: var(--gold);
  border-color: var(--gold);
}
.coding-card.tone-value {
  --tone: var(--good);
  border-color: var(--good);
}
.coding-card.tone-silver {
  --tone: var(--silver);
}
.coding-card.tone-bronze {
  --tone: var(--bronze);
}

/* Rank chip: a solid tone fill. Text colour flips per theme so it stays
   legible on both the light tone colours (dark theme) and the dark ones
   (light theme). */
.rank-badge {
  position: absolute;
  top: -.75rem;
  left: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.35rem;
  height: 1.5rem;
  padding: 0 .5rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #101318;
  background: var(--tone, var(--accent-fill));
  border: 1px solid var(--panel);
}
.rank-badge.rank-1 { color: #101318; }
.rank-badge.rank-3, .rank-badge.rank-4 { color: #101318; }
[data-theme="light"] .rank-badge { color: #ffffff; }

.coding-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .2rem; }
.coding-title { margin: 0; font-size: 1.06rem; letter-spacing: -.015em; }
.coding-tagline {
  font-size: .78rem;
  font-weight: 640;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.coding-why { margin: 0; color: var(--fg-dim); font-size: .875rem; line-height: 1.6; }

.coding-use-cases { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.use-label {
  width: 100%;
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-faint);
  margin-bottom: .15rem;
}
.use-tag {
  font-size: .745rem;
  padding: .16rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-dim);
}

.coding-coeffs {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .7rem;
  font-size: .855rem;
  margin: auto 0 0;
  padding-top: .85rem;
  border-top: 1px solid var(--line-soft);
}
.coding-coeffs dt { color: var(--fg-dim); }
.coding-coeffs dd { margin: 0; font-family: var(--mono); font-weight: 620; text-align: right; }
.coding-coeffs dd.cache { color: var(--cache); }

.coding-id { font-size: .74rem; color: var(--fg-faint); overflow-wrap: anywhere; }

/* ==================== 12. Landing: token calculator ==================== */

.calc-panel { position: relative; }

.calc-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.6rem;
  align-items: start;
}
@media (max-width: 820px) { .calc-body { grid-template-columns: minmax(0, 1fr); } }

.calc-left, .calc-right { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.calc-right {
  padding-left: 1.6rem;
  border-left: 1px solid var(--line);
}
@media (max-width: 820px) {
  .calc-right { padding-left: 0; padding-top: 1.4rem; border-left: 0; border-top: 1px solid var(--line); }
}

.calc-label {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 620;
  font-size: .72rem;
  color: var(--fg-faint);
}

.calc-rub {
  font-size: clamp(1.9rem, 4.4vw, 2.6rem);
  font-weight: 680;
  letter-spacing: -.035em;
  line-height: 1.1;
}

/* Quick-pick buttons for the amounts that actually unlock tiers. */
.calc-presets { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0 .25rem; }
.calc-preset {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 620;
  padding: .28rem .6rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--fg-dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: color .14s var(--ease), border-color .14s var(--ease), background-color .14s var(--ease);
}
.calc-preset:hover { color: var(--fg); border-color: var(--fg-faint); }
.calc-preset.active {
  color: var(--btn-fg);
  background: var(--accent-fill);
  border-color: var(--accent-fill);
}

/* Range input, restyled in both engines. Flat track, flat accent fill. */
.calc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: .35rem 0 0;
  background: transparent;
  cursor: pointer;
}
.calc-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-fill) 0 / var(--fill, 40%) 100% no-repeat, var(--panel-3);
  border: 1px solid var(--line);
}
.calc-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line);
}
.calc-slider::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-fill);
}
.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-fill);
  transition: border-color .14s var(--ease);
}
.calc-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-fill);
}
.calc-slider:hover::-webkit-slider-thumb { border-color: var(--accent); }
.calc-slider:focus-visible { outline: none; }
.calc-slider:focus-visible::-webkit-slider-thumb { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }
.calc-slider:focus-visible::-moz-range-thumb { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }

.calc-range { display: flex; justify-content: space-between; font-family: var(--mono); }

/* ---- Discount ladder ---- */

.calc-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
}
.calc-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .05rem;
  flex: 1 1 auto;
  min-width: 62px;
  padding: .35rem .3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.calc-tier .ct-rub { font-family: var(--mono); font-size: .74rem; color: var(--fg-faint); }
.calc-tier .ct-pct { font-family: var(--mono); font-size: .88rem; font-weight: 700; color: var(--fg-dim); }
/* Tiers already unlocked by the current amount. */
.calc-tier.reached {
  border-color: var(--ok-line);
  background: var(--ok-bg);
}
.calc-tier.reached .ct-pct { color: var(--ok-fg); }
/* The tier in force right now. */
.calc-tier.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.calc-tier.active .ct-pct { color: var(--accent); }
.calc-tier.active .ct-rub { color: var(--fg-dim); }

.calc-tokens {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 4.4vw, 2.6rem);
  font-weight: 680;
  letter-spacing: -.04em;
  line-height: 1.1;
}
.calc-tokens-sub { margin-top: -.1rem; }

/* Discount headline + breakdown on the results side. */
.calc-discount {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  align-self: flex-start;
  margin: .6rem 0 .15rem;
  padding: .28rem .65rem;
  border-radius: 999px;
  font-weight: 640;
  font-size: .82rem;
  color: var(--ok-fg);
  border: 1px solid var(--ok-line);
  background: var(--ok-bg);
}
.calc-discount .cd-pct { font-family: var(--mono); font-size: .95rem; font-weight: 700; }
.calc-discount.none { color: var(--fg-faint); border-color: var(--line); background: var(--panel-2); }
.calc-discount:empty,
.calc-discount.none:empty { display: none !important; }

.calc-breakdown {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .22rem .8rem;
  margin: .6rem 0 0;
  font-size: .855rem;
}
.calc-breakdown dt { color: var(--fg-dim); }
.calc-breakdown dd { margin: 0; font-family: var(--mono); font-weight: 620; text-align: right; }
.calc-breakdown dd.bonus { color: var(--good); }

.calc-next {
  margin-top: .7rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: var(--panel-2);
  color: var(--fg-dim);
  font-size: .82rem;
  line-height: 1.5;
}
.calc-next strong { color: var(--accent); font-weight: 640; }
.calc-next.maxed { border-style: solid; border-color: var(--warn-line); background: var(--warn-bg); }
.calc-next.maxed strong { color: var(--warn-fg); }

.calc-examples { display: flex; flex-direction: column; gap: .3rem; }
.calc-example {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6rem;
  padding: .35rem .6rem;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
}
.calc-footnote { margin: 1.3rem 0 0; padding-top: .9rem; border-top: 1px solid var(--line-soft); }
.calc-toggle { margin: .25rem 0 1.1rem; }

/* ==================== 13. Landing: cache explainer, spotlight, FAQ ==================== */

.cache-explainer { position: relative; }
.cache-explainer p { margin: 0 0 .7rem; line-height: 1.65; }

.cache-demo {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.cache-demo-row { display: grid; grid-template-columns: 8.5rem 1fr 3.2rem; gap: .7rem; align-items: center; }
@media (max-width: 560px) { .cache-demo-row { grid-template-columns: 6rem 1fr 3rem; } }
.cache-demo-bar {
  height: 12px;
  border-radius: 3px;
  min-width: 8px;
}
.cache-demo-bar.t-in { background: var(--tk-in); }
.cache-demo-bar.t-cr { background: var(--tk-cr); }
.cache-demo-row .mono { text-align: right; }
.cache-demo-note { margin-top: .25rem; }

/* Spotlight cards reuse .modelcard and add the role heading. */
.spotlight-role {
  margin: .35rem 0 0;
  font-size: .95rem;
  letter-spacing: -.012em;
  color: var(--accent);
}
.spotlight.tone-gold .spotlight-role { color: var(--gold); }
.spotlight.tone-silver .spotlight-role { color: var(--silver); }
.spotlight.tone-bronze .spotlight-role { color: var(--bronze); }
.spotlight.tone-gold { border-color: var(--gold); }
.spotlight.tone-gold::before { background: var(--gold); }
.spotlight.tone-silver::before { background: var(--silver); }
.spotlight.tone-bronze::before { background: var(--bronze); }

.all-models-grid { margin-top: .25rem; }

/* ---- FAQ accordion ---- */

.faq-item { border-bottom: 1px solid var(--line-soft); }
.faq-item:last-child { border-bottom: 0; }
.faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 1.1rem .2rem;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--fg);
  font: inherit;
  font-size: .98rem;
  font-weight: 560;
  transition: color .14s var(--ease);
}
.faq-q:hover { color: var(--accent); }
.faq-q.open { color: var(--accent); }
.faq-chevron {
  flex: 0 0 auto;
  color: var(--fg-faint);
  transition: transform .18s var(--ease-out), color .14s var(--ease);
}
.faq-q.open .faq-chevron { transform: rotate(180deg); color: var(--accent); }
.faq-body { padding: 0 2rem 1.1rem .2rem; animation: faq-in .18s var(--ease-out) both; }
.faq-body p { margin: 0; line-height: 1.65; }
@keyframes faq-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ==================== 15. Motion, accessibility, print ==================== */

/*
 * The decorative backdrop layers of the previous design are gone; the element
 * and its class stay defined so the markup (if it is ever re-added) is inert
 * rather than unstyled.
 */
.bg-noise { display: none; }

/* Compatibility shims: two stray class names that no rule ever defined. */
.org { color: var(--accent); }
.w3 { color: var(--fg-faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .modelcard:hover, .coding-card:hover, .advantage:hover, .use-case:hover { transform: none; }
}

@media print {
  body::before, body::after, .bg-noise, #topbar, #toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .modelcard, .coding-card { break-inside: avoid; box-shadow: none; border-color: #ccc; }
  a[data-link] { text-decoration: underline; }
}

/* ==================== 16. Dashboard chrome ==================== */

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: .5rem 0 1.5rem;
}
.dash-greet h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.05rem);
  font-weight: 660;
  letter-spacing: -.03em;
}
.dash-greet p { margin: .3rem 0 0; font-size: .9rem; }
.dash-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Balance warning: loud enough to act on, quiet enough not to shout twice. */
.balance-warn {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin: 0 0 1.5rem;
  padding: .9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--warn-line);
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
}
.balance-warn strong { color: var(--warn-fg); }
.balance-warn.empty {
  border-color: var(--err-line);
  border-left-color: var(--bad);
  background: var(--err-bg);
}
.balance-warn.empty strong { color: var(--err-fg); }
.balance-warn .bw-icon { font-size: 1.15rem; line-height: 1.3; flex: 0 0 auto; }

/* Top-up ladder, one card per rung. */
.topup-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0;
}
@media (max-width: 1080px) { .topup-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px)  { .topup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.topup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .85rem .5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.topup-card:hover {
  border-color: var(--fg-faint);
  background: var(--panel-3);
}
.topup-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.topup-card .tc-rub { font-size: 1.02rem; font-weight: 660; letter-spacing: -.02em; }
.topup-card .tc-pct {
  font-family: var(--mono);
  font-size: .86rem;
  font-weight: 700;
  color: var(--good);
}
.topup-card .tc-tokens { color: var(--fg-dim); }

/* Top-up calculator section inside dashboard */
.topup-calc {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  margin-top: 1.25rem;
}
.topup-calc-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  flex-wrap: wrap;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line-soft);
}
.topup-calc-side {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  min-width: 0;
}
.topup-calc-side.to {
  text-align: right;
  align-items: flex-end;
}
.topup-calc-divider {
  font-size: 1.6rem;
  font-weight: 300;
  color: var(--fg-faint);
  user-select: none;
}
@media (max-width: 680px) {
  .topup-calc-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: .9rem;
  }
  .topup-calc-divider { display: none; }
  .topup-calc-side.to {
    text-align: left;
    align-items: flex-start;
  }
}
.topup-tokens-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
}
.topup-slider-wrap {
  margin-top: 1.2rem;
}
.topup-actions {
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.topup-buttons {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}
.topup-note {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--fg-dim);
  font-size: .84rem;
}
.topup-note-icon {
  color: var(--fg-faint);
}

/* ==================== Docs / installers ==================== */

.docs-h2 {
  margin: 2.6rem 0 .8rem;
  font-size: 1.25rem;
  letter-spacing: -.01em;
}
.docs-faq {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: .65rem;
}
.docs-faq li { color: var(--fg-dim); }
.docs-faq strong { color: var(--fg); }
.panel .copybox { margin-top: .4rem; }
/* ==================== Footer ==================== */

#site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 2.25rem clamp(.9rem, 3vw, 1.75rem) 1.75rem;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 3rem;
  align-items: center;
  justify-content: space-between;
}
.footer-brand { display: flex; align-items: center; gap: .7rem; }
.footer-brand .brand-mark { width: 34px; height: 34px; }
.footer-name { font-weight: 800; letter-spacing: .04em; }
.footer-tagline { font-size: .8rem; color: var(--fg-dim); }
.footer-nav { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.footer-nav a {
  color: var(--fg-dim);
  font-size: .92rem;
  text-decoration: none;
  transition: color .14s var(--ease);
}
.footer-nav a:hover { color: var(--accent); }
.footer-copy {
  max-width: 1200px;
  margin: 1.4rem auto 0;
  font-size: .78rem;
  color: var(--fg-faint);
}
.footer-copy a { color: var(--fg-dim); text-decoration: none; }
.footer-copy a:hover { color: var(--accent); }

/* ==================== Legal pages ==================== */

.legal { max-width: 780px; }
.legal-head { margin-bottom: 2rem; }
.legal-head h1 { margin: 0 0 .4rem; }
.legal-lang-note {
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--fg-faint);
  font-style: italic;
}
.legal-lead { color: var(--fg-dim); }
.legal-section { margin: 0 0 2rem; }
.legal-section h2 {
  font-size: 1.06rem;
  letter-spacing: -.01em;
  margin: 0 0 .7rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
.legal-section p { color: var(--fg-dim); line-height: 1.65; margin: .55rem 0; }
.legal-list {
  margin: .6rem 0;
  padding-left: 1.2rem;
  display: grid;
  gap: .5rem;
  color: var(--fg-dim);
}
.legal-contacts a { color: var(--accent); }
.legal-contacts li { line-height: 1.55; }

/* ==================== Support / tickets ==================== */

.support-hero { margin-bottom: 1.75rem; }
.support-hero h1 { margin: 0 0 .4rem; }
.support-cards { margin-bottom: 1.75rem; }
.support-cards .panel {
  display: flex;
  flex-direction: column;
}
.support-cards .panel > p.muted {
  flex: 1;
}
.support-cards .panel .btn {
  margin-top: auto;
  align-self: flex-start;
}
.support-auth-row { display: flex; gap: .6rem; margin-top: 1rem; }
.support-form .field { margin-bottom: 1rem; }
.support-form textarea.input {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  padding: .65rem .8rem;
  border-radius: var(--radius-sm);
}
.ticket-table { width: 100%; border-collapse: collapse; }
.ticket-row { cursor: pointer; transition: background-color .12s var(--ease); }
.ticket-row:hover { background: var(--panel-2); }
.ticket-table th {
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--fg-faint);
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
}
.ticket-table td { padding: .7rem; border-bottom: 1px solid var(--line); }
.ticket-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.ticket-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.1rem 0 1.25rem;
}
.ticket-detail-subj { margin: 0 0 .3rem; font-size: 1.08rem; }
.ticket-thread {
  display: grid;
  gap: .8rem;
  margin: 1rem 0 1.35rem;
  max-height: 30rem;
  overflow-y: auto;
  padding: .25rem .25rem .5rem;
}
.ticket-msg {
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  background: var(--panel);
}
.ticket-msg.from-admin {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ticket-msg.from-user { margin-left: auto; }
.ticket-msg-meta { margin-bottom: .35rem; font-size: .82rem; }
.ticket-msg-meta strong { letter-spacing: .01em; }
.ticket-msg-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  color: var(--fg-dim);
}
.ticket-actions { display: flex; gap: .6rem; }
.ticket-reply-form { margin-top: .5rem; }

@media (max-width: 640px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .ticket-msg { max-width: 100%; }
}

/* ==== Model health badge (dashboard model cards) ==== */

/* A small solid dot plus a word. No pulse, no ring — the text carries the
   meaning, so colour is never the only signal. */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .16rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 620;
  letter-spacing: .03em;
  line-height: 1.5;
  border: 1px solid;
  user-select: none;
  white-space: nowrap;
}
.health-badge .dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  position: relative;
  flex: none;
}
.health-badge .txt { opacity: 1; }

.health-badge.online {
  color: var(--ok-fg);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}
.health-badge.online .dot {
  background: var(--good);
}

.health-badge.offline {
  color: var(--err-fg);
  border-color: var(--err-line);
  background: var(--err-bg);
}
.health-badge.offline .dot {
  background: var(--bad);
}

.modelcard.offline { opacity: .72; }
.modelcard.offline .mc-coeffs { opacity: .8; }


/* ==================== 17. Catalog Filter & UI Polish ==================== */



/* Copyable model slug */
.mc-id-copyable {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: fit-content;
  border-radius: var(--radius-xs);
  padding: .1rem .35rem;
  margin-left: -.35rem;
  transition: background-color .14s var(--ease), color .14s var(--ease);
}
.mc-id-copyable:hover {
  background: var(--panel-2);
  color: var(--accent);
}
.mc-id-copyable.copied {
  color: var(--good) !important;
  background: var(--panel-2);
}

/* Responsive top navigation on mobile */
@media (max-width: 820px) {
  #topbar {
    padding: .5rem .8rem .4rem;
    gap: .4rem .6rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand spacer user"
      "nav   nav    nav";
    min-height: auto;
  }
  .brand {
    grid-area: brand;
    margin-right: 0;
  }
  .spacer {
    grid-area: spacer;
    display: none;
  }
  #balance-chip:not([hidden]) {
    grid-area: spacer;
    display: inline-flex;
    align-items: center;
    justify-self: end;
    margin-right: .3rem;
  }
  #balance-chip[hidden] {
    display: none !important;
  }
  #userbox {
    grid-area: user;
    justify-content: flex-end;
    gap: .3rem;
    flex-wrap: nowrap;
  }
  #mainnav {
    grid-area: nav;
    overflow-x: auto;
    flex-wrap: nowrap;
    width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: .25rem 0 .2rem;
    margin: 0 -.4rem;
    padding-left: .4rem;
  }
  #mainnav::-webkit-scrollbar {
    display: none;
  }
}

/* ---- Hidden admin entry point -------------------------------------------
   One unobtrusive control in the footer, rendered only for an administrator
   who is already signed in. It is the sole thing on the public site that leads
   to the panel; nothing else hints that /admin exists. */
.admin-link {
  display: block;
  margin: 1rem auto 0;
  padding: .3rem .7rem;
  font: inherit;
  font-size: .78rem;
  color: var(--muted, #8b90a0);
  background: none;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: 999px;
  cursor: pointer;
}
.admin-link:hover { color: var(--fg, #e8e9f0); }

/* The login card (and the admin one behind it) sits alone in the viewport, so
   centre it vertically as well as horizontally. */
main > .center-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 18rem);
}
