:root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-2: #1c2430;
    --line: #2b3441;
    --text: #e6edf3;
    --muted: #8b98a8;
    --accent: #3b82f6;
    --live: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
}

* { box-sizing: border-box; }

/*
   `[hidden]` ne vient que de la feuille de style du navigateur : n'importe
   quelle règle d'auteur portant un `display` la neutralise, quelle que soit sa
   spécificité. Sans ce rappel, `#app { display: flex }` et `.login
   { display: grid }` rendaient l'attribut `hidden` sans effet — l'écran de
   connexion restait affiché par-dessus le panel après un login réussi.
*/
[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button {
    font: inherit;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    padding: 6px 12px;
}
button:hover { border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { border-color: #532; color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button:disabled { opacity: .4; cursor: not-allowed; }

input[type="text"], input[type="password"], input[type="search"] {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
}
input:focus { outline: none; border-color: var(--accent); }

.muted { color: var(--muted); }
.error { color: var(--danger); }
.spacer { flex: 1; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ── Connexion ───────────────────────────────────────────────────────────── */

.login {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 30%, #182029, var(--bg) 70%);
}
.login-card {
    width: min(360px, 90vw);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }
.login-card button { background: var(--accent); border-color: var(--accent); padding: 9px; }

/* ── Structure ───────────────────────────────────────────────────────────── */

#app { height: 100%; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--live); }
.status.ko { color: var(--danger); }
.reason { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.reason input { width: 280px; }

main { flex: 1; display: flex; min-height: 0; }

.sidebar {
    width: 280px;
    flex: none;
    border-right: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.players { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.players li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.players li:hover { background: var(--panel-2); }
.players li .pid { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.players li .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players li .dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.players li.watched .dot { background: var(--live); }
.players li.watched { color: var(--live); }

.grid-wrap { flex: 1; overflow-y: auto; padding: 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.empty { color: var(--muted); text-align: center; margin-top: 15vh; }
.empty p { margin: 4px 0; }

/* ── Vignettes ───────────────────────────────────────────────────────────── */

.tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tile header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}
.tile header button { padding: 3px 9px; font-size: 13px; }
.tile-title { font-weight: 600; }
.tile-state { font-size: 12px; color: var(--muted); }
.tile-state.live { color: var(--live); }
.tile-state.paused { color: var(--warn); }
.tile-state.ended { color: var(--danger); }

.tile-body { position: relative; background: #000; aspect-ratio: 16 / 9; }
.tile-body video, .tile-body img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    background: #000;
}
.tile-body video.active, .tile-body img.active { display: block; }
.tile-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 13px;
    background: rgba(0, 0, 0, .45);
    text-align: center;
    padding: 12px;
}

.tile-meta {
    padding: 7px 10px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
