:root {
  --bg: #0e0f13;
  --panel: #171920;
  --panel-2: #1f222b;
  --line: #2a2e39;
  --text: #e8e9ee;
  --muted: #8b90a0;
  --accent: #ff5c7a;
  --accent-2: #ffb347;
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

input, select, button { font: inherit; color: inherit; }
input:not([type=range]), select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:not([type=range]):focus { border-color: var(--accent); }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter .15s, transform .05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff7d5c); border-color: transparent; color: #fff; font-weight: 600; }
.btn.accent { background: #262a35; border-color: #3a3f4d; }
.btn.big { padding: 13px 20px; font-size: 16px; width: 100%; }

/* ---------- Главная ---------- */
.home { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 500px at 50% -10%, #2a1520 0%, transparent 60%), var(--bg); }
.home-card, .modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.logo { font-size: 52px; line-height: 1; }
h1, h2 { margin: 0; }
.home-card p { margin: 0 0 6px; }
.or { color: var(--muted); font-size: 13px; }

/* ---------- Модалка ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,6,9,.75); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-card p { margin: 0; }

/* ---------- Комната ---------- */
.room { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; white-space: nowrap; }
.load { flex: 1; display: flex; gap: 8px; min-width: 0; }
.load input { flex: 1; min-width: 0; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 320px; gap: 16px; padding: 16px; }
.player-col { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.nowplaying { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 20px; }
.nowplaying b { color: var(--text); font-weight: 600; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 140px);
  background: #000;
  border-radius: var(--r);
  overflow: hidden;
  user-select: none;
}
.stage:fullscreen { border-radius: 0; max-height: none; aspect-ratio: auto; }
.media-wrap, .media-wrap > *, .media-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-wrap video { object-fit: contain; background: #000; }
.placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 20px; }
.ph-icon { font-size: 46px; }
.click-layer { position: absolute; inset: 0; cursor: pointer; }
.stage.empty .click-layer { display: none; }

.notice {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(20,22,28,.92); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 22px; text-align: center; max-width: 90%; z-index: 5;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.toast {
  position: absolute; top: 14px; left: 50%; transform: translate(-50%, -8px);
  background: rgba(0,0,0,.72); padding: 7px 14px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 6; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Панель управления */
.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 14px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  transition: opacity .25s;
  z-index: 4;
}
.stage.empty .controls { display: none; }
.stage.idle:not(.paused) .controls { opacity: 0; }
.stage.idle:not(.paused) { cursor: none; }
.ctrl-row { display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.time { font-variant-numeric: tabular-nums; font-size: 14px; margin-left: 6px; white-space: nowrap; }
.icon {
  background: none; border: 0; width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: #fff; padding: 0;
}
.icon:hover { background: rgba(255,255,255,.12); }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
.controls select { padding: 5px 6px; background: rgba(255,255,255,.08); border-color: transparent; font-size: 13px; }

.seek-wrap { position: relative; margin-bottom: 4px; }
.seek-tip { position: absolute; bottom: 18px; transform: translateX(-50%); background: #000; padding: 2px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; height: 16px; margin: 0; }
#seek { width: 100%; }
#volume { width: 90px; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--p, 0%), rgba(255,255,255,.25) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--p, 0%), rgba(255,255,255,.25) var(--p, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; border: 0; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }

/* Мини-чат поверх видео */
.mini-chat {
  position: absolute; left: 14px; bottom: 86px; width: min(400px, 62%);
  z-index: 5; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.mini-msgs { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.mini-msg {
  background: rgba(0,0,0,.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 5px 11px; border-radius: 12px; font-size: 14px; max-width: 100%;
  overflow-wrap: anywhere; transition: opacity .6s; animation: pop .2s ease-out;
}
.mini-msg b { margin-right: 6px; }
.mini-msg.sys { color: #c7cad4; font-style: italic; font-size: 13px; }
.mini-msg.old { opacity: 0; }
.stage.mini-open .mini-msg.old { opacity: .9; }
.mini-form { pointer-events: auto; }
.mini-form input { width: 100%; background: rgba(0,0,0,.75); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 9px 12px; }
.stage:fullscreen .mini-chat { bottom: 96px; }
.stage:fullscreen .mini-msg { font-size: 17px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* Сайдбар */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.net { font-weight: 500; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.net.ok { color: var(--ok); } .net.warn { color: var(--warn); } .net.bad { color: var(--bad); }
.users { list-style: none; margin: 0; padding: 8px; max-height: 180px; overflow: auto; }
.users li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.users .me { color: var(--muted); font-size: 12px; }

.chat-panel { flex: 1; }
.chat { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.chat .msg { word-wrap: break-word; }
.chat .msg b { margin-right: 6px; }
.chat .sys { color: var(--muted); font-size: 13px; font-style: italic; }
.chat-panel form { padding: 10px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; overflow: auto; padding: 10px; }
  .chat-panel { min-height: 320px; }
  .brand span { display: none; }
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .load { order: 3; flex-basis: 100%; }
  #invite { margin-left: auto; }
  #volume { display: none; }
}
