:root {
  --bg: #0f1115; --panel: #161920; --panel-2: #1d212a; --line: #262b36;
  --text: #e9ecf2; --muted: #8b93a5; --accent: #ff7a59; --accent-2: #c2410c;
  --radius: 12px; --player-h: 92px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
.hidden { display: none !important; }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 24px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.login-card button { width: 100%; padding: 12px; border-radius: 10px; background: var(--accent); color: #111; font-weight: 600; }
.error { color: #ff6b6b; min-height: 1.2em; margin: 0; font-size: 14px; }

/* Mise en page */
.app { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: 1fr var(--player-h); height: 100dvh; }
.sidebar { grid-row: 1; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; font-weight: 700; font-size: 17px; }
nav { flex: 1; overflow: auto; padding: 4px 10px; }
.nav-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 16px 10px 6px; }
.nav-item { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 9px 10px;
  border-radius: 8px; color: var(--muted); overflow: hidden; }
.nav-item span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.count { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.ghost { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.ghost:hover { color: var(--text); border-color: var(--muted); }

.main { grid-row: 1; overflow: auto; padding: 0 24px 24px; min-width: 0; }
.toolbar { position: sticky; top: 0; z-index: 2; display: flex; gap: 12px; align-items: center; padding: 16px 0;
  background: linear-gradient(var(--bg) 75%, transparent); }
#search { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--panel-2); color: var(--text); }

/* Scène « en cours » */
.stage { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: end; padding: 8px 0 24px; }
.stage-art { position: relative; width: 200px; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, #2a2f3b, #161920); }
.stage-art img { width: 100%; height: 100%; object-fit: cover; }
#viz { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.video { grid-template-columns: 1fr; }
.stage.video .stage-art { display: none; }
#media { display: none; width: 100%; max-height: 60vh; background: #000; border-radius: var(--radius); }
.stage.video #media { display: block; }
.stage-title { font-size: clamp(22px, 4vw, 38px); font-weight: 800; line-height: 1.1; word-break: break-word; }
.stage-sub { color: var(--muted); margin-top: 6px; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 8px; }
.list-head h2 { margin: 0; font-size: 18px; }
.pill { padding: 8px 16px; border-radius: 999px; background: var(--accent); color: #111; font-weight: 600; font-size: 14px; }

.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: grid; grid-template-columns: 36px 1fr auto auto; gap: 12px; align-items: center; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; }
.track:hover { background: var(--panel); }
.track.playing { background: var(--panel-2); }
.track.playing .t-title { color: var(--accent); }
.t-num { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.t-main { min-width: 0; }
.t-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-folder { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; text-transform: uppercase; }
.t-dur { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; min-width: 40px; text-align: right; }
.empty { color: var(--muted); padding: 24px 10px; }

/* Barre de lecture */
.player { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 16px; align-items: center;
  padding: 0 20px; background: var(--panel); border-top: 1px solid var(--line); }
.now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now-cover { width: 56px; height: 56px; border-radius: 8px; background: var(--panel-2) center/cover; flex-shrink: 0; }
.now-text { min-width: 0; }
.now-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.buttons { display: flex; align-items: center; gap: 14px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted);
  font-size: 18px; text-decoration: none; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn.on { color: var(--accent); }
.play-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: #111; font-size: 18px; }
.play-btn:hover { transform: scale(1.05); }
.seek { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.seek input { flex: 1; }
.extras { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
#volume { width: 110px; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--line); accent-color: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
input[type=range]::-moz-range-progress { background: var(--accent); height: 4px; border-radius: 4px; }

.mobile-only { display: none; }

/* Rôles & gestion */
.login-hint { color: var(--muted); margin: -8px 0 0; font-size: 14px; text-align: center; }
.link { color: var(--muted) !important; background: none !important; font-weight: 400 !important; font-size: 14px; }
.link:hover { color: var(--text) !important; }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: rgba(255,122,89,.15); color: var(--accent); align-self: center; }
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; margin-bottom: 10px;
  border: 1px dashed var(--line); border-radius: var(--radius); }
.folder-actions { display: contents; }
.hint { color: var(--muted); font-size: 13px; }
.ghost.danger:hover { color: #ff6b6b; border-color: #ff6b6b; }
.uploads { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.uploads li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 12px; background: var(--panel); border-radius: 8px; font-size: 13px; }
.uploads .bar { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.uploads .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uploads .err { color: #ff6b6b; }
.track { grid-template-columns: 36px 1fr auto auto auto; }
.t-act { display: flex; gap: 2px; }
.t-act button { width: 30px; height: 30px; border-radius: 6px; color: var(--muted); }
.t-act button:hover { background: var(--panel-2); color: var(--text); }
.t-act button.del:hover { color: #ff6b6b; }
.dropzone { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(15,17,21,.85);
  border: 3px dashed var(--accent); font-size: 22px; font-weight: 700; text-align: center; pointer-events: none; }
.dropzone small { font-size: 14px; color: var(--muted); font-weight: 400; }
.toast { position: fixed; left: 50%; bottom: calc(var(--player-h) + 16px); transform: translateX(-50%); z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); }
.toast.err { border-color: #ff6b6b; color: #ffb3b3; }

@media (max-width: 820px) {
  :root { --player-h: 144px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto var(--player-h) 0; width: 260px; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .mobile-only { display: inline-grid; }
  .main { padding: 0 16px 16px; }
  .seg button { padding: 6px 9px; }
  .stage { grid-template-columns: 110px 1fr; gap: 16px; }
  .stage-art { width: 110px; }
  .player { grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); gap: 8px 12px; }
  .controls { grid-column: 1 / -1; grid-row: 2; }
  .extras #volume, .extras #mute { display: none; }
  .track { grid-template-columns: 28px 1fr auto auto; }
  .hint { display: none; }
  .t-badge { display: none; }
}
