:root {
  color-scheme: dark;
  --fond: #0d0f14;
  --surface: #161922;
  --surface2: #1f2330;
  --ligne: #2a2f3d;
  --texte: #eef0f5;
  --doux: #969cab;
  --accent: #ff7a45;
  --accent-doux: #ff7a4522;
  --ok: #3ecf8e;
  --alerte: #ff6161;
  --alpha: #8a96ff;
  --z2u: #2cc0ad;
  --rayon: 14px;
  --barre: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 12px);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* ---- Connexion ---- */
.connexion { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.connexion form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.connexion h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.02em; display: flex; gap: 10px; align-items: center; }
.connexion p { margin: 0 0 8px; color: var(--doux); }
.champ { width: 100%; padding: 14px 16px; border-radius: var(--rayon); border: 1px solid var(--ligne); background: var(--surface); outline: none; }
.champ:focus { border-color: var(--accent); }
.bouton { padding: 14px 18px; border-radius: var(--rayon); background: var(--accent); color: #1a0d06; font-weight: 650; text-align: center; }
.bouton.second { background: var(--surface2); color: var(--texte); font-weight: 550; }
.bouton:disabled { opacity: .5; }
.erreur { color: var(--alerte); min-height: 1.4em; margin: 0; }

/* ---- En-tête ---- */
header.haut {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--ligne);
}
.ligne-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.marque { font-weight: 750; font-size: 19px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.pastille { font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--surface2); color: var(--doux); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pastille::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--doux); }
.pastille.on::before { background: var(--ok); }
.pastille.lecture::before { background: var(--accent); }
.recherche { position: relative; }
.recherche input { width: 100%; padding: 12px 40px 12px 14px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--surface); outline: none; }
.recherche input:focus { border-color: var(--accent); }
.recherche .effacer { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; color: var(--doux); font-size: 18px; }
.onglets { display: flex; gap: 6px; margin-top: 10px; }
.onglets button { flex: 1; padding: 9px 0; border-radius: 10px; color: var(--doux); font-weight: 600; background: var(--surface); }
.onglets button[aria-selected="true"] { background: var(--accent-doux); color: var(--accent); }
.puces { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.puces::-webkit-scrollbar { display: none; }
.puces button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--ligne); color: var(--doux); font-size: 13.5px; white-space: nowrap; }
.puces button[aria-pressed="true"] { border-color: var(--accent); color: var(--texte); background: var(--accent-doux); }

main { padding: 6px 16px 16px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 15px; margin: 22px 0 10px; color: var(--doux); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.vide { color: var(--doux); padding: 28px 4px; text-align: center; }
.plus { width: 100%; margin-top: 12px; }

/* ---- Listes de chaînes ---- */
.liste { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.chaine { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 12px; background: var(--surface); min-width: 0; width: 100%; text-align: start; }
.feuille .chaine { background: var(--surface2); }
.recherche input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.chaine .jouer-zone { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: start; }
.logo { width: 42px; height: 42px; border-radius: 10px; flex: none; display: grid; place-items: center; font-weight: 750; font-size: 14px; background: var(--surface2); color: var(--doux); }
.nom { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sous { color: var(--doux); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.textes { min-width: 0; flex: 1; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; letter-spacing: .03em; vertical-align: 1px; margin-inline-end: 6px; }
.badge.a { background: #8a96ff22; color: var(--alpha); }
.badge.z { background: #2cc0ad22; color: var(--z2u); }
.badge.t { background: var(--surface2); color: var(--doux); }
.etoile { width: 38px; height: 38px; border-radius: 50%; color: var(--doux); font-size: 20px; flex: none; }
.etoile[aria-pressed="true"] { color: #ffc93c; }
.groupe { background: var(--surface); border-radius: 12px; overflow: hidden; }
.groupe > button { width: 100%; display: flex; justify-content: space-between; padding: 13px 14px; font-weight: 600; text-align: start; }
.groupe .compte { color: var(--doux); font-weight: 500; }
.groupe .contenu { padding: 0 8px 8px; display: grid; gap: 4px; }
.groupe .contenu button { text-align: start; padding: 10px 10px; border-radius: 10px; background: var(--surface2); display: flex; justify-content: space-between; gap: 10px; }

/* ---- Grilles films / séries ---- */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px 10px; }
.carte { text-align: start; min-width: 0; }
.affiche { aspect-ratio: 2 / 3; width: 100%; border-radius: 10px; overflow: hidden; background: linear-gradient(145deg, var(--surface2), var(--surface)); position: relative; display: grid; place-items: center; color: var(--doux); font-size: 12px; padding: 6px; text-align: center; }
.affiche img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.affiche .progression { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.carte .nom { font-size: 13.5px; margin-top: 6px; }
.carte .sous { font-size: 12px; }
.rangee { display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.rangee::-webkit-scrollbar { display: none; }

/* ---- Fiche (feuille du bas) ---- */
.voile { position: fixed; inset: 0; background: #000a; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.feuille { width: 100%; max-width: 760px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 20px); }
.poignee { width: 42px; height: 5px; border-radius: 3px; background: var(--ligne); margin: 0 auto 12px; }
.fermer { float: right; width: 34px; height: 34px; border-radius: 50%; background: var(--surface2); color: var(--doux); font-size: 18px; }
.entete-fiche { display: flex; gap: 14px; }
.entete-fiche .affiche { width: 108px; flex: none; }
.entete-fiche h3 { margin: 4px 0 6px; font-size: 20px; line-height: 1.2; }
.meta { color: var(--doux); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.resume { color: #c9cdd6; font-size: 14px; margin: 12px 0 0; }
.actions { display: grid; gap: 8px; margin-top: 16px; }
.saisons { display: flex; gap: 6px; overflow-x: auto; margin: 16px 0 10px; scrollbar-width: none; }
.saisons button { padding: 7px 13px; border-radius: 999px; background: var(--surface2); color: var(--doux); white-space: nowrap; font-weight: 600; }
.saisons button[aria-pressed="true"] { background: var(--accent-doux); color: var(--accent); }
.episode { display: flex; gap: 12px; align-items: center; padding: 11px 10px; border-radius: 12px; background: var(--surface2); width: 100%; text-align: start; margin-bottom: 6px; }
.episode .num { font-weight: 750; color: var(--accent); width: 34px; flex: none; }
.episode.fini .num { color: var(--doux); }
.barre-prog { height: 3px; border-radius: 2px; background: var(--ligne); margin-top: 6px; overflow: hidden; }
.barre-prog i { display: block; height: 100%; background: var(--accent); }
.versions { margin-top: 18px; }

/* ---- Barre télécommande ---- */
.telecommande {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--ligne);
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
}
.telecommande .interieur { max-width: 760px; margin: 0 auto; }
.tc-ligne { display: flex; align-items: center; gap: 10px; }
.tc-titre { flex: 1; min-width: 0; text-align: start; }
.tc-boutons { display: flex; gap: 4px; }
.rond { width: 42px; height: 42px; border-radius: 50%; background: var(--surface2); display: grid; place-items: center; font-size: 17px; flex: none; }
.rond.principal { background: var(--accent); color: #1a0d06; }
.rond:disabled { opacity: .35; }
.tc-temps { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--doux); font-variant-numeric: tabular-nums; }
.tc-temps input { flex: 1; accent-color: var(--accent); }
.tc-etendu { margin-top: 12px; display: grid; gap: 12px; }
.tc-grille { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tc-grille button { padding: 11px 0; border-radius: 12px; background: var(--surface2); font-size: 13px; font-weight: 600; }
.croix { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 48px); gap: 6px; justify-content: center; }
.croix button { border-radius: 12px; background: var(--surface2); font-size: 18px; }
.croix .ok { background: var(--accent-doux); color: var(--accent); font-weight: 750; font-size: 14px; }
.vol { display: flex; align-items: center; gap: 10px; }
.vol input { flex: 1; accent-color: var(--accent); }

/* ---- Messages ---- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 18px); z-index: 40; background: #2c3140; color: var(--texte); padding: 11px 16px; border-radius: 12px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px #0008; font-size: 14px; }
.toast.erreur { background: #4a1f23; color: #ffd6d6; }
.install { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-doux); color: var(--texte); font-size: 13.5px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
