:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1b19;
  --muted: #6c6862;
  --line: #e2ded7;
  --accent: #e0592a;
  --accent-ink: #ffffff;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --bad: #c0392b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --panel: #1e1c1a;
    --ink: #eeebe6;
    --muted: #9b968e;
    --line: #34312d;
    --accent: #ff7a45;
    --accent-ink: #1a0d06;
    --ok: #4fc183;
    --warn: #e0a64a;
    --bad: #ef6f5f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password] {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
input[type=range] { accent-color: var(--accent); width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }

/* ----- connexion ----- */
#login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}
#login .card { width: 100%; max-width: 360px; }
#login p { margin: 6px 0 4px; }
#login button { width: 100%; margin-top: 16px; }

/* ----- salle : la 3D occupe tout l'écran, l'interface flotte dans les coins ----- */
#room { height: 100%; }
#stage { position: relative; height: 100%; overflow: hidden; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
input[type=file] { display: none; }
details.note summary { cursor: pointer; color: var(--accent); }
details.note ol { padding-left: 20px; margin: 8px 0; }
/* icônes Lucide (icons.js) : au trait, de la couleur du texte */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; stroke-width: 2; }
[data-icon] { display: inline-flex; }
button:has(> [data-icon]) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.icon-btn { padding: 7px 9px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* messages brefs, en haut au centre : problème de connexion, « X a pris la main »… */
.alert, #banner {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; white-space: nowrap;
}
.alert { top: 12px; border-color: var(--warn); }
#banner { top: 52px; }

/* ----- coins et panneaux repliables (panels.js) ----- */
.corner { position: absolute; display: flex; gap: 8px; align-items: flex-start; max-width: calc(100% - 24px); pointer-events: none; }
.corner > * { pointer-events: auto; }
.corner.top-left { top: 12px; left: 12px; max-width: min(380px, calc(50% - 24px)); flex-direction: column; }
.corner.top-right { top: 12px; right: 12px; }
.corner.bottom-left { bottom: 12px; left: 12px; align-items: flex-end; flex-wrap: wrap-reverse; max-width: calc(100% - 90px); } /* commandes du club */
.corner.bottom-right { bottom: 12px; right: 12px; align-items: flex-end; }

.pod {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); font-size: 13px;
}
.bottom-left .pod, .bottom-right .pod { flex-direction: column-reverse; } /* s'ouvrent vers le haut */
.pod-head {
  display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  border: 0; background: none; border-radius: 18px; padding: 6px 12px; font-size: 13px;
}
.pod .pod-head { justify-content: flex-start; }
.pod-head:hover { background: var(--bg); }
.pod.open .pod-head { color: var(--accent); }
.pod-body { display: none; padding: 4px 12px 12px; }
.pod.open .pod-body { display: flex; flex-direction: column; gap: 8px; }
.pod-body .note { margin: 0; }
.key { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.pod.open .pod-head .key { display: none; }

.pod-body .row { gap: 4px; }
.pod-body .row button, .pod-body > button { padding: 4px 9px; font-size: 12px; }
.pod-body button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pod-body .swatch { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.pod-body .swatch.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--panel) inset; }
.pod-body .by { font-size: 11px; }
.pod-body .by:empty { display: none; }
#podMusic { max-width: 100%; }
#podMusic .pod-body { min-width: 240px; }
#hudVol { font-variant-numeric: tabular-nums; }
#podDance .pod-body { width: min(440px, calc(100vw - 24px)); }
#podLights .pod-body { width: min(300px, calc(100vw - 24px)); }
#podBox { max-width: 100%; }
#podBox .pod-body { width: min(320px, calc(100vw - 24px)); }
#podBox form input { flex: 1; min-width: 0; padding: 4px 8px; font-size: 13px; }
#podBox select { flex: 1; min-width: 0; padding: 4px 6px; font-size: 13px; }
#podBox .people:empty { display: none; }
.badge { font-size: 11px; font-weight: 600; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; }

/* ----- fenêtre « Écrans » : partages d'écran du box en grand (screen.js) ----- */
.screen-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.75);
  display: grid; place-items: center; padding: 16px;
}
.screen-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  width: min(1600px, 100%); height: 100%; display: flex; flex-direction: column; gap: 10px;
}
.screen-overlay:fullscreen { padding: 0; }
.screen-overlay:fullscreen .screen-panel { border-radius: 0; width: 100%; }
.screen-head { gap: 6px; }
.screen-head h2 { margin: 0 8px 0 0; }
.screen-tabs { flex: 1; gap: 4px; }
.screen-tabs button { padding: 4px 10px; font-size: 13px; }
.screen-tabs button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.screen-grid { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.screen-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.screen-grid[data-count="3"], .screen-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
.screen-grid[data-count="0"] { display: none; }
.screen-tile { position: relative; margin: 0; min-height: 0; background: #0b0d12; border-radius: 8px; overflow: hidden; cursor: zoom-in; }
.screen-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; }
.screen-tile.zoomed { cursor: grab; }
.screen-tile.zoomed:active { cursor: grabbing; }
.zoom-bar { gap: 4px; align-items: center; }
.zoom-bar .zoom-btn { padding: 3px 10px; font-size: 13px; }
.zoom-label { min-width: 46px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.screen-tile figcaption {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.6); color: #fff;
  padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.screen-grid[data-count="1"] .screen-tile:not(.zoomed) { cursor: zoom-out; }

.slider { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.slider input { flex: 1; min-width: 90px; }

/* micro : toujours visible, à côté des présents */
.mic {
  width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); color: var(--muted);
}
.mic.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mic.muted { border-color: var(--warn); color: var(--warn); } /* son coupé */

/* présents */
.people { list-style: none; margin: 0; padding: 0; min-width: 200px; max-height: 40vh; overflow: auto; }
.people li { display: flex; align-items: center; gap: 2px; padding: 3px 0; white-space: nowrap; }
.people .dot { background: var(--muted); }
.people li.dj .dot { background: var(--ok); }
.people li.speaking .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(79, 193, 131, 0.35); }

/* aide */
.help h2 { margin: 4px 0 0; }
.help ul { margin: 0; padding-left: 18px; width: min(340px, calc(100vw - 48px)); }
.help li { margin: 3px 0; }

/* indication au-dessus du personnage (« E : s'installer ») */
.hint {
  position: absolute; left: 50%; top: 64%; transform: translateX(-50%); /* sous le personnage */
  background: var(--panel); border: 1px solid var(--accent); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font-weight: 600; pointer-events: none; white-space: nowrap;
}
/* assis : l'indication reste affichée tout du long, elle descend en bas de l'écran et se fait discrète */
.hint.seated {
  top: auto; bottom: 60px; border-color: var(--line); color: var(--muted);
  font-weight: 500; font-size: 12px; padding: 4px 12px; opacity: 0.85;
}

@media (max-width: 640px) {
  .corner.bottom-left { max-width: calc(100% - 24px); }
}

/* ----- tableau blanc (éditeur) ----- */
.board-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6);
  display: grid; place-items: center; padding: 16px;
}
.board-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; width: min(1200px, 100%); max-height: 100%; overflow: auto;
}
.board-tools { gap: 6px; margin-bottom: 10px; }
.board-tools button { padding: 5px 10px; font-size: 13px; }
.board-tools button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.board-tools .swatch { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.board-tools .swatch.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--panel) inset; }
.board-wrap { position: relative; }
.board-canvas {
  display: block; width: 100%; aspect-ratio: 2048 / 922; touch-action: none;
  border-radius: 6px; border: 6px solid #9aa0aa; background: #fbfbf8;
}
.board-text {
  position: absolute; width: 260px !important; transform: translateY(-4px);
  background: #fff !important; font-weight: 600;
}

/* ----- panneau « Diffuser ma musique » (ouvert depuis le panneau Musique) ----- */
.dj-panel {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 20;
  width: min(480px, calc(100% - 32px)); max-height: calc(100% - 24px); overflow: auto;
}
.dj-panel .dj-head { justify-content: space-between; margin-bottom: 4px; }
.dj-panel .dj-head h2 { margin: 0; }
.dj-panel #transport { margin-top: 8px; }
.dj-playlist { list-style: none; padding: 0; margin: 12px 0 0; max-height: 200px; overflow: auto; }
.dj-playlist li { padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.dj-playlist li:hover { background: var(--bg); }
.dj-playlist li.current { color: var(--accent); font-weight: 600; }

/* ----- fenêtre « Mon personnage » (look-editor.js) ----- */
.look-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6);
  display: grid; place-items: center; padding: 16px;
}
.look-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  width: min(860px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 10px;
}
.look-head { justify-content: space-between; }
.look-head h2 { margin: 0; }
.look-body { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.look-left { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.look-preview {
  width: 300px; height: 400px; border-radius: 10px; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 50% 35%, #3a4152, #151821 75%);
}
.look-left .note { margin: 0; font-size: 12px; }
.look-rows { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
.look-row { display: flex; flex-direction: column; gap: 4px; }
.look-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.look-choices { gap: 4px; flex-wrap: wrap; }
.look-choices button { padding: 4px 9px; font-size: 12px; }
.look-choices button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.look-choices .swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.look-choices .swatch.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--panel) inset; }
.look-choices .swatch.origin { background: repeating-linear-gradient(45deg, var(--bg) 0 4px, var(--line) 4px 8px); }
.look-actions { gap: 8px; }
.look-actions .spacer { flex: 1; }

/* diagnostic (#stats) */
.stats { position: fixed; left: 50%; top: 4px; transform: translateX(-50%); z-index: 60; font: 12px/1.4 ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.7); color: #9fe870; padding: 2px 8px; border-radius: 6px; pointer-events: none; }
