: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: calc(14px + env(safe-area-inset-top)) 4vw 14px;   /* safe-area : ne pas passer sous la barre d'état iPhone */
  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; }
/* Utilisateur connecté + bouton « changer d'utilisateur » */
.userbox { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted, #9aa); font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { background: #1a1a22; border: 1px solid #2a2a35; color: var(--txt); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; font-size: 15px; line-height: 1; flex: 0 0 auto; }
.logout:hover, .logout:focus { border-color: var(--red); outline: none; }

/* ---------- 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 .thumb { position: relative; }
.card .poster { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #222; }
.cardprog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.55); z-index: 2; }
.cardprog i { display: block; height: 100%; background: var(--red); }
.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; }
.badgehd { background: rgba(0,0,0,.72); color: #bcd6ff; font-size: 10px; font-weight: 800; letter-spacing: .3px;
  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: calc(16px + env(safe-area-inset-top)); 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: calc(18px + env(safe-area-inset-top)); left: 4vw; z-index: 55; font-size: 18px; font-weight: 700;
  text-shadow: 0 2px 8px #000; max-width: 62vw; }
/* maintenant/à suivre : AU-DESSUS de la barre de contrôle (sinon elle passait dessous) */
.player-epg { position: absolute; bottom: calc(82px + env(safe-area-inset-bottom)); 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; }
/* Auto-masquage des contrôles superposés avec l'inactivité */
.player-close, .player-title, .player-epg, .zapbtn { transition: opacity .3s ease; }
.player.idle .player-close, .player.idle .player-title, .player.idle .player-epg,
.player.idle .zapbtn { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
/* Barre de contrôle unique (rouge/noir) en bas du lecteur */
.pbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 57;
  padding: 6px 3vw calc(14px + env(safe-area-inset-bottom));   /* safe-area : au-dessus de la barre home iPhone */
  background: linear-gradient(to top, rgba(0,0,0,.88), rgba(0,0,0,.5) 65%, transparent);
  transition: opacity .3s ease; }
.player.idle .pbar { opacity: 0; pointer-events: none; }
.pbar-seek { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #fff; text-shadow: 0 1px 4px #000; margin-bottom: 8px; }
.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); }
.pbar-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.pbar-left { grid-column: 1; justify-self: start; display: flex; align-items: center; gap: 8px; }
.pbar-center { grid-column: 2; justify-self: center; display: flex; align-items: center; gap: 8px; }
.pbar-right { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 8px; }
/* Volume inutile sur écrans tactiles (boutons physiques) — masqué en portrait ET paysage ; gardé sur ordi (souris). */
@media (hover: none) and (pointer: coarse) { .pbar-left { display: none; } }
.pb { background: rgba(255,255,255,.1); border: 0; color: #fff; height: 42px; width: 42px; padding: 0;
  border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.pb svg { width: 22px; height: 22px; }
.pb:hover { background: var(--red); }
.pb.pb-play { background: #fff; color: #111; }       /* lecture/pause = bouton blanc proéminent (centré) */
.pb.pb-play:hover { background: #d9d9d9; }
.pb-vol { width: 90px; max-width: 22vw; accent-color: var(--red); cursor: pointer; }
/* On masque la barre de contrôles NATIVE du <video> -> 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); }

/* ---------- 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; justify-content: center; gap: 8px; padding: 12px 22px; border: 0;
  border-radius: 8px; font-size: 15px; font-weight: 700; }
.btn-play { background: #fff; color: #111; flex: 1 1 100%; }   /* action principale : pleine largeur */
.btn-play:hover { background: #d9d9d9; }
.btn-fav, .btn-2 { background: rgba(255,255,255,.15); color: #fff; flex: 1 1 0; min-width: 0; }   /* secondaires : largeur égale */
.btn-2:hover, .btn-fav:hover { background: rgba(255,255,255,.25); }
.btn-row { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.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); }

/* ---------- Programme (EPG des chaînes récemment regardées) ---------- */
.guide-list { padding: 16px 4vw 60px; display: flex; flex-direction: column; gap: 8px; }
.guide-row { display: flex; gap: 16px; background: #15151c; border: 1px solid #20202a; border-radius: 10px;
  padding: 12px 14px; cursor: pointer; transition: background .12s ease; }
.guide-row:hover, .guide-row:focus { background: #1e1e28; outline: 2px solid var(--focus); outline-offset: 0; }
.gr-name { flex: 0 0 32%; max-width: 220px; font-weight: 700; font-size: 15px; color: #f0f0f4;
  align-self: center; overflow: hidden; text-overflow: ellipsis; }
.gr-info { flex: 1; min-width: 0; }
.gr-now { font-size: 14px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-dot { color: var(--red); margin-right: 6px; }
.gr-bar { height: 4px; background: rgba(255,255,255,.15); border-radius: 999px; margin: 7px 0; overflow: hidden; }
.gr-bar i { display: block; height: 100%; background: var(--red); }
.gr-next { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Détail guide (modal) */
.gd-head { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 24px 14px; flex-wrap: wrap; }
.gd-head h2 { margin: 0; font-size: 22px; flex: 1 1 auto; min-width: 0; }
.gd-head .btn-play { flex: 0 0 auto; }
.gd-list { padding: 0 16px 24px; }
.gd-row { display: flex; gap: 14px; padding: 11px 10px; align-items: flex-start; border-radius: 8px; }
.gd-row + .gd-row { border-top: 1px solid #20202a; }
.gd-row.live { background: rgba(229,9,20,.13); border-radius: 8px; }
.gd-row.past { opacity: .42; }
.gd-time { flex: 0 0 46px; color: var(--red); font-weight: 700; font-size: 14px; }
.gd-txt { flex: 1; min-width: 0; font-size: 14px; color: #e8e8ee; display: flex; flex-direction: column; gap: 3px; }
.gd-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.gd-tag { flex: 0 0 auto; align-self: center; background: var(--red); color: #fff; font-size: 10px;
  font-weight: 800; letter-spacing: .3px; padding: 2px 7px; border-radius: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .gr-name { flex-basis: 40%; font-size: 14px; }
  /* En-tête en 3 lignes propres : logo / onglets (rangée scrollable) / recherche */
  .topbar { flex-wrap: wrap; gap: 10px 12px; }
  .brand.small { font-size: 18px; flex-basis: 100%; }
  .tabs { order: 2; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 4px; padding-bottom: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; white-space: nowrap; }
  .search { order: 3; flex: 0 0 100%; 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; }
