/* TVMate — dark, clean, scannable */

:root {
  --bg:         #000000;
  --surface:    #1a1d27;
  --surface2:   #22263a;
  --border:     #2a2d3e;
  --text:       #eaedf8;
  --text-muted: #858ab0;
  --text-dim:   #5a5e7a;
  --text-soft:  #b2bada;
  --accent:     #5b8af5;
  --today-glow: rgba(91, 138, 245, 0.08);
  --new-badge:  #27ae60;
  --season-badge: #e67e22;
  --finale-badge: #8b2be2;
  --font:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:       'JetBrains Mono', 'Consolas', monospace;
}

/* ── Dark palette: Ocean ── */
html[data-palette="ocean"] {
  --bg:          #000000;
  --surface:     #0e2030;
  --surface2:    #152840;
  --border:      #1c3858;
  --text:        #c8e8f8;
  --text-muted:  #5898be;
  --text-dim:    #386888;
  --text-soft:   #82c0d8;
  --accent:      #18c0e0;
  --today-glow:  rgba(24,192,224,0.09);
  --new-badge:   #20c070;
  --season-badge:#e08020;
  --finale-badge:#8b2be2;
}
html[data-palette="ocean"] header {
  background: linear-gradient(135deg, #040c14 0%, #091828 100%);
  border-bottom-color: #020810;
}

/* ── Dark palette: Forest ── */
html[data-palette="forest"] {
  --bg:          #000000;
  --surface:     #101e16;
  --surface2:    #172c1e;
  --border:      #1e3c28;
  --text:        #c0e8c0;
  --text-muted:  #50a070;
  --text-dim:    #347048;
  --text-soft:   #82c088;
  --accent:      #28d060;
  --today-glow:  rgba(40,208,96,0.09);
  --new-badge:   #20c070;
  --season-badge:#e08020;
  --finale-badge:#8b2be2;
}
html[data-palette="forest"] header {
  background: linear-gradient(135deg, #040e08 0%, #091c10 100%);
  border-bottom-color: #020804;
}

/* ── Dark palette: Ember ── */
html[data-palette="ember"] {
  --bg:          #000000;
  --surface:     #1e1408;
  --surface2:    #2a1c0a;
  --border:      #3c2810;
  --text:        #f8ddb5;
  --text-muted:  #bc9250;
  --text-dim:    #786030;
  --text-soft:   #d8a868;
  --accent:      #f09030;
  --today-glow:  rgba(240,144,48,0.09);
  --new-badge:   #20c070;
  --season-badge:#f09030;
  --finale-badge:#8b2be2;
}
html[data-palette="ember"] header {
  background: linear-gradient(135deg, #0e0800 0%, #1e1000 100%);
  border-bottom-color: #080400;
}

/* ── Dark palette: Amethyst ── */
html[data-palette="amethyst"] {
  --bg:          #000000;
  --surface:     #170d2e;
  --surface2:    #201440;
  --border:      #341e5c;
  --text:        #e0ccff;
  --text-muted:  #9068d0;
  --text-dim:    #604098;
  --text-soft:   #b088e8;
  --accent:      #a058f8;
  --today-glow:  rgba(160,88,248,0.09);
  --new-badge:   #20c070;
  --season-badge:#e08020;
  --finale-badge:#8b2be2;
}
html[data-palette="amethyst"] header {
  background: linear-gradient(135deg, #090318 0%, #140628 100%);
  border-bottom-color: #050110;
}

/* ── Dark palette: Carbon ── */
html[data-palette="carbon"] {
  --bg:          #000000;
  --surface:     #161820;
  --surface2:    #1c1e28;
  --border:      #262a38;
  --text:        #dddfe8;
  --text-muted:  #6878b8;
  --text-dim:    #4c5480;
  --text-soft:   #90a0c8;
  --accent:      #5890f0;
  --today-glow:  rgba(88,144,240,0.09);
  --new-badge:   #20c070;
  --season-badge:#e08020;
  --finale-badge:#8b2be2;
}
html[data-palette="carbon"] header {
  background: linear-gradient(135deg, #08090e 0%, #101218 100%);
  border-bottom-color: #040508;
}

/* ── Dark palette: Rust ── */
html[data-palette="rust"] {
  --bg:          #000000;
  --surface:     #201008;
  --surface2:    #2c1610;
  --border:      #441e14;
  --text:        #f8d0b0;
  --text-muted:  #be6050;
  --text-dim:    #784038;
  --text-soft:   #d88068;
  --accent:      #e04828;
  --today-glow:  rgba(224,72,40,0.09);
  --new-badge:   #20c070;
  --season-badge:#e08020;
  --finale-badge:#8b2be2;
}
html[data-palette="rust"] header {
  background: linear-gradient(135deg, #0e0500 0%, #1c0a06 100%);
  border-bottom-color: #080200;
}

/* ── Light mode — Navy Daylight palette ── */
html.light-mode {
  --bg:           #ffffff;
  --surface:      #e4e9ff;
  --surface2:     #bcc9f0;
  --border:       #8898d0;
  --text:         #07103a;
  --text-muted:   #1e3280;
  --text-soft:    #1e3280;
  --text-dim:     #4858a0;
  --accent:       #2a5ae8;
  --today-glow:   rgba(42, 90, 232, 0.13);
  --new-badge:    #1a7a3a;
  --season-badge: #b84a00;
  --finale-badge: #7020c0;
}

/* ── Light mode: dark gradient header ── */
html.light-mode header {
  background: linear-gradient(135deg, #1a2d60 0%, #2d4494 100%);
  border-bottom-color: #141f45;
}
html.light-mode .week-label       { color: rgba(255,255,255,0.78); }
html.light-mode .user-info        { color: rgba(255,255,255,0.70); }
html.light-mode .pop-end-label    { color: var(--text-muted); }
html.light-mode .nav-btn {
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.82);
}
html.light-mode .nav-btn:hover { border-color: #fff; color: #fff; }
html.light-mode .filter-group { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
html.light-mode .filter-btn { color: rgba(255,255,255,0.7); }
html.light-mode .filter-btn.active { background: var(--accent); color: #fff; }
html.light-mode .filter-btn:hover:not(.active) { background: rgba(255,255,255,0.12); color: #fff; }
html.light-mode .icon-btn { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.75); }
html.light-mode .icon-btn:hover { border-color: rgba(255,255,255,0.65); color: #fff; }
html.light-mode .logout-link { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.75); }
html.light-mode .logout-link:hover { border-color: #fff; color: #fff; }
html.light-mode .week-jump-input {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.85);
}
html.light-mode .light-switch {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.30);
}
html.light-mode .light-switch .light-switch-lever { background: rgba(255,255,255,0.45); }
html.light-mode .light-switch.switch-on .light-switch-lever { background: #90c0ff; }
/* ── Palette: Pearl ── */
html[data-palette="pearl"] {
  --bg:          #ffffff;
  --surface:     #ffffff;
  --surface2:    #e8e8ef;
  --border:      #c4c4d0;
  --text:        #18182e;
  --text-muted:  #52527a;
  --text-dim:    #9898b8;
  --accent:      #6050d0;
  --today-glow:  rgba(96,80,208,0.08);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="pearl"] header {
  background: linear-gradient(135deg, #2a2040 0%, #4a3880 100%);
  border-bottom-color: #1a1030;
}

/* ── Palette: Rose ── */
html[data-palette="rose"] {
  --bg:          #ffffff;
  --surface:     #fff5f7;
  --surface2:    #f5dde4;
  --border:      #e0aab8;
  --text:        #3a0f1a;
  --text-muted:  #8a3a50;
  --text-dim:    #c080a0;
  --accent:      #d0305a;
  --today-glow:  rgba(208,48,90,0.08);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="rose"] header {
  background: linear-gradient(135deg, #5a0a20 0%, #8a1a3a 100%);
  border-bottom-color: #3a0410;
}

/* ── Palette: Sage ── */
html[data-palette="sage"] {
  --bg:          #ffffff;
  --surface:     #f6fbf6;
  --surface2:    #d8ecd8;
  --border:      #a0c8a0;
  --text:        #0f2a0f;
  --text-muted:  #3a6a3a;
  --text-dim:    #70a070;
  --accent:      #2a8040;
  --today-glow:  rgba(42,128,64,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="sage"] header {
  background: linear-gradient(135deg, #0f3020 0%, #1a5030 100%);
  border-bottom-color: #081808;
}

/* ── Palette: Sky ── */
html[data-palette="sky"] {
  --bg:          #ffffff;
  --surface:     #f4faff;
  --surface2:    #cce4f8;
  --border:      #90c0e8;
  --text:        #051828;
  --text-muted:  #2050a0;
  --text-dim:    #6090c8;
  --accent:      #1878d0;
  --today-glow:  rgba(24,120,208,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="sky"] header {
  background: linear-gradient(135deg, #051830 0%, #0a3060 100%);
  border-bottom-color: #020c1a;
}

/* ── Palette: Sand ── */
html[data-palette="sand"] {
  --bg:          #ffffff;
  --surface:     #fdfaf4;
  --surface2:    #ede4d0;
  --border:      #c8b890;
  --text:        #2a1e08;
  --text-muted:  #705a30;
  --text-dim:    #a89060;
  --accent:      #c08020;
  --today-glow:  rgba(192,128,32,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="sand"] header {
  background: linear-gradient(135deg, #3a2808 0%, #604018 100%);
  border-bottom-color: #201400;
}

/* ── Palette: Lavender ── */
html[data-palette="lavender"] {
  --bg:          #ffffff;
  --surface:     #faf8ff;
  --surface2:    #e4daf5;
  --border:      #c0a8e8;
  --text:        #1e0a3a;
  --text-muted:  #6040a0;
  --text-dim:    #a080d0;
  --accent:      #7040c0;
  --today-glow:  rgba(112,64,192,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="lavender"] header {
  background: linear-gradient(135deg, #200840 0%, #400880 100%);
  border-bottom-color: #100428;
}

/* ── Palette: Coral ── */
html[data-palette="coral"] {
  --bg:          #ffffff;
  --surface:     #fff8f5;
  --surface2:    #ffd8c8;
  --border:      #e8a888;
  --text:        #3a0a00;
  --text-muted:  #903020;
  --text-dim:    #c07060;
  --accent:      #e04820;
  --today-glow:  rgba(224,72,32,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="coral"] header {
  background: linear-gradient(135deg, #3a0800 0%, #602010 100%);
  border-bottom-color: #200400;
}

/* ── Palette: Jade ── */
html[data-palette="jade"] {
  --bg:          #ffffff;
  --surface:     #f4fbf8;
  --surface2:    #c8e8e0;
  --border:      #88c8b8;
  --text:        #051e18;
  --text-muted:  #1a6050;
  --text-dim:    #509080;
  --accent:      #1a9070;
  --today-glow:  rgba(26,144,112,0.09);
  --new-badge:   #1a7a3a;
  --season-badge:#b84a00;
  --finale-badge:#7020c0;
}
html[data-palette="jade"] header {
  background: linear-gradient(135deg, #051e18 0%, #0a4030 100%);
  border-bottom-color: #020f0c;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
}

body {
  min-width: 1120px; /* matches grid min-width; document scrolls header+grid together */
}

/* ── Header ── */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto;
  align-items: center;
  padding: 10px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  grid-column: 1;
  grid-row: 1;
}

.view-toggles-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Filters — centred, with Filters button to the right of the pill group */
.header-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  grid-column: 2;
  grid-row: 1;
}

/* Icons + user — top-right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* Filters open button — visually separate from the pill group */
.filters-open-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 7px 14px;
  transition: all 0.15s;
  white-space: nowrap;
}
.filters-open-btn:hover { border-color: var(--accent); color: var(--text); }
.filters-open-btn.active { border-color: var(--accent); color: var(--accent); }

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.header-logo {
  height: 40px;
  width: auto;
  display: block;
}

.header-left a { line-height: 0; }

.week-nav { display: flex; align-items: center; gap: 8px; }

.week-jump-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  height: 26px;
}
.week-jump-input:focus { outline: none; border-color: var(--accent); }
.week-jump-input::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.week-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 160px;
  text-align: center;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Filter group (segmented control) ── */
.filter-group {
  display: flex;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--border);
}
.filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 7px 16px;
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn.active { background: var(--accent); color: #fff; }
.filter-btn:hover:not(.active) { background: rgba(255,255,255,0.08); color: var(--text); }
#btn-all:not(.active) { color: var(--text-muted); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--text); }

.text-icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
}
.text-icon-btn:hover { border-color: var(--accent); color: var(--text); }
html.light-mode .text-icon-btn { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.75); }
html.light-mode .text-icon-btn:hover { border-color: #fff; color: #fff; }

/* ── Popularity slider in header ── */
.pop-slider-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pop-slider-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}
.pop-label-for { color: var(--season-badge); }
.pop-end-label {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}
.pop-slider-sep {
  color: var(--border);
  flex-shrink: 0;
  padding: 0 2px;
}
.pop-slider {
  width: 130px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.country-filter-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--text-dim);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s;
}
.country-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.country-filter-btn.country-filter-active {
  border-color: var(--season-badge);
  color: var(--season-badge);
}
html.light-mode .country-filter-btn { border-color: var(--text-muted); color: var(--text-muted); }
html.light-mode .country-filter-btn.country-filter-active { border-color: rgba(255,160,30,0.85); color: rgba(255,160,30,1); }

/* Filters Modal — pinned to top, stacked sliders, no backdrop */
#filters-overlay {
  align-items: flex-start;
  background: none;
  backdrop-filter: none;
}
#filters-modal {
  margin-top: 0;
  border-radius: 0 0 10px 10px;
  max-height: fit-content;
  padding: 14px 20px 16px;
}

/* Header row: Filters title + Country + Type + × all inline */
.filter-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filter-modal-header h2 { margin: 0; flex-shrink: 0; }

/* × button inline with title — not absolute */
.filter-modal-x {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
}
.filter-modal-x:hover { color: var(--text); }

.filter-modal-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.filter-modal-label {
  width: 54px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}
.filter-modal-slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.filter-modal-slider-group .pop-slider {
  flex: 1;
  width: auto;
}

/* Country Filter Modal */
#country-filter-modal { max-width: 620px; }
.country-filter-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.country-filter-all-btn {
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}
.country-filter-all-btn:hover { border-color: var(--accent); color: var(--accent); }
.country-filter-note {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
}
.country-filter-list {
  column-count: 2;
  column-gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.country-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  break-inside: avoid;
}
.country-row:hover { background: var(--surface2); }
.country-row input[type=checkbox] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.country-flag { font-size: 18px; line-height: 1; flex-shrink: 0; width: 24px; text-align: center; }
.country-name { font-size: 13px; color: var(--text); }


/* ── Grid ── */
/* ── Scrolling tip ticker ── */
.scroll-ticker {
  overflow: hidden;
  white-space: nowrap;
  padding: 5px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: #fff;
}
html.light-mode .scroll-ticker { color: #000; }
.scroll-ticker span {
  display: inline-block;
  white-space: pre;
  will-change: transform;
}

/* overflow-y:auto makes grid-wrapper a vertical scroll container so
   position:sticky on day-header works. overflow-x is hidden — horizontal
   scroll is handled at the document level (body min-width). */
.grid-wrapper {
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - 62px - 27px); /* single-row header (~62px) + ticker */
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  min-width: 1120px;
  gap: 0;
}

.day-col {
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 62px);
}
.day-col:last-child { border-right: none; }

.day-col.today {
  background: var(--today-glow);
  position: relative;
}
.day-col.today::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid #f5c518;
  pointer-events: none;
  z-index: 100;
}

.day-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 90;
}

.today .day-header {
  background: var(--surface2);
  border-bottom-color: var(--accent);
}

.day-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.today .day-name { color: var(--accent); }

.day-date {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}

.day-shows { padding: 4px 0; }

/* ── Show Row ── */
.show-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.2s;
  overflow: hidden;
  background: var(--row-tint, transparent);
}
.show-row:hover { background: var(--row-tint-hover, var(--surface2)); }
.show-row.hidden-show  { display: none; }
.show-row.not-followed { display: none; }
.show-row.followed     { opacity: 1; }


.show-body {
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 6px;
}

/* Line 1 — show name + badges + info btn */
.row-line1 {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.show-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.show-name > span { display: inline-block; }
.show-row:hover .show-name.overflows { text-overflow: clip; }
.show-row:hover .show-name.overflows > span {
  animation: show-name-marquee 4s 0.3s ease-in-out infinite;
}
@keyframes show-name-marquee {
  0%,  15% { transform: translateX(0); }
  45%, 55% { transform: translateX(var(--scroll-px, 0)); }
  85%, 100% { transform: translateX(0); }
}

.badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.badge-new    { background: var(--new-badge);    color: #fff; }
.badge-season { background: var(--season-badge); color: #fff; }
.badge-finale { background: var(--finale-badge); color: #fff; }

.watched-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.watched-btn:hover          { border-color: var(--new-badge); color: var(--new-badge); }
.watched-btn.watched-active { background: var(--new-badge); border-color: var(--new-badge); color: #fff; }

.show-row.is-watched         { opacity: 0.5; }
.show-row.is-partial-watched { opacity: 0.7; }

.info-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.1s;
}
.info-btn:hover { color: var(--accent); }

/* Line 2 — badge + episode code + time + action buttons */
.row-line2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}
.row-line2 .watched-btn { margin-left: 0; }

.ep-code {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

.time-str {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
}
.lang-flag {
  font-size: 11px;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}
.lang-flag + .time-str {
  margin-left: 4px;
}
.time-us-tag {
  font-size: 8px;
  font-family: var(--font);
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 3px;
  vertical-align: middle;
  letter-spacing: 0.03em;
  margin-left: auto;
}

/* Expanded details */
.show-details {
  display: none;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}
.show-row.expanded .show-details { display: block; }
.show-row.expanded .detail-title  { color: var(--text-soft); }
.show-row.expanded .detail-time   { color: var(--text-soft); }
.show-row.expanded .ep-watched-btn { color: var(--text-soft); border-color: var(--text-soft); }

/* White text/borders on tinted (followed) rows so buttons are visible over the colour */
.show-row[style*="--row-tint"] .show-details { border-top-color: rgba(255,255,255,0.2); }
.show-row[style*="--row-tint"] .detail-title,
.show-row[style*="--row-tint"] .detail-time  { color: rgba(255,255,255,0.85); }
.show-row[style*="--row-tint"] .detail-link-btn {
  background: #1a3055;
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.2);
}
.show-row[style*="--row-tint"] .detail-link-btn:hover {
  background: #22406e;
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}
.show-row[style*="--row-tint"] .all-eps-btn,
.show-row[style*="--row-tint"] .edit-show-btn,
.show-row[style*="--row-tint"] .hide-btn {
  background: #1a3055;
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.2);
}
.show-row[style*="--row-tint"] .all-eps-btn:hover,
.show-row[style*="--row-tint"] .edit-show-btn:hover,
.show-row[style*="--row-tint"] .hide-btn:hover {
  background: #22406e;
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}
.show-row[style*="--row-tint"] .follow-btn:not(.is-followed) {
  background: #1a3055;
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.2);
}
.show-row[style*="--row-tint"] .watched-btn {
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.65);
}
.show-row[style*="--row-tint"] .info-btn {
  color: rgba(255,255,255,0.9);
}

/* Black text/borders on tinted rows in light mode */
.light-mode .show-row[style*="--row-tint"] .show-details { border-top-color: rgba(0,0,0,0.15); }
.light-mode .show-row[style*="--row-tint"] .detail-title,
.light-mode .show-row[style*="--row-tint"] .detail-time  { color: rgba(0,0,0,0.8); }
.light-mode .show-row[style*="--row-tint"] .detail-link-btn {
  background: #f0eeeb;
  color: rgba(0,0,0,0.75);
  border-color: rgba(0,0,0,0.2);
}
.light-mode .show-row[style*="--row-tint"] .detail-link-btn:hover {
  background: #e2dfd9;
  color: #000;
  border-color: rgba(0,0,0,0.45);
}
.light-mode .show-row[style*="--row-tint"] .all-eps-btn,
.light-mode .show-row[style*="--row-tint"] .edit-show-btn,
.light-mode .show-row[style*="--row-tint"] .hide-btn {
  background: #f0eeeb;
  color: rgba(0,0,0,0.75);
  border-color: rgba(0,0,0,0.2);
}
.light-mode .show-row[style*="--row-tint"] .all-eps-btn:hover,
.light-mode .show-row[style*="--row-tint"] .edit-show-btn:hover,
.light-mode .show-row[style*="--row-tint"] .hide-btn:hover {
  background: #e2dfd9;
  color: #000;
  border-color: rgba(0,0,0,0.45);
}
.light-mode .show-row[style*="--row-tint"] .follow-btn:not(.is-followed) {
  background: #f0eeeb;
  color: rgba(0,0,0,0.75);
  border-color: rgba(0,0,0,0.2);
}
.light-mode .show-row[style*="--row-tint"] .watched-btn {
  color: rgba(0,0,0,0.75);
  border-color: rgba(0,0,0,0.5);
}
.light-mode .show-row[style*="--row-tint"] .info-btn {
  color: rgba(0,0,0,0.75);
}

/* Line 3 — episode title / multi-ep list */
.detail-eps {
  margin-bottom: 5px;
}

.detail-title {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-ep-row {
  cursor: pointer;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.detail-ep-row:last-child { border-bottom: none; }
.detail-ep-row:hover { background: var(--surface2); }

/* Collapsed 2-line summary */
.ep-summary { display: flex; flex-direction: column; gap: 1px; }
.ep-summary-line1 { display: flex; align-items: center; gap: 6px; }
.ep-summary-line2 { padding-left: 2px; }

/* Expanded full row */
.ep-full         { display: none; flex-direction: column; gap: 4px; }
.ep-full-top     { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ep-full-links   { display: flex; flex-wrap: wrap; gap: 3px; padding-left: 2px; }

.detail-ep-row.ep-expanded .ep-summary { display: none; }
.detail-ep-row.ep-expanded .ep-full    { display: flex; }

.ep-watched-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 9px;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.ep-watched-btn:hover          { border-color: var(--new-badge); color: var(--new-badge); }
.ep-watched-btn.watched-active { background: var(--new-badge); border-color: var(--new-badge); color: #fff; }

.detail-code {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

.detail-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Line 4 — links + follow */
.detail-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.detail-footer-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}

.detail-link-btn {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.1s, color 0.1s;
}
.detail-link-btn:hover { border-color: var(--accent); color: var(--accent); }

.add-edit-links-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.1s, color 0.1s;
}
.add-edit-links-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Compact link buttons inside episode expand rows */
.season-ep-links .detail-link-btn {
  font-size: 10px;
  padding: 2px 6px;
}
.season-ep-links .detail-link-btn img {
  width: 10px;
  height: 10px;
  margin-right: 3px;
}

.hide-btn {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.hide-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.hidden-list {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.hidden-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.hidden-list-name {
  font-size: 13px;
  flex: 1;
}

.follow-btn {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.follow-btn:hover:not(.is-followed) { border-color: var(--accent); color: var(--accent); }
.follow-btn.is-followed             { color: #fff; }

.no-shows {
  padding: 16px 8px;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-wide { width: 600px; }


.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: color 0.1s;
}
.modal-close:hover { color: var(--text); }

.modal-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

/* Info modal content */
.modal-show-header {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-poster {
  width: 80px;
  height: 112px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface2);
}

.modal-show-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-show-meta  { font-size: 11px; color: var(--text-muted); line-height: 1.6; }

.modal-follow-btn {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.modal-follow-btn:hover:not(.is-followed) { border-color: var(--accent); color: var(--accent); }

.modal-show-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.1s;
}
.link-btn:hover { border-color: var(--accent); color: var(--accent); }

.modal-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-episodes-heading { font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.ep-row {
  display: flex;
  gap: 8px;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.ep-row:last-child { border-bottom: none; }
.ep-row .code { font-family: var(--mono); color: var(--text-dim); width: 56px; flex-shrink: 0; }
.ep-row .name { flex: 1; color: var(--text-muted); }
.ep-row .date { color: var(--text-dim); flex-shrink: 0; }

/* Links Manager */
.links-help {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.links-help code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  color: var(--accent);
}

.link-entry {
  display: grid;
  grid-template-columns: auto 1fr 2fr auto auto auto auto;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
  border-radius: 4px;
  transition: opacity 0.15s;
}
.link-entry.dragging { opacity: 0.35; }
.link-entry.drag-over { outline: 2px solid var(--accent); outline-offset: 1px; }

.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 14px;
  padding: 0 2px;
  user-select: none;
  line-height: 1;
}
.drag-handle:active { cursor: grabbing; }
.link-entry input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
  width: 100%;
}
.link-entry input:focus { outline: none; border-color: var(--accent); }

.btn-del-link, .btn-reset-link {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  width: 26px;
  height: 26px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-del-link:hover   { border-color: #c0392b; color: #c0392b; }
.btn-reset-link:hover { border-color: var(--accent); color: var(--accent); }

.btn-add-link {
  margin-top: 8px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  width: 100%;
  transition: all 0.15s;
}
.btn-add-link:hover { border-color: var(--accent); color: var(--accent); }

.links-presets {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.links-presets span { font-size: 11px; color: var(--text-muted); }
.links-presets button {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.links-presets button:hover { border-color: var(--accent); color: var(--text); }

.url-configurator {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.url-configurator h3 { font-size: 13px; margin-bottom: 6px; }
.url-configurator p  { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }

.cfg-term-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
.cfg-term-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.cfg-term {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  flex: 1;
}
.cfg-copy-btn {
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.cfg-copy-btn:hover { opacity: 0.85; }

.configurator-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.configurator-row input {
  flex: 1;
  min-width: 150px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
}
.configurator-row input:focus { outline: none; border-color: var(--accent); }
.configurator-row button, .cfg-result button {
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 11px;
}

.cfg-result {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.cfg-result.hidden { display: none; }
#cfg-preview {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
}

/* Settings */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}
.setting-row:last-child { border-bottom: none; }
.setting-row button {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.setting-row button:hover { border-color: #c0392b; color: #c0392b; }

h2 { font-size: 16px; margin-bottom: 16px; }

/* ── Settings hub ── */
.settings-menu {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.settings-menu-item:hover { border-color: var(--accent); background: var(--surface); }

.settings-menu-arrow { color: var(--text-muted); font-size: 16px; }

.settings-sync-btn {
  font-size: 11px;
  padding: 5px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.settings-sync-btn:hover { border-color: var(--accent); color: var(--accent); }
.settings-sync-btn:disabled { opacity: 0.5; cursor: default; }

.settings-back {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 16px;
  display: inline-block;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.settings-back:hover { border-color: var(--accent); background: var(--surface); }

/* ── Account section ── */
.account-sections { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }

.account-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.account-section h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.acc-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.acc-save-btn {
  margin-top: 6px;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  color: #fff;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}
.acc-save-btn:hover { opacity: 0.85; }
.acc-save-btn.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-muted); }
.acc-save-btn.btn-ghost:hover { border-color: var(--accent); color: var(--text); opacity: 1; }
.acc-save-btn.btn-danger { background: none; border: 1px solid #c0392b; color: #c0392b; }
.acc-save-btn.btn-danger:hover { background: #c0392b; color: #fff; opacity: 1; }
.acc-msg { font-size: 11px; min-height: 16px; margin: 6px 0 2px; }
.acc-ok  { color: #4caf50; }
.acc-err { color: #e74c3c; }

/* Export / Import */
.import-mode-label {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; margin: 6px 0;
}
.import-mode-label:has(input:checked) { border-color: var(--accent); }
.import-mode-label input { display: none; }
.import-mode-title { font-size: 12px; font-weight: 600; color: var(--text); }
.import-mode-desc  { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.import-file-name  { font-size: 11px; color: var(--accent); margin: 5px 0 2px; min-height: 15px; font-style: italic; }
.import-divider    { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.import-confirm {
  border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px;
  margin: 10px 0 4px; background: var(--surface);
}
.import-confirm.danger { border-color: #c0392b; background: rgba(192,57,43,0.07); }
.import-confirm-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.import-confirm-list  { margin: 6px 0 8px 18px; padding: 0; font-size: 12px; color: var(--text-muted); }
.import-confirm-list li { margin-bottom: 3px; }
.import-confirm-note  { font-size: 11px; color: var(--text-muted); margin: 6px 0 0; }
.import-confirm-note.warn { color: #c0392b; font-weight: 600; margin-top: 8px; }
.import-confirm-btns  { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.import-result        { font-size: 12px; padding: 8px 12px; border-radius: 6px; margin-top: 8px; }
.import-result.ok     { color: #27ae60; border: 1px solid #27ae60; background: rgba(39,174,96,0.07); }
.import-result.err    { color: #c0392b; border: 1px solid #c0392b; background: rgba(192,57,43,0.07); }

/* ── Airdates unmatched inline search ── */
.airdates-unmatched-row {
  display: flex;
  flex-direction: column;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.airdates-unmatched-row:last-child { border-bottom: none; }
.airdates-unmatched-top { display: flex; align-items: center; gap: 8px; }
.airdates-unmatched-name { flex: 1; color: var(--text-muted); }
.airdates-link-btn { padding: 2px 8px; font-size: 11px; }
.airdates-search-area { margin-top: 5px; position: relative; }
.airdates-search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 200;
  max-height: 160px;
  overflow-y: auto;
}
.airdates-search-result {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.airdates-search-result:last-child { border-bottom: none; }
.airdates-search-result:hover { background: var(--surface2); }

/* ── Import Modal ── */
.import-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.import-modal-overlay.hidden { display: none; }

.import-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 560px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.import-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.import-modal-header h2 { margin-bottom: 0; }

.import-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.import-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.import-tab:hover { color: var(--text); }
.import-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.import-tab-panel {
  min-height: 120px;
}

.import-textarea {
  width: 100%;
  height: 80px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  resize: vertical;
  box-sizing: border-box;
  font-family: var(--font);
}
.import-textarea:focus { outline: none; border-color: var(--accent); }

.setting-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 12px 0 6px;
}

.lang-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  min-height: 26px;
}

.lang-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text);
}
.lang-tag button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  line-height: 1;
}
.lang-tag button:hover { color: #c0392b; }

.lang-add-row {
  display: flex;
  gap: 6px;
}
.lang-add-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
}
.lang-add-row input:focus { outline: none; border-color: var(--accent); }
.lang-add-row button {
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 11px;
}

/* ── User info in header ── */
.user-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

.logout-link {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}
.logout-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.discuss-badge {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}
.discuss-badge:hover {
  border-color: var(--accent);
  color: var(--accent);
}
html.light-mode .discuss-badge { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.75); }
html.light-mode .discuss-badge:hover { border-color: #fff; color: #fff; }

/* ── User menu dropdown ── */
.user-menu {
  position: relative;
}
.user-menu-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 11px;
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}
.user-menu-btn:hover { border-color: var(--accent); color: var(--text); }
.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dd-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s;
  box-sizing: border-box;
}
.user-dd-item:hover { background: var(--surface3, rgba(255,255,255,0.06)); color: var(--text); }
.user-dd-logout { border-top: 1px solid var(--border); color: var(--text-dim); margin-top: 2px; }
html.light-mode .user-menu-btn { border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
html.light-mode .user-menu-btn:hover { border-color: #fff; color: #fff; }
html.light-mode .user-dropdown { background: rgba(30,30,40,0.97); border-color: rgba(255,255,255,0.15); }
html.light-mode .user-dd-item { color: rgba(255,255,255,0.75); }
html.light-mode .user-dd-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ── Light switch (rocker style) ── */
.light-switch {
  width: 18px;
  height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px;
  gap: 0;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.light-switch:hover { border-color: var(--accent); }

.light-switch-lever {
  width: 10px;
  height: 11px;
  background: var(--text-dim);
  border-radius: 2px;
  position: absolute;
  top: 3px;
  transition: top 0.2s ease, background 0.2s;
}

/* switch-on = light mode = lever drops DOWN */
.light-switch.switch-on .light-switch-lever {
  top: 14px;
  background: var(--accent);
}

/* ── Auth pages ── */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 360px;
  max-width: 90vw;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.auth-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit {
  width: 100%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  transition: opacity 0.15s;
}
.auth-submit:hover {
  opacity: 0.9;
}

.auth-error {
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid #c0392b;
  border-radius: 4px;
  color: #e74c3c;
  font-size: 12px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.auth-link {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-link a {
  color: var(--accent);
  text-decoration: none;
}
.auth-link a:hover {
  text-decoration: underline;
}

.auth-optional {
  color: var(--text-muted);
  font-weight: 400;
}

.auth-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Colour swatch in expanded panel ── */
.follow-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.follow-color-swatch:hover { border-color: rgba(255,255,255,0.6); }

/* ── Colour picker modal ── */
.colour-picker-modal { max-width: 320px; }
.colour-picker-modal h3 { margin-bottom: 12px; font-size: 14px; }
.colour-swatches {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.colour-swatch-option {
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; border: 2px solid transparent;
}
.colour-swatch-option:hover, .colour-swatch-option.selected {
  border-color: #fff;
}
.colour-custom-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
}
.custom-edit-toggle-label {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none;
}
.custom-edit-toggle-label input[type=checkbox] { display: none; }
.custom-edit-toggle-track {
  display: inline-block; width: 28px; height: 14px; border-radius: 7px;
  background: var(--border); position: relative; transition: background 0.2s; flex-shrink: 0;
}
.custom-edit-toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); transition: left 0.2s, background 0.2s;
}
#custom-edit-toggle:checked + .custom-edit-toggle-track { background: var(--accent); }
#custom-edit-toggle:checked + .custom-edit-toggle-track::after { left: 16px; background: #fff; }
.custom-edit-toggle-text { font-size: 10px; color: var(--text-muted); }
.colour-custom-swatch.edit-mode { outline: 1px dashed var(--text-muted); outline-offset: 2px; }
.colour-custom-row { margin-bottom: 12px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.colour-custom-row input[type=color] { margin-left: 6px; vertical-align: middle; cursor: pointer; }
.colour-picker-secondary-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.colour-unfollow-row { display: contents; }
.colour-unfollow-row.hidden { display: none; }
.colour-unfollow-btn {
  padding: 5px 10px; border: 1px solid #c0392b; border-radius: 6px;
  background: none; color: #c0392b; cursor: pointer; font-size: 11px;
}
.colour-unfollow-btn:hover { background: #c0392b; color: #fff; }
.colour-cancel-btn {
  margin-left: auto; padding: 5px 10px; border: none; border-radius: 6px;
  background: var(--surface2); color: var(--text); cursor: pointer; font-size: 11px;
}
.colour-cancel-btn:hover { opacity: 0.8; }
.colour-picker-actions button {
  width: 100%; padding: 9px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--accent); color: #fff;
}

/* ── Search modal ── */
.search-input {
  width: 100%; padding: 8px 10px; margin-bottom: 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border); gap: 8px;
}
.search-result-row:last-child { border-bottom: none; }
.search-result-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.search-result-name { font-size: 13px; font-weight: 500; }
.search-result-meta { font-size: 11px; color: var(--text-muted); }
.search-result-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.search-result-swatch {
  width: 16px; height: 16px; border-radius: 3px;
  cursor: pointer; border: 1px solid rgba(255,255,255,0.3);
}
.search-follow-btn {
  padding: 4px 10px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer;
}
.search-follow-btn.is-followed {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.search-goto-btn {
  padding: 4px 8px; border-radius: 4px; font-size: 11px;
  background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer;
}
.search-goto-btn:hover { border-color: var(--accent); color: var(--text); }

.search-url-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.search-url-label {
  font-size: 11px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-url-row {
  display: flex; gap: 8px; align-items: center;
}
.search-url-row .search-input { flex: 1; font-size: 12px; }
#search-url-status {
  margin-top: 6px; font-size: 12px; min-height: 18px; color: var(--text-muted);
}
.search-more-btn {
  text-align: center;
  padding: 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.search-more-btn:hover { text-decoration: underline; }

/* Goto episode highlight */
@keyframes goto-pulse {
  0%, 100% {
    background: rgba(91, 138, 245, 0.06);
    box-shadow: 0 0 0 0 rgba(91, 138, 245, 0);
  }
  50% {
    background: rgba(91, 138, 245, 0.22);
    box-shadow: 0 0 18px 4px rgba(91, 138, 245, 0.45), inset 0 0 12px rgba(91, 138, 245, 0.15);
  }
}
.show-row.goto-highlight {
  display: flex !important; /* override filter hiding */
  animation: goto-pulse 1.4s ease-in-out infinite;
  border-left-color: var(--accent) !important;
  outline: 1px solid rgba(91, 138, 245, 0.4);
  border-radius: 4px;
}
.search-empty { color: var(--text-muted); font-size: 12px; padding: 12px 0; }

/* ── Favourite link star ── */
.btn-fav-link {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-dim); padding: 2px 4px;
}
.btn-fav-link.active { color: #f1c40f; }

/* ── Followed modal header ── */
.followed-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.followed-modal-header h2 { margin: 0; }
.followed-modal-actions { display: flex; gap: 6px; }

/* ── Settings followed list ── */
.followed-list { margin-top: 8px; max-height: 200px; overflow-y: auto; }
.followed-list-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.followed-list-row:last-child { border-bottom: none; }
.followed-list-swatch {
  width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0;
  cursor: pointer; border: 1px solid rgba(255,255,255,0.2);
}
.followed-list-name { flex: 1; font-size: 12px; }
.followed-list-unfollow, .followed-list-alleps {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-muted); font-size: 10px; padding: 2px 6px; cursor: pointer;
}
.followed-list-unfollow:hover { border-color: #e74c3c; color: #e74c3c; }
.followed-list-alleps:hover { border-color: var(--accent); color: var(--accent); }

/* ── All Episodes button ── */
.all-eps-btn {
  padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer;
  white-space: nowrap;
}
.all-eps-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── All Episodes Modal ── */
.episodes-content { max-height: 65vh; overflow-y: auto; }

.season-group { border-bottom: 1px solid var(--border); }
.season-group:last-child { border-bottom: none; }

.season-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 6px; cursor: pointer;
  font-size: 13px; font-weight: 600; user-select: none;
}
.season-header:hover { background: var(--surface2); }
.season-ep-count { font-size: 11px; color: var(--text-muted); font-weight: normal; flex: 1; }
.season-chevron  { font-size: 10px; color: var(--text-dim); }

.season-episodes { padding: 2px 0 6px; }
.season-ep-row {
  font-size: 12px;
  cursor: pointer;
}
.season-ep-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 10px;
}
.season-ep-row:hover .season-ep-summary,
.season-ep-row.ep-open .season-ep-summary { background: var(--surface2); }
.season-ep-links {
  display: none;
  padding: 4px 10px 6px 34px;
  gap: 6px;
  flex-wrap: wrap;
}
.season-ep-row.ep-open .season-ep-links { display: flex; }
.s-ep-no-links { font-size: 11px; color: var(--text-dim); }
.s-ep-code  { font-family: var(--mono); font-size: 10px; color: var(--accent); flex-shrink: 0; }
.s-ep-title { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-ep-date  { font-family: var(--mono); font-size: 10px; color: var(--text-dim); flex-shrink: 0; }

/* Info modal — action buttons row */
.modal-show-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 8px;
}

/* ── Show Settings Modal ── */
.show-settings-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: var(--font);
  margin-bottom: 4px;
}
.show-settings-input:focus { outline: none; border-color: var(--accent); }

.ep-offset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.ep-offset-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  width: 30px;
  height: 30px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.ep-offset-btn:hover { border-color: var(--accent); color: var(--accent); }
.ep-offset-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 30px;
  text-align: center;
}
.ep-offset-hint {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.show-settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.show-settings-save {
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  padding: 7px 20px;
  font-size: 12px;
  transition: opacity 0.15s;
}
.show-settings-save:hover { opacity: 0.85; }
.show-settings-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 7px 16px;
  font-size: 12px;
}
.show-settings-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.search-term-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
}
.chip-label {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.search-term-chip {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.search-term-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Edit button in show row */
.edit-show-btn {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.edit-show-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Edit button in followed list */
.followed-list-edit {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
}
.followed-list-edit:hover { border-color: var(--accent); color: var(--accent); }

/* ── Palette switcher ── */
.palette-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.palette-btn:hover { border-color: var(--accent); }

.palette-btn-inner {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: conic-gradient(
    #5b8af5 0deg 72deg,
    #48c870 72deg 144deg,
    #f0a020 144deg 216deg,
    #e04040 216deg 288deg,
    #ff2d78 288deg 360deg
  );
}

.palette-panel {
  position: fixed;
  top: 60px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  z-index: 500;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 300px;
}
.palette-panel.hidden { display: none; }

.palette-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: 2px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  padding: 5px;
  transition: border-color 0.15s;
  font-family: var(--font);
}
.palette-swatch:hover { border-color: var(--border); }
.palette-swatch.active { border-color: var(--accent); }

.swatch-preview {
  width: 44px;
  height: 30px;
  border-radius: 5px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.swatch-accent {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
}
.swatch-name {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.shade-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.shade-row-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.shade-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}
.shade-row-value {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.reset-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  padding: 6px 4px 0;
}
.reset-mode-btn {
  flex: 1;
  font-size: 10px;
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
}
.reset-mode-btn:hover { background: var(--border); color: var(--text); }

/* ── Month View ──────────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  user-select: none;
}
.view-toggle-opt {
  padding: 2px 9px;
  border-radius: 16px;
  font-size: 11px;
  color: var(--text-muted);
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.view-toggle-opt.active {
  background: var(--accent);
  color: #fff;
}

.month-view .grid {
  grid-template-columns: repeat(7, minmax(110px, 1fr));
}

.month-view .day-col {
  min-height: 0;
}

.month-view .day-header {
  position: static;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
}

.month-view .day-name {
  font-size: 10px;
}

.month-view .day-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  margin-top: 0;
}

.month-view .row-line1,
.month-view .row-line2 { display: none; }

.row-compact { display: none; }

.month-view .row-compact {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 3px 5px;
}

.compact-line1 {
  display: flex;
  align-items: center;
  min-width: 0;
}

.compact-line2 {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  margin-top: 1px;
}

.compact-time {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.month-view .row-compact .ep-code {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--accent);
}

.month-view .row-compact .watched-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  min-width: 18px;
  font-size: 10px;
  padding: 0;
}

.compact-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-soft);
}
.compact-title > span { display: inline-block; }
.show-row:hover .compact-title.overflows > span {
  animation: show-name-marquee 4s 0.3s ease-in-out infinite;
}

.month-view .row-compact .badge {
  flex-shrink: 0;
  font-size: 8px;
  padding: 1px 4px;
}

.month-view .row-compact .info-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  min-width: 18px;
  font-size: 12px;
  padding: 0;
}

.month-view .show-body { padding: 0; }

/* ── Narrow desktop (viewport < 1120px) — 2-row header ─────────────────────── */
/* Row 1: logo+nav (left) · icons/user (right)                                */
/* Row 2: filter buttons + Filters button, full-width                         */
@media (min-width: 721px) and (max-width: 1119px) {

  header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 6px;
  }

  /* Row 1 left: logo + week nav */
  .header-left {
    grid-column: 1;
    grid-row: 1;
  }

  /* Row 1 right: icons + user */
  .header-right {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  /* Row 2: filter buttons + Filters button — full width */
  .header-center {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }

  /* Header is 2 rows: nav row (~40px) + filter row (~44px) + gap + padding ≈ 112px */
  .grid-wrapper {
    height: calc(100vh - 112px - 27px);
  }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {

  body { min-width: 0; }

  /* Switch to flex so row 1 (logo+nav | icons) can share space naturally,
     then filter buttons and sliders each get their own full-width row.     */
  header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    row-gap: 5px;
    padding: 8px 10px 6px;
  }

  /* Row 1 left: logo + week-nav (< date >) + view-toggles-group wraps below */
  .header-left {
    flex: 1;
    min-width: 0;
    order: 1;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 4px;
  }

  /* week-nav takes the remaining space next to the logo */
  .week-nav { flex: 1; min-width: 0; }

  /* view-toggles-group wraps to its own line within header-left */
  .view-toggles-group {
    flex: 0 0 100%;
    gap: 8px;
  }

  /* Row 1 right: icon buttons + user */
  .header-right {
    order: 2;
    flex-shrink: 0;
    gap: 5px;
    align-self: flex-start;
  }

  /* Row 2 — filter buttons, full width */
  .header-center {
    order: 3;
    flex: 0 0 100%;
    justify-content: center;
  }

  /* Compact elements to keep row 1 tight */
  .header-logo { height: 32px; flex-shrink: 0; }
  .week-label { min-width: 0; font-size: 10px; }
  .week-jump-input { display: none; }   /* hide date picker — saves ~80px */
  .btn-label { display: none; }         /* all text-icon-btns show icon only */

  /* Larger touch targets */
  .filter-btn { padding: 7px 12px; font-size: 12px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  #btn-search { padding: 6px; }

  /* Grid: account for extra toggle row */
  .grid-wrapper {
    height: calc(100vh - 148px - 27px);
    overflow: auto;
  }

  .grid {
    grid-template-columns: repeat(7, minmax(80px, 1fr));
  }

  .day-name { font-size: 11px; }
  .day-date { font-size: 10px; }

  /* Today column: keep accent */
  .today .day-header {
    background: var(--surface2);
    border-bottom-color: var(--accent);
  }

  /* Show rows: slightly more padding for touch */
  .show-body { padding: 6px 8px 6px 8px; }

  .watched-btn {
    width: 20px;
    height: 20px;
  }

  /* Modals: near full-screen */
  .modal,
  .modal-wide {
    width: 95vw;
    max-width: 95vw;
    max-height: 92vh;
    padding: 16px 14px;
  }

  .modal h2 { font-size: 15px; }

  /* Settings link entries: collapse URL col so it fits */
  .link-entry {
    grid-template-columns: auto minmax(0,1fr) minmax(0,1.5fr) auto auto auto auto;
    gap: 4px;
  }
  .link-entry input { padding: 4px 6px; font-size: 10px; }

  /* Lang add row: stack on very narrow */
  .lang-add-row { flex-wrap: wrap; }

  /* Configurator row: stack */
  .configurator-row { flex-direction: column; }

  /* Followed / hidden lists: taller scroll area on mobile */
  .followed-list  { max-height: 300px; }
  .hidden-list    { max-height: 300px; }
  .episodes-content { max-height: 70vh; }

  /* Info modal poster: smaller on mobile */
  .modal-poster { width: 60px; height: 84px; }
  .modal-show-title { font-size: 15px; }

  /* Search input: full width already, just ensure it renders nicely */
  .search-input { font-size: 16px; } /* prevent iOS zoom-in on focus */

  /* Auth pages: slightly narrower card */
  .auth-card { padding: 24px 18px; }

  /* User info text: hide on small screens, show logout only */
  .user-info { display: none; }

  /* Import modal: near full-screen on mobile */
  .import-modal {
    width: 95vw;
    max-width: 95vw;
    max-height: 92vh;
    padding: 16px 14px;
  }
  .import-tab { padding: 6px 8px; font-size: 11px; }
}

/* ── Grid loading spinner ── */
.grid-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}
.grid-loading img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  animation: koala-spin 1s linear infinite;
}
@keyframes koala-spin {
  to { transform: rotate(360deg); }
}

/* ── Text colour overrides — must be last to win specificity order ── */
html.light-mode .show-name,
html.light-mode .compact-title,
html.light-mode .detail-title,
html.light-mode .show-row.expanded .detail-title { color: #000; }
.show-name,
.compact-title,
.detail-title,
.show-row.expanded .detail-title { color: #fff; }

/* ── Scrollbars ── */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* Watched hide mode */
body.hide-watched .show-row.is-watched { display: none !important; }

/* Season checkbox in All Episodes modal */
.season-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 4px;
  accent-color: var(--accent);
}

/* Unwatched Only button toolbar */
#eps-modal-toolbar { margin-bottom: 10px; }
.ep-filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
}
.ep-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ep-filter-btn:hover:not(.active) { border-color: var(--text-muted); color: var(--text); }

/* Watched: Shadow/Hide toggle in filters modal header */
.watched-mode-toggle { display: flex; align-items: center; gap: 4px; margin-left: 4px; border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; }
.watched-mode-lbl { font-size: 11px; color: var(--text-muted); transition: color 0.15s; white-space: nowrap; }
.watched-mode-lbl.active { color: var(--text); font-weight: 600; }
.watched-mode-prefix { color: var(--text); font-weight: 700; margin-right: 2px; }
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(12px); }
