/* StreamX — dark streaming UI (own implementation; same UX direction as typical
   video platforms: sticky top bar, centered max-width, card grids, hero row). */

:root {
  --bg: #0a0e14;
  --bg-soft: #11161f;
  --bg-card: #161d28;
  --bg-hover: #1e2734;
  --border: #242f3d;
  --text: #f2f5f9;
  --text-dim: #9aa5b4;
  --text-faint: #66707f;
  --accent: #07d9ff;
  --accent2: #8a2bff;
  --accent-soft: rgba(7, 217, 255, 0.14);
  --green: #2ea043;
  --gold: #f5b301;
  --danger: #ff4d6d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  --topbar-h: 60px;
  --maxw: 1280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3544; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- splash ---------- */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(1100px 600px at 50% -10%, #0b2340, var(--bg));
}
.splash-logo {
  font-size: 34px; font-weight: 800; letter-spacing: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.splash-sub { color: var(--text-faint); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; height: var(--topbar-h);
  display: flex; align-items: center; gap: 22px; padding: 0 20px;
}
.brand { font-weight: 800; letter-spacing: 1px; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 14px; font-weight: 900;
}
.topnav { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 8px 14px; border-radius: 20px; color: var(--text-dim);
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: all 0.15s;
}
.topnav a:hover { color: var(--text); background: var(--bg-hover); }
.topnav a.active { color: #fff; background: var(--accent2); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.flex-spacer { flex: 1; }

.badge {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
  letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap;
}
.badge.live { background: rgba(46, 160, 67, 0.12); color: var(--green); border-color: var(--green); }
.badge.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-right: 6px; animation: pulse 1.2s ease-in-out infinite;
}

.btn {
  border: none; border-radius: var(--radius-sm); padding: 9px 16px;
  font-weight: 700; font-size: 14px; transition: all 0.15s;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- layout ---------- */
#main { max-width: var(--maxw); margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 4px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: 0.5px; }
.page-sub { color: var(--text-dim); font-size: 14px; }

/* ---------- hero ---------- */
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  min-height: 340px; display: flex; align-items: flex-end;
  background: linear-gradient(135deg, #14233f, #0b1a34);
}
.hero-bg { position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%; opacity: 0.55; }
.hero-body {
  position: relative; padding: 34px; max-width: 640px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
}
.hero-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--accent); text-transform: uppercase; }
.hero-title { font-size: 30px; font-weight: 800; margin: 6px 0 8px; }
.hero-author { color: var(--text-dim); font-size: 14px; margin-bottom: 10px; }
.hero-desc { color: var(--text-dim); font-size: 14px; }
.hero-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
/* ---------- rows ---------- */
.row { margin-top: 26px; }
.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.row-title { font-size: 20px; font-weight: 800; }
.see-all {
  font-size: 13px; font-weight: 700; color: var(--accent);
  text-decoration: none; white-space: nowrap; padding: 3px 8px;
  border-radius: 12px; transition: background 0.15s ease, color 0.15s ease;
}
.see-all:hover { background: var(--accent-soft, rgba(229, 9, 20, 0.12)); }
.row-rule { flex: 1; height: 1px; background: var(--border); }
.hscroll { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.hscroll .media-card { flex: 0 0 180px; }

/* ---------- media card ---------- */
.media-card { display: block; }
.card-poster {
  position: relative; aspect-ratio: 16 / 10; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-soft); border: 1px solid var(--border);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.media-card:hover .card-poster { transform: translateY(-4px); border-color: var(--accent); }
.card-poster img { width: 100%; height: 100%; object-fit: cover; }
.card-badge {
  position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, 0.72); color: #fff; padding: 2px 8px; border-radius: 20px;
}
.card-platform {
  position: absolute; right: 8px; top: 8px; font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 20px; letter-spacing: 0.5px; text-transform: uppercase;
}
.card-platform.youtube { background: rgba(255, 77, 109, 0.9); color: #fff; }
.card-platform.bilibili { background: rgba(0, 166, 170, 0.9); color: #fff; }
.card-remove {
  position: absolute; left: 8px; top: 8px; z-index: 6;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, 0.7); color: #fff;
  font-size: 16px; line-height: 1; font-weight: 800; cursor: pointer;
  opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center;
}
.media-card:hover .card-remove { opacity: 1; }
.card-remove:hover { background: var(--danger); }
.card-remove.show { opacity: 1; }
.card-title { font-size: 14px; font-weight: 700; margin-top: 8px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--text-faint); font-size: 12px; margin-top: 3px; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px 14px; }
.grid .media-card .card-poster { aspect-ratio: 16 / 10; }
.empty { color: var(--text-faint); text-align: center; padding: 50px 20px; font-size: 15px; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rgb-flow { to { background-position: 200% center; } }
@keyframes spinner { to { transform: rotate(360deg); } }

/* ---------- leech / resolve ---------- */
.leech-panel {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px; max-width: 640px; margin: 12px auto 0;
}
.leech-title { font-size: 22px; font-weight: 800; }
.leech-sub { color: var(--text-dim); margin: 6px 0 16px; }
.platform-chips { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 20px; font-size: 13px; font-weight: 700;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
}
.chip.on { color: #fff; border-color: var(--accent); background: var(--accent-soft); }
.leech-input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.leech-input-row .input { flex: 1 1 260px; }

.loading {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 30px; color: var(--text-dim);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spinner 0.8s linear infinite;
}
.result-box {
  margin-top: 18px; padding: 16px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
}
.result-title { font-weight: 800; font-size: 16px; }
.result-meta { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- watch / player ---------- */
.player-wrap {
  background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; max-height: 72vh; width: 100%;
}
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.watch-meta { margin-top: 16px; }
.watch-title { font-size: 22px; font-weight: 800; }
.watch-byline { color: var(--text-dim); margin-top: 6px; font-size: 14px; }
.watch-desc { color: var(--text-dim); margin-top: 12px; font-size: 14px; max-width: 760px; }
.watch-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

.quality-select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13px;
}
.tag-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); }

.net-note {
  margin-top: 14px; font-size: 13px; color: var(--gold);
  background: rgba(245, 179, 1, 0.1); border: 1px solid rgba(245, 179, 1, 0.35);
  padding: 10px 14px; border-radius: var(--radius-sm);
}

/* ---------- playback controls (refresh / boost / CC) ---------- */
.ctl-group { display: inline-flex; align-items: center; gap: 8px; }
.ctl-label { font-size: 13px; color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.boost-range {
  -webkit-appearance: none; appearance: none; width: 130px; height: 4px;
  background: var(--border); border-radius: 3px; outline: none;
}
.boost-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); cursor: pointer; border: none;
}
.boost-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: none;
}

.cc-panel {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); max-width: 560px;
}
.cc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cc-note { margin-top: 10px; font-size: 12px; color: var(--text-faint); }
.cc-mode-wrap { display: inline-flex; gap: 0; margin-right: 6px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.cc-mode-btn { padding: 4px 10px; font-size: 11px; font-weight: 600; background: var(--bg-card); color: var(--text-dim); border: none; cursor: pointer; transition: background 0.15s, color 0.15s; }
.cc-mode-btn:hover { background: var(--bg-hover); color: var(--text); }
.cc-mode-btn.active { background: var(--accent-soft); color: var(--accent); }
.cc-mode-btn + .cc-mode-btn { border-left: 1px solid var(--border); }

/* ---------- download panel ---------- */
.dl-panel {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); max-width: 560px;
}
.dl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.dl-toggle { display: inline-flex; gap: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.dl-tab { padding: 5px 14px; font-size: 12px; font-weight: 700; background: var(--bg-card); color: var(--text-dim); border: none; cursor: pointer; transition: background 0.15s, color 0.15s; }
.dl-tab:hover { background: var(--bg-hover); color: var(--text); }
.dl-tab.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.dl-tab + .dl-tab { border-left: 1px solid var(--border); }
.dl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dl-row + .dl-row { margin-top: 10px; }
.dl-actions { align-items: center; }
.dl-note { font-size: 12px; color: var(--text-faint); flex: 1; min-width: 0; }

/* ---------- background download dock (floating, survives navigation) ---------- */
.dl-dock {
  position: fixed; right: 16px; bottom: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; width: min(340px, calc(100vw - 32px));
}
.dl-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; animation: fadeIn 0.18s ease;
}
.dl-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.dl-card-kind {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.dl-card-title {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dl-card-x {
  border: none; background: transparent; color: var(--text-faint);
  font-size: 13px; cursor: pointer; padding: 2px 4px; line-height: 1;
}
.dl-card-x:hover { color: var(--text); }
.dl-bar {
  height: 8px; border-radius: 4px; overflow: hidden;
  background: var(--border); margin-bottom: 8px;
}
.dl-bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px; transition: width 0.35s ease;
}
.dl-bar > i.failed { background: var(--danger); }
.dl-card-status { font-size: 12px; color: var(--text-dim); }
.dl-card-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.dl-card-size { font-size: 12px; color: var(--text-faint); }
.dl-card-error {
  margin-top: 6px; font-size: 12px; color: var(--danger);
  background: rgba(255, 77, 109, 0.08); border: 1px solid rgba(255, 77, 109, 0.35);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
/* Completed card = the "Save" popup: highlighted, with a glow border. */
.dl-card.ready { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow); }
.dl-card.failed { border-color: var(--danger); }

/* ---------- on-server download library ---------- */
.dl-library {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; animation: fadeIn 0.18s ease;
  max-height: 40vh; overflow-y: auto;
}
.dl-lib-head { font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.dl-lib-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-top: 1px solid var(--border); }
.dl-lib-row:first-of-type { border-top: none; }
.dl-lib-name {
  flex: 1; min-width: 0; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dl-lib-size { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ---------- custom subtitle overlay (CC) ---------- */
.sub-overlay {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 7%; z-index: 6; max-width: 86%; text-align: center;
  pointer-events: none; opacity: 0; transition: opacity 0.12s ease;
  font-size: var(--sub-size, 1.1em); line-height: 1.35;
  color: var(--sub-color, #fff);
  font-weight: 700;
  text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 4px rgba(0,0,0,0.95), 0 1px 3px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
  white-space: pre-wrap;
}
.sub-overlay.show { opacity: 1; }
.sub-overlay.pos-top { bottom: auto; top: 7%; }
.sub-overlay.loading { opacity: 0.6; letter-spacing: 1px; }
/* Native <track> mirror: renders the same CC text while the <video> itself is
   fullscreen (custom .sub-overlay is a sibling of <video> and is never part of
   native fullscreen). Mode is toggled hidden/showing from player.js; this is
   only the fallback look before JS applies the user's color/size. */
video::cue(.sxcc) {
  background: transparent; background-color: transparent; box-shadow: none;
  color: #fff; font-size: 1.15em; font-weight: 700; white-space: pre-line;
  text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 4px rgba(0,0,0,0.95), 0 1px 3px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
}
::cue(.sxcc) {
  background: transparent; background-color: transparent; box-shadow: none;
  color: #fff; font-size: 1.15em; font-weight: 700; white-space: pre-line;
  text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 4px rgba(0,0,0,0.95), 0 1px 3px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
}
video::cue {
  background: transparent; background-color: transparent; box-shadow: none;
  color: #fff; font-size: 1.15em; font-weight: 700; white-space: pre-line;
  text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 4px rgba(0,0,0,0.95), 0 1px 3px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
}
::cue {
  background: transparent; background-color: transparent; box-shadow: none;
  color: #fff; font-size: 1.15em; font-weight: 700; white-space: pre-line;
  text-shadow: 0 0 1px #000, 0 0 2px #000, 0 0 4px rgba(0,0,0,0.95), 0 1px 3px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
}
video::-webkit-media-text-track-container,
video::-webkit-media-text-track-display {
  background: transparent; background-color: transparent; box-shadow: none;
}

/* ---------- player error ---------- */
.player-error {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 24px;
  background: rgba(0, 0, 0, 0.85); color: #fff;
}
.player-error .gate-lock { font-size: 38px; }
.player-error .gate-title { font-size: 17px; font-weight: 800; }
.player-error .gate-sub { color: var(--text-faint); font-size: 13px; max-width: 420px; }
.player-wrap { position: relative; }
/* ---------- tap-for-sound (muted autoplay fallback) ---------- */
.tap-unmute {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 7; padding: 12px 22px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.78); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 16px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
/* ---------- forms / modal ---------- */
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-faint); margin: 12px 0 6px; letter-spacing: 0.3px; }
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border);
  color: var(--text); font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: min(380px, 100%); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.modal-error, .err-text { color: var(--danger); font-size: 13px; margin-top: 10px; }

.auth-user { font-size: 13px; font-weight: 700; color: var(--accent); }
.auth-user::before { content: "👤 "; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #223047; color: #fff; padding: 12px 22px; border-radius: 24px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 100;
  animation: fadeIn 0.2s ease;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 18px 20px; text-align: center;
  color: var(--text-faint); font-size: 12.5px;
}
.site-footer span {
  font-weight: 700; background: linear-gradient(90deg, #ff2d55, #ff8c00, #ffee00, #00c853, #00a0ff, #7b2dff, #ff2d55);
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: rgb-flow 4s linear infinite;
}

/* ---------- admin ---------- */
.admin-form { max-width: 440px; }
.admin-form .input { margin-bottom: 10px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--bg-card);
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .brand { font-size: 15px; }
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .hero { min-height: 240px; }
  .hero-title { font-size: 22px; }
  .hero-body { padding: 20px; }
  #main { padding: 14px 12px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px 10px; }
  .hscroll .media-card { flex: 0 0 150px; }
  .watch-title { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- mobile bottom navigation ---------- */
:root { --bottomnav-h: 60px; }

.bottomnav {
  display: none; /* hidden on desktop, shown via media query */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--bottomnav-h);
  background: rgba(10, 14, 20, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  padding-bottom: env(safe-area-inset-bottom, 0);
  justify-content: space-around;
  align-items: center;
}

.bottomnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  padding: 6px 4px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  border-radius: 8px;
  position: relative;
}

.bottomnav-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.bottomnav-item.active {
  color: var(--accent);
}

.bottomnav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 0 0 3px 3px;
}

.bottomnav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottomnav-label {
  font-size: 10px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Show bottom nav on mobile, hide top nav */
@media (max-width: 768px) {
  .bottomnav { display: flex; }
  .topnav { display: none; }
  .topbar-inner { gap: 12px; }
  .topbar-right { margin-left: auto; }
  #main { padding-bottom: calc(var(--bottomnav-h) + 24px); }
  .site-footer { margin-bottom: var(--bottomnav-h); }
  /* Toast should sit above the bottom nav */
  .toast { bottom: calc(var(--bottomnav-h) + 16px); }
}
/* ---------------- themed dropdowns (see js/dropdown.js) ----------------
 * WebView paints native <select> popups as an opaque OS dialog, so the list
 * is rendered in-page. The panel is 50% transparent over the app's own palette. */
.dd { position: relative; display: inline-flex; }
.dd-native {
  position: absolute !important;
  width: 2px; height: 2px; margin: -1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}
.dd-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; cursor: pointer; -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 46vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-trigger::after {
  content: ""; width: 0; height: 0; flex: 0 0 auto;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
}
.dd-trigger[disabled] { opacity: .45; cursor: default; }
.dd.open .dd-trigger { border-color: var(--accent); color: var(--text); }

.dd-panel {
  position: fixed; z-index: 1200;
  max-height: 56vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px; margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(36, 47, 61, 0.85);
  background: rgba(13, 18, 26, 0.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
}
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .dd-panel { background: rgba(13, 18, 26, 0.86); }
}
.dd-opt {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-opt:hover, .dd-opt:focus { background: rgba(30, 39, 52, 0.7); color: var(--text); outline: none; }
.dd-opt.on { color: var(--accent); background: rgba(7, 217, 255, 0.14); font-weight: 600; }
.dd-opt.is-none { color: var(--text-faint); font-style: italic; }
.dd-empty { padding: 10px 12px; color: var(--text-faint); font-size: 12px; }

/* Settings → Install Extension dropdown */
.set-ext-opt { display: block; width: 100%; text-align: left; padding: 9px 14px; background: transparent; border: 0; color: var(--text, #e6edf3); font: inherit; font-size: 14px; cursor: pointer; }
.set-ext-opt:hover { background: rgba(7, 217, 255, 0.12); color: var(--accent, #07d9ff); }
