:root {
  --bg: #ffffff;
  --surface: #f6f6f4;
  --line: #e7e7e3;
  --text: #141414;
  --muted: #6b6b66;
  --faint: #9a9a94;
  --accent: #d92d20;
  --good: #1a7f4b;
  --chip: #f0f0ec;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --surface: #1a1a1a; --line: #2a2a2a; --text: #f2f2ef;
    --muted: #a3a39d; --faint: #73736e; --accent: #ff6b5e; --good: #4cc38a; --chip: #232323;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --surface: #1a1a1a; --line: #2a2a2a; --text: #f2f2ef;
  --muted: #a3a39d; --faint: #73736e; --accent: #ff6b5e; --good: #4cc38a; --chip: #232323;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
button, input, select { font: inherit; color: inherit; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding-top: 14px; padding-bottom: 12px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; font-weight: 700; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.stores { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.stores::-webkit-scrollbar { display: none; }
.store {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid transparent; background: none; padding: 7px 12px; border-radius: 999px; cursor: pointer; color: var(--muted);
}
.store:hover { color: var(--text); }
.store[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.store .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.store .n { font-size: 12px; opacity: .6; font-variant-numeric: tabular-nums; }
.store:disabled { opacity: .45; cursor: default; }

/* Store info */
.store-info { margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 13px; color: var(--muted); }
.store-info b { color: var(--text); font-weight: 600; }
.store-info a { color: var(--text); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0 12px; }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 10px; padding: 0 12px; }
.search svg { width: 17px; height: 17px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; background: none; outline: none; width: 100%; padding: 10px 0; }
select { background: var(--surface); border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; }
.tog { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.tog input { accent-color: var(--text); margin: 0; }

.cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.cats::-webkit-scrollbar { display: none; }
.cat { white-space: nowrap; border: 1px solid var(--line); background: none; padding: 6px 11px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--muted); }
.cat:hover { color: var(--text); }
.cat[aria-pressed="true"] { border-color: var(--text); color: var(--text); font-weight: 600; }
.cat .n { opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums; }

.count { color: var(--faint); font-size: 13px; margin: 14px 0 10px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; text-align: left; background: none; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--faint); }
.card:active { transform: scale(.99); }
.card .img { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: #fff; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.card .img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-weight: 700; font-size: 12px; padding: 3px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.card .body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.meta .dot { width: 7px; height: 7px; border-radius: 50%; }
.title { font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.desc { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-row { margin-top: auto; padding-top: 6px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.price { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.was { color: var(--faint); text-decoration: line-through; font-size: 13px; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { background: var(--chip); color: var(--muted); font-size: 11px; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.chip.member { color: var(--text); }
.chip.limit { color: var(--accent); }

.en { color: var(--muted); font-size: 12px; font-style: italic; margin-top: -2px; }
.real { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.real::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.r-real { color: var(--good); }
.r-ok { color: #2f7d9c; }
.r-likely { color: #b7791f; }
.r-weak, .r-none { color: var(--faint); }
.r-member { color: #7c5cc4; }
.verdict { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface); color: var(--text); }
.verdict b { color: inherit; }
.verdict.r-real b { color: var(--good); } .verdict.r-ok b { color: #2f7d9c; } .verdict.r-likely b { color: #b7791f; } .verdict.r-member b { color: #7c5cc4; }
.muted { color: var(--muted); }
.starts { font-size: 11.5px; color: var(--muted); }
.raw summary { cursor: pointer; font-size: 13px; color: var(--muted); }

.picks { margin-top: 26px; }
.picks-head h2, .all-head { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.picks-head p { margin: 4px 0 14px; color: var(--muted); font-size: 13px; max-width: 60ch; }
.all-head { margin-top: 36px; }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }

.soon { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); }

/* Footer */
.foot { margin-top: 56px; padding-top: 20px; padding-bottom: 40px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }
.foot p { margin: 4px 0; }

/* Dialog */
dialog { border: 0; padding: 0; border-radius: 18px; width: min(760px, calc(100% - 24px)); max-height: calc(100% - 24px); background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.close { position: absolute; top: 10px; right: 12px; z-index: 1; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface); font-size: 22px; line-height: 1; cursor: pointer; }
.dlg { display: grid; grid-template-columns: 1fr 1fr; }
.dlg .pic { background: #fff; display: grid; place-items: center; padding: 16px; min-height: 260px; }
.dlg .pic img { max-width: 100%; max-height: 420px; object-fit: contain; }
.dlg .info { padding: 24px 22px 22px; display: flex; flex-direction: column; gap: 10px; }
.dlg h2 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -0.01em; padding-right: 30px; }
.dlg .price { font-size: 28px; }
.facts { margin: 4px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.parts { margin: 2px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.parts li { margin: 2px 0; }
.btn { align-self: flex-start; margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; background: var(--text); color: var(--bg); text-decoration: none; padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.good { color: var(--good); font-weight: 600; }

@media (max-width: 640px) {
  .top .wrap { padding-top: 10px; padding-bottom: 8px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .body { padding: 9px 10px 10px; }
  .price { font-size: 18px; }
  .dlg { grid-template-columns: 1fr; }
  .dlg .pic { min-height: 200px; }
  .dlg .pic img { max-height: 260px; }
  .toolbar select { flex: 1; }
}

/* Week selector + archive */
.sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week { background: var(--surface); border: 0; border-radius: 6px; padding: 2px 6px; font-size: 12px; color: var(--text); }
.archive { margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, #b7791f 16%, var(--bg)); font-size: 13.5px; }
.archive a { color: var(--text); font-weight: 600; }
.foot a { color: var(--muted); }

/* Cheapest this week */
.cheap { margin-top: 36px; }
.cheap-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.cheap-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cheap-name { font-weight: 600; font-size: 14px; }
.cheap-name span { display: block; font-weight: 400; font-size: 12px; color: var(--faint); }
.cheap-stores { display: flex; flex-wrap: wrap; gap: 6px; }
.cheap-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 5px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums; }
.cheap-chip b { color: var(--text); font-weight: 600; }
.cheap-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.cheap-chip .diff { color: var(--faint); font-size: 11.5px; }
.cheap-chip.best { border-color: var(--good); color: var(--good); }
.cheap-chip.best b { color: var(--good); }
.cheap-chip.me { outline: 2px solid var(--text); outline-offset: 1px; }
.cheap-chip:hover { border-color: var(--faint); }
.compare { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.compare-head { width: 100%; font-size: 12.5px; color: var(--faint); }
@media (max-width: 640px) {
  .cheap-row { grid-template-columns: 1fr; gap: 6px; }
}
