/* ============================================================================
   LocalLLM Fit — design tokens

   Aesthetic: technical instrument. Bench equipment, not a SaaS dashboard.
   Dark-first because this sits alongside terminals; the light theme is designed
   as a printed instrument panel rather than an inversion.

   Two flavours from one codebase, switched by data-brand on <html>:
     neutral     (default) — personal/GitHub build, no Elements AI connection
     elementsai            — full Elements AI brand per its brand guide

   OKLCH throughout: equal lightness steps look equal, which HSL does not give.
   Chroma drops as lightness approaches the extremes, or colours go garish.
   ============================================================================ */

:root {
  /* neutral · dark — graphite casing, tinted very slightly toward the signal hue */
  --bg:            oklch(0.165 0.008 158);
  --bg-glow:       none;
  --surface:       oklch(0.205 0.009 158);
  --surface-2:     oklch(0.235 0.010 158);
  --surface-3:     oklch(0.275 0.011 158);
  --line:          oklch(0.31 0.010 158 / 0.55);
  --line-strong:   oklch(0.345 0.012 158);

  --text:          oklch(0.945 0.006 158);
  --text-2:        oklch(0.735 0.009 158);
  --text-3:        oklch(0.575 0.010 158);

  /* One signal colour. It stays rare so it keeps meaning. */
  --accent:        oklch(0.755 0.115 156);
  --accent-ink:    oklch(0.19 0.03 158);
  --accent-soft:   oklch(0.755 0.115 156 / 0.12);
  --accent-line:   oklch(0.755 0.115 156 / 0.30);

  /* Data series need genuinely different hues, not three tints of one. */
  --series-1:      oklch(0.755 0.115 156);
  --series-2:      oklch(0.70 0.105 236);
  --series-3:      oklch(0.46 0.016 158);

  --good:          oklch(0.755 0.115 156);
  --good-soft:     oklch(0.755 0.115 156 / 0.12);
  --warn:          oklch(0.78 0.135 68);
  --warn-soft:     oklch(0.78 0.135 68 / 0.14);
  --bad:           oklch(0.68 0.175 22);
  --bad-soft:      oklch(0.68 0.175 22 / 0.14);

  --shadow-hero:   0 1px 0 oklch(1 0 0 / 0.05) inset, 0 18px 44px -28px oklch(0 0 0 / 0.75);
  --shadow-card:   0 1px 0 oklch(1 0 0 / 0.03) inset, 0 8px 24px -22px oklch(0 0 0 / 0.7);

  /* Instruments have tight radii, not pill-shaped everything. */
  --radius:        8px;
  --radius-lg:     10px;
  --wrap:          1180px;
  --ease:          cubic-bezier(.2, .7, .3, 1);
  --dur:           170ms;

  /* 4pt scale, semantic names */
  --space-xs: 4px;  --space-sm: 8px;  --space-md: 12px; --space-lg: 16px;
  --space-xl: 24px; --space-2xl: 32px; --space-3xl: 48px;

  --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme='light'] {
  /* neutral · light — a printed panel: warm paper, ink, one signal colour */
  --bg:            oklch(0.965 0.005 158);
  --bg-glow:       none;
  --surface:       oklch(0.995 0.002 158);
  --surface-2:     oklch(0.975 0.004 158);
  --surface-3:     oklch(0.945 0.006 158);
  --line:          oklch(0.28 0.01 158 / 0.10);
  --line-strong:   oklch(0.28 0.01 158 / 0.20);

  --text:          oklch(0.235 0.012 158);
  --text-2:        oklch(0.455 0.012 158);
  --text-3:        oklch(0.615 0.010 158);

  --accent:        oklch(0.505 0.135 152);
  --accent-ink:    oklch(0.995 0 0);
  --accent-soft:   oklch(0.505 0.135 152 / 0.10);
  --accent-line:   oklch(0.505 0.135 152 / 0.28);

  --series-1:      oklch(0.545 0.135 152);
  --series-2:      oklch(0.545 0.115 240);
  --series-3:      oklch(0.775 0.012 158);

  --good:          oklch(0.505 0.135 152);
  --good-soft:     oklch(0.505 0.135 152 / 0.10);
  --warn:          oklch(0.545 0.115 62);
  --warn-soft:     oklch(0.545 0.115 62 / 0.10);
  --bad:           oklch(0.525 0.165 22);
  --bad-soft:      oklch(0.525 0.165 22 / 0.10);

  --shadow-hero:   0 1px 0 oklch(1 0 0) inset, 0 16px 36px -30px oklch(0.2 0.02 158 / 0.35);
  --shadow-card:   0 1px 0 oklch(1 0 0) inset, 0 6px 18px -18px oklch(0.2 0.02 158 / 0.28);
}

/* ---------------------------------------------------------------------------
   Elements AI flavour. Values come from the Elements AI brand guide, not from
   taste. The guide mandates Inter + Geist Mono and forbids substitution, which
   overrides the general preference against Inter: for a branded surface,
   consistency with the brand is the point.
   --------------------------------------------------------------------------- */
:root[data-brand='elementsai'] {
  --bg:            #10131d;
  --surface:       #181b26;
  --surface-2:     #1c1f2a;
  --surface-3:     #272a34;
  --line:          #44465226;
  --line-strong:   #4446524d;

  --text:          #e8e5e0;
  --text-2:        rgba(232, 229, 224, 0.62);
  --text-3:        rgba(232, 229, 224, 0.36);

  --accent:        #f59768;
  --accent-ink:    #10131d;
  --accent-soft:   #f5976824;
  --accent-line:   #f5976859;

  --series-1:      #f59768;
  --series-2:      #7d97e0;
  --series-3:      #4a4d59;

  --good:          #8fc9a0;  --good-soft: #8fc9a01f;
  --warn:          #ffb693;  --warn-soft: #ffb6931f;
  --bad:           #e0736b;  --bad-soft:  #e0736b1f;

  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-brand='elementsai'][data-theme='light'] {
  --bg:            #f3f1ed;
  --surface:       #ffffff;
  --surface-2:     #faf8f4;
  --surface-3:     #eceae4;
  --line:          #10131d14;
  --line-strong:   #10131d26;

  --text:          #10131d;
  --text-2:        rgba(16, 19, 29, 0.66);
  --text-3:        rgba(16, 19, 29, 0.42);

  --accent:        #e07840;
  --accent-ink:    #ffffff;
  --accent-soft:   #e0784014;
  --accent-line:   #e078403d;

  --series-1:      #e07840;
  --series-2:      #3150aa;
  --series-3:      #c9c5bd;
}

* { box-sizing: border-box; }

/* The hidden attribute must win. Any element carrying an explicit display rule
   (.field.split is display:grid) would otherwise override the UA's [hidden]
   style and stay on screen — which is how VRAM and System RAM leaked into the
   Apple Silicon panel, where there is only one pool of memory. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }   /* nothing should ever scroll the page sideways */

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

/* Numbers must never jitter while a slider moves. */
.num, input[type='number'], .mono, .stat-v, .out { font-variant-numeric: tabular-nums; }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }

a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0; font-weight: 600;
}
.skip:focus { left: 0; }

/* ───────────────── top bar ───────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }

.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 600; letter-spacing: -.015em; }
.brand-mark { font-size: 1rem; line-height: 1; color: var(--accent); }
.brand-name b { font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.freshness {
  font-size: .74rem; color: var(--text-3); font-family: var(--mono);
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.freshness::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 0 3px var(--good-soft);
}
.freshness[data-state='stale']::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.freshness[data-state='error']::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text-2); cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
[data-theme='dark'] .i-sun { display: none; }
[data-theme='light'] .i-moon { display: none; }

/* ───────────────── layout ───────────────── */

.stage {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  padding: 1.75rem 0 2rem;
}
/* Grid and flex children default to min-width:auto, so a single nowrap element
   (the long mlx_lm.generate command) refuses to shrink and drags the whole
   layout wider than the viewport. Everything that can hold long content has to
   be allowed to shrink below it. */
.stage > *, .answer-zone, .hero, .runner, .infobox, .warnbox { min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.controls { position: sticky; top: 76px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }

.h-eyebrow {
  font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 .55rem;
}

.ghost-btn {
  font: inherit; font-size: .78rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent);
  transition: background var(--dur) var(--ease);
}
.ghost-btn:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* segmented control */
.seg {
  display: grid; grid-auto-flow: column; gap: 3px;
  background: var(--surface-3); padding: 3px; border-radius: 11px; margin-bottom: 1rem;
}
.seg-btn {
  font: inherit; font-size: .8rem; font-weight: 500; padding: .45rem .3rem;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

.field { margin-bottom: .9rem; }
.field.split { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.field label {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
  font-size: .82rem; font-weight: 500; color: var(--text-2); margin-bottom: .35rem;
}
.unit { font-size: .72rem; color: var(--text-3); font-family: var(--mono); }
.out {
  font-family: var(--mono); font-size: .78rem; color: var(--accent);
  background: var(--accent-soft); padding: .1rem .4rem; border-radius: 6px;
}

input[type='number'], select {
  width: 100%; font: inherit; font-size: .9rem;
  padding: .5rem .65rem; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
select { appearance: none; padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1.05rem center, right .8rem center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type='range'] {
  width: 100%; appearance: none; background: transparent; height: 22px; cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px; background: var(--surface-3);
}
input[type='range']::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent-line), 0 2px 6px #0006;
  transition: transform var(--dur) var(--ease);
}
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 99px; background: var(--surface-3); }
input[type='range']::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent-line);
}

.help { font-size: .76rem; color: var(--text-3); margin: .4rem 0 0; line-height: 1.45; }

.rule { border: 0; border-top: 1px solid var(--line); margin: 1.15rem 0 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  font: inherit; font-size: .78rem; font-weight: 500; padding: .35rem .7rem;
  border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.is-active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

.note {
  font-size: .78rem; color: var(--text-2); line-height: 1.5;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  padding: .6rem .75rem; border-radius: var(--radius); margin-bottom: var(--space-md);
}

/* memory presets: one tap beats typing a number */
.presets { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .45rem; }
.preset {
  font: inherit; font-family: var(--mono); font-size: .74rem; padding: .28rem .5rem;
  border-radius: 8px; cursor: pointer; min-width: 2.6rem;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.preset:hover { color: var(--text); border-color: var(--text-3); }
.preset.is-active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.preset-custom {
  width: 4.6rem !important; font-family: var(--mono); font-size: .74rem !important;
  padding: .28rem .5rem !important; border-radius: 8px;
  -moz-appearance: textfield;
}
.preset-custom::-webkit-outer-spin-button,
.preset-custom::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.preset-custom::placeholder { color: var(--text-3); }

/* ───────────────── the answer ───────────────── */

/* Plain English before any numbers. */
/* Set as a statement, not a callout. An accent stripe down the side is the most
   overused device in this kind of UI and it never reads as intentional. */
.summary {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.1rem); line-height: 1.55;
  color: var(--text-2); margin: 0 0 var(--space-lg); max-width: 68ch;
}
.summary b { color: var(--text); font-weight: 600; }

/* An assumed configuration must not look like a confirmed one. */
.summary-guess {
  background: var(--warn-soft); border: 1px solid color-mix(in oklab, var(--warn) 38%, transparent);
  padding: var(--space-md) var(--space-lg); border-radius: var(--radius);
}
.summary-guess b { color: var(--warn); }

.link-btn {
  font: inherit; font-size: .78rem; padding: 0; border: 0; background: none;
  color: var(--text-2); cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent); }

.answer-zone { min-height: 420px; }

.empty {
  display: grid; place-items: center; gap: .75rem; text-align: center;
  min-height: 420px; color: var(--text-3);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.empty-mark { font-size: 2rem; color: var(--line-strong); }

/* hero — deliberately outranks everything else on the page */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-hero);
}
/* A single hairline at the top edge, the way a panel meets its bezel. */
.hero::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 1px;
  background: var(--accent); opacity: .85;
}
/* A single soft bloom behind the answer, so depth comes from light rather than
   from putting a drop shadow on everything. */

/* On paper the same bloom reads as a smudge rather than light, so it is much
   weaker and pulled to the top edge where it behaves like a highlight. */



.badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.badge {
  font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: .25rem .55rem; border-radius: 6px; display: inline-flex; align-items: center; gap: .35rem;
}
.badge-pick { background: var(--accent); color: var(--accent-ink); }
.badge-comfortable, .badge-fits {
  background: transparent; color: var(--good); box-shadow: inset 0 0 0 1px currentColor;
}
.badge-tight       { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px currentColor; }
.badge-wont-fit    { background: var(--bad-soft);  color: var(--bad);  box-shadow: inset 0 0 0 1px currentColor; }
.badge-new { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
.badge-cap { background: transparent; color: var(--series-2); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--series-2) 45%, transparent); }

.hero-name {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 700; letter-spacing: -.03em;
  line-height: 1.08; margin: 0 0 .3rem;
}
.hero-pub { font-size: .8rem; color: var(--text-3); font-family: var(--mono); margin: 0 0 1rem; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: var(--space-lg); margin-bottom: var(--space-xl);
  padding: var(--space-lg) 0; border-block: 1px solid var(--line);
}
.stat-k {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: .3rem;
}
.stat-v { font-family: var(--mono); font-size: 1.05rem; font-weight: 500; letter-spacing: -.01em; }
.stat-v small { font-weight: 400; color: var(--text-2); font-size: .8em; }

/* the arithmetic, shown — the thing ModelFit never does */
.budget { margin-bottom: 1.1rem; }
.budget-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: var(--space-sm);
}
.bar {
  display: flex; height: 26px; border-radius: 4px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line-strong);
}
.bar-seg { display: grid; place-items: center; font-size: .66rem; font-weight: 600; min-width: 0; transition: flex-basis var(--dur) var(--ease); }
.bar-seg span { padding-inline: .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg-w  { background: var(--series-1); color: var(--accent-ink); }
.seg-kv { background: var(--series-2); color: oklch(0.18 0.02 236); }
.seg-ov { background: var(--series-3); color: var(--text-2); }
.bar-over { background: repeating-linear-gradient(45deg, var(--bad) 0 6px, color-mix(in srgb, var(--bad) 60%, transparent) 6px 12px); }
.bar-limit { position: relative; margin-top: .35rem; font-size: .68rem; color: var(--bad); font-family: var(--mono); }
.seg-free { background: transparent; color: var(--text-3); }
.bar-legend { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: .5rem; font-size: .73rem; color: var(--text-2); }
.bar-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: .35rem; }

.cmd {
  display: flex; align-items: center; gap: .6rem; min-width: 0; max-width: 100%;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: .55rem .7rem; font-family: var(--mono); font-size: .82rem;
}
.cmd code {
  flex: 1; min-width: 0;              /* the actual fix: allow shrinking */
  overflow-x: auto; white-space: nowrap; color: var(--text);
  scrollbar-width: thin;
}
.cmd .prompt { color: var(--text-3); }
.copy-btn {
  flex: 0 0 auto;
  font: inherit; font-size: .72rem; padding: .25rem .5rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.copy-btn:hover { color: var(--text); }
.copy-btn.is-done { color: var(--good); border-color: var(--good); }

.verified {
  font-size: .68rem; font-family: var(--mono); color: var(--good);
  display: inline-flex; align-items: center; gap: .3rem; margin-top: .5rem;
}

.links { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .9rem; font-size: .78rem; }
.links a { color: var(--text-2); }
.links a:hover { color: var(--accent); }

/* runner-up — clearly subordinate, but with a stated reason it is second */
.runner {
  margin-top: 1rem; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-card);
}
.runner-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.runner-name { font-size: 1.1rem; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.runner-why { font-size: .82rem; color: var(--text-2); margin: .4rem 0 .7rem; }
.runner-stats { display: flex; flex-wrap: wrap; gap: 1.2rem; font-size: .78rem; color: var(--text-2); }
.runner-stats b { color: var(--text); font-weight: 600; }

details.others { margin-top: 1rem; }
details.others > summary {
  cursor: pointer; font-size: .82rem; color: var(--text-2); padding: .5rem 0;
  list-style: none; display: flex; align-items: center; gap: .45rem;
}
details.others > summary::-webkit-details-marker { display: none; }
details.others > summary::before { content: '▸'; color: var(--text-3); transition: transform var(--dur) var(--ease); }
details.others[open] > summary::before { transform: rotate(90deg); }
.other-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.other {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .8rem;
}
.other-name { font-size: .86rem; font-weight: 600; margin: 0 0 .3rem; letter-spacing: -.01em; }
.other-meta { font-size: .73rem; color: var(--text-3); font-family: var(--mono); }

.warnbox {
  margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid color-mix(in oklab, var(--warn) 34%, var(--line-strong));
  color: var(--text-2); font-size: .82rem; line-height: 1.5;
}
.warnbox b { color: var(--warn); }

/* A tip that unlocks capability is not a warning, and colouring it like one
   both clashes with the palette and misreads as an error. */
.infobox {
  margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  color: var(--text-2); font-size: .82rem; line-height: 1.55;
}
.infobox b { color: var(--text); font-weight: 600; }
.infobox code {
  font-family: var(--mono); font-size: .95em; color: var(--text);
  background: var(--surface-3); padding: .1rem .35rem; border-radius: 5px;
  border: 1px solid var(--line-strong);
}
.warnbox code { font-family: var(--mono); font-size: .95em; background: var(--surface-3); padding: .1rem .35rem; border-radius: 5px; }

/* skeletons — never a spinner on an empty page */
.skel { border-radius: var(--radius-lg); border: 1px solid var(--line-strong); padding: 1.4rem 1.5rem; background: var(--surface); }
.skel-line { height: 12px; border-radius: 6px; margin-bottom: .7rem;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skel-line.lg { height: 34px; width: 62%; margin-bottom: 1.1rem; }
.skel-line.sm { width: 40%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ───────────────── explainer + footer ───────────────── */

.explainer { padding: 1.5rem 0 3rem; border-top: 1px solid var(--line); }
.explainer h2 { font-size: 1.05rem; letter-spacing: -.02em; margin: 0 0 1rem; }
.explainer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.explainer h3 { font-size: .85rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.explainer p { margin: 0; font-size: .84rem; color: var(--text-2); line-height: 1.6; }

.foot { border-top: 1px solid var(--line); padding: 1.25rem 0 2.5rem; }
.foot-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .78rem; color: var(--text-3); }
.foot p { margin: 0; }
.foot a { color: var(--text-2); }

/* ───────────────── responsive ───────────────── */

@media (max-width: 1040px) {
  /* On a phone the controls panel is nearly a full screen tall, so leaving it
     first meant scrolling past the entire form to reach the thing people came
     for. The answer leads; the controls sit directly under it. */
  .stage {
    grid-template-columns: 1fr; display: flex; flex-direction: column;
    /* align-items:start is right for the desktop grid (it stops the sidebar
       stretching to full height) but wrong here: in a COLUMN flex container the
       cross axis is horizontal, so `start` sizes children to their content and
       they burst out of the viewport. Stretch is what makes them fill it. */
    align-items: stretch;
  }
  .answer-zone { order: 1; }
  .controls { order: 2; position: static; }
  .wrap { width: min(100% - 1.75rem, var(--wrap)); }
  .answer-zone { min-height: 0; }
}

@media (max-width: 460px) {
  .seg-btn { font-size: .74rem; padding: .45rem .2rem; }
  .field.split { grid-template-columns: 1fr; }
  .freshness { display: none; }
  .hero { padding: 1.15rem 1.1rem 1.25rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .7rem; }
}

/* Touch targets. A 29px chip is fine for a mouse and frustrating for a thumb.
   pointer:coarse is the honest query — it asks how the device is being driven
   rather than inferring it from screen width, so a touchscreen laptop counts. */
@media (pointer: coarse), (max-width: 560px) {
  .preset, .chip { min-height: 36px; padding-inline: .85rem; }
  .ghost-btn { min-height: 36px; }
  .seg-btn { min-height: 40px; }
  .copy-btn { min-height: 34px; padding-inline: .7rem; }
  .icon-btn { width: 40px; height: 40px; }
  .brand { min-height: 40px; align-items: center; }
  /* Action links sit in a row of their own, so they can carry real padding
     without disturbing any prose. */
  .links a, .link-btn { min-height: 34px; display: inline-flex; align-items: center; }
  .links { gap: var(--space-lg) var(--space-xl); }
  input[type='number'], select { min-height: 40px; }
  /* A bigger thumb is easier to grab and easier to see where it landed. */
  input[type='range']::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8px; }
  input[type='range']::-moz-range-thumb { width: 19px; height: 19px; }
  input[type='range'] { height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ─────────────── speed scale ───────────────
   The whole scale, shown once, so a tok/s figure explains itself. Boundaries
   are multiples of average adult reading speed; see SPEED_BANDS in fit.js. */
.stat-band {
  font-size: .68rem; color: var(--text-3); margin-top: .15rem;
  letter-spacing: .01em;
}
.speed-scale { margin-top: .9rem; }
.scale-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); margin-bottom: .35rem;
}
.scale-bands { display: flex; flex-wrap: wrap; gap: .3rem; }
.scale-band {
  display: flex; align-items: baseline; gap: .35rem;
  padding: .25rem .5rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
  font-size: .72rem; color: var(--text-3); min-height: 32px; box-sizing: border-box;
}
.scale-band b { font-weight: 500; color: var(--text-2); }
.scale-band i { font-style: normal; font-family: var(--mono); font-size: .68rem; }
.scale-band.is-here {
  border-color: var(--accent-line); background: var(--accent-soft);
}
.scale-band.is-here b { color: var(--text); font-weight: 600; }

/* ─────────────── routes to fit ───────────────
   Open when the pick was compromised, collapsed when it was clean, so the
   panel appearing expanded is itself information. */
details.routes { margin-top: 1rem; }
details.routes > summary {
  cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: .4rem; list-style: none;
  min-height: 32px;
}
details.routes > summary::-webkit-details-marker { display: none; }
details.routes > summary::before { content: '▸'; color: var(--text-3); transition: transform var(--dur) var(--ease); }
details.routes[open] > summary::before { transform: rotate(90deg); }

.route-list { list-style: none; margin: .55rem 0 0; padding: 0; display: grid; gap: .5rem; }
.route {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  flex-wrap: wrap;
  padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.route-tight { border-color: var(--warn-soft); }
.route-main { display: grid; gap: .18rem; min-width: 0; flex: 1 1 240px; }
.route-kind {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3);
}
.route-label { font-size: .86rem; font-weight: 600; letter-spacing: -.01em; }
.route-gain { font-size: .76rem; color: var(--accent); }
.route-cost { font-size: .73rem; color: var(--text-3); line-height: 1.4; }
.route-side {
  display: flex; align-items: center; gap: .55rem; flex: 0 0 auto;
  margin-left: auto;
}
.route-fit { font-size: .74rem; color: var(--text-3); white-space: nowrap; }
.route-warn { color: var(--warn); }
.route-apply {
  font: inherit; font-size: .76rem; font-weight: 600;
  padding: .35rem .7rem; min-height: 32px;
  border: 1px solid var(--accent-line); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.route-apply:hover { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 520px) {
  .route { flex-direction: column; align-items: stretch; }
  /* flex-basis follows the MAIN axis, so the 240px basis that gives the text
     column a sensible width in a row becomes a 240px minimum HEIGHT once the
     card stacks, spreading four lines over a quarter of the screen. Same shape
     as the align-items bug that shipped here before: a property that is correct
     in one direction and wrong in the other. */
  .route-main { flex: 0 1 auto; }
  .route-side { margin-left: 0; justify-content: space-between; }
  .route-apply { flex: 0 0 auto; }
}

/* ─────────────── applied adjustments ───────────────
   An applied route otherwise leaves no visible trace but a query parameter. */
.applied {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin: 0 0 .7rem;
}
.applied-k {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3);
}
.applied-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .15rem .15rem .55rem; min-height: 36px; box-sizing: border-box;
  border: 1px solid var(--accent-line); border-radius: var(--radius);
  background: var(--accent-soft); font-size: .74rem; color: var(--text-2);
}
.applied-undo {
  /* 32px minimum so it is tappable on a phone. The responsive suite now loads
     a config with an adjustment applied, so this is actually measured. */
  font: inherit; font-size: .95rem; line-height: 1;
  width: 32px; height: 32px; flex: 0 0 32px; display: inline-flex;
  align-items: center; justify-content: center;
  border: 0; border-radius: 4px; background: transparent;
  color: var(--text-3); cursor: pointer;
}
.applied-undo:hover { background: var(--surface-3); color: var(--text); }

/* ─────────────── what this machine is good for ───────────────
   The buying question ("if I get 128 GB, what does that get me?") answered in
   one place, instead of making people flip the use-case chips four times. */
.usecases {
  margin-top: 1rem; padding: .8rem .9rem;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface);
}
.uc-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); margin-bottom: .5rem;
}
.uc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.uc-row {
  display: grid; gap: .1rem .7rem; align-items: baseline;
  grid-template-columns: 8.5rem 1fr;
  padding: .4rem .5rem; border-radius: var(--radius);
  border: 1px solid transparent;
}
.uc-row.is-here { background: var(--accent-soft); border-color: var(--accent-line); }
.uc-label { font-size: .74rem; color: var(--text-3); }
.uc-row.is-here .uc-label { color: var(--text-2); font-weight: 600; }
.uc-model { font-size: .84rem; font-weight: 600; letter-spacing: -.01em; }
.uc-meta { grid-column: 2; font-size: .71rem; color: var(--text-3); }
.uc-none { font-size: .78rem; color: var(--text-3); font-style: italic; }

@media (max-width: 520px) {
  .uc-row { grid-template-columns: 1fr; gap: .05rem; }
  .uc-meta { grid-column: 1; }
}

/* Use cases are multi-select; the hint says so without a legend. */
.h-hint {
  font-size: .62rem; text-transform: none; letter-spacing: 0;
  color: var(--text-3); font-weight: 400; margin-left: .35rem;
}
