:root {
  --fond: #0b0d12;
  --surface: #141821;
  --surface2: #1b2030;
  --trait: #252b3b;
  --texte: #eef1f6;
  --doux: #8e96aa;
  --accent: #ff8a4c;
  --accent2: #ffc56b;
  --bleu: #7cc4ff;
  --rayon: 14px;
  --bas: env(safe-area-inset-bottom, 0px);
  --haut: env(safe-area-inset-top, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(74px + var(--bas));
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; }

/* ---------- En-tête ---------- */
.entete {
  position: sticky; top: 0; z-index: 10;
  padding: calc(10px + var(--haut)) 16px 8px;
  background: linear-gradient(var(--fond) 82%, rgba(11,13,18,0));
}
.entete-ligne { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { font-size: 28px; line-height: 1.1; margin: 4px 0 10px; letter-spacing: -.02em; font-weight: 750; }
.maj { color: var(--doux); font-size: 12px; white-space: nowrap; }

.puces { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 6px; padding: 0 16px; }
.puces::-webkit-scrollbar, .logos::-webkit-scrollbar { display: none; }
.puce {
  flex: none; padding: 7px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--trait);
  color: var(--doux); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.puce.actif { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.logos { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 4px; padding: 2px 16px 4px; }
.logo-choix {
  flex: none; width: 58px; height: 46px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--trait);
  display: grid; place-items: center; position: relative;
}
.logo-choix.actif { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.logo-choix img { max-width: 40px; max-height: 26px; object-fit: contain; }
.logo-choix .num { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: var(--doux); font-weight: 700; }

/* ---------- Logos de chaîne ---------- */
.chaine { display: flex; align-items: center; gap: 10px; min-width: 0; }
.badge {
  flex: none; width: 46px; height: 38px; border-radius: 10px; background: #fff;
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.badge img { max-width: 38px; max-height: 26px; object-fit: contain; }
.badge .repli { color: var(--fond); font-weight: 800; font-size: 11px; text-align: center; line-height: 1.05; padding: 0 3px; }
.numero { font-variant-numeric: tabular-nums; color: var(--doux); font-weight: 700; font-size: 13px; min-width: 22px; text-align: right; }

/* ---------- Listes ---------- */
main { padding: 4px 12px 16px; }
.vide { color: var(--doux); text-align: center; padding: 48px 20px; }
.ligne {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 12px; border-radius: var(--rayon); background: var(--surface); margin-bottom: 8px;
  width: 100%; text-align: left;
}
.ligne .gauche { display: flex; align-items: center; gap: 8px; }
.titre { font-weight: 700; font-size: 16px; line-height: 1.25; }
.sous { color: var(--doux); font-size: 13.5px; margin-top: 2px; }
.heure { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent2); }
.cat { color: var(--doux); }
.suivant { margin-top: 8px; font-size: 13.5px; color: var(--doux); display: flex; gap: 6px; }
.suivant b { color: var(--texte); font-weight: 600; }
.jauge { height: 4px; border-radius: 4px; background: var(--trait); margin-top: 8px; overflow: hidden; }
.jauge i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; }

/* ---------- Ce soir ---------- */
.soir { background: var(--surface); border-radius: 18px; margin-bottom: 12px; overflow: hidden; }
.soir-tete { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 0; }
.soir-tete .nom { font-weight: 700; color: var(--doux); font-size: 13px; letter-spacing: .02em; text-transform: uppercase; }
.prime { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 10px 12px 12px; width: 100%; text-align: left; }
.vignette { width: 132px; aspect-ratio: 16/10; border-radius: 10px; background: var(--surface2) center/cover no-repeat; position: relative; overflow: hidden; }
.vignette img { width: 100%; height: 100%; object-fit: cover; }
.vignette .duree { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 6px; }
.etiquette { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 3px; }
.seconde { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; padding: 10px 12px 12px; border-top: 1px solid var(--trait); font-size: 14px; }
.seconde .etiquette { color: var(--bleu); margin: 0; flex: none; }
.seconde .t { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Journée / Semaine ---------- */
.bloc { background: var(--surface); border-radius: 18px; margin-bottom: 12px; padding: 4px 0; }
.bloc-tete { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.bloc-tete .nom { font-weight: 700; }
.jour-titre { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); padding: 14px 6px 6px; }
.prog { scroll-margin-top: 170px; display: grid; grid-template-columns: 50px 1fr; gap: 10px; padding: 9px 12px; width: 100%; text-align: left; border-top: 1px solid var(--trait); }
.bloc .prog:first-of-type { border-top: 0; }
.prog.encours { background: linear-gradient(90deg, rgba(255,138,76,.14), transparent 70%); }
.prog.passe .t, .prog.passe .heure { opacity: .45; }
.prog .t { font-weight: 600; }
.prog .s { color: var(--doux); font-size: 13px; }
.direct { font-size: 10px; font-weight: 800; color: var(--fond); background: var(--accent); border-radius: 4px; padding: 1px 4px; margin-left: 6px; vertical-align: 2px; }

/* ---------- Chaînes ---------- */
.recherche {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--texte); font-size: 16px; margin-bottom: 10px; outline: none;
}
.recherche:focus { border-color: var(--accent); }
.section-titre { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--doux); padding: 14px 4px 2px; }
.reglage { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border-radius: 12px; margin-bottom: 6px; }
.reglage .nom { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reglage input {
  width: 58px; padding: 7px 6px; border-radius: 8px; border: 1px solid var(--trait); background: var(--surface2);
  color: var(--texte); text-align: center; font-size: 16px; font-variant-numeric: tabular-nums;
}
.bouton-rond { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface2); flex: none; }
.bouton-rond svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bouton-rond.ajout { background: var(--accent); color: var(--fond); }
.bouton-rond.retrait { color: #ff6b6b; }
.attente { opacity: .45; pointer-events: none; }
.note { color: var(--doux); font-size: 13px; padding: 4px 4px 10px; }

/* ---------- Barre d'onglets ---------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--bas));
  background: rgba(16,19,26,.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--trait);
}
.onglets button { display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: var(--doux); font-size: 10.5px; font-weight: 600; }
.onglets svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.onglets svg .plein { fill: currentColor; stroke: none; }
.onglets svg .creux { fill: rgba(16,19,26,1); }
.onglets button.actif { color: var(--accent); }
.onglets button.actif .onde { animation: onde 1.8s ease-in-out infinite; }
@keyframes onde { 50% { opacity: .25; } }

/* ---------- Fiche programme ---------- */
.fiche { position: fixed; inset: 0; z-index: 30; }
.fiche-fond { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.fiche-carte {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding-bottom: calc(20px + var(--bas));
  animation: monte .22s ease-out;
}
@keyframes monte { from { transform: translateY(40px); opacity: .4; } }
.fiche-fermer { position: absolute; right: 12px; top: 12px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.fiche-fermer svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.fiche-image { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--surface2); }
.fiche-corps { padding: 16px 18px 0; }
.fiche-corps h2 { font-size: 22px; margin: 6px 0 4px; line-height: 1.2; }
.fiche-corps .meta { color: var(--doux); font-size: 14px; margin-bottom: 12px; }
.fiche-corps p { margin: 0; font-size: 15.5px; line-height: 1.5; color: #d6dae4; }
.fiche-sans-image { padding-top: 48px; }

@media (min-width: 700px) {
  main, .entete { max-width: 760px; margin-left: auto; margin-right: auto; }
  .fiche-carte { max-width: 620px; margin: 0 auto; border-radius: 22px; bottom: 5vh; }
}
