/* Prix de la Pomme: the whole stylesheet.

   Design choices (see docs/frontend.md, "Design"):
   - Plain, typographic base (from the v16 mock-up): white cards with a thin
     border on a soft page, left-aligned, system font. No glass, no map: the
     numbers are the content.
   - Colour where it carries meaning (from the original keynote design): every
     tile of the bento has its own hue (--tint), a faint wash of it at the top
     and a gradient big number. Green = cheaper, orange = pricier, blue = you.
   - Every colour is a custom property, redefined for dark mode, so the page
     follows the system theme without duplicate rules.
   - Dense tables over minimal layouts: visitors come to compare numbers.
   - Desktop first; tablets (900px) and phones (680px) at the end. */
:root {
  --bg: #f3f5f9;
  --bg-2: #eceff5;
  --surface: #ffffff;
  --text: #16161a;
  --muted: #6b6d75;
  --line: #e3e6ec;
  --fill: #eff1f5;
  --fill-hover: #e5e8ee;
  --accent: #0071e3;
  --accent-soft: #e6f0fc;
  --good: #16803a;
  --good-soft: #e3f4e8;
  --bad: #c2410c;
  --bad-soft: #fcece3;
  /* Gap tile bars: what Apple charges (excl. tax), then the tax on top. */
  --apple: linear-gradient(90deg, #5e5ce6, #0a84ff);
  --tax: linear-gradient(90deg, #7fd4f5, #b5e8fb);
  /* Tile hues (one per tile, see .t-*) and how strong their wash is. */
  --green: #22a65a;
  --orange: #f2780c;
  --purple: #8a5cf0;
  --blue: #0a84ff;
  --pink: #e8457a;
  --teal: #1aa5b8;
  --wash: 9%;
  --card-shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 6px 20px rgba(20, 24, 40, 0.05);
  --pop-shadow: 0 16px 48px rgba(20, 24, 40, 0.16), 0 2px 6px rgba(20, 24, 40, 0.06);
  --ground: #2c7a2c; /* the logo's ground line, lighter in dark mode */
  /* System fonts only: San Francisco on Apple devices, no web font to download. */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d10;
    --bg-2: #0a0b0e;
    --surface: #17181c;
    --text: #f2f2f5;
    --muted: #9d9ea6;
    --line: #2a2b31;
    --fill: #222328;
    --fill-hover: #2c2d33;
    --accent: #3d9bff;
    --accent-soft: #15253d;
    --good: #46d07f;
    --good-soft: #133022;
    --bad: #ff8a4c;
    --bad-soft: #3a2216;
    --tax: linear-gradient(90deg, #2f6f8c, #3f86a6);
    --wash: 14%;
    --card-shadow: none;
    --pop-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    --ground: #4fb347;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg), var(--bg-2)) fixed;
  color: var(--text);
  font: 15px/1.45 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Native option lists are drawn by the system: force readable colours (some
   browsers inherit the light text of dark mode on a white list). */
select option { color: #1d1d1f; background: #fff; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* Segmented control: a grey track, the chosen segment raised in white. */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--fill); }
.segmented button { border: 0; background: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: background 0.2s, box-shadow 0.2s; }
.segmented [aria-checked='true'], .segmented [aria-selected='true'], .segmented [aria-pressed='true'] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }

/* ---------- Top bar ----------
   Sticky: logo on the left (inline SVG: the tree keeps its colours, the name
   follows the text colour), the visitor's country, currency and language on the right. */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1080px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; color: var(--text); text-decoration: none; }
/* Explicit width: Safari can size an inline svg wrongly from aspect-ratio alone. */
.logo-line { display: block; height: 22px; width: calc(22px * 377 / 46); overflow: visible; }
.logo-line .ground { stroke: var(--ground); }
.top-settings { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.field { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.field:focus-within { border-color: var(--accent); }
.field-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.field select { border: 0; background: transparent; font-weight: 600; font-size: 13px; padding: 0 2px; max-width: 170px; cursor: pointer; color: var(--text); }
.field select:focus { outline: none; }
.lang-seg button { padding: 4px 8px; font-size: 12px; }
/* On phones the language buttons move above the footer (see 680px). */
.lang-foot-wrap { display: none; padding-top: 24px; }

/* ---------- Product picker ----------
   Category tabs, a row of product chips (price at home), then the model,
   configuration and option menus on one wrapping line. */
.picker.wrap { padding-top: 28px; }
.cats { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { border: 0; background: none; padding: 0 0 10px; font-size: 15px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.cats button:hover { color: var(--text); }
.cats button[aria-selected='true'] { color: var(--text); font-weight: 600; border-color: var(--accent); }
.products { display: flex; gap: 8px; padding: 16px 0 4px; overflow-x: auto; scrollbar-width: none; }
.products::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 14px; text-align: left; }
.chip:hover { border-color: var(--muted); }
.chip b { font-size: 14px; font-weight: 600; }
.chip span { font-size: 12px; color: var(--muted); }
.chip[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.picks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 14px; }
/* Both containers are filled by app.js; their items join the .picks line. */
.config-picks, .picks .options { display: contents; }
.option-pick { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 3px 4px 3px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.option-pick select { border: 0; border-radius: 999px; background: var(--fill); padding: 4px 8px; font-size: 13px; font-weight: 600; color: var(--text); max-width: 340px; min-width: 0; }
.option-pick.changed { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Dock ----------
   One card row: "Countries" + every flag + the count (opens the country menu),
   then the incl./excl. tax switch. */
.dock-wrap { max-width: 1080px; margin: 18px auto 0; padding: 0 24px; display: flex; }
.dock { display: flex; align-items: center; max-width: 100%; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--card-shadow); }
.dock-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px 14px; border: 0; border-radius: 10px; background: none; text-align: left; transition: background 0.2s; }
.dock-item.static { cursor: default; padding: 3px 4px 3px 10px; }
.dock-item:not(.static):hover { background: var(--fill); }
.dock-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dock-value { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }
.flags { display: inline-flex; flex-wrap: wrap; gap: 2px; font-size: 17px; }
#countries-value .count { color: var(--muted); font-weight: 500; }
.dock-sep { width: 1px; height: 28px; background: var(--line); flex: none; }

/* ---------- Country menu ----------
   HTML popover attribute. Positioned under the dock by app.js (placePopover)
   on desktop; a bottom sheet on phones. */
.pop {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 680px;
  max-height: min(72vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--pop-shadow);
  color: var(--text);
}
.pop:popover-open { animation: pop-in 0.18s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .pop:popover-open { animation: none; } }
.pop-head { display: flex; gap: 10px; align-items: center; }
.search { flex: 1; min-width: 0; border: 0; border-radius: 12px; background: var(--fill); padding: 9px 14px; font-size: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.preset { border: 0; border-radius: 999px; background: var(--fill); padding: 4px 12px; font-size: 12.5px; }
.preset:hover { background: var(--fill-hover); }
.preset[aria-pressed='true'] { background: var(--accent); color: #fff; }
.pop-countries h3 { margin: 14px 4px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px; }
.country-opt { display: flex; align-items: center; gap: 8px; min-width: 0; border: 0; border-radius: 10px; background: none; padding: 6px 8px; font-size: 14px; text-align: left; }
.country-opt:hover { background: var(--fill); }
.check { width: 18px; height: 18px; flex: none; border-radius: 6px; border: 1.5px solid var(--muted); opacity: 0.6; }
.country-opt[aria-pressed='true'] .check {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.opt-meta { margin-left: auto; font-size: 11.5px; color: var(--muted); flex: none; }
.pop-foot { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; margin: 12px -16px 0; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.done { border: 0; border-radius: 999px; background: var(--accent); color: #fff; padding: 7px 18px; font-weight: 600; font-size: 14px; }

/* ---------- Stage ----------
   Heading of the comparison: product name, then model and configuration
   (subtitle), then the US/CA tax pickers. */
main.wrap { padding-top: 24px; }
.stage-head h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.title-config { display: block; margin-top: 6px; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.regions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.regions:empty { display: none; }
.region-pick { display: inline-flex; align-items: center; gap: 6px; }
.region-pick select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 4px 6px; font-size: 13px; color: var(--text); max-width: 220px; }

/* ---------- Bento ----------
   Six-column grid; each tile class is placed by name in grid-template-areas,
   so the layout is changed here without touching app.js:
     a = cheapest + most expensive   b = possible saving   c = your rank
     d = sold in N countries         r = ranking           f, g = total gap (amount, %)
     w = gap analysis (Apple's price vs taxes)
   Each tile sets --tint: a wash of it at the top, its label in that hue. */
.bento {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(130px, auto);
  grid-template-areas:
    'a a b b c d'
    'a a r r r r'
    'f g r r r r'
    'w w w w w w';
  gap: 16px;
  margin-top: 24px;
}
.tile {
  --tint: var(--muted);
  min-width: 0;
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--card-shadow);
}
.bento .tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  background: linear-gradient(170deg, color-mix(in srgb, var(--tint) var(--wash), var(--surface)), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--tint) 18%, var(--line));
}
.t-a { grid-area: a; --tint: var(--green); }
.t-b { grid-area: b; --tint: var(--green); }
.t-c { grid-area: c; --tint: var(--purple); }
.t-d { grid-area: d; --tint: var(--teal); }
.t-f { grid-area: f; --tint: var(--blue); }
.t-g { grid-area: g; --tint: var(--pink); }
.t-r { grid-area: r; --tint: var(--blue); }
.t-w { grid-area: w; --tint: var(--purple); }
/* Neutral wash on the two text-heavy tiles: their bars carry the colour. */
.bento .t-r, .bento .t-w { align-items: stretch; background: var(--surface); border-color: var(--line); }
.tile-label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: color-mix(in srgb, var(--tint) 70%, var(--text)); }
/* The big number: gradient text (background clipped to the glyphs), tabular
   digits so that amounts align, never wrapped. */
.tile-big {
  margin: 4px 0 2px;
  font-size: clamp(30px, 3.4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.t-a .tile-big { font-size: clamp(34px, 4vw, 52px); }
.t-f .tile-big, .t-g .tile-big { font-size: clamp(22px, 2.2vw, 30px); }
.t-c .tile-big { font-size: clamp(28px, 3vw, 40px); }
.g-green { background-image: linear-gradient(135deg, #22b35e, #0e9e8e); }
.g-orange { background-image: linear-gradient(135deg, #ff9500, #ff3b5c); }
.g-purple { background-image: linear-gradient(135deg, #b25af2, #5e5ce6); }
.g-pink { background-image: linear-gradient(135deg, #ff375f, #bf5af2); }
.g-blue { background-image: linear-gradient(135deg, #0a84ff, #45c3f5); }
.g-teal { background-image: linear-gradient(135deg, #1fb5c9, #0a84ff); }
.tile-sub { margin: 0; font-size: 13px; color: var(--muted); max-width: 32ch; }
.tile-country { margin: 2px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
/* Cheapest above, most expensive below: the lower half washes orange. */
.bento .extremes { gap: 14px; background: linear-gradient(180deg, color-mix(in srgb, var(--green) var(--wash), var(--surface)), var(--surface) 45%, var(--surface) 55%, color-mix(in srgb, var(--orange) var(--wash), var(--surface))); }
.extreme { display: flex; flex-direction: column; align-items: flex-start; }
.extreme.high .tile-label { color: color-mix(in srgb, var(--orange) 70%, var(--text)); }
.extreme-sep { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--line); }
.extremes .gap { font-weight: 600; }
.gap.cheaper { color: var(--good); }
.gap.pricier { color: var(--bad); }
.gap.ref { color: var(--accent); }

/* Ranking: bars diverge from the reference (centre line, blue). */
.t-r .tile-label { margin-bottom: 2px; }
.rank-legend { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-list li { display: grid; grid-template-columns: 22px 24px minmax(80px, 140px) 1fr 84px auto; align-items: center; gap: 10px; padding: 4px 0; font-size: 15px; }
.rank-list li.gap { display: block; text-align: center; color: var(--muted); padding: 0; line-height: 1; }
.rank-pos { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .home .rank-name { color: var(--accent); font-weight: 600; }
.rank-bar { position: relative; height: 8px; border-radius: 999px; background: var(--fill); }
.rank-bar::before { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--accent); }
.rank-bar span { position: absolute; top: 0; bottom: 0; }
.rank-bar .up { left: 50%; border-radius: 0 999px 999px 0; background: linear-gradient(90deg, #ff9500, #ff3b5c); }
.rank-bar .down { right: 50%; border-radius: 999px 0 0 999px; background: linear-gradient(270deg, #22b35e, #0e9e8e); }
.rank-extra { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-list .pricier .rank-extra { color: var(--bad); }
.rank-list .cheaper .rank-extra { color: var(--good); }
.rank-list .ref .rank-extra { color: var(--accent); font-weight: 500; }
.rank-price { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 72px; }

/* Gap analysis: two split bars, the decomposition, one sentence. */
.bento .t-w { gap: 14px; }
.gap-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.gap-bars { display: flex; flex-direction: column; gap: 10px; }
.gap-row { display: grid; grid-template-columns: 140px 1fr 84px; align-items: center; gap: 12px; font-size: 14px; }
.gap-who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gap-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.gap-bar { position: relative; height: 12px; border-radius: 999px; background: var(--fill); }
.gap-bar span { position: absolute; top: 0; bottom: 0; }
.gap-bar .apple { left: 0; border-radius: 999px 0 0 999px; background: var(--apple); }
.gap-bar .tax { border-radius: 0 999px 999px 0; background: var(--tax); }
.gap-bar .unknown { left: 0; border-radius: 999px; background: repeating-linear-gradient(135deg, var(--fill-hover) 0 4px, transparent 4px 8px); }
.gap-legend { margin: 2px 0 0; display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.gap-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.gap-legend .l-apple { background: var(--apple); }
.gap-legend .l-tax { background: var(--tax); }
.gap-split { margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.gap-split div { display: flex; justify-content: space-between; gap: 12px; }
.gap-split dt { color: var(--muted); }
.gap-split dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.gap-split .total { border-top: 1px solid var(--line); padding-top: 6px; }
.gap-split .total dt { color: var(--text); font-weight: 600; }
.gap-text { margin: 0; font-size: 14px; line-height: 1.5; }

/* ---------- Details table ----------
   Scrolls horizontally inside its card rather than overflowing the page.
   Green = cheaper than the reference, orange = pricier, blue = the reference. */
.detail { margin-top: 16px; padding: 22px 24px 18px; }
.detail h2 { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.table-wrap { overflow-x: auto; margin: 0 -10px; padding: 0 10px; }
.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.grid th, .grid td { padding: 10px; text-align: left; vertical-align: middle; white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid thead th { font-size: 12px; font-weight: 500; color: var(--muted); }
.grid .num { text-align: right; }
.grid tbody tr:hover { background: var(--fill); }
.grid tbody tr:last-child > * { border-bottom: 0; }
.sortable button { border: 0; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.sortable button:hover, .sortable[aria-sort='ascending'] button, .sortable[aria-sort='descending'] button { color: var(--text); }
.sort-mark { font-size: 11px; opacity: 0.5; }
.rank { width: 28px; color: var(--muted); font-size: 12px; }
th.country { font-weight: 500; }
.cell-inner { display: inline-flex; align-items: center; gap: 8px; }
.flag { font-size: 18px; line-height: 1; }
.tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; }
.local { color: var(--muted); }
.badge { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 600; padding: 1px 5px; border-radius: 5px; background: var(--fill); color: var(--muted); vertical-align: 1px; }
.badge.ht { background: var(--bad-soft); color: var(--bad); }
.badge.no-adapter { color: var(--text); font-weight: 500; }
.grid small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.info { border-bottom: 1px dotted var(--muted); cursor: help; }
.grid td.main { font-weight: 700; font-size: 15px; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill.cheaper { color: var(--good); background: var(--good-soft); }
.pill.pricier { color: var(--bad); background: var(--bad-soft); }
.pill.neutral { color: var(--muted); background: var(--fill); font-weight: 500; }
.barcell { width: 16%; min-width: 80px; }
.bar { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5e5ce6, #0a84ff); }
tr.best .bar span { background: linear-gradient(90deg, #22b35e, #0e9e8e); }
tr.best td.main { color: var(--good); }
tr.home { background: var(--accent-soft); }
tr.home > :first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.unavailable { opacity: 0.5; }

.empty { padding: 24px 0; text-align: center; color: var(--muted); }
.notes { margin: 16px 0 0; padding: 14px 0 0 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; display: grid; gap: 4px; }
.foot { padding-top: 24px; padding-bottom: 40px; color: var(--muted); font-size: 12px; }
.foot p { margin: 0 0 6px; }

/* ---------- Guides ----------
   Cards under the details (and under a guide, for the other guides): tiles with
   their own hue, like the bento's. Guide pages (public/guides/, generated by
   scripts/build-guides.mjs) share the top bar and footer; the article is one
   card at a reading width. */
.guides-section { margin-top: 32px; }
.guides-section h2 { margin: 0 0 12px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.guide-card {
  --tint: var(--teal);
  display: flex; flex-direction: column; gap: 6px;
  color: var(--text); text-decoration: none;
  background: linear-gradient(170deg, color-mix(in srgb, var(--tint) var(--wash), var(--surface)), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--tint) 18%, var(--line));
  transition: transform 0.2s, box-shadow 0.2s;
}
.guide-card:nth-child(2n) { --tint: var(--orange); }
.guide-card:hover { transform: translateY(-2px); box-shadow: var(--pop-shadow); }
.guide-title { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.guide-text { font-size: 14px; color: var(--muted); }
.guide-go { margin-top: auto; padding-top: 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.foot a { color: inherit; }
/* Production pages: the model's (or site's) summary, then links to every model
   page (scripts/build-site.mjs). */
.model-summary { margin-top: 16px; padding: 22px 24px; }
.model-summary h2 { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.model-summary p { margin: 0 0 6px; max-width: 46rem; line-height: 1.55; }
.all-products { margin-top: 40px; font-size: 13px; color: var(--muted); }
.all-products h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.all-products p { margin: 0 0 6px; line-height: 1.6; }
.all-products strong { margin-right: 6px; color: var(--text); font-weight: 600; }
.all-products a { color: inherit; text-decoration: none; }
.all-products a:hover { color: var(--accent); text-decoration: underline; }

/* Guide page: language links instead of buttons, kept in the top bar on phones.
   The card is as wide as the comparator's content; its text keeps a reading
   width (about 75 characters a line), aligned left. */
.guide-page .top .lang-seg { display: inline-flex; }
.lang-seg a { border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none; }
.lang-seg a[aria-current] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.guide-wrap { padding-top: 24px; }
.guide-back { margin: 0 0 14px; font-size: 14px; }
.guide-back a { color: var(--accent); text-decoration: none; }
.article {
  --tint: var(--teal);
  padding: 36px 44px; font-size: 16px; line-height: 1.6;
  background: linear-gradient(175deg, color-mix(in srgb, var(--tint) var(--wash), var(--surface)), var(--surface) 320px);
}
.article > * { max-width: 46rem; }
.article h1 { margin: 0 0 16px; font-size: clamp(28px, 4vw, 38px); line-height: 1.12; letter-spacing: -0.025em; }
.article h1 + p { font-size: 18px; color: var(--muted); }
.article h2 { margin: 36px 0 10px; font-size: 22px; line-height: 1.25; letter-spacing: -0.015em; scroll-margin-top: 70px; }
.article p, .article ul, .article ol { margin: 0 0 14px; }
.article ul, .article ol { padding-left: 22px; }
.article li { margin-bottom: 8px; }
.article a { color: var(--accent); overflow-wrap: anywhere; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0 20px; }
.article ol:last-child { font-size: 14px; color: var(--muted); } /* sources */
.article-table { overflow-x: auto; margin: 18px 0 20px; }
.article table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.article th, .article td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.article td { white-space: nowrap; }
.article th:first-child { text-align: left; font-weight: 500; }
.article thead th { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.article tbody tr:has(strong) { background: var(--accent-soft); } /* the result rows */
.guide-page .guides { margin-top: 24px; }

/* ---------- Responsive ----------
   900px: tablets, the bento goes to two columns (total gap and gap analysis
   right under the cheapest/most expensive tile), field labels are dropped.
   680px: phones. Language above the footer, a bottom-sheet country menu, three
   flags in the dock, and the table keeps the essentials: country, compared
   price, gap with the reference. */
@media (max-width: 900px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: 'a a' 'f g' 'w w' 'b b' 'c d' 'r r'; }
  .gap-body { grid-template-columns: 1fr 1fr; }
  .gap-bars { grid-column: 1 / -1; }
  .top .field-label { display: none; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 12px; }
  .top-in { padding: 8px 12px; gap: 8px; }
  .logo-line { height: 18px; width: calc(18px * 377 / 46); }
  .field { padding: 4px 8px; }
  .field select { font-size: 12px; max-width: 120px; }
  .top-settings label:has(#currency) select { max-width: 58px; }
  .top .lang-seg { display: none; }
  .lang-foot-wrap { display: flex; }
  .picker.wrap { padding-top: 18px; }
  .cats { gap: 18px; }
  .picks .option-pick { flex: 1 1 100%; }
  .option-pick select { max-width: none; flex: 1; }
  .dock-wrap { padding: 0 12px; margin-top: 14px; }
  .dock { width: 100%; }
  #countries-btn { flex: 1; min-width: 0; padding: 8px 10px; }
  /* Narrow row: the first three flags, the count says the rest. */
  #countries-value, .flags { flex-wrap: nowrap; }
  .flags span:nth-child(n + 4) { display: none; }
  #mode button { padding: 6px 10px; }
  main.wrap { padding-top: 18px; }
  .stage-head h1 { font-size: 28px; }
  .bento { gap: 10px; margin-top: 18px; grid-auto-rows: minmax(120px, auto); }
  .tile { padding: 16px; }
  .rank-list li { grid-template-columns: 18px 22px minmax(0, 1fr) auto auto; gap: 8px; font-size: 14px; }
  .rank-bar { display: none; }
  .gap-body { grid-template-columns: 1fr; gap: 14px; }
  .gap-row { grid-template-columns: 96px 1fr 64px; gap: 8px; font-size: 13px; }
  .detail { padding: 16px 12px 14px; }
  .pop { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; max-height: 82vh; border-radius: 20px 20px 0 0; }
  .country-grid { grid-template-columns: 1fr 1fr; }
  .opt-meta { display: none; }
  .barcell, .grid .rank, .grid .local, .grid .tax, .grid .alt { display: none; }
  .grid th, .grid td { padding: 9px 6px; }
  .vs-name { display: none; } /* "vs 🇸🇬": the flag is enough, the home row says "you" */
  .grid tr.unavailable td[colspan] { text-align: right; }
  .foot { padding-bottom: 32px; }
  .guide-wrap { padding-top: 16px; }
  .article { padding: 22px 18px; font-size: 15.5px; }
  .article h1 { font-size: 26px; }
  .article h1 + p { font-size: 16.5px; }
  .article h2 { font-size: 19px; margin-top: 28px; }
}
