/* ════════════════════════════════════════════════════════════════════
   AniShelf — v2
   Aesthetic: deep warm-black cinema, amber on charcoal, editorial
   typography, grain, soft depth. Mobile-first with graceful scale-up.
   ════════════════════════════════════════════════════════════════════ */

/* ═══════════════════ TOKENS ═══════════════════ */
:root {
  /* ─ Surfaces ─ */
  --bg:         #0A0A0B;
  --bg-1:       #0F0F12;
  --bg-2:       #14141A;
  --surface:    #1A1A21;
  --surface-hi: #23232C;
  --surface-lo: #111115;
  --border:     #26262F;
  --border-hi:  #36363F;

  /* ─ Text ─ */
  --text:       #F5F5F7;
  --text-dim:   #9A9AA8;
  --text-faint: #63636E;

  /* ─ Brand ─ */
  --accent:      #FF6A1A;     /* amber, warmer than CR */
  --accent-hi:   #FF8A3D;
  --accent-dark: #D04E0A;
  --accent-glow: rgba(255,106,26,.20);
  --accent-soft: rgba(255,106,26,.10);

  /* ─ Semantic ─ */
  --cool:    #5CE1E6;          /* secondary cool accent */
  --success: #34D399;
  --danger:  #F43F5E;
  --gold:    #FFCF4E;

  /* ─ Typography ─ */
  --font-display: "Bricolage Grotesque",
                  "Iowan Old Style",
                  "Segoe UI Variable Display",
                  system-ui, sans-serif;
  --font-body:    "Geist",
                  ui-sans-serif, system-ui, -apple-system,
                  "Segoe UI Variable Text", "Segoe UI",
                  sans-serif;
  --font-mono:    ui-monospace, "JetBrains Mono",
                  "SF Mono", Consolas, monospace;

  /* ─ Radius ─ */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* ─ Shadows ─ */
  --sh-1: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
  --sh-2: 0 4px 12px rgba(0,0,0,.35), 0 12px 28px rgba(0,0,0,.35);
  --sh-3: 0 12px 32px rgba(0,0,0,.55), 0 32px 80px rgba(0,0,0,.45);
  --sh-glow: 0 0 0 1px rgba(255,106,26,.30), 0 12px 40px var(--accent-glow);

  /* ─ Motion ─ */
  --ease:    cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --dur-xs: .12s;
  --dur-sm: .2s;
  --dur-md: .35s;
  --dur-lg: .5s;

  /* ─ Layout (mobile defaults; overridden in MQs) ─ */
  --header-h: 56px;
  --filter-h: auto;
  --panel-w:  100vw;
  --gutter:   14px;

  /* ─ Noise overlay (reusable) ─ */
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ═══════════════════ RESET ═══════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  font-feature-settings: "ss01", "cv11";
  -webkit-tap-highlight-color: transparent;
}

/* Ambient background — warm radial pool behind everything, fixed */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 60% at 15% 0%,  rgba(255,106,26,.08), transparent 60%),
    radial-gradient(ellipse 60% 50% at 95% 12%, rgba(92,225,230,.05), transparent 55%),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(255,106,26,.04), transparent 70%),
    var(--bg);
  pointer-events: none;
}
/* Subtle film grain overlay — unified feel */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--noise);
  background-size: 160px 160px;
  opacity: .35;
  mix-blend-mode: overlay;
  pointer-events: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ─ Scrollbar ─ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Reusable selection */
::selection { background: var(--accent); color: #fff; }

/* ═══════════════════ HEADER ═══════════════════ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-h);
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
/* Subtle top glow line */
header::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,106,26,.35) 30%,
    rgba(255,106,26,.35) 70%,
    transparent 100%);
  opacity: .6;
  pointer-events: none;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.035em;
  white-space: nowrap;
  color: var(--text);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity var(--dur-sm) var(--ease);
}
.logo:hover { opacity: 0.82; }
.logo:active { transform: scale(0.97); }
.logo::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  margin-right: 10px;
  box-shadow: 0 0 16px var(--accent-glow);
  flex-shrink: 0;
}
.logo em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
}

.season-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px var(--gutter) 0;
}
.season-row select { flex: 1; min-width: 0; }

/* ─ Tabs ─ */
.tabs {
  order: 4;
  width: 100%;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-lo);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px -2px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
  border: 1px solid var(--border-hi);
}
.tab.active::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 7px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ─ Views ─ */
.view { display: none; }
.view.view-active { display: block; }

.view-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 80px 24px;
  min-height: 50vh;
  max-width: 440px;
  margin: 0 auto;
  color: var(--text-dim);
}
.view-placeholder .ph-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-lo);
  border: 1px solid var(--border);
  color: var(--accent);
  box-shadow: 0 10px 40px -12px var(--accent-glow);
}
.view-placeholder h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.view-placeholder p {
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

/* ═══════════════════ DISCOVER ═══════════════════ */
.discover-search {
  padding: 16px var(--gutter) 6px;
}
.discover-search-inner {
  position: relative;
}
.discover-search svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.discover-search input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 14px 13px 40px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--dur-xs), background-color var(--dur-xs);
}
.discover-search input:hover { border-color: var(--border-hi); }
.discover-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.discover-rails {
  padding: 12px 0 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.discover-rails[hidden],
.discover-results[hidden] { display: none !important; }
.discover-results {
  padding: 12px var(--gutter) 60px;
}
.discover-results .grid { margin-top: 8px; }
.results-hdr { align-items: center; flex-wrap: wrap; }
.results-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-sm) var(--ease);
}
.results-back:hover {
  background: var(--surface-hi);
  color: var(--text);
  border-color: var(--border-hi);
}
.results-back svg { flex-shrink: 0; }

.rail {
  position: relative;
}
.rail-hdr {
  padding: 0 var(--gutter) 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.rail-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0;
}
.rail-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: -2px;
  box-shadow: 0 0 10px var(--accent-glow);
}
.rail-sub {
  font-size: 12px;
  color: var(--text-faint);
}

.rail-scroller {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px var(--gutter) 12px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}
.rail-scroller::-webkit-scrollbar { height: 8px; }
.rail-scroller::-webkit-scrollbar-track { background: transparent; }
.rail-scroller::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 4px;
}
.rail-scroller > .card,
.rail-scroller > .card-skel {
  flex: 0 0 130px;
  width: 130px;
  scroll-snap-align: start;
}
.rail-skel { background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.rail-error {
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.load-more-btn {
  display: block;
  margin: 24px auto 0;
  padding: 11px 28px;
}

/* ═══════════════════ CALENDAR ═══════════════════ */
.cal-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px var(--gutter) 8px;
}
.cal-nav {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  font-family: inherit;
}
.cal-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.cal-week-label {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  flex: 1;
  text-align: center;
  min-width: 0;
}
.cal-today-btn {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-xs) var(--ease);
}
.cal-today-btn:hover:not([disabled]) {
  border-color: var(--accent);
  color: var(--accent);
}
.cal-today-btn[disabled] {
  opacity: .4;
  cursor: default;
}

.cal-hdr {
  flex-wrap: wrap;
  row-gap: 10px;
}
.cal-seerr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.cal-seerr-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-sm) var(--ease), border-color var(--dur-sm) var(--ease);
  flex-shrink: 0;
}
.cal-seerr-toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform var(--dur-sm) var(--ease), background var(--dur-sm) var(--ease);
}
.cal-seerr-toggle input:checked {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cal-seerr-toggle input:checked::after {
  transform: translateX(14px);
  background: var(--accent);
}
.cal-seerr-toggle .toggle-slider { display: none; }
.cal-seerr-toggle:hover .cal-seerr-label { color: var(--text); }

.cal-days {
  padding: 8px var(--gutter) 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.cal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cal-day-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 10px 30px -12px var(--accent-glow);
}
.cal-day-hdr {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-lo);
}
.cal-day-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cal-day-date {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.cal-today-badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--r-xs);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cal-day-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.cal-day-list { padding: 6px 0; }
.cal-day-empty {
  padding: 18px 16px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}
.cal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background var(--dur-xs) var(--ease);
  position: relative;
}
.cal-row:hover { background: var(--accent-soft); }
.cal-row.cal-aired { opacity: .55; }
.cal-poster {
  width: 42px;
  height: 60px;
  border-radius: var(--r-xs);
  object-fit: cover;
  background: var(--surface-lo);
  flex-shrink: 0;
}
.cal-info {
  flex: 1;
  min-width: 0;
}
.cal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.cal-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.cal-dot-upcoming,
.cal-dot-aired {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-dot-upcoming {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52,211,153,.5);
}
.cal-dot-aired {
  background: var(--text-faint);
}

select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 32px 9px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%239A9AA8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--dur-xs), background-color var(--dur-xs);
  flex: 1;
  min-width: 0;
}
select:hover  { border-color: var(--border-hi); }
select:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-wrap {
  order: 2;
  position: relative;
  flex: 1;
  min-width: 0;
}
.search-wrap svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px 10px 36px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--dur-xs), background-color var(--dur-xs);
  font-family: inherit;
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:hover { border-color: var(--border-hi); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hdr-right { order: 3; margin-left: auto; display: flex; gap: 8px; }

/* ─ Buttons ─ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover {
  background: var(--accent-hi);
  box-shadow: 0 10px 28px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.25);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Icon-only button on narrow screens */
@media (max-width: 559px) {
  .hdr-right .btn-label { display: none; }
  .hdr-right .btn {
    padding: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
  }
}

/* ═══════════════════ FILTERS ═══════════════════ */
.actions-bar {
  position: relative;
  padding: 11px var(--gutter);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg) 100%);
  min-width: 0;
}

/* ─ Sort block (lives inside .actions-bar) ─ */
.sort-block {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ─ Filter trigger button ─ */
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}
.filter-trigger:hover {
  border-color: var(--border-hi);
  transform: translateY(-1px);
}
.filter-trigger.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.filter-trigger svg { color: currentColor; }
.filter-count {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.filter-trigger.active .filter-count {
  background: var(--accent);
  color: #fff;
}

/* ─ Active filter pills ─ */
.filter-pills {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1;
  padding: 2px 0;
  scroll-snap-type: x proximity;
}
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pills:empty { display: none; }

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(255,106,26,.35);
  border-radius: var(--r-pill);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  animation: pillIn var(--dur-sm) var(--ease);
}
@keyframes pillIn {
  from { transform: scale(.85); opacity: 0; }
}
.filter-pill .pill-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,106,26,.18);
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-xs);
  border: none;
  padding: 0;
  font-family: inherit;
}
.filter-pill .pill-x:hover {
  background: var(--accent);
  color: #fff;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--r-pill);
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  white-space: nowrap;
  user-select: none;
  font-family: inherit;
}
.chip:hover {
  border-color: var(--border-hi);
  color: var(--text);
  transform: translateY(-1px);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px -4px var(--accent-glow);
}

/* ═══════════════════ FILTER SHEET ═══════════════════ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(6px);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-md) var(--ease);
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.filter-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 190;
  background: var(--bg-2);
  border-top: 1px solid var(--border-hi);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-3);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--dur-md) var(--ease), visibility 0s linear var(--dur-md);
  padding-bottom: env(safe-area-inset-bottom);
  pointer-events: none;
  visibility: hidden;
}
.filter-sheet.open {
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition: transform var(--dur-md) var(--ease), visibility 0s linear 0s;
}

.filter-sheet-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-sheet-hdr h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.filter-sheet-body {
  padding: 18px 20px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

.filter-group { margin-bottom: 22px; }
.filter-group:last-child { margin-bottom: 8px; }
.filter-group-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.filter-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.filter-sheet-ftr {
  display: flex;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.filter-sheet-ftr .btn {
  flex: 1;
  justify-content: center;
  padding: 12px 16px;
}

/* Mobile bottom sheet keeps above styles as-is. */
/* Desktop: centered modal instead of bottom sheet */
@media (min-width: 768px) {
  .filter-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: 520px;
    max-width: calc(100vw - 32px);
    max-height: 80vh;
    border: 1px solid var(--border-hi);
    border-radius: var(--r-lg);
    transform: translate(-50%, -50%) scale(.96);
    opacity: 0;
    transition: transform var(--dur-md) var(--ease), opacity var(--dur-md) var(--ease), visibility 0s linear var(--dur-md);
  }
  .filter-sheet.open {
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: transform var(--dur-md) var(--ease), opacity var(--dur-md) var(--ease), visibility 0s linear 0s;
  }
  .filter-sheet .p-grab { display: none; }
}

/* ═══════════════════ SORT ═══════════════════ */
.sort-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
  flex-shrink: 0;
}

.sort-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.sort-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--r-pill);
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
  user-select: none;
  font-family: inherit;
}
.sort-chip:hover { border-color: var(--border-hi); color: var(--text); }
.sort-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════ CONTENT ═══════════════════ */
.content {
  min-width: 0;
  padding: 20px var(--gutter) 60px;
  transition: margin-right var(--dur-md) var(--ease);
}

.section-hdr {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.section-hdr::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 48px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-pill);
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 4.5vw, 32px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
}
.count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0;
}

/* ═══════════════════ GRID ═══════════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ═══════════════════ CARD ═══════════════════ */
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition:
    transform var(--dur-sm) var(--ease),
    border-color var(--dur-sm) var(--ease),
    box-shadow var(--dur-sm) var(--ease);
  animation: cardIn var(--dur-md) var(--ease) both;
  will-change: transform;
}
/* Stagger reveal */
.card:nth-child(1)  { animation-delay: .00s; }
.card:nth-child(2)  { animation-delay: .04s; }
.card:nth-child(3)  { animation-delay: .08s; }
.card:nth-child(4)  { animation-delay: .12s; }
.card:nth-child(5)  { animation-delay: .16s; }
.card:nth-child(6)  { animation-delay: .20s; }
.card:nth-child(7)  { animation-delay: .24s; }
.card:nth-child(8)  { animation-delay: .28s; }
.card:nth-child(9)  { animation-delay: .32s; }
.card:nth-child(10) { animation-delay: .36s; }
.card:nth-child(n+11) { animation-delay: .40s; }

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--sh-glow), var(--sh-2);
  transform: translateY(-4px);
}
.card:hover .card-poster { transform: scale(1.06); }

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--surface-lo);
  transition: transform var(--dur-md) var(--ease);
}

.card-overlay {
  position: absolute;
  inset: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  background: linear-gradient(
    to top,
    rgba(0,0,0,.96) 0%,
    rgba(0,0,0,.78) 28%,
    rgba(0,0,0,.35) 56%,
    transparent 78%
  );
  opacity: 0;
  transition: opacity var(--dur-sm) var(--ease);
}
.card:hover .card-overlay { opacity: 1; }
/* On touch devices, show overlay always (tap instead of hover) */
@media (hover: none) and (min-width: 768px) {
  .card-overlay { opacity: 1; background: linear-gradient(to top, rgba(0,0,0,.92), rgba(0,0,0,.55) 40%, transparent 70%); }
}

.overlay-genres {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
}
@media (min-width: 768px) {
  .overlay-genres { display: flex; }
}
.gtag {
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  color: #fff;
  border-radius: var(--r-xs);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255,255,255,.12);
}

.req-btn {
  display: none;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.005em;
  cursor: pointer;
  width: 100%;
  transition: all var(--dur-xs) var(--ease);
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 14px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.18);
  font-family: inherit;
}
.req-btn:hover  { background: var(--accent-hi); transform: translateY(-1px); }
.req-btn:active { transform: scale(.97); }
.req-btn.in-lib {
  background: var(--success);
  color: #032820;
  cursor: default;
  box-shadow: none;
}
.req-btn.done {
  background: color-mix(in srgb, var(--success) 85%, #000);
  color: #032820;
  cursor: default;
  box-shadow: none;
}
.req-btn.busy {
  opacity: .75;
  cursor: wait;
}

/* ─ Card badges ─ */
.card-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.badge {
  border-radius: var(--r-xs);
  padding: 2px 5px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.10);
}
.b-lib { background: rgba(52,211,153,.85); color: #022C1D; border-color: rgba(52,211,153,.50); }
.b-air { background: rgba(244,63,94,.85);  color: #fff;     border-color: rgba(244,63,94,.50); }
.b-fmt { background: rgba(0,0,0,.72);      color: #E2E2E8;  border-color: rgba(255,255,255,.14); }

.score-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  background: rgba(0,0,0,.78);
  color: var(--gold);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.005em;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,207,78,.25);
  font-family: var(--font-mono);
}

/* ─ Card info footer ─ */
.card-info { padding: 7px 8px 8px; }
.card-title {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 3px;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.dot.airing {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52,211,153,.6);
}
.dot.upcoming {
  background: var(--cool);
  box-shadow: 0 0 8px rgba(92,225,230,.5);
}

/* ═══════════════════ DETAIL PANEL ═══════════════════ */
/* Mobile default: bottom sheet */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-md) var(--ease);
}
.panel-backdrop.open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  max-height: 88vh;
  background: var(--bg-2);
  border-top: 1px solid var(--border-hi);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-3);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 150;
  transform: translateY(100%);
  transition: transform var(--dur-md) var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.panel.open { transform: none; }

/* Grab handle (mobile only) */
.p-grab {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 9px 0 4px;
  background: linear-gradient(to bottom, var(--bg-2) 70%, transparent);
}
.p-grab::before {
  content: '';
  display: block;
  width: 42px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border-hi);
}

.p-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all var(--dur-xs) var(--ease);
}
.p-close:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: rotate(90deg);
}

.p-banner {
  width: 100%;
  aspect-ratio: 16/7;
  max-height: 240px;
  object-fit: cover;
  display: block;
  background: var(--surface-lo);
}
.p-banner-ph {
  width: 100%;
  aspect-ratio: 16/7;
  max-height: 240px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,106,26,.18), transparent 55%),
    linear-gradient(135deg, #1a1520 0%, #0a0a0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  opacity: .6;
}

.p-body {
  padding: 18px 18px 24px;
}

.p-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 4px;
  color: var(--text);
}
.p-sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 14px;
  font-style: italic;
  letter-spacing: 0;
}

.p-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
}
.p-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ─ Stat grid ─ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 13px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--dur-sm);
}
.stat:hover::before { opacity: 1; }
.stat-l {
  font-family: var(--font-display);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 3px;
  font-weight: 700;
}
.stat-v {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ─ Countdown ─ */
.countdown {
  background:
    linear-gradient(135deg, rgba(255,106,26,.14), rgba(255,106,26,.03)),
    var(--surface);
  border: 1px solid rgba(255,106,26,.28);
  border-radius: var(--r-md);
  padding: 13px 15px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.countdown::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(90deg, transparent, rgba(255,106,26,.18), transparent);
  animation: sweep 3.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sweep {
  0%, 100% { transform: translateX(-100%); }
  50%      { transform: translateX(100%); }
}
.countdown-l {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 3px;
  font-weight: 700;
}
.countdown-v {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

/* ─ Synopsis ─ */
.synopsis {
  font-size: 13px;
  line-height: 1.72;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.synopsis.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.syn-toggle {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 0;
  margin-bottom: 16px;
  cursor: pointer;
  transition: color var(--dur-xs);
  font-family: inherit;
}
.syn-toggle:hover { color: var(--accent-hi); }

/* ─ Panel actions ─ */
.p-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trailer-btn {
  background: rgba(244,63,94,.14);
  color: #FFB5C2;
  border: 1px solid rgba(244,63,94,.35);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--dur-xs) var(--ease);
}
.trailer-btn:hover {
  background: rgba(244,63,94,.22);
  border-color: var(--danger);
  color: #fff;
}
.req-btn-lg {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--dur-xs) var(--ease);
  box-shadow: 0 8px 24px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.2);
  font-family: inherit;
  letter-spacing: -0.005em;
}
.req-btn-lg:hover {
  background: var(--accent-hi);
  transform: translateY(-1px);
  box-shadow: 0 14px 32px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.28);
}
.req-btn-lg:active { transform: scale(.98); }
.req-btn-lg.in-lib,
.req-btn-lg.done {
  background: var(--success);
  color: #022C1D;
  box-shadow: none;
  cursor: default;
}
.req-btn-lg[disabled] { opacity: .75; cursor: default; }

/* ═══════════════════ SEASON PICKER (detail panel) ═══════════════════ */
.season-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.sp-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.sp-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}
.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-lo);
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    border-color var(--dur-xs) var(--ease),
    background var(--dur-xs) var(--ease);
  font-size: 13px;
}
.sp-row:hover:not(.sp-disabled) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-lo));
}
.sp-row:has(.sp-check:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-lo));
}
.sp-disabled {
  opacity: .55;
  cursor: not-allowed;
}
.sp-check {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-hi);
  background: var(--bg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--dur-xs) var(--ease);
}
.sp-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.sp-check:checked::after {
  content: '';
  width: 8px;
  height: 8px;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.sp-check:disabled { cursor: not-allowed; }
.sp-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.sp-tag {
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.sp-tag-5 { background: rgba(52,211,153,.18); color: var(--success); border-color: rgba(52,211,153,.35); }
.sp-tag-2,
.sp-tag-3 { background: rgba(255,207,78,.14); color: var(--gold); border-color: rgba(255,207,78,.30); }
.sp-tag-4 { background: rgba(96,165,250,.16); color: var(--cool); border-color: rgba(96,165,250,.32); }

/* ═══════════════════ SETTINGS MODAL ═══════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay.open { display: flex; animation: fadeIn var(--dur-md) var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  padding: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-3);
  animation: modalIn var(--dur-md) var(--ease);
}
@keyframes modalIn {
  from { transform: translateY(16px) scale(.98); opacity: 0; }
}

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-hdr h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-x {
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur-xs);
}
.modal-x:hover { color: var(--text); background: var(--surface); }

.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.cfg-section-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.conn-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.conn-item-left { display: flex; align-items: center; gap: 12px; }
.conn-item-name { font-size: 13px; font-weight: 600; }
.conn-item-detail { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-faint);
  transition: all var(--dur-sm);
}
.conn-dot.ok  { background: var(--success); box-shadow: 0 0 10px rgba(52,211,153,.55); }
.conn-dot.err { background: var(--danger);  box-shadow: 0 0 10px rgba(244,63,94,.55);  }
.conn-dot.spin {
  background: transparent;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.6;
}
.hint code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ─ Preferences ─ */
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.pref-label { font-size: 13px; font-weight: 600; display: block; }
.pref-desc  { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* ─ Toggle switch ─ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  transition: all var(--dur-sm) var(--ease);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  bottom: 3px;
  left: 3px;
  transition: all var(--dur-sm) var(--ease);
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* ═══════════════════ TOASTS ═══════════════════ */
.toasts {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  right: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
  pointer-events: none;
  align-items: flex-end;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: tIn var(--dur-md) var(--ease);
  box-shadow: var(--sh-2);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes tIn  { from { transform: translateY(20px); opacity: 0; } }
@keyframes tOut { to   { transform: translateY(20px); opacity: 0; } }

/* ═══════════════════ STATES ═══════════════════ */
.loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 18px;
  color: var(--text-faint);
  font-size: 13px;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
  font-size: 14px;
}
.empty-icon { font-size: 52px; margin-bottom: 14px; opacity: .5; }

/* ─ Skeleton cards ─ */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  background: linear-gradient(90deg,
    var(--surface) 25%, var(--surface-hi) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--r-xs);
}
.card-skel {
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  pointer-events: none;
}
.skel-poster { width: 100%; aspect-ratio: 2/3; }
.skel-info { padding: 10px 12px 13px; display: flex; flex-direction: column; gap: 7px; }
.skel-title  { height: 12px; width: 85%; }
.skel-title2 { height: 12px; width: 55%; }
.skel-meta   { height: 10px; width: 45%; }

.load-progress {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 8px;
  margin-top: -8px;
  font-family: var(--font-mono);
}

/* ═══════════════════ BACK TO TOP ═══════════════════ */
#backTop {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  width: 44px;
  height: 44px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-dim);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all var(--dur-md) var(--ease);
  z-index: 80;
  box-shadow: var(--sh-1);
  backdrop-filter: blur(8px);
}
#backTop.visible { opacity: 1; pointer-events: auto; transform: none; }
#backTop:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -6px var(--accent-glow);
}

/* ─ FR source badge ─ */
.kitsu-loading {
  display: inline-block;
  width: 80px;
  height: 14px;
  vertical-align: middle;
  border-radius: var(--r-xs);
  margin-left: 8px;
}
.kitsu-src {
  font-family: var(--font-display);
  font-size: 9px;
  background: var(--accent-soft);
  border: 1px solid rgba(255,106,26,.35);
  color: var(--accent);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  margin-left: 8px;
  vertical-align: middle;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ═══════════════════ RESPONSIVE — small tablets ═══════════════════ */
@media (min-width: 560px) {
  :root { --gutter: 18px; }
  .grid { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .tabs { order: 2; width: auto; }
  .search-wrap { order: 3; max-width: 260px; flex: 1; }
  .hdr-right { order: 4; }
  select { flex: 0 1 auto; min-width: 110px; }
}

/* ═══════════════════ RESPONSIVE — tablets ═══════════════════ */
@media (min-width: 768px) {
  :root { --gutter: 22px; --header-h: 62px; }
  .grid { grid-template-columns: repeat(5, 1fr); gap: 16px; }
  .card-info { padding: 11px 13px 13px; }
  .card-title { font-size: 13px; }
  .card-meta { font-size: 11px; gap: 6px; }
  .req-btn { display: block; padding: 9px 10px; font-size: 12px; }
  .badge { padding: 3px 7px; font-size: 9px; }
  .score-badge { padding: 3px 8px; font-size: 11px; top: 8px; right: 8px; }
  .card-badges { top: 8px; left: 8px; }
  .section-title { font-size: 28px; }
  .p-body { padding: 22px 24px 28px; }
  .p-title { font-size: 26px; }
}

/* ═══════════════════ RESPONSIVE — desktop: side drawer ═══════════════════ */
@media (min-width: 1024px) {
  :root {
    --gutter: 28px;
    --panel-w: 460px;
  }
  .grid { grid-template-columns: repeat(6, 1fr); gap: 18px; }

  /* Content shifts to make room for side drawer */
  .content.shifted { margin-right: var(--panel-w); }

  /* Panel becomes a right-side drawer */
  .panel {
    left: auto;
    right: 0;
    top: var(--header-h);
    bottom: 0;
    width: var(--panel-w);
    max-height: none;
    height: calc(100vh - var(--header-h));
    border-top: none;
    border-left: 1px solid var(--border-hi);
    border-radius: 0;
    transform: translateX(100%);
    z-index: 90;
  }
  .panel.open { transform: none; }
  .panel-backdrop { display: none; }
  .p-grab { display: none; }
  .p-banner,
  .p-banner-ph { max-height: 200px; }
}

/* ═══════════════════ RESPONSIVE — wide ═══════════════════ */
@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(7, 1fr); }
}
@media (min-width: 1600px) {
  .grid { grid-template-columns: repeat(8, 1fr); }
}

/* ═══════════════════ REDUCED MOTION ═══════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════ FOCUS RINGS ═══════════════════ */
button:focus-visible,
select:focus-visible,
input:focus-visible,
.chip:focus-visible,
.sort-chip:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
