:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #dfe3da;
  --text: #1c2118;
  --text-dim: #5d6655;
  --accent: #2f6d3c;
  --accent-soft: #e4f0e3;
  --deal: #b3261e;
  --deal-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(28, 33, 24, .06), 0 4px 14px rgba(28, 33, 24, .05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14170f;
    --surface: #1d2118;
    --surface-2: #252a1f;
    --border: #363d2d;
    --text: #e8ece3;
    --text-dim: #9aa48d;
    --accent: #7fc98c;
    --accent-soft: #23301f;
    --deal: #ff9b8f;
    --deal-soft: #33211d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg: #14170f;
  --surface: #1d2118;
  --surface-2: #252a1f;
  --border: #363d2d;
  --text: #e8ece3;
  --text-dim: #9aa48d;
  --accent: #7fc98c;
  --accent-soft: #23301f;
  --deal: #ff9b8f;
  --deal-soft: #33211d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is display:none, but any author `display` rule
   beats it — `.more { display: block }` was leaving the button on screen with
   hidden=true. Make the attribute win everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

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

/* ---------- header ---------- */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.site-head .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 28px; line-height: 1; }
.site-head h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.tagline { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }
.head-meta { display: flex; align-items: center; gap: 10px; }
.updated { font-size: 12px; color: var(--text-dim); }

.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -.01em; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--text-dim); }

/* ---------- summary ---------- */
.summary-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.store-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; background: var(--surface-2);
}
.store-card.is-best { border-color: var(--accent); background: var(--accent-soft); }
.store-name { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.store-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 6px;
}
.store-stat { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 0; }
.store-sub { font-size: 12px; color: var(--text-dim); }
.store-card.is-empty { opacity: .62; }

/* ---------- watchlist ---------- */
.watch-form { display: flex; gap: 8px; margin-bottom: 10px; }
.watch-form input { flex: 1; min-width: 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 3px 6px 3px 10px; font-size: 12.5px; font-weight: 600;
}
.tag-n {
  background: var(--accent); color: var(--surface);
  border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 700;
}
.tag.is-cold { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.tag.is-cold .tag-n { background: var(--border); color: var(--text-dim); }
.tag button {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; opacity: .75;
}
.tag button:hover { opacity: 1; }
.watch-hits { margin-top: 12px; }
.watch-hits:empty { margin-top: 0; }
.watch-empty { font-size: 13px; color: var(--text-dim); margin: 10px 0 0; }

/* ---------- filters ---------- */
.filter-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.filter-row:last-child { margin-bottom: 0; }
.filter-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); padding-top: 7px; min-width: 62px; flex-shrink: 0;
}
.search-row { gap: 8px; }
.search-row input { flex: 1; min-width: 0; }

input[type="text"], input[type="search"], select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; font-size: 14px; font-family: inherit;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
/* In dark mode --accent is a light green, so the active chip needs dark text. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip[aria-pressed="true"],
  :root:not([data-theme="light"]) .btn { color: #14170f; }
}
:root[data-theme="dark"] .chip[aria-pressed="true"],
:root[data-theme="dark"] .btn { color: #14170f; }
.chip .n { opacity: .65; font-size: 11.5px; margin-left: 4px; }

.toggles { align-items: center; justify-content: space-between; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; }
.link-btn {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font-size: 13px; font-family: inherit; text-decoration: underline; padding: 0;
}

.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.more { display: block; margin: 8px auto 32px; }

/* ---------- results ---------- */
.result-count { font-size: 13px; color: var(--text-dim); margin: 0 0 10px 2px; }

.grid {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card.is-watched { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }

.card-media {
  position: relative; aspect-ratio: 4 / 3; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: contain; }
.card-media .placeholder { font-size: 34px; opacity: .3; }
.card-media .placeholder[hidden] { display: none; }
/* Stacking inside the media box: glyph (0) < image (1) < badges (2). The
   badges must stay on top or a full-bleed photo hides the discount, which is
   the one number the card exists to show. */
.card-media img { position: relative; z-index: 1; }

.pct {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: var(--deal); color: #fff;
  font-size: 13px; font-weight: 700; border-radius: 7px; padding: 3px 7px;
  letter-spacing: -.01em;
}
.store-tag {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-size: 11px; font-weight: 650; border-radius: 6px; padding: 2px 6px;
}

.card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; flex: 1; gap: 4px; }
.card-cat {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent);
}
.card-name { font-size: 14px; font-weight: 620; line-height: 1.35; margin: 0; }
.card-name a { color: inherit; text-decoration: none; }
.card-name a:hover { text-decoration: underline; }
.card-sub {
  font-size: 12px; color: var(--text-dim); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-prices {
  display: flex; align-items: baseline; gap: 8px; margin-top: auto;
  padding-top: 8px; flex-wrap: wrap;
}
.price-now {
  font-size: 19px; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap;   /* never break "CHF" off its amount */
}
.price-was { font-size: 13px; color: var(--text-dim); text-decoration: line-through; }
.price-unit { font-size: 11.5px; color: var(--text-dim); }
.card-note {
  font-size: 11px; color: var(--text-dim);
  background: var(--surface-2); border-radius: 5px; padding: 3px 6px;
  align-self: flex-start;
}
.card-valid { font-size: 11px; color: var(--text-dim); }

.empty { text-align: center; padding: 40px 16px; color: var(--text-dim); }

/* ---------- footer ---------- */
.site-foot {
  border-top: 1px solid var(--border); background: var(--surface);
  margin-top: 28px; padding: 18px 0 32px;
}
.site-foot p { font-size: 12px; color: var(--text-dim); margin: 0 0 6px; max-width: 70ch; }
.sources { font-size: 11.5px; }

/* The disclaimer and the repo link sit side by side on a wide screen and
   stack on a phone, so the link never pushes the note out of the way. */
.foot-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 10px;
}
.foot-note { flex: 1 1 320px; margin-bottom: 0 !important; }
/* The legal line matters but should not compete with the practical advice. */
.foot-legal { display: inline-block; margin-top: 5px; font-size: 11px; opacity: .8; }

.repo-link {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.repo-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.repo-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.repo-link-text { display: flex; flex-direction: column; line-height: 1.3; }
.repo-link-text strong { font-size: 13px; font-weight: 650; }
.repo-link-text span { font-size: 11.5px; color: var(--text-dim); }

.repo-link-star { font-size: 15px; color: var(--text-dim); }
.repo-link:hover .repo-link-star { color: var(--accent); }

@media (max-width: 560px) {
  /* Five stacked store cards pushed the actual deals off the first screen. */
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .store-card { padding: 9px 10px; }
  .store-name { font-size: 13px; }
  .store-stat { font-size: 21px; margin-top: 2px; }
  .store-sub { font-size: 11px; }
  .store-badge { font-size: 9px; padding: 1px 4px; }
  .panel { padding: 13px; margin: 13px 0; }

  .repo-link { width: 100%; }
  .filter-row { flex-direction: column; gap: 6px; }
  .filter-label { padding-top: 0; }
  .search-row { flex-direction: row; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .price-now { font-size: 17px; }
  .site-head .wrap { padding-top: 10px; padding-bottom: 10px; }
}
