:root {
  --bg: #0f1117;
  --panel: #1a1d28;
  --panel2: #232735;
  --accent: #8b5cf6;
  --accent2: #ec4899;
  --text: #e8eaf0;
  --muted: #8b90a3;
  --border: #2c3142;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: #f87171; font-size: 13px; }

button {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: white; border: none; padding: 11px 18px;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
button:hover { opacity: .9; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--panel2); border: 1px solid var(--border); }

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login page ---------- */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1e1b3a, #0f1117 70%);
}
.login-box {
  background: var(--panel);
  padding: 36px; border-radius: 16px;
  width: 340px; text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-box h1 {
  margin: 0 0 4px; font-size: 22px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-box .sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-box input {
  width: 100%; padding: 12px; margin-bottom: 12px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
}
.login-box button { width: 100%; }

/* Profile picker (step 2 of login) */
.profile-screen { text-align: center; max-width: 720px; padding: 0 20px; }
.profile-heading {
  font-size: 26px; margin: 0 0 32px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.profile-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; margin-bottom: 20px;
}
.profile-tile { cursor: pointer; width: 110px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.profile-avatar {
  width: 90px; height: 90px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700; color: white;
  border: 3px solid transparent; transition: border-color .15s, transform .15s;
}
.profile-tile:hover .profile-avatar { border-color: var(--text); transform: scale(1.04); }
.profile-name { font-size: 14px; color: var(--muted); }
.profile-tile:hover .profile-name { color: var(--text); }
.add-avatar { background: var(--panel2); border: 2px dashed var(--border); font-size: 32px; color: var(--muted); }
.add-profile {
  margin: 10px auto 0; max-width: 320px; padding: 18px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.add-profile input {
  width: 100%; padding: 11px; margin-bottom: 10px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
}
.add-profile-btns { display: flex; gap: 8px; }
.add-profile-btns button { flex: 1; padding: 9px; font-size: 13px; }

/* ---------- Top navigation ---------- */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
  position: relative; z-index: 200; /* above the popup-overlay (z-index: 100) */
}
.nav-left { display: flex; align-items: center; gap: 18px; }
.brand { font-weight: 700; font-size: 16px; }
.nav-link {
  color: var(--muted); font-size: 14px; font-weight: 500; padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--text); border-bottom-color: var(--accent); }
.nav-right { display: flex; gap: 14px; align-items: center; }
.users { font-size: 12px; color: var(--muted); }
.nav-name { font-size: 13px; font-weight: 600; }
.logout-btn {
  background: var(--panel2); border: 1px solid var(--border);
  padding: 7px 14px; font-size: 12px; font-weight: 500;
}

/* ---------- Season loader bar ---------- */
.loaderbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 22px; background: var(--panel2); border-bottom: 1px solid var(--border);
}
.loaderbar select, .loaderbar input[type=number] {
  padding: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
}
.loaderbar input[type=number] { width: 90px; }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.status { font-size: 13px; color: var(--muted); }
.loaderbar-spacer { flex: 1; min-width: 8px; }

/* ---------- Watch page layout (fixed viewport, no whole-page scroll) ---------- */
/* Scoped to .watch-shell rather than body, so this never affects other pages. */
.watch-shell {
  height: 100vh;
  height: 100dvh; /* accounts for mobile browser chrome */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.watch-shell .nav,
.watch-shell .loaderbar { flex-shrink: 0; }

main {
  flex: 1 1 auto;
  min-height: 0; /* required for children to be allowed to shrink/scroll inside flex */
  display: flex; gap: 18px; padding: 18px 22px; align-items: stretch;
}
.player-col { flex: 1 1 70%; min-width: 0; display: flex; flex-direction: column; }
.player-stage {
  flex: 1 1 auto; position: relative; min-height: 0;
  background: #000; border-radius: 12px; overflow: hidden;
}
#player { position: absolute; inset: 0; width: 100%; height: 100%; }
#player iframe { width: 100%; height: 100%; border: 0; }
/* Cover-image fallback for entries without a trailer: a blurred, darkened
   copy fills the box so there are no harsh black bars, with the same image
   shown sharp and fully visible (never cropped) on top. */
.player-cover-wrap {
  position: absolute; inset: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.player-cover-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(35px) brightness(0.35); transform: scale(1.15);
}
.player-cover-fg {
  position: relative; z-index: 1; max-width: 88%; max-height: 88%;
  object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
/* Playback controls now live inline in the loader bar, not below the player. */
.loaderbar .controls { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.loaderbar .controls button { background: var(--panel); border: 1px solid var(--border); padding: 9px 14px; font-size: 13px; }
.finish-btn {
  border-color: #34d399 !important; color: #34d399;
  margin-right: 6px; padding-right: 16px !important;
  position: relative;
}
.finish-btn::after {
  content: ""; position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
  width: 1px; height: 22px; background: var(--border);
}
.skip-status {
  font-size: 12px; font-weight: 600; color: var(--accent2);
  background: var(--panel); border: 1px solid var(--accent2); border-radius: 20px;
  padding: 5px 12px;
}

.info-col {
  flex: 1 1 30%; min-width: 280px; max-width: 420px;
  display: flex; flex-direction: column; min-height: 0;
}
.info-col-scroll { flex: 1 1 auto; overflow-y: auto; padding-right: 4px; min-height: 0; }
.info-panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; min-height: 200px;
}
.info-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.info-tab {
  background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 8px 10px; cursor: pointer; border-bottom: 2px solid transparent; border-radius: 0;
}
.info-tab:hover { color: var(--text); opacity: 1; }
.info-tab.active { color: var(--text); border-bottom-color: var(--accent2); }
.info-panel h3 { margin: 0 0 4px; font-size: 18px; }
.info-panel .romaji { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.meta-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; }
.meta-row span { color: var(--muted); }
.genres { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.genre { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); }
.desc { font-size: 13px; line-height: 1.6; color: #c5c9d6; max-height: 160px; overflow-y: auto; }
.score { color: #34d399; font-weight: 600; }
.airdate { font-size: 12px; color: var(--muted); margin: 0 0 10px; }

.quick-vote-row { display: flex; gap: 8px; margin: 4px 0 14px; }
.vote-btn {
  flex: 1; background: var(--panel2); border: 1px solid var(--border);
  padding: 8px; font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.vote-btn.active.vote-up { border-color: #34d399; color: #34d399; background: rgba(52,211,153,.12); }
.vote-btn.active.vote-down { border-color: #f87171; color: #f87171; background: rgba(248,113,113,.12); }

.note-block { margin-top: 14px; }
.note-block label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.note-block textarea {
  width: 100%; min-height: 70px; resize: vertical;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 10px; font-size: 13px;
}
.note-display {
  margin-top: 12px; padding: 12px; background: var(--panel2);
  border-left: 3px solid var(--accent); border-radius: 6px;
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.note-display a { color: var(--accent2); }

/* Studio tab: reuses the search-result-row look from My List */
.tab-result-list { max-height: 320px; overflow-y: auto; }

/* Staff / Cast tabs */
.staff-list { max-height: 320px; overflow-y: auto; padding-right: 10px; }
.staff-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.staff-row:last-child { border-bottom: none; }
.staff-name { font-weight: 500; }
.staff-role { color: var(--muted); font-size: 12px; text-align: right; flex-shrink: 0; }


/* Tracking box */
.track-box {
  margin-top: 14px; padding: 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
}
.track-box h4, .group-view h4 {
  margin: 0 0 12px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.track-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.track-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.track-row label { font-size: 13px; width: 70px; color: var(--muted); flex-shrink: 0; }
.track-row.col label { width: auto; }
.track-row select {
  flex: 1; padding: 8px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
}
.ep-ctrl { display: flex; align-items: center; gap: 6px; }
.ep-ctrl button {
  width: 30px; height: 30px; padding: 0; font-size: 18px; line-height: 1;
  background: var(--panel2); border: 1px solid var(--border);
}
.ep-ctrl input {
  width: 60px; padding: 7px; text-align: center;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.rating-ctrl { display: flex; align-items: center; gap: 10px; flex: 1; }
.rating-ctrl input[type=range] { flex: 1; accent-color: var(--accent); }
.rating-val { font-weight: 700; width: 28px; text-align: center; color: var(--accent2); }
.track-box textarea {
  width: 100%; min-height: 56px; resize: vertical;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 9px; font-size: 13px;
}
.saved-hint { font-size: 11px; color: #34d399; margin: 4px 0 0; opacity: 0; transition: opacity .2s; }
.saved-hint.show { opacity: 1; }

/* Group view */
.group-view {
  margin-top: 14px; padding: 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
}
.group-view-body { display: flex; flex-direction: column; gap: 8px; }
.gv-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.gv-name { font-weight: 600; min-width: 80px; }
.gv-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); }
.gv-badge.watching { color: #34d399; border-color: #34d39955; }
.gv-badge.planned { color: #60a5fa; border-color: #60a5fa55; }
.gv-badge.completed { color: var(--accent2); border-color: var(--accent2); }
.gv-badge.dropped { color: var(--muted); }
.gv-rating { color: var(--accent2); font-weight: 600; }
.gv-empty { font-size: 12px; color: var(--muted); }

/* Mini "up next" strip, pinned under the info column (not full page width).
   Sized to fit 4 thumbnails + the "+" tile without a scrollbar at typical
   column widths; degrades to a horizontal scroll on very narrow windows. */
.mini-strip-block { flex-shrink: 0; margin-top: 14px; }
.mini-strip {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
}
.strip-item {
  flex: 0 0 auto; width: 76px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; transition: border-color .1s;
}
.strip-item:hover { border-color: var(--accent); }
.strip-item.active { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
.strip-item img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--panel2); }
.strip-item .si-title { font-size: 10px; line-height: 1.25; padding: 4px 5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.strip-add-tile {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); background: var(--panel2);
  font-size: 22px; color: var(--muted); transition: border-color .1s, color .1s;
}
.strip-add-tile:hover { border-color: var(--accent); color: var(--text); }

/* Full trailer list, opened on demand in a popup instead of always on-screen */
.popup-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 9, 14, 0.75);
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.popup-panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 1100px; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.popup-header {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.popup-header h2 { font-size: 16px; margin: 0; flex: 1; }
.popup-header select {
  padding: 7px 12px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px;
}
.join-party-panel {
  max-width: 380px; padding: 32px; text-align: center; align-items: stretch;
}
.join-party-panel h2 {
  margin: 0 0 12px; font-size: 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.join-party-panel p { font-size: 13px; line-height: 1.6; margin: 0 0 22px; }
.join-party-panel button { width: 100%; }
.popup-close {
  background: var(--panel2); border: 1px solid var(--border);
  width: 32px; height: 32px; padding: 0; font-size: 14px; border-radius: 8px;
}
.popup-hint { padding: 10px 20px 0; margin: 0; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.popup-panel .list { padding: 20px; overflow-y: auto; }

.ranking-list { padding: 8px 20px 20px; overflow-y: auto; }
.ranking-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ranking-row:last-child { border-bottom: none; }
.ranking-rank { font-size: 14px; font-weight: 700; color: var(--muted); width: 28px; flex-shrink: 0; text-align: center; }
.ranking-cover { width: 36px; height: 50px; object-fit: cover; border-radius: 4px; background: var(--panel2); flex-shrink: 0; }
.ranking-title { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; }
.ranking-score { font-size: 13px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.ranking-empty { padding: 24px 4px; text-align: center; color: var(--muted); font-size: 13px; }

.list { display: flex; flex-wrap: wrap; gap: 16px; }
.card {
  flex: 1 1 175px; max-width: 220px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; cursor: grab; transition: transform .1s, border-color .1s, opacity .1s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card.active { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
.card.dragging { opacity: 0.4; cursor: grabbing; }
.card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card-img-wrap {
  position: relative; width: 100%; height: 0; padding-bottom: 150%; /* 2:3 ratio via width */
  background: #000; overflow: hidden;
}
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.card-score {
  position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.78);
  color: #34d399; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
}
.card .ct { padding: 10px; }
.ct-title {
  font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ct-meta { font-size: 11px; color: var(--muted); }
.card .no-trailer { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ---------- Calendar page ---------- */
.calendar-page { padding: 24px 22px 60px; max-width: 1500px; margin: 0 auto; }
.cal-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.cal-mode-tabs { display: flex; gap: 8px; }
.cal-mode-tab {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  padding: 8px 16px; font-size: 13px; font-weight: 500;
}
.cal-mode-tab.active { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: white; border: none; }
.cal-season-controls { display: flex; gap: 8px; align-items: center; }
.cal-season-controls select, .cal-season-controls input {
  padding: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
}
.cal-season-controls input { width: 90px; }
.cal-tz-note { font-size: 11px; color: var(--muted); margin-left: auto; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; align-items: start; }
.cal-day {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; min-height: 160px;
}
.cal-day.today { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
.cal-day-header {
  padding: 10px 12px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;
  background: var(--panel2);
}
.cal-day.today .cal-day-header { color: var(--accent2); }
.cal-day-date { font-size: 11px; color: var(--muted); font-weight: 400; }
.cal-day.today .cal-day-date { color: var(--accent2); }
.cal-day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 600px; overflow-y: auto; }
.cal-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 16px 0; margin: 0; }

.cal-now-marker { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.cal-now-marker::before, .cal-now-marker::after { content: ""; flex: 1; height: 1px; background: var(--accent2); }
.cal-now-marker span { font-size: 10px; font-weight: 700; color: var(--accent2); text-transform: uppercase; }

.cal-entry { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-entry-main { display: flex; align-items: center; gap: 8px; padding: 7px; }
.cal-time { font-size: 11px; font-weight: 700; color: var(--accent2); flex-shrink: 0; width: 40px; }
.cal-cover { width: 28px; height: 40px; object-fit: cover; border-radius: 3px; background: var(--panel); flex-shrink: 0; }
.cal-entry-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cal-title {
  font-size: 12px; font-weight: 500; line-height: 1.25; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cal-ep { font-size: 10px; color: var(--muted); }
.cal-streams { padding: 0 7px 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.cal-stream-link {
  font-size: 10px; padding: 3px 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; color: var(--accent2);
}

@media (max-width: 1000px) {
  .cal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .cal-grid { grid-template-columns: 1fr; }
}

/* ---------- My List page ---------- */
.list-page { padding: 24px 22px 60px; max-width: 1100px; margin: 0 auto; }
.list-page h1 { font-size: 22px; margin: 0 0 18px; }

.search-box { position: relative; margin-bottom: 20px; }
.search-box input {
  width: 100%; padding: 13px 16px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 10;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  max-height: 360px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.sr-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sr-item:last-child { border-bottom: none; }
.sr-item img { width: 38px; height: 54px; object-fit: cover; border-radius: 4px; background: var(--panel); flex-shrink: 0; }
.sr-info { flex: 1; min-width: 0; }
.sr-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { font-size: 11px; color: var(--muted); }
.sr-add { padding: 6px 12px; font-size: 12px; flex-shrink: 0; }
.sr-add.added { background: var(--panel); border: 1px solid var(--border); cursor: default; opacity: .7; }
.sr-empty { padding: 14px; font-size: 13px; color: var(--muted); text-align: center; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  padding: 8px 16px; font-size: 13px; font-weight: 500;
}
.tab.active { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: white; border: none; }

.empty-hint {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; font-size: 14px; color: var(--muted); text-align: center;
}

.tracked-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tracked-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; position: relative; display: flex; gap: 12px;
}
.tracked-card .tc-cover { width: 70px; height: 100px; object-fit: cover; border-radius: 6px; background: var(--panel2); flex-shrink: 0; }
.tc-body { flex: 1; min-width: 0; }
.tc-title { font-size: 14px; font-weight: 600; margin: 0 0 8px; padding-right: 20px; }
.tc-title a { color: var(--text); }
.tc-title a:hover { color: var(--accent2); }
.tc-remove {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--panel2); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.tc-remove:hover { color: #f87171; border-color: #f87171; }
.tc-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.tc-row select {
  flex: 1; padding: 6px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px;
}
.tc-ep { display: flex; align-items: center; gap: 4px; }
.tc-ep button {
  width: 22px; height: 22px; padding: 0; font-size: 14px; line-height: 1;
  background: var(--panel2); border: 1px solid var(--border);
}
.tc-ep input {
  width: 42px; padding: 4px; text-align: center; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.tc-rating { display: flex; align-items: center; gap: 8px; flex: 1; }
.tc-rating input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.tc-rating span { font-weight: 700; color: var(--accent2); width: 20px; text-align: center; }
.tc-note-toggle { font-size: 11px; color: var(--muted); cursor: pointer; background: none; padding: 0; }
.tc-note-toggle:hover { color: var(--text); opacity: 1; }
.tc-note {
  width: 100%; min-height: 50px; margin-top: 6px; resize: vertical;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 7px; font-size: 12px;
}

@media (max-width: 820px) {
  main { flex-direction: column; overflow-y: auto; }
  .player-col { flex: none; }
  .player-stage { aspect-ratio: 16/9; flex: none; min-height: 0; }
  .info-col { width: 100%; max-width: none; }
  .info-col-scroll { overflow-y: visible; }
  /* Mini-strip (incl. the "+" tile) stays visible - it's the only way to
     reach the full list popup, and horizontal swipe-scroll works fine here. */
}

/* ========== Airing Calendar page ========== */
.schedule-controls {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--panel2); border-bottom: 1px solid var(--border);
}
.schedule-controls-left  { display: flex; gap: 8px; align-items: center; }
.schedule-controls-right { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.schedule-controls select, .schedule-controls input[type=number] {
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
}
.schedule-controls input[type=number] { width: 80px; }

.schedule-empty { padding: 48px; text-align: center; color: var(--muted); font-size: 14px; }

/* Calendar wraps in a scrollable area so very wide weeks still work */
.calendar-wrap { flex: 1; overflow-x: auto; overflow-y: auto; padding: 16px 22px 24px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 10px; }

.cal-col { display: flex; flex-direction: column; min-width: 130px; }

.cal-day-header {
  position: sticky; top: 0; z-index: 2;
  padding: 8px 10px 6px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px 8px 0 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
}
.cal-today .cal-day-header { background: rgba(109,40,217,.18); border-color: var(--accent); }
.cal-day-name { font-size: 13px; font-weight: 700; color: var(--text); }
.cal-day-date { font-size: 11px; color: var(--muted); }

.cal-entries {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  padding: 6px 0;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px;
  padding: 8px 6px;
}
.cal-today .cal-entries { border-color: var(--accent); }

/* Individual airing card */
.airing-card {
  display: flex; gap: 7px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px; transition: border-color .1s;
}
.airing-card:hover { border-color: var(--accent); }
.airing-card.aired { opacity: 0.45; }

.airing-cover {
  width: 36px; height: 50px; object-fit: cover; border-radius: 4px;
  background: var(--panel2); flex-shrink: 0;
}
.airing-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.airing-time-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.airing-time { font-size: 11px; font-weight: 700; color: var(--accent2); }
.airing-title {
  font-size: 12px; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  color: var(--text); text-decoration: none;
}
.airing-title:hover { color: var(--accent); }
.airing-ep { font-size: 11px; color: var(--muted); }
.airing-streams { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.stream-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.stream-badge:hover { border-color: var(--accent); color: var(--text); }

/* Tracking status dot (tiny indicator from My List) */
.track-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.track-dot.track-planned   { background: #60a5fa; }
.track-dot.track-watching  { background: #34d399; }
.track-dot.track-completed { background: var(--accent2); }
.track-dot.track-dropped   { background: var(--muted); }

/* ========== Settings page ========== */
.settings-page {
  max-width: 620px; margin: 36px auto; padding: 0 22px; display: flex; flex-direction: column; gap: 22px;
}
.settings-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px;
}
.settings-heading { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 16px; }
.settings-row { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.settings-label { color: var(--muted); min-width: 80px; }
.settings-value { font-weight: 600; }
.settings-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
.settings-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.file-pick-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; font-size: 13px; font-weight: 500; color: var(--text);
  transition: border-color .1s;
}
.file-pick-btn:hover { border-color: var(--accent); }
.file-pick-btn input[type="file"] { display: none; }

.danger-zone { border-color: rgba(239,68,68,.3); }
.danger-zone .settings-heading { color: #f87171; }
.btn-danger { background: rgba(239,68,68,.12); border-color: #f87171; color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,.22); opacity: 1; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }

#deleteConfirmInput {
  padding: 9px 12px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; min-width: 200px;
}

/* Make the nav-name link look like the user's name, not a hyperlink */
a.nav-name { text-decoration: none; }
a.nav-name:hover { opacity: .8; }
a.nav-name.active { border-bottom: 2px solid var(--accent2); padding-bottom: 2px; }

/* Season controls group inside schedule bar (hidden when "currently airing" is active) */
.schedule-season-group { display: flex; gap: 8px; align-items: center; }
.schedule-season-group.hidden { display: none; }

/* Group-tracking pills on airing calendar cards */
.airing-group { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.airing-group-pill {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 20px;
  white-space: nowrap;
}
.airing-group-pill.track-planned   { background: rgba(96,165,250,.2);  color: #60a5fa; }
.airing-group-pill.track-watching  { background: rgba(52,211,153,.2);  color: #34d399; }
.airing-group-pill.track-completed { background: rgba(167,139,250,.2); color: #a78bfa; }
.airing-group-pill.track-dropped   { background: rgba(156,163,175,.2); color: #9ca3af; }

/* NOW-line: full-width line with centered time badge */
.cal-now-line {
  display: flex; align-items: center; gap: 6px; margin: 2px 0; flex-shrink: 0;
}
.cal-now-line::before, .cal-now-line::after {
  content: ""; flex: 1; height: 1px; background: var(--accent2);
}
.cal-now-label {
  font-size: 10px; font-weight: 700; color: var(--accent2);
  letter-spacing: .3px; white-space: nowrap;
}

/* ========== Landing page ========== */
.landing-page {
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  padding: 48px 24px; max-width: 860px; margin: 0 auto; gap: 40px;
}
.landing-hero { text-align: center; padding: 16px 0 8px; }
.landing-title {
  font-size: clamp(32px, 6vw, 52px); font-weight: 800; margin: 0 0 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.landing-tagline { font-size: 16px; color: var(--muted); margin: 0; }
.landing-welcome { font-size: 14px; color: var(--text); margin-top: 10px; }

.landing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.landing-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 20px; display: flex; flex-direction: column; gap: 10px;
  text-decoration: none; color: var(--text); transition: border-color .15s, transform .1s;
}
.landing-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.landing-card-icon { font-size: 28px; }
.landing-card-title { font-size: 15px; font-weight: 700; }
.landing-card-desc { font-size: 13px; color: var(--muted); line-height: 1.55; flex: 1; }
.landing-card-arrow { font-size: 12px; color: var(--accent2); align-self: flex-end; }

/* ========== Tube page ========== */
body.tube-body {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.tube-topbar {
  flex-shrink: 0; display: flex; gap: 10px; align-items: center;
  padding: 10px 22px; background: var(--panel2); border-bottom: 1px solid var(--border);
}
.tube-url-input {
  flex: 1; padding: 9px 14px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px;
}
.tube-url-input:focus { border-color: var(--accent); outline: none; }

.tube-workspace { flex: 1 1 auto; min-height: 0; background: #000; position: relative; }
.tube-player-wrap { width: 100%; height: 100%; position: relative; }
.tube-player-wrap #player { width: 100%; height: 100%; }
.tube-player-wrap #player iframe { width: 100%; height: 100%; border: 0; }

/* Canvas fills the player area exactly; CSS scales it from the fixed 1280×720 resolution */
#drawCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none; /* prevent scroll/zoom on touch devices */
}

.tube-controls {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 10px 22px; background: var(--panel2); border-top: 1px solid var(--border);
}
.ctrl-btn { background: var(--panel); border: 1px solid var(--border); padding: 8px 16px; font-size: 15px; }
.time-display { font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 90px; }
.seek-bar { flex: 1; accent-color: var(--accent); cursor: pointer; }

/* ---- Floating draw toolbar ---- */
.draw-toolbar {
  position: absolute; bottom: 16px; left: 16px; z-index: 20;
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  background: rgba(8, 9, 14, 0.88); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 8px 12px;
  backdrop-filter: blur(12px);
  user-select: none;
}
.mode-btn {
  font-size: 16px; padding: 6px 8px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color .1s;
}
.mode-btn.draw-active {
  border-color: var(--accent2); background: rgba(167,139,250,.18);
}
.draw-tools { display: flex; align-items: center; gap: 8px; }
.draw-tools.hidden { display: none; }

.toolbar-divider {
  width: 1px; height: 24px; background: rgba(255,255,255,.13); flex-shrink: 0;
}
.tool-group { display: flex; gap: 4px; }
.tool-btn {
  font-size: 15px; padding: 5px 9px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
}
.tool-btn.active { border-color: var(--accent2); background: rgba(167,139,250,.18); }

.color-grid { display: flex; gap: 5px; }
.color-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); cursor: pointer; padding: 0;
  transition: transform .1s, border-color .1s;
}
.color-swatch:hover { transform: scale(1.25); }
.color-swatch.active { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(167,139,250,.4); }

.size-btns { display: flex; gap: 4px; align-items: center; }
.size-btn {
  font-size: 12px; padding: 4px 9px; min-width: 28px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); transition: border-color .1s;
}
.size-btn.active { border-color: var(--accent2); background: rgba(167,139,250,.18); }

.clear-btn {
  font-size: 15px; padding: 5px 9px;
  background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.4);
  border-radius: 6px; color: #f87171;
}
.clear-btn:hover { opacity: .8; opacity: 1; background: rgba(239,68,68,.28); }

/* Volume slider + quality selector in tube controls */
.vol-slider  { width: 80px; accent-color: var(--accent); cursor: pointer; }
.quality-sel {
  padding: 5px 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px; cursor: pointer;
}

/* Tube workspace: player + playlist side by side */
.tube-workspace { display: flex; flex-direction: row; flex: 1 1 auto; min-height: 0; }
.tube-player-wrap { flex: 1 1 auto; min-width: 0; position: relative; background: #000; }

/* Playlist sidebar */
.tube-playlist-panel {
  flex-shrink: 0; width: 260px;
  background: var(--panel2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.tube-playlist-panel.hidden { display: none; }
.playlist-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.playlist-title { font-size: 13px; font-weight: 700; }
.playlist-close { background: none; border: none; font-size: 18px; color: var(--muted); padding: 0; }
.playlist-close:hover { color: var(--text); opacity: 1; }
.playlist-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.playlist-empty { padding: 18px 14px; font-size: 13px; color: var(--muted); text-align: center; }

.playlist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; transition: background .1s;
}
.playlist-item:hover { background: rgba(255,255,255,.05); }
.playlist-item.active { background: rgba(109,40,217,.2); border-left: 3px solid var(--accent); }
.playlist-item:not(.active) { border-left: 3px solid transparent; }

.playlist-thumb {
  width: 64px; height: 36px; object-fit: cover; border-radius: 4px;
  background: #111; flex-shrink: 0;
}
.playlist-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.playlist-item-title {
  font-size: 12px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.playlist-item-by { font-size: 10px; color: var(--muted); }
.playlist-item-remove {
  background: none; border: none; color: var(--muted); font-size: 16px;
  padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.playlist-item-remove:hover { color: #f87171; opacity: 1; }

/* Playlist toggle button */
.playlist-toggle-btn { margin-left: 4px; }

/* Playlist panel */
.tube-workspace { display: flex; }
.tube-playlist-panel {
  width: 270px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border);
}
.tube-playlist-panel.hidden { display: none; }
.pl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pl-header-title { font-size: 13px; font-weight: 700; }
.pl-close-btn { background: none; border: none; font-size: 14px; color: var(--muted); padding: 2px 6px; }
.pl-close-btn:hover { color: var(--text); opacity: 1; }

.pl-items { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.pl-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; transition: background .1s;
  border: 1px solid transparent;
}
.pl-item:hover { background: var(--panel2); }
.pl-item.pl-active { background: rgba(109,40,217,.15); border-color: var(--accent); }
.pl-thumb { width: 60px; height: 34px; object-fit: cover; border-radius: 4px; background: var(--panel2); flex-shrink: 0; }
.pl-title { flex: 1; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pl-remove { background: none; border: none; color: var(--muted); font-size: 12px; padding: 2px 5px; flex-shrink: 0; border-radius: 4px; }
.pl-remove:hover { color: #f87171; background: rgba(239,68,68,.12); opacity: 1; }

.pl-add-row { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.pl-url-input {
  flex: 1; padding: 7px 10px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.pl-add-btn { background: var(--accent); border: none; padding: 7px 12px; border-radius: 6px; font-weight: 700; color: #fff; }
.pl-add-btn:hover { opacity: .85; }

/* Playlist toggle button in topbar */
.pl-toggle-btn {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; font-size: 13px; white-space: nowrap;
}
.pl-toggle-btn:hover { border-color: var(--accent); opacity: 1; }

/* Undo / Redo buttons in draw toolbar */
.undo-redo-btn { font-size: 14px; min-width: 32px; }
.undo-redo-btn:disabled { opacity: .3; cursor: not-allowed; }

/* Profile avatar image (when a photo is uploaded) */
.profile-avatar-img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 50%;
}

/* Avatar preview circle on settings page */
.avatar-preview {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--panel2); border: 2px solid var(--border);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: var(--muted);
}

/* ===== Online avatars in the controls bar ===== */
.online-avatars {
  display: flex; align-items: center; margin-left: 10px;
}
.online-avatar-wrap {
  position: relative; margin-left: -8px; cursor: default;
  transition: transform .15s;
}
.online-avatar-wrap:first-child { margin-left: 0; }
.online-avatar-wrap:hover { transform: scale(1.15) translateY(-2px); z-index: 99 !important; }
.online-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--panel2);
  display: flex; align-items: center; justify-content: center;
}
.online-avatar-img { object-fit: cover; }
.online-avatar-init { font-size: 13px; font-weight: 700; color: #fff; }

/* ===== Geo-block popup (overlays the player stage) ===== */
.player-stage { position: relative; } /* make sure it's the containing block */
.geo-block-popup {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(8, 9, 14, 0.82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.geo-block-popup.hidden { display: none; }
.geo-block-inner {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 30px; max-width: 420px; width: 90%; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.geo-block-icon { font-size: 36px; margin-bottom: 10px; }
.geo-block-title { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
.geo-block-desc { font-size: 14px; color: var(--muted); margin: 0 0 20px; }
.geo-block-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.geo-btn {
  width: 100%; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.geo-btn-skip { background: rgba(109,40,217,.15); border: 1px solid var(--accent); color: #c4b5fd; }
.geo-btn-skip:hover { background: rgba(109,40,217,.3); opacity: 1; }
.geo-or { font-size: 12px; color: var(--muted); }
.geo-alt-row { display: flex; gap: 8px; width: 100%; }
.geo-url-input {
  flex: 1; padding: 9px 12px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px;
}
.geo-btn-alt { background: var(--accent); border: 1px solid var(--accent); color: #fff; white-space: nowrap; }
.geo-btn-alt:hover { opacity: .85; }
