:root {
  --bg: #000000;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.11);
  --text: #ffffff;
  --text-dim: #9a9a9a;
  --accent: #ffd400;
  --accent-text: #ffd400;
  --accent2: #4f8fa6;
  --watched: #2ecc71;
  --ended: #7d8794; /* muted slate — "ended" is passive/informational, doesn't need a vivid hue */
  --canceled: #e5484d;
  --dnf: #6b6b6b;
  --border: rgba(255, 255, 255, 0.14);
  --track: rgba(255, 255, 255, 0.15); /* progress-bar background track */
  --glass-highlight: rgba(255, 255, 255, 0.28); /* specular edge catch on glass panels */
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --glass-blur: blur(22px) saturate(130%);
  /* The top bar and bottom tab bar sit over scrolling poster art of any color — they need to stay
     legible no matter what's behind them, so they get a much less transparent tint than the rest
     of the glass surfaces (which only ever sit over the ambient background). */
  --nav-glass-bg: rgba(15, 15, 15, 0.82);
}

:root[data-theme="light"] {
  --bg: #eeeeee; /* not pure white — translucent white panels need to read against something */
  --surface: rgba(255, 255, 255, 0.55);
  --surface-2: rgba(255, 255, 255, 0.78);
  --text: #12120f;
  --text-dim: #68675f;
  --accent-text: #8a6d00;
  --accent2: #2c6a80;
  --watched: #1a9850;
  --ended: #5a6472;
  --canceled: #c8353b;
  --dnf: #5f5f5f;
  --border: rgba(0, 0, 0, 0.12);
  --track: rgba(0, 0, 0, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.75);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --nav-glass-bg: rgba(255, 255, 255, 0.86);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Figtree", sans-serif;
  min-height: 100vh;
  overscroll-behavior: none; /* no elastic bounce/pull-to-refresh — feels like a native app, not a web page */
}

/* Soft color underneath everything for the glass panels to catch and refract — Liquid Glass
   needs something behind it, a flat black/white page gives blur nothing to do. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 212, 0, 0.20), transparent 42%),
    radial-gradient(circle at 88% 10%, rgba(79, 143, 166, 0.22), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(46, 204, 113, 0.12), transparent 45%);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 212, 0, 0.30), transparent 42%),
    radial-gradient(circle at 88% 10%, rgba(79, 143, 166, 0.26), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(46, 204, 113, 0.16), transparent 45%);
}

#app {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.mono { font-family: "JetBrains Mono", monospace; }
.display { font-family: "Figtree", sans-serif; font-weight: 800; letter-spacing: -0.01em; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
::selection { background: var(--accent); color: #000; }

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

.skeleton-block {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line { border-radius: 6px; }
.skeleton-card { cursor: default; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -48px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  z-index: 50;
  pointer-events: none;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 24px;
  padding: 10px 16px;
  border-radius: 24px;
  background: var(--nav-glass-bg);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}

.logo {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  cursor: pointer;
}
.logo-icon { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.logo-icon svg { width: 28px; height: 28px; display: block; }
.logo-text {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--text);
}

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

/* .icon-btn is itself `display: flex` for centering its own SVG, which makes it a block-level
   flex container by default — without this, each icon-btn here stacks on its own line instead
   of sitting in a row. */
.topbar-nav { display: flex; align-items: center; gap: 18px; }

.lang-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 16px;
  cursor: pointer;
}
.lang-btn.active { background: var(--accent); color: #000; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); }

/* Tucked behind the gear icon on Profile (see .list-picker-wrap) instead of always taking up
   space in the page flow — same floating-popover positioning as .list-picker. */
.profile-settings {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}
.settings-menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-menu-label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.settings-menu-hint { font-size: 11px; color: var(--text-dim); margin: 0; }

.new-list-row { display: flex; gap: 8px; margin-top: 4px; }
.list-detail-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }

.list-picker-wrap { position: relative; }
.list-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  min-width: 240px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}
.list-picker input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.btn.accent {
  background: var(--accent);
  color: #000;
  font-weight: 800;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 4px 18px rgba(255, 212, 0, 0.25);
}
.btn.ghost { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border); color: var(--text-dim); box-shadow: none; }
.icon-btn { position: relative; background: transparent; border: none; color: var(--text-dim); padding: 6px; display: flex; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.active {
  background: var(--surface-2);
  color: var(--accent-text);
  border-radius: 12px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.filter-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--bg);
}

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

.card { cursor: pointer; }
.poster {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); }
.progress-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--track); }
.progress-fill { height: 100%; background: var(--accent); }
.progress-fill.caught-up { background: var(--watched); }
.progress-fill.ended { background: var(--ended); }
.progress-fill.canceled { background: var(--canceled); }
.progress-fill.dnf { background: var(--dnf); }
.card-title { font-size: 12.5px; font-weight: 600; margin-top: 7px; line-height: 1.3; }
.card-meta { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

/* Badges sit on top of poster art and can appear 100+ times on a grid page — no backdrop-filter
   here, real blur at that scale is a known iOS Safari jank source. Translucency alone still reads as glass. */
.card-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
}
.card-badge.ended { background: var(--ended); border-color: transparent; }
.card-badge.canceled { background: var(--canceled); border-color: transparent; }
.card-badge.caught-up { background: var(--watched); color: #000; border-color: transparent; }
.card-badge.dnf { background: var(--dnf); border-color: transparent; }
.card-badge.upcoming { left: auto; right: 6px; background: var(--accent2); border-color: transparent; }

.upcoming-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: rgba(79, 143, 166, 0.14);
  border: 1px solid rgba(79, 143, 166, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.upcoming-banner svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent2); }

.providers-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.providers-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.provider-logo { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); }
.providers-attribution { font-size: 10px; color: var(--text-dim); text-decoration: none; margin-left: 4px; }
.providers-attribution:hover { text-decoration: underline; }

.cast-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.cast-card { flex: 0 0 90px; text-align: center; display: block; color: inherit; text-decoration: none; }
.cast-photo {
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}
.cast-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-name { font-size: 11px; font-weight: 600; line-height: 1.25; }
.cast-character { font-size: 9.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.3; }

.status-pill {
  display: inline-flex;
  align-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 9px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.status-pill.default { background: rgba(255, 212, 0, 0.14); color: var(--accent-text); }
.status-pill.caught-up { background: rgba(46, 204, 113, 0.14); color: var(--watched); }
.status-pill.ended { background: rgba(125, 135, 148, 0.18); color: var(--ended); }
.status-pill.canceled { background: rgba(229, 72, 77, 0.16); color: var(--canceled); }
.status-pill.dnf { background: var(--surface-2); color: var(--dnf); }
.status-pill.upcoming { background: rgba(79, 143, 166, 0.16); color: var(--accent2); }

.view-toggle {
  display: flex;
  gap: 6px;
}

@keyframes controls-reveal {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.library-search { margin-bottom: 14px; animation: controls-reveal 0.18s ease; }
.filters-panel {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  animation: controls-reveal 0.18s ease;
}
.select-control {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.select-control:focus { outline: none; border-color: var(--accent); }

.calendar-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  flex-shrink: 0;
  text-align: center;
}
.calendar-date-day { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--text-dim); }
.calendar-date-rel { font-size: 9.5px; color: var(--accent-text); font-weight: 700; margin-top: 2px; }

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.calendar-header .profile-title { margin-bottom: 0; }

.calendar-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.calendar-month-label { font-size: 14px; font-weight: 700; text-transform: capitalize; min-width: 140px; text-align: center; }

.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-days-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-weekday {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  padding-bottom: 6px;
}
/* Up to ~35 cells on screen at once — translucent tint for the glass look, no backdrop-filter (cost scales with count).
   No fixed height: cells stretch to fill their row, which fitCalendarGrid() (app.js) sizes to
   the actual remaining viewport space, Google Calendar-style, instead of leaving a dead gap. */
.calendar-cell {
  display: flex;
  flex-direction: column;
  min-width: 0; /* grid items default to min-width:auto — without this, a chip's nowrap text
                   forces its column wider than 1fr, breaking the 7-equal-column layout on narrow screens */
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  background: var(--surface);
  overflow: hidden;
}
.calendar-cell.empty { background: transparent; border-color: transparent; }
.calendar-cell.today { border-color: var(--accent); }
.calendar-cell.skeleton-block { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; }
.calendar-cell-day { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--text-dim); margin-bottom: 3px; }
.calendar-cell.today .calendar-cell-day { color: var(--accent-text); font-weight: 700; }
.calendar-cell-shows { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.calendar-chip {
  font-size: 9px;
  font-weight: 600;
  background: var(--accent2);
  color: #fff;
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0; /* same fix at the flex-item level, so ellipsis truncation actually applies */
}
.calendar-chip-more { background: var(--surface-2); color: var(--text-dim); }

.day-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.day-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface-2);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}
.day-sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

@media (max-width: 480px) {
  .calendar-weekday { font-size: 8.5px; }
}

.show-list { display: flex; flex-direction: column; gap: 8px; }
/* Library list view can hold the whole collection (100s of rows) — same rule as calendar-cell:
   translucent background only, backdrop-filter would be applied to far too many elements at once. */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
}
.list-item:hover { background: var(--surface-2); }
.list-thumb {
  width: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
}
.list-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.list-thumb.wide { width: 72px; aspect-ratio: 16 / 9; }
.list-info { flex: 1; min-width: 0; }
.list-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-title-row .card-title { margin-top: 0; }
.list-title-row .status-pill { margin-bottom: 0; padding: 2px 8px; font-size: 9.5px; }
.list-progress-bar { height: 3px; border-radius: 2px; background: var(--track); overflow: hidden; margin-top: 6px; }
.list-progress-fill { height: 100%; background: var(--accent); }
.list-progress-fill.caught-up { background: var(--watched); }
.list-progress-fill.ended { background: var(--ended); }
.list-progress-fill.canceled { background: var(--canceled); }
.list-progress-fill.dnf { background: var(--dnf); }

.up-next-check-inline {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}
.up-next-check-inline:hover { background: var(--accent); color: #000; }

.up-next-check {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.search-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.search-type-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 700;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.tab-btn.active { background: var(--accent); border-color: transparent; color: #000; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg { position: absolute; left: 12px; top: 11px; }
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 12px 10px 34px;
  color: var(--text);
  font-size: 14px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.search-input:focus { outline: none; border-color: var(--accent); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }

.section { margin-bottom: 30px; }
.section-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 12px 16px;
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}
.section-title.collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.section-count { color: var(--text); font-family: "JetBrains Mono", monospace; }
.section-chevron { color: var(--text-dim); display: flex; flex-shrink: 0; }
.section-chevron svg { width: 15px; height: 15px; }

.profile-title { font-size: 24px; margin: 0 0 20px; }
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 30px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 12px;
  text-align: center;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.stat-value { font-family: "JetBrains Mono", monospace; font-size: 26px; font-weight: 700; color: var(--accent-text); }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 4px; }
.profile-empty { color: var(--text-dim); font-size: 13px; }

.profile-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.badges-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 24px;
}
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  opacity: 0.4;
  text-align: center;
  flex: 0 0 76px;
}
.badge-card.earned { opacity: 1; color: var(--text); border-color: rgba(255, 212, 0, 0.4); box-shadow: inset 0 1px 0 var(--glass-highlight); }
.badge-icon { color: var(--accent-text); }
.badge-icon svg { width: 22px; height: 22px; }
.badge-name { font-size: 9.5px; font-weight: 700; line-height: 1.3; }

.card-favorite { position: absolute; bottom: 8px; right: 6px; color: var(--accent); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.card-favorite svg { width: 14px; height: 14px; }
.list-favorite { color: var(--accent-text); display: flex; align-items: center; }
.list-favorite svg { width: 12px; height: 12px; }

@media (max-width: 480px) {
  .profile-stats { grid-template-columns: 1fr 1fr; }
}

.season {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.season-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  cursor: pointer;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.season-header-left { display: flex; align-items: center; gap: 10px; }
.episode-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
}
.episode-row.watched { background: rgba(46, 204, 113, 0.08); }
.checkbox {
  width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-top: 2px;
  -webkit-touch-callout: none; /* long-press opens the rewatch menu — don't let iOS show its own callout */
  -webkit-user-select: none;
  user-select: none;
}
.checkbox.checked { background: var(--watched); border: none; color: #000; }
.checkbox.checked:hover { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkbox-count { font-size: 8px; font-weight: 800; font-family: "JetBrains Mono", monospace; line-height: 1; }
.episode-main { flex: 1; min-width: 0; cursor: pointer; }
.episode-row-top { display: flex; align-items: center; gap: 12px; }
.episode-chevron { color: var(--text-dim); flex-shrink: 0; display: flex; }
.episode-chevron svg { width: 13px; height: 13px; }
.episode-overview { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; margin: 6px 0 0; }

.watched-menu { display: flex; gap: 6px; margin-top: 8px; }
.watched-menu-btn {
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 5px 10px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.watched-menu-btn.accent { background: var(--accent); border-color: transparent; color: #000; }

.detail-header { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.detail-poster { width: 110px; flex-shrink: 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.detail-info { flex: 1; min-width: 0; }

/* iOS keeps primary navigation in a floating bottom tab bar, never at the top — hidden here,
   swapped in for .topbar-nav below the mobile breakpoint (see the media query below). */
.bottom-nav { display: none; }

/* ---- mobile ---- */
@media (max-width: 640px) {
  /* No top bar left on mobile — pad for the status bar/notch ourselves instead. */
  #app { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(100px + env(safe-area-inset-bottom, 0px)); }

  /* Primary nav lives in the bottom tab bar and settings live in Profile now — nothing left
     for the top bar to do on mobile, so it's gone entirely (also very iOS: a bare top edge
     above scrolling content, no top chrome, is the standard "large title" home-screen look). */
  .topbar { display: none; }

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

  .library-search { flex-basis: 100%; }

  .detail-header { gap: 14px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    justify-content: space-around;
    align-items: center;
    padding: 6px;
    background: var(--nav-glass-bg);
    border: 1px solid var(--border);
    border-radius: 26px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 9.5px;
    font-weight: 600;
    padding: 7px 4px;
    border-radius: 18px;
  }
  .bottom-nav-item svg { width: 20px; height: 20px; }
  .bottom-nav-item.active { color: var(--accent-text); }
}

@media (max-width: 420px) {
  .detail-header { flex-direction: column; }
  .detail-poster { width: 140px; margin: 0 auto; }
}
