/* MorpheusTV — feuille de style unique, sans dépendance externe. */

:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --bg-hover: #1f2630;
  --border: #262d38;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #5a6472;
  --accent: #e5a00d;
  --accent-hover: #f5b429;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 10px;
  --radius-sm: 6px;
  --topbar-h: 60px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

/* L'attribut hidden passe par la feuille de style du navigateur, qu'une simple
   règle d'auteur suffit à écraser : sans ceci, tout élément masqué en JS mais
   déclaré display:flex ou display:grid ici resterait visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Double-taper ne doit jamais zoomer. « manipulation » ne laisse au navigateur
   que le défilement et le pincement : le zoom au double-tap disparait, et avec
   lui le délai de 300 ms que Safari s'accordait pour distinguer un tap simple
   d'un double-tap. Posé sur la racine, cela vaut pour toute la page — le
   comportement d'un élément tactile résulte de l'intersection de sa valeur
   avec celle de ses ancêtres. Le pincement, lui, reste possible : c'est un
   geste volontaire, et iOS refuse de toute façon qu'une page le désactive. */
html, body { touch-action: manipulation; }

/* Pas d'élasticité : sur iPhone, tirer la page au-delà de ses bords la faisait
   suivre le doigt et découvrait un vide au-dessus de la barre. Une page qui
   tient dans l'écran ne bouge plus ; une page plus longue défile normalement. */
html, body { overscroll-behavior: none; }

/* Pas de barre de défilement sur un écran tactile : on défile au doigt, et elle
   ne fait que passer par-dessus les affiches. Une souris, elle, en a besoin. */
@media (hover: none) and (pointer: coarse) {
  html, body, * { scrollbar-width: none; }
  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  *::-webkit-scrollbar { display: none; width: 0; height: 0; }
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* ---------- barre supérieure ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
/* La tuile, le toit et le triangle sont dessinés par le SVG lui-même : il ne
   reste ici qu'à lui donner sa taille. Un flex-shrink à zéro le protège du
   tassement quand la barre se remplit. */
.brand-mark {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }

.search-wrap { flex: 1; max-width: 460px; }
#search {
  width: 100%;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
}
#search:focus { border-color: var(--accent); background: var(--bg-hover); }
#search::placeholder { color: var(--text-faint); }

.nav-link {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-raised); }
.nav-link.active { color: var(--text); background: var(--bg-hover); }

/* ---------- bandeau de scan ---------- */

.scan-banner {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.scan-banner-text { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.scan-banner-text strong { font-weight: 600; white-space: nowrap; }
.scan-banner-text span {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scan-banner-bar {
  flex: 1;
  height: 4px;
  min-width: 80px;
  border-radius: 2px;
  background: var(--bg-hover);
  overflow: hidden;
}
.scan-banner-bar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s ease;
}

/* ---------- structure de page ---------- */

.view { padding: 28px 24px 64px; max-width: 1600px; margin: 0 auto; }
.view.view-flush { padding: 0; max-width: none; }

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.page-head .count { color: var(--text-faint); font-size: 14px; }
.page-head .spacer { flex: 1; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

select, input[type=text], input[type=password], input[type=number] {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); }

/* Les contrôles de formulaire n'héritent pas de la police du document : sans
   ces deux lignes, ils gardent la police et le corps par défaut du navigateur
   (environ 13 px), plus petits que le reste de l'interface. */
select, textarea,
input[type=text], input[type=password], input[type=number], input[type=search] {
  font-family: inherit;
  font-size: 14px;
}

/* Sur écran tactile, Safari iOS zoome d'autorité sur un champ dont le texte
   fait moins de 16 px, et ne dézoome pas en sortant : la page reste décalée.
   Passer à 16 px est la seule parade qui ne bloque pas le zoom manuel de
   l'utilisateur (contrairement à maximum-scale dans la balise viewport). */
@media (pointer: coarse) {
  select, textarea,
  input[type=text], input[type=password], input[type=number], input[type=search] {
    font-size: 16px;
  }
}

/* ---------- boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: #39424f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1117;
  font-weight: 650;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 81, 73, .1); border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  user-select: none;
}
.toggle input { accent-color: var(--accent); margin: 0; }
.toggle:has(input:checked) { color: var(--text); border-color: var(--accent); }

/* ---------- grille de films ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 18px;
}

.card { cursor: pointer; display: block; }
.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover .poster {
  transform: translateY(-4px);
  border-color: #39424f;
  box-shadow: var(--shadow);
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.poster-empty {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.35;
}

.poster-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, .55);
}
.poster-progress > div { height: 100%; background: var(--accent); }

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(13, 17, 23, .85);
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}
.badge-watched { color: var(--success); }
.badge-warn { color: var(--accent); }

.card-title {
  margin-top: 9px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Deux lignes sont réservées même quand le titre en occupe une seule : sans
     cela, une carte au titre court est plus basse que sa voisine et la rangée
     perd son alignement. */
  min-height: 2.6em;
}
.card-year { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }

/* ---------- fiche film ---------- */

.detail-hero {
  position: relative;
  min-height: 340px;
  padding: 40px 24px 32px;
  background-size: cover;
  background-position: center 20%;
}
.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(13,17,23,.97) 0%, rgba(13,17,23,.82) 45%, rgba(13,17,23,.55) 100%),
              linear-gradient(to top, var(--bg) 2%, transparent 55%);
}
.detail-inner {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}
.detail-poster {
  width: 210px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-raised);
}
.detail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-body { flex: 1; min-width: 0; padding-top: 6px; }
.detail-body h1 { margin: 0 0 6px; font-size: 32px; font-weight: 700; letter-spacing: -.025em; }
.detail-tagline { color: var(--text-dim); font-style: italic; margin: 0 0 14px; }
.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}
.detail-meta .dot { color: var(--text-faint); }
.rating { color: var(--accent); font-weight: 650; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 12.5px;
  color: var(--text-dim);
}

.overview { max-width: 720px; margin: 0 0 24px; color: #c9d1d9; }
/* Résumé replié pour que les boutons tiennent dans l'écran : le nombre de
   lignes est posé par ajusterFiche(), selon la place disponible. */
.overview.overview-replie {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.overview.overview-deplie { margin-bottom: 4px; }
.voir-plus {
  display: block;
  margin: 0 0 20px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.voir-plus[hidden] { display: none; }

/* L'image de fond d'une fiche, dans son calque : sa hauteur est celle de la
   fiche repliée (--fond-h, posée par ajusterFiche), et ne bouge plus quand le
   résumé se déplie. Le voile de .detail-hero::after passe par-dessus. */
.detail-fond {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--fond-h, 100%);
  background-size: cover;
  background-position: center 20%;
  pointer-events: none;
}
/* Fiche allongée : le bas de l'image se fond dans le fond de la page plutôt
   que de s'arrêter net au milieu du résumé. */
.detail-hero.resume-deplie .detail-fond {
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent);
  mask-image: linear-gradient(to bottom, #000 65%, transparent);
}
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Caractéristiques du fichier, dans la fenêtre « Infos » : une ligne par
   information plutôt qu'une carte, pour tenir sur un écran de téléphone. */
.infos-sous-titre { margin-top: 2px; font-size: 13px; color: var(--text-dim); }
.infos-fichier {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0;
  font-size: 14px;
}
.infos-fichier dt,
.infos-fichier dd { padding: 9px 0; border-bottom: 1px solid var(--border); }
.infos-fichier dt { padding-right: 18px; color: var(--text-faint); white-space: nowrap; }
.infos-fichier dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
/* Le chemin est trop long pour une demi-ligne : il prend toute la largeur. */
.infos-fichier .pleine { grid-column: 1 / -1; }
.infos-fichier dt.pleine { padding-bottom: 2px; border-bottom: 0; }
.infos-fichier dd.chemin {
  border-bottom: 0;
  text-align: left;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- lecteur ---------- */

.player-wrap { background: #000; }
.player-wrap video { width: 100%; max-height: calc(100vh - var(--topbar-h)); display: block; background: #000; }
.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.player-bar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.player-bar .spacer { flex: 1; }

/* ---------- réglages ---------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 22px;
  margin-bottom: 20px;
}
.panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 9px;
}
.panel .hint { color: var(--text-dim); font-size: 13.5px; margin: 0 0 18px; }
.panel .hint a { color: var(--accent); text-decoration: underline; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
.field input, .field select { width: 100%; }
.field .sub { color: var(--text-faint); font-size: 12.5px; margin-top: 5px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row .field { flex: 1; margin-bottom: 0; }

.lib-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.lib-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.lib-item .lib-info { flex: 1; min-width: 0; }
.lib-item .lib-name { font-weight: 600; }
.lib-item .lib-path {
  color: var(--text-faint);
  font-size: 12.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.stat-value { font-size: 22px; font-weight: 680; letter-spacing: -.02em; }
.stat-label { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }

.status-line { display: flex; align-items: center; gap: 9px; font-size: 14px; padding: 7px 0; }
.dot-indicator { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--success); }
.dot-warn { background: var(--accent); }
.dot-err { background: var(--danger); }

.error-list {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  max-height: 220px;
  overflow-y: auto;
  font-size: 12.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text-dim);
}
.error-list div { padding: 2px 0; }

/* ---------- sélecteur de dossier ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(1, 4, 9, .75);
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%;
  max-width: 620px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0 0 8px; font-size: 16px; font-weight: 650; }
.modal-path {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-dim);
  word-break: break-all;
}
.modal-list { flex: 1; overflow-y: auto; padding: 8px; }
.modal-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.modal-entry:hover { background: var(--bg-hover); }
.modal-entry .icon { color: var(--accent); flex-shrink: 0; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-foot .spacer { flex: 1; }
.modal-foot .count { color: var(--text-dim); font-size: 13px; }

.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.match-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.match-item img { width: 52px; height: 78px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--bg-raised); }
.match-item .match-body { min-width: 0; }
.match-item .match-title { font-weight: 600; }
.match-item .match-overview {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- états vides et messages ---------- */

.empty {
  max-width: 520px;
  margin: 72px auto;
  text-align: center;
}
.empty .icon { font-size: 44px; margin-bottom: 14px; }
.empty h2 { margin: 0 0 8px; font-size: 19px; font-weight: 650; }
.empty p { color: var(--text-dim); margin: 0 0 22px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 90vw;
}
.toast.error { border-color: var(--danger); color: #ffa198; }
.toast.success { border-color: var(--success); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 11px; color: var(--text-dim); padding: 48px 0; justify-content: center; }

/* ---------- adaptations petits écrans ---------- */

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .brand-name { display: none; }
  .nav-link { padding: 7px 9px; }
  .view { padding: 20px 14px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 18px 12px; }
  .detail-inner { flex-direction: column; gap: 20px; }
  .detail-poster { width: min(210px, 56vw); }
  .detail-body h1 { font-size: 24px; }
  .detail-hero { padding: 24px 14px; }
  .scan-banner { padding: 9px 14px; gap: 10px; }
  .scan-banner-text span { display: none; }
}

/* ---------- navigation etendue ---------- */

/* La recherche est poussée à droite : la navigation a quitté la barre du haut
   pour le panneau latéral, et rien ne la tient plus par la gauche. */
.search-wrap { margin-left: auto; }

/* ---------- rangees horizontales (accueil) ---------- */

.row-section { margin-bottom: 34px; }
.row-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.row-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.row-more { color: var(--text-dim); font-size: 13.5px; }
.row-more:hover { color: var(--accent); }

/* Les rangées de l'accueil. Elles s'appelaient « row », comme les lignes de
   formulaire déclarées plus haut : deux composants sans rapport pour un seul
   nom, et comme ce bloc-ci vient après, il l'emportait partout. Un champ de
   saisie et son bouton se retrouvaient chacun large de 168 pixels — la largeur
   d'une affiche. */
.card-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 168px;
  gap: 18px;
  overflow-x: auto;

  /* La barre de défilement reste masquée : une rangée se lit à la façon de
     Plex ou de Netflix, où c'est la carte coupée au bord qui annonce la suite.
     Le contenu défile toujours — au doigt, au pavé tactile, et à la molette
     accompagnée de Maj.

     La réserve du bas ne disparait pas avec elle : une carte survolée se
     soulève et projette une ombre, et overflow-x: auto rend la coupe
     verticale effective. Sans cette marge, l'ombre serait rognée. */
  padding-bottom: 10px;
  scrollbar-width: none;

  /* Les cartes s'alignent par le haut plutôt que de s'étirer à la hauteur de
     la plus grande : une carte au titre sur deux lignes ne doit pas décaler
     l'affiche de ses voisines. */
  align-items: start;
}
.card-row.wide { grid-auto-columns: 300px; }
.card-row::-webkit-scrollbar { display: none; }

/* ---------- carte paysage (reprendre la lecture) ---------- */

.card-wide .thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card-wide:hover .thumb {
  transform: translateY(-4px);
  border-color: #39424f;
  box-shadow: var(--shadow);
}
.card-wide .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: #fff;
  background: rgba(0, 0, 0, .3);
  opacity: 0;
  transition: opacity .18s ease;
}
.card-wide:hover .thumb-play { opacity: 1; }

.card-sub { color: var(--text-faint); font-size: 12.5px; margin-top: 3px; }

/* ---------- fiche serie : saisons et episodes ---------- */

.detail-parent {
  display: inline-block;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.detail-parent:hover { text-decoration: underline; }
.detail-poster-wide { width: 300px; aspect-ratio: 16/9; }

.seasons { max-width: 1200px; margin: 34px auto 0; padding: 0 24px 40px; }

/* Les affiches de saison sont un peu plus petites que celles d'une
   bibliothèque : une série de dix saisons doit tenir sans faire défiler. */
.grid-seasons { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }

/* ---------- distribution ---------- */

/* Une rangée de portraits ronds, comme sur Plex. Elle défile de côté plutôt
   que de passer à la ligne : vingt personnes sur trois lignes repousseraient
   tout le reste de la fiche. */
.cast { max-width: 1200px; margin: 30px auto 0; padding: 0 24px 40px; }
.seasons + .cast { margin-top: 0; }
.cast .row-head { align-items: center; }
.cast-version { color: var(--text-dim); font-size: 13.5px; }
.cast-edit { margin-left: auto; }
.cast-note { margin: -6px 0 12px; }
.cast-track {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.cast-person { flex: 0 0 132px; text-align: center; scroll-snap-align: start; }
.cast-photo {
  --teinte: 210;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, hsl(var(--teinte) 45% 38%), hsl(calc(var(--teinte) + 40) 40% 20%));
  color: rgba(255, 255, 255, .92);
  font-size: 34px;
  font-weight: 650;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.cast-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-name { margin-top: 10px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.cast-role { margin-top: 2px; font-size: 13px; color: var(--text-dim); line-height: 1.3; }

@media (max-width: 640px) {
  .cast { padding: 0 16px 32px; }
  .cast-person { flex-basis: 96px; }
  .cast-photo { width: 96px; font-size: 26px; }
}

/* Fenêtre d'édition de la distribution. */
.modal-cast { max-width: 760px; }
.cast-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cast-tab { font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.cast-tab:disabled { cursor: default; opacity: .55; }
.cast-tab-on { border-color: var(--accent); color: var(--accent); }
.cast-count { color: var(--text-faint); margin-left: 6px; }
.cast-origin { margin: 10px 0 12px; }
.cast-list { display: flex; flex-direction: column; gap: 8px; }
.cast-line { display: flex; align-items: center; gap: 12px; }
.cast .cast-photo-sm, .cast-photo-sm {
  width: 44px;
  flex: 0 0 44px;
  font-size: 14px;
  box-shadow: none;
  padding: 0;
}
button.cast-photo-sm { cursor: pointer; font: inherit; font-size: 16px; }
.cast-line-text { display: flex; flex-direction: column; min-width: 0; }
.cast-line-text span { color: var(--text-dim); font-size: 13px; }
.cast-line-edit input { flex: 1; min-width: 0; }
.cast-line-tools { display: flex; gap: 4px; }
.cast-search { padding: 6px 0 8px 56px; }
.cast-results { margin-top: 10px; }
.cast-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.cast-result:hover { border-color: var(--accent); }
.cast-result img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; }
.cast-result small { color: var(--text-faint); }

@media (max-width: 640px) {
  .cast-line-edit { flex-wrap: wrap; }
  .cast-line-edit input { flex-basis: calc(100% - 56px); }
  .cast-search { padding-left: 0; }
}

/* Passage d'une saison à l'autre depuis le bas de la liste d'épisodes. */
.season-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.season-chip {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  font-size: 13px;
  color: var(--text-dim);
  transition: background .15s, border-color .15s, color .15s;
}
.season-chip:hover { background: var(--bg-hover); border-color: #39424f; color: var(--text); }
.season-chip.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #10141a;
  font-weight: 600;
}

.episode-list { display: flex; flex-direction: column; gap: 10px; }
.episode-row {
  display: flex;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  transition: background .15s, border-color .15s;
}
.episode-row:hover { background: var(--bg-hover); border-color: #39424f; }

.episode-thumb {
  position: relative;
  width: 168px;
  flex-shrink: 0;
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.episode-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.episode-body { min-width: 0; flex: 1; }
.episode-title { font-weight: 600; display: flex; align-items: center; gap: 9px; }
.episode-seen {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 4px;
  padding: 1px 6px;
}
.episode-meta { color: var(--text-faint); font-size: 12.5px; margin-top: 3px; }
.episode-overview {
  color: var(--text-dim);
  font-size: 13px;
  margin: 7px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- lecteur ---------- */

.player-mode {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.mode-direct { color: var(--success); border-color: var(--success); }
.mode-transcode { color: var(--accent); border-color: var(--accent); }

.player-select {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.player-select select { height: 30px; font-size: 13px; max-width: 190px; }

.player-wrap { position: relative; }
.player-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 17, 23, .92);
  padding: 24px;
}
.player-error { text-align: center; max-width: 480px; }
.player-error strong { display: block; font-size: 17px; margin-bottom: 8px; color: var(--danger); }
.player-error p { color: var(--text-dim); margin: 0; }

/* ---------- reglages ---------- */

.lib-kind {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---------- petits ecrans ---------- */

@media (max-width: 720px) {
  .search-wrap { display: none; }
  .card-row { grid-auto-columns: 132px; }
  .card-row.wide { grid-auto-columns: 240px; }
  .episode-row { flex-direction: column; gap: 10px; }
  .episode-thumb { width: 100%; }
  .detail-poster-wide { width: 100%; max-width: 300px; }
  .seasons { padding: 0 14px; }
  .player-bar { flex-wrap: wrap; gap: 10px; }
  .player-select select { max-width: 130px; }
}

/* ---------- lecteur : plein ecran et messages ---------- */

/* Le conteneur passe en plein ecran plutot que la balise video seule, pour que
   les selecteurs de piste et de qualite restent accessibles. */
.player-shell:fullscreen { display: flex; flex-direction: column; background: #000; }
.player-shell:fullscreen .player-wrap { flex: 1; display: flex; }
.player-shell:fullscreen video { flex: 1; width: 100%; max-height: none; height: 100%; }

#player-fullscreen { font-size: 15px; line-height: 1; }

.player-notice {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  background: rgba(13, 17, 23, .92);
  border: 1px solid var(--border);
  font-size: 13.5px;
  max-width: 90%;
}

/* Les sous-titres natifs sont trop petits par defaut sur grand ecran. */
video::cue {
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 1.05em;
  line-height: 1.35;
}

/* ---------- pied du selecteur de dossier ---------- */

.modal-foot-stack { flex-direction: column; align-items: stretch; gap: 12px; }
.modal-foot-row { display: flex; align-items: center; gap: 10px; }
.modal-foot-row .spacer { flex: 1; }

/* ---------- guide TV ---------- */

/*
 * Les heures et les rangées vivent dans un même conteneur qui défile
 * horizontalement : elles restent alignées quoi qu'on fasse. L'ancien en-tête
 * collant était décalé de la hauteur de la barre du haut, mais par rapport au
 * cadre du guide (overflow: hidden) et non à la fenêtre — il retombait donc
 * par-dessus la première chaîne.
 */
.guide {
  --guide-col: 230px;
  --guide-head-h: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
/* Défilement possible au doigt ou à la molette, mais sans barre visible. */
.guide-scroll { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.guide-scroll::-webkit-scrollbar { display: none; }
/* La grille remplit la largeur ; en dessous de 180 px par heure, elle déborde. */
.guide-grid { position: relative; min-width: calc(var(--guide-col) + 4 * 180px); }

.guide-head {
  display: flex;
  height: var(--guide-head-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.guide-corner {
  width: var(--guide-col);
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
}
.guide-times { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.guide-time {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  padding-left: 8px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.guide-row { display: flex; border-bottom: 1px solid var(--border); }
.guide-row:last-of-type { border-bottom: none; }

.guide-channel {
  width: var(--guide-col);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg-raised);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 10;
}
.guide-channel:hover { background: var(--bg-hover); }
/* Les logos n'ont pas tous les mêmes proportions : un cadre fixe les aligne. */
.guide-channel img { width: 56px; height: 34px; object-fit: contain; flex-shrink: 0; }
.guide-channel-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guide-number {
  display: inline-block;
  min-width: 34px;
  color: var(--text-faint);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

.guide-lane { position: relative; height: 68px; flex: 1; min-width: 0; }
.guide-program {
  position: absolute;
  top: 7px;
  bottom: 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}
.guide-program:hover { background: var(--bg-hover); border-color: var(--accent); }
.guide-live { border-color: var(--accent); background: rgba(229, 160, 13, .12); }
.guide-title {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guide-hours { font-size: 11.5px; color: var(--text-faint); }
.guide-empty {
  position: sticky;
  left: var(--guide-col);
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  color: var(--text-faint);
  font-size: 13px;
}

/* La ligne de l'heure passe sous la colonne des chaînes quand on fait défiler. */
.guide-now {
  position: absolute;
  top: var(--guide-head-h);
  bottom: 0;
  left: calc(var(--guide-col) + (100% - var(--guide-col)) * var(--now-frac));
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
}
.guide-day { color: var(--text-dim); font-size: 13.5px; min-width: 170px; text-align: center; }

/* ---------- réglages : chaînes et balayage ---------- */

.tv-channel-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; }
.tv-channel {
  display: grid;
  grid-template-columns: 56px 44px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
.tv-channel img { width: 56px; height: 32px; object-fit: contain; }
.tv-channel .tv-logo-vide { width: 56px; height: 32px; }
.tv-channel-num { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 13px; }
.tv-channel-name { font-weight: 600; font-size: 14px; }
.tv-channel-masquee { opacity: .5; }
.tv-channel select { min-width: 150px; }
.tv-scan-status { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--text-dim); font-size: 13.5px; }
.tv-scan-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.tv-scan-row { display: grid; grid-template-columns: auto 52px 1fr auto; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--bg-raised); }
.tv-scan-row .sub { color: var(--text-faint); font-size: 12px; }
.tv-guide-options { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
/* .toggle est dessiné pour une ligne de 34 px : ici, l'étiquette porte une
   description sur plusieurs lignes, qui débordait sur l'option suivante. */
.tv-guide-options label.toggle,
.panel .field > label.toggle {
  display: flex;
  height: auto;
  min-height: 34px;
  padding: 10px 12px;
  line-height: 1.4;
}
/* `.field input` élargit tout champ à 100 % : la case à cocher aussi, qui
   repoussait son libellé à l'autre bout de l'étiquette. */
.field label.toggle input { width: auto; flex: none; }
.tv-guide-options label.toggle { align-items: flex-start; }
.tv-guide-options label.toggle input { margin-top: 3px; }
.tv-guide-options strong { display: block; color: var(--text); }
.tv-guide-options .sub { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-faint); }
.tv-sd-fields[hidden], .tv-gratuit-fields[hidden] { display: none; }

.player-now { font-size: 13px; color: var(--text-dim); }
.player-now-time { color: var(--text-faint); margin-left: 8px; }

@media (max-width: 720px) {
  .guide { --guide-col: 136px; }
  .guide-channel { padding: 0 10px; }
  .guide-number { min-width: 0; }
}

/* ================================================================== */
/* Profils : sélection, pastilles, pavé numérique                     */
/* ================================================================== */

/* Pendant la sélection, ni barre de navigation ni bandeau d'analyse. */
body.picking-profile .topbar,
body.picking-profile .sidebar,
body.picking-profile .sidebar-scrim,
body.picking-profile .scan-banner { display: none !important; }

.view-picker {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
}

.picker { text-align: center; max-width: 900px; width: 100%; }
.picker h1 {
  margin: 0 0 12px;
  font-size: 38px;
  font-weight: 750;
  letter-spacing: -.03em;
}
.picker-intro { color: var(--text-dim); margin: 0 auto 32px; max-width: 460px; }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 168px));
  gap: 34px 26px;
  justify-content: center;
  margin-top: 40px;
}

.picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-dim);
  transition: color .2s ease;
}
.picker-item:hover { color: var(--text); }
.picker-name { font-size: 15px; font-weight: 550; }

/* --- pastille --- */

.profile-badge {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .28), transparent 62%),
    var(--profile-color, var(--accent));
  box-shadow:
    0 10px 30px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), box-shadow .22s ease;
}
.profile-lg { width: 132px; height: 132px; font-size: 56px; }
.profile-sm { width: 30px; height: 30px; font-size: 15px; }

.picker-item:hover .profile-badge,
.picker-item:focus-visible .profile-badge {
  transform: translateY(-6px) scale(1.04);
  box-shadow:
    0 20px 46px rgba(0, 0, 0, .6),
    0 0 0 3px rgba(255, 255, 255, .14),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}

.profile-initial { color: #0d1117; font-weight: 700; opacity: .82; }
.profile-emoji { line-height: 1; }

.profile-lock {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 38%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: .34em;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
.profile-sm .profile-lock { display: none; }

/* La couronne de l'administrateur, posée en haut à droite de la pastille — le
   cadenas occupe déjà le bas. Pas de fond ni de bordure : une ombre portée
   suffit à la détacher, et l'emoji reste lisible même très réduit, ce que le
   cadenas ne permettait pas. */
.profile-crown {
  position: absolute;
  top: -8%;
  right: -6%;
  font-size: .32em;
  line-height: 1;
  transform: rotate(14deg);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .7));
  pointer-events: none;
}
/* Sur une pastille de 30 px, une taille relative donnerait 5 px : illisible.
   La couronne garde donc une taille fixe, quitte à déborder un peu. */
.profile-sm .profile-crown { font-size: 13px; top: -7px; right: -5px; }

/* Dans la pastille de la barre, la couronne rentre dans le galet plutôt que
   d'en dépasser : le contour arrondi doit rester net. */
.profile-chip .profile-crown { top: -3px; right: -2px; }

/* --- pastille dans la barre --- */

.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.profile-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: #39424f;
}
.profile-chip-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- pavé numérique --- */

.modal-pin { max-width: 340px; text-align: center; }
.modal-pin .modal-head { border-bottom: none; padding-bottom: 6px; }

.pin-dots { display: flex; justify-content: center; gap: 16px; padding: 18px 0 6px; }
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-faint);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}

.pin-error { color: var(--danger); font-size: 13px; min-height: 18px; padding: 4px 20px; }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px 20px 20px;
}
.pin-key {
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 21px;
  font-weight: 550;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.pin-key:hover { background: var(--bg-hover); }
.pin-key:active { transform: scale(.94); }
.pin-key-ghost { font-size: 14px; color: var(--text-dim); background: transparent; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.shake { animation: shake .38s ease; }

/* --- nuanciers du formulaire --- */

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 19px;
  display: grid;
  place-items: center;
  transition: transform .15s ease, border-color .15s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { border-color: var(--text); }
.swatch-avatar { background: var(--bg); border-color: var(--border); color: var(--text-dim); font-size: 18px; }
.swatch-avatar.selected { border-color: var(--accent); }

/* ================================================================== */
/* Finition générale : profondeur, flou, matières                      */
/* ================================================================== */

/* Un dégradé d'ambiance évite le noir plat sur les grandes surfaces.
   Il est porté par un calque fixe posé derrière le contenu, et non par
   background-attachment: fixed. Cette propriété est mal gérée par Safari sur
   iOS : elle oblige le navigateur à recomposer le fond à chaque image, le
   défilement devient saccadé et la page refuse d'aller jusqu'en bas — elle
   revient d'elle-même quelques centaines de pixels plus haut.
   La couleur de fond, elle, reste portée par html. */
body { background: transparent; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(229, 160, 13, .07), transparent 60%),
    radial-gradient(1000px 520px at 100% 0%, rgba(124, 156, 143, .06), transparent 55%);
}

/* Barre supérieure : verre dépoli plutôt qu'aplat translucide. */
.topbar {
  background: rgba(13, 17, 23, .72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 8px 24px rgba(0, 0, 0, .28);
}

.scan-banner {
  background: rgba(22, 27, 34, .78);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

/* Affiches : ombre en deux couches, plus proche d'une vraie profondeur. */
.poster, .card-wide .thumb {
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 20px rgba(0, 0, 0, .22);
}
.card:hover .poster, .card-wide:hover .thumb {
  transform: translateY(-6px) scale(1.015);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, .38),
    0 22px 48px rgba(0, 0, 0, .48),
    0 0 0 1px rgba(255, 255, 255, .08);
}
.card { transition: filter .2s ease; }
.grid:hover .card:not(:hover), .card-row:hover .card:not(:hover) { filter: brightness(.82); }

/* Panneaux : léger effet de verre et liseré supérieur. */
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 40%),
              var(--bg-raised);
  border-color: rgba(255, 255, 255, .07);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 12px 32px rgba(0, 0, 0, .26);
}
.panel-glass {
  background: rgba(22, 27, 34, .66);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

/* Fenêtres modales : arrière-plan franchement flouté. */
.modal-backdrop {
  background: rgba(1, 4, 9, .62);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.modal {
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 32%),
              rgba(22, 27, 34, .96);
  border-color: rgba(255, 255, 255, .1);
  box-shadow: 0 32px 80px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .05);
}

/* Boutons : relief discret et retour tactile. */
.btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, 0)),
              var(--bg-raised);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #f0b02a, var(--accent));
  box-shadow: 0 2px 6px rgba(229, 160, 13, .3), 0 6px 18px rgba(229, 160, 13, .18);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 3px 10px rgba(229, 160, 13, .42), 0 10px 26px rgba(229, 160, 13, .24);
}

/* Fiche détaillée : dégradé plus doux, titre mieux détaché. */
.detail-hero::after {
  background:
    linear-gradient(to right, rgba(13, 17, 23, .98) 0%, rgba(13, 17, 23, .86) 42%, rgba(13, 17, 23, .5) 100%),
    linear-gradient(to top, var(--bg) 1%, transparent 58%);
}
.detail-body h1 { text-shadow: 0 2px 24px rgba(0, 0, 0, .55); }
.detail-poster {
  box-shadow: 0 8px 20px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .5);
}

/* Le bandeau d'infos et les messages du lecteur passent aussi au verre. */
.player-bar {
  background: rgba(22, 27, 34, .8);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}
.player-notice, .toast {
  background: rgba(22, 27, 34, .82);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}

/* Guide TV : la colonne des chaînes se détache du défilement. */
.guide-channel { box-shadow: 6px 0 16px rgba(0, 0, 0, .28); }
.guide-live { box-shadow: 0 0 0 1px rgba(229, 160, 13, .3), 0 4px 14px rgba(229, 160, 13, .14); }
.guide-now { box-shadow: 0 0 14px rgba(229, 160, 13, .6); }

/* Épisodes et chiffres : même traitement de surface. */
.episode-row, .stat, .lib-item {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .24);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.episode-row:hover {
  transform: translateX(3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .34);
}

/* Champs : anneau de focus lisible, sans agressivité. */
select:focus, input:focus {
  box-shadow: 0 0 0 3px rgba(229, 160, 13, .18);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Apparition en douceur du contenu d'une vue. */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view > * { animation: rise .32s cubic-bezier(.2, .8, .3, 1) both; }
.view.view-flush > * { animation: none; }

/* Respect des préférences système : rien ne bouge si l'animation gêne. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .view > * { animation: none; }
}

/* ---------- menu de la pastille de profil ---------- */

.profile-menu-wrap { position: relative; }
.profile-chip-caret { color: var(--text-faint); font-size: 11px; margin-left: 1px; }

.profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  min-width: 248px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 34%),
              rgba(22, 27, 34, .95);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .62), 0 0 0 1px rgba(255, 255, 255, .04);
  animation: menu-in .16s cubic-bezier(.2, .8, .3, 1) both;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-menu-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 12px;
}
.profile-menu-name { font-weight: 650; font-size: 14.5px; }
.profile-menu-role { color: var(--text-faint); font-size: 12px; }

.profile-menu-section {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .13s ease;
}
.profile-menu-item:hover { background: var(--bg-hover); }
.profile-menu-icon { width: 18px; text-align: center; font-size: 14px; }
.profile-menu-lock { margin-left: auto; font-size: 11px; opacity: .7; }

.profile-menu-separator {
  height: 1px;
  margin: 7px 4px;
  background: var(--border);
}

/* ================================================================== */
/* Téléphone                                                          */
/* ================================================================== */

/* Aucun bouton ne doit se comprimer sous la largeur de son texte : sinon le
   libellé, centré et insécable, déborde des deux côtés. */
.btn { flex-shrink: 0; }

/* Une pastille de profil rognée par le bord de l'écran n'est plus cliquable. */
.profile-chip { flex-shrink: 0; }
.brand { min-width: 0; }

@media (max-width: 720px) {
  /* En haut : le bouton du menu, la marque, le profil. Toute la navigation
     vit dans le panneau de gauche, ouvert par ☰. */
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-name { display: none; }
  .search-wrap { display: none; }

  /* Champ et bouton côte à côte ne tiennent pas : on empile. */
  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  .row .field { width: 100%; }
  .row .btn { width: 100%; }

  /* Les libellés longs peuvent revenir à la ligne plutôt que déborder. */
  .btn { white-space: normal; min-height: 36px; height: auto; padding: 8px 14px; }

  .profile-chip-name { max-width: 92px; }

  /* La pastille termine la barre : le menu s'aligne sur son bord droit, hérité
     de la règle générale. L'ancrer à gauche — ce qu'il fallait faire du temps
     où la pastille était en début de barre — le faisait déborder de l'écran
     par la droite. Seule la largeur reste à borner. */
  .profile-menu {
    min-width: 0;
    width: 248px;
    max-width: calc(100vw - 24px);
  }

  .picker h1 { font-size: 30px; }
  .modal-foot { flex-wrap: wrap; }
}

/* Écrans très étroits : la pastille se réduit à son avatar. */
@media (max-width: 400px) {
  .profile-chip-name { display: none; }
  .profile-chip { padding: 4px 8px 4px 4px; }
}

/* ================================================================== */
/* Activité : ce qui est lu en ce moment, dans les réglages            */
/* ================================================================== */

.session-list { display: flex; flex-direction: column; gap: 12px; }

.session {
  display: flex;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.session-thumb {
  flex-shrink: 0;
  width: 54px;
  height: 80px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font-size: 22px;
}
.session-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Sans min-width, un titre insécable élargit la carte au lieu d'être coupé. */
.session-main { flex: 1; min-width: 0; }

.session-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.session-who { font-size: 13px; color: var(--text-dim); }

.session-state {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
}
.session-state.is-paused { color: var(--text-faint); }

.session-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-sub {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-bar {
  height: 4px;
  margin: 9px 0 5px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}
.session-bar > div {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .4s ease;
}

.session-times {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.session-approx {
  margin-left: 7px;
  border-bottom: 1px dotted var(--text-faint);
  cursor: help;
}

.session-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag-direct { color: var(--success); border-color: var(--success); }
.tag-transcode { color: var(--accent); border-color: var(--accent); }
.tag-faint { color: var(--text-faint); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .session { gap: 11px; padding: 10px; }
  .session-thumb { width: 44px; height: 66px; }
}

/* ================================================================== */
/* Sections : une bibliothèque porte plusieurs dossiers                */
/* ================================================================== */

/* La carte d'une section s'empile : en-tête, dossiers, action. La classe est
   nécessaire — le panneau des profils réutilise .lib-item et doit, lui, rester
   sur une seule ligne. */
.lib-section { flex-direction: column; align-items: stretch; gap: 11px; }

.lib-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-head .spacer { flex: 1; }

.lib-paths { display: flex; flex-direction: column; gap: 7px; }

.lib-path-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
/* Sans min-width, un chemin long pousse le bouton hors de la carte. */
.lib-path-row .lib-path { flex: 1; min-width: 0; }

.lib-empty {
  color: var(--text-faint);
  font-size: 13px;
  padding: 2px 0 4px;
}

/* Un profil que le serveur refusera de supprimer : la pastille le dit avant
   qu'on ne cherche le bouton. */
.lib-kind-locked { color: var(--accent); border-color: var(--accent); }

/* Une saisie courte n'a pas besoin de toute la largeur d'un sélecteur. */
.modal-narrow { max-width: 420px; }
.modal-body { padding: 16px 20px; }
.modal-body .field { margin-bottom: 0; }

/* ================================================================== */
/* Réglages : rail de sections à gauche, volet de contenu à droite     */
/* ================================================================== */

/* Les réglages n'ont plus de rail à eux : la navigation est passée dans le
   panneau de gauche, celui des sections. Deux menus côte à côte prenaient
   460 pixels pour dire la même chose, et sur écran étroit le second devenait
   une bande de puces à faire défiler, seul endroit de l'application à ne pas
   se naviguer par le panneau. */
.settings-shell {
  max-width: 900px;
  margin: 0 auto;
}

.settings-pane { min-width: 0; }

.settings-head { margin-bottom: 20px; }
.settings-head h2 {
  margin: 0 0 5px;
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -.02em;
}
.settings-head p { margin: 0; color: var(--text-dim); font-size: 14px; max-width: 620px; }

/* Le rail ne se réanime pas d'une section à l'autre : il ne change pas, seul
   le volet de droite est remplacé. */
.view > .settings-shell { animation: none; }
.settings-pane { animation: rise .26s cubic-bezier(.2, .8, .3, 1) both; }

/* ---------- liste « à régler » de l'aperçu ---------- */

.issue-list { display: flex; flex-direction: column; gap: 10px; }

.issue {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
}
.issue-err { border-left-color: var(--danger); }
.issue-warn { border-left-color: var(--accent); }
.issue-icon { font-size: 14px; line-height: 1.5; flex-shrink: 0; }
.issue-body { flex: 1; min-width: 0; font-size: 14px; color: var(--text-dim); }
.issue-link { color: var(--accent); white-space: nowrap; margin-left: 6px; font-weight: 550; }
.issue-link:hover { text-decoration: underline; }

.settings-ok { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); }

/* ---------- rangées de boutons sous un panneau ---------- */

.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- bibliothèques groupées par type ---------- */

.lib-group + .lib-group { margin-top: 22px; }
.lib-group-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.lib-group-title .count {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
}
.lib-icon { margin-right: 5px; }

/* ---------- couples clé/valeur du panneau Serveur ---------- */

.kv {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
  gap: 9px 20px;
  margin: 0;
  font-size: 13.5px;
}
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- choix de type à la création d'une section ---------- */

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.choice:hover { background: var(--bg-hover); color: var(--text); }
.choice.selected { border-color: var(--accent); background: rgba(229, 160, 13, .08); color: var(--text); }
.choice-icon { font-size: 19px; line-height: 1.2; }
.choice-name { font-weight: 600; font-size: 14px; }
.choice-sub { font-size: 12px; color: var(--text-faint); }

/* ---------- téléphone et tablette : le rail passe en bandeau ---------- */

@media (max-width: 900px) {
  .settings-shell { grid-template-columns: minmax(0, 1fr); gap: 18px; }

  .settings-head h2 { font-size: 21px; }
  .choices { grid-template-columns: 1fr; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}

/* ================================================================== */
/* Panneau de navigation à gauche, ouvert par le bouton ☰              */
/* ================================================================== */

:root { --sidebar-w: 236px; }

/* ---------- les boutons ☰ et ← ---------- */

/* Les deux voisinent dans leur propre groupe : l'espacement large de la barre
   les aurait éloignés l'un de l'autre autant que de la marque. */
.topbar-left { display: flex; align-items: center; gap: 2px; margin-left: -8px; flex-shrink: 0; }

.icon-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-raised); color: var(--text); }

.back-btn { font-size: 21px; line-height: 1; }

/* Les traits des icônes sont dessinés, pas écrits : un émoji à côté du ☰ et du
   ← aurait une couleur et une graisse à lui. */
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.ico, .ico * { stroke-linecap: round; stroke-linejoin: round; }
.ico-close { font-size: 17px; line-height: 1; }

/* ---------- groupe d'actions à droite ---------- */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* La recherche et la liste ne sont proposées qu'à l'accueil : ailleurs, la
   page a déjà ses propres commandes en tête, et le panneau de gauche mène à
   la liste. */
#nav-watchlist { display: none; }
body.at-home #nav-watchlist { display: grid; }

/* Sur grand écran le champ de recherche est déjà là : un bouton qui l'ouvre
   n'aurait rien à ouvrir. */
#search-toggle { display: none; }
.ico-close { display: none; }

@media (max-width: 720px) {
  body.at-home #search-toggle,
  body.searching #search-toggle { display: grid; }

  /* En recherche, le champ prend toute la barre : ce qui l'entoure s'efface
     plutôt que de le réduire à une fente. */
  body.searching .search-wrap { display: block; flex: 1 1 auto; margin-left: 0; }
  body.searching .topbar-left,
  body.searching .brand,
  body.searching #nav-watchlist,
  body.searching #profile-button { display: none; }
  body.searching .ico-search { display: none; }
  body.searching .ico-close { display: block; }
}

.burger { display: block; position: relative; width: 18px; height: 12px; }
.burger span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), opacity .16s ease;
}
.burger span:nth-child(1) { top: 0; }
.burger span:nth-child(2) { top: 5px; }
.burger span:nth-child(3) { top: 10px; }

/* ---------- le panneau ---------- */

.layout { display: flex; align-items: flex-start; }
.layout-main { flex: 1 1 auto; min-width: 0; }

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transition: margin-left .22s cubic-bezier(.2, .8, .3, 1),
              transform .24s cubic-bezier(.2, .8, .3, 1);
}

/* Refermé, le panneau sort par la gauche plutôt que de disparaitre d'un coup :
   le contenu récupère la place en glissant. Un débordement vers la gauche
   n'agrandit pas la zone défilable, contrairement à un débordement à droite.
   Ses liens sortent du parcours clavier par l'attribut inert, posé depuis le
   script : une transition sur visibility permettrait de garder la glissade
   visible, mais elle ne s'applique pas de façon fiable avec une durée nulle. */
body:not(.nav-open) .sidebar {
  margin-left: calc(var(--sidebar-w) * -1);
}

/* Chacun des deux visages du panneau est lui-même une colonne : c'est ce qui
   laisse « Réglages » descendre en bas par sa marge automatique, ce qu'un
   simple conteneur aurait rompu. */
.side-pane {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 14.5px;
  white-space: nowrap;
}
.side-link::before {
  content: attr(data-icon);
  width: 20px;
  text-align: center;
  font-size: 16px;
  filter: grayscale(1) opacity(.72);
  transition: filter .18s ease;
}
.side-link.active { background: var(--bg-hover); color: var(--text); font-weight: 550; }
.side-link.active::before { filter: none; }

/* Le trait pousse les réglages en bas du panneau quand la place le permet, et
   se contente de séparer quand la liste des sections a tout rempli. */
.side-sep { height: 1px; margin: 14px 12px 11px; background: var(--border); margin-top: auto; }

/* ---------- les sections de la bibliothèque ---------- */

.side-group { margin: 16px 0 4px; }

.side-group-title {
  padding: 0 12px 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Une section n'a pas d'icône : la gouttière vide du ::before l'aligne sur les
   entrées qui en ont une, sans ajouter un émoji de plus à chaque ligne. */
.side-library {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}
.side-library.active { color: var(--text); }

/* ---------- le panneau en mode réglages ---------- */

/* Le retour se lit comme un en-tête, pas comme une section de plus : c'est la
   sortie, et elle doit se distinguer de ce qu'elle surplombe. */
.side-back {
  color: var(--text-faint);
  font-size: 13.5px;
  margin-bottom: 6px;
}
.side-back:hover { color: var(--text); }

/* La pastille reprend le pire de ce que la section signale, pour qu'un
   problème se remarque sans ouvrir les onze sections une par une. */
.side-flag {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.side-flag-err { background: var(--danger); }
.side-flag-warn { background: var(--accent); }

/* ---------- écran étroit : le panneau se superpose ---------- */

.sidebar-scrim {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 44;
  background: rgba(0, 0, 0, .55);
}

/* Épinglé, le panneau fait partie de la page : il n'y a rien à assombrir. */
@media (min-width: 901px) {
  .sidebar-scrim { display: none !important; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 45;
    flex: none;
    width: 262px;
    height: auto;
    margin-left: 0;
    border-right: none;
    box-shadow: var(--shadow);
  }
  body:not(.nav-open) .sidebar {
    margin-left: 0;
    transform: translateX(-100%);
  }

  /* Ici le bouton ouvre et referme vraiment quelque chose : les trois barres
     deviennent une croix. Épinglé, il ne fait que rendre de la place, et
     garder les barres évite de promettre une fermeture. */
  body.nav-open .burger span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
  body.nav-open .burger span:nth-child(2) { opacity: 0; }
  body.nav-open .burger span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }
}

/* Le plein écran du lecteur ne laisse rien dépasser. */
body:has(.player-shell:fullscreen) .sidebar,
body:has(.player-shell:fullscreen) .sidebar-scrim { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sidebar, .burger span { transition: none; }
}

/* ================================================================== */
/* Tri et filtres d'une grille                                        */
/* ================================================================== */

/* Un bouton dont le rÃ©glage est actif : l'accent suffit Ã  le signaler, un
   remplissage plein en ferait l'action principale de la page. */
.btn-on { color: var(--accent); border-color: var(--accent); }
.btn-on:hover:not(:disabled) { background: rgba(229, 160, 13, .1); border-color: var(--accent); }

.btn-icon { opacity: .6; font-size: 12px; }
.sort-arrow { color: var(--accent); font-weight: 700; }

/* ---------- fenÃªtre Â« Trier par Â» ---------- */

.sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
}
.sort-row:hover { background: var(--bg-hover); color: var(--text); }
.sort-row.is-chosen { color: var(--text); background: var(--bg-hover); }

/* La colonne de la coche est rÃ©servÃ©e mÃªme quand elle est vide : les libellÃ©s
   restent alignÃ©s, et la coche n'a pas l'air de pousser sa ligne. */
.sort-check { width: 14px; flex-shrink: 0; color: var(--accent); font-weight: 700; }
.sort-name { flex: 1; min-width: 0; }
.sort-sens {
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- fenÃªtre Â« Filtrer Â» ---------- */

.filter-group { padding: 4px 4px 16px; }
.filter-group:last-child { padding-bottom: 4px; }

.filter-group-title {
  padding: 0 8px 9px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 8px; }

.filter-chip {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.filter-chip:hover { background: var(--bg-hover); color: var(--text); }
.filter-chip.is-chosen {
  border-color: var(--accent);
  background: rgba(229, 160, 13, .12);
  color: var(--accent);
  font-weight: 550;
}

@media (max-width: 720px) {
  /* Sur un Ã©cran Ã©troit, le sens du tri passe sous son libellÃ© plutÃ´t que de
     rogner les deux. */
  .sort-row { flex-wrap: wrap; row-gap: 2px; }
  .sort-name { flex: 1 0 auto; }
  .sort-sens { flex-basis: 100%; text-align: left; padding-left: 24px; }
}

/* ================================================================== */
/* Correction manuelle d'une fiche                                    */
/* ================================================================== */

.edit-block { padding: 14px 16px; }
.edit-block + .edit-block { border-top: 1px solid var(--border); }

/* Ce qui a été corrigé à la main le dit, et propose de revenir en arrière :
   un champ figé sans explication passerait pour un bogue le jour où une
   analyse ne le met plus à jour. */
.lock-note {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
}
.lock-note span { flex: 1; min-width: 180px; }

.poster-current { display: flex; align-items: flex-start; gap: 14px; }
.poster-current img {
  width: 74px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
.poster-empty-sm {
  display: grid;
  place-items: center;
  width: 74px;
  aspect-ratio: 2 / 3;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 12px;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.poster-choice {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.poster-choice:hover { border-color: var(--accent); transform: translateY(-2px); }
.poster-choice img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }

/* La langue de l'affiche décide souvent du choix : un même film a son titre
   gravé dans l'image, et l'on ne veut pas d'une jaquette en coréen. */
.poster-lang {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .7);
  color: var(--text-dim);
  font-size: 10.5px;
  text-transform: uppercase;
}

/* Code d'appairage : il se lit de loin, parfois sur un téléviseur. */
.pair-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 56px;
    font-weight: 650;
    letter-spacing: 10px;
    color: var(--accent);
    text-align: center;
    padding: 28px 20px;
    margin: 0 auto 20px;
    max-width: 560px;
    background: var(--bg-raised);
    border-radius: 14px;
}
