:root {
  --bg:        #f7f5f0;
  --surface:   #ffffff;
  --border:    rgba(0,0,0,0.08);
  --fg:        #1a1714;
  --muted:     #6b6560;
  --dim:       #9e9890;
  --accent:    #c8522a;
  --accent-bg: rgba(200,82,42,0.08);
  --green:     #2e7d4f;
  --green-bg:  rgba(46,125,79,0.08);
  --nav-h:     56px;
  --display:   'Playfair Display', Georgia, serif;
  --body:      'DM Sans', system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #12100e;
    --surface:   #1c1a17;
    --border:    rgba(255,255,255,0.07);
    --fg:        #f0ede6;
    --muted:     #9e9890;
    --dim:       #6b6560;
    --accent:    #e06b3a;
    --accent-bg: rgba(224,107,58,0.12);
    --green:     #4caf78;
    --green-bg:  rgba(76,175,120,0.12);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:        #12100e;
  --surface:   #1c1a17;
  --border:    rgba(255,255,255,0.07);
  --fg:        #f0ede6;
  --muted:     #9e9890;
  --dim:       #6b6560;
  --accent:    #e06b3a;
  --accent-bg: rgba(224,107,58,0.12);
  --green:     #4caf78;
  --green-bg:  rgba(76,175,120,0.12);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 max(20px, env(safe-area-inset-left, 0px));
  gap: 12px;
  z-index: 100;
}
.logo {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-freshness {
  font-size: 12px;
  color: var(--dim);
  margin-right: 16px;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .nav-freshness { display: none; }
}
.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 6px;
  transition: color .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 18px;
  border-radius: 6px;
  transition: opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

/* ── PAGE WRAPPER ── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-left, 0px));
}

/* ── HEADER / SEARCH ── */
.explore-header {
  padding: 40px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.explore-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.explore-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.025em;
  color: var(--fg);
}
.explore-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}
.search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 16px;
}
.search-input {
  flex: 1;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 16px;
  font: 14px var(--body);
  color: var(--fg);
  outline: none;
  transition: border-color .15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); }

/* ── VIEW TOGGLES (PILLS) ── */
.view-toggles { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--border); }
.view-btn {
  background: none; border: none; color: var(--muted); font-family: var(--body); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: all 0.15s;
}
.view-btn:hover:not(.active) { color: var(--fg); }
.view-btn.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ── STATS BAR ── */
.stats-bar {
  display: flex;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  font-size: 0.82rem;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
}
.stats-bar strong { color: var(--fg); font-weight: 600; }

/* ── BACK BUTTON ── */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent-bg); color: var(--accent);
  border: 1px solid rgba(200,82,42,0.2); padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; margin-bottom: 20px; border: none; font-family: var(--body);
}
.back-btn:hover { opacity: 0.8; }

/* ── BOOK GRID ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.book-card:hover {
  border-color: rgba(200,82,42,0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.book-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
.card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--border);
  display: block;
}
.card-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-prices {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.card-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.card-mrp {
  font-size: 0.75rem;
  color: var(--dim);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}
.card-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--green-bg);
  color: var(--green);
  padding: 2px 6px;
  border-radius: 4px;
}
.card-watchers {
  font-size: 0.72rem;
  color: var(--dim);
}

/* ── SERIES FOLDER CARDS ── */
.series-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; transition: transform .15s, border-color .15s; display: flex; flex-direction: column;
  height: 320px;
}
.series-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.series-cover { width: 100%; height: 220px; object-fit: cover; background: var(--border); border-bottom: 1px solid var(--border); }
.series-cover-placeholder { width: 100%; height: 220px; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.series-info { padding: 16px; display: flex; flex-direction: column; justify-content: center; flex: 1; }
.series-name { font-size: 16px; font-weight: 700; color: var(--fg); margin-bottom: 4px; line-height: 1.2; }
.series-meta { font-size: 12px; color: var(--muted); }

/* ── DETAIL PANEL ── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}
.detail-overlay[hidden] { display: none !important; }

.detail-panel {
  width: min(800px, 100vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 28px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
@media (max-width: 600px) {
  .detail-overlay { align-items: flex-end; justify-content: stretch; }
  .detail-panel { width: 100%; height: 85vh; border-left: none; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; }
}

.panel-close {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1.4;
  transition: color .15s;
}
.panel-close:hover { color: var(--fg); }

.panel-book-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.panel-cover {
  width: 96px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 7px;
  background: var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.panel-cover-placeholder {
  width: 96px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  background: var(--border);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}
.panel-title {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
  margin-bottom: 8px;
}
.panel-watchers {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.panel-bw-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 500 12px var(--body);
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(200,82,42,0.2);
  border-radius: 6px;
  padding: 5px 12px;
  text-decoration: none;
  transition: opacity .15s;
}
.panel-bw-btn:hover { opacity: .8; }

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  flex: 1;
  min-width: 110px;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dim);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  line-height: 1;
}

.stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 5px; }

/* chart */
.chart-section-title {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 12px;
}
.chart-wrap { overflow-x: auto; }
svg.price-chart { display: block; width: 100%; min-width: 280px; }

/* chart tooltip */
.chart-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  color: var(--fg);
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  white-space: nowrap;
  display: none;
}
.tt-price { font-weight: 700; font-size: 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
.tt-date  { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── CHART TIMELINE BUTTONS ── */

/* cta strip */
.cta-strip {
  background: var(--accent-bg);
  border: 1px solid rgba(200,82,42,0.15);
  border-radius: 10px;
  padding: 18px 20px;
  text-align: center;
}
.cta-strip p { font-size: 0.875rem; color: var(--fg); margin-bottom: 12px; line-height: 1.5; }
.cta-strip strong { color: var(--accent); }

/* ── EMPTY / NOT TRACKED ── */
.not-tracked {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 28px;
  text-align: center;
  max-width: 520px;
  margin: 40px auto;
}
.not-tracked-icon { font-size: 2.5rem; margin-bottom: 12px; }
.not-tracked h3 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--fg);
}
.not-tracked p { font-size: 0.875rem; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.url-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.url-input {
  flex: 1;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font: 13px var(--body);
  color: var(--fg);
  outline: none;
  transition: border-color .15s;
}
.url-input:focus { border-color: var(--accent); }
.url-input::placeholder { color: var(--muted); }

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  padding: 60px 0;
  justify-content: center;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── SORT SELECT ── */
.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
  margin-left: auto;
}
.sort-select:focus { border-color: var(--accent); }

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--border);
  padding: 24px max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  width: 100%;
}

/* ── TOAST ── */

.card-body button:hover:not(:disabled) {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ── PAGINATION ── */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 32px 0;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 36px;
  text-align: center;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-ellipsis {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  color: var(--dim);
  user-select: none;
}
.page-ellipsis:hover {
  background: var(--border);
  color: var(--fg);
}
.page-input {
  width: 44px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--fg);
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  border-radius: 6px;
  outline: none;
}
.filter-row {
  display: none;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}
.filter-row.active {
  display: flex;
  animation: slideDown 0.3s ease-out forwards;
}
@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--body);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
  max-width: 200px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.filter-select:focus { border-color: var(--accent); }
.btn-clear-filter {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}
.btn-clear-filter:hover { background: var(--accent-bg); }

/* ── Added: book links, filters, follow, compare ─────────────────────────── */
a.card-title { text-decoration: none; }
a.card-title:hover, a.card-title:focus-visible { text-decoration: underline; }
.card-watch-btn {
  width: 100%; background: var(--accent); border: 1px solid var(--accent); color: #fff; padding: 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: opacity .15s; margin-top: 8px;
  font-family: var(--body);
}
.card-watch-btn:hover { opacity: .88; }
.card-watch-btn.in-list { background: var(--green-bg); border-color: rgba(46,125,79,0.2); color: var(--green); cursor: default; }
.compare-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; cursor: pointer; }
.compare-check input { accent-color: var(--accent); }
.panel-badges { margin: 4px 0 6px; }
.page-ellipsis { background: none; border: none; font: inherit; }

.price-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.price-input { width: 92px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg); cursor: pointer; }
.filter-check input { accent-color: var(--accent); }

.series-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.series-bar .back-btn { margin-bottom: 0; }
.follow-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px;
  font: 600 13px var(--body); cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
}
.follow-btn:hover { border-color: var(--accent); color: var(--accent); }
.follow-btn.following { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.follow-hint { font-size: 12px; color: var(--muted); }
.following-mark { color: var(--accent); }

.compare-tray {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 900;
  width: min(960px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.compare-tray-items { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.compare-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-bg); color: var(--fg);
  padding: 3px 4px 3px 10px; border-radius: 999px; font-size: 12px; }
.compare-chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 999px; }
.compare-chip button:hover { color: var(--accent); }
.compare-tray-actions { display: flex; gap: 8px; align-items: center; }
.compare-tray-actions .btn-primary[disabled] { opacity: .5; cursor: not-allowed; }

.compare-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.55); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.compare-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(1240px, 100%);
  max-height: calc(100vh - 32px); overflow: auto; padding: 20px 22px 26px; }
.compare-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.compare-head h2 { font-family: var(--display); font-size: 1.4rem; margin: 0; }
.compare-head .panel-close { position: static; margin: 0; }
.compare-scroll { overflow-x: auto; }
.compare-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.compare-table th, .compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare-table thead th { vertical-align: bottom; min-width: 170px; }
.compare-table tbody th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.compare-table td.best { color: var(--green); font-weight: 700; }
.cmp-cover, .cmp-cover-placeholder { width: 72px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 8px; background: var(--border); }
.cmp-cover-placeholder { display: flex; align-items: center; justify-content: center; }
.cmp-title { display: block; color: var(--fg); font-weight: 600; text-decoration: none; margin-bottom: 6px; }
.cmp-title:hover { text-decoration: underline; color: var(--accent); }
.cmp-remove { background: none; border: 0; color: var(--accent); font-size: 12px; cursor: pointer; padding: 0; }
.cmp-verdict { font-weight: 600; }
.cmp-great, .cmp-good { color: var(--green); }
.cmp-wait { color: var(--accent); }

/* ── Filters dropdown ───────────────────────────────────────────────────── */
.filter-menu { position: relative; }
.filter-menu:has(.filter-row:not(.active)) { display: none; }          /* series view: no filters */
.filter-toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 100%; min-height: 42px;
  background: var(--surface); border: 1px solid var(--border); color: var(--fg); border-radius: 8px;
  padding: 0 14px; font: 500 14px var(--body); cursor: pointer; white-space: nowrap;
}
.filter-toggle:hover, .filter-toggle[aria-expanded="true"] { border-color: var(--accent); }
.filter-toggle.has-filters { border-color: var(--accent); color: var(--accent); }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
}
.filter-count[hidden] { display: none; }
/* the panel itself (overrides the old always-visible filter row) */
.filter-row.active { display: none; animation: none; }
.filter-row.active.open {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center;
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; margin: 0;
  width: min(520px, calc(100vw - 32px)); padding: 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(0,0,0,.22);
}
.filter-row.open .filter-select { width: 100%; }
.filter-row.open .price-range { grid-column: 1 / -1; }
.filter-row.open .price-range .price-input { flex: 1; width: auto; }
.filter-panel-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.filter-done { padding: 8px 18px; }
@media (max-width: 640px) {
  .filter-row.active.open { grid-template-columns: 1fr; width: calc(100vw - 40px); }
  .filter-row.open .filter-select, .filter-row.open .price-range { width: 100%; min-width: 0; }
}

/* ── Donate dialog (same as the home page) ──────────────────────────────── */
.btn-donate { background: none; border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); color: var(--green); font-family: var(--body); font-size: 0.875rem; font-weight: 500; cursor: pointer; padding: 8px 14px; border-radius: 6px; transition: background .15s, border-color .15s; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-backdrop[hidden] { display: none !important; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; max-width: 440px; width: 100%; position: relative; text-align: center; }
.modal h3 { font-family: var(--display); font-size: 1.4rem; font-weight: 700; color: var(--fg); margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 4px; transition: color .15s; }
.donate-chip { background: var(--bg); border: 1px solid var(--border); color: var(--fg); font-family: var(--body); font-size: 14px; font-weight: 500; padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: border-color .15s, color .15s; font-variant-numeric: tabular-nums; }
.donate-btn-main { width: 100%; background: var(--green); border: none; border-radius: 8px; padding: 12px 20px; font: 600 15px var(--body); color: #fff; cursor: pointer; transition: opacity .15s; margin-bottom: 12px; }
.donate-note-small { font-size: 12px; color: var(--dim); }

/* compare: money columns in green */
.compare-table td.green { color: var(--green); font-weight: 600; }
.compare-table td.above-low { color: var(--accent); font-weight: 600; }
.filter-menu { margin-right: auto; }
.filter-row.open .filter-select { max-width: none; min-width: 0; }
@media (max-width: 580px) { .btn-donate .ext-label { display: none; } }
.panel-meta-line { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel-meta-line a { color: var(--accent); text-decoration: none; }
.panel-meta-line a:hover { text-decoration: underline; }

/* Author / publisher: dropdown with a search box */
.combo { position: relative; min-width: 190px; }
.combo-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.combo-btn .combo-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn::after { content: '▾'; color: var(--muted); font-size: 11px; flex: none; }
.combo-btn.has-value { border-color: var(--accent); }
.combo-pop { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 100%; width: max(100%, 280px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.combo-search { width: 100%; }
.combo-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.combo-list li { padding: 7px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--fg); }
.combo-list li:hover, .combo-list li.active { background: var(--accent-bg); }
.combo-list li[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.combo-list li.partial { font-style: italic; }
.combo-list li.combo-note { cursor: default; color: var(--muted); font-size: 12px; background: none; }
.filter-row.open .combo { width: 100%; min-width: 0; }
@media (max-width: 640px) { .combo-pop { width: 100%; } }

/* Phones: the filter panel spans the search row (not from the Filters button off-screen) */
@media (max-width: 640px) {
  .search-row { position: relative; }
  .filter-menu { position: static; }
  .filter-row.active.open { left: 0; right: 0; width: auto; max-width: 100%; }
  .combo-pop { width: 100%; min-width: 0; }
}

/* ── Select multiple ───────────────────────────────────────────────────── */
.stats-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.select-toggle {
  background: var(--surface); border: 1px solid var(--border); color: var(--fg); border-radius: 8px; padding: 8px 12px;
  font: 500 13px var(--body); cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s;
}
.select-toggle:hover { border-color: var(--accent); color: var(--accent); }
.select-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.book-card { position: relative; }
.book-card.selecting { cursor: pointer; }
.book-card.selected { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-bg); }
.select-box {
  position: absolute; top: 10px; left: 10px; z-index: 3; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.book-card.selected .select-box { border-color: var(--accent); }
.select-box input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.select-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 950;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  width: max-content; max-width: calc(100vw - 24px); padding: 10px 14px; border-radius: 14px;
  background: var(--fg); color: var(--bg); box-shadow: 0 12px 36px rgba(0,0,0,.35);
}
.select-bar[hidden] { display: none; }
.select-count { font-size: 13px; padding: 0 6px; white-space: nowrap; }
.select-btn {
  background: transparent; color: inherit; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); border-radius: 8px;
  padding: 8px 12px; font: 600 13px var(--body); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.select-btn:hover:not(:disabled) { border-color: var(--bg); }
.select-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.select-btn:disabled { opacity: .45; cursor: default; }
/* keep clear of the compare tray and the phone install bar */
body:has(.compare-tray:not([hidden])) .select-bar { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
body:has(.select-bar:not([hidden])) .br-install-bar { display: none; }
@media (max-width: 640px) {
  .select-bar { left: 12px; right: 12px; transform: none; width: auto; max-width: none; }
  .stats-bar { flex-wrap: wrap; gap: 8px; }
}
/* toasts must not cover the selection bar */
body:has(.select-bar:not([hidden])) .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }

/* Description for crawlers only: in the page HTML, not shown to visitors */
.explore-intro { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Shop filter: a multi-select drop-down like the author / publisher ones */
.shop-combo { min-width: 160px; }
.shop-pop { padding: 6px; width: max(100%, 230px); }
.shop-opt { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--fg); cursor: pointer; }
.shop-opt:hover { background: var(--accent-bg); }
.shop-opt input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.shop-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.shop-hint { margin: 4px 10px 6px; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.shop-clear { margin: 0 10px 4px; padding: 0; background: none; border: 0; color: var(--accent); font-size: 12px; cursor: pointer; }
.filter-row.open .shop-combo { width: 100%; min-width: 0; }
