/* PSflix Web — Netflix-style theme: black #141414 + red #E50914. */

:root {
  --bg: #141414;
  --bg-2: #1f1f1f;
  --bg-3: #2a2a2a;
  --red: #e50914;
  --red-dark: #b00610;
  --text: #ffffff;
  --muted: #b3b3b3;
  --dim: #808080;
  --border: #333333;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

main { padding: 0 4vw 48px; }
.page { padding-top: 16px; }

/* ---------- top nav ---------- */

/* Sticky lives on the #nav wrapper, not on the header: a sticky
 * element cannot move outside its parent, and #nav is exactly
 * header-height, so sticky on the header never stuck at all (the
 * nav scrolled away on desktop and mobile alike). The wrapper's
 * parent is the full-height body, so it sticks properly. */
#nav { position: sticky; top: 0; z-index: 100; }

/* Header: two rows everywhere. Row 1 = logo | search | Messenger |
 * Profile (all visible without scrolling, all >= 44px targets);
 * row 2 = the nav links (scrollable when they overflow). On narrow
 * screens the search collapses to an icon button that expands into
 * a full-width input row when tapped (see the 640px block). */
.topnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 4vw;
  background: linear-gradient(to bottom, rgba(0,0,0,.7), rgba(0,0,0,0));
  background-color: #141414;
  border-bottom: 1px solid var(--border);
}
.logo {
  color: var(--red);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
  order: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* Official P logo mark next to the PSflix text (28px, logo-96.png). */
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
.nav-search {
  order: 2;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 480px;
  position: relative;
}
.nav-search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 16px;
  padding: 11px 14px 11px 40px;
  outline: none;
}
.nav-search input:focus { border-color: var(--muted); }
/* Magnifier glyph inside the input (desktop + expanded mobile).
 * Hidden while the search is collapsed to its icon button. */
.nav-search::before {
  content: "";
  display: none;
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  border-right-color: transparent;
  transform: rotate(-45deg);
  pointer-events: none;
}
@media (min-width: 641px) {
  .nav-search::before { display: block; }
}
.nav-search.expanded::before { display: block; }
/* Icon toggle + close are mobile-only (desktop shows the input). */
.nav-search-toggle,
.nav-search-close { display: none; }
.nav-actions {
  order: 3;
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}
.nav-icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-icon-btn:hover { color: var(--text); }
.nav-icon-btn.active {
  color: var(--text);
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}
.nav-icon-btn svg { width: 24px; height: 24px; display: block; }
.nav-icon-btn img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
/* App-download dropdown (round-web-download, two-step): the header
 * icon opens a small menu; "Download APK" inside it starts the
 * download. */
.nav-download-wrap { position: relative; flex-shrink: 0; }
.nav-download-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 60;
}
.nav-download-menu.open { display: block; }
.nav-download-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.nav-download-item:hover { background: var(--bg-3); }
.nav-download-title { display: block; font-weight: 600; }
.nav-download-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
/* Friend-request red dot (toggled by PSUsers.refreshNavDot). */
.nav-icon-btn .nav-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e50914;
  border: 2px solid #141414;
  display: block;
}

/* Suggestions dropdown under the header search input (shared nav,
 * so it works on every page). Absolutely positioned inside the
 * relative .nav-search: on desktop it hangs under the input; on
 * mobile it hangs under the expanded full-width search row. */
.nav-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 200;
  background: #1f1f1f;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  min-height: 56px;
  color: var(--text);
}
.nav-suggest-item + .nav-suggest-item { border-top: 1px solid var(--border); }
.nav-suggest-item:hover, .nav-suggest-item:focus { background: #2a2a2a; outline: none; }
.nav-suggest-poster {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg-2);
}
.nav-suggest-poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}
.nav-suggest-body { min-width: 0; }
.nav-suggest-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-suggest-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.nav-links {
  order: 4;
  display: flex;
  gap: 20px;
  flex: 1 1 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 8px 2px;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 700; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 56vh;
  display: flex;
  align-items: flex-end;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2) center / cover no-repeat;
  margin-top: 12px;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20,20,20,.95) 0%, rgba(20,20,20,.35) 55%, rgba(20,20,20,.15) 100%);
}
.hero-body {
  position: relative;
  z-index: 1;
  padding: 32px;
  max-width: 640px;
}
.hero-title { font-size: 36px; font-weight: 800; margin: 0 0 8px; line-height: 1.1; }
.hero-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.hero-overview {
  color: #e5e5e5;
  font-size: 15px;
  margin: 0 0 18px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 4px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  background: var(--red);
  color: #fff;
}
.btn:hover { background: var(--red-dark); }
.btn.secondary { background: rgba(109,109,110,.7); color: #fff; }
.btn.secondary:hover { background: rgba(109,109,110,.9); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--muted); }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- rows & cards ---------- */

.row { margin-top: 28px; }
.row-title { font-size: 19px; font-weight: 700; margin: 0 0 12px; }
.row-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.row-scroll::-webkit-scrollbar { height: 6px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.card {
  flex: 0 0 auto;
  width: 150px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-2);
  transition: transform .15s ease;
}
.card:hover { transform: scale(1.04); }
.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-3);
}
.card-poster-fallback {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--muted);
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
}
.card-body { padding: 8px 10px 10px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.card-progress > div { height: 100%; background: var(--red); }

/* grid (search results / browse / more trending) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.grid .card { width: auto; }

/* "Did you mean" pin above the search results grid (fuzzy
 * fallback): a muted label over one tappable title row. */
#search-didyoumean { margin: 12px 0 4px; }
.didyoumean-label { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.didyoumean-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  max-width: 480px;
  color: var(--text);
}
.didyoumean-row:hover { border-color: var(--muted); }
.didyoumean-poster {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg-3);
}
.didyoumean-poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}
.didyoumean-body { min-width: 0; }
.didyoumean-title { font-size: 15px; font-weight: 600; }
.didyoumean-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
/* "Similar titles" separator inside the results grid (fuzzy
 * matches appended below the direct hits). */
.search-fuzzy-label {
  grid-column: 1 / -1;
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { background: var(--text); color: #000; border-color: var(--text); font-weight: 700; }

/* ---------- detail ---------- */

.detail-hero {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: flex-end;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2) center / cover no-repeat;
  margin-top: 12px;
}
.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20,20,20,.97) 0%, rgba(20,20,20,.45) 60%, rgba(20,20,20,.2) 100%);
}
.detail-body { position: relative; z-index: 1; padding: 32px; max-width: 720px; }
.detail-title { font-size: 34px; font-weight: 800; margin: 0 0 8px; line-height: 1.1; }
.detail-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.detail-meta .rating { color: #46d369; font-weight: 700; }
.detail-overview { color: #e5e5e5; font-size: 15px; margin: 0 0 18px; }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.resume-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
}
.resume-pill:hover { border-color: var(--muted); }

.season-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.episode-list { display: flex; flex-direction: column; gap: 10px; }
.episode {
  display: flex;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  align-items: flex-start;
}
.episode:hover { border-color: var(--muted); }
.episode-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  padding-top: 2px;
}
.episode-still {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-3);
  flex-shrink: 0;
}
.episode-info { min-width: 0; }
.episode-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.episode-overview {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.episode-meta { color: var(--dim); font-size: 12px; margin-top: 4px; }

/* ---------- player ---------- */

.player-page { padding: 0; }
.player-wrap {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 57px);
}
.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: rgba(0,0,0,.6);
  z-index: 5;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  color: var(--text);
  background: rgba(0,0,0,.85);
  z-index: 6;
}
.player-error p { color: var(--muted); margin: 0; max-width: 480px; }

/* double-tap seek zones */
.seek-zone {
  position: absolute;
  top: 0;
  bottom: 64px;
  width: 30%;
  z-index: 3;
}
.seek-zone.left { left: 0; }
.seek-zone.right { right: 0; }
.seek-flash {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.7);
  color: #fff;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.seek-flash.show { opacity: 1; }
.seek-flash.left { left: 12%; }
.seek-flash.right { right: 12%; }

/* center play/pause — the ONLY on-video play/pause control.
 * Single-tap elsewhere on the video shows/hides the controls.
 * While playing it rides with the controls (hides on idle);
 * while paused it is always visible (the .paused rule below
 * must come AFTER the .idle rule — equal specificity). */
.center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  padding: 0;
  z-index: 4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .25s;
  touch-action: manipulation;
}
.center-play:active { transform: translate(-50%, -50%) scale(0.94); }
.player-wrap.idle .center-play { opacity: 0; pointer-events: none; }
.player-wrap.paused .center-play { opacity: 1; pointer-events: auto; }

/* custom controls */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 8px 12px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
  opacity: 1;
  transition: opacity .25s;
}
.player-wrap.idle .controls { opacity: 0; pointer-events: none; }
.player-wrap.idle { cursor: none; }
.seek-row { display: flex; align-items: center; gap: 10px; }
.seek-row input[type="range"] {
  flex: 1;
  accent-color: var(--red);
  cursor: pointer;
}
.time-label { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.controls-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.ctl-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  padding: 6px 9px;
  border-radius: 4px;
}
.ctl-btn:hover { background: rgba(255,255,255,.15); }
.ctl-btn:disabled { opacity: .35; cursor: default; }

/* Touch devices (phones/tablets): the ±10s buttons are redundant —
 * double-tap on the left/right side already seeks ±10s. Desktop
 * keeps them (a mouse has no double-tap seek). The elements stay
 * in the DOM — only hidden. */
@media (pointer: coarse) {
  #btn-back10, #btn-fwd10 { display: none; }
}
.ctl-spacer { flex: 1; }
.ctl-select {
  background: rgba(0,0,0,.6);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  max-width: 150px;
}

/* Quality button: shows the current resolution (e.g. 720p) or AUTO.
 * 44px minimum at ALL widths — the desktop buttons are smaller, but
 * this one must stay tappable on a phone in landscape too. */
.quality-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .02em;
}

/* Quality menu — sits above the control bar, right-aligned (the
 * button lives on the right side of the row, after the spacer).
 * A child of #controls, so the idle-hide covers it too. */
.quality-menu {
  position: absolute;
  bottom: 100%;
  right: 12px;
  margin-bottom: 8px;
  min-width: 180px;
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(20,20,20,.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.quality-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.quality-item:hover { background: rgba(255,255,255,.1); }
.quality-item.active { color: var(--red); font-weight: 700; }
.quality-item .tick { width: 18px; visibility: hidden; }
.quality-item.active .tick { visibility: visible; }
.quality-note {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.volume-row { display: flex; align-items: center; gap: 4px; }
.volume-row input[type="range"] { width: 80px; accent-color: var(--red); }
.player-title-bar { padding: 14px 4vw 0; }
.player-title { font-size: 19px; font-weight: 700; margin: 0; }
.player-sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.player-note {
  margin: 12px 4vw 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- below-player content ---------- */
/* The player page used to end at the title — on a portrait phone
 * the rest of the screen was empty black. These sections fill it:
 * overview + meta, the episode list (series), recommendations.
 * .player-page has no side padding (the video is edge-to-edge), so
 * the sections below it carry their own, matching the title bar. */
.player-about { padding: 14px 4vw 0; max-width: 900px; }
.player-meta { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.player-meta .rating { color: #46d369; font-weight: 700; }
.player-overview { color: #e5e5e5; font-size: 15px; margin: 0; line-height: 1.5; }
.player-page .row { padding-left: 4vw; padding-right: 4vw; }
.player-episodes .episode-list { max-width: 900px; }
.episode.current { border-color: var(--red); background: #2a1414; }
.episode.current .episode-num { color: var(--red); }
.episode-now {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  padding: 2px 6px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ---------- live tv / sports tiles ---------- */

.channel-row { margin-top: 28px; }
.channel-grid { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.channel-tile {
  flex: 0 0 auto;
  width: 104px;
  cursor: pointer;
  text-align: center;
}
.channel-logo-box {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  background: var(--bg-2);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.channel-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.channel-letter {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}
.channel-name {
  font-size: 13px;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.channel-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.channel-tile.offline .channel-logo-box,
.channel-tile.offline .channel-name,
.channel-tile.offline .channel-sub { opacity: .4; }
.live-pill {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.offline-pill {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: #555;
  color: #ccc;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.inline-player {
  margin-top: 16px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}
.inline-player.open { display: block; }
.inline-player video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.inline-player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
}
.inline-player-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-player-status { font-size: 13px; color: var(--muted); }

/* ---------- modal (server picker) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal-list { display: flex; flex-direction: column; gap: 8px; }
.modal-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  font-size: 15px;
}
.modal-item:hover { border-color: var(--muted); }
.modal-actions { margin-top: 16px; text-align: right; }

/* ---------- misc ---------- */

.empty-state { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 15px; }
.error-state { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 15px; }
.loading-row { color: var(--muted); padding: 24px 0; text-align: center; }
.section-head { font-size: 22px; font-weight: 800; margin: 20px 0 4px; }
.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* app_state gate overlay */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-box { text-align: center; max-width: 480px; }
.gate-logo { color: var(--red); font-size: 34px; font-weight: 800; letter-spacing: 1px; margin-bottom: 16px; }
.gate-title { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.gate-msg { color: var(--muted); font-size: 15px; }

/* ---------- mobile (phone) ---------- */
/* All phone rules live inside media queries — the desktop layout
 * above is untouched. Breakpoints: 640px (portrait phones),
 * 480px (narrow phones). Player controls also apply in phone
 * landscape (short screens), where the width is over 640px. */

@media (max-width: 640px) {
  /* No horizontal overflow anywhere on the page. NOTE: the clip is
   * on main, NOT on html/body — overflow on an ancestor of the
   * sticky top nav breaks position: sticky in Chrome (the nav
   * scrolls away). main is the nav's sibling, so it is safe here. */
  main { padding: 0 12px 40px; overflow-x: clip; }

  /* top nav: row 1 = logo + search icon + Messenger + Profile,
   * row 2 = the scrollable links. The search is an icon button
   * (44px) until tapped, when it expands into a full-width input
   * row between row 1 and the links. */
  .topnav { gap: 8px 12px; padding: 10px 12px; }
  .logo { font-size: 22px; }
  .nav-search { flex: 0 0 auto; max-width: none; }
  .nav-search input { display: none; }
  .nav-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
  }
  .nav-search-toggle svg { width: 24px; height: 24px; display: block; }
  .nav-search.expanded { flex: 1 1 100%; }
  .nav-search.expanded .nav-search-toggle { display: none; }
  .nav-search.expanded input { display: block; }
  .nav-search.expanded .nav-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    margin-left: 4px;
    padding: 0;
  }
  .nav-links { gap: 4px; }
  .nav-link { padding: 12px 10px; font-size: 14px; flex-shrink: 0; }

  /* hero / detail */
  .hero { min-height: 38vh; }
  .hero-title, .detail-title { font-size: 26px; }
  .hero-body, .detail-body { padding: 20px; }
  .hero-overview { -webkit-line-clamp: 2; font-size: 14px; }
  .detail-hero { min-height: 340px; }
  .detail-overview { font-size: 14px; }

  /* 44px tap targets */
  .btn { min-height: 44px; padding: 12px 20px; }
  .btn.small { min-height: 40px; padding: 10px 14px; }
  .chip {
    min-height: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
  }
  .resume-pill { min-height: 44px; }

  /* rows & cards */
  .row { margin-top: 22px; }
  .row-title { font-size: 17px; }
  .card { width: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }

  /* header search input: 16px text so iOS never zooms the field
   * on focus */
  .nav-search input { font-size: 16px; }

  /* episodes */
  .episode { padding: 10px; gap: 10px; }
  .episode-still { width: 110px; }
  .episode-num { min-width: 24px; font-size: 17px; }

  /* channels */
  .channel-tile { width: 88px; }
  .channel-logo-box { width: 64px; height: 64px; }

  /* modal */
  .modal { padding: 16px; }
  .modal-item { min-height: 44px; }

  /* misc */
  .section-head { font-size: 20px; }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

  /* no 300ms tap delay anywhere on the page */
  button, select, input, .card, .episode, .channel-tile, a { touch-action: manipulation; }
}

@media (max-width: 480px) {
  .hero { min-height: 34vh; }
  .detail-hero { min-height: 300px; }
  .card { width: 112px; }
  .episode-still { width: 96px; }
}

/* Phone player controls: narrow portrait AND short landscape
 * (a phone in landscape is 700-900px wide, so max-width alone
 * would miss it). Desktop windows are unaffected. */
@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) {
  .player-wrap { max-height: calc(100dvh - 57px); }
  .player-wrap:fullscreen { max-height: 100dvh; }
  .player-wrap, .ctl-btn, .ctl-select, input[type="range"] { touch-action: manipulation; }

  /* Small screens: the wrap is short (219px on a 390px phone) and
   * the control bar is ~114px tall, so a button centered on the
   * wrap would sit ON the seek bar (verified: taps sought instead
   * of pausing). Center it in the area above the controls instead
   * (same 118px the seek zones clear), and shrink it to fit. */
  .center-play {
    width: 56px;
    height: 56px;
    font-size: 24px;
    top: calc((100% - 118px) / 2);
  }

  /* Seek zones end above the control bar. The bar is one scrollable
   * row tall on phones (~114px), so 118px clears it with margin —
   * the zones and the bar must never overlap, or taps in the overlap
   * hit the bar once it wakes up (pointer-events) instead of the zone.
   * (Measured: a wrapping 3-row bar was 175px tall and covered 43px
   * of the zones — double-tap seek silently did nothing.) */
  .seek-zone { bottom: 118px; }

  .controls { padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px)); }

  /* fat seek bar with a big thumb — grabbable on touch */
  .seek-row input[type="range"] { height: 44px; }
  .seek-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--red);
  }
  .seek-row input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--red);
  }
  .time-label { font-size: 13px; }

  /* One horizontally scrollable control row — wrapping would make
   * the bar tall enough to cover the seek zones (see above). Order
   * puts the essentials first: transport, language, fullscreen;
   * speed and the HLS track picker are a swipe away. */
  .controls-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
  }
  .controls-row::-webkit-scrollbar { display: none; }
  .controls-row .ctl-btn, .controls-row .ctl-select, .controls-row .volume-row { flex-shrink: 0; }
  #btn-play { order: 1; }
  #btn-back10 { order: 2; }
  #btn-fwd10 { order: 3; }
  #btn-prev { order: 4; }
  #btn-next { order: 5; }
  .volume-row { order: 6; }
  #lang-select { order: 7; }
  #quality-btn { order: 8; }
  #btn-fullscreen { order: 9; }
  #speed { order: 10; }
  #audio-tracks { order: 11; }

  /* Phones: the wrap is short (219px on a 390px portrait phone)
   * and the control bar is ~114px tall — a 4-item menu above the
   * bar would run off the top of the viewport. A bottom sheet
   * instead: fixed to the viewport bottom (no ancestor has a
   * transform/filter, so fixed positioning still works), still a
   * child of #controls so the idle-hide covers it. */
  .quality-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin-bottom: 0;
    border-radius: 12px 12px 0 0;
    max-height: 60vh;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .ctl-spacer { display: none; }
  .ctl-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .ctl-select { min-height: 44px; font-size: 14px; padding: 8px 6px; max-width: 128px; }

  /* phones have hardware volume buttons — the slider only eats space */
  .volume-row input[type="range"] { display: none; }

  .player-title { font-size: 17px; }
  .player-note { margin: 12px 12px 0; font-size: 13px; }
}
