:root {
  --bg: #eef1f8;
  --panel: #ffffff;
  --panel-2: #f5f7fc;
  --ink: #1a2138;
  --muted: #5b6480;
  --line: #dde2f0;
  --accent: #8a5f0a;
  --accent-ink: #ffffff;
  --success: #1f6f5c;
  --sale: #c1440e;
  --gold: #b08a3e;
  --cooling: #2c7dc9;
  --ortho: #a1457a;
  --hypo: #3f7d51;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 33, 56, .05), 0 8px 24px rgba(26, 33, 56, .06);
}

/* Explicit override from the theme toggle (theme.js sets data-theme on
   <html>) — takes priority over the OS preference below regardless of
   which direction it goes (forcing dark on a light system, or vice versa). */
:root[data-theme="dark"] {
  --bg: #0e1424;
  --panel: #151c33;
  --panel-2: #1b2340;
  --ink: #f1efe6;
  --muted: #8b93b5;
  --line: #2a3358;
  --accent: #f0c14b;
  --accent-ink: #241a04;
  --success: #59c4a4;
  --sale: #ff8f63;
  --gold: #d9b264;
  --cooling: #6db8f5;
  --ortho: #d989ba;
  --hypo: #74d093;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
}

/* No-JS fallback: follow the OS preference when theme.js hasn't run (or is
   disabled) to set data-theme explicitly yet. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1424;
    --panel: #151c33;
    --panel-2: #1b2340;
    --ink: #f1efe6;
    --muted: #8b93b5;
    --line: #2a3358;
    --accent: #f0c14b;
    --accent-ink: #241a04;
    --success: #59c4a4;
    --sale: #ff8f63;
    --gold: #d9b264;
    --cooling: #6db8f5;
    --ortho: #d989ba;
    --hypo: #74d093;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .card .price { font-family: "Fraunces", Georgia, serif; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inline-icon { vertical-align: -1px; margin-right: 1px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
.brand .mark { display: inline-flex; color: var(--accent); margin-right: 2px; }
.brand .tag {
  font-family: "Inter", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
  margin-left: 10px;
}
.stats { color: var(--muted); font-size: 13px; }

@media (max-width: 480px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 18px; }
  .brand .tag, .stats { display: none; }
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.region-switcher { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--panel-2); }
.region-switcher a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
}
.region-switcher a .flag { font-size: 15px; line-height: 1; }
.region-switcher a:hover { color: var(--ink); }
.region-switcher a.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
@media (max-width: 640px) {
  .region-switcher a span:not(.flag) { display: none; }
  .region-switcher a { padding: 6px 8px; }
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.hero {
  background:
    radial-gradient(ellipse 900px 420px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
    var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 56px 28px 44px;
}
.hero-inner {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  line-height: 1.15;
}
.hero-sub {
  margin: 0 auto 28px;
  max-width: 560px;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.55;
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 18px;
  max-width: 540px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.hero-search:focus-within { border-color: var(--accent); }
.hero-search-icon { color: var(--muted); flex-shrink: 0; }
.hero-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  min-width: 0;
  padding: 10px 0;
}
.hero-search input:focus { outline: none; }
.hero-search button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  flex-shrink: 0;
}
.hero-search button:hover { filter: brightness(1.06); }

@media (max-width: 640px) {
  .hero { padding: 40px 18px 32px; }
  .hero-search { flex-wrap: wrap; border-radius: 20px; padding: 12px; }
  .hero-search input { width: 100%; order: 1; padding: 8px 4px; }
  .hero-search-icon { order: 0; }
  .hero-search button { order: 2; width: 100%; }
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 48px 28px 28px;
  text-align: center;
  background:
    radial-gradient(ellipse 700px 300px at 50% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
    var(--panel);
}
.footer-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.footer-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  text-decoration: none;
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
}
.footer-logo span { color: var(--ink); }
.footer-tagline {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.55;
  max-width: 440px;
}
.footer-contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: filter .1s;
}
.footer-contact:hover { filter: brightness(1.06); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin-top: 6px;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.footer-links a:hover { color: var(--accent); }
.footer-disclosure {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  opacity: .8;
  line-height: 1.5;
}
.footer-bottom {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 12px;
  color: var(--muted);
}
.footer-bottom a { color: var(--muted); text-decoration: none; }
.footer-bottom a:hover { color: var(--accent); }

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.filters-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.clear-filters {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 4px;
  min-height: 32px;
}
.clear-filters:hover { text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: 268px 1fr;
  gap: 28px;
  padding: 28px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
}

/* Placed after the base .filters rule so it actually wins the cascade at
   equal specificity — a version of this that came before the base rule
   left .filters permanently sticky on mobile, overlapping the grid below
   it instead of stacking above it. */
@media (max-width: 860px) {
  .filters { position: static; top: auto; }
}

.filter-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
}

.filter-group input[type="text"],
.filter-group select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
}
.filter-group input[type="text"]:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
  cursor: pointer;
  margin: 4px 0;
}
.filter-group input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
}
.filter-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: pointer;
  margin-top: -8px;
}
.filter-group input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
}
.filter-group input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: pointer;
}

.checkbox-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 9px;
  text-transform: none;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: normal;
  cursor: pointer;
  min-height: 30px;
}
.checkbox-row input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s, color .1s, border-color .1s;
}
.pill:hover { border-color: var(--accent); }
.pill.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.price-range-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.price-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 16px;
  min-height: 38px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow);
  transition: background .1s, color .1s, border-color .1s;
}
.price-pill:hover { border-color: var(--accent); }
.price-pill.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.results-bar {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 18px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  box-shadow: var(--shadow);
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }

.card .thumb {
  aspect-ratio: 1 / 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}
.card .thumb img { max-width: 88%; max-height: 88%; object-fit: contain; }
.card .thumb .noimg { color: var(--muted); font-size: 12px; }

.compare-flag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gold);
  color: #221a08;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.card .body { padding: 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.card .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge.type-mattress { color: var(--accent); border-color: var(--accent); }
.badge.type-pillow { color: #8a5cb8; border-color: #8a5cb8; }

.card .features { display: flex; gap: 6px; flex-wrap: wrap; }
.feature-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
}
.feature-chip.cooling {
  background: color-mix(in srgb, var(--cooling) 14%, transparent);
  color: var(--cooling);
}
.feature-chip.ortho {
  background: color-mix(in srgb, var(--ortho) 14%, transparent);
  color: var(--ortho);
}
.feature-chip.hypo {
  background: color-mix(in srgb, var(--hypo) 14%, transparent);
  color: var(--hypo);
}

.card .name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.32;
  min-height: 2.65em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card .meta { font-size: 12px; color: var(--muted); }

.card .price-row {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.card .price { font-size: 19px; font-weight: 600; }
.card .rrp { font-size: 12px; color: var(--muted); text-decoration: line-through; font-family: "Inter", sans-serif; }
.card .saving { font-size: 11px; color: var(--sale); font-weight: 700; }

.card .rating { font-size: 12px; color: var(--muted); }

.card .stock-out { color: var(--sale); }

.load-more {
  display: block;
  margin: 28px auto 0;
  padding: 11px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  box-shadow: var(--shadow);
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }
.load-more[hidden] { display: none; }


.offer-list { display: flex; flex-direction: column; gap: 10px; }
.offer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel-2);
}
.offer-row.best { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--panel-2)); }
.offer-row .offer-merchant { font-weight: 600; font-size: 14px; }
.offer-row .offer-sub { font-size: 12px; color: var(--muted); }
.offer-row .offer-price { font-family: "Fraunces", serif; font-size: 17px; font-weight: 600; text-align: right; }
.offer-row .offer-rrp { font-size: 11px; color: var(--muted); text-decoration: line-through; display: block; }
.best-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--success);
  letter-spacing: .04em;
}

/* server-rendered product detail page */
.breadcrumb {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 28px 0;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--ink); }
.breadcrumb a:first-child { color: var(--accent); font-weight: 600; }
.breadcrumb-sep { margin: 0 10px; opacity: .5; }

.product-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 28px 64px;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 760px) {
  .product-page { grid-template-columns: 1fr; padding: 20px 16px 48px; }
}

.product-media .thumb {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.product-media .thumb img { width: 100%; height: 100%; object-fit: cover; }

.product-info h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
}
.product-meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.product-info .badges, .product-info .features { margin-bottom: 10px; }
.product-desc { color: var(--ink); font-size: 14.5px; line-height: 1.6; margin: 12px 0 20px; }

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 24px;
}
.product-price-row .price { font-family: "Fraunces", serif; font-size: 30px; font-weight: 600; }
.product-price-row .rrp { color: var(--muted); text-decoration: line-through; font-size: 15px; }
.product-price-row .saving { color: var(--sale); font-weight: 700; font-size: 14px; }

.product-info h2 { font-size: 17px; margin: 0 0 12px; }

/* legal pages (privacy / cookies / terms) */
.legal-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}
.legal-page h1 {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 600;
}
.legal-updated { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.legal-notice {
  margin: 0 0 28px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-2));
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.legal-page h2 {
  margin: 28px 0 8px;
  font-size: 17px;
  font-weight: 600;
}
.legal-page p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
}
.legal-page a { color: var(--accent); }
