/* SportPursuit Deal Hunter - dark theme (default) + light theme.
   Colour tokens live here; everything below consumes them. */

:root,
html[data-theme="dark"] {
  --bg: #0e1117;
  --panel: #161b24;
  --panel2: #1d2430;
  --border: #2a3342;
  --text: #e6eaf2;
  --muted: #8b96a8;
  --accent: #22c55e;
  --accent2: #f59e0b;
  --danger: #ef4444;
  --accent-ink: #052e16;          /* text on top of --accent */
  --row-hover: var(--panel2);
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --scroll-thumb: #38445a;
  --img-bg: #ffffff;
  --focus: #7dd3fc;
}

html[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel2: #eef1f6;
  --border: #d4dae4;
  --text: #141a24;
  --muted: #5d6b80;
  --accent: #15803d;
  --accent2: #b45309;
  --danger: #dc2626;
  --accent-ink: #ffffff;
  --row-hover: #e6ebf3;
  --shadow: 0 8px 30px rgba(15, 23, 42, .18);
  --scroll-thumb: #b6c0cf;
  --img-bg: #ffffff;
  --focus: #0369a1;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--scroll-thumb) transparent; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- generic focus + motion ---------- */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 200;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 8px; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .btn:active { transform: none; }
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 22px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; white-space: nowrap; }
.accent { color: var(--accent); }
.gender-badge {
  background: #1e3a8a;
  color: #93c5fd;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}
html[data-theme="light"] .gender-badge { background: #dbeafe; color: #1e3a8a; }

.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.last-scan { color: var(--muted); font-size: 12px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: filter .15s, transform .05s, border-color .15s;
  font-family: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
}
.btn:active { transform: scale(.97); }
.btn-rescan { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-rescan:hover { filter: brightness(1.1); }
.btn-rescan:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border); width: 100%; }
.btn-ghost:hover { border-color: var(--muted); }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
}
.btn-inline { width: auto; padding: 8px 12px; }
.btn-active, .btn[aria-pressed="true"] {
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
  border-color: var(--accent) !important;
}

.spin { display: inline-block; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- stats ---------- */
.stats-row {
  display: flex;
  gap: 12px;
  padding: 16px 24px 0;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 18px;
  min-width: 120px;
}
.stat-card .num { font-size: 22px; font-weight: 800; color: var(--accent); }
.stat-card .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card.clickable { cursor: pointer; text-align: left; font-family: inherit; }
.stat-card.clickable:hover { border-color: var(--accent); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 292px 1fr;
  gap: 20px;
  padding: 16px 24px 40px;
  align-items: start;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 76px;
  align-self: start;
  /* The panel stack is taller than the viewport, so the sidebar scrolls itself
     rather than pushing its lower controls out of reach.
     Both states have to fit: at the top of the page the header, stats row and
     toolbar sit above it (natural top ≈ 166px), and once sticky has pinned it
     the top is 76px. Sizing for the former keeps it on screen in both. */
  max-height: calc(100vh - 176px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
/* Flex items shrink by default, which squashed the panels down to fit inside
   max-height. The stack therefore never overflowed, the sidebar never became
   scrollable, and the footer sat below the fold with no way to reach it. */
.sidebar > * { flex: 0 0 auto; }

/* Whole-sidebar collapse. The control lives in the toolbar, not inside the
   sidebar - a button inside the thing it hides cannot bring it back. */
.lbl-expand { display: none; }
body.sidebar-collapsed .lbl-expand { display: inline; }
body.sidebar-collapsed .lbl-hide { display: none; }
body.sidebar-collapsed .layout { grid-template-columns: 1fr; }
body.sidebar-collapsed .sidebar { display: none; }

.drawer-head { display: none; }
.drawer-scrim { display: none; }

.sidebar-footer {
  display: flex;
  gap: 8px;
  /* Not sticky: as a sticky element sitting at the bottom of the pinned column
     it floated over the controls at the end of the panel stack and swallowed
     their clicks. A plain row at the end of the scroll is unambiguous. */
  padding: 2px 0;
}
.sidebar-footer .btn { flex: 1; }

/* ---------- collapsible groups ---------- */
.group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.group-head-btn-wrap { margin: 0; font-size: inherit; }
.group-head-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}
.group-head-btn:hover { background: var(--panel2); }
.group-head-btn .chev {
  display: inline-block;
  transition: transform .15s;
  color: var(--muted);
  font-size: 10px;
}
.group-head-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.group-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.group-head-btn[aria-expanded="false"] + .group-body { display: none; }

.subpanel h4 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.facet-count { font-size: 10px; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ---------- active filter summary ---------- */
.active-filters { display: flex; flex-direction: column; gap: 6px; }
.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.active-chips:empty { display: none; }
.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 11px;
  color: var(--text);
}
.active-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; line-height: 1; padding: 0 3px;
}
.active-chip button:hover { color: var(--danger); }

.pill {
  background: #7c3aed; color: #ede9fe; border-radius: 999px;
  padding: 1px 8px; font-size: 11px; font-weight: 700; margin-left: 4px;
}
.pill-new { background: var(--accent2); color: #3b2100; }
.pill-muted { background: var(--panel2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- facet lists ---------- */
.category-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.category-list-sm { max-height: 170px; }
.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.cat-row:hover { background: var(--row-hover); }
.cat-row.active { background: #143d26; }
html[data-theme="light"] .cat-row.active { background: #d1fae5; }
.cat-row .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-count { color: var(--muted); font-size: 11px; }
/* A facet that the current filters have reduced to nothing. */
.cat-row.facet-empty .cat-name,
.cat-row.facet-empty .cat-count { opacity: .45; }
.cat-row input { accent-color: var(--accent); }

/* ---------- hide a brand ---------- */
/* The eye is a button inside the row's <label>, so its handler preventDefaults
   and stops propagation - otherwise clicking it would also toggle the brand on. */
.row-block {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 5px;
  opacity: .55;
}
.cat-row:hover .row-block { opacity: 1; }
.row-block:hover { background: var(--border); color: var(--text); }
.row-block:focus-visible { opacity: 1; }
.row-block.on { opacity: 1; color: var(--accent2); }
.cat-row.is-blocked .cat-name,
.cat-row.is-blocked .cat-count { opacity: .4; text-decoration: line-through; }

.blocked-list {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.blocked-list .blocked-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 10px;
  border-radius: 6px;
  background: var(--panel2);
  font-size: 12px;
}
.blocked-list .blocked-row .cat-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: line-through;
  opacity: .75;
}

.search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.search:focus { border-color: var(--accent); }
.search-main { flex: 1; min-width: 180px; }
.search-wrap { position: relative; flex: 1; min-width: 180px; display: flex; }
.kbd-inline {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.kbd-inline *, .kbd-hint { pointer-events: none; }

.kbd-hint {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  background: var(--panel2);
  margin-left: auto;
}

.range-row { display: flex; gap: 8px; }
.range-row input { flex: 1; width: 0; min-width: 0; }
input[type=number] {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  outline: none;
  font-family: inherit;
  font-size: 13px;
}
input[type=number]:focus { border-color: var(--accent); }

input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}
.slider-label b { color: var(--text); }

.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
.check input { accent-color: var(--accent); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-toggle { display: inline-flex; align-items: center; gap: 6px; }
.sort {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  outline: none;
  font-family: inherit;
  font-size: 13px;
  max-width: 100%;
}
.result-count { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ---------- grid ---------- */
.deals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
  align-items: start;
}
.window-spacer { grid-column: 1 / -1; pointer-events: none; }

.group-head {
  grid-column: 1 / -1;
  margin: 18px 0 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.group-head .line { flex: 1; height: 1px; background: var(--border); }

/* ---------- loading skeleton ---------- */
.skeleton-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.skeleton-card .sk-img { aspect-ratio: 1; }
.skeleton-card .sk-line {
  height: 11px;
  margin: 10px 12px;
  border-radius: 6px;
}
.skeleton-card .sk-line.short { width: 55%; }
.skeleton-card .sk-line.tall { height: 18px; }
.sk-shimmer {
  background: linear-gradient(90deg, var(--panel2) 25%, var(--border) 37%, var(--panel2) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.load-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0 14px;
}
.load-status .spin { font-size: 16px; color: var(--accent); }

/* ---------- empty states ---------- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--panel);
}
.empty-state .empty-icon { font-size: 34px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 auto 16px; color: var(--muted); max-width: 460px; line-height: 1.5; }
.empty-state .btn { display: inline-block; width: auto; }

.grid-footer { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; }
.grid-footer .btn { width: auto; }

/* ---------- card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .12s, border-color .12s;
  position: relative;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }

.card .img-wrap { position: relative; background: var(--img-bg); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.card img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card img.lazy { opacity: 0; }
.card img.loaded { opacity: 1; transition: opacity .3s; }

.discount-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--danger);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}
.sold-out-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.fav-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,.55);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  color: #fff;
}
.fav-btn:hover { background: rgba(0,0,0,.8); }
.fav-btn.on { background: #fde047; color: #422006; }

.card .body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.brand-line { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.title-line { font-size: 13px; line-height: 1.35; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.title-line a { color: inherit; text-decoration: none; }
.title-line a:hover { text-decoration: underline; }
.cat-line { font-size: 11px; color: var(--muted); }

.price-row { margin-top: auto; display: flex; align-items: baseline; gap: 8px; padding-top: 6px; flex-wrap: wrap; }
.price-now { font-size: 17px; font-weight: 800; color: var(--accent); }
.price-rrp { font-size: 12px; color: var(--muted); text-decoration: line-through; }
.savings { font-size: 11px; color: var(--accent2); margin-left: auto; font-weight: 600; }

.sizes-row { font-size: 11px; color: var(--muted); padding-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sizes-row .in { color: #93c5fd; }
/* Listing sizes for a product whose stock has not been checked: deliberately
   muted and italic so it cannot be mistaken for "in stock". */
.sizes-row .sz-unchecked { color: var(--muted); font-style: italic; }
html[data-theme="light"] .sizes-row .in { color: #1d4ed8; }

.rating-row { font-size: 11px; color: var(--accent2); }

.card a.view-link {
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 8px;
  font-weight: 700;
  font-size: 12px;
  border-radius: 8px;
  margin-top: 8px;
}
.card a.view-link:hover { filter: brightness(1.1); }

.sample-banner {
  background: #78350f;
  color: #fde68a;
  padding: 9px 24px;
  font-size: 13px;
  border-bottom: 1px solid #b45309;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.35; }

.tag-row { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 5px; }
.tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.tag-new { background: #7c2d12; color: #fed7aa; }
.tag-drop { background: #14532d; color: #86efac; }
.tag-low { background: #1e3a8a; color: #bfdbfe; }
.tag-fast { background: #1e293b; color: #93c5fd; border: 1px solid #334155; }
.tag-mine { background: #065f46; color: #6ee7b7; }
.tag-unchecked { background: var(--panel2); color: var(--muted); border: 1px dashed var(--border); }
.tag-ends { background: #7f1d1d; color: #fecaca; }
.tag-trust { background: #78350f; color: #fde68a; }
.tag-reason { background: var(--accent); color: var(--accent-ink); }
html[data-theme="light"] .tag-fast { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
html[data-theme="light"] .tag-new { background: #ffedd5; color: #9a3412; }
html[data-theme="light"] .tag-drop { background: #dcfce7; color: #166534; }
html[data-theme="light"] .tag-low { background: #dbeafe; color: #1e40af; }
html[data-theme="light"] .tag-mine { background: #d1fae5; color: #065f46; }
html[data-theme="light"] .tag-unchecked { background: var(--panel2); color: var(--muted); }
html[data-theme="light"] .tag-ends { background: #fee2e2; color: #991b1b; }
html[data-theme="light"] .tag-trust { background: #fef3c7; color: #92400e; }

.stock-note { font-size: 11px; color: #fca5a5; padding-top: 3px; }
html[data-theme="light"] .stock-note { color: #b91c1c; }
.prev-line { font-size: 11px; color: var(--muted); }
.sz-out { color: var(--danger); text-decoration: line-through; }

.colour-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(128,128,128,.55);
  vertical-align: middle;
}

/* ---------- density ---------- */
body.compact .deals-grid { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
body.compact .card .body { padding: 9px; gap: 2px; }
body.compact .title-line { font-size: 12px; -webkit-line-clamp: 2; min-height: 32px; }
body.compact .price-now { font-size: 15px; }
body.compact .sizes-row,
body.compact .feature-line,
body.compact .rating-row,
body.compact .stock-note,
body.compact .prev-line,
body.compact .cat-line { display: none; }
body.compact .card a.view-link { padding: 6px; font-size: 11px; }
body.compact .similar-btn { padding: 6px 8px; font-size: 11px; }

/* ---------- watchlist / alerts ---------- */
.watch-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.watch-row {
  display: flex; align-items: center; gap: 4px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 6px; font-size: 12px;
}
.watch-row .watch-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.watch-name { font-weight: 600; }
.watch-desc { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-hits { font-size: 10px; color: var(--muted); }
.watch-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 3px 4px; border-radius: 5px;
}
.watch-btn:hover { color: var(--text); background: var(--border); }
.watch-del:hover { color: var(--danger); }
.watch-form { display: flex; flex-direction: column; gap: 6px; }
.watch-form input, .watch-form select { width: 100%; }
.watch-form-actions { display: flex; gap: 6px; }
.watch-form-actions .btn { flex: 1; width: auto; }
.watch-preview {
  background: var(--panel2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.watch-preview b { color: var(--text); }
.watch-preview ul { margin: 6px 0 0; padding-left: 16px; }

.alert-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.alert-item {
  display: flex; flex-direction: column; gap: 1px; text-decoration: none;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 8px; color: var(--text);
}
.alert-item:hover { border-color: var(--accent); }
.alert-item.is-new { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.alert-rule { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.alert-title { font-size: 12px; }
.alert-price { font-size: 11px; color: var(--accent); font-weight: 600; }

/* ---------- swatches ---------- */
.swatch-row { display: flex; align-items: center; gap: 4px; padding-top: 5px; flex-wrap: wrap; }
.swatch-label { font-size: 10px; color: var(--muted); margin-right: 2px; }
.swatch {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; box-shadow: 0 0 0 1px var(--border); padding: 0;
  position: relative;
}
.swatch.on { border-color: var(--accent); }

.delivery-line { font-size: 11px; color: #93c5fd; padding-top: 3px; }
html[data-theme="light"] .delivery-line { color: #1d4ed8; }
.feature-line { font-size: 11px; color: var(--muted); padding-top: 3px; }

.card-actions { display: flex; gap: 6px; margin-top: 8px; }
.card-actions .view-link { flex: 1; margin-top: 0; }
.similar-btn {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.similar-btn:hover { border-color: var(--accent); }

/* similar products: real links with thumbnails */
.similar-panel {
  margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.similar-item {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; font-size: 11px;
}
.similar-item:hover { border-color: var(--accent); }
.similar-thumb {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px;
  background: var(--img-bg); object-fit: contain;
}
.similar-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.similar-title {
  color: var(--text); overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.similar-price { color: var(--accent); font-weight: 600; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* Any stylesheet rule that sets `display` on an element the JS toggles with the
   [hidden] attribute must be guarded here, or the attribute silently loses and
   the element keeps occupying space (and intercepting clicks). */
.modal[hidden],
.toast[hidden],
.drawer-scrim[hidden],
.sample-banner[hidden],
.window-spacer[hidden],
.similar-panel[hidden],
.alert-list[hidden] { display: none !important; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  max-width: 460px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.shortcut-list dt { text-align: right; }
.shortcut-list dd { margin: 0; color: var(--muted); }
kbd {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--panel2); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px;
  padding: 2px 6px; font-size: 11px; font-family: inherit; font-weight: 700;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: min(92vw, 560px);
  font-size: 13px;
  /* Never let an overlay eat clicks aimed at the page underneath; the action
     button re-enables pointer events for itself. */
  pointer-events: none;
}
.toast.toast-action { display: flex; align-items: center; gap: 14px; }
.toast button {
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 7px; padding: 6px 12px; font-weight: 700; font-size: 12px;
  cursor: pointer; font-family: inherit; flex-shrink: 0;
  pointer-events: auto;
}

/* ================= responsive ================= */

/* tablet: drawer instead of a pinned column */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; padding: 14px 16px 40px; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 120;
    width: min(88vw, 340px);
    max-height: 100vh;
    height: 100%;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 12px 14px 20px;
    transform: translateX(-102%);
    transition: transform .2s ease;
    overflow-y: auto;
  }
  body.drawer-open .sidebar { transform: none; }
  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    padding-bottom: 6px;
  }
  /* In drawer mode the whole-column control is the drawer's own close button. */
  .drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 110;
  }
  .drawer-scrim[hidden] { display: none; }
  /* The toolbar button already covers both modes, so in the drawer it is the
     opener only; the drawer header carries its own close button. */
  .sidebar-footer { position: static; }
  .stats-row { padding: 14px 16px 0; gap: 10px; }
  .stat-card { padding: 8px 14px; min-width: 104px; }
  .stat-card .num { font-size: 19px; }
  .topbar { padding: 12px 16px; }
}

/* ---------- session (sign-out control, signed-in name) ---------- */
/* Used by app.html, landing.html and login.html, so it lives in the shared
   stylesheet rather than being duplicated in the two page stylesheets. */
.logout-form { margin: 0; display: inline-flex; }
.logout-form button { font: inherit; cursor: pointer; }
.whoami {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}
.brand-home { display: inline-flex; text-decoration: none; border-radius: 6px; }
.brand-home .logo { display: block; }

@media (max-width: 900px) {
  .whoami { display: none; }
}

/* The brand needs a floor of its own. `.actions` is flex-shrink: 0 (the buttons
   must not squash), and the h1 is nowrap, so on a narrow phone the two simply
   overlapped -- 135px of the title sat underneath the buttons. Letting the
   topbar wrap puts the action row on its own line instead. */
.topbar { row-gap: 10px; flex-wrap: wrap; }
.brand { min-width: 14rem; }

@media (max-width: 760px) {
  .brand h1 { font-size: 15px; }
  .logo { font-size: 18px; }
  .last-scan { display: none; }
  .toolbar { gap: 6px; }
  .toolbar .sort { flex: 1 1 140px; min-width: 0; }
  .search-wrap { flex: 1 1 100%; order: -1; }
  .result-count { margin-left: 0; flex: 1 1 100%; }
  .deals-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
}

/* Below the width where brand + actions fit on one line, the primary action
   takes the full row underneath and the title stays readable. */
@media (max-width: 560px) {
  .brand { min-width: 0; }
  .actions { flex: 1 1 100%; justify-content: flex-end; }
  .btn-rescan { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 520px) {
  .layout { padding: 10px 12px 32px; }
  .deals-grid { grid-template-columns: 1fr; }
  body.compact .deals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { padding: 10px 12px 0; }
  .stat-card { flex: 1 1 calc(50% - 10px); min-width: 0; padding: 8px 12px; }
  .stat-card .num { font-size: 17px; }
  .toolbar .sort { flex: 1 1 100%; }
  .btn-rescan { padding: 8px 10px; font-size: 12px; }
  .modal-card { padding: 16px; }
  .toast { bottom: 12px; }
}
