/* ══════════════════════════════════════════════════════════════════════════
   Design tokens — dark is the default; [data-theme="light"] overrides below.
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;

  --radius: 10px;
  --radius-sm: 8px;

  /* Page-wide horizontal inset + tile gap — kept in sync so header/context-bar/
     grid all share one edge (ixxx.com/popular-style near-full-bleed density). */
  --page-pad-x: 8px;
  --grid-gap: 8px;

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #050505;
  --bg-sunken: #000000;
  --bg-elevated: #0a0a0a;
  --surface: #0a0a0a;
  --surface-2: #111112;
  --surface-hover: #18181a;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --muted-overlay: rgba(255, 255, 255, 0.05);

  --text: #f2f2f2;
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-muted: rgba(255, 255, 255, 0.42);
  --text-faint: rgba(255, 255, 255, 0.26);

  --accent: #dc2626;
  --accent-2: #ef4444;
  --accent-strong: #b91c1c;
  --accent-soft: rgba(220, 38, 38, 0.16);
  --accent-on: #ffffff;

  --rating-red: #f87171;
  --rating-orange: #fb923c;
  --rating-green: #4ade80;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 4px 14px rgba(220, 38, 38, 0.4);

  --header-bg: rgba(5, 5, 5, 0.9);
}

[data-theme='light'] {
  color-scheme: light;

  --bg: #fafafa;
  --bg-sunken: #f0f0f0;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --surface-hover: #e9e9e9;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);
  --muted-overlay: rgba(0, 0, 0, 0.04);

  --text: #0a0a0a;
  --text-secondary: rgba(10, 10, 10, 0.65);
  --text-muted: rgba(10, 10, 10, 0.45);
  --text-faint: rgba(10, 10, 10, 0.28);

  --accent: #dc2626;
  --accent-2: #b91c1c;
  --accent-strong: #991b1b;
  --accent-soft: rgba(220, 38, 38, 0.1);
  --accent-on: #ffffff;

  --rating-red: #dc2626;
  --rating-orange: #d97706;
  --rating-green: #16a34a;

  --shadow-sm: 0 2px 8px rgba(10, 10, 10, 0.06);
  --shadow-md: 0 8px 24px rgba(10, 10, 10, 0.1);
  --shadow-lg: 0 16px 48px rgba(10, 10, 10, 0.14);
  --shadow-glow: 0 4px 14px rgba(220, 38, 38, 0.2);

  --header-bg: rgba(250, 250, 250, 0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── Header tools (browse switch + theme) ──────────────────────────────── */
.header-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  margin-left: 0.15rem;
}

.browse-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  position: relative;
}

.browse-switch-cap {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

.browse-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.browse-switch-track {
  position: relative;
  width: 1.7rem;
  height: 0.92rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.browse-switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 0.16s ease, background 0.15s;
}

.browse-switch input:checked + .browse-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.browse-switch input:checked + .browse-switch-track .browse-switch-thumb {
  transform: translateX(0.76rem);
  background: #fff;
}

.browse-switch input:focus-visible + .browse-switch-track {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.browse-switch:not(:has(input:checked)) .browse-switch-cap:first-child,
.browse-switch:has(input:checked) .browse-switch-cap:last-child {
  color: var(--text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle:active { transform: scale(0.92); }

.theme-toggle svg { width: 1.1rem; height: 1.1rem; }

.theme-toggle .icon-moon { display: none; }

[data-theme='light'] .theme-toggle .icon-sun { display: none; }
[data-theme='light'] .theme-toggle .icon-moon { display: block; }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  height: 4.5rem;
  padding: 0 var(--page-pad-x);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
  transition: transform 0.28s ease;
}

header.header-hidden,
.legal-header.header-hidden {
  transform: translateY(-100%);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Brand mark — small accent square + serif wordmark, per the XFinder brand spec */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
  user-select: none;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #000;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glow);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Main nav — Categories / Channels / Pornstars; vertically centered with brand */
.main-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex-shrink: 0;
  height: 2rem; /* match .brand-mark so links share the brand's vertical center */
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0;
  border: none;
  position: relative;
  transition: color 0.15s;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); }
.nav-link.active::after { background: var(--accent); }

/* Search bar — occupies the slot where template action buttons would sit */
.search-wrap {
  flex: 1;
  min-width: 0;
  max-width: 32rem;
  margin-left: auto;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin: 0;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-row input {
  width: 100%;
  min-width: 0;
  min-height: 2rem;
  padding: 0.35rem 2.1rem 0.35rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.search-row input::-webkit-search-cancel-button,
.search-row input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-row input::placeholder { color: var(--text-muted); }

.search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 0.28rem;
  transform: translateY(-50%);
  width: 1.85rem;
  height: 1.85rem;
  min-width: 1.85rem;
  min-height: 1.85rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--muted-overlay);
  color: var(--text);
}

.search-clear.hidden { display: none; }

#search-btn {
  min-height: 2rem;
  padding: 0.35rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-glow);
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

#search-btn:hover   { background: var(--accent-2); }
#search-btn:active  { transform: scale(0.97); }

.search-stats {
  margin-top: 0.35rem;
  min-height: 1.05em;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#crawl-btn { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
#crawl-btn:hover { background: var(--surface-hover); }
#crawl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#stop-btn { background: #3a1414; color: #fca5a5; border: 1px solid #5c1f1f; }
#stop-btn:hover { background: #4a1a1a; color: #fff; }
#stop-btn.hidden { display: none; }

/* ── Context bar — filter banner + ranking filters, sits below (not part of) the header ── */
.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  padding: 0 var(--page-pad-x);
  position: relative;
  z-index: 25;
  overflow: visible;
}

.crawl-status {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.crawl-status.hidden { display: none; }

.progress-bar {
  margin-top: 0.3rem;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.4s ease;
}

main { padding: 1rem var(--page-pad-x); }

/* Crawlable H1 for Bing/Google — not shown in the layout (no intro dump). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.card {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  border: 1px solid transparent;
}

[data-theme='light'] .card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme='light'] .card img,
[data-theme='light'] .card.skeleton .thumb-wrap {
  background: var(--surface-2);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card img {
  width: 100%;
  height: auto; /* override HTML height attr so aspect-ratio takes effect */
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #000;
  display: block;
}

.card.skeleton {
  pointer-events: none;
}
.card.skeleton .thumb-wrap {
  aspect-ratio: 16/9;
  background: #000;
}
.card.skeleton .card-title,
.card.skeleton .card-meta {
  min-height: 1em;
}

/* ── Thumbnail overlay ───────────────────────────────────────────────────── */
.thumb-wrap {
  position: relative;
}

.badge {
  position: absolute;
  border-radius: 4px;
  backdrop-filter: blur(2px);
  white-space: nowrap;
}

/* Rating badge — bottom-left (fixed dark chip: sits on arbitrary thumbnails, not themed) */
.badge-rating.item-score {
  bottom: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.65);
}
.badge-rating .rating-thumb {
  width: 0.9em;
  height: 0.9em;
  display: block;
  flex-shrink: 0;
}
.rating-red    { color: var(--rating-red); }
.rating-orange { color: var(--rating-orange); }
.rating-green  { color: var(--rating-green); }
.rating-orange .rating-thumb { transform: rotate(90deg); }
.rating-red .rating-thumb    { transform: rotate(180deg); }

/* Duration badge — bottom-right, zinc pill style (also fixed, overlays media) */
.badge-duration {
  bottom: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(39, 39, 42, 0.82);
  color: #f4f4f5;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.01em;
}
.badge-quality {
  font-size: 0.62rem;
  font-weight: 800;
  color: #ff9a66;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Card text area ──────────────────────────────────────────────────────── */
.card-title {
  padding: 0.35rem 0.55rem 0.08rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme='light'] .card-title {
  color: var(--text);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.55rem 0.35rem;
  font-size: 0.7rem;
  gap: 0.4rem;
  white-space: nowrap;
}

.card-site {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-site.has-alts {
  cursor: pointer;
  user-select: none;
}
.card-site.has-alts:hover { color: var(--accent, #a78bfa); }

/* Infinite scroll sentinel */
#scroll-sentinel { height: 1px; }
#scroll-sentinel.hidden { display: none; }
#scroll-sentinel.loading::after {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 2rem auto;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent, #a78bfa);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card-ago {
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.empty {
  color: var(--text-faint);
  font-size: 0.95rem;
  padding: 2rem 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 0 3rem;
}

.pagination.hidden { display: none; }

.page-nav {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.5rem;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-sm);
}

.page-nav:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.page-nav[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.page-label {
  color: var(--text-faint);
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 7.5rem;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  #grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root {
    --page-pad-x: 6px;
    --grid-gap: 4px;
  }
  header { height: auto; padding: 0.85rem var(--page-pad-x); }
  .header-inner { flex-wrap: wrap; gap: 0.65rem; }
  .brand { order: 1; }
  .header-tools { order: 2; margin-left: auto; }
  .main-nav { order: 3; flex: 1 1 100%; gap: 1.1rem; }
  .search-wrap { order: 4; flex: 1 1 100%; max-width: none; margin-left: 0; }
  .context-bar { padding: 0 var(--page-pad-x); }
  #grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  main { padding: 0.5rem var(--page-pad-x); }

  #grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap);
  }

  .card-title {
    font-size: 0.72rem;
    padding: 0.28rem 0.4rem 0.04rem;
  }

  .card-meta {
    font-size: 0.62rem;
    padding: 0 0.4rem 0.28rem;
  }

  .search-row input  { font-size: 1rem; } /* 16px minimum prevents iOS Safari auto-zoom */
  #search-btn { font-size: 0.72rem; padding: 0.55rem 0.85rem; min-height: 44px; }
  .search-row input { min-height: 44px; }
  .search-clear { width: 2.4rem; height: 2.4rem; min-width: 2.4rem; min-height: 2.4rem; }
  .nav-select { min-height: 48px; }
  .theme-toggle { min-width: 36px; min-height: 36px; width: 36px; height: 36px; }
  .filters-panel { left: 0; right: 0; width: auto; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--grid-gap); }
}

/* ── Pornstar / Channel directories (single-page A-Z list, no images) ───── */
#pornstar-directory.hidden { display: none; }
#channel-directory.hidden  { display: none; }
#grid.hidden                { display: none; }

.pstar-letters {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  padding: 0.6rem 0;
  margin-bottom: 1rem;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.pstar-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pstar-letter:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.pstar-letter--empty {
  color: var(--text-faint);
  background: transparent;
  border-color: transparent;
}

.pstar-section { padding-top: 0.5rem; margin-bottom: 1.75rem; scroll-margin-top: 4rem; }

.pstar-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.pstar-section-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.35rem 1rem;
}

.pstar-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.25rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.1s;
}

.pstar-link:hover { color: var(--accent); text-decoration: underline; }

.pstar-empty {
  color: var(--text-faint);
  font-size: 0.95rem;
  padding: 2rem 0;
}

@media (max-width: 600px) {
  .pstar-section-list { grid-template-columns: repeat(2, 1fr); }
  .pstar-letter { min-width: 1.5rem; height: 1.5rem; font-size: 0.72rem; }
}

/* ── Categories grid (single page, top-50, configurable images) ─────────── */
#category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--grid-gap);
}

#category-grid.hidden { display: none; }

.category-card {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.category-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.category-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.8rem 0.8rem 0.6rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.88));
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  #category-grid { grid-template-columns: repeat(2, 1fr); gap: var(--grid-gap); }
}

/* ── Dropdown selects (Duration inside the filters panel) ── */
.nav-select {
  appearance: none;
  min-width: 140px;
  min-height: 44px;
  padding: 0.5rem 2.2rem 0.5rem 0.75rem;
  background: var(--surface-2);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 52%,
    calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.nav-select:hover,
.nav-select:focus {
  background-color: var(--surface-hover);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 52%,
    calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text);
  border-color: var(--accent);
}

.nav-select option { background: var(--surface-2); color: var(--text); }

/* ── Filter banner — "currently viewing X", lives in the context bar ───── */
.filter-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 0 0.6rem;
  flex: 1 1 auto;
  min-width: 0;
}

.filter-banner.hidden { display: none; }

.filter-icon { color: var(--text-faint); font-size: 0.78rem; }

#filter-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ── Filters bar — ranking + duration filters, only shown for an active query ── */
.filters-bar {
  padding: 0.6rem 0 0.9rem;
  flex: 0 0 auto;
  overflow: visible;
  margin-left: auto;
}

.filters-bar.hidden { display: none; }

.filters-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filters-toggle:hover,
.filters-toggle[aria-expanded='true'] {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.filters-toggle svg { color: var(--accent); flex-shrink: 0; }

.filters-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.15rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}

.filters-count.hidden { display: none; }

.filter-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s, background 0.15s;
  line-height: 1;
}

.filter-clear:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.filters-panel {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  left: auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(360px, 100%);
  min-width: 0;
  max-width: 100%;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  box-sizing: border-box;
}

.filters-panel.hidden { display: none; }

.filters-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filters-group-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.filters-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-option {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-option:hover { color: var(--text); border-color: var(--border-strong); }

.filter-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.filters-group .nav-select {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-faint);
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 2.2rem;
}

.filters-group .nav-select:not([data-empty='1']) {
  color: var(--text-secondary);
  text-align: left;
}

/* ── Site footer (present on every page) ────────────────────────────────── */
.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  background:
    radial-gradient(ellipse 900px 260px at 15% 0%, var(--accent-soft), transparent 70%),
    var(--bg-sunken);
  padding: 3rem 2rem 1.5rem;
}

.footer-browse {
  max-width: 1100px;
  margin: 0 auto 2.25rem;
}
.footer-browse-hubs {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.45rem 1.25rem;
  margin-bottom: 0.85rem;
}
.footer-browse-hubs a { font-weight: 600; color: var(--text); }
.footer-cat-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}
.footer-cat-list a { font-size: 0.82rem; }

.footer-inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 2.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.footer-logo { align-self: flex-start; }

.footer-tagline {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 30ch;
}

.rta-badge {
  display: inline-block;
  align-self: flex-start;
  line-height: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  opacity: 0.92;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.rta-badge:hover { opacity: 1; box-shadow: var(--shadow-md); }

.rta-badge img { display: block; width: 132px; height: auto; }

.footer-rta-note {
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--text-faint);
  max-width: 34ch;
}

.footer-heading {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s, padding-left 0.15s;
}

.footer-links a:hover { color: var(--accent); padding-left: 3px; }

.footer-bottom {
  max-width: 1100px;
  margin: 2.5rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.footer-disclaimer { color: var(--text-faint); text-align: right; }

@media (max-width: 700px) {
  .footer-inner { grid-template-columns: 1fr; gap: 2rem; }
  .site-footer { padding: 2.25rem 1.25rem 1.25rem; }
  .footer-tagline, .footer-rta-note { max-width: none; }
  .footer-bottom { flex-direction: column; }
  .footer-disclaimer { text-align: left; }
}

/* ── Static legal/support pages ──────────────────────────────────────────── */
.legal-header {
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.legal-header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.legal-back {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-right: auto;
}

.legal-back:hover { color: var(--text); }

.legal-page { padding: 2.5rem 2rem 1rem; }

.legal-content {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.7;
  color: var(--text-secondary);
}

.legal-content h1 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.legal-updated {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 2rem;
}

.legal-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin: 1.75rem 0 0.65rem;
}

.legal-content h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.1rem 0 0.5rem;
}

.legal-content p { margin-bottom: 0.9rem; font-size: 0.94rem; }

.legal-content ul,
.legal-content ol {
  margin: 0 0 0.9rem 1.4rem;
  font-size: 0.94rem;
}

.legal-content li { margin-bottom: 0.4rem; }

.legal-content a { color: var(--accent-2); text-decoration: none; }
.legal-content a:hover { text-decoration: underline; }

.legal-content strong { color: var(--text); }

.legal-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.legal-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.legal-toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}

.legal-toc ol {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.86rem;
}

.legal-toc a { color: var(--text-secondary); }
.legal-toc a:hover { color: var(--accent); }

.faq-item { margin-bottom: 1.5rem; }
.faq-q {
  font-weight: 700;
  color: var(--text);
  font-size: 0.98rem;
  margin-bottom: 0.35rem;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.contact-card h3 { margin-top: 0; }

@media (max-width: 600px) {
  .legal-header { padding: 0.85rem 1rem; }
  .legal-page { padding: 1.75rem 1rem 1rem; }
}
