/* Tokens: docs/UI-SPEC.md section 1.4 */
:root {
  --c-cream: #fff7e8; --c-white: #ffffff; --c-ink: #1a1033; --c-ink-soft: #5b5170; --c-line-soft: #cfc6dc;
  --c-sun: #ffd23f; --c-raspberry: #d4104f; --c-cobalt: #1f3fd6;
  --c-warn-pale: #ffe4dc; --c-warn-deep: #8a1c00;
  --c-ok-pale: #d2f4ef; --c-ok-deep: #00605a;
  --c-mid-pale: #fff0b8; --c-mid-deep: #6b4a00;
  --t-pea-pale: #d6f5c4; --t-pea-deep: #1d5c12;
  --t-soy-pale: #fff0b8; --t-soy-deep: #6b4a00;
  --t-rice-pale: #cfeefa; --t-rice-deep: #00507a;
  --t-blend-pale: #ffd6e6; --t-blend-deep: #a3003f;
  --t-nut-pale: #ffe0c2; --t-nut-deep: #8f3a00;
  --t-fruit-pale: #e8dcff; --t-fruit-deep: #5a1fa8;
  --t-dairy-pale: #dfe8ff; --t-dairy-deep: #1a37b8;
  --t-egg-pale: #f6e7d6; --t-egg-deep: #6e3f12;
  --f-display: "Archivo", "Arial Black", system-ui, sans-serif;
  --f-label: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-hero: clamp(2.25rem, 6vw + 0.5rem, 4.75rem);
  --fs-small: 0.875rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-pill: 999px;
  --bw: 3px; --bw-thin: 2px;
  --sh-sm: 3px 3px 0 0 var(--c-ink); --sh-md: 5px 5px 0 0 var(--c-ink); --sh-lg: 8px 8px 0 0 var(--c-ink); --sh-pressed: 1px 1px 0 0 var(--c-ink);
  --focus: 0 0 0 3px var(--c-cream), 0 0 0 6px var(--c-cobalt);
  --dur-fast: 120ms; --dur-med: 220ms; --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1); --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --page-max: 1280px; --control-col: 360px; --gutter: 16px; --phone-bar-h: 64px;
}
@media (min-width: 900px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--c-cream); color: var(--c-ink); }
body { margin: 0; font: 400 1rem/1.5 var(--f-body); overflow-x: hidden; }
img, svg, input, select { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--c-cobalt); }
.label { font: 700 1rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; }
.label--sm { font-size: 0.8125rem; letter-spacing: 0.06em; color: var(--c-ink-soft); }
.display { font-family: var(--f-display); font-weight: 900; font-stretch: 125%; }
.h-sec { font: 800 1.25rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.03em; margin: var(--sp-5) 0 var(--sp-3); }
.help, .small { font-size: var(--fs-small); line-height: 1.45; }
.help { color: var(--c-ink-soft); margin-top: var(--sp-1); }
.num { font-variant-numeric: tabular-nums; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.skip { position: fixed; top: 8px; left: 8px; z-index: 50; background: var(--c-sun); color: var(--c-ink); border: var(--bw) solid var(--c-ink); padding: 8px 12px; transform: translateY(-200%); font-weight: 700; }
.skip:focus { transform: none; box-shadow: var(--sh-md); }

/* Buttons */
.btn { font: 800 1.0625rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; min-height: 48px; padding: 0 var(--sp-4);
  border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-md); cursor: pointer; color: var(--c-ink); background: var(--c-white);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.btn--primary { background: var(--c-raspberry); color: var(--c-white); }
.btn--cobalt { background: var(--c-cobalt); color: var(--c-white); width: 100%; }
.btn--cobalt.ok { background: var(--c-sun); color: var(--c-ink); }
.btn--sm { min-height: 40px; box-shadow: var(--sh-sm); font-size: 0.9375rem; }
.btn:focus-visible { box-shadow: var(--sh-md), var(--focus); }
@media (hover: hover) { .btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 0 var(--c-ink); } }
.btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: var(--sh-pressed); }
.btn:disabled { background: var(--c-cream); color: var(--c-ink-soft); border-style: dashed; box-shadow: none; cursor: not-allowed; }
.textbtn { font: 700 0.9375rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-cobalt); background: none; border: 0; padding: 0; min-height: 44px;
  text-decoration: underline 2px; text-underline-offset: 3px; cursor: pointer; border-radius: 4px; }

/* Hero */
.hero { background: var(--c-sun); border-bottom: var(--bw) solid var(--c-ink); padding: var(--sp-6) var(--gutter); }
.hero__in { max-width: var(--page-max); margin: 0 auto; position: relative; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-size: 1.5rem; line-height: 1; background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-md); padding: 5px 6px 5px 12px; transform: rotate(-2deg); white-space: nowrap; }
.wm-worth { display: inline-flex; align-items: center; }
.wm-worth svg { margin: 0 1px; flex: none; }
.wm-the { font: 800 0.95rem/1 var(--f-label); letter-spacing: 0.06em; color: var(--c-ink-soft); align-self: center; }
.wm-bar { background: var(--c-raspberry); color: var(--c-white); border: var(--bw-thin) solid var(--c-ink); border-radius: 8px; padding: 3px 8px 2px; transform: rotate(3deg); box-shadow: 2px 2px 0 0 var(--c-ink); }
.hero h1 { font-size: var(--fs-hero); line-height: 0.95; letter-spacing: -0.02em; margin: var(--sp-4) 0 var(--sp-3); max-width: 13ch; overflow-wrap: break-word; }
.scrolldown { display: inline-flex; align-items: center; gap: 10px; margin-top: var(--sp-5); min-height: 48px; padding: 10px 18px 10px 22px; font: 800 1.125rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--c-white); background: var(--c-ink); border: var(--bw) solid var(--c-ink); border-radius: var(--r-pill); box-shadow: 4px 4px 0 0 var(--c-raspberry); text-decoration: none; }
.scrolldown svg { animation: nudge 1.6s ease-in-out infinite; }
.scrolldown:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 0 var(--c-raspberry); }
.scrolldown:focus-visible { outline: none; box-shadow: 4px 4px 0 0 var(--c-raspberry), var(--focus); }
@keyframes nudge { 50% { transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .scrolldown svg { animation: none; } }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.hero__sub { font-weight: 500; font-size: 1.125rem; line-height: 1.45; max-width: 46ch; }
.hero__ctas { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-3) var(--sp-4); margin-top: var(--sp-5); width: 100%; }
.hero__ctas .scrolldown { margin-top: 0; }
.aibtn { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 20px 10px 16px; font: 800 1.125rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--c-ink); background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-pill); box-shadow: 4px 4px 0 0 var(--c-cobalt); cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.aibtn svg { color: var(--c-cobalt); flex: none; }
@media (hover: hover) { .aibtn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 0 var(--c-cobalt); } }
.aibtn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 0 var(--c-cobalt); }
.aibtn:focus-visible { box-shadow: 4px 4px 0 0 var(--c-cobalt), var(--focus); }
.stickers { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4) var(--sp-5); margin-top: var(--sp-5); }
.sticker.sticker--math { color: var(--c-raspberry); border-color: var(--c-raspberry); box-shadow: 4px 4px 0 0 var(--c-raspberry); }
.sticker.sticker--iq { color: var(--c-ink); border-color: var(--c-ink); box-shadow: 4px 4px 0 0 var(--c-ink); text-align: left; }
.sticker--iq sup { font-size: 0.7em; vertical-align: 0.5em; line-height: 0; }
.sticker--iq small { display: block; font: 500 0.75rem/1.25 var(--f-body); text-transform: none; color: var(--c-ink-soft); margin-top: 4px; max-width: 22ch; }
.sticker { font: 800 1.125rem/1 var(--f-label); text-transform: uppercase; color: var(--c-cobalt); background: var(--c-white); border: var(--bw) solid var(--c-cobalt); border-radius: var(--r-md);
  box-shadow: 4px 4px 0 0 var(--c-cobalt); padding: 6px 12px; transform: rotate(var(--rot, 0deg)); display: inline-block; }
.ghsticker { position: absolute; top: 0; right: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; font: 800 0.9375rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--c-ink); background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-sm); text-decoration: none; transform: rotate(3deg);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
@media (hover: hover) { .ghsticker:hover { transform: rotate(3deg) translate(-2px, -2px); box-shadow: 5px 5px 0 0 var(--c-ink); } }
.ghsticker:focus-visible { box-shadow: var(--sh-sm), var(--focus); }
/* Phone hero: short enough that the chips and the start of the ranking show on the first screen. */
@media (max-width: 899px) {
  .hero { padding: var(--sp-4) var(--gutter) var(--sp-5); }
  .hero__in { display: flex; flex-direction: column; align-items: flex-start; }
  .ghsticker { top: 0; font-size: 0.8125rem; padding: 0 10px; gap: 5px; transform: rotate(3deg); }
  .ghsticker svg { width: 16px; height: 16px; }
  .hero h1 { font-size: clamp(1.625rem, 5vw + 0.4rem, 2.5rem); line-height: 1; max-width: none; margin: var(--sp-3) 0 var(--sp-2); }
  .hero__sub { font-size: 0.9375rem; line-height: 1.4; }
  .hero__ctas { align-self: stretch; justify-content: flex-start; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-4); }
  .hero__ctas > * { flex: 1 1 auto; justify-content: center; min-height: 44px; padding: 8px 12px; font-size: 0.9375rem; gap: 6px; white-space: nowrap; }
  .hero__ctas svg { width: 18px; height: 18px; }
  .stickers { flex-wrap: nowrap; gap: var(--sp-3); margin-top: var(--sp-4); }
  .sticker { font-size: 0.9375rem; padding: 5px 9px; box-shadow: 3px 3px 0 0 currentColor; white-space: nowrap; }
  .sticker--iq small, .sticker--iq sup, .gh-long { display: none; }
  .wordmark { font-size: 1.3rem; }
}
/* Phone in landscape: keep the hero to the wordmark, headline and buttons. */
@media (max-width: 899px) and (max-height: 500px) { .hero__sub, .stickers { display: none; } .hero h1 { font-size: 1.75rem; } }
@media (max-width: 899px) { main.layout { padding-top: var(--sp-2); } .presets.presets--top { margin-top: 0; } #count { font-size: 0.9375rem; } }
@media (max-width: 380px) { .hero h1 { font-size: 1.5rem; } .hero__ctas > * { padding: 8px 9px; font-size: 0.875rem; } .wordmark { font-size: 1.15rem; } .sticker { font-size: 0.8125rem; padding: 4px 7px; } .stickers { gap: var(--sp-2); } }
@media (min-width: 900px) {
  .hero { padding: var(--sp-7) var(--gutter); }
  .sticker { font-size: 1.5rem; padding: 8px 16px; }
  .sticker--iq { font-size: 1.125rem; }
  .ghsticker { font-size: 1.0625rem; padding: 0 16px; }
}
/* Wide: a two-column hero. Text on the left, a sticker cluster filling the right half, centred on the headline. */
@media (min-width: 1100px) {
  .hero__in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 40%); grid-template-rows: auto auto auto 1fr auto; column-gap: var(--sp-6); }
  .hero__in > .hero__ctas { grid-column: 1 / -1; grid-row: 5; margin-top: var(--sp-6); }
  .hero__in > :not(.stickers):not(.ghsticker):not(.hero__ctas) { grid-column: 1; }
  .wordmark { justify-self: start; }
  .stickers { grid-column: 2; grid-row: 1 / 5; align-self: center; justify-self: center; margin: var(--sp-7) 0 0;
    display: grid; grid-template-columns: auto auto; gap: var(--sp-5) var(--sp-4); align-items: center; justify-items: center; }
  .sticker { font-size: 2.25rem; padding: 10px 20px; }
  .sticker--math { grid-column: 1 / -1; justify-self: start; }
  .sticker--count { justify-self: end; }
  .sticker--iq { font-size: 1.375rem; justify-self: start; }
  .sticker--iq small { font-size: 0.8125rem; }
}

/* Layout */
.layout { max-width: var(--page-max); margin: 0 auto; padding: var(--sp-4) var(--gutter) calc(var(--phone-bar-h) + var(--sp-6)); }
#results { min-width: 0; }
#results:focus { outline: none; box-shadow: none; }
@media (min-width: 900px) {
  .layout { padding: var(--sp-6) var(--gutter); display: grid; grid-template-columns: var(--control-col) minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
  /* --panel-h is set by app.js so the panel always ends at the window's bottom edge, even while the hero is still on screen.
     No overscroll containment: once the panel reaches its end, the wheel scrolls the page. */
  .layout > #controls { position: sticky; top: var(--sp-4); max-height: var(--panel-h, calc(100dvh - 2 * var(--sp-4))); overflow-y: auto;
    background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: var(--sp-5) var(--sp-5) 0; }
  .presets--top, .phone-bar { display: none !important; }
}

/* Presets */
.presets { margin-top: var(--sp-2); }
.chiprow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: 2px 6px 6px 2px; }
.chiprow > .label { flex: 0 0 100%; }
.presets--top .chiprow { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter) 8px; }
.presets--top .chiprow > .label { flex: 0 0 auto; }
.presets--top { margin-bottom: var(--sp-2); }
.chip { font: 700 1rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; padding: 10px 16px; min-height: 44px; border-radius: var(--r-pill);
  border: var(--bw) solid var(--c-ink); background: var(--c-white); color: var(--c-ink); box-shadow: var(--sh-sm); cursor: pointer; transition: transform var(--dur-fast) var(--ease-out); }
.chip[aria-pressed="true"] { background: var(--c-sun); transform: rotate(-2deg); }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.chip:focus-visible { box-shadow: var(--sh-sm), var(--focus); }
.chiprow > .tipwrap { display: inline-flex; }

/* Popups that explain a control (hover, keyboard focus, tap). Shown below the control, never over it. */
.tipwrap { position: relative; }
.tip { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: max-content; max-width: min(290px, calc(100vw - 32px)); pointer-events: none;
  background: var(--c-ink); color: var(--c-white); font: 500 0.875rem/1.4 var(--f-body); text-transform: none; letter-spacing: 0; padding: 8px 11px; border-radius: var(--r-sm);
  box-shadow: 3px 3px 0 0 var(--c-raspberry); animation: tipin var(--dur-fast) var(--ease-out) 250ms both; }
.tip::before { content: ""; position: absolute; top: -6px; left: 14px; border: 6px solid transparent; border-top: 0; border-bottom-color: var(--c-ink); }
.tipwrap:hover > .tip, .tipwrap:has(:focus-visible) > .tip { display: block; }
.tipwrap:has(:focus-visible) > .tip { animation-delay: 0ms; }
@media (hover: none) { .tipwrap:focus-within > .tip { display: block; animation-delay: 0ms; } }
@keyframes tipin { from { opacity: 0; transform: translateY(-3px); } }
.chip--custom { border-style: dashed; background: var(--c-cream); box-shadow: none; cursor: default; display: inline-flex; align-items: center; }

/* Sliders */
.weight { margin-bottom: var(--sp-4); }
.weight__top { display: flex; justify-content: space-between; align-items: baseline; }
.weight__val { font-size: 1.5rem; line-height: 1; padding: 2px 6px; border-radius: 6px; transition: transform var(--dur-fast) var(--ease-out); }
.weight__val.off { font: 800 1.125rem/1 var(--f-label); color: var(--c-ink-soft); }
.weight:has(input:active) .weight__val { background: var(--c-sun); transform: rotate(-4deg); }
.weight .ign { color: var(--c-ink-soft); text-transform: none; font-weight: 600; }
input[type=range] { appearance: none; -webkit-appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; display: block; }
input[type=range]::-webkit-slider-runnable-track { height: 14px; border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--c-raspberry) 0 var(--fill, 0%), var(--c-white) var(--fill, 0%) 100%); }
input[type=range]::-moz-range-track { height: 10px; border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-pill); background: var(--c-white); }
input[type=range]::-moz-range-progress { height: 10px; background: var(--c-raspberry); border-radius: var(--r-pill); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 10px; background: var(--c-sun); border: var(--bw) solid var(--c-ink); box-shadow: var(--sh-sm); transition: transform var(--dur-fast) var(--ease-out); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 10px; background: var(--c-sun); border: var(--bw) solid var(--c-ink); box-shadow: var(--sh-sm); }
input[type=range]:focus-visible { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: var(--sh-sm), var(--focus); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: var(--sh-sm), var(--focus); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12) rotate(-6deg); box-shadow: var(--sh-pressed); }
.ticks { height: 6px; margin: -8px 14px 0; background: repeating-linear-gradient(to right, var(--c-ink-soft) 0 2px, transparent 2px 10%); background-size: calc(100% - 2px) 100%; border-right: 2px solid var(--c-ink-soft); }

/* Strict switch */
.strict { position: relative; background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); padding: var(--sp-3); box-shadow: var(--sh-sm); margin-top: var(--sp-4); }
.strict:has(input:checked) { background: var(--c-ok-pale); }
.strict:has(input:checked)::after { content: "STRICT"; position: absolute; top: -12px; right: 10px; font: 800 0.8125rem/1 var(--f-label); letter-spacing: 0.06em; background: var(--c-white); border: var(--bw-thin) solid var(--c-ink); border-radius: 6px; padding: 3px 7px; transform: rotate(-4deg); }
.strict .help { color: var(--c-ink); }
.switch { display: flex; align-items: center; gap: var(--sp-3); font-weight: 700; min-height: 44px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 60px; height: 34px; margin: 0; border-radius: var(--r-pill); border: var(--bw) solid var(--c-ink); background: var(--c-white); box-shadow: var(--sh-sm); position: relative; cursor: pointer; }
.switch input::before { content: ""; position: absolute; top: 3px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--c-ink); transition: transform var(--dur-fast) var(--ease-out); }
.switch input::after { content: "OFF"; position: absolute; right: 5px; top: 8px; font: 800 0.6875rem/1 var(--f-label); color: var(--c-ink); }
.switch input:checked { background: var(--c-cobalt); }
.switch input:checked::before { background: var(--c-white); transform: translateX(26px); }
.switch input:checked::after { content: "ON"; right: auto; left: 8px; color: var(--c-white); }
.switch input:focus-visible { box-shadow: var(--sh-sm), var(--focus); }

/* Filter groups */
details { border-top: var(--bw-thin) solid var(--c-ink); }
summary { font: 800 1.0625rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.03em; min-height: 48px; display: flex; align-items: center; gap: var(--sp-2); list-style: none; cursor: pointer; border-radius: 4px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "▾"; margin-left: auto; transition: transform var(--dur-med) var(--ease-out); }
details[open] > summary::after { transform: rotate(180deg); }
@media (hover: hover) { summary:hover { background: var(--c-cream); } }
.pill { font: 800 0.75rem/1 var(--f-label); background: var(--c-sun); border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-pill); padding: 3px 8px; }
fieldset { border: 0; margin: 0; padding: var(--sp-1) 0 var(--sp-4); min-width: 0; }
#dealbreakers fieldset { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--sp-3); padding-bottom: 0; }
#dealbreakers .tip { max-width: min(260px, calc(100vw - 32px)); }
legend { padding: 0; font-size: var(--fs-small); color: var(--c-ink-soft); margin-bottom: var(--sp-1); }
.check { display: flex; gap: var(--sp-3); align-items: center; min-height: 44px; font-weight: 500; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border: var(--bw) solid var(--c-ink); border-radius: 6px; background: var(--c-white); box-shadow: 2px 2px 0 0 var(--c-ink); cursor: pointer; }
.check input:checked { background: var(--c-raspberry) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M3.5 9.5l3.5 3.5 7.5-8' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }
.check input:disabled { border-style: dashed; box-shadow: none; }
.check:has(input:disabled) { color: var(--c-ink-soft); cursor: default; }
.swatch { width: 16px; height: 16px; border-radius: 4px; background: var(--pale); border: 2px solid var(--deep); flex: none; margin-right: -4px; }
.limit { display: grid; grid-template-columns: 1fr auto 96px 2.2em; align-items: center; gap: var(--sp-2); min-height: 52px; font-weight: 500; }
.limit input, #q, #sort { height: 48px; font: 500 1rem var(--f-body); border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-sm); background: var(--c-white); color: var(--c-ink); padding: 0 var(--sp-2); }
.limit input { height: 44px; width: 96px; }
.limit input:invalid { border: var(--bw) solid var(--c-warn-deep); }
#controls > .h-sec:first-child { margin-top: 0; }
#clear { width: 100%; margin: var(--sp-3) 0 var(--sp-4); box-shadow: var(--sh-sm); }
.share { position: sticky; bottom: 0; background: var(--c-white); border-top: var(--bw-thin) solid var(--c-ink); padding: var(--sp-3) 6px var(--sp-4) 0; margin-top: var(--sp-2); }
.more { display: none; }
.layout > #controls .share::before { content: ""; position: absolute; left: calc(-1 * var(--sp-5)); right: calc(-1 * var(--sp-5)); bottom: calc(100% + 2px); height: 80px; pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--c-white) 85%); }
.layout > #controls .more { display: inline-flex; align-items: center; gap: 4px; position: absolute; bottom: calc(100% - 15px); left: 50%; z-index: 2; transform: translateX(-50%) rotate(-2deg);
  min-height: 34px; padding: 0 14px; font: 800 0.9375rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-ink); background: var(--c-sun);
  border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-pill); box-shadow: var(--sh-sm); cursor: pointer; white-space: nowrap; }
.layout > #controls .more:active { transform: translateX(-50%) translate(2px, 2px); box-shadow: var(--sh-pressed); }
.layout > #controls.at-end .share::before, .layout > #controls.at-end .more { display: none; }
#share-url:not([hidden]) { position: static; width: 100%; height: 44px; clip-path: none; margin-top: var(--sp-2); }

/* Toolbar */
.toolbar { position: sticky; top: 0; z-index: 5; background: var(--c-cream); padding: var(--sp-3) 0; display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr) auto; }
/* Small phones: search and sort share one row so the sticky block stays short; the "Sort" word stays for screen readers. */
@media (max-width: 479px) {
  .toolbar { gap: var(--sp-2); }
  .sortwrap .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #sort { min-width: 0; width: 116px; }
}
#q { border-width: var(--bw); border-radius: var(--r-md); box-shadow: var(--sh-sm); padding-left: 40px; width: 100%;
  background: var(--c-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6.5' fill='none' stroke='%231a1033' stroke-width='3'/%3E%3Cpath d='M15 15l6 6' stroke='%231a1033' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") 12px center/20px no-repeat; }
#q:focus-visible, #sort:focus-visible { box-shadow: var(--sh-sm), var(--focus); }
.sortwrap { display: flex; align-items: center; gap: var(--sp-2); }
#sort { border-width: var(--bw); border-radius: var(--r-md); box-shadow: var(--sh-sm); font: 700 1rem var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; flex: 1; min-width: 160px; }
#count { font-weight: 700; margin-top: var(--sp-1); }
#count .hid { color: var(--c-raspberry); text-decoration: underline 2px dotted; text-underline-offset: 3px; }
#subnote { margin-bottom: var(--sp-3); min-height: 1px; }

/* Banner and empty */
.banner { background: var(--c-sun); border: var(--bw) solid var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-md); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.banner .h-sec { margin-top: 0; } .banner .btn { margin-top: var(--sp-3); }
.empty { background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: var(--sp-6); text-align: center; max-width: 560px; margin: var(--sp-5) auto; }
.empty h3 { font-size: 2rem; line-height: 1.05; margin: var(--sp-3) 0 var(--sp-2); overflow-wrap: anywhere; }
.empty .btns { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; margin-top: var(--sp-4); }

/* Cards */
#list { list-style: none; margin: 0; padding: 0 8px 8px 0; display: grid; gap: var(--sp-4); max-width: 828px; }
.card { background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-md); overflow: hidden; cursor: pointer;
  display: grid; grid-template-columns: 40px 72px minmax(0, 1fr) auto; min-height: 104px; transition: box-shadow var(--dur-fast) var(--ease-out); }
li.open .card, li.top .card { box-shadow: var(--sh-lg); }
@media (hover: hover) { .card:hover { box-shadow: var(--sh-lg); } }
.rank { font-size: 1.75rem; line-height: 1; letter-spacing: -0.03em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.delta { font: 800 0.8125rem/1 var(--f-label); height: 0.8125rem; }
.block { background: var(--pale); color: var(--deep); border-inline: var(--bw) solid var(--c-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; grid-column: 2; }
.block.whole { clip-path: polygon(14px 0, 100% 0, 100% 100%, 0 100%, 0 14px); }
.block__big { font: 900 1.0625rem/1 var(--f-display); font-stretch: 100%; letter-spacing: 0.01em; }
.block__line { font: 700 0.75rem/1.1 var(--f-label); text-align: center; padding: 0 4px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.main { padding: var(--sp-3) var(--sp-3); min-width: 0; }
.brand { font: 700 0.8125rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-ink-soft); }
.name { font: 800 1.125rem/1.15 var(--f-display); font-stretch: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 4px; }
li.open .name { -webkit-line-clamp: unset; }
.name__link { color: inherit; text-decoration: none; padding-block: 2px; border-radius: 4px; }
.name__link::after { content: " ↗"; font: 700 0.875em/1 var(--f-body); color: var(--c-cobalt); }
@media (hover: hover) { .name__link:hover { color: var(--c-cobalt); text-decoration: underline 3px; text-underline-offset: 3px; } }
.name__link:focus-visible { box-shadow: var(--focus); text-decoration: underline 3px; text-underline-offset: 3px; }
.keys { font-size: var(--fs-small); font-weight: 500; }
.nov { font-weight: 700; color: var(--c-raspberry); }
.tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-2); }
.tag { font: 800 0.75rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border: var(--bw-thin) solid currentColor; border-radius: var(--r-sm); white-space: nowrap; }
.tag--mid { color: var(--c-mid-deep); background: var(--c-mid-pale); }
.tag--warn { color: var(--c-warn-deep); background: var(--c-warn-pale); }
.tag--low { color: var(--c-ink-soft); background: transparent; border-style: dashed; } /* data quality, kept neutral so red means allergy only */
.tag--has { color: var(--c-ink); background: var(--c-white); }
.tag--cat { border: 0; padding: 0; color: var(--c-ink-soft); font-size: 0.8125rem; font-weight: 700; }
.card__toggle { margin-top: var(--sp-1); }
.card__toggle::after { content: " ▾"; display: inline-block; }
li.open .card__toggle::after { content: " ▴"; }
.score { padding: var(--sp-3) var(--sp-3) var(--sp-3) 0; position: relative; display: flex; align-items: flex-start; justify-content: center; }
.score-badge { width: 60px; height: 60px; border-radius: 50% 46% 50% 44%; background: var(--c-cobalt); color: var(--c-white); border: var(--bw) solid var(--c-ink); box-shadow: var(--sh-sm); transform: rotate(-6deg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-badge b { font-size: 1.375rem; line-height: 1; letter-spacing: -0.02em; }
.score-badge i { font: 700 0.6875rem/1 var(--f-label); font-style: normal; }
.score-badge.pop { animation: pop var(--dur-med) var(--ease-pop); }
@keyframes pop { 50% { transform: rotate(-6deg) scale(1.12); } }
li.top .score-badge { background: var(--c-sun); color: var(--c-ink); }
.toppick { display: none; position: absolute; top: 2px; right: 2px; font: 800 0.6875rem/1 var(--f-label); letter-spacing: 0.06em; background: var(--c-white); border: var(--bw-thin) solid var(--c-ink); border-radius: 6px; padding: 2px 5px; transform: rotate(8deg); z-index: 1; white-space: nowrap; }
li.top .toppick { display: block; }
li.top .score { padding-top: 20px; }
li.enter { animation: enter 180ms var(--ease-out); }
@keyframes enter { from { opacity: 0; transform: scale(0.96); } }

/* Store buttons: Amazon first and loud, the rest white; a search (no direct page) gets a dashed border and a magnifier */
.stores { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-3) var(--sp-3); cursor: auto; }
.store { font: 800 0.875rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-ink); background: var(--c-white); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 0 10px; border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-sm); box-shadow: var(--sh-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.store small { font: 700 0.6875rem/1 var(--f-label); color: var(--c-ink-soft); letter-spacing: 0.06em; }
.store--amazon { background: var(--c-sun); border-width: var(--bw); padding: 0 14px; font-size: 0.9375rem; }
.store--amazon:not(.store--search)::after { content: "↗"; font: 700 0.875rem/1 var(--f-body); }
.store--search { border-style: dashed; box-shadow: none; }
.store--amazon.store--search small { color: var(--c-ink); }
@media (hover: hover) { .store:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--c-ink); } }
.store:active { transform: translate(2px, 2px); box-shadow: var(--sh-pressed); }
.store:focus-visible { box-shadow: var(--sh-sm), var(--focus); }

/* Breakdown */
.breakdown { grid-column: 1 / -1; padding: var(--sp-4); border-top: var(--bw-thin) dashed var(--c-ink); cursor: auto; background: var(--c-white); position: relative; }
.breakdown h4 { font: 800 1rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.breakdown p { margin-top: var(--sp-3); max-width: 65ch; }
.bd-row { margin-top: var(--sp-3); }
.bd-top { display: flex; flex-wrap: wrap; gap: 2px var(--sp-3); align-items: baseline; }
.bd-name { font: 700 0.9375rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.04em; }
.bd-raw { font-weight: 700; font-size: 0.9375rem; margin-left: auto; text-align: right; }
.bd-w { font-size: var(--fs-small); color: var(--c-ink-soft); }
.bd-line { display: grid; grid-template-columns: minmax(0, 1fr) 7.5em; gap: var(--sp-3); align-items: center; margin-top: 4px; font-size: var(--fs-small); font-weight: 500; }
.bd-pts { text-align: right; }
.track { height: 16px; border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-sm); background: var(--c-white); overflow: hidden; }
.track > span { display: block; height: 100%; width: calc(var(--v) * 100%); border-right: 2px solid var(--c-ink); transition: width var(--dur-med) var(--ease-out);
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, 0.25) 6px 9px), var(--deep); }
.track.zero { opacity: 0.5; }
.bd-total { font-weight: 700; text-align: right; margin-top: var(--sp-2); }
.breakdown .btn { margin-top: var(--sp-4); width: 100%; }
/* Phone card: the protein-colour block becomes a thin band across the top so the name gets the width; full names, 44 px store buttons. */
@media (max-width: 899px) {
  .card { grid-template-columns: 40px minmax(0, 1fr) auto; min-height: 0; }
  .block { grid-column: 1 / -1; grid-row: 1; flex-direction: row; justify-content: flex-start; gap: 8px; padding: 5px var(--sp-3) 4px; border-inline: 0; border-bottom: var(--bw-thin) solid var(--c-ink); min-width: 0; }
  .block.whole { clip-path: none; border-bottom-style: dashed; }
  .block__big { font-size: 0.9375rem; flex: none; }
  .block__line { font-size: 0.875rem; text-align: left; padding: 0; -webkit-line-clamp: 1; }
  .rank { grid-row: 2; grid-column: 1; padding-left: 4px; }
  .main { grid-row: 2; grid-column: 2; padding-left: var(--sp-2); }
  .score { grid-row: 2; grid-column: 3; }
  .name { -webkit-line-clamp: unset; display: block; }
  .stores { grid-row: 3; }
  .breakdown { grid-row: 4; }
  .store { min-height: 44px; }
  .toppick, .score-badge i, .store small { font-size: 0.75rem; }
}
@media (min-width: 900px) {
  .card { grid-template-columns: 56px 112px minmax(0, 1fr) auto; min-height: 120px; }
  .rank { font-size: 2.25rem; }
  .block__big { font-size: 1.375rem; } .block__line { font-size: 0.875rem; padding: 0 8px; }
  .main { padding: var(--sp-3) var(--sp-4); }
  .name { font-size: 1.25rem; }
  .score-badge { width: 72px; height: 72px; } .score-badge b { font-size: 1.75rem; }
  .breakdown { grid-column: 3 / -1; padding: var(--sp-4) var(--sp-4) var(--sp-5); }
  .stores { grid-column: 3 / -1; padding: 0 var(--sp-4) var(--sp-3); }
  .breakdown .btn { width: auto; }
  .block { grid-row: 1 / span 3; }
}

/* Footer */
footer { background: var(--c-ink); color: var(--c-white); padding: var(--sp-7) var(--gutter) calc(var(--sp-7) + var(--phone-bar-h)); }
.footer__in { max-width: var(--page-max); margin: 0 auto; }
footer p { max-width: 65ch; margin-top: var(--sp-4); }
footer a { color: var(--c-sun); display: inline-block; padding-block: 3px; }
footer p code { font-size: 0.875rem; background: #2e2350; padding: 2px 6px; border-radius: 4px; }

/* Install cards: hero dialog and footer share the markup (app.js buildInstalls) */
.installs { display: grid; gap: var(--sp-4); margin-top: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.icard { min-width: 0; background: var(--c-white); color: var(--c-ink); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-sm); padding: var(--sp-3); display: flex; flex-direction: column; }
footer .icard { border-color: var(--c-white); box-shadow: 4px 4px 0 0 var(--c-sun); }
.icard__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.icard__name { font: 800 1.0625rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.03em; margin: 0; color: var(--c-ink); }
.icard__note { font-size: var(--fs-small); color: var(--c-ink-soft); margin: 4px 0 var(--sp-2); max-width: none; flex: 1; }
.icard__code { margin: 0; background: var(--c-ink); color: var(--c-white); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; white-space: pre; font: 500 0.8125rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; scrollbar-width: thin; scrollbar-color: var(--c-sun) transparent; }
.icard__code code { font: inherit; background: none; padding: 0; }
.icard__code:focus-visible { box-shadow: var(--focus); }
.copybtn { flex: none; min-height: 36px; min-width: 76px; padding: 0 12px; font: 800 0.9375rem/1 var(--f-label); text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer;
  color: var(--c-white); background: var(--c-cobalt); border: var(--bw-thin) solid var(--c-ink); border-radius: var(--r-sm); box-shadow: 2px 2px 0 0 var(--c-ink); }
@media (max-width: 899px) { .copybtn { min-height: 44px; } }
.copybtn.ok { background: var(--c-sun); color: var(--c-ink); }
.copybtn:active { transform: translate(2px, 2px); box-shadow: none; }
.copybtn:focus-visible { box-shadow: 2px 2px 0 0 var(--c-ink), var(--focus); }

/* "Give it to your AI" dialog */
.aidlg { width: min(720px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 32px); padding: 0; border: var(--bw) solid var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-lg); background: var(--c-cream); color: var(--c-ink); overflow: auto; }
.aidlg::backdrop { background: rgba(26, 16, 51, 0.55); }
.aidlg[open] { animation: dlgin var(--dur-med) var(--ease-pop); }
@keyframes dlgin { from { opacity: 0; transform: translateY(12px) rotate(-1deg); } }
.aidlg__in { padding: var(--sp-5); }
.aidlg__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.aidlg__head h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); line-height: 1; letter-spacing: -0.01em; background: var(--c-sun); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-sm); padding: 6px 12px; transform: rotate(-1.5deg); }
.aidlg__in > p { margin-top: var(--sp-4); max-width: 60ch; }
.aidlg .installs { grid-template-columns: 1fr; gap: var(--sp-3); }
.aidlg__x { flex: none; width: 44px; height: 44px; font: 800 1.75rem/1 var(--f-body); cursor: pointer; color: var(--c-ink); background: var(--c-white); border: var(--bw) solid var(--c-ink); border-radius: var(--r-md); box-shadow: var(--sh-sm); }
.aidlg__x:focus-visible { box-shadow: var(--sh-sm), var(--focus); }
@media (max-width: 600px) { .aidlg__in { padding: var(--sp-4); } }
footer h2 { font: 800 1.25rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.03em; margin-top: var(--sp-6); color: var(--c-sun); }
.footer__sticker { display: inline-block; background: var(--c-sun); color: var(--c-ink); border: var(--bw) solid var(--c-sun); box-shadow: 4px 4px 0 0 var(--c-raspberry); border-radius: var(--r-md); transform: rotate(-1deg);
  font: 800 1.25rem/1.1 var(--f-label); text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 14px; margin: 0; }
@media (min-width: 900px) { footer { padding-bottom: var(--sp-7); } }

/* Phone bar and sheet */
.phone-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; min-height: var(--phone-bar-h); padding: var(--sp-2) var(--gutter) calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: var(--c-ink); color: var(--c-white); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.phone-bar__preset { color: var(--c-sun); }
.phone-bar .btn { box-shadow: 3px 3px 0 0 var(--c-sun); border-color: var(--c-white); }
body.sheet-open .phone-bar { display: none; }
body.sheet-open .layout { padding-bottom: 64dvh; }
#tune-sheet { position: fixed; inset: auto 0 0 0; z-index: 20; margin: 0; width: 100%; max-width: 100%; height: 62dvh; border: var(--bw) solid var(--c-ink); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -5px 0 0 var(--c-ink); background: var(--c-white); color: var(--c-ink); padding: 0; }
#tune-sheet.big { height: 92dvh; }
#tune-sheet[open] { display: flex; flex-direction: column; animation: sheet var(--dur-slow) var(--ease-out); }
@keyframes sheet { from { transform: translateY(100%); } }
.sheet__head { flex: none; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); border-bottom: var(--bw-thin) solid var(--c-ink); }
.sheet__head h2 { margin-right: auto; }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-4) var(--sp-4) 0; flex: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Unranked group: bars with no verified price, below every ranked bar */
.group-head { margin: var(--sp-4) 0 var(--sp-3); padding-top: var(--sp-3); border-top: var(--bw) dashed var(--c-ink); }
.group-head h3 { margin: 0 0 var(--sp-1); font-size: 1.125rem; }
.group-head p { margin: 0; }
li.unranked .score-badge { background: var(--c-white); color: var(--c-ink); box-shadow: none; opacity: 0.7; }
li.unranked .rank__n { opacity: 0.5; }
.sticker .iq { text-transform: none; } /* BarIQ keeps its capitals so the IQ joke reads */
