:root {
  --bg: #000;
  --bg-elev: #000;
  --bg-card: #0a0a0a;
  --bg-hover: #161616;
  --glass-blur: 0px;
  --glass-border: #222;
  --glass-highlight: transparent;
  --text: #fff;
  --text-dim: #99a1ab;
  --text-faint: #666;
  --accent: #e50914;
  --accent-dim: #a30710;
  --danger: #ff4444;
  --radius: 10px;
  --sidebar-w: 240px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* ============ TOP BAR ============ */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  flex-shrink: 0;
  position: relative;
  z-index: 40; /* above #detail (30) — profile dropdown must paint over the detail page; below player (100) */
}

#logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 6px;
}
#logo:hover em { text-decoration: none; }
#logo:hover .logo-mark path { fill: #ff2432; }
#logo:focus-visible { outline: 2px solid var(--accent); }
#logo .logo-mark { width: 22px; height: 22px; flex-shrink: 0; }
#logo .logo-mark path { fill: var(--accent); }
#logo em { font-style: normal; color: var(--accent); }

#search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}

#search {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

#search:focus { border-color: var(--accent-dim); }

#search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 1.2rem;
  color: var(--text-faint);
}

#mode-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.mode-tab {
  padding: 8px 18px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
}

.mode-tab:hover { color: var(--text); background: var(--bg-hover); }
.mode-tab.active { color: #fff; background: var(--accent); }

#sidebar-toggle {
  font-size: 1.15rem;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
#sidebar-toggle:hover { color: var(--text); background: var(--bg-hover); }

#sidebar.pinned { border-right-color: #2e2e2e; }

#settings-btn {
  font-size: 1.25rem;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius);
}

#settings-btn:hover { color: var(--text); background: var(--bg-hover); }
#settings-btn.active { color: var(--accent); background: rgba(229,9,20,0.12); }

/* ============ LAYOUT ============ */
#main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ============ SIDEBAR ============ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--glass-border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 0;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item:hover { color: var(--text); background: var(--bg-hover); }
.cat-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6a6a6a;
  padding: 12px 14px 4px;
}

/* long-press menu reordering */
.cat-item { touch-action: pan-y; }
.menu-reordering { user-select: none; cursor: grabbing; }
.dragging-item {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  background: #1d1d1d;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  opacity: 0.95;
  transform: scale(1.02);
  cursor: grabbing;
}
.drag-placeholder {
  border: 1px dashed #3a3a3a;
  border-radius: var(--radius);
  margin: 2px 0;
  background: #050505;
}

.cat-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(229, 9, 20, 0.06);
}

.cat-count {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-left: 8px;
  flex-shrink: 0;
}

.cat-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cat-hide {
  font-size: 0.7rem;
  color: var(--text-faint);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.cat-item:hover .cat-hide { display: flex; }
.cat-hide:hover { color: var(--danger); background: var(--bg-hover); }

/* ============ CONTENT ============ */
#content {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
  background: transparent; /* body aurora glows through */
}

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

/* vertical grid used inside sports sections (TV-friendly navigation) */
.sports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

/* ---------- settings view: two-pane (category rail + panel) ---------- */
#settings-view { padding: 24px 28px 40px; }
.set-shell { display: flex; gap: 28px; max-width: 980px; }
.set-rail {
  flex: 0 0 190px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--glass-border);
  padding-right: 16px;
  align-self: flex-start;
  position: sticky;
  top: 16px;
}
.set-rail-item {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.set-rail-item:hover { color: var(--text); background: #161616; }
.set-rail-item.active { color: var(--accent); background: rgba(229,9,20,0.08); font-weight: 600; }
.set-pane { flex: 1; min-width: 0; }
.set-pane .set-section { margin-bottom: 0; }
.set-section h2 {
  font-size: 1.15rem;
  margin: 0 0 16px;
  color: var(--text);
}
@media (max-width: 700px) {
  .set-shell { flex-direction: column; gap: 14px; }
  .set-rail {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding: 0 0 10px;
    position: static;
  }
  .set-rail-item { padding: 7px 12px; font-size: 0.88rem; }
}
.set-account { color: var(--text-dim); font-size: 0.92rem; display: grid; gap: 6px; margin-bottom: 14px; }
.set-account .set-k { display: inline-block; min-width: 110px; color: #888; }
.set-account .set-v { color: var(--text); }
.set-btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-ghost.danger { color: #ff6b6b; border-color: #4a2626; }
.btn-ghost.danger:hover { background: #2a1515; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid #1d1d1d;
  font-size: 0.95rem;
}
.set-toggle {
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: #2a2a2a;
  border: 1px solid var(--glass-border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.set-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #777;
  transition: left 0.15s ease, background 0.15s ease;
}
.set-toggle.on { background: var(--accent); border-color: var(--accent); }
.set-toggle.on::after { left: 22px; background: #0a0a0a; }
.set-select {
  background: #1a1a1a;
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 0.92rem;
}
.set-entry-list { max-height: 260px; overflow-y: auto; border: 1px solid #222; border-radius: var(--radius); margin-bottom: 12px; }
.set-entry { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #161616; font-size: 0.9rem; }
.set-entry:last-child { border-bottom: none; }
.set-entry:hover { background: #161616; }
.set-entry input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; flex-shrink: 0; }
.set-entry-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.set-collapse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 1px solid #262626;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text);
}
.set-collapse-head:hover { background: #161616; }
.set-collapse-count { color: var(--text-dim); }
.set-collapse-arrow { color: #777; font-size: 0.85rem; transition: transform 0.15s ease; }
.set-collapse-head.open .set-collapse-arrow { transform: rotate(90deg); }
.set-collapse-body { margin-top: 10px; }

/* multi-account switcher */
#acct-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.acct-chip {
  background: #1a1a1a;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-dim);
  padding: 6px 14px;
  font-size: 0.88rem;
  cursor: pointer;
}
.acct-chip:hover { color: var(--text); border-color: #555; }
.acct-chip.active { border-color: var(--accent); color: var(--accent); }
.acct-row { justify-content: space-between; }
.acct-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-actions { display: flex; gap: 8px; flex-shrink: 0; }
.acct-actions .btn-ghost { padding: 5px 12px; font-size: 0.85rem; }

/* profile avatar + dropdown (topbar, right of gear) */
#profile-wrap { position: relative; flex-shrink: 0; }
#profile-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3a3a3a;
}
#profile-btn:hover { border-color: var(--accent); }
#profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-elev);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.7), inset 0 1px 0 var(--glass-highlight);
  padding: 6px;
  z-index: 400;
}
#profile-menu[hidden] { display: none; }
.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  padding: 9px 10px;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  text-align: left;
}
.profile-item:hover { background: #1f1f1f; }
.profile-item.active { background: #191919; }
.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-check { color: var(--accent); font-weight: 700; }
.profile-add .profile-avatar { background: #222; color: var(--text-dim); border: 1px dashed #444; }
.profile-signout { border-top: 1px solid #222; margin-top: 4px; padding-top: 11px; }
.profile-signout .profile-avatar { background: #2a1515; color: #ff6b6b; border: 1px solid #4a2626; }
.profile-signout .profile-label { color: #ff8787; }

/* themed prompt dialog (profile naming) */
#ask-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300; /* above wizard (1200): add-profile name dialog opens over the login modal */
}
#ask-backdrop[hidden] { display: none; }
#ask-dialog {
  background: var(--bg-elev);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), inset 0 1px 0 var(--glass-highlight);
  padding: 22px 24px;
  width: min(400px, calc(100vw - 40px));
}
#ask-dialog h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--text); }
#ask-dialog .sub { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 14px; line-height: 1.45; }
#ask-input {
  width: 100%;
  background: #1c1c1c;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 12px;
  margin-bottom: 16px;
}
#ask-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229,9,20,0.15); }
#ask-dialog .btn-row { display: flex; gap: 10px; justify-content: flex-end; }

/* settings text inputs (Trakt keys) */
.set-input {
  background: #1a1a1a;
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
}
.set-input:focus { outline: none; border-color: var(--accent); }
.simkl-msg { color: var(--text-dim); font-size: 0.88rem; }
.simkl-msg b { color: var(--text); }
.simkl-code { color: var(--accent); font-size: 1.1rem; letter-spacing: 0.12em; padding: 0 6px; }

/* ============ SORT BAR (movies/series) ============ */
#sort-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sort-btn {
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}

.sort-btn:hover { color: var(--text); background: var(--bg-hover); }
.sort-btn.active { background: var(--accent); color: #fff; }

.ch-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  display: flex;
  flex-direction: column;
  user-select: none;
}

.ch-card:hover { background: var(--bg-hover); transform: translateY(-2px); }
.ch-card.playing { outline: 2px solid var(--accent); }

.ch-logo-box {
  aspect-ratio: 16 / 9;
  background: #141414;
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

/* portrait poster style for movies/series */
.ch-poster-box {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius) var(--radius) 0 0;
}

.ch-poster-box .ch-logo {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
}

.ch-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ch-rating {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(0,0,0,0.72);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.ch-hide {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
}

.ch-rating ~ .ch-hide, .ch-poster-box .ch-hide { left: auto; right: 8px; }
.ch-fav + .ch-hide { left: 8px; right: auto; }

/* Rotten Tomatoes score on grid cards — bottom-right, opposite the star */
.ch-tomato {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  color: #9ca3af;
  z-index: 2;
  pointer-events: none;
}
.ch-tomato:empty { display: none; }
.ch-tomato.fresh { color: #4ade80; }
.ch-tomato.rotten { color: #f87171; }

/* "Clear filters" action inside the grid empty state */
.empty-clear-btn {
  margin-top: 14px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
}
.empty-clear-btn:hover { filter: brightness(1.12); }
.ch-poster-box .ch-hide { right: 8px; left: auto; }

.ch-card:hover .ch-hide { display: flex; }
.ch-hide:hover { color: var(--danger); background: rgba(0,0,0,0.8); }

.ch-logo-fallback {
  color: var(--text-faint);
  font-size: 1.6rem;
  font-weight: 800;
}

.ch-fav {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.05rem;
  color: var(--text-dim);
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
}

.ch-card:hover .ch-fav, .ch-fav.on { opacity: 1; }
.ch-fav.on { color: var(--accent); }

.ch-name {
  padding: 9px 10px 11px;
  font-size: 0.82rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}

/* now/next line under name (live only) */
.ch-epg {
  padding: 0 10px 9px;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-epg .epg-time { color: var(--accent-dim); }

/* ============ EMPTY / LOAD STATES ============ */
#empty, #loading {
  color: var(--text-dim);
  padding: 60px 0;
  text-align: center;
  font-size: 0.95rem;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #222;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ PLAYER OVERLAY ============ */
#player {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: none;
}

#player.open { display: flex; flex-direction: column; }

#video-wrap {
  flex: 1;
  position: relative;
  background: #000; /* wet-dark behind video, keeps glass feel */
  min-height: 0;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

#player-error {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

#player-error.show { display: flex; }

#player-error .code { font-size: 2.4rem; }

/* auto-skip toast: small unobtrusive notice while zapping past dead channels */
#player-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 10px 18px;
  background: #000;
  color: #fff;
  border: 1px solid #333;
  border-radius: var(--radius, 10px);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 30;
  pointer-events: none;
}

#player-error button {
  margin-top: 8px;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
}

/* ===== Netflix-style overlay chrome (floats on video) ===== */
#chrome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.25s ease;
  pointer-events: none; /* children re-enable */
}
#chrome.chrome-hidden-state { opacity: 0; }
#chrome > * { pointer-events: auto; }

/* gradient scrims top + bottom */
#chrome-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #000;
}
#chrome-bottom {
  padding: 6px 20px 14px;
  background: #000;
}

/* autohide: whole chrome fades, video stays untouched */
#player.chrome-hidden #chrome { opacity: 0; }
#player.chrome-hidden #chrome > * { pointer-events: none; }

#chrome-title { flex: 1; min-width: 0; }
#chrome-title #player-title {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#chrome-title #player-epg {
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* control buttons */
.cbtn {
  background: #111;
  border: none;
  color: #fff;
  font-size: 1.05rem;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  line-height: 1;
}
.cbtn:hover { background: #222; }
.cbtn:active { transform: scale(0.94); }
.cbtn.close { background: var(--danger); }
.cbtn.close:hover { background: #ff6666; }
#player-fav.on { color: var(--accent); }
.cbtn.big {
  width: 74px;
  height: 74px;
  font-size: 1.9rem;
  border-radius: 50%;
  background: #000;
  border: 1px solid #333;
}
.cbtn.big:hover { background: #222; }
#center-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
#center-flash[hidden] { display: none; }

/* seek row */
#seek-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
#seek-bar {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}
#seek-bar:hover { height: 8px; }
#seek-buffered, #seek-played {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 3px;
}
#seek-buffered { background: #333; }
#seek-played { background: var(--accent); }
#seek-thumb {
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.12s ease;
}
#seek-bar:hover #seek-thumb { transform: translateY(-50%) scale(1); }
#live-pill {
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* control row */
#ctrl-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
#ctrl-row .spacer { flex: 1; }
#ctrl-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}
.vol-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
#vol-slider {
  width: 90px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* speed menu (anchored above the speed button) */
#speed-menu {
  position: absolute;
  z-index: 12;
  background: #000;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 90px;
}
#speed-menu[hidden] { display: none; }
#speed-menu button {
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
}
#speed-menu button:hover { background: #111; }
#speed-menu button.on { color: var(--accent); font-weight: 700; }

/* channel drawer toggle now lives in the top chrome row (normal flow button) */
.player-chlist-btn {
  z-index: 7; /* ABOVE the drawer — it's the close control while open */
}
#player-chlist {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 80vw;
  background: #000;
  border-right: 1px solid var(--glass-border);
  overflow-y: auto;
  padding: 10px;
  z-index: 6;
}
.chlist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}
.chlist-row:hover { background: #0d0d0d; }
.chlist-row.active { background: rgba(229, 9, 20, 0.12); color: var(--accent); }
.chlist-row img { width: 46px; height: 30px; object-fit: contain; border-radius: 4px; background: #0a0a0a; flex-shrink: 0; }
.chlist-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chlist-empty { color: var(--text-dim); font-size: 0.9rem; padding: 14px; }

/* ============ MODAL (settings / wizard) ============ */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1200; /* above landing (1000) + acct-modal (1100): login wizard floats over front door */
  display: none;
  align-items: center;
  justify-content: center;
}

#modal-backdrop.open { display: flex; }

#modal {
  background: var(--bg-elev);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 var(--glass-highlight);
  border-radius: 14px;
  padding: 28px;
  width: min(440px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
}

#modal h2 { font-size: 1.2rem; margin-bottom: 6px; }
#modal .sub { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 18px; line-height: 1.45; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.field input:focus { border-color: var(--accent-dim); }

#modal .btn-row { display: flex; gap: 10px; margin-top: 20px; }

.btn-primary {
  flex: 1;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  border-radius: var(--radius);
}

.btn-primary:disabled { opacity: 0.5; cursor: wait; }

.btn-ghost {
  padding: 11px 16px;
  border-radius: var(--radius);
  color: var(--text-dim);
  background: var(--bg-card);
}

#modal-status {
  margin-top: 12px;
  font-size: 0.85rem;
  min-height: 1.3em;
}

#modal-status.err { color: var(--danger); }
#modal-status.ok { color: var(--accent); }

/* ============ NETFLIX HOME ============ */
#home { padding-bottom: 40px; }

#hero {
  position: relative;
  height: 46vh;
  min-height: 320px;
  max-height: 520px;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
  background: #0a0a0a;
}

.hero-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  filter: brightness(0.85);
}

.hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #000 8%, rgba(0,0,0,0.6) 45%, rgba(0,0,0,0.15) 75%),
              linear-gradient(to right, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 55%);
}

.hero-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 34px;
  max-width: 640px;
}

.hero-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 9px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.hero-title {
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.08;
  margin-bottom: 8px;
  text-shadow: 0 2px 14px rgba(0,0,0,0.8);
}

.hero-meta {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.hero-overview {
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 18px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.9);
}

.hero-actions { display: flex; gap: 10px; }

.hero-play {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 11px 28px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.hero-play:hover { background: #ff2432; }

.hero-more {
  background: #2e2e2e;
  color: #fff;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.hero-more:hover { background: #3d3d3d; }

/* rows */
#rows { padding: 8px 0 0; }

.row { margin: 22px 0 6px; }

.row h2 {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 24px;
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

.row-viewall {
  margin-left: 12px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  vertical-align: middle;
}
.row-viewall:hover { background: rgba(229,9,20,0.1); }

.row h2.live-row { color: var(--danger); }

.event-time {
  position: absolute;
  left: 7px;
  bottom: 6px;
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.event-time.on {
  background: var(--danger);
  color: #fff;
}

.row-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 24px 14px;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.row-scroll::-webkit-scrollbar { display: none; }
.row-scroll.dragging { cursor: grabbing; scroll-behavior: auto; }
.row-scroll.dragging .row-card { pointer-events: none; }

.row-card {
  flex: 0 0 auto;
  width: 220px;
  cursor: pointer;
  transition: transform 0.13s ease;
}

.row-card:hover { transform: scale(1.05); }

.row-card-box {
  aspect-ratio: 16 / 9;
  background: #141414;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 7px;
}

.row-card-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-card-meta {
  position: absolute;
  left: 7px;
  bottom: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0,0,0,0.65);
  padding: 2px 7px;
  border-radius: 4px;
  display: none;
}

.row-card-meta:not(:empty) { display: block; }

/* "Added 2d ago" chip (Recently Added row, year-filtered New Releases row) */
.added-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  background: rgba(229, 9, 20, 0.92);
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
}

.row-card-name {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-card:hover .row-card-name { color: var(--text); }

/* ---------- global search overlay (cross-mode results) ---------- */
#global-search {
  position: absolute;
  inset: 0;
  z-index: 60;
  overflow-y: auto;
  padding: 12px 18px 40px;
  background: var(--bg);
}
.gs-section { margin-bottom: 22px; }
.gs-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}
.gs-count {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.78rem;
}
.gs-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.gs-card { flex: 0 0 128px; cursor: pointer; }
.gs-box {
  aspect-ratio: 16 / 9;
  background: #141414;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dim);
}
.gs-box img { width: 100%; height: 100%; object-fit: cover; }
.gs-card:hover .gs-box { border-color: var(--accent); }
.gs-name {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-card:hover .gs-name { color: var(--text); }
.gs-hl { color: var(--accent); font-weight: 700; }
.gs-more {
  margin-top: 8px;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.gs-more:hover { color: var(--text); border-color: var(--accent); }
.gs-empty { color: var(--text-dim); font-size: 0.9rem; padding: 30px 4px; }

/* ---------- filter chips (sort bar, Movies/Series tabs) ---------- */
.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Simkl watchlist button (detail actions) ---------- */
.d-simkl-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.d-simkl-btn:hover { color: var(--text); border-color: var(--text-dim); }
.d-simkl-btn.in-list {
  border-color: #22c55e;
  color: #22c55e;
}
.d-simkl-btn:disabled { opacity: 0.5; cursor: wait; }

/* ---------- franchise / collection strip (movie detail) ---------- */
.d-collection { margin-top: 16px; }
.d-collection h2 { margin: 10px 0 8px; }
.d-col-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.d-col-card {
  flex: 0 0 92px;
  cursor: default;
  position: relative;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.d-col-card img {
  width: 92px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  margin-bottom: 4px;
  display: block;
}
.d-col-card.missing { opacity: 0.42; }
.d-col-card:not(.missing) { cursor: pointer; }
.d-col-card:not(.missing):hover img { border-color: var(--accent); }
.d-col-card:not(.missing):hover span { color: var(--text); }
.d-col-card span i { font-style: normal; color: var(--text-dim); opacity: 0.7; }
.d-col-ph {
  width: 92px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: #141414;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.d-col-have {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- downloads (detail buttons + settings panel) ---------- */
.d-dl-btn,
.d-epdl {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.d-dl-btn:hover, .d-epdl:hover { color: var(--text); border-color: var(--text-dim); }
.d-dl-btn.dl-busy, .d-epdl.dl-busy {
  border-color: var(--accent);
  color: var(--accent);
  cursor: pointer;
}
.d-dl-btn.dl-done, .d-epdl.dl-done {
  border-color: #22c55e;
  color: #22c55e;
}
.d-epdl {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 0.78rem;
  align-self: center;
  min-width: 44px;
}
.d-dl-hint { color: var(--text-dim); font-size: 0.78rem; margin-top: 8px; }

.dl-list { display: flex; flex-direction: column; gap: 8px; }
.dl-empty { color: var(--text-dim); font-size: 0.85rem; padding: 6px 0; }
.dl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.dl-info { flex: 1; min-width: 0; }
.dl-name {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dl-sub { font-size: 0.74rem; color: var(--text-dim); margin-top: 2px; }
.dl-sub.err { color: #f87171; }
.dl-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.dl-bar > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}
.dl-row button {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.76rem;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.dl-row button:hover { color: var(--text); }
.dl-row .dl-del { font-size: 0.85rem; padding: 4px 9px; }
.dl-quota { font-size: 0.74rem; color: var(--text-dim); margin-bottom: 10px; }

.row-progress {
  height: 3px;
  background: #2a2a2a;
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}

.row-progress div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

@media (max-width: 700px) {
  #hero { height: 52vh; border-radius: 0; }
  .hero-info { padding: 20px; }
  .row-card { width: 190px; }
  .row h2 { padding: 0 16px; }
  .row-scroll { padding: 4px 16px 12px; }
}

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ============ MOBILE ============ */
@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    left: -260px;
    top: 52px;
    bottom: 0;
    z-index: 50;
    transition: left 0.2s ease;
    width: 260px;
  }
  #sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.6); }
  #grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  #logo { display: none; }
  #player-epg { display: none; }
  .vol-wrap #vol-slider { width: 64px; }
  #ctrl-row { gap: 6px; }
  .cbtn { padding: 8px 10px; font-size: 0.95rem; }
  /* topbar wraps: search+gear on row 1, scrollable tabs on row 2 */
  #topbar { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px 4px; }
  #search-wrap { order: 1; flex: 1 1 auto; min-width: 0; }
  #sidebar-toggle { order: 0; }
  #settings-btn { order: 2; }
  #mode-tabs {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  #mode-tabs::-webkit-scrollbar { display: none; }
  .mode-tab { flex: 0 0 auto; padding: 7px 14px; white-space: nowrap; }
}

/* ---------- About panel (v1.0) ---------- */
.about-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.about-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.about-brand svg {
  width: 52px;
  height: 52px;
  fill: var(--accent);
  flex: none;
}
.about-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}
.about-name span { color: var(--accent); }
.about-ver {
  font-size: 13px;
  color: var(--accent);
  margin-top: 2px;
}
.about-tag {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}
.about-foot {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
  opacity: 0.7;
}

/* ---------- Detail pages (v1.1 cinema layout) ---------- */
/* grid stays in the DOM (scroll preserved) but is covered while #detail exists */
#content > #grid:has(~ #detail) { visibility: hidden; }
/* detail is the sole scroll container while open — kills the double scrollbar */
#content:has(> #detail) { overflow: hidden; }
/* rail + hamburger are dead weight on detail — back pill is the only chrome */
body:has(#detail) #sidebar { display: none !important; }
body:has(#detail) #sidebar-toggle { display: none !important; }
#detail {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #000;
  overflow-y: auto;
  padding-bottom: 80px;
  animation: d-in 0.25s ease;
}
@keyframes d-in { from { opacity: 0; } to { opacity: 1; } }
#d-back {
  /* lives in the topbar, right side (before the gear) — flex row sibling */
  background: transparent;
  border: 1px solid #3a3a3a;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 16px 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
#d-back:hover { border-color: var(--accent); color: var(--accent); }

.d-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 140px 0; color: var(--text-dim); font-size: 15px;
}
.spinner {
  width: 22px; height: 22px;
  border: 2px solid #333; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- hero: full-bleed backdrop, content docked low-left ---- */
.d-hero {
  position: relative;
  height: 62vh;
  min-height: 430px;
}
.d-backdrop {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.55;
}
.d-backdrop.img-dead, .d-poster.img-dead { display: none; }
.d-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, #000 2%, rgba(0,0,0,0.62) 42%, rgba(0,0,0,0.25) 78%, rgba(0,0,0,0.35) 100%),
    linear-gradient(to right, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.25) 45%, rgba(0,0,0,0.05) 100%);
}
.d-head {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 34px;
  padding: 0 56px 0;
  align-items: flex-end;
}
.d-poster {
  width: 230px;
  border-radius: 12px;
  flex: none;
  margin-bottom: -60px;                 /* straddles hero/content seam */
  box-shadow: 0 18px 50px rgba(0,0,0,0.85);
  position: relative;
  z-index: 2;
}
.d-headtxt { flex: 1; min-width: 0; padding-bottom: 34px; }
#d-title {
  margin: 0 0 12px;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.05;
  text-shadow: 0 2px 18px rgba(0,0,0,0.8);
}
.d-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  color: #d8d8d8; font-size: 14.5px; margin-bottom: 22px;
  align-items: center;
}
.d-meta > span:not(.d-stars) { display: flex; align-items: center; gap: 18px; }
.d-meta > span + span::before {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: #555; margin-right: 14px;
}
.d-stars { color: var(--accent); letter-spacing: 2px; }
.d-stars b { color: #fff; margin-left: 6px; font-size: 15px; }
.d-actions { display: flex; gap: 12px; align-items: center; }
#d-play, #d-play1 {
  background: var(--accent); color: #fff; border: 0;
  font-weight: 800; font-size: 16px; letter-spacing: 0.2px;
  padding: 13px 44px; border-radius: 10px; cursor: pointer;
  box-shadow: 0 4px 24px rgba(229, 9, 20, 0.35);
  transition: filter 0.15s, transform 0.1s;
}
#d-play:hover, #d-play1:hover { filter: brightness(1.12); }
#d-play:active, #d-play1:active { transform: scale(0.98); }
#d-resume {
  display: inline-flex;
}
#d-resume-btn {
  background: rgba(0,0,0,0.5); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  font-weight: 600; font-size: 14px;
  padding: 11px 22px; border-radius: 10px; cursor: pointer;
  backdrop-filter: blur(6px);
}
#d-resume-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- body columns ---- */
.d-cols {
  display: grid;
  grid-template-columns: minmax(0,1fr) 320px;
  gap: 56px;
  padding: 74px 56px 0;    /* left col clears the straddling poster */
}
.d-main h2, .d-side h2 {
  font-size: 15px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.d-main p, .d-side p {
  color: #cfcfcf; line-height: 1.7; font-size: 15.5px; margin: 0 0 30px;
  max-width: 820px;
}
.d-cast { line-height: 1.9; }
.d-cast .cast-name { color: #e8e8e8; }

/* trailers */
#d-trailers { display: flex; gap: 14px; flex-wrap: wrap; }
.d-trailer {
  position: relative;
  width: 280px;
  border: 0; background: none;
  border-radius: 10px; overflow: hidden;
  cursor: pointer; padding: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  transition: transform 0.15s;
}
.d-trailer:hover { transform: scale(1.03); }
.d-trailer img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.d-trailer img.img-dead { display: none; }
.d-trailer span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.05) 55%);
  opacity: 0; transition: opacity 0.15s;
}
.d-trailer:hover span { opacity: 1; }
.d-trailer .play-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(229,9,20,0.92); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; padding-left: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* facts table */
#d-facts { display: flex; flex-direction: column; gap: 0; }
.d-fact {
  display: flex; justify-content: space-between; gap: 14px; font-size: 13.5px;
  padding: 9px 0; border-bottom: 1px solid #141414;
}
#d-facts .d-fact:last-child { border-bottom: 0; }
.d-fact a { color: var(--accent); text-decoration: none; font-weight: 600; }
.d-fact a:hover { text-decoration: underline; }
.d-fact span:first-child { color: var(--text-dim); flex: none; }
.d-fact span:last-child { color: #e8e8e8; text-align: right; word-break: break-word; }

/* season tabs */
#d-seasons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.d-season {
  background: #0d0d0d; border: 1px solid #262626;
  color: var(--text-dim); font-size: 13.5px; font-weight: 600;
  padding: 8px 20px; border-radius: 22px; cursor: pointer;
  transition: all 0.15s;
}
.d-season:hover { border-color: #444; color: var(--text); }
.d-season.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 800;
}

/* episode rows */
#d-eplist { display: flex; flex-direction: column; gap: 12px; }
.d-ep {
  display: flex; gap: 16px;
  background: #0b0b0b;
  border: 1px solid #1a1a1a;
  border-radius: 10px;
  overflow: hidden; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.d-ep:hover { border-color: var(--accent-dim); background: #101010; }
.d-ep.playing { border-color: var(--accent); }
.d-epimg {
  width: 220px; min-height: 124px; flex: none;
  background: #111;
  display: flex; align-items: center; justify-content: center;
}
.d-epimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-epimg img.img-dead { display: none; }
.d-ep-nostill { color: #333; font-size: 30px; }
.d-epbody { padding: 12px 16px 12px 0; min-width: 0; }
.d-eptitle { font-size: 15.5px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.d-eptitle .ep-num { color: var(--accent); margin-right: 8px; }
.d-epmeta { font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; display: flex; gap: 12px; }
.d-epplot { font-size: 14px; color: #b9b9b9; line-height: 1.55; }
.d-epplot.blurred { filter: blur(6px); transition: filter 0.15s; }
.d-ep.watched .d-eptitle::after {
  content: '✓'; color: var(--accent); font-size: 13px; font-weight: 700; margin-left: 8px;
}
.d-ep-progress {
  height: 3px; background: #222; border-radius: 2px;
  margin-top: 8px; max-width: 280px; overflow: hidden;
}
.d-ep-progress > div { height: 100%; background: var(--accent); }

@media (max-width: 900px) {
  .d-head { flex-direction: column; align-items: flex-start; padding: 0 22px; gap: 16px; }
  .d-poster { width: 150px; margin-bottom: -40px; }
  .d-headtxt { padding-bottom: 24px; }
  #d-title { font-size: 30px; }
  .d-cols { grid-template-columns: 1fr; gap: 34px; padding: 54px 22px 0; }
  .d-epimg { width: 140px; min-height: 80px; }
}

/* cast chips (v1.1) */
.d-cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 16px 12px;
  margin-bottom: 30px;
}
.cast-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  text-align: center;
}
.cast-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #2a2a2a;
  transition: border-color 0.15s, transform 0.15s;
  background: #141414;
}
.cast-chip:hover .cast-avatar { border-color: var(--accent); transform: scale(1.05); }
.cast-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  background: #101010;
}
.cast-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.cast-role {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.25;
}

/* director links (facts row + legacy side paragraph) */
.d-fact a.dir-link, .dir-side .dir-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.d-fact a.dir-link:hover, .dir-side .dir-link:hover { text-decoration: underline; }

/* rating badges (meta row) */
.r-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  line-height: 1;
  border: 1px solid #2e2e2e;
  background: #101010;
  color: #fff;
}
.r-rt { border-color: #4a1512; }
.r-rt.fresh { color: #ff6b5e; }
.r-rt.rotten { color: #9aa0a6; }
.r-imdb { border-color: #4a4a12; color: #f5c518; }
.r-meta.good { color: #66d36e; border-color: #1c3a20; }
.r-meta.mid { color: #e0b341; border-color: #3a301c; }

/* ============ Account landing (Who's watching?) ============ */
#landing {
  position: fixed; inset: 0; z-index: 1000;
  background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 34px; padding: 32px;
}
.landing-brand {
  display: flex; align-items: center; gap: 14px;
  color: #E50914;
}
.landing-brand svg {
  width: 40px; height: 40px; fill: #E50914; flex: none;
}
.landing-brand-name {
  font-size: 26px; letter-spacing: .18em; font-weight: 800; color: #fff;
}
.landing-brand-name b { color: #E50914; font-weight: 800; }
.landing-title {
  margin: 0; font-size: 30px; font-weight: 800; color: #fff; letter-spacing: .01em;
}
.landing-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 26px; max-width: 900px;
}
.landing-tile {
  background: none; border: 0; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: 150px; color: #9aa0a6; font: inherit;
  position: relative;
}
.landing-avatar {
  width: 120px; height: 120px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 44px; font-weight: 800; color: #fff;
  border: 3px solid transparent;
  box-shadow: 0 0 0 1px #1c1c1f;
  transition: border-color .15s, color .15s, transform .15s;
}
.landing-tile:hover .landing-avatar,
.landing-tile:focus-visible .landing-avatar {
  border-color: #fff;
  transform: scale(1.04);
}
.landing-tile:hover, .landing-tile:focus-visible { color: #fff; outline: none; }
.landing-tile.is-active .landing-avatar { border-color: #fff; }
.landing-tile.is-active { color: #fff; }
.landing-badge {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  background: #E50914; color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.landing-name { font-size: 15px; font-weight: 600; }
.landing-avatar-add {
  background: #141417 !important; color: #9aa0a6 !important; font-size: 40px;
}
.landing-tile:hover .landing-avatar-add { background: #1f1f23 !important; color: #fff !important; }
.landing-avatar-login {
  background: #141417 !important; color: #E50914 !important; font-size: 40px;
}
.landing-tile:hover .landing-avatar-login { color: #fff !important; }
/* hide app chrome while the picker owns the screen */
body:has(#landing) #topbar,
body:has(#landing) #main { visibility: hidden; }
@media (max-width: 720px) {
  .landing-tile { width: 104px; }
  .landing-avatar { width: 88px; height: 88px; font-size: 34px; }
  .landing-title { font-size: 22px; }
  .landing-grid { gap: 18px; }
}

/* ---- account row on landing (Create account / Sign in / Synced as) ---- */
.landing-acct {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  margin-top: 6px;
}
.landing-acct-label { color: #9aa0a6; font-size: 13px; }
.landing-acct-btn {
  background: #141417; color: #c7c7cc; border: 1px solid #2a2a2e;
  border-radius: 8px; padding: 8px 16px; font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.landing-acct-btn:hover { background: #1f1f23; color: #fff; border-color: #3a3a40; }
.landing-acct-btn:disabled { opacity: .55; cursor: default; }
.landing-acct-primary {
  background: #E50914; border-color: #E50914; color: #fff;
}
.landing-acct-primary:hover { background: #f6121d; border-color: #f6121d; color: #fff; }
.landing-acct-hint { color: #5f6368; font-size: 12px; }

/* ---- account modal (register / sign in) ---- */
#acct-modal {
  position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.78);
  display: grid; place-items: center; padding: 24px;
}
.acct-card {
  width: 380px; max-width: 100%;
  background: #0b0b0d; border: 1px solid #26262b; border-radius: 14px;
  padding: 26px 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
}
.acct-card h2 { margin: 0; color: #fff; font-size: 20px; }
.acct-sub { margin: 0 0 4px; color: #9aa0a6; font-size: 12.5px; line-height: 1.5; }
.acct-input {
  background: #141417; border: 1px solid #2a2a2e; border-radius: 8px;
  color: #fff; padding: 11px 12px; font: inherit; font-size: 14px; outline: none;
}
.acct-input:focus { border-color: #E50914; }
.acct-err { color: #ff6b6b; font-size: 12.5px; min-height: 16px; }
.acct-go {
  background: #E50914; color: #fff; border: 0; border-radius: 8px;
  padding: 12px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.acct-go:hover { background: #f6121d; }
.acct-go:disabled { opacity: .6; cursor: default; }
.acct-swap {
  background: none; border: 0; color: #9aa0a6; font: inherit; font-size: 12.5px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.acct-swap:hover { color: #fff; }
