:root {
  --bg: #0b0b0f;
  --panel: #14141b;
  --panel-2: #1c1c26;
  --line: #2a2a38;
  --text: #ececf1;
  --muted: #8b8b9e;
  --accent: #ffb547;
  --accent-ink: #1a1206;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); padding: 9px 14px;
  border-radius: 9px; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #3d3d52; background: #23232f; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=password], input[type=search], select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }

.brand { font-weight: 800; letter-spacing: -.02em; font-size: 18px; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }

/* ---------- Accueil ---------- */
.home { max-width: 880px; margin: 0 auto; padding: 32px 20px 60px; }
.home header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.hero h1 { font-size: 34px; letter-spacing: -.03em; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 0 26px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.files { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; }
.file { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.file:last-child { border-bottom: 0; }
.file:hover { background: var(--panel-2); }
.file.sel { background: rgba(255,181,71,.12); box-shadow: inset 3px 0 0 var(--accent); }
.file .p { word-break: break-all; }
.file .dir { color: var(--muted); }
.file .sz { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.profile { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--panel-2); }
.profile.sel { border-color: var(--accent); background: rgba(255,181,71,.08); }
.profile b { display: block; margin-bottom: 4px; }
.profile small { color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- Salle ---------- */
.room { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.topbar .title b { color: var(--text); }
.layout { display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.stage { position: relative; background: #000; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage.idle { cursor: none; }
video::cue { background: rgba(0,0,0,.72); color: #fff; font-size: 1.15em; line-height: 1.3; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(0,0,0,.6); text-align: center; padding: 20px; z-index: 5; }
.overlay .big { font-size: 18px; font-weight: 600; }
.bar { width: min(380px, 80%); height: 6px; background: #ffffff22; border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.spinner { width: 46px; height: 46px; border: 4px solid #ffffff22; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 16px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); transition: opacity .25s; z-index: 4;
}
.stage.idle .controls { opacity: 0; pointer-events: none; }
.seek { position: relative; height: 16px; cursor: pointer; display: flex; align-items: center; }
.seek .track { position: absolute; left: 0; right: 0; height: 5px; background: #ffffff26; border-radius: 99px; overflow: hidden; }
.seek .avail { position: absolute; left: 0; top: 0; bottom: 0; background: #ffffff22; }
.seek .buf { position: absolute; left: 0; top: 0; bottom: 0; background: #ffffff44; }
.seek .prog { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.seek .knob { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); box-shadow: 0 0 0 4px #ffb54733; }
.seek .hover-t { position: absolute; bottom: 20px; transform: translateX(-50%); background: #000c; padding: 2px 6px; border-radius: 5px; font-size: 12px; pointer-events: none; font-variant-numeric: tabular-nums; }
.seek.locked { cursor: not-allowed; }
.ctl-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ic { background: none; border: 0; width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.ic:hover { background: #ffffff1a; }
.ic:disabled { opacity: .4; cursor: not-allowed; }
.time { font-variant-numeric: tabular-nums; color: #ddd; font-size: 13px; }
.spacer { flex: 1; }
.vol { width: 90px; accent-color: var(--accent); }

.reactions { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.reaction { position: absolute; bottom: 70px; font-size: 34px; animation: floatUp 2.6s ease-out forwards; }
.reaction small { display: block; font-size: 11px; text-align: center; color: #fff; text-shadow: 0 1px 2px #000; }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-260px); opacity: 0; } }

.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.members { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow: auto; }
.members li { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ready { background: var(--ok); }
.dot.buffering { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.members .you { color: var(--muted); font-size: 12px; }
.host-tools { display: flex; flex-direction: column; gap: 8px; }
.host-tools label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 !important; border-bottom: 0 !important; }
.chat h3 { padding: 14px 16px 0; }
.msgs { flex: 1; overflow: auto; padding: 4px 16px 10px; display: flex; flex-direction: column; gap: 6px; }
.msg { word-wrap: break-word; }
.msg b { color: var(--accent); margin-right: 6px; }
.msg.sys { color: var(--muted); font-size: 12.5px; font-style: italic; }
.chat form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.emojis { display: flex; gap: 2px; padding: 6px 10px 0; }
.emojis button { background: none; border: 0; font-size: 18px; padding: 4px 6px; border-radius: 6px; }
.emojis button:hover { background: var(--panel-2); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal .card { width: min(560px, 100%); max-height: 90vh; overflow: auto; margin: 0; }
.modal .card.wide { width: min(760px, 100%); }
.modal h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 20px; }

.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px #0008; }

.stage:fullscreen .controls { padding-bottom: 20px; }

@media (max-width: 900px) {
  .room { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 16/9; }
  .side { border-left: 0; border-top: 1px solid var(--line); min-height: 420px; }
  .vol { display: none; }
}

/* ---------- Icônes Lucide ---------- */
svg.lucide { flex: none; display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.brand svg.lucide { color: var(--accent); width: 22px; height: 22px; }
.ic svg.lucide { width: 20px; height: 20px; }
#playBtn svg.lucide { fill: currentColor; }
.h-ic { display: inline-flex; align-items: center; gap: 6px; }
.h-ic svg.lucide { width: 14px; height: 14px; }
.crown { color: var(--accent); display: inline-flex; }
.toast { display: flex; align-items: center; gap: 8px; }
.toast svg.lucide { color: var(--accent); }

/* ---------- Lecteur : panneau audio / sous-titres ---------- */
.ic.on { background: #ffffff1f; }
.ic.cc { position: relative; }
.ic.cc::after {
  content: ''; position: absolute; left: 9px; right: 9px; bottom: 4px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .2s;
}
.ic.cc.on::after { transform: scaleX(1); }

.menu-anchor { position: relative; }
.pop {
  position: absolute; right: 0; bottom: calc(100% + 12px); z-index: 20;
  min-width: 460px; max-width: min(560px, 92vw);
  background: rgba(18, 18, 26, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid #ffffff1c; border-radius: 14px; box-shadow: 0 18px 50px #000a;
  overflow: hidden; transform-origin: bottom right; animation: popIn .16s ease-out;
}
.pop.single { min-width: 280px; }
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.pop-cols { display: flex; }
.pop-col { flex: 1 1 0; }
.pop-col { padding: 10px 6px; min-width: 0; }
.pop-col + .pop-col { border-left: 1px solid #ffffff14; }
.pop-h {
  display: flex; align-items: center; gap: 7px; padding: 4px 12px 10px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.pop-list { display: flex; flex-direction: column; gap: 2px; max-height: min(320px, 45vh); overflow-y: auto; }
.pop-item {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px 8px 6px; color: var(--text);
  transition: background .12s;
}
.pop-item:hover:not(:disabled) { background: #ffffff12; }
.pop-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pop-item:disabled { opacity: .4; cursor: not-allowed; }
.pop-item .chk { width: 18px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); flex: none; }
.pop-item .pi-text { display: flex; flex-direction: column; min-width: 0; }
.pop-item .pi-label { font-weight: 500; }
.pop-item.sel .pi-label { color: var(--accent); }
.pop-item .pi-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-top: 1px solid #ffffff14; color: var(--muted); font-size: 13px;
}
.seg { display: inline-flex; background: #ffffff10; border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; border-radius: 6px; width: 34px; height: 28px; color: var(--muted); font-weight: 600; line-height: 1; }
.seg button[data-v="s"] { font-size: 11px; }
.seg button[data-v="m"] { font-size: 14px; }
.seg button[data-v="l"] { font-size: 18px; }
.seg button:hover { color: var(--text); }
.seg button.sel { background: var(--accent); color: var(--accent-ink); }

/* Taille des sous-titres */
.stage.subs-s video::cue { font-size: .8em; }
.stage.subs-m video::cue { font-size: 1.1em; }
.stage.subs-l video::cue { font-size: 1.4em; }
/* Sous-titres remontés quand les contrôles sont visibles (Chrome / Edge) */
video::-webkit-media-text-track-container { transition: transform .25s ease; }
.stage:not(.idle) video::-webkit-media-text-track-container { transform: translateY(-64px); }

/* Barre de progression plus confortable */
.seek .track { transition: height .15s; }
.seek:hover .track { height: 8px; }
.seek .knob { transform: translateX(-50%) scale(.7); transition: transform .15s; }
.seek:hover .knob { transform: translateX(-50%) scale(1); }

/* Retour visuel play / pause / avance */
.flash {
  position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; z-index: 3;
  border-radius: 50%; background: #000a; color: #fff; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
}
.flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: .95; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.35); } }

@media (max-width: 900px) {
  .pop { min-width: 0; width: min(92vw, 420px); }
  .pop-cols { flex-direction: column; }
  .pop-col + .pop-col { border-left: 0; border-top: 1px solid #ffffff14; }
}
