/* ============================================================
   NorexTube player.css — style sombre moderne, mobile-first
   ============================================================ */
:root {
  --main-color: #FF4757;          /* rouge NorexTube (cohérent avec la carte hub) */
  --bg: #0e0e12;
  --bg-soft: #16161d;
  --bg-card: #1c1c25;
  --border: #2a2a36;
  --text: #e8e8ee;
  --text-dim: #9a9aa8;
  --accent: #ff4757;
  --accent-hover: #ff5f6d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

/* Le header partagé utilise son propre theming ; on force la couleur */
.custom-header { --main-color: var(--accent); }
.custom-header .title-banner h1 {
  background: linear-gradient(90deg, #ff4757, #ff8a3d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ==================== Zone de saisie ==================== */
.player-app {
  width: 100%;
  max-width: 1680px;
  margin: 20px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px 26px;
  align-items: start;
}
/* Dès qu'une vidéo est chargée : player persistant à gauche,
   liste de résultats fine à droite (disposition façon YouTube) */
.player-app.has-player {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
}

/* Barre de recherche pleine largeur, à plat (pas de carte) */
.url-box {
  grid-column: 1 / -1;
}

.url-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 0 5px 16px;
  transition: border-color 0.15s ease;
}
.url-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.18);
}

.url-icon {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  flex: 0 0 auto;
}

#search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 0;
}
#search-input::placeholder { color: var(--text-dim); }

/* Bouton de recherche : loupe intégrée à la pilule (façon YouTube) */
.load-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--text);
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0 999px 999px 0;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 18px 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.load-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.load-btn:hover { background: var(--bg-soft); }
.load-btn:active { background: var(--bg-card); }

.error-msg {
  margin: 10px 2px 0;
  color: #ff6b6b;
  font-size: 0.88rem;
  background: rgba(255, 71, 87, 0.08);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ==================== Player ==================== */
.player-wrap {
  min-width: 0;
  /* Pas de carte : cadre vidéo + contrôles à plat */
}
/* Player collant à gauche : il reste visible pendant que la liste défile */
.player-app.has-player .player-wrap {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: 16px;
}

.video-frame {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.embed-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.embed-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ==================== Résultats de recherche (liste façon YouTube) ==================== */
.results-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-app.has-player .results-panel {
  grid-column: 2;
  grid-row: 2;
}

.rr-head {
  margin: 0 8px 4px;
  font-size: 1.02rem;
  color: var(--text);
}

.rr-count {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.rr-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Colonne droite : la liste défile seule pendant que le player reste */
.player-app.has-player .rr-list {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding-right: 6px;
}

.rr-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 8px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.rr-item:hover,
.rr-item.is-active { background: #262630; }

.rr-thumb-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 168px;
  max-width: 42%;
}
/* Pleine largeur (avant la 1re lecture) : miniatures plus grandes */
.player-app:not(.has-player) .rr-thumb-wrap { width: 246px; max-width: 38%; }

.rr-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}

.rr-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.rr-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.rr-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rr-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rr-status {
  margin: 6px 8px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.rr-more {
  margin: 8px 6px 4px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.rr-more:hover { border-color: var(--accent); background: #23232e; }
.rr-more:disabled { opacity: 0.6; cursor: default; }

/* Créateur (chaîne) cliquable dans un résultat */
.rr-channel {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}
.rr-channel:hover,
.rr-channel:focus-visible { text-decoration: underline; outline: none; }

/* ==================== Page chaîne (façon YouTube) ==================== */
.rr-back {
  align-self: flex-start;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 4px 8px;
  margin: 0 0 4px;
  cursor: pointer;
}
.rr-back:hover { color: var(--accent); }

.ch-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.ch-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--bg-card);
}
.ch-meta { min-width: 0; }
.ch-name {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-sub { color: var(--text-dim); font-size: 0.82rem; }

/* ==================== Page chaîne (pleine largeur) ==================== */
.channel-panel {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Quand la page chaîne est ouverte, on repasse en une colonne : le player
   (s'il joue) est au-dessus, la grille de la chaîne dessous, pleine largeur. */
.player-app.channel-view { grid-template-columns: minmax(0, 1fr); }
.player-app.channel-view .player-wrap {
  grid-column: 1;
  grid-row: auto;
  position: static;
}

/* Grille façon YouTube : 3 miniatures par ligne sur PC, titre en dessous */
.ch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px 16px;
  padding: 4px 8px 10px;
}
.ch-grid .rr-item {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 0;
  background: transparent;
}
.ch-grid .rr-item:hover,
.ch-grid .rr-item.is-active { background: transparent; }
.ch-grid .rr-item:hover .rr-thumb {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.channel-panel .ch-grid .rr-thumb-wrap {
  width: 100%;
  max-width: 100%;
}
.ch-grid .rr-title {
  font-size: 0.92rem;
  -webkit-line-clamp: 2;
}
.ch-grid .rr-sub { font-size: 0.8rem; }
.ch-grid .rr-badge { font-size: 0.72rem; }
/* Bouton « Afficher plus » sous la grille, centré pleine largeur */
.channel-panel > .rr-more {
  margin: 6px 8px 14px;
  width: calc(100% - 16px);
}

/* ==================== Barre de contrôles ==================== */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.video-title {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chaîne + titre empilés sous la vidéo (façon YouTube) */
.video-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.video-channel {
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-channel:hover { text-decoration: underline; }

.controls-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ctl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.ctl-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.ctl-btn:hover { border-color: var(--accent); background: #23232e; }
.ctl-btn:active { transform: scale(0.96); }

#cinema-btn { border-color: rgba(255, 71, 87, 0.4); }
#cinema-btn:hover { background: rgba(255, 71, 87, 0.12); }

.ctl-dl { color: #7dd87d; border-color: rgba(125, 216, 125, 0.35); }
.ctl-dl:hover { background: rgba(125, 216, 125, 0.1); border-color: #7dd87d; }

/* ==================== Mode Cinéma ==================== */
body.cinema {
  overflow: hidden;
  background: #000;
}

body.cinema .player-app {
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
  grid-template-columns: minmax(0, 1fr);
}
body.cinema .url-box,
body.cinema .results-panel {
  display: none;
}

/* Spécificité renforcée : la règle .has-player .player-wrap (sticky)
   gagnerait sinon (plus de classes) et casserait le plein écran */
body.cinema .player-app.has-player .player-wrap,
body.cinema .player-app .player-wrap {
  border: none;
  border-radius: 0;
  background: #000;
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

body.cinema .video-frame {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

body.cinema .embed-container {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;   /* on laisse l'iframe se gérer en plein écran */
  display: flex;
  align-items: center;
  justify-content: center;
}
body.cinema .embed-container iframe {
  position: static;
  width: 100%;
  height: 100%;
}

/* Fond assombri déjà géré par le fixed overlay (z-index 1000 + body noir) */

.cinema-exit {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(20, 20, 28, 0.85);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.cinema-exit:hover { background: rgba(255, 71, 87, 0.85); color: #fff; }

body.cinema .controls-bar {
  border-top: 1px solid var(--border);
  background: #0a0a0e;
}



/* ==================== Lecture automatique ==================== */

/* Interrupteur dans la barre de contrôles */
.ctl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ctl-toggle:hover { border-color: var(--accent); background: #23232e; }
.ctl-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ctl-switch {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: #33333e;
  border: 1px solid #4a4a58;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.ctl-knob {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cfcfd8;
  transform: translateY(-50%);
  transition: transform 0.2s ease, background 0.2s ease;
}
.ctl-toggle[aria-checked="true"] .ctl-switch {
  background: var(--accent);
  border-color: var(--accent);
}
.ctl-toggle[aria-checked="true"] .ctl-knob {
  transform: translate(16px, -50%);
  background: #fff;
}

/* Vidéo qui va être enchaînée : liseré dans la liste */
.rr-item.is-next {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Écran de fin, posé sur le lecteur */
.auto-next-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 14px;
  pointer-events: none;    /* la vidéo reste pilotable pendant le décompte */
}
.auto-next-overlay.is-visible { display: flex; }

.auto-next-card {
  pointer-events: auto;
  position: relative;
  width: min(340px, 100%);
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 12, 16, 0.94);
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: auto-next-in 0.22s ease-out;
}
@keyframes auto-next-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.auto-next-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a20;
}
.auto-next-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.auto-next-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.auto-next-thumb:hover .auto-next-play,
.auto-next-thumb:focus-visible .auto-next-play { opacity: 1; }

.auto-next-info { min-width: 0; }
.auto-next-eyebrow {
  margin: 0 0 5px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.auto-next-title {
  margin: 0 0 3px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.auto-next-channel {
  margin: 0 0 9px;
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auto-next-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.auto-next-btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.auto-next-btn:hover { background: rgba(255, 255, 255, 0.20); border-color: var(--accent); }
.auto-next-btn--primary { background: var(--accent); border-color: var(--accent); }
.auto-next-btn--primary:hover { background: color-mix(in srgb, var(--accent) 82%, #000); border-color: transparent; }
.auto-next-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}
.auto-next-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
}

@media (max-width: 520px) {
  .auto-next-card { grid-template-columns: 1fr; }
  .auto-next-thumb { display: none; }
}

/* ============================================================
   POLISH (2026-10-01) — hero d'accueil, auto-chargement,
   squelettes, survols, retour en haut.
   ============================================================ */

/* Halo d'ambiance en haut de page (léger, non intrusif) */
body::before {
  content: "";
  position: fixed;
  inset: -10% -10% auto -10%;
  height: 62vh;
  background:
    radial-gradient(58% 100% at 50% 0%, rgba(255, 71, 87, 0.16), transparent 70%),
    radial-gradient(40% 70% at 85% 8%, rgba(255, 138, 61, 0.10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.player-app { position: relative; z-index: 1; }

/* ---------- Auto-chargement : sentinelle + spinner + fin ---------- */
.rr-sentinel { display: flex; justify-content: center; padding: 14px 8px 6px; }
.rr-end {
  margin: 12px 8px 6px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}
.rr-more { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.rr-spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.rr-more.is-loading { pointer-events: none; }
.rr-more.is-loading .rr-spinner { opacity: 1; animation: rr-spin 0.7s linear infinite; }
@keyframes rr-spin { to { transform: rotate(360deg); } }

/* La sentinelle de la grille chaîne occupe toute la largeur */
.ch-grid > .rr-sentinel,
.ch-grid > .rr-end { grid-column: 1 / -1; }

/* ---------- Squelettes de chargement ---------- */
.rr-list--loading { pointer-events: none; }
.rr-skel { display: flex; align-items: flex-start; gap: 14px; padding: 8px; }
.rr-skel-thumb {
  flex: 0 0 auto;
  width: 168px; max-width: 42%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}
.player-app:not(.has-player) .rr-skel-thumb { width: 246px; max-width: 38%; }
.rr-skel-meta { flex: 1 1 auto; display: flex; flex-direction: column; gap: 9px; padding-top: 8px; min-width: 0; }
.rr-skel-line { height: 12px; border-radius: 6px; }
.rr-skel-line.w80 { width: 80%; }
.rr-skel-line.w50 { width: 50%; }
.rr-skel-thumb, .rr-skel-line {
  background-color: var(--bg-card);
  background-image: linear-gradient(90deg, var(--bg-card) 0%, #26262f 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: rr-shimmer 1.25s ease-in-out infinite;
}
@keyframes rr-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* ---------- Survols plus vivants ---------- */
.rr-item { transition: background 0.14s ease, transform 0.14s ease; }
.rr-item:hover { transform: translateX(3px); }
.ch-grid .rr-item:hover { transform: translateY(-3px); }
.rr-thumb-wrap { overflow: hidden; border-radius: 8px; }
.rr-thumb { transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), filter 0.2s ease; }
.rr-item:hover .rr-thumb { transform: scale(1.045); filter: saturate(1.12) brightness(1.04); }

/* Entrée en douceur des éléments (et des tranches auto-chargées) */
.rr-item, .rr-skel { animation: tube-fade 0.35s ease both; }
@keyframes tube-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Barre de défilement fine (colonne de résultats) ---------- */
.player-app.has-player .rr-list { scrollbar-width: thin; scrollbar-color: #3a3a46 transparent; }
.player-app.has-player .rr-list::-webkit-scrollbar { width: 9px; }
.player-app.has-player .rr-list::-webkit-scrollbar-track { background: transparent; }
.player-app.has-player .rr-list::-webkit-scrollbar-thumb {
  background: #33333e; border-radius: 999px; border: 2px solid var(--bg);
}
.player-app.has-player .rr-list::-webkit-scrollbar-thumb:hover { background: #454552; }

/* ---------- Cadre vidéo : léger halo ---------- */
.video-frame {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ---------- Bouton « retour en haut » ---------- */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(20, 20, 28, 0.86);
  color: var(--text);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  animation: tube-fade 0.25s ease both;
}
.to-top svg { width: 20px; height: 20px; }
.to-top:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: translateY(-2px); }
.to-top[hidden] { display: none; }

/* ---------- Page d'accueil : historique + recommandations ---------- */
.tube-home {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 8px;
  animation: tube-fade 0.45s ease both;
}
.tube-home[hidden] { display: none; }
.home-block { min-width: 0; }
.home-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 10px;
}
.home-title {
  margin: 0 4px 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.home-head .home-title { margin: 0; }
.home-clear {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.home-clear:hover { color: var(--accent); background: rgba(255, 71, 87, 0.08); }

/* Rangée horizontale (historique de visionnage) */
.home-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 220px);
  gap: 14px;
  overflow-x: auto;
  padding: 2px 4px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #3a3a46 transparent;
}
.home-row::-webkit-scrollbar { height: 8px; }
.home-row::-webkit-scrollbar-thumb { background: #33333e; border-radius: 999px; }
.home-card {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.home-card__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.home-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), filter 0.2s ease;
}
.home-card:hover .home-card__thumb img { transform: scale(1.05); filter: brightness(1.06); }
.home-card__title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-card__sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chips (chaînes + recherches) */
.home-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.home-chip {
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.home-chip:hover { border-color: var(--accent); background: rgba(255, 71, 87, 0.08); transform: translateY(-1px); }
.home-chip--chan { color: var(--accent); border-color: rgba(255, 71, 87, 0.32); }

/* ---------- Barre de conversion / téléchargement (discrète) ---------- */
.dl-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 880;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: rgba(14, 14, 18, 0.94);
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  /* Ne bloque JAMAIS un clic : ne gêne pas le visionnage. */
  pointer-events: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.dl-bar[hidden] { display: none; }
.dl-bar__label {
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dl-bar__fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #ff4757, #ff8a3d);
  transition: width 0.2s ease;
}
.dl-bar.is-indeterminate .dl-bar__fill {
  width: 100%;
  background: linear-gradient(90deg, transparent, #ff4757 45%, #ff8a3d 55%, transparent);
  background-size: 45% 100%;
  background-repeat: no-repeat;
  transition: none;
  animation: dl-slide 1.1s ease-in-out infinite;
}
@keyframes dl-slide { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.dl-bar.is-done { border-top-color: rgba(125, 216, 125, 0.55); }
.dl-bar.is-done .dl-bar__fill { background: #7dd87d; }

@media (prefers-reduced-motion: reduce) {
  .rr-item, .rr-skel, .tube-home, .to-top { animation: none !important; }
  .rr-thumb, .rr-item, .home-card__thumb img { transition: none !important; }
}

/* ==================== Mobile ==================== */
@media (max-width: 640px) {
  .controls-bar { flex-direction: column; align-items: stretch; }
  .video-title { text-align: center; white-space: normal; }
  .controls-actions { justify-content: center; margin-left: 0; flex-wrap: wrap; }
  .ctl-btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .load-label { display: none; }
  .load-btn { padding: 12px 14px; }
}

/* Mode paysage : on garde le player compact */
@media (max-height: 520px) and (orientation: landscape) {
  .player-app { margin-top: 12px; }
  #search-input { padding: 8px 0; }
  .load-btn { padding: 10px 14px; }
  .rr-list { max-height: 45vh; }
}

/* Tablette / mobile : tout en une colonne (recherche, player, résultats) */
@media (max-width: 900px) {
  .player-app,
  .player-app.has-player { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .player-app.has-player .player-wrap { position: static; grid-column: 1; grid-row: auto; }
  .player-app.has-player .results-panel { grid-column: 1; grid-row: auto; }
  .player-app.has-player .rr-list { max-height: none; overflow: visible; }
  .rr-thumb-wrap,
  .player-app:not(.has-player) .rr-thumb-wrap { width: 128px; max-width: 42%; }

  /* Page chaîne sur mobile : une colonne, items compacts (miniature à gauche) */
  .ch-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .ch-grid .rr-item {
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
    padding: 8px;
    background: transparent;
  }
  .ch-grid .rr-item:hover,
  .ch-grid .rr-item.is-active { background: #262630; }
  .ch-grid .rr-item:hover .rr-thumb { outline: none; }
  .channel-panel .ch-grid .rr-thumb-wrap { width: 128px; max-width: 42%; }
  .ch-head { padding: 10px 4px 12px; }
  .ch-avatar { width: 60px; height: 60px; }
}

/* ==================== Mobile — retour en haut ==================== */
@media (max-width: 640px) {
  .to-top { right: 14px; bottom: 14px; width: 44px; height: 44px; }
  .rr-skel-thumb { width: 128px; max-width: 42%; }
}

