:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #17171b;
  --muted: #5b5a55;
  --faint: #66655f;
  --border: #e2dfd6;
  --border-strong: #c9c6be;
  --line: #e8e5dd;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --accent-soft: #fbe7da;
  --accent-soft-text: #9a3412;
  --bar: #ebaa85;
  --bar-track: #ece9e2;
  --sale: #1e6b3e;
  --sale-bg: #ddf0e2;
  --heart: #b42318;
  --tag-bg: #efece5;
  --tag-text: #3a3935;
  --row-hover: #faf9f6;
  --dot-ring: rgba(23, 23, 27, 0.18);
  --shadow: 0 12px 32px rgba(23, 23, 27, 0.14);
  --logo-accent: #d9480f;
  --radius: 8px;
  /* Bottom sheets: fast out, long settle. */
  --sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

/* Light is the default. The footer's theme picker sets data-theme on <html>,
   resolving "System" to light or dark in the inline script in web.rs. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121214;
  --surface: #1c1c20;
  --surface-2: #222227;
  --text: #eceae4;
  --muted: #a3a19a;
  --faint: #98968f;
  --border: #2e2e33;
  --border-strong: #3e3e45;
  --line: #28282d;
  --accent: #ff8a4c;
  --accent-text: #1a0d05;
  --accent-soft: #3a2216;
  --accent-soft-text: #ffc4a3;
  --bar: #8a4a28;
  --bar-track: #2a2a2f;
  --sale: #8fe0ae;
  --sale-bg: #17301f;
  --heart: #ff8a80;
  --tag-bg: #26262b;
  --tag-text: #cfcdc6;
  --row-hover: #222227;
  --dot-ring: rgba(255, 255, 255, 0.35);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --logo-accent: #ff8a4c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

header.site, main { max-width: 1180px; margin: 0 auto; padding: 0 32px; }
header.site { padding-top: 24px; padding-bottom: 8px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none;
  font-family: var(--mono); font-weight: 600; font-size: 22px; letter-spacing: -0.03em;
}
/* The "o" of the wordmark is a lens, as in the icon. */
.lens { width: 0.6em; height: 0.6em; margin: 0 0.01em; vertical-align: -0.02em; overflow: visible; }
.lens circle { fill: none; stroke: currentColor; stroke-width: 2; }
.lens path { stroke: var(--logo-accent); stroke-width: 2.2; stroke-linecap: round; }
main { padding-bottom: 64px; display: flex; flex-direction: column; gap: 20px; }

h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 20px; margin: 0; }

.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }

.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; padding-top: 12px; }
.intro > div { display: flex; flex-direction: column; gap: 6px; }
.lede { margin: 0; color: var(--muted); max-width: 640px; }
.facts { margin: 0; font-size: 15px; color: var(--muted); }

/* ---- filters ---- */

input, select, button { font: inherit; color: var(--text); }

/* Protein types and search up front, the rest behind "Filters". */
.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: grid; grid-template-columns: 300px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
}
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field .input {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted);
}
.field .input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.field input[type="search"] { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; font-size: 15px; color: var(--text); }

/* A <details> that opens like a menu: the type picker and the filters panel. */
.picker { position: relative; }
.picker summary { list-style: none; cursor: pointer; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.type-picker summary {
  display: flex; align-items: center; gap: 6px; min-height: 46px; padding: 4px 10px 4px 12px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted);
}
.type-picker[open] summary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.type-picker[open] summary > .icon { transform: rotate(180deg); }
.type-summary { display: flex; flex-direction: column; justify-content: center; flex: 1; min-width: 0; line-height: 1.2; }
.summary-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.summary-sub { font-size: 12px; font-weight: 400; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-summary .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: -4px; }

.picker-panel {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.picker-option { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.picker-option:hover { background: var(--row-hover); }
.picker-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.picker-option.sub { padding-left: 30px; }
.picker-option.empty { opacity: 0.55; }
.option-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.vegan-mark { display: inline-flex; color: var(--sale); }
.shop-name { flex: 1; min-width: 0; font-weight: 600; }
.shop-count { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* "Vegan only" shrinks away once a protein type is ticked. */
.vegan-wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease, opacity .2s ease; }
.type-field:has(input[name="types"]:checked) .vegan-wrap { grid-template-rows: 0fr; opacity: 0; visibility: hidden; }
.vegan-clip { display: flex; min-height: 0; overflow: hidden; }
.vegan-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 2px; border: 0; background: none; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.vegan-toggle:hover { color: var(--text); }
.vegan-toggle .icon { color: var(--sale); }

.more-filters summary {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px;
  border: 1px solid var(--text); border-radius: 6px; background: var(--surface); color: var(--text); font-weight: 600;
}
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); font-family: var(--mono); font-size: 13px;
}
.count-badge[hidden] { display: none; }
.filter-panel {
  position: absolute; z-index: 10; top: calc(100% + 6px); right: 0; width: 360px; max-height: min(75vh, 680px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px 16px 0; display: flex; flex-direction: column; gap: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 17px; }
.panel-section { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.panel-section legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.panel-section .picker-option { padding-left: 4px; padding-right: 4px; }
.panel-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -16px; padding: 12px 16px 16px; background: var(--surface); border-top: 1px solid var(--line);
}

.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch .track { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The chips row opens and shuts by animating its height; the row stays and
   only its inside is swapped. */
.active-filters {
  grid-column: 1 / -1; display: grid; grid-template-rows: 0fr; margin-top: -4px;
  transition: grid-template-rows .2s ease, margin-top .2s ease;
}
.active-filters:has(.active-inner.on) { grid-template-rows: 1fr; margin-top: 0; }
.active-inner {
  min-height: 0; overflow: hidden; visibility: hidden; opacity: 0; transition: opacity .2s ease, visibility 0s .2s;
}
.active-inner.on { visibility: visible; opacity: 1; transition: opacity .2s ease; }
.chip-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-text);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.chip .x { width: 20px; text-align: center; font-size: 16px; line-height: 1; }
.filters-col { display: flex; flex-direction: column; align-items: flex-end; }
.clear-cell { display: flex; min-height: 0; }
/* As tall as "Vegan only" (18px lines, 6px padding), so the row it shares with
   it keeps its height whichever of the two shows. */
.clear-cell .clear { padding: 6px 2px; font-size: 13px; line-height: 18px; animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: 0; } }
.filters noscript { grid-column: 1 / -1; }

.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 999px; flex: none;
  background: var(--dot); box-shadow: inset 0 0 0 1px var(--dot-ring);
}

.weights { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.weights input {
  width: 96px; height: 44px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: var(--surface); font-size: 15px;
}
.clear { color: var(--muted); font-size: 14px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none;
}

.result-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Sorting on phones: a button and a bottom sheet in place of the headers. */
.sort-sheet { display: none; }
.sort-sheet summary {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text);
}
.sheet-panel {
  position: absolute; z-index: 10; background: var(--surface); box-shadow: var(--shadow);
  padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 16px; overflow: auto;
}
.sort-options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sort-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px;
  padding: 0 4px; border-bottom: 1px solid var(--line); color: var(--text); font-weight: 500; text-decoration: none;
}
.sort-option[aria-current] { color: var(--accent); font-weight: 700; }
.sort-option .reverse { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.panel-section .legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.sheet-panel .segmented { align-self: flex-start; }

/* All powders or only the favorites. */
.fav-switch { display: inline-flex; gap: 2px; margin: 0; padding: 3px; border: 0; border-radius: 6px; background: var(--tag-bg); }
.fav-switch label { position: relative; display: inline-flex; }
.fav-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.fav-switch span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 4px;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.fav-switch input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 23, 27, 0.12); }
.fav-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.fav-switch .icon { color: var(--heart); }
.fav-switch .fav-count { font-family: var(--mono); font-weight: 500; padding: 0; min-height: 0; }

@media (prefers-reduced-motion: reduce) {
  .vegan-wrap, .switch .track, .switch .track::after, .active-filters, .active-inner { transition: none; }
  .clear-cell .clear { animation: none; }
}

/* ---- results ---- */

.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.result-bar p { margin: 0; }
.count span { color: var(--muted); }
.footnote { color: var(--muted); font-size: 13px; margin: 0; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { border-collapse: collapse; width: 100%; }
.products th {
  padding: 8px 12px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); text-align: left; white-space: nowrap; background: var(--surface-2);
}
.products td { padding: 14px 12px; border-top: 1px dashed var(--border-strong); vertical-align: middle; }
.products tbody tr:hover { background: var(--row-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.products th.num { text-align: right; }
.sort {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 6px; margin: 0 -6px;
  border-radius: 6px; color: var(--muted); text-decoration: none;
}
.sort:hover { background: var(--bar-track); }
.sort.active { color: var(--text); }
th.num .sort { flex-direction: row-reverse; }
.cost-head { display: inline-flex; align-items: center; gap: 8px; }
.cost-head select {
  height: 30px; padding: 0 4px 0 8px; border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0;
}

.products .rank { width: 36px; font-family: var(--mono); font-size: 13px; color: var(--faint); }
.cost { width: 190px; }
.cost-value { display: block; font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.bar { display: block; width: 130px; height: 4px; margin-top: 6px; border-radius: 4px; background: var(--bar-track); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--bar); }
.bar span.best { background: var(--accent); }

/* The podium: the three cheapest by kr per protein, each a step quieter than
   the one above. A wash of the accent, a stripe down the left edge, a medal
   for the rank and a bigger, orange price. */
.products tr[data-podium] { --podium: 0%; --stripe: 0px; background: color-mix(in srgb, var(--accent) var(--podium), var(--surface)); }
.products tr[data-podium="1"] { --podium: 10%; --stripe: 4px; }
.products tr[data-podium="2"] { --podium: 6%; --stripe: 3px; }
.products tr[data-podium="3"] { --podium: 3%; --stripe: 2px; }
.products tbody tr[data-podium]:hover { background: color-mix(in srgb, var(--accent) calc(var(--podium) + 3%), var(--surface)); }
.products tr[data-podium] td:first-child { box-shadow: inset var(--stripe) 0 0 var(--accent); }
.medal {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-weight: 700; border: 2px solid var(--accent); color: var(--accent); background: var(--surface);
}
tr[data-podium="1"] .medal {
  width: 30px; height: 30px; font-size: 15px; background: var(--accent); color: var(--accent-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
tr[data-podium="2"] .medal { background: var(--accent-soft); color: var(--accent-soft-text); }
tr[data-podium="3"] .medal { border-width: 1.5px; }
tr[data-podium] .cost-value { color: var(--accent); }
tr[data-podium="1"] .cost-value { font-size: 24px; }
tr[data-podium="2"] .cost-value { font-size: 21px; }
tr[data-podium="3"] .cost-value { color: var(--accent-soft-text); }
.podium-label {
  display: inline-block; margin-bottom: 4px; padding: 1px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-text);
}

.product .brand-name, .title-block .brand-name {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--faint);
}
.product .name { font-weight: 600; color: var(--text); text-decoration: none; }
.product .name:hover { text-decoration: underline; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; font-size: 14px; color: var(--muted); }
/* A row's other flavors: rows of their own, shown while "+N flavors" is open. */
/* Sized like a tag; the global 44px summary height moves to an invisible hit area. */
.flavors summary {
  display: block; position: relative; min-height: 0; list-style: none; cursor: pointer;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--accent-soft-text); background: var(--accent-soft); padding: 1px 7px; border-radius: 5px;
}
.flavors summary::before { content: ""; position: absolute; inset: -11px -4px; }
.flavors summary::-webkit-details-marker { display: none; }
.flavors summary:hover { text-decoration: underline; }
.products tr.flavor-row { display: none; background: var(--surface-2); }
.products tbody:has(details.flavors[open]) tr.flavor-row { display: table-row; }
.products tr.flavor-row td { padding-top: 6px; padding-bottom: 6px; border-top-color: var(--line); font-size: 14px; }
.flavor-row .cost-value { font-size: 15px; }
.flavor-row .icon-button { width: 36px; height: 36px; }
.flavor-name { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.flavor-name a { color: var(--text); }
.tag {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 5px;
  background: var(--tag-bg); color: var(--tag-text); white-space: nowrap;
}
.tag.muted { color: var(--muted); font-weight: 500; }
.shop-cell { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 14px; }
.m-weight { display: none; }
.products .weight, .products .protein { font-size: 14px; }
/* The column that matters: the others are fixed or do not wrap, so without
   this it is the one that gives up the room on a narrower window. */
@media (min-width: 861px) { .products td.product { min-width: 220px; } }
.price .now { display: block; font-weight: 600; }
.was-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 2px; }
s.was { color: var(--faint); }
.badge.sale {
  display: inline-block; font-weight: 700; font-size: 13px; color: var(--sale); background: var(--sale-bg);
  padding: 0 6px; border-radius: 5px; white-space: nowrap;
}
.actions { width: 96px; }
.action-buttons { display: flex; justify-content: flex-end; gap: 2px; }
.icon-button {
  width: 44px; height: 44px; border: 0; border-radius: 6px; background: transparent; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--row-hover); }
.fav-form { margin: 0; display: inline-flex; }
.heart .icon { color: var(--muted); }
.heart.on .icon { color: var(--heart); fill: currentColor; }
.out-of-stock td:not(.actions) { opacity: 0.6; }
tr.empty td { padding: 48px 24px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.page-numbers { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.pager a, .pager .page {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager .page.current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager .page-step { white-space: nowrap; }

/* ---- product page ---- */

.crumbs a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; color: var(--muted); text-decoration: none; }
.product-page { display: flex; flex-direction: column; gap: 24px; }
.product-top { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 32px; align-items: start; }
.photo {
  aspect-ratio: 1 / 1; background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: #5a6478; font-size: 14px;
}
.photo img { width: 100%; height: 100%; object-fit: contain; }
.product-main { display: flex; flex-direction: column; gap: 20px; }
.title-block { display: flex; flex-direction: column; gap: 6px; }
.title-block h1 { font-size: 36px; line-height: 1.1; }
.price-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
}
.price-card p { margin: 0; }
.price-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.cost-block { display: flex; flex-direction: column; gap: 2px; }
.big-cost { font-family: var(--mono); font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; color: var(--accent); }
.price-now { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.price-now > div { display: flex; align-items: baseline; gap: 10px; }
.price-now .price { font-size: 26px; font-weight: 700; }
.choice { display: flex; flex-direction: column; gap: 8px; }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.size {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); color: var(--text); text-decoration: none;
}
.size span { font-size: 13px; color: var(--muted); }
.size[aria-current] { border: 2px solid var(--accent); padding: 9px 13px; }
.flavors { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-link {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
}
.pill-link[aria-current] { background: var(--text); color: var(--bg); border-color: var(--text); }
.other-size { font-weight: 400; color: var(--muted); }
.pill-link[aria-current] .other-size { color: inherit; }
.buy-row { display: flex; gap: 10px; align-items: center; }
.buy { flex: 1; min-height: 48px; }
.buy-row .heart { width: 48px; height: 48px; border: 1px solid var(--border-strong); border-radius: 8px; }
.stock { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.card p { margin: 0; }
.card.source { margin-top: 16px; }
.source-products { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.history { gap: 18px; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--tag-bg); border-radius: 6px; }
.seg {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 4px;
  color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none;
}
.seg[aria-current] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 23, 27, 0.12); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); }
.stat .label { font-weight: 500; }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--faint); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.key-line span { width: 14px; height: 3px; border-radius: 2px; background: var(--accent); }
.key-sale span { width: 12px; height: 12px; border-radius: 3px; background: var(--sale-bg); }

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart.narrow { display: none; }
.chart .grid { stroke: var(--bar-track); stroke-width: 1; }
.chart .sale { fill: var(--sale-bg); opacity: 0.7; }
.chart .area { fill: var(--accent); opacity: 0.07; }
.chart .price { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .dot.sale { stroke: var(--sale); }
.chart .now { fill: var(--accent); }
.chart .axis { fill: var(--faint); font-size: 12px; font-family: inherit; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.calc {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; padding: 14px 16px;
  background: var(--surface-2); border-radius: 8px; font-variant-numeric: tabular-nums;
}
.calc dt { color: var(--muted); }
.calc dd { margin: 0; text-align: right; font-weight: 600; }
.calc .total { padding-top: 8px; border-top: 1px solid var(--border); }
.calc dd.total { color: var(--accent); font-weight: 700; }
.nutrition th, .nutrition td { padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.nutrition th { text-align: left; font-weight: 500; color: var(--tag-text); }
.nutrition tr:first-child td { font-weight: 700; }
.ingredients { color: var(--muted); font-size: 14px; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

.report { margin-top: 16px; padding-top: 12px; padding-bottom: 12px; }
.report form { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; max-width: 560px; }
.report select, .report textarea, .feedback select, .feedback textarea, .feedback input[type="email"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); font: inherit; color: var(--text);
}
.report select, .feedback select, .feedback input[type="email"] { min-height: 46px; }
.report textarea, .feedback textarea { resize: vertical; }
.report .trap, .feedback .trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.feedback { max-width: 600px; }
.feedback h2, .feedback p { margin: 0; }

footer.site {
  width: min(1116px, 100% - 64px); margin: 0 auto; padding: 20px 0 40px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: 14px; color: var(--muted);
}
footer.site p { margin: 0; }
footer.site a { color: var(--text); }
.theme[hidden] { display: none; }
.theme { display: inline-flex; align-items: center; gap: 8px; }
.theme select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 4px 8px;
}

/* ---- narrow screens ---- */

/* Too narrow for every column: weight and protein % go, and the weight moves
   under the shop. */
@media (max-width: 1080px) {
  .products .weight, .products .protein { display: none; }
}
@media (min-width: 641px) and (max-width: 1080px) {
  .products td.shop .m-weight { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
}

@media (max-width: 860px) {
  .product-top { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .photo { max-width: 280px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .products .shop { display: none; }
}

@media (max-width: 640px) {
  header.site, main { padding: 0 16px; }
  footer.site { width: calc(100% - 32px); padding-bottom: 32px; }
  header.site { padding-top: 16px; }
  h1 { font-size: 22px; }
  .intro { padding-top: 4px; }
  .intro > div { gap: 2px; }
  .facts { font-size: 14px; }
  .title-block h1 { font-size: 28px; }
  .big-cost { font-size: 36px; }
  .filters { padding: 14px; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 8px; }
  /* Types and the Filters button first, search under them. */
  .type-field { grid-row: 1; grid-column: 1; }
  .filters-col { grid-row: 1; grid-column: 2; }
  .filters .search { grid-row: 2; grid-column: 1 / -1; }
  .active-filters { margin-top: -10px; }
  /* The filters panel and the sorting are bottom sheets over a dimmed page.
     They slide up on an ease-out curve and back down on close: the content
     stays rendered while it leaves (`::details-content`, where supported;
     elsewhere the close is instant). */
  .more-filters > summary::before, .sort-sheet > summary::before {
    content: ""; position: fixed; inset: 0; z-index: 30; background: rgba(23, 23, 27, 0.45); cursor: default;
    opacity: 0; pointer-events: none; transition: opacity .35s var(--sheet-ease);
  }
  .more-filters[open] > summary::before, .sort-sheet[open] > summary::before { opacity: 1; pointer-events: auto; }
  .more-filters::details-content, .sort-sheet::details-content {
    transition: content-visibility .35s allow-discrete;
  }
  .filter-panel, .sheet-panel {
    position: fixed; z-index: 31; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 85vh;
    border: 0; border-radius: 16px 16px 0 0;
    transform: translateY(100%); transition: transform .35s var(--sheet-ease);
  }
  .more-filters[open] .filter-panel, .sort-sheet[open] .sheet-panel { transform: none; }
  /* The page stays put under an open sheet, and a scroll inside the sheet
     stops at its ends instead of carrying on into the page. */
  html:has(.more-filters[open]), html:has(.sort-sheet[open]) { overflow: hidden; }
  .filter-panel, .sheet-panel { overscroll-behavior: contain; }
  @starting-style {
    .more-filters[open] .filter-panel, .sort-sheet[open] .sheet-panel { transform: translateY(100%); }
    .more-filters[open] > summary::before, .sort-sheet[open] > summary::before { opacity: 0; }
  }
  .sheet-panel { padding-bottom: 24px; }
  .sort-sheet { display: block; }
  .panel-foot .button { flex: 1; }

  /* The table becomes one card per product. */
  .table-wrap { background: none; border: 0; overflow: visible; }
  /* Sorting moves to the "Sort" sheet. */
  .products thead { display: none; }
  .chart.wide { display: none; }
  .chart.narrow { display: block; }
  .products { display: flex; flex-direction: column; gap: 12px; }
  .products tbody { display: flex; flex-direction: column; }
  .products tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px 0; align-items: start;
    grid-template-areas: "product product product" "shop price actions";
    position: relative; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  }
  .products tbody tr:hover { background: var(--surface); }
  .products td { display: block; padding: 0; border: 0; }
  .products td.rank { display: none; }
  /* On a card the medal hangs over its top edge, and the wash covers it all. */
  .products tbody tr[data-podium] { border-color: color-mix(in srgb, var(--accent) calc(var(--podium) * 4), var(--border)); }
  .products tbody tr[data-podium="1"] { border-width: 2px; }
  .products tbody tr[data-podium]:hover { background: color-mix(in srgb, var(--accent) var(--podium), var(--surface)); }
  .products tr[data-podium] td:first-child { box-shadow: none; }
  .products tr[data-podium] td.rank { display: block; position: absolute; top: -11px; left: 12px; }
  .products tr[data-podium] .medal { width: 24px; height: 24px; font-size: 12px; }
  .products tr[data-podium="1"] .medal { width: 26px; height: 26px; font-size: 13px; }
  .products tr[data-podium] td.product { padding-top: 4px; }
  .products:has(tr[data-podium]) { padding-top: 6px; }
  .products tbody tr[data-podium="1"] .cost-value { font-size: 24px; }
  /* The heart closes the bottom row; the shop link is one tap away on the
     product page. The divider runs under all three cells unbroken. */
  .products td.actions {
    grid-area: actions; width: auto; display: flex; align-items: center; justify-content: flex-end; align-self: stretch;
    padding: 12px 0 0 4px; border-top: 1px solid var(--line);
  }
  .products td.actions .action-buttons > a { display: none; }
  .products td.actions .fav-form { display: flex; }
  .products td.actions .heart { width: 40px; height: 40px; margin: -10px -10px -10px 0; }
  .products td.product { grid-area: product; }
  /* The product spans the card, so its badges get the full width; the price
     per protein sits in the top corner, and the brand and name leave it room. */
  .products td.cost { grid-area: cost; width: auto; padding-left: 16px; text-align: right; }
  .products tr:not(.flavor-row) td.cost { position: absolute; top: 16px; right: 16px; }
  .products tr:not(.flavor-row) :is(.brand-name, .name) { display: block; margin-right: 112px; }
  .products td.cost .bar { display: none; }
  .cost-value { font-size: 20px; }
  .products td.shop {
    display: flex; grid-area: shop; align-items: center; gap: 8px; padding-top: 12px;
    border-top: 1px solid var(--line); color: var(--tag-text);
  }
  .m-weight { display: inline; color: var(--muted); }
  .m-weight::before { content: "· "; }
  .products td.price {
    grid-area: price; display: flex; flex-direction: row-reverse; align-items: center; justify-content: flex-start;
    gap: 8px; padding: 12px 0 0 16px; border-top: 1px solid var(--line);
  }
  .price .now { display: inline; }
  .was-line { margin: 0; }
  .was-line s { display: none; }
  .products td.weight, .products td.protein { display: none; }
  tr.empty { display: block !important; }
  /* Open flavors hang under their card as compact lines. */
  .products tbody:has(details.flavors[open]) tr.flavor-row { display: grid; }
  .products tbody:has(details.flavors[open]) tr:not(.flavor-row) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .products tbody tr.flavor-row {
    grid-template-areas: "product cost actions"; align-items: center; padding: 8px 16px;
    background: var(--surface-2); border-top: 0; border-radius: 0;
  }
  .products tbody tr.flavor-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
  .products tr.flavor-row td.shop, .products tr.flavor-row td.price { display: none; }
  .products tr.flavor-row td.actions { align-self: center; padding: 0 0 0 4px; border-top: 0; }
  .flavor-row .cost-value { font-size: 15px; }
  .pager .page-numbers { order: -1; width: 100%; }
  .pager .page-step { flex: 1; }
  .stats { gap: 8px; }
  .buy-row .heart { flex: none; }
}

/* After the phone rules, so it wins over the sheets' slide. */
@media (prefers-reduced-motion: reduce) {
  .filter-panel, .sheet-panel, .more-filters > summary::before, .sort-sheet > summary::before,
  .more-filters::details-content, .sort-sheet::details-content { transition: none; }
}
