/* Spesa Radar. Visual language: the Italian supermarket shelf tag (cartellino prezzo).
   Prices are the loudest thing on every screen, set in condensed Archivo; everything
   else stays quiet. Yellow marks the cheapest option, red marks a stated discount. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #eef0ec;
  --tag: #ffffff;
  --ink: #1a1e3a;
  --ink-2: #4a5068;
  --ink-3: #737a8f;
  --rule: #d3d8d0;
  --rule-strong: #1a1e3a;
  --yellow: #ffd23f;
  --on-yellow: #1a1e3a;
  --red: #d9232a;
  --on-red: #ffffff;
  --chain-coop: #d4202a;
  --chain-eurospin: #1557a8;
  --chain-conad: #e8890c;
  --chain-despar: #13854a;
  --chain-eurospar: #0e8a8a;
  --chain-interspar: #8a3fa8;
  --gutter: 16px;
  --nav-h: 60px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --narrow: 68%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #15172b;
    --tag: #1f2238;
    --ink: #eef0ec;
    --ink-2: #b9bdcc;
    --ink-3: #8c91a6;
    --rule: #30344f;
    --rule-strong: #b9bdcc;
    --red: #ff565b;
    --on-red: #1a0a0b;
    --chain-coop: #ff5a5f;
    --chain-eurospin: #6aa4ff;
    --chain-conad: #ffaa3b;
    --chain-despar: #4cc785;
    --chain-eurospar: #43c6c6;
    --chain-interspar: #c48ae0;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15172b;
  --tag: #1f2238;
  --ink: #eef0ec;
  --ink-2: #b9bdcc;
  --ink-3: #8c91a6;
  --rule: #30344f;
  --rule-strong: #b9bdcc;
  --red: #ff565b;
  --on-red: #1a0a0b;
  --chain-coop: #ff5a5f;
  --chain-eurospin: #6aa4ff;
  --chain-conad: #ffaa3b;
  --chain-despar: #4cc785;
  --chain-eurospar: #43c6c6;
  --chain-interspar: #c48ae0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
img { max-width: 100%; display: block; }
a { color: inherit; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--tag); padding: 8px 12px; }

h1, h2, h3 { margin: 0; font-stretch: var(--narrow); line-height: 1.05; letter-spacing: -0.01em; }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 24px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 600; font-stretch: 100%; line-height: 1.3; letter-spacing: 0; }
.muted, .sub { color: var(--ink-2); }
.sub { font-size: 14px; margin-top: 4px; }
.small { font-size: 13px; }
.link { color: var(--ink); font-weight: 650; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

/* ---------------------------------------------------------------- shelf-tag price */

.amount { position: relative; display: inline-flex; align-items: flex-start; font-stretch: var(--narrow); font-weight: 800; line-height: 0.9; letter-spacing: -0.01em; white-space: nowrap; }
.amount > span[aria-hidden] { display: inline-flex; align-items: flex-start; }
.amount .cur { font-size: 0.48em; font-weight: 700; margin: 0.12em 0.08em 0 0; }
.amount .whole { font-size: 1em; }
.amount .cents { font-size: 0.55em; margin-top: 0.06em; }
.amount .per { font-size: 0.5em; font-weight: 650; font-stretch: 85%; align-self: flex-end; margin: 0 0 0.08em 0.1em; color: var(--ink-2); }

.price { font-size: 26px; display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0 8px; }
.price.deal .amount { color: var(--red); }
.was { font-size: 13px; color: var(--ink-3); font-weight: 500; margin-bottom: 2px; }
.until { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.badge {
  position: absolute;
  top: 0;
  left: 0;
  padding: 4px 8px 5px;
  background: var(--red);
  color: var(--on-red);
  font-weight: 800;
  font-stretch: var(--narrow);
  font-size: 17px;
  line-height: 1;
  border-radius: 0 0 4px 0;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 14px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 10px;
  background: var(--paper);
  border-bottom: 2px solid var(--rule-strong);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; color: var(--ink); }
.wordmark { font-size: 21px; font-weight: 800; font-stretch: var(--narrow); letter-spacing: -0.01em; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  background: var(--tag);
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  min-width: 0;
}
.search:focus-within { border-color: var(--ink); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; }
.search input { border: 0; background: none; outline: none; width: 100%; min-width: 0; font-size: 16px; }
.search input::placeholder { color: var(--ink-3); }

.nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--tag);
  border-top: 2px solid var(--rule-strong);
}
.nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-3);
}
.nav a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  top: -2px;
  left: 22%;
  right: 22%;
  height: 4px;
  background: var(--yellow);
}
.nav .count {
  position: absolute;
  top: 5px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--yellow);
  color: var(--on-yellow);
  font: 800 11px/18px var(--font);
  font-style: normal;
  text-align: center;
}

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .topbar { grid-template-columns: auto minmax(260px, 480px) 1fr; padding-inline: max(var(--gutter), calc((100vw - 1160px) / 2)); }
  .nav { position: static; display: flex; justify-content: flex-end; gap: 2px; height: auto; padding: 0; background: none; border: 0; }
  .nav a { flex-direction: row; gap: 7px; font-size: 14px; padding: 8px 12px; }
  .nav a svg { width: 19px; height: 19px; }
  .nav a[aria-current="page"]::after { top: auto; bottom: -12px; left: 12px; right: 12px; }
  .nav .count { position: static; }
}

/* ---------------------------------------------------------------- layout */

main { max-width: 1160px; margin: 0 auto; padding: 22px var(--gutter) 48px; outline: none; }
.section { margin-block: 36px; }
.section:first-child { margin-top: 4px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card { background: var(--tag); border: 1.5px solid var(--rule); border-radius: 6px; }

/* ---------------------------------------------------------------- hero: the same basket, two receipts */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  margin-block: 4px 40px;
}
.hero h1 {
  font-size: clamp(40px, 11vw, 76px);
  font-stretch: 70%;
  font-weight: 850;
  line-height: 0.92;
  letter-spacing: -0.015em;
  max-width: 11ch;
  text-wrap: balance;
}
.hero-sub { margin-top: 16px; font-size: 17px; line-height: 1.45; color: var(--ink-2); max-width: 44ch; }

.hero-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 6px 6px 6px 14px;
  background: var(--tag);
  border: 2px solid var(--ink);
  border-radius: 8px;
  max-width: 520px;
}
.hero-search:focus-within { box-shadow: 0 0 0 4px var(--yellow); }
.hero-search svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; }
.hero-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 17px; padding: 8px 0; }
.hero-search button {
  flex: none;
  border: 0;
  border-radius: 5px;
  padding: 11px 16px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 750;
  font-size: 15px;
}
.hero-try { margin-top: 10px; font-size: 14px; color: var(--ink-3); }
.hero-try a { color: var(--ink); font-weight: 650; text-underline-offset: 3px; }
.hero-fresh { margin-top: 26px; font-size: 13.5px; color: var(--ink-2); max-width: 46ch; }
.hero-stores { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--ink); font-weight: 650; }
.hero-stores span { display: inline-flex; align-items: center; gap: 6px; }
.hero-note { margin: -24px 0 32px; font-size: 13px; color: var(--ink-3); }

/* The aisle: a shelf of this week's staples above one cart per compared store. */
.aisle { display: grid; gap: 14px; min-width: 0; }
.aisle-hint { font-size: 14px; color: var(--ink-2); }

.shelf-row {
  list-style: none;
  margin: 0;
  padding: 0 2px 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 6px;
  /* the shelf board under each row of products */
  background: linear-gradient(to top, var(--ink) 0 6px, transparent 6px) bottom / 100% 86px repeat-y;
}
.shelf-item {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 4px;
  width: 100%;
  height: 86px;
  padding: 0 0 10px;
  border: 0;
  background: none;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.1;
  color: var(--ink);
  text-align: center;
}
.shelf-item img { width: 46px; height: 46px; object-fit: contain; transition: transform .15s ease, opacity .15s ease; }
.shelf-item span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf-item[aria-pressed="false"] img { opacity: .25; filter: grayscale(1); transform: translateY(4px); }
.shelf-item[aria-pressed="false"] span { color: var(--ink-3); text-decoration: line-through; }
.shelf-item:hover img { transform: translateY(-3px); }

.carts { display: grid; grid-template-columns: repeat(var(--carts, 3), minmax(0, 1fr)); gap: 10px 6px; margin-top: 18px; }
.cart { position: relative; margin: 0; padding-top: 36px; }
.cart-body { position: relative; aspect-ratio: 200 / 170; }
.cart-frame { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.cart-mesh { stroke-width: 1.5; opacity: .35; }
.cart-basket { fill: color-mix(in srgb, var(--tag) 70%, transparent); }
/* products lie inside the basket, clipped to its trapezoid */
.cart-pile {
  position: absolute;
  left: 21%; top: 12%; width: 76%; height: 58%;
  display: flex; flex-wrap: wrap-reverse; align-content: flex-start; justify-content: center;
  padding: 0 6% 2px;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
}
.cart-pile img {
  width: 30%; aspect-ratio: 1; margin: -6% -3%;
  object-fit: contain;
  transform: rotate(var(--tilt));
  filter: drop-shadow(0 2px 2px rgb(26 30 58 / .25));
}
.cart-store { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-weight: 750; font-size: 15px; }
/* Product shots come on white: on light paper, multiply makes the white disappear. */
.shelf-item img, .cart-pile img { mix-blend-mode: multiply; }
:root[data-theme="dark"] .shelf-item img, :root[data-theme="dark"] .cart-pile img { mix-blend-mode: normal; border-radius: 4px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shelf-item img, :root:not([data-theme="light"]) .cart-pile img { mix-blend-mode: normal; border-radius: 4px; }
}
@media (max-width: 899px) {
  .cart { padding-top: 26px; }
  .cart-tag { font-size: 20px; padding: 4px 7px 5px 15px; }
  .cart-tag .tag-hole { left: 4px; width: 6px; height: 6px; margin-top: -3px; }
  .cart-store { font-size: 13px; }
}

/* The price tag hangs from the cart handle. Yellow = the cheapest cart for the current picks. */
.cart-tag {
  position: absolute; left: 0; top: 0; z-index: 2;
  padding: 6px 10px 7px 20px;
  background: var(--tag);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  font-size: 30px;
  transform: rotate(-3deg);
  transform-origin: 10px 50%;
  transition: background-color .2s ease;
}
.cart.cheapest .cart-tag { background: var(--yellow); color: var(--on-yellow); border-color: var(--on-yellow); }
.tag-hole { position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 1px 2px rgb(0 0 0 / .3); }
.cart-tag .tag-hole { left: 6px; }
.aisle-verdict { min-height: 1.5em; font-weight: 650; font-size: 16px; }

/* One orchestrated moment on load: the products drop into the carts. Later drops answer a tap. */
@media (prefers-reduced-motion: no-preference) {
  .cart-pile img { animation: drop .45s cubic-bezier(.3, 1.3, .5, 1) calc(.25s + var(--i) * 60ms) both; }
  .cart-pile img.dropped { animation: drop .35s cubic-bezier(.3, 1.3, .5, 1) both; }
}
@keyframes drop { from { opacity: 0; transform: translateY(-140%) rotate(calc(var(--tilt) * -2)); } }

@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; gap: 48px; margin-bottom: 56px; min-height: calc(100vh - 160px); }
  .shelf-item img { width: 56px; height: 56px; }
  .shelf-row { background-size: 100% 98px; }
  .shelf-item { height: 98px; font-size: 12px; }
  .cart-tag { font-size: 36px; }
}

/* ---------------------------------------------------------------- staples: a shelf-edge price strip */

.staples { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule-strong); }
.staples li { border-bottom: 1.5px solid var(--rule); }
.staple {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 14px;
  width: 100%;
  padding: 12px 2px;
  border: 0;
  background: none;
  text-align: left;
}
.staple:hover .staple-name { text-decoration: underline; text-underline-offset: 3px; }
.staple-name { font-weight: 650; font-size: 16px; }
.staple-best { grid-row: span 2; display: grid; justify-items: end; gap: 3px; font-size: 30px; }
.staple-where { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.staple-others { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--ink-3); }
.staple-others span { display: inline-flex; align-items: center; gap: 5px; }
@media (min-width: 860px) {
  .staples { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; }
}

/* ---------------------------------------------------------------- chips */

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--tag);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .dot { width: 9px; height: 9px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--ink-3); flex: none; }
.dot.coop { background: var(--chain-coop); }
.dot.eurospin { background: var(--chain-eurospin); }
.dot.conad { background: var(--chain-conad); }
.dot.despar { background: var(--chain-despar); }
.dot.eurospar { background: var(--chain-eurospar); }
.dot.interspar { background: var(--chain-interspar); }

/* ---------------------------------------------------------------- product cards */

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 158px; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin-inline: calc(-1 * var(--gutter)); padding: 0 var(--gutter) 6px; scroll-snap-type: x mandatory; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 960px) { .rail { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: visible; margin: 0; padding: 0; } }

.product {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--tag);
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.product:hover { border-color: var(--ink); }
.product .thumb {
  position: relative;
  aspect-ratio: 1;
  background: #fff;
  display: grid;
  place-items: center;
  border-bottom: 1.5px solid var(--rule);
}
.product .thumb img { width: 82%; height: 82%; object-fit: contain; }
.thumb .ph { width: 38%; height: 38%; color: #c2c7c0; }
.product .store { display: flex; align-items: center; gap: 6px; padding: 10px 10px 0; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.product .name {
  margin: 4px 10px 0;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.product .meta { display: flex; flex-wrap: wrap; gap: 0 10px; padding: 4px 10px 0; font-size: 12px; color: var(--ink-3); min-height: 1.5em; }
.product-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 10px; }
.product-foot .price { font-size: 25px; }

.add {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  background: var(--tag);
  color: var(--ink);
}
.add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.add.in { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }

/* ---------------------------------------------------------------- browse toolbar */

.toolbar { display: grid; gap: 8px; margin-bottom: 16px; }
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-row .spacer { flex: 1; }
.select {
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--tag) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737a8f' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
  appearance: none;
  font-size: 14px;
  font-weight: 600;
}
.result-count { font-size: 13px; color: var(--ink-2); }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); max-width: 44ch; margin: 0 auto; }
.empty svg { width: 56px; height: 56px; color: var(--ink-3); margin: 0 auto 12px; }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty p + p { margin-top: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background: var(--tag);
  font-weight: 700;
  text-decoration: none;
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.more { display: flex; justify-content: center; margin-top: 20px; }

.skeleton { background: var(--rule); border-radius: 6px; opacity: 0.6; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------------------------------------------------------------- aisles */

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); column-gap: 22px; border-top: 2px solid var(--rule-strong); }
.cat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 12px 2px;
  border-bottom: 1.5px solid var(--rule);
  text-decoration: none;
  font-weight: 650;
  font-size: 15px;
}
.cat:hover { text-decoration: underline; text-underline-offset: 3px; }
.cat small { color: var(--ink-3); font-weight: 500; font-size: 12.5px; }

/* ---------------------------------------------------------------- product sheet */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-top: 6px solid var(--rule-strong);
  border-radius: 10px 10px 0 0;
  background: var(--tag);
  color: var(--ink);
}
.sheet::backdrop { background: rgb(21 23 43 / 0.5); }
.sheet[open] { animation: up 0.18s ease-out; }
@keyframes up { from { transform: translateY(20px); } }
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 10px; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-body { padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 18px; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; font-weight: 650; }
.sheet-top .small { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 4px; border: 1.5px solid var(--rule); background: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; }
.detail-head { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: start; }
.detail-head .thumb { position: relative; aspect-ratio: 1; background: #fff; border-radius: 6px; display: grid; place-items: center; border: 1.5px solid var(--rule); overflow: hidden; }
.detail-head .thumb img { width: 86%; height: 86%; object-fit: contain; }
.detail-head h2 { font-size: 22px; margin: 2px 0 4px; }
.detail-head .price { font-size: 44px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); border-top: 1.5px solid var(--rule); border-bottom: 1.5px solid var(--rule); }
.fact { padding: 10px 2px; }
.fact + .fact { border-left: 1.5px solid var(--rule); padding-left: 12px; }
.fact b { display: block; font-size: 20px; font-weight: 800; font-stretch: var(--narrow); }
.fact span { font-size: 12.5px; color: var(--ink-2); }
.spark { width: 100%; height: 64px; margin-top: 8px; }
.spark-range { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--ink-3); }
.alt { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; width: 100%; padding: 10px 0; border: 0; border-top: 1.5px solid var(--rule); background: none; text-align: left; cursor: pointer; }
.alt:hover .alt-name { text-decoration: underline; text-underline-offset: 3px; }
.alt img, .alt .ph-box { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 4px; }
.alt-name { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.alt-meta { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.alt-meta span { display: inline-flex; align-items: center; gap: 5px; }
.alt-price { text-align: right; font-weight: 800; font-stretch: var(--narrow); font-size: 18px; }
.alt-price small { display: block; font-weight: 500; font-stretch: 100%; color: var(--ink-3); font-size: 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
#sheet-add:not(.primary) { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
.source-note { font-size: 12.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- shopping list */

.list-summary { display: grid; gap: 6px; padding: 16px 18px; background: var(--yellow); color: var(--on-yellow); border-color: var(--yellow); }
.summary-label { font-weight: 650; }
.list-summary .big { font-size: 56px; }
.list-summary .amount .per { color: inherit; }
.summary-meta { display: flex; gap: 14px; font-size: 14px; }
.list-saving { font-size: 14px; font-weight: 650; }
.store-group { margin-top: 20px; overflow: hidden; }
.store-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 2px solid var(--rule-strong); font-weight: 700; font-size: 17px; }
.store-head .left { display: flex; align-items: center; gap: 8px; }
.store-count { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.line { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1.5px solid var(--rule); }
.store-head + .line { border-top: 0; }
.line .check { width: 26px; height: 26px; border-radius: 4px; border: 2px solid var(--ink-3); background: var(--tag); display: grid; place-items: center; padding: 0; }
.line .check svg { width: 16px; height: 16px; fill: none; stroke: var(--paper); stroke-width: 3; stroke-linecap: round; opacity: 0; }
.line.done .check { background: var(--ink); border-color: var(--ink); }
.line.done .check svg { opacity: 1; }
.line.done .line-name { text-decoration: line-through; color: var(--ink-3); }
.line-name { font-size: 14.5px; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
.line-sub { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.line-sub.warn { color: var(--red); }
.line-deal { color: var(--red); font-weight: 700; }
.line-right { display: grid; justify-items: end; gap: 6px; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--rule); border-radius: 4px; }
.stepper button { width: 30px; height: 28px; border: 0; background: none; font-size: 17px; font-weight: 700; color: var(--ink-2); }
.stepper span { min-width: 18px; text-align: center; font-weight: 700; font-size: 14px; }
.line-total { font-weight: 800; font-stretch: var(--narrow); font-size: 19px; }

/* ---------------------------------------------------------------- about, footer, toast */

.prose { max-width: 66ch; }
.prose p, .prose li { color: var(--ink-2); margin-top: 8px; }
.prose h2 { margin: 30px 0 4px; }
.prose ul { padding-left: 18px; }
.sources { display: grid; gap: 8px; margin-top: 14px; }
.source { display: grid; gap: 3px; padding: 14px 16px; }
.source .head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.source-meta { display: flex; flex-wrap: wrap; gap: 0 14px; font-size: 13px; color: var(--ink-3); }
.foot { margin-top: 48px; padding-top: 16px; border-top: 2px solid var(--rule-strong); font-size: 13px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot span { display: inline-flex; align-items: center; gap: 6px; }
.foot a { color: var(--ink-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 650;
  font-size: 14px;
  max-width: calc(100vw - 32px);
}
@media (min-width: 860px) { .toast { bottom: 24px; } }
