:root {
  --bg: #0b0b0f;
  --bg2: #14141b;
  --red: #e50914;
  --red-2: #b00710;
  --txt: #f5f5f7;
  --muted: #9a9aa6;
  --card: #1c1c25;
  --focus: #ffffff;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt);
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
/* Barre de scroll de la page masquée (défilement conservé) */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
body.noscroll { overflow: hidden; }
.hidden { display: none !important; }
img { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Marque ---------- */
.brand { font-weight: 800; letter-spacing: .5px; color: var(--red); font-size: 28px; }
.brand span { color: var(--txt); margin-left: 6px; }
.brand.small { font-size: 19px; cursor: pointer; white-space: nowrap; }

/* ---------- Connexion ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2a0a0c 0%, var(--bg) 55%); }
.login-card { background: rgba(0,0,0,.55); padding: 40px 36px; border-radius: 12px;
  width: min(92vw, 360px); display: flex; flex-direction: column; gap: 16px; backdrop-filter: blur(6px); }
.login-card h1 { text-align: center; margin: 0 0 8px; }
.login-card input { padding: 14px 16px; border-radius: var(--radius); border: 1px solid #333;
  background: #1a1a1f; color: var(--txt); font-size: 16px; }
.login-card button { padding: 14px; border: 0; border-radius: var(--radius); background: var(--red);
  color: #fff; font-size: 16px; font-weight: 700; }
.login-card button:hover { background: var(--red-2); }
.login-err { color: #ff6b6b; min-height: 18px; margin: 0; text-align: center; font-size: 14px; }

/* ---------- Barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px;
  padding: 14px 4vw; background: linear-gradient(180deg, rgba(11,11,15,.96), rgba(11,11,15,.6));
  backdrop-filter: blur(8px); border-bottom: 1px solid #1d1d26; }
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab { background: transparent; border: 0; color: var(--muted); font-size: 15px; padding: 8px 12px;
  border-radius: 999px; }
.tab:hover { color: var(--txt); }
.tab.active { color: var(--txt); background: #23232e; }
.search input { background: #1a1a22; border: 1px solid #2a2a35; color: var(--txt);
  padding: 9px 14px; border-radius: 999px; width: 200px; font-size: 14px; }
.search input:focus { outline: none; border-color: var(--red); width: 240px; }

/* ---------- Lignes / cartes ---------- */
main { padding: 18px 0 80px; min-height: 60vh; }
.row { margin: 26px 0; }
/* En-tête de ligne : titre + petites flèches à droite */
.row-head { display: flex; align-items: center; gap: 10px; padding: 0 4vw; margin-bottom: 10px; }
.row-head h2 { font-size: 17px; margin: 0; color: #e8e8ee; }
.rownav { display: flex; gap: 6px; }
.navbtn { width: 40px; height: 32px; border-radius: 7px; background: #23232e; border: 1px solid #2f2f3b;
  color: #e8e8ee; font-size: 20px; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.navbtn:hover, .navbtn:focus { background: var(--red); border-color: var(--red); color: #fff; outline: none; }
.strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 4vw 12px;
  scroll-behavior: smooth; scrollbar-width: none; -ms-overflow-style: none; }
.strip::-webkit-scrollbar { display: none; }

/* Cartes films / séries */
.card { flex: 0 0 auto; width: 150px; background: var(--card); border-radius: var(--radius);
  overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; position: relative; }
.card:hover, .card:focus { transform: scale(1.06); box-shadow: 0 8px 24px rgba(0,0,0,.6);
  outline: 2px solid var(--focus); z-index: 2; }
.card .poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #222; }
.card .label { padding: 8px 9px; font-size: 13px; line-height: 1.25; color: #d9d9e2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }

/* Carte chaîne live = bloc titre compact (différencie des affiches films/séries) */
.chan { flex: 0 0 auto; width: 160px; height: 92px; border-radius: var(--radius); cursor: pointer;
  position: relative; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 12px; background: linear-gradient(135deg, #23232e, #15151c); border: 1px solid #2a2a37;
  transition: transform .15s ease, box-shadow .15s ease; }
.chan:hover, .chan:focus { transform: scale(1.05); box-shadow: 0 8px 24px rgba(0,0,0,.6);
  outline: 2px solid var(--focus); border-color: var(--red); z-index: 2; }
.chan .name { font-size: 14px; font-weight: 600; color: #f0f0f4; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Pastilles (4K + favori en haut-gauche) et note /10 (haut-droite, discrète) */
.tl { position: absolute; top: 6px; left: 6px; z-index: 2; display: flex; gap: 4px; }
.badge4k { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 4px; }
.fav-dot { background: rgba(0,0,0,.6); border-radius: 50%; width: 22px; height: 22px;
  display: grid; place-items: center; font-size: 12px; }
.rating { position: absolute; top: 6px; right: 6px; z-index: 2; background: rgba(0,0,0,.72);
  color: #ffd34d; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.grid .chan { width: auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 0 4vw; }
.grid .card { width: auto; }

.empty { color: var(--muted); padding: 40px 4vw; text-align: center; }
.loading { color: var(--muted); padding: 30px 4vw; }

/* ---------- Lecteur ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: #000; display: flex;
  align-items: center; justify-content: center; }
.player video { width: 100%; height: 100%; background: #000; }
.player-close { position: absolute; top: 16px; right: 18px; z-index: 60; background: rgba(0,0,0,.55);
  color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; }
.player-close:hover { background: var(--red); }
.player-title { position: absolute; top: 18px; left: 4vw; z-index: 55; font-size: 18px; font-weight: 700;
  text-shadow: 0 2px 8px #000; max-width: 70vw; }
.player-epg { position: absolute; bottom: 18px; left: 4vw; right: 4vw; z-index: 55; font-size: 14px;
  color: #d6d6de; text-shadow: 0 2px 6px #000; }
.player-epg b { color: #fff; }
.player-msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 58;
  max-width: min(86vw, 560px); background: rgba(20,20,27,.94); border: 1px solid #2a2a35;
  border-radius: 12px; padding: 22px 26px; text-align: center; font-size: 15px; line-height: 1.55;
  color: #e8e8ee; box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.player-msg b { color: #fff; }
.player-msg .ic { font-size: 30px; display: block; margin-bottom: 8px; }
/* Zapping chaînes (lecteur live) */
.zapbtn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 57; width: 56px; height: 84px;
  border: 0; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff; font-size: 38px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; }
.zapbtn:hover, .zapbtn:focus { background: var(--red); outline: none; }
.zapbtn.prev { left: 16px; } .zapbtn.next { right: 16px; }
/* Réglage synchro sous-titres */
.sub-sync { position: absolute; bottom: 70px; right: 18px; z-index: 57; display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.55); padding: 6px 12px; border-radius: 999px; font-size: 13px; color: #d6d6de; }
.sub-sync button { background: #23232e; border: 1px solid #3a3a47; color: #fff; border-radius: 6px;
  padding: 4px 9px; font-size: 13px; cursor: pointer; }
.sub-sync button:hover { background: var(--red); border-color: var(--red); }
.sub-sync #sub-off { min-width: 40px; text-align: center; font-weight: 700; color: #fff; }
/* Auto-masquage des contrôles superposés avec l'inactivité */
.player-close, .player-title, .player-epg, .zapbtn, .sub-sync { transition: opacity .3s ease; }
.player.idle .player-close, .player.idle .player-title, .player.idle .player-epg,
.player.idle .zapbtn, .player.idle .sub-sync { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
/* Barre de progression personnalisée (films HLS : permet d'avancer n'importe où) */
.seekbar { position: absolute; left: 4vw; right: 4vw; bottom: 44px; z-index: 57; display: flex; align-items: center;
  gap: 12px; font-size: 13px; color: #fff; text-shadow: 0 1px 4px #000; transition: opacity .3s ease; }
.seek-track { flex: 1; height: 6px; background: rgba(255,255,255,.25); border-radius: 999px; cursor: pointer; position: relative; }
.seek-track:hover { height: 9px; }
.seek-fill { height: 100%; width: 0; background: var(--red); border-radius: 999px; position: relative; }
.seek-fill::after { content: ''; position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%; background: var(--red); }
.player.idle .seekbar { opacity: 0; pointer-events: none; }
/* On masque la barre de contrôles NATIVE du <video> ("Live Broadcast") -> on garde nos contrôles custom uniquement */
.player video::-webkit-media-controls,
.player video::-webkit-media-controls-enclosure,
.player video::-webkit-media-controls-panel { display: none !important; -webkit-appearance: none !important; }
/* Cercle de chargement central */
.player-spin { position: absolute; top: 50%; left: 50%; z-index: 58; width: 64px; height: 64px;
  margin: -32px 0 0 -32px; border-radius: 50%; border: 5px solid rgba(255,255,255,.22);
  border-top-color: var(--red); animation: bctv-spin .9s linear infinite; pointer-events: none; }
@keyframes bctv-spin { to { transform: rotate(360deg); } }
/* Gros bouton lecture/pause central (affiché en pause) */
.big-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 59;
  width: 88px; height: 88px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font-size: 36px;
  background: rgba(0,0,0,.5); display: grid; place-items: center; padding-left: 4px; }
.big-play:hover { background: var(--red); }
/* Bouton plein écran (bas-gauche) */
.btn-full { position: absolute; bottom: 70px; left: 18px; z-index: 57; width: 40px; height: 40px; border: 0;
  border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; cursor: pointer;
  transition: opacity .3s ease; }
.btn-full:hover { background: var(--red); }
.player.idle .btn-full { opacity: 0; pointer-events: none; }

/* ---------- Fiche détail ---------- */
.modal { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.modal-card { position: relative; width: min(94vw, 820px); max-height: 88vh; overflow: auto;
  background: var(--bg2); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.7); }
.modal-hero { display: flex; gap: 20px; padding: 24px; }
.modal-hero img { width: 170px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background:#222; }
.modal-hero h2 { margin: 0 0 8px; font-size: 24px; }
.modal-meta { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.modal-plot { color: #cfcfd8; font-size: 14px; line-height: 1.5; }
.trk-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.trk-lbl { color: var(--muted); font-size: 14px; }
.trk-btn { background: #23232e; border: 1px solid #2f2f3b; color: #e8e8ee; font-size: 13px; font-weight: 700;
  padding: 4px 13px; border-radius: 999px; cursor: pointer; }
.trk-btn:hover { border-color: var(--red); }
.trk-btn.on { background: var(--red); border-color: var(--red); color: #fff; }
.trk-badge { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px; border: 0;
  border-radius: 6px; font-size: 15px; font-weight: 700; }
.btn-play { background: #fff; color: #111; }
.btn-play:hover { background: #d9d9d9; }
.btn-fav { background: rgba(255,255,255,.15); color: #fff; margin-left: 10px; }
.btn-row { margin-top: 16px; }
.seasons { padding: 0 24px 24px; }
.season-title { font-size: 16px; margin: 18px 0 10px; }
.epi { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  background: #1b1b24; margin-bottom: 8px; cursor: pointer; }
.epi:hover { background: #25252f; outline: 1px solid var(--focus); }
.epi .num { color: var(--red); font-weight: 700; width: 30px; }
.epi .t { flex: 1; font-size: 14px; }
.modal-close { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.5); color: #fff;
  border: 0; width: 38px; height: 38px; border-radius: 50%; font-size: 18px; z-index: 2; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: #23232e; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; width: 100%; }
  .search input, .search input:focus { width: 100%; }
  .card { width: 120px; }
  .chan { width: 140px; }
  .modal-hero { flex-direction: column; }
  .modal-hero img { width: 120px; }
}

/* ---------- TV (grands écrans, focus visible pour télécommande) ---------- */
@media (min-width: 1280px) {
  .card { width: 165px; }
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
