:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --line: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --accent: #9147ff;
  --focus: #ffd166;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, sans-serif;
  overflow: hidden;
}
#app { display: flex; height: 100%; }

/* --- panneau latéral --- */
#sidebar {
  display: flex;
  flex-direction: column;
  flex: 0 0 320px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
#app.hidden-side #sidebar { display: none; }
#sidebar header, #sidebar footer { padding: 12px; border-color: var(--line); }
#sidebar header { border-bottom: 1px solid var(--line); }
#sidebar footer { border-top: 1px solid var(--line); display: grid; gap: 8px; }
h1 { font-size: 20px; margin: 0 0 10px; display: flex; justify-content: space-between; gap: 8px; }
#total { color: var(--accent); font-weight: 400; }
#list { flex: 1; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
#list li { border-bottom: 1px solid var(--line); }
#list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
#list input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
#list img { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; }
#list .who { flex: 1; min-width: 0; display: grid; gap: 2px; }
#list .who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
#list .game { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .don {
  flex: 0 0 auto;
  color: #00d68f;
  border: 1px solid #00d68f55;
  border-radius: 3px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
#list .v { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
#list li:not(.off) .v { color: #ff5c5c; }
.sortline { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--muted); }
#sort, #quality { flex: 1; padding: 6px; background: #0e0e10; color: var(--text); border: 1px solid var(--line); border-radius: 4px; font: inherit; }
#list li.off { opacity: 0.45; }
#list li.fav { background: #1f1b2b; }
.star {
  flex: 0 0 auto;
  padding: 4px 8px;
  background: none;
  border: 0;
  color: #4b4b52;
  font-size: 20px;
  line-height: 1;
}
.star.on { color: var(--focus); }

/* --- grille --- */
#grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 4px;
  padding: 4px;
  grid-auto-rows: 1fr;
  min-width: 0;
}
#grid:empty::after {
  content: "Coche des streamers dans le panneau de gauche.";
  color: var(--muted);
  place-self: center;
}
/* Barre SOUS la vidéo, jamais par-dessus : Twitch refuse l'autoplay d'un player
   recouvert, même par un élément transparent. */
.tile { display: flex; flex-direction: column; background: #000; min-width: 0; min-height: 0; }
.tile.focused { grid-column: 1 / -1; grid-row: 1; }
.video { position: relative; flex: 1; min-height: 0; }
.player, .player iframe { width: 100%; height: 100%; border: 0; display: block; }
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel);
}
.tile.focused .bar .focus { color: var(--focus); }
.bar .focus {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.bar input[type=range] { width: 110px; accent-color: var(--accent); }
button { font: inherit; color: var(--text); background: #303038; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; cursor: pointer; }
/* Bandeau au-dessus de la grille : rien ne doit recouvrir les players (exigence Twitch). */
#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#controls {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#app.show-chat #chatToggle { color: var(--focus); }

/* --- chat de la chaîne en avant --- */
#chat { flex: 0 0 360px; display: none; border-left: 1px solid var(--line); background: var(--panel); }
#app.show-chat #chat { display: block; }
#chat iframe {
  width: 100%;
  height: 100%;
  border: 0;
  /* Le chat Twitch est illisible à 3 m : on grossit tout l'iframe, on ne peut pas le styler (cross-origin). */
  zoom: 1.25;
}
input[type=search] { width: 100%; padding: 8px; background: #0e0e10; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }

/* --- télé : le focus doit être évident à 3 m --- */
:focus-visible, [data-nav]:focus { outline: 4px solid var(--focus); outline-offset: 2px; }
#list label:focus-within { background: #26262c; }
