:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-light: #1f1f1f;
  --card: #181818;
  --primary: #e50914;
  --primary-light: #ff3d47;
  --text: #ffffff;
  --text-2: #b3b3b3;
  --muted: #808080;
  --border: #2d2d2d;
  --warning: #f5c518;

  --safe: clamp(14px, 3.5vw, 52px);
  --poster-w: clamp(104px, 9.5vw, 150px);
  --poster-h: calc(var(--poster-w) * 1.5);     /* 2:3 */
  --trend-w: clamp(215px, 19.5vw, 330px);
  --trend-h: calc(var(--trend-w) * 0.5625);     /* 16:9 */
  --chan-w: clamp(140px, 13vw, 225px);
  --chan-h: calc(var(--chan-w) * 0.62);
}

/* ---- Temi ----
   L'URL ?theme=NOME imposta data-theme su <html>. Il default (:root) è Netflix.
   Per un nuovo tema aggiungere un blocco :root[data-theme="nome"] { --primary: ... } */
:root[data-theme="netflix"] { --primary: #e50914; --primary-light: #ff3d47; }

/* ===== Tema PRIME: menu verticale a sinistra, logo a una lettera ===== */
:root[data-theme="prime"] {
  --bg: #0a0a0a; --surface: #141414; --surface-light: #1f1f1f; --card: #181818;
  --primary: #e50914; --primary-light: #ff3d47; --border: #2d2d2d;
}
:root[data-theme="prime"] .topnav {
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  top: 0; left: 0; right: auto; bottom: 0; width: 86px; height: 100vh;
  padding: 18px 0; gap: 14px;
  background: linear-gradient(90deg, rgba(0,0,0,.72) 40%, transparent);
}
:root[data-theme="prime"] .logo { display: none; }
:root[data-theme="prime"] .logo-mark { display: block; margin: 0 auto 6px 22px; }
:root[data-theme="prime"] .tabs { flex-direction: column; gap: 2px; width: 100%; align-items: stretch; }
:root[data-theme="prime"] .tab {
  flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; font-size: 10px;
  border-radius: 0; color: var(--text-2);
}
:root[data-theme="prime"] .tab .material-symbols-rounded { font-size: 24px; }
:root[data-theme="prime"] .tab.active::after { display: none; }
:root[data-theme="prime"] .tab.active { background: none; color: #fff; }
:root[data-theme="prime"] .tab.active .material-symbols-rounded { color: var(--primary); }
/* focus: riga che si dissolve nel nero, a filo del bordo sinistro, niente box */
:root[data-theme="prime"] .tab.focused {
  color: #fff;
  background: linear-gradient(90deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.06) 45%, transparent 92%);
}
:root[data-theme="prime"] .searchbox { margin: auto 0 6px; width: 100%; justify-content: center; padding: 12px 0; border: none; background: none; border-radius: 0; }
:root[data-theme="prime"] .searchbox.focused, :root[data-theme="prime"] .searchbox:focus-within {
  background: linear-gradient(90deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.06) 45%, transparent 92%);
}
:root[data-theme="prime"] .searchbox .search { display: none; }   /* rail stretto: solo icona… */
:root[data-theme="prime"] .searchbox.focused .search {           /* …si apre come barra quando selezionata */
  display: block; position: fixed; top: 0; left: 86px; width: min(460px, 44vw);
  background: rgba(10,10,10,.97); color: #fff; padding: 16px 20px; z-index: 96;
  border: none; border-bottom: 2px solid var(--primary); font-size: clamp(15px,1.4vw,19px);
}
:root[data-theme="prime"] .account { display: none; }
:root[data-theme="prime"] .hero, :root[data-theme="prime"] .rows { margin-left: 86px; }
:root[data-theme="prime"] .detail-info { left: calc(var(--safe) + 86px); }
:root[data-theme="prime"] .detail-bottom { padding-left: calc(var(--safe) + 86px); }
:root[data-theme="prime"] .detail-shade-h { background: linear-gradient(90deg, var(--bg) 0%, rgba(10,10,10,.65) 44%, transparent 100%); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
img { -webkit-user-drag: none; user-select: none; }

/* ---------- LOGIN ---------- */
.login {
  height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 700px at 50% -20%, #2a0a0d 0%, transparent 55%), linear-gradient(180deg, #0c0c0c, #000);
}
.login-card { width: min(92vw, 420px); background: rgba(20,20,20,.94); border: 1px solid #262626; border-radius: 16px; padding: clamp(22px,4vw,40px); }
.brand-logo { height: clamp(40px,7vw,60px); width: auto; display: block; margin-bottom: 10px; }
form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input { background: #0f0f0f; border: 1px solid #2a2a2a; border-radius: 8px; padding: 13px 14px; color: var(--text); font-size: 16px; }
input:focus { outline: none; border-color: var(--primary); }
button { cursor: pointer; border: none; border-radius: 6px; padding: 14px; font-size: 16px; font-weight: 800; color: #fff; background: var(--primary); }
button:disabled { opacity: .6; }
.msg { min-height: 18px; font-size: 13px; margin: 2px 0 0; }
.msg.err { color: #ff6b6b; }

/* ---------- APP ---------- */
.app { height: 100vh; display: flex; flex-direction: column; position: relative; }

/* TOP NAV (logo + tab + ricerca) */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 95;   /* sopra il dettaglio (90), sotto il player (100) */
  display: flex; align-items: center; gap: clamp(14px,2vw,34px);
  padding: clamp(10px,1.6vw,22px) var(--safe);
  background: linear-gradient(180deg, rgba(0,0,0,.9) 10%, transparent);
}
.logo { height: clamp(20px,2vw,32px); width: auto; display: block; }
.logo-mark { display: none; width: clamp(26px,2.4vw,38px); height: auto; }
.tabs { display: flex; gap: clamp(6px,1.2vw,22px); }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: clamp(14px,1.25vw,19px); color: var(--text-2); font-weight: 600;
  padding: 7px 12px; cursor: pointer; border: none; background: none; position: relative; border-radius: 8px;
}
.material-symbols-rounded { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; line-height: 1; }
.tab .material-symbols-rounded { font-size: clamp(20px,1.6vw,26px); }
.tab.active .material-symbols-rounded { font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24; }
.tab.active { color: #fff; font-weight: 800; }
.tab.focused { color: #fff; background: rgba(255,255,255,.12); }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -3px; height: 3px; border-radius: 3px;
  background: var(--primary);
}
.tab.focused { outline: none; }
.searchbox {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  width: min(32vw, 360px);
  background: rgba(0,0,0,.6); border: 2px solid #333; border-radius: 6px;
  padding: 8px 14px;
}
.searchbox .material-symbols-rounded { color: var(--muted); font-size: 22px; }
.searchbox:focus-within, .searchbox.focused { border-color: #fff; }
.searchbox:focus-within .material-symbols-rounded { color: #fff; }
.search {
  flex: 1; min-width: 0; background: none; border: none; padding: 0; color: var(--text);
  font-size: clamp(13px,1.1vw,17px);
}
.search:focus { outline: none; }
.account { color: var(--muted); font-size: clamp(11px,.95vw,14px); }
.icon-btn { background: none; border: none; color: var(--text-2); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { color: #fff; background: rgba(255,255,255,.12); }
/* pagina Impostazioni (stile v1: griglia di card) */
.settings-page { position: fixed; inset: 0; z-index: 92; background: var(--bg); overflow-y: auto; scrollbar-width: none;
  padding: calc(var(--safe) + 36px) var(--safe) 6vh; }
.settings-page::-webkit-scrollbar { display: none; }
:root[data-theme="prime"] .settings-page { padding-left: calc(var(--safe) + 86px); }
.settings-page.hidden { display: none; }
.sp-head { font-size: clamp(24px,3vw,42px); font-weight: 900; margin-bottom: 24px; }
.sp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 1100px; }
.sp-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 12px; background: var(--card);
  border: 2px solid transparent; cursor: pointer; min-height: 120px; transition: transform .12s ease; }
.sp-card.focused { border-color: #fff; transform: scale(1.02); }
.sp-card.soon { opacity: .55; }
.sp-card .material-symbols-rounded { font-size: 30px; color: var(--primary); }
.sp-label { font-weight: 700; font-size: clamp(14px,1.2vw,17px); }
.sp-value { margin-top: auto; color: var(--text-2); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sp-soon { color: var(--muted); font-size: 11px; }
@media (max-width: 720px) { .sp-grid { grid-template-columns: repeat(2, 1fr); } }
.set-sw { width: 40px; height: 22px; border-radius: 999px; background: #555; position: relative; flex-shrink: 0; transition: background .15s; }
.set-sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.set-sw.on { background: var(--primary); }
.set-sw.on::after { left: 20px; }

/* HERO con backdrop (stile Netflix) */
.hero { position: relative; height: 56vh; min-height: 320px; flex-shrink: 0; overflow: hidden; background: var(--bg); }
/* backdrop ancorato a destra, sfumato sul bordo sinistro verso il nero */
.hero-bg {
  position: absolute; top: 0; right: 0; bottom: 0; left: auto; width: 72%;
  background-size: cover; background-position: center;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 34%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 34%);
  transition: background-image .35s ease;
}
.hero-shade { position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--bg) 0%, rgba(10,10,10,.55) 24%, transparent 52%),
             linear-gradient(0deg, var(--bg) 0%, rgba(10,10,10,.25) 30%, transparent 55%); }
.hero-inner { position: absolute; z-index: 2; left: var(--safe); bottom: clamp(16px,3.5vh,48px); max-width: min(620px, 52vw); }
.hero-cat { text-transform: uppercase; letter-spacing: .14em; font-size: clamp(11px,.95vw,14px); color: var(--primary); font-weight: 800; margin-bottom: 10px; }
.hero-name { margin: 0 0 10px; font-size: clamp(28px,4vw,60px); font-weight: 900; line-height: 1.02; letter-spacing: -.02em; text-shadow: 0 2px 18px rgba(0,0,0,.75); }
.hero-logo { display: block; width: auto; height: auto; max-width: min(440px, 44vw); max-height: 20vh; object-fit: contain; margin: 0 0 14px; filter: drop-shadow(0 3px 14px rgba(0,0,0,.55)); }
.hero-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; color: var(--text-2); font-size: clamp(12px,1.05vw,16px); font-weight: 600; }
.hero-meta .m { display: inline-flex; align-items: center; gap: 4px; }
.hero-meta .match { color: var(--accent, #46d369); }
.hero-meta .tag { border: 1px solid #555; border-radius: 3px; padding: 0 6px; font-size: .85em; }
.hero-meta .material-symbols-rounded { font-size: 1.15em; }
.hero-star { color: var(--warning); }
.hero-overview {
  margin: 0 0 16px; color: #d8d8d8; font-size: clamp(13px,1.1vw,17px); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 10px rgba(0,0,0,.7);
}
.hero-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-play { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: #111;
  font-weight: 800; font-size: clamp(14px,1.2vw,18px); padding: 8px 20px; border-radius: 6px; }
.hero-play .material-symbols-rounded { font-size: 1.4em; }
.hero-hint { color: var(--text-2); font-size: clamp(12px,1vw,15px); }
.key { display: inline-block; background: rgba(255,255,255,.14); border-radius: 5px; padding: 1px 8px; font-weight: 700; font-size: .9em; }

/* ROWS */
.rows { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 5vh 0 6vh; scrollbar-width: none; position: relative; z-index: 3;
  /* sfumatura in alto: i contenuti svaniscono verso l'hero invece di tagliarsi */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 4.5vh);
  mask-image: linear-gradient(180deg, transparent 0, #000 4.5vh); }
/* senza hero: le righe partono dall'alto, con spazio per non finire sotto la top-bar */
.rows.no-hero { padding-top: clamp(64px, 9vh, 100px); }
:root[data-theme="prime"] .rows.no-hero { padding-top: 22px; }
.rows::-webkit-scrollbar { display: none; }
.row { margin-bottom: clamp(14px,2.4vh,30px); }
.row-title { font-size: clamp(15px,1.35vw,22px); font-weight: 800; margin: 0 0 1vh; padding: 0 var(--safe); color: #e5e5e5; }
.track { display: flex; gap: clamp(8px,.8vw,16px); padding: 10px var(--safe); transition: transform .2s ease; will-change: transform; }

/* card generica */
.card { flex: 0 0 auto; position: relative; cursor: pointer; border-radius: 6px;
  transition: transform .15s ease, box-shadow .15s ease, outline-color .15s ease;
  outline: 3px solid transparent; }
.card img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: var(--card); }
.card .ph { width: 100%; height: 100%; display: grid; place-items: center; text-align: center; padding: 6px;
  background: var(--surface-light); border-radius: 6px; color: var(--text-2); font-weight: 700; font-size: clamp(11px,1vw,15px); }
.card.focused { transform: scale(1.1); z-index: 6; outline-color: #fff; box-shadow: 0 14px 36px rgba(0,0,0,.7); }

.card.poster { width: var(--poster-w); height: var(--poster-h); }
.card.chan  { width: var(--chan-w);  height: var(--chan-h); }
.card.chan img, .card.chan .ph { object-fit: contain; background: var(--card); padding: 8%; }
.card.wide { width: var(--trend-w); height: var(--trend-h); }
.card.wide img { object-fit: cover; }
.card.wide .logo-ov {
  position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%);
  width: auto; height: auto; max-width: 72%; max-height: 38%; object-fit: contain;
  background: none;   /* niente box scuro dietro il logo (override di .card img) */
  /* contorno grigio scuro leggerissimo, niente ombra pesante */
  filter: drop-shadow(0 0 1.5px rgba(30,30,30,.8)) drop-shadow(0 0 1px rgba(30,30,30,.55));
  pointer-events: none;
}
.card.wide .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; border-radius: 0 0 6px 6px;
  background: linear-gradient(0deg, rgba(0,0,0,.92) 12%, rgba(0,0,0,.4) 60%, transparent);
  font-size: clamp(11px,.95vw,15px); font-weight: 700; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Top 10 con numero gigante */
.top10 { display: flex; align-items: flex-end; }
.top10 .num { position: relative; font: italic 900 clamp(66px,8vw,128px)/0.8 system-ui, sans-serif;
  color: #0a0a0a; -webkit-text-stroke: 3px #5a5a5a; margin-right: -2.2vw; margin-bottom: -4px; z-index: 3; }
.top10 .poster { width: var(--poster-w); height: var(--poster-h); z-index: 2; }

.badge { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.75); border: 1px solid rgba(255,255,255,.25);
  border-radius: 3px; padding: 0 5px; font-size: 9px; font-weight: 800; }
.rating { color: var(--warning); font-weight: 700; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: #000; color: var(--muted); font-size: 18px; z-index: 50; text-align: center; }

/* LIVE a 3 colonne (stile v1) */
.live { position: absolute; inset: 0; z-index: 3; display: flex; background: var(--bg); }
:root[data-theme="prime"] .live { left: 86px; }
.live-cats { width: clamp(150px, 15vw, 220px); flex-shrink: 0; background: #0f0f0f; border-right: 1px solid #1a1a1a;
  overflow-y: auto; scrollbar-width: none; padding: 54px 0 20px; }
.live-cats::-webkit-scrollbar, .live-chans::-webkit-scrollbar, .live-epg::-webkit-scrollbar { display: none; }
.lcat { padding: 11px 18px; font-size: clamp(12px,1vw,15px); color: var(--muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid transparent; }
.lcat.sel { color: #fff; }
.lcat.focused { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--primary); }

.live-chans { width: clamp(240px, 24vw, 340px); flex-shrink: 0; background: #111; border-right: 1px solid #1a1a1a;
  overflow-y: auto; scrollbar-width: none; padding: 54px 0 20px; }
.lchan { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; border-left: 3px solid transparent; }
.lchan.focused { background: rgba(255,255,255,.1); border-left-color: var(--primary); }
.lchan-logo { width: 42px; height: 42px; object-fit: contain; background: #000; border-radius: 6px; flex-shrink: 0; }
.lchan-info { min-width: 0; flex: 1; }
.lchan-name { font-size: clamp(12px,1vw,15px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lchan-epg { font-size: clamp(10px,.85vw,12px); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.lchan-prog { height: 3px; background: #333; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.lchan-prog > div { height: 100%; background: var(--primary); }

.live-preview { flex: 1; min-width: 0; padding: 54px var(--safe) 20px; display: flex; flex-direction: column; }
:root[data-theme="prime"] .live-cats, :root[data-theme="prime"] .live-chans, :root[data-theme="prime"] .live-preview { padding-top: 16px; }
.live-screen { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden; cursor: pointer; outline: 3px solid transparent; outline-offset: 2px; }
.live-screen.focused { outline-color: #fff; }
.live-screen video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.live-now { position: absolute; left: 12px; bottom: 10px; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.8); font-size: clamp(14px,1.3vw,18px); }
.live-epg-title { font-weight: 800; font-size: clamp(14px,1.2vw,18px); margin: 18px 0 8px; color: #e5e5e5; }
.live-epg { flex: 1; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: 2px; }
.epg-item { display: flex; gap: 12px; padding: 8px 10px; border-radius: 6px; border: 2px solid transparent; }
.epg-item.focused { border-color: #fff; background: rgba(255,255,255,.06); }
.epg-item.past { opacity: .45; }
.epg-item.now { background: rgba(229,9,20,.14); }
.epg-time { color: var(--muted); font-size: clamp(11px,.9vw,13px); min-width: 46px; font-variant-numeric: tabular-nums; }
.epg-name { font-size: clamp(12px,1vw,14px); font-weight: 600; }
.epg-desc { font-size: clamp(10px,.85vw,12px); color: var(--muted); margin-top: 2px; }

/* PAGINA DETTAGLIO (stile v1) */
.detail { position: fixed; inset: 0; background: var(--bg); z-index: 90; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.detail::-webkit-scrollbar { display: none; }
.detail-top { position: relative; height: 52vh; min-height: 300px; overflow: hidden; }
.detail-bg { position: absolute; inset: 0; background-size: cover; background-position: center 18%; }
.detail-shade-h { position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 0%, rgba(10,10,10,.65) 36%, rgba(10,10,10,.1) 72%, transparent 100%); }
.detail-shade-v { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 1%, rgba(10,10,10,.25) 24%, transparent 55%); }
.detail-info { position: absolute; z-index: 2; left: var(--safe); right: var(--safe); bottom: clamp(14px,3vh,34px); max-width: min(560px, 54vw); }
.detail-logo { display: none; width: auto; height: auto; max-width: min(300px,30vw); max-height: 14vh; object-fit: contain; margin: 0 0 10px; filter: drop-shadow(0 3px 12px rgba(0,0,0,.6)); }
.detail-logo[src] { display: block; }
.detail-title { margin: 0 0 8px; font-size: clamp(24px,3.2vw,46px); font-weight: 900; line-height: 1.03; }
.detail-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: clamp(12px,1vw,15px); }
.detail-meta .meta-match { color: #46d369; font-weight: 800; }
.detail-meta .meta-t { color: #aaa; font-weight: 600; }
.detail-meta .tag { border: 1px solid #555; border-radius: 3px; padding: 0 6px; color: var(--text-2); font-size: .85em; font-weight: 700; }
.detail-genres { color: #9a9a9a; font-size: clamp(11px,.95vw,14px); margin-bottom: 8px; }
.detail-plot { color: #cfcfcf; font-size: clamp(12px,1.05vw,16px); line-height: 1.45; max-width: 60ch; margin: 0 0 10px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.detail-cast { color: #8f8f8f; font-size: clamp(10px,.9vw,13px); line-height: 1.5; margin-bottom: 14px; }
.detail-cast .cl { color: #6a6a6a; font-weight: 800; }
.detail-buttons { display: flex; align-items: center; gap: 12px; }
.detail-play { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: #111;
  font-weight: 800; font-size: clamp(13px,1.15vw,17px); padding: 9px 22px; border-radius: 5px; border: 3px solid transparent; cursor: pointer; }
.detail-play .material-symbols-rounded { font-size: 1.4em; }
.detail-play.focused { border-color: #fff; }
.detail-fav { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(109,109,110,.6); border: 3px solid transparent; color: #fff; cursor: pointer; }
.detail-fav.on .material-symbols-rounded { color: var(--primary); }
.detail-fav.focused { border-color: #fff; }

.detail-bottom { position: relative; z-index: 2; padding: 10px var(--safe) 6vh; }
/* tendina stagioni (identica alla v1) */
.detail-seasons { display: none; margin-bottom: 10px; }
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-btn { display: inline-flex; align-items: center; gap: 6px; background: #242424; border: 2px solid #555; color: #fff;
  font-weight: 600; font-size: clamp(12px,1vw,15px); padding: 6px 14px; border-radius: 4px; cursor: pointer; }
.dropdown-btn .material-symbols-rounded { font-size: 18px; }
.dropdown-btn.focused { border-color: #fff; background: #333; }
.dropdown-list { position: absolute; top: 100%; left: 0; margin-top: 2px; background: #1a1a1a; border: 1px solid #333;
  border-radius: 4px; min-width: 180px; max-height: 300px; overflow-y: auto; z-index: 20; scrollbar-width: none; }
.dropdown-list::-webkit-scrollbar { display: none; }
.dropdown-item { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-left: 3px solid transparent; cursor: pointer; }
.dropdown-item .di-name { color: #999; font-size: 13px; }
.dropdown-item.sel .di-name, .dropdown-item.focused .di-name { color: #fff; font-weight: 600; }
.dropdown-item.focused { background: #2a2a2a; border-left-color: #fff; }
.dropdown-item .di-count { color: #666; font-size: 11px; margin-left: auto; }

/* griglia episodi 4 colonne */
.detail-episodes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 12px; }
.ep-card { cursor: pointer; border-radius: 4px; overflow: hidden; background: #181818; border: 2px solid transparent; transition: transform .12s ease; }
.ep-card.focused { border-color: #fff; transform: scale(1.04); }
.ep-thumb { position: relative; width: 100%; aspect-ratio: 16/9; background: #1a1a2e; }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); display: none;
  width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.6); align-items: center; justify-content: center; font-size: 16px; color: #fff; }
.ep-card.focused .ep-play { display: flex; }
.ep-cap { color: #ccc; font-size: clamp(10px,.85vw,12px); padding: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* correlati */
.rel-section { margin-top: 18px; }
.rel-title { color: #e5e5e5; font-size: clamp(14px,1.2vw,18px); font-weight: 700; margin-bottom: 8px; }
.rel-row { display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 8px 3px; }
.rel-row::-webkit-scrollbar { display: none; }
.rel-card { flex: 0 0 auto; width: clamp(96px,8vw,130px); aspect-ratio: 2/3; border-radius: 4px; overflow: hidden;
  background: var(--card); border: 2px solid transparent; cursor: pointer; }
.rel-card.focused { border-color: #fff; transform: scale(1.05); }
.rel-card img { width: 100%; height: 100%; object-fit: cover; }

.detail-hint { position: fixed; bottom: var(--safe); right: var(--safe); color: var(--muted); z-index: 3; font-size: clamp(12px,1vw,15px); }
@media (max-width: 720px) { .detail-episodes { grid-template-columns: repeat(3, 1fr); } .detail-info { max-width: 90vw; } }

/* PLAYER (stile v1) */
.player { position: fixed; inset: 0; background: #000; z-index: 100; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
/* video della preview portato a schermo intero (stesso elemento, nessun ricaricamento) */
#player .fs-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; z-index: 1; }
.player-spinner { position: absolute; top: 50%; left: 50%; width: 54px; height: 54px; margin: -27px; z-index: 4;
  border: 5px solid rgba(255,255,255,.22); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.player-controls { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; justify-content: space-between;
  opacity: 1; transition: opacity .3s ease; pointer-events: none;
  background: linear-gradient(0deg, rgba(0,0,0,.8), transparent 24%, transparent 76%, rgba(0,0,0,.65)); }
.player-controls.off { opacity: 0; }
.pc-top { display: flex; align-items: center; gap: 16px; padding: var(--safe); }
.pc-title { font-size: clamp(16px,1.8vw,26px); font-weight: 800; text-shadow: 0 2px 10px rgba(0,0,0,.8); }
.pc-bottom { display: flex; flex-direction: column; gap: 12px; padding: 0 var(--safe) var(--safe); }
.pc-bar { position: relative; height: 5px; background: rgba(255,255,255,.28); border-radius: 3px; cursor: pointer; pointer-events: auto; }
/* Live: niente play/seek, mostra la barra info EPG */
.pc-live-epg { display: none; }
.player.is-live .pc-live-epg { display: block; }
.player.is-live #pc-back { display: none; }   /* niente freccia back accanto al nome in live */
.player.is-live #pc-bar, .player.is-live .pc-row { display: none; }
.pcl-row { display: flex; align-items: center; gap: 12px; }
.pcl-title { font-size: clamp(16px,1.6vw,24px); font-weight: 800; }
.pcl-badge { background: var(--primary); color: #fff; font-weight: 800; font-size: 11px; padding: 2px 8px; border-radius: 3px; }
.pcl-time { color: var(--text-2); font-size: clamp(12px,1.1vw,15px); margin-top: 4px; }
.pcl-track { height: 4px; background: rgba(255,255,255,.25); border-radius: 2px; margin: 8px 0; max-width: 460px; }
.pcl-track > div { height: 100%; background: var(--primary); border-radius: 2px; }
.pcl-desc { color: #ccc; font-size: clamp(12px,1vw,15px); max-width: min(60ch, 60vw); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcl-next { color: var(--muted); font-size: clamp(11px,.95vw,14px); margin-top: 6px; }
.pcl-noepg { color: var(--muted); }
.pc-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--primary); border-radius: 3px; }
.pc-knob { position: absolute; top: 50%; left: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); transform: translate(-50%,-50%); }
.pc-row { display: flex; align-items: center; gap: 16px; }
.pc-time { font-variant-numeric: tabular-nums; color: #ddd; font-size: clamp(12px,1.1vw,16px); min-width: 48px; }
.pc-time:last-child { text-align: right; }
.pc-buttons { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(14px,2vw,34px); pointer-events: auto; }
.pc-icon { background: none; border: none; color: #fff; cursor: pointer; display: inline-flex; padding: 8px; border-radius: 50%; }
.pc-icon .material-symbols-rounded { font-size: clamp(26px,2.6vw,38px); }
.pc-play .material-symbols-rounded { font-size: clamp(36px,3.6vw,52px); }
.pc-nextprompt { position: absolute; right: var(--safe); bottom: calc(var(--safe) + 96px); z-index: 5; pointer-events: auto; cursor: pointer;
  background: rgba(20,20,20,.92); border: 1px solid #333; border-radius: 8px; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.pc-nextprompt .np-label { color: var(--muted); font-size: 12px; }
.pc-nextprompt b { font-size: clamp(14px,1.3vw,18px); }
.pc-nextprompt .np-hint { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* pannello episodi nel player */
.pc-eppanel { position: absolute; top: 0; left: 0; bottom: 0; width: min(440px, 44vw); z-index: 6;
  background: rgba(8,8,8,.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid rgba(255,255,255,.1); transform: translateX(-100%); transition: transform .22s ease;
  display: flex; flex-direction: column; }
.pc-eppanel.open { transform: translateX(0); }
.pcep-head { padding: var(--safe) var(--safe) 14px; font-size: clamp(16px,1.5vw,22px); font-weight: 800; }
.pcep-list { flex: 1; overflow-y: auto; scrollbar-width: none; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.pcep-list::-webkit-scrollbar { display: none; }
.pcep-item { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.pcep-item.focused { border-color: #fff; background: rgba(255,255,255,.08); }
.pcep-item.playing .pcep-cap { color: var(--primary); }
.pcep-thumb { width: 118px; aspect-ratio: 16/9; border-radius: 4px; overflow: hidden; background: #1a1a2e; flex-shrink: 0; }
.pcep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pcep-cap { font-size: clamp(11px,1vw,14px); font-weight: 600; line-height: 1.3; }

/* overlay Live nel fullscreen: canali (destra) + categorie (sinistra) */
.pl-overlay { position: absolute; top: 0; left: 0; bottom: 0; z-index: 7; display: flex; }
.pl-overlay.hidden { display: none; }
@keyframes plSlideIn { from { transform: translateX(-100%); opacity: .2; } to { transform: translateX(0); opacity: 1; } }
/* categorie: larghezza animata (0 -> piena) così i canali scorrono in sincrono, senza salti */
.pl-cats { width: 0; overflow: hidden; transition: width .22s ease; background: rgba(8,8,8,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-right: 0 solid rgba(255,255,255,.08); padding: calc(var(--safe)) 0; }
.pl-cats.show { width: min(240px,22vw); overflow-y: auto; scrollbar-width: none; border-right-width: 1px; }
.pl-chans { width: min(380px,36vw); background: rgba(8,8,8,.8); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255,255,255,.06); overflow-y: auto; scrollbar-width: none; padding: calc(var(--safe)) 0; animation: plSlideIn .22s ease; }
.pl-cats::-webkit-scrollbar, .pl-chans::-webkit-scrollbar { display: none; }
.pl-cat { padding: 10px 18px; color: var(--muted); font-size: 14px; cursor: pointer; border-left: 3px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-cat.sel { color: #fff; }
.pl-cat.focused { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--primary); }
.pl-chan { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; border-left: 3px solid transparent; }
.pl-chan.playing { background: rgba(229,9,20,.16); }
.pl-chan.focused { background: rgba(255,255,255,.12); border-left-color: var(--primary); }
.pl-chan img { width: 40px; height: 40px; object-fit: contain; background: #000; border-radius: 5px; flex-shrink: 0; }
.pl-chan-info { min-width: 0; flex: 1; }
.pl-chan-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-chan-epg { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* pannello opzioni live (qualità/audio/sottotitoli) */
.pl-opts { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px,32vw); z-index: 7;
  background: rgba(8,8,8,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255,255,255,.08); overflow-y: auto; scrollbar-width: none; padding: calc(var(--safe)) 14px;
  animation: plSlideInRight .2s ease; }
@keyframes plSlideInRight { from { transform: translateX(100%); opacity: .3; } to { transform: translateX(0); opacity: 1; } }
.pl-opts.hidden { display: none; }
.pl-opts::-webkit-scrollbar { display: none; }
.plo-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 16px 2px 6px; }
.plo-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; font-size: clamp(13px,1.1vw,16px); }
.plo-item.focused { border-color: #fff; background: rgba(255,255,255,.08); }
.plo-item.active { color: var(--primary); font-weight: 700; }
.plo-check { font-size: 18px; }
