:root {
  --bg: #121418;
  --panel: #1a1d23;
  --panel-2: #22262e;
  --line: #2e333d;
  --text: #e3e6eb;
  --muted: #8a919e;
  --accent: #7c8cff;
  --accent-soft: #2c3363;
  --select: #2b3a63;
  --danger: #e26d6d;
  --ok: #4fc38a;
  --warn: #e3b341;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover { filter: brightness(1.2); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; border-color: var(--line); }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
button.on { background: var(--accent); color: #0d0f14; }
input[type=text], input[type=search], input:not([type]), select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
input[type=range] { accent-color: var(--accent); }
.muted { color: var(--muted); }
h2, h3 { margin: 0; font-size: 15px; }
h3 { font-size: 13px; }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 600; }
.status { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.dot.ready { background: var(--warn); }
.dot.connected { background: var(--ok); }
.dot.playing { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.voice { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.invite { color: var(--accent); }

/* Colonnes */
.columns {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(190px, 270px) minmax(0, 1fr) minmax(300px, 420px); gap: 1px;
  background: var(--line);
}
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; outline: none; }
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.panel-head input[type=search] { flex: 1; min-width: 160px; }
.panel-body { flex: 1; overflow-y: auto; padding: 6px 0; }
.panel-foot {
  display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line);
}
.panel-foot .muted { margin-right: auto; }

/* Arbre des listes */
.tree-list { user-select: none; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 3px 12px; cursor: pointer; }
.tree-row:hover { background: var(--panel-2); }
.tree-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .exp { width: 14px; color: var(--muted); font-family: monospace; }
.tree-row.sub { padding-left: 34px; }
.tree-row.sub .name.untagged { font-style: italic; color: var(--muted); }
.tree-row .count { color: var(--muted); font-size: 12px; }
/* Cercle vide = désactivé, plein = activé, à moitié plein = en partie */
.toggle, .row .circle {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--muted); background: transparent;
  cursor: pointer; justify-self: center;
}
.toggle.on { border-color: var(--accent); background: var(--accent); }
.toggle.part { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }

/* Lignes de morceaux */
.selectable { user-select: none; }
.group-head {
  padding: 8px 12px 2px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.row {
  display: grid; align-items: center; gap: 10px;
  padding: 3px 12px; cursor: default; border-left: 3px solid transparent;
}
#library .row { grid-template-columns: 20px minmax(120px, 1fr) minmax(120px, 1.4fr) 64px 22px; }
.pl-list .row { grid-template-columns: 14px 20px 1fr 60px 20px; }
.row:hover { background: var(--panel-2); }
.row.sel { background: var(--select); }
.row.current { border-left-color: var(--accent); }
.row .circle:hover, .toggle:hover { border-color: var(--text); }
.row.sel .circle { border-color: var(--accent); background: var(--accent); }
.row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t.fallback { color: var(--muted); font-style: italic; }
.row .off { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.row .d { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.row a { color: var(--muted); text-decoration: none; }
.row a:hover { color: var(--accent); }
.row .x { background: none; border: none; color: var(--muted); padding: 0; }
.row .x:hover { color: var(--danger); }
.row .playing-mark { color: var(--accent); }
.dead { color: var(--warn); }
.empty { padding: 20px 14px; color: var(--muted); }

/* Lecteur */
.player { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.now { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#now-title { font-weight: 600; }
.progress { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; color: var(--muted); }
.progress input { flex: 1; }
.controls { display: flex; align-items: center; gap: 6px; }
.controls button { min-width: 38px; }
.controls .big { font-size: 18px; padding: 2px 14px; }
.vol { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.vol input { width: 110px; }
.loop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls { flex-wrap: wrap; }
.switch-btns { flex-wrap: wrap; }
.seg { display: flex; }
.seg button { border-radius: 0; border-color: var(--line); background: transparent; font-size: 12px; padding: 3px 8px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--accent); color: #0d0f14; border-color: var(--accent); }

/* Blocs de playlist */
.pl-block { display: flex; flex-direction: column; min-height: 0; }
#block-active { flex: 3; border-bottom: 1px solid var(--line); }
#block-standby { flex: 2; }
.pl-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; flex-wrap: wrap; }
.pl-head h3 { margin-right: auto; }
.pl-list { flex: 1; overflow-y: auto; min-height: 60px; outline: none; padding-bottom: 20px; }
.pl-list.drop-end { box-shadow: inset 0 -3px 0 var(--accent); }
.row.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.switch { padding: 8px 12px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.switch-btns { display: flex; gap: 6px; }
.switch-btns button { flex: 1; }
.switch label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.switch label input { flex: 1; }

/* Fenêtres par-dessus */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  width: min(1100px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin-right: auto; }
.modal-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 140px; }
.form-row .label { width: 190px; color: var(--muted); }
table.manage { width: 100%; border-collapse: collapse; }
table.manage th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px; }
table.manage td { padding: 3px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
table.manage td input { width: 100%; }
table.manage .off { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.manage .actions { white-space: nowrap; }
table.manage .actions button { padding: 2px 6px; }
.picker { background: var(--panel-2); }
.picker td { padding: 8px; }

/* Messages */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }
.toast.error { border-color: var(--danger); }

/* Onglets des listes (Gérer les morceaux) */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.tab { background: transparent; border-color: var(--line); }
.tab.on { background: var(--accent); color: #0d0f14; border-color: var(--accent); }

.tree-row.add .name { color: var(--accent); }
.row .local { color: var(--muted); cursor: help; }

/* Réglages et assistant */
.modal-body h3 { font-size: 14px; margin-top: 4px; }
.modal-body ol { margin: 6px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.modal-body p { margin: 4px 0; }
.step { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.step.done { border-color: var(--ok); }
.stack { display: flex; flex-direction: column; gap: 6px; }
.ok { color: var(--ok); }
.error { color: var(--danger); }
.small { font-size: 12px; }

/* Bouton « œil » des mots de passe */
.pw-wrap { position: relative; display: flex; flex: 1; min-width: 140px; }
.pw-wrap input { flex: 1; min-width: 0; padding-right: 34px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 3px; color: var(--muted); line-height: 0;
}
.pw-eye:hover { color: var(--text); filter: none; }

/* Comptes : fonctions réservées à l'admin, mot de passe temporaire */
body:not(.is-admin) .admin-only { display: none !important; }
.temp-pw { border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.pw-code { font-family: Consolas, monospace; font-size: 18px; letter-spacing: .08em; background: var(--panel-2); padding: 4px 10px; border-radius: 6px; user-select: all; }

/* Accueil du compte admin (pas d'espace de musique) */
#admin-home { display: none; flex: 1; align-items: center; justify-content: center; padding: 16px; }
body.is-admin #admin-home { display: flex; }
body.is-admin main.columns { display: none; }
.admin-card {
  width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
}
.admin-card h2 { font-size: 18px; }
.admin-card p { margin: 0; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--accent); color: var(--accent); white-space: nowrap; }

/* Repère doré du compte admin */
:root { --gold: #e3b341; }
#user-name.admin { border-color: var(--gold); color: var(--gold); }
.admin-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px;
  background: var(--gold); color: #1a1405; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  vertical-align: middle;
}
table.manage tr.admin-row td { background: rgba(227, 179, 65, .08); }
table.manage tr.admin-row td:first-child { box-shadow: inset 3px 0 0 var(--gold); }

/* Compte désactivé : nom grisé */
table.manage tr.disabled-row td:first-child { color: var(--muted); opacity: .6; }

/* Espaces partagés : membres et droits */
.member { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.rights-group { display: flex; flex-direction: column; gap: 3px; }
.rights-title { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.right { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.right input { accent-color: var(--accent); }
#space-select { border-color: var(--accent); }
body.guest-space .topbar { box-shadow: inset 0 -2px 0 var(--accent); }
[data-right]:disabled { opacity: .35; cursor: not-allowed; }
