/* owncord: dark-gray interface, white text.
   Layout: compact gate card; room as a header bar + a responsive grid of member
   tiles + a docked control bar; chat slides in as a side column (.wrap.chat-open).
   Look: neutral dark-gray panels, white text, ONE neutral accent (light gray, no colour),
   red only for "off / leave / danger". The colour theme from background.js is locked out
   on purpose (see "interface lock" at the end of this file). */
:root {
  --bg: #121212;
  --bg-1: #151515;
  --bg-2: #101010;
  --tint: #1c1c1c;
  --panel: #1b1b1b;
  --panel-2: #242424;
  --panel-3: #2e2e2e;
  --hover: #3a3a3a;
  --text: #ffffff;
  --muted: #b0b0b0;
  --line: #343434;
  --accent: #f2f2f2;
  --accent-ink: #111111;
  --accent-2: #bdbdbd;
  --danger: #ec6a5e;
  --idle: #8f8f8f;
  --radius: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--panel-3) transparent; scrollbar-width: thin; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(1100px 620px at 50% -8%, #1d1d1d, transparent 70%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

#bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; display: block; }

.wrap { position: relative; z-index: 1; width: 100%; max-width: 540px; padding: 24px; }
.stage { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; justify-content: center; }
.stage > #gate { flex: 1 1 100%; max-width: 480px; margin: 0 auto; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.logo.small { font-size: 19px; }
.tag { color: var(--muted); margin: 8px 0 22px; font-size: 13.5px; line-height: 1.5; }

#gate { display: flex; flex-direction: column; }
#gate-new { display: flex; flex-direction: column; }
.gate-hint { margin: 0 0 14px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.gate-hint b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.gate-link { display: block; width: 100%; margin: 10px 0 0; background: none; border: 0; color: var(--muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.gate-link:hover { color: var(--text); }
/* пароль в настройках: поля как у остальных строк настроек */
#settings-modal #set-pane-profile .pw-row > label { flex: 0 0 110px; width: 110px; }
#set-pane-profile .pw-row input[type="password"], #set-pane-profile .pw-row input[type="email"] { margin: 0; padding: 9px 10px; font-size: 13px; flex: 1; width: 0; min-width: 0; }
#pw-save, #email-save { align-self: flex-start; margin: 2px 0 10px; }
/* после обновления страницы мы сразу возвращаемся в комнату: экран входа при этом не мигает */
.rejoining #gate { visibility: hidden; }
.audio-resume { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.audio-resume[hidden] { display: none; }
.gate-me { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.gate-me .avatar { margin: 0; width: 52px; height: 52px; border-color: var(--panel-2); }
.gate-name { font-size: 17px; font-weight: 700; }
.gate-handle, .pc-handle { font-family: var(--mono); font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="email"], textarea {
  width: 100%; padding: 13px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 15px; font-family: inherit;
}
input[type="text"], input[type="password"], input[type="email"] { margin-bottom: 12px; }
/* Ползунки исключены: рамка вокруг всего 82×22 слайдера выглядит лишним прямоугольником,
   для клавиатуры остаётся кольцо вокруг ползунка (строка ниже). */
input:not([type="range"]):focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; }

button {
  padding: 12px 16px; border-radius: 11px; border: none;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--panel-3);
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
}
button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { width: 100%; background: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #ffffff; }
.ghost { background: transparent; border: 1px solid var(--line); }
.ghost:hover { background: var(--panel-2); }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.room-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
}
#status {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
#status.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
#status.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.head-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; padding: 0; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; color: var(--text);
}
.icon-btn:hover { background: var(--panel-3); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.unread { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #ffffff; box-shadow: 0 0 0 2px var(--panel); }

.peers {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px; margin-bottom: 18px; min-height: 60px;
}
.peer {
  --tone: #8c8c8c;
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px; padding: 0 10px 12px;
  background: var(--panel-2); border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--line)); border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s; cursor: pointer;
}
.peer:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--tone) 60%, var(--line)); box-shadow: 0 14px 34px -14px var(--tone); }
.peer.speaking {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), 0 0 22px -6px var(--accent);
}
.pbanner, .pe-banner, .pc-banner {
  background-color: var(--tone, #8c8c8c);
  background-image:
    radial-gradient(120% 160% at 0% 0%, rgba(255, 255, 255, 0.24), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 11px),
    linear-gradient(135deg, transparent 30%, rgba(0, 0, 0, 0.5));
  background-size: cover; background-position: center;
}
.pbanner { position: absolute; top: 0; left: 0; right: 0; height: 66px; z-index: 0; transition: filter 0.25s; }
.pbanner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--panel-2) 90%, transparent)); }
.pbanner::before {
  content: ""; position: absolute; inset: 0; z-index: 1; transform: translateX(-100%);
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
}
.peer:hover .pbanner::before { animation: sheen 0.9s ease-out; }
@keyframes sheen { to { transform: translateX(100%); } }
.peer.speaking .pbanner { filter: saturate(1.3) brightness(1.15); }
.peer > .avatar, .peer > .pname, .peer > .states, .peer > .meter { position: relative; z-index: 1; }
.states { display: inline-flex; gap: 4px; }
.deaf-state { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 22px; border-radius: 999px; color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }
.deaf-state svg { width: 14px; height: 14px; display: block; }
.net { position: absolute; top: 8px; left: 9px; z-index: 2; display: inline-flex; padding: 3px 5px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); }
.net svg { width: 16px; height: 12px; display: block; fill: currentColor; }
.net.good { color: var(--accent); }
.net.ok { color: var(--accent-2); }
.net.bad { color: var(--danger); }
.net.idle { color: var(--muted); }
.net.ok rect:nth-child(3), .net.bad rect:nth-child(n+2), .net.idle rect { opacity: 0.3; }
.peer.has-banner .pname { text-shadow: 0 1px 3px rgba(0,0,0,0.55); }

.avatar {
  position: relative; width: 52px; height: 52px; border-radius: 50%;
  flex: none; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: #fff; overflow: visible;
  background-size: cover; background-position: center;
  margin-top: 36px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.15s;
}
.peer.speaking .avatar { box-shadow: 0 0 0 2px var(--accent), 0 0 16px -2px var(--accent); animation: talk 1.3s ease-out infinite; }
@keyframes talk {
  0% { box-shadow: 0 0 0 2px var(--accent), 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  100% { box-shadow: 0 0 0 2px var(--accent), 0 0 0 13px transparent; }
}
.avatar .initial { pointer-events: none; }
.avatar .status-dot {
  position: absolute; right: 0; bottom: 0;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2.5px solid var(--panel-2); background: var(--muted);
}
.status-dot.online { background: var(--accent); }
.status-dot.idle { background: var(--idle); }
.status-dot.dnd { background: var(--danger); }

.pname { font-size: 14px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer.owner .pname::before, .pc-name.owner::before, .person-name.owner::before {
  content: ""; display: inline-block; width: 14px; height: 12px; margin-right: 5px; vertical-align: -1px;
  background: var(--accent-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M2 6l5 4 5-8 5 8 5-4-2 12H4z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M2 6l5 4 5-8 5 8 5-4-2 12H4z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.peer.forced .mic-state.off { outline: 1px dashed color-mix(in srgb, var(--danger) 70%, transparent); outline-offset: 1px; }
.you {
  position: absolute; top: 9px; right: 9px; margin: 0; z-index: 2;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-2) 45%, transparent); padding: 2px 6px; border-radius: 7px;
}

.mic-state {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 28px; height: 22px; border-radius: 999px; transition: background 0.15s, color 0.15s;
}
.mic-state svg { width: 14px; height: 14px; display: block; animation: icon-swap 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.mic-state.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.mic-state.off { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }
.peer.speaking .mic-state.on { color: var(--accent-ink); background: var(--accent); }
.peer.has-banner .mic-state { text-shadow: 0 1px 2px rgba(0,0,0,0.6); }

.meter { width: 100%; max-width: 90px; height: 5px; background: var(--panel-3); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.meter-fill { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 3px; }

.controls {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.mic-btn {
  width: 52px; height: 52px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); flex: none;
}
.mic-btn:hover { background: #ffffff; }
.mic-btn.on { background: var(--danger); color: #fff; }
.mic-btn.on:hover { background: #f07f74; }
.mic-btn .ic-off { display: none; }
.mic-btn.on .ic-on { display: none; }
.mic-btn.on .ic-off { display: block; }

.vid-btn {
  width: 52px; height: 52px; padding: 0; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-3); color: var(--text);
}
.vid-btn svg { width: 22px; height: 22px; display: block; }
.vid-btn.on { background: var(--accent); color: var(--accent-ink); }
.deaf-btn .ic-off, .deaf-btn.on .ic-on { display: none; }
.deaf-btn.on .ic-off { display: block; }
.deaf-btn.on { background: var(--danger); color: #fff; }
.deaf-btn.on:hover { background: #f07f74; }
.vid-btn.on:hover { background: #ffffff; }

.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 12vw, 200px), 1fr)); gap: 8px; align-content: start; }
.vtile {
  position: relative; min-width: 0; aspect-ratio: 16 / 9; overflow: hidden; cursor: zoom-in;
  background: #000; border: 1px solid var(--line); border-radius: var(--radius);
}
.vtile.main { grid-column: 1 / -1; order: -1; justify-self: center; width: min(100%, calc((100dvh - 210px) * 16 / 9)); }
.videos:has(.vtile:not(.main)) .vtile.main { width: min(100%, calc((100dvh - 320px) * 16 / 9)); }
.vtile:not(.main) { cursor: pointer; }
.vtile:not(.main) .vlabel { font-size: 10px; padding: 2px 6px; left: 6px; bottom: 6px; }
.vtile:not(.main):hover { border-color: var(--accent); }
.vtile canvas, .vtile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vtile.screen:not(.self)::before {
  content: "ЭФИР"; position: absolute; top: 10px; left: 10px; z-index: 1;
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #fff;
  padding: 3px 8px 3px 19px; border-radius: 6px;
  background: radial-gradient(circle at 10px 50%, #fff 0 3px, transparent 3.5px), var(--danger);
}
.vtile.self.camera video { transform: scaleX(-1); }
.vtile:fullscreen { aspect-ratio: auto; border: none; border-radius: 0; cursor: zoom-out; }
.vlabel {
  position: absolute; left: 8px; bottom: 8px; z-index: 1;
  font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 7px;
  background: rgba(0, 0, 0, 0.62); color: var(--text);
  max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vtile.waiting::after {
  content: "ожидание кадра…"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-family: var(--mono); font-size: 12px;
}

.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; text-align: center; }
#ptt-hint { color: var(--accent-2); }

.chat.card { flex: 1 1 320px; min-width: 260px; max-width: 360px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.chat.card[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; }
.chat-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chat-title svg { width: 17px; height: 17px; color: var(--accent); }
.chat-input-row #chat-send svg { width: 17px; height: 17px; display: block; margin: auto; }
.modal-x svg, .vol-popup-close svg { width: 15px; height: 15px; display: block; }
.chat-clear { padding: 6px 12px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.chat-clear:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.chat-messages {
  display: flex; flex-direction: column; gap: 8px;
  height: 340px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.chat-msg { font-size: 14px; line-height: 1.4; word-break: break-word; }
.chat-msg .cname { font-weight: 700; margin-right: 6px; }
.chat-msg .ctime { color: var(--muted); font-family: var(--mono); font-size: 10.5px; margin-left: 6px; }
.chat-msg a { color: var(--accent); }
.chat-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 10px; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; margin-bottom: 0; }
.chat-input-row #chat-send { width: 48px; flex: none; padding: 0; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.chat-input-row #chat-send:hover { background: #ffffff; }

/* Все окна — один и тот же центрированный диалог (как «Музыка вместе»): карточка по центру,
   боковая колонка секций внутри, скролл только в контенте. */
.modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade-in 0.2s ease-out;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(820px, 100%); max-width: min(820px, 100%);
  height: min(720px, 100%); max-height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 18px; box-shadow: 0 30px 80px rgba(0,0,0,0.65);
  display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden;
  animation: modal-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.closing { animation: fade-out 0.18s ease-in forwards; }
.modal.closing .modal-card { animation: modal-out 0.16s ease-in forwards; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.97) translateY(10px); } }
@keyframes modal-out { to { opacity: 0; transform: scale(0.98); } }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; flex: none; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { width: 30px; height: 30px; padding: 0; border-radius: 9px; background: var(--panel-2); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--panel-3); color: var(--text); }
.modal-x.floating { position: absolute; top: 12px; right: 12px; z-index: 2; }

.set-row { display: flex; align-items: center; gap: 12px; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.set-row label { font-size: 13px; color: var(--muted); flex: none; width: 160px; }
.set-row.col label { width: auto; }
.mic-test { display: flex; align-items: center; gap: 10px; }
.mt-bar { flex: 1; height: 10px; border-radius: 5px; background: var(--panel-3); overflow: hidden; }
#mt-fill { display: block; height: 100%; width: 0%; background: var(--muted); border-radius: 5px; transition: background 0.15s; }
#mt-fill.on { background: var(--accent); }
.mic-test .ghost { padding: 7px 12px; font-size: 12.5px; flex: none; }
.mic-test .ghost.on { border-color: var(--accent-2); color: var(--accent-2); }
.set-hint { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 10px 6px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; background: none; border: 0; color: var(--muted); font-size: 11px; line-height: 1.2; text-align: center; cursor: pointer; }
.swatch i { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); transition: transform 0.15s, box-shadow 0.15s; }
.swatch:hover { background: none; }
.swatch:hover i { transform: scale(1.08); }
.swatch[aria-pressed="true"] { color: var(--text); }
.swatch[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent), 0 0 18px -2px var(--accent); }
.theme-custom { display: flex; gap: 8px; }
.fx-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-chip { padding: 7px 12px; border-radius: 999px; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.fx-chip:hover { color: var(--text); }
.fx-chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.set-section { margin-top: 6px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.room-settings { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid color-mix(in srgb, var(--accent-2) 35%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--accent-2) 5%, var(--panel)); }
.room-settings .set-section { margin: 0; color: var(--accent-2); }
.crown-chip { margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--accent-2) 15%, transparent); }
.room-settings input[type="text"], .room-settings input[type="number"] { margin: 0; padding: 9px 10px; font-size: 13px; flex: 1; min-width: 0; }
.owner-move { display: flex; flex-direction: column; gap: 6px; }
.owner-move select { width: 100%; flex: none; padding-top: 8px; padding-bottom: 8px; font-size: 12.5px; }
/* number-поля (лимит) без своей базы: берём вид текстовых, поля в строках — одной ширины */
.room-settings input[type="number"] { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 11px; font-family: inherit; -moz-appearance: textfield; appearance: textfield; }
.room-settings input[type="number"]::-webkit-inner-spin-button, .room-settings input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.room-settings .set-row input[type="text"], .room-settings .set-row input[type="number"] { width: 0; }
.room-row { flex-wrap: wrap; }
.room-row .person-line { white-space: normal; }
.room-row.pick { cursor: pointer; }
.room-row.pick:hover:not(.current):not(.blocked) { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); }
.room-row.blocked { opacity: 0.55; cursor: not-allowed; }
.room-row .person-line.members { white-space: normal; }
.room-edit { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px 2px 2px; border-top: 1px solid var(--line); animation: rise-in 0.18s ease-out; }
#settings-modal #set-pane-rooms .room-settings .set-row:not(.col) > label { flex: 0 0 150px; width: 150px; }
#settings-modal #set-pane-rooms .room-edit .set-row:not(.col) > label { flex: 0 0 120px; width: 120px; }
.room-edit .set-row input[type="text"], .room-edit .set-row input[type="number"] { margin: 0; padding: 8px 10px; font-size: 13px; flex: 1; min-width: 0; }
.room-edit .pe-tools { flex-wrap: wrap; }
.room-pw { flex-basis: 100%; display: flex; gap: 8px; padding-top: 6px; }
.room-pw input { margin: 0; flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.room-row.current { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.room-row .person-who { flex: 1; min-width: 140px; }
.room-row .person-actions { padding: 0; flex-wrap: nowrap; animation: none; }
.room-row .person-actions button { padding: 6px 10px; font-size: 12px; }
.people-list { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.person .avatar { margin: 0; width: 38px; height: 38px; font-size: 15px; border-width: 2px; flex: none; }
.person:not(.online) { opacity: 0.75; }
.person.online .avatar { box-shadow: 0 0 0 2px var(--accent); }
.person-who { min-width: 0; }
.person-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-handle { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.person-line { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-tools { display: flex; flex-direction: column; gap: 6px; }
.people-tools input { width: 100%; margin: 0; }
.person-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person.actionable { cursor: pointer; }
.person.actionable:hover { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); }
.person.banned { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.ban-chip { margin-left: auto; flex: none; font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border-radius: 7px; color: #ffb4ab; background: color-mix(in srgb, var(--danger) 16%, transparent); }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px 8px; animation: rise-in 0.18s ease-out; }
.person-actions button { padding: 7px 11px; font-size: 12.5px; }
.announce-row { display: flex; gap: 8px; }
.announce-row input { flex: 1; min-width: 0; }
.chat-msg.announce { padding: 8px 10px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--accent-2) 45%, var(--line)); background: color-mix(in srgb, var(--accent-2) 9%, transparent); }
.ann-tag { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.toast.announce { border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line)); max-width: min(460px, calc(100vw - 32px)); }
.set-row select, .owner-move select {
  flex: 1; min-width: 0; padding: 9px 30px 9px 10px; border-radius: 9px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-size: 13px;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b0b0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

input[type="range"] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; cursor: pointer; }
.set-row input[type="range"] { flex: 1; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--panel-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -5px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--panel-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--panel); border-radius: 50%; background: var(--accent); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }

.set-row input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; margin: 0 0 0 auto;
  width: 42px; height: 24px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.set-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.set-row input[type="checkbox"]:checked { background: color-mix(in srgb, var(--accent) 32%, var(--panel-3)); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.set-row input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--accent); }
.set-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.set-row input[type="color"] { width: 44px; height: 32px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); cursor: pointer; }
.set-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.set-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.set-row input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

.set-row input[type="file"] { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.set-row input[type="file"]::file-selector-button {
  font: inherit; font-size: 12.5px; margin-right: 10px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-3); color: var(--text); cursor: pointer;
}
.set-row input[type="file"]::file-selector-button:hover { background: var(--hover); }

/* Баннер теперь своей собственной высоты: пропорции картинки проставляет paintBanner в --b-ratio,
   поэтому широкий баннер виден целиком, а не срезан фиксированными 110/132px. */
.pe-banner, .pc-banner {
  position: relative; height: auto; aspect-ratio: var(--b-ratio, 3.1);
  min-height: 92px; max-height: min(220px, 32vh); border-radius: 12px; margin-bottom: 26px;
}
.pc-banner { border-radius: 0; margin: -20px -20px 26px; }
.pe-avatar, .pc-avatar {
  position: absolute; left: 28px; bottom: -22px;
  width: 64px; height: 64px; border-radius: 50%;
  border: 4px solid var(--panel); background: var(--accent) center/cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; color: var(--accent-ink);
}
.pc-body { display: flex; flex-direction: column; gap: 6px; }
.pc-name { font-size: 20px; font-weight: 700; }
.pc-status { font-size: 13px; color: var(--muted); }
.pc-about { font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.pc-avatar { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pc-banner::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 -44px 60px -34px rgba(0, 0, 0, 0.6); }
.pc-name { letter-spacing: 0.2px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

.pe-card { position: relative; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); overflow: hidden; padding-bottom: 14px; }
.pe-card .pc-banner { margin: 0; border-radius: 0; cursor: pointer; }
/* Аватар в редакторе больше не привязан к высоте баннера: он в потоке и залезает на него на 30px.
   position: relative обязателен — static заставлял баннер (он relative) рисоваться поверх кружка. */
.pe-card .pc-avatar {
  position: relative; top: auto; bottom: auto; left: auto;
  margin: -30px 0 0 28px; z-index: 1; border-color: var(--panel-2); cursor: pointer; transition: box-shadow 0.15s;
}
.pe-card .pc-avatar:hover { box-shadow: 0 0 0 3px var(--accent); }
.pe-card .pc-body { padding: 8px 16px 0; gap: 4px; }
.pe-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.15s;
}
.pe-card .pc-banner:hover .pe-hint { opacity: 1; }
.pe-drop.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.pe-tools { display: flex; gap: 8px; }
.pe-tools .ghost { padding: 7px 12px; font-size: 12.5px; }
.pe-count { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 6px; }

.pop-menu {
  position: fixed; z-index: 50; width: 264px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; gap: 8px;
}
.pm-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.pm-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button { flex: 1; padding: 8px 0; font-size: 13px; border-radius: 8px; background: transparent; color: var(--muted); }
.seg button:hover { background: var(--panel-3); color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.pm-note { margin: 2px 0 4px; font-family: var(--mono); font-size: 11px; color: var(--accent-2); }
.pm-hint { margin: 0; font-size: 11.5px; line-height: 1.35; color: var(--muted); }
#sm-go.danger { background: var(--danger); color: #fff; }
#sm-go.danger:hover { background: #f07f74; }

.vol-popup {
  position: fixed; z-index: 50; width: 196px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; gap: 10px;
}
.vol-popup[hidden] { display: none; }
.vol-popup-head { display: flex; align-items: center; gap: 10px; }
.vol-popup-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vol-popup-close { flex: none; width: 26px; height: 26px; padding: 0; border-radius: 7px; background: var(--panel-2); color: var(--muted); font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.vol-popup-close:hover { background: var(--panel-3); color: var(--text); }
.vol-popup input[type="range"] { width: 100%; }
.vol-popup > button { width: 100%; padding: 8px; font-size: 13px; }
.owner-tools { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.owner-tools button { width: 100%; padding: 8px; font-size: 12.5px; }
.owner-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.danger-ghost { color: #ffb4ab; border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.danger-ghost:hover { background: var(--danger); color: #fff; }

@media (max-width: 560px) {
  .wrap, .wrap.chat-open { max-width: 100%; padding: 14px; }
  .peers { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .avatar { width: 46px; height: 46px; font-size: 18px; }
  .set-row { flex-wrap: wrap; }
  .set-row label { width: 100%; }
}

/* Низкое окно: карточка входа (331px + 48px полей .wrap) не влезала в 360px —
   документ вылезал на 19px. Ужимаем отступы, чтобы вход был виден целиком. */
@media (max-height: 520px) {
  .wrap { padding: 12px; }
  .card { padding: 14px; }
  .tag { margin: 6px 0 12px; }
  .gate-hint { margin-bottom: 8px; }
  .gate-me { gap: 10px; margin-bottom: 10px; padding: 8px 10px; }
  .gate-me .avatar { width: 40px; height: 40px; }
  input[type="text"], input[type="password"], input[type="email"], textarea { padding: 10px 12px; }
  input[type="text"], input[type="password"], input[type="email"] { margin-bottom: 8px; }
  button { padding: 10px 14px; }
}

/* ==== room: the whole window ==== */
.wrap:has(#room:not([hidden])) { max-width: none; height: 100vh; height: 100dvh; padding: 0; }
.wrap:has(#room:not([hidden])) > .stage { height: 100%; gap: 0; flex-wrap: nowrap; }
.stage > #room { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.room-head {
  flex: none; height: 58px; margin: 0; padding: 0 18px;
  background: color-mix(in srgb, var(--panel) 86%, transparent); backdrop-filter: blur(10px);
}
.count-chip { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.room-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 28px 28px 8px;
  display: flex; flex-direction: column; justify-content: center; gap: 14px;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
}
.room-people { display: flex; flex-direction: column; gap: 14px; }
/* Развёрнутый текст занимает правую колонку ровно так же, как демонстрация экрана, поэтому
   участники перестраиваются в плотные горизонтальные строки в обоих случаях. */
.wrap.has-video .room-body, .wrap.has-lyrics .room-body { flex-direction: row; align-items: flex-start; justify-content: flex-start; gap: 18px; }
.wrap.has-video .room-people, .wrap.has-lyrics .room-people { flex: 1 1 0; min-width: 0; max-width: 460px; }
.wrap.has-video .room-body > .videos { flex: 1 1 0; min-width: 0; }
.room-body .peers { width: 100%; max-width: 920px; margin: 0 auto; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 200px)); justify-content: center; }
.wrap.has-video .room-body .peers, .wrap.has-lyrics .room-body .peers { max-width: none; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.wrap.has-video .room-body .peer .pname, .wrap.has-lyrics .room-body .peer .pname { min-width: 48px; }
.wrap.has-video .room-body .peer, .wrap.has-lyrics .room-body .peer { flex-direction: row; gap: 10px; padding: 8px 10px; text-align: left; }
.wrap.has-video .room-body .peer .avatar, .wrap.has-lyrics .room-body .peer .avatar { width: 34px; height: 34px; margin: 0; font-size: 14px; border-width: 2px; }
.wrap.has-video .room-body .peer .meter, .wrap.has-lyrics .room-body .peer .meter { display: none; }
.wrap.has-video .room-body .peer .pbanner, .wrap.has-lyrics .room-body .peer .pbanner { height: 100%; }
.wrap.has-video .room-body .peer .pbanner::after, .wrap.has-lyrics .room-body .peer .pbanner::after { background: linear-gradient(90deg, rgba(18, 18, 18, 0.55), rgba(18, 18, 18, 0.88)); }
.wrap.has-video .room-body .peer .pname, .wrap.has-lyrics .room-body .peer .pname { flex: 1; min-width: 0; font-size: 13px; }
.wrap.has-video .room-body .peer .you, .wrap.has-lyrics .room-body .peer .you { position: static; order: 3; }
.wrap.has-video .room-body .peer .net, .wrap.has-lyrics .room-body .peer .net { position: static; order: 4; padding: 2px 3px; }
.room-body .videos { margin: 0; }
.room-body .hint { margin: 2px 0 0; }

.controls {
  flex: none; align-self: center; margin: 10px 0 18px; padding: 10px 12px; gap: 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(12px);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
}
.dock-sep { width: 1px; height: 30px; background: var(--line); margin: 0 2px; }
.leave-btn {
  height: 52px; padding: 0 20px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--danger) 16%, var(--panel-3)); color: #ffb4ab;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}
.leave-btn:hover { background: var(--danger); color: #fff; }
.leave-btn svg { width: 18px; height: 18px; }

.wrap:has(#room:not([hidden])) .chat.card {
  flex: 0 0 340px; max-width: 340px; height: 100%; border-radius: 0; border: none;
  border-left: 1px solid var(--line); box-shadow: none; background: color-mix(in srgb, var(--panel) 95%, transparent);
}
.wrap:has(#room:not([hidden])) .chat-messages { flex: 1; height: auto; min-height: 0; }

.toasts { position: fixed; left: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px; border-radius: 12px; font-size: 13.5px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease-out; transition: opacity 0.35s, transform 0.35s;
}
.toast.out { opacity: 0; transform: translateY(6px); }
.toast b { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; }
.toast.in b { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.toast.left b { color: var(--muted); background: var(--panel-3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .wrap.has-video .room-body { flex-direction: column; align-items: stretch; }
  .wrap.has-video .room-people { max-width: none; }
  .wrap.has-video .room-body > .videos { flex: none; order: -1; }
  /* Крупный текст колонку НЕ ломает: в колонке его левый край лёг бы на фиксированный
     плеер (900×800: панель 844px под карточкой 400px). Оставляем row — на две равные
     колонки его хватает (413 + 18 + 413, край панели 459 > правого края плеера 416),
     а потолок ширины снимаем, иначе тексту остаётся 820px там, где есть половина окна. */
  .wrap.has-lyrics .room-lyrics { max-width: none; }
  .vtile.main { width: min(100%, calc((100dvh - 300px) * 16 / 9)); }
  .videos:has(.vtile:not(.main)) .vtile.main { width: min(100%, calc((100dvh - 390px) * 16 / 9)); }
  .wrap:has(#room:not([hidden])) .chat.card { position: fixed; top: 58px; right: 0; bottom: 0; z-index: 30; box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5); }
}

@media (max-width: 760px) {
  .room-head { height: 52px; padding: 0 12px; gap: 8px; }
  .count-chip { display: none; }
  .room-body { padding: 14px 12px 6px; justify-content: flex-start; }
  .room-body .peers { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .videos { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .controls { margin: 6px 0 12px; padding: 8px; gap: 8px; }
  .leave-btn { padding: 0 14px; }
  .wrap:has(#room:not([hidden])) .chat.card { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; max-width: none; z-index: 30; border-left: none; }
  .toasts { left: 12px; right: 12px; bottom: auto; top: 60px; }
}

/* ==== motion ==== */
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.94); } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.9); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes badge-pop { 0% { transform: scale(0); } 70% { transform: scale(1.4); } }
@keyframes icon-swap { from { opacity: 0; transform: scale(0.5) rotate(-25deg); } }
@keyframes live { 50% { opacity: 0.3; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

#gate:not([hidden]) { animation: rise-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
#room:not([hidden]) { animation: fade-in 0.35s ease-out; }
#join:disabled { opacity: 1; color: transparent; position: relative; }
#join:disabled::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--accent-ink); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
#status.ok::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; vertical-align: 1px;
  border-radius: 50%; background: var(--accent); animation: live 2s ease-in-out infinite;
}

.peer, .vtile { animation: pop-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.peer.leaving, .vtile.leaving { animation: pop-out 0.22s ease-in forwards; pointer-events: none; }

.wrap:has(#room:not([hidden])) .chat.card:not([hidden]) { animation: slide-in-right 0.26s cubic-bezier(0.2, 0.8, 0.2, 1); }
.chat-msg { animation: rise-in 0.22s ease-out; }
.unread:not([hidden]) { animation: badge-pop 0.35s ease-out; }

.pop-menu:not([hidden]) { animation: menu-in 0.18s ease-out; transform-origin: bottom center; }
.vol-popup:not([hidden]) { animation: menu-in 0.15s ease-out; transform-origin: top left; }

.controls button { transition: transform 0.15s, background 0.15s, box-shadow 0.15s, color 0.15s; }
.controls button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.controls button:active:not(:disabled) { transform: translateY(0) scale(0.93); box-shadow: none; }
.mic-btn.on .ic-off, .mic-btn:not(.on) .ic-on { animation: icon-swap 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ==== anime look: name styles, profile effects ==== */
[data-ns]:not([data-ns=""]) { -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none !important; }
[data-ns="sakura"] { background-image: linear-gradient(90deg, #ffb7d5, #fff0f6 50%, #ff8fbb); }
[data-ns="sunset"] { background-image: linear-gradient(90deg, #ffc46b, #ff7a8a 60%, #c86bff); }
[data-ns="neon"] { background-image: linear-gradient(90deg, #5ce1ff, #ff6bd5); filter: drop-shadow(0 0 5px rgba(255, 107, 213, 0.55)); }
[data-ns="gold"] { background-image: linear-gradient(100deg, #c08a2e 0%, #ffe9a3 25%, #c08a2e 50%, #ffe9a3 75%, #c08a2e 100%); background-size: 200% 100%; animation: ns-shine 3s linear infinite; }
[data-ns="rainbow"] { background-image: linear-gradient(90deg, #ff6b6b, #ffd25e, #7ee0b0, #5fd3e6, #b49cff, #ff6bd5, #ff6b6b); background-size: 200% 100%; animation: ns-shine 4s linear infinite; }
[data-ns="frost"] { background-image: linear-gradient(180deg, #ffffff 30%, #9fd2ff); }
[data-ns="aurora"] { background-image: linear-gradient(90deg, #4be8c6, #5ce1ff 35%, #b49cff 70%, #ff8fe0); background-size: 200% 100%; animation: ns-shine 5s linear infinite; }
[data-ns="ocean"] { background-image: linear-gradient(90deg, #2bd1ff, #3a7bff 60%, #6be9ff); }
[data-ns="fire"] { background-image: linear-gradient(90deg, #ffd25e, #ff7a3c 45%, #ff3c6b); background-size: 200% 100%; animation: ns-shine 3s linear infinite; filter: drop-shadow(0 0 4px rgba(255, 90, 40, 0.45)); }
[data-ns="galaxy"] { background-image: linear-gradient(90deg, #8c6bff, #ff6bd5 50%, #5ce1ff); background-size: 200% 100%; animation: ns-shine 4.5s linear infinite; }
[data-ns="mint"] { background-image: linear-gradient(90deg, #7ef0c0, #c8ffe9 50%, #5fd3e6); }
[data-ns="candy"] { background-image: linear-gradient(90deg, #ff9ec7, #ffd6a5 50%, #a5d8ff); }
[data-ns="toxic"] { background-image: linear-gradient(90deg, #aaff3d, #5cff9e 60%, #c6ff4b); filter: drop-shadow(0 0 5px rgba(140, 255, 80, 0.5)); }
[data-ns="royal"] { background-image: linear-gradient(100deg, #7b4bff 0%, #ffe9a3 25%, #7b4bff 50%, #ffe9a3 75%, #7b4bff 100%); background-size: 200% 100%; animation: ns-shine 3.5s linear infinite; }
@keyframes ns-shine { to { background-position: -200% 0; } }
.person-name[data-ns] .person-handle { -webkit-text-fill-color: var(--muted); }

.pfx { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; border-radius: inherit; container-type: size; }
.pfx i { position: absolute; left: var(--x); top: 0; width: var(--s); height: var(--s); opacity: 0; animation: var(--t) linear var(--d) infinite; }
.pfx-sakura i { background: linear-gradient(135deg, #ffe3ee, #ff9cc2); border-radius: 80% 0 80% 0; animation-name: pfx-fall; }
.pfx-snow i { background: #f4f8ff; border-radius: 50%; animation-name: pfx-fall; }
.pfx-hearts i { background: #ff6b9a; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 88 C20 66 6 48 18 28 C28 13 46 18 50 32 C54 18 72 13 82 28 C94 48 80 66 50 88 Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 88 C20 66 6 48 18 28 C28 13 46 18 50 32 C54 18 72 13 82 28 C94 48 80 66 50 88 Z'/%3E%3C/svg%3E") center / contain no-repeat; animation-name: pfx-rise; }
.pfx-sparkles i { top: var(--y); background: #fff3b0; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 2 Q50 50 98 50 Q50 50 50 98 Q50 50 2 50 Q50 50 50 2 Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 2 Q50 50 98 50 Q50 50 50 98 Q50 50 2 50 Q50 50 50 2 Z'/%3E%3C/svg%3E") center / contain no-repeat; animation-name: pfx-twinkle; animation-timing-function: ease-in-out; }
@keyframes pfx-fall {
  0% { opacity: 0; transform: translate(0, -12px) rotate(0deg); }
  10%, 85% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(26px, calc(100cqh + 12px)) rotate(400deg); }
}
@keyframes pfx-rise {
  0% { opacity: 0; transform: translate(0, calc(100cqh + 12px)) scale(0.6); }
  15%, 70% { opacity: 0.85; }
  100% { opacity: 0; transform: translate(-16px, 20cqh) scale(1.1); }
}
@keyframes pfx-twinkle { 0%, 100% { opacity: 0; transform: scale(0.2) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(90deg); } }
.calm .pfx { display: none; }
.calm [data-ns] { animation: none; }

.pe-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.fx-chip [data-ns] { font-weight: 700; }

/* ==== Парсер ==== */
.modal-card.parser { width: min(1240px, 100%); max-width: min(1240px, 100vw); overflow: hidden; gap: 10px; padding-bottom: 0; }
/* Ширины под содержимое: анкета и карточка узкие, список людей — самый широкий после парсера. */
#card-modal .modal-card { width: min(560px, 100%); height: auto; max-height: min(720px, 100%); }
#people-modal .modal-card { width: min(920px, 100%); }
/* Окна без колонок (профиль, люди, карточка) прокручиваются целиком: секций в rail там нет. */
#people-modal .modal-card, #card-modal .modal-card { overflow-y: auto; }
.parser .modal-head { gap: 12px; justify-content: flex-start; }
.parser .modal-head .modal-x { margin-left: auto; }
.px-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.px-status.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.px-status.warn { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line)); }
.px-status.bad { color: #ffb4ab; border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.px-ask { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--panel-2)); animation: rise-in 0.2s ease-out; }
.px-ask-title { font-weight: 700; }
.px-ask-row { display: flex; gap: 8px; }
.px-ask-row input { flex: 1; min-width: 0; margin: 0; }
.px-ask-row .primary { width: auto; }
.px-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.px-tabs button { padding: 9px 14px; border-radius: 9px 9px 0 0; background: none; color: var(--muted); font-size: 13.5px; border-bottom: 2px solid transparent; flex: none; }
.px-tabs button:hover { color: var(--text); background: var(--panel-2); }
.px-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.px-body { flex: 1; min-height: 0; display: flex; gap: 14px; position: relative; }
.px-main { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 20px; }
.px-side { width: 430px; flex: none; overflow-y: auto; overflow-x: hidden; border-left: 1px solid var(--line); padding: 0 4px 20px 14px; animation: rise-in 0.18s ease-out; }
.px-side-head { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; background: var(--panel); padding: 6px 0 8px; z-index: 1; }
.px-side-head h3 { margin: 0; font-size: 15px; flex: 1; }
.px-side-head .icon-btn { width: 32px; height: 32px; padding: 0; font-size: 15px; }
.px-side-body { display: flex; flex-direction: column; gap: 10px; }
.px-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.px-tools input[type="text"] { flex: 1 1 260px; min-width: 0; margin: 0; }
.px-tools select { max-width: 260px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; }
.px-tools .ghost, .px-more, .px-side .ghost, .px-btn { padding: 7px 12px; font-size: 12.5px; }
.px-btn { display: inline-flex; align-items: center; border-radius: 11px; color: var(--text); text-decoration: none; font-weight: 600; }
.px-more { align-self: center; }
.px-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.px-card { padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.px-card-v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.px-card-k { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.px-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.px-chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.px-feed { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); max-height: 46vh; overflow-y: auto; }
.px-feed.tall { max-height: none; flex: 1; }
.px-line { display: flex; gap: 10px; padding: 6px 12px; font-size: 13px; line-height: 1.4; text-align: left; border-bottom: 1px solid var(--line); background: none; border-radius: 0; color: var(--text); font-weight: 400; }
.px-line:last-child { border-bottom: 0; }
button.px-line:hover { background: var(--panel-3); }
.px-line .px-time { flex: none; margin-left: 0; padding-top: 2px; }
.px-line-text { min-width: 0; word-break: break-word; }
.px-line.info .px-line-text { color: var(--muted); }
.px-line.warn .px-line-text { color: var(--accent-2); }
.px-line.error .px-line-text { color: #ffb4ab; }
.px-list { display: flex; flex-direction: column; gap: 6px; }
.px-row { display: flex; gap: 11px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-weight: 400; text-align: left; width: 100%; }
.px-row:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.px-row.small { padding: 8px 10px; }
.px-row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.px-row-top { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 13px; }
.px-row-top b { font-weight: 650; }
.px-row-text { font-size: 13.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.px-row-text.tall { -webkit-line-clamp: 4; }
.px-row-text.dim { color: var(--muted); font-size: 12.5px; -webkit-line-clamp: 1; }
.px-dim { color: var(--muted); font-size: 12.5px; }
.px-time { color: var(--muted); font-family: var(--mono); font-size: 11px; margin-left: auto; }
.px-row-top .px-time { margin-left: auto; }
.px-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.px-badges:empty { display: none; }
.px-badge { font-family: var(--mono); font-size: 10.5px; padding: 1px 7px; border-radius: 7px; color: var(--muted); background: var(--panel-3); }
.px-badge.bad { color: #ffb4ab; background: color-mix(in srgb, var(--danger) 16%, transparent); }
.px-badge.accent { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
/* прирост за последний час: зелёная пилюля рядом с общим счётчиком */
.px-delta { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 7px; color: #7ee0a1; background: color-mix(in srgb, #7ee0a1 16%, transparent); }
.px-delta.zero { color: var(--muted); background: var(--panel-3); }
.px-chip .px-delta { margin-left: 6px; }
.px-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px; }
.px-ava { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--panel-3) center/cover; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 15px; }
.px-ava.big { width: 76px; height: 76px; font-size: 28px; }
.px-author { display: flex; gap: 10px; align-items: center; padding: 6px; margin: -6px; background: none; border-radius: 12px; color: var(--text); text-align: left; font-weight: 400; }
.px-author:hover { background: var(--panel-2); }
.px-author > span:last-child { display: flex; flex-direction: column; }
.px-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.px-quote { padding: 6px 10px; border-left: 3px solid var(--line); font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.px-quote b { color: var(--text); font-weight: 600; }
.px-media { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.px-img { max-width: 100%; max-height: 340px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); }
.px-person { display: flex; gap: 14px; align-items: center; }
.px-person-name { font-size: 19px; font-weight: 700; }
.px-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.px-bars { display: flex; align-items: flex-end; gap: 3px; height: 92px; padding: 6px 4px 0; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.px-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.px-bar i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); }
.px-bar span { font-family: var(--mono); font-size: 9px; color: var(--muted); height: 12px; }
.px-hist { display: flex; gap: 10px; font-size: 13px; align-items: baseline; }
.px-hist .px-time { margin: 0; flex: none; }
.px-hist s { color: var(--muted); }
.px-pre { max-height: 420px; overflow: auto; font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-all; }
.px-form { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.px-form textarea { width: 100%; }
.px-form input[type="text"], .px-form input[type="password"], .px-form input[type="number"] { flex: 1; min-width: 0; margin: 0; }
.px-form input[type="number"] { max-width: 120px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.px-form .set-row label { width: 220px; }
@media (max-width: 900px) {
  .px-side { position: absolute; inset: 0; width: auto; border-left: 0; padding-left: 0; background: var(--panel); z-index: 2; }
}

/* ---- Музыка вместе: поиск + очередь ---- */
#music-q { width: 100%; margin-bottom: 10px; }
.music-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.music-row {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 8px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.music-row:hover { background: var(--panel-3); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.music-thumb { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 7px; object-fit: cover; background: var(--panel-3); }
.music-thumb-note { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.music-thumb-note svg { width: 20px; height: 20px; }
.music-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.music-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-src { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-empty { padding: 18px 6px; font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center; }
/* Очередь живёт на своей вкладке во весь рост панели: номера строк — это реальный порядок
   воспроизведения, а не декор, и они же дают глазами мерить длину списка. */
.music-queue {
  display: flex; flex-direction: column; gap: 4px; margin: 0; flex: 1 1 auto; min-height: 0;
  overflow: auto; scrollbar-width: thin; counter-reset: qq;
}
.music-qlabel {
  position: sticky; top: 0; z-index: 2; margin: 0; padding: 6px 8px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  background: linear-gradient(180deg, var(--panel) 60%, transparent);
}
.music-qrow { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.music-qrow::before {
  counter-increment: qq; content: counter(qq); flex: none; width: 20px; text-align: right;
  font-size: 11.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
}
.music-qrow.now { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.music-qrow.now::before { color: var(--accent); }
.mq-empty {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px 20px; text-align: center; color: var(--muted); font-size: 13.5px;
}
.mq-empty svg { width: 34px; height: 34px; opacity: 0.45; }
.mq-empty .ghost { padding: 8px 14px; font-size: 13px; }
.music-qrow .music-thumb { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 6px; }
.music-qmeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.music-qtitle { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.music-qby { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.music-row.music-added { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }
/* Заголовки групп результатов: «Telegram-каналы» / «ВКонтакте». */
.music-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 8px 2px 0; }

/* ---- Окно «Музыка вместе»: диалог по центру с боковой колонкой разделов ----
   Rail слева держит разделы (Поиск/Лайки/Плейлисты/Настройки), справа — сам контент.
   Ширина окна не растёт бесконечно: 1040px и 92% высоты, чтобы список не уползал за экран. */
#music-modal { align-items: center; justify-content: center; padding: 16px; }
#music-modal .modal-card {
  width: min(1040px, 100%); max-width: min(1040px, 100%); height: min(760px, 100%);
  max-height: 100%; padding: 16px 18px; gap: 12px; overflow: hidden;
  border-radius: 18px; border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.65);
  animation: mm-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#music-modal.closing .modal-card { animation: mm-out 0.16s ease-in forwards; }
@keyframes mm-in { from { opacity: 0; transform: scale(0.97) translateY(10px); } }
@keyframes mm-out { to { opacity: 0; transform: scale(0.98); } }
.mm-body { display: flex; gap: 16px; flex: 1 1 auto; min-height: 0; }
.mm-rail {
  flex: 0 0 184px; display: flex; flex-direction: column; gap: 4px;
  padding-right: 14px; border-right: 1px solid var(--line);
}
.mm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
/* Списки внутри диалога растут в свою колонку, а не в 50vh поверх неё. */
#music-modal .music-results { max-height: none; flex: 1 1 auto; min-height: 0; }
.mm-tab {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border-radius: 10px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.mm-tab svg { width: 16px; height: 16px; flex: none; }
.mm-tab span { flex: 1 1 auto; min-width: 0; }
.mm-tab:hover { color: var(--text); background: var(--panel-3); }
.mm-tab.is-on { color: var(--text); background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); box-shadow: inset 2px 0 0 var(--accent); }
.mm-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mm-badge {
  flex: none; min-width: 22px; padding: 1px 6px; border-radius: 999px;
  background: var(--panel-3); color: var(--text); font-size: 11px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}
.mm-badge[hidden] { display: none; }
/* Узкое окно: колонка разделов становится полосой сверху, списки остаются во всю ширину. */
@media (max-width: 720px) {
  .mm-body { flex-direction: column; gap: 10px; }
  .mm-rail { flex: none; flex-direction: row; align-items: center; overflow-x: auto; padding-right: 0; border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .mm-tab { width: auto; padding: 8px 10px; }
}
/* ---- Группы настроек ---- */
.mm-group { padding: 4px 0 10px; border-bottom: 1px solid var(--line); }
.mm-group:last-child { border-bottom: 0; }
.mm-group-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }
.mm-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; font-size: 13px; color: var(--text); }
.mm-row > span { flex: 1 1 auto; min-width: 0; }
.mm-seg { display: flex; gap: 4px; flex: none; }
.mm-seg button {
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.mm-seg button:hover { color: var(--text); background: var(--panel-3); }
.mm-seg button.is-on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.mm-slide { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 13px; }
.mm-slide > span { flex: 0 0 auto; min-width: 130px; }
.mm-slide input[type="range"] { flex: 1 1 auto; min-width: 0; }
.mm-slide output { flex: 0 0 46px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.music-pane-set { gap: 2px; overflow-y: auto; scrollbar-width: thin; padding-right: 4px; }

/* ---- Медиатека: лайки и плейлисты комнаты ---- */
.music-pane { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
/* Окно настроек стоит на том же rail, что и «Музыка вместе»: скролл — внутри колонки секций. */
#settings-modal .music-pane { overflow-y: auto; scrollbar-width: thin; gap: 12px; padding-right: 6px; }
@media (min-width: 721px) { #settings-modal .mm-rail { flex-basis: 196px; } }
#settings-modal .set-row:not(.col) label { flex: 1 1 auto; width: auto; min-width: 0; }
#settings-modal .set-row > input[type="checkbox"] { margin-left: auto; }
#settings-modal .set-row > input[type="range"], #settings-modal .set-row > select { flex: 0 1 260px; }
.music-meta { flex: 1 1 auto; }
.music-act {
  flex: 0 0 auto; width: 30px; height: 30px; margin-left: auto; display: flex; align-items: center; justify-content: center;
  padding: 0; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer;
}
.music-act + .music-act { margin-left: 0; }
.music-act svg { width: 17px; height: 17px; }
.music-act:hover { color: var(--text); background: var(--panel-3); }
.music-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.music-act.is-on { color: #ff5b6e; }
.music-newpl { display: flex; gap: 8px; margin-bottom: 10px; }
.music-newpl input { flex: 1 1 auto; min-width: 0; }
.mp-btn {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.mp-btn:hover { background: var(--panel-3); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.mp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.music-plays { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow: auto; }
.music-pl { padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.music-pl-head { display: flex; align-items: center; gap: 8px; }
.music-pl-name { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-pl-count { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); }
.music-pl-items { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.music-pl .music-row { background: var(--panel-3); }
.music-pick { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 2px; padding: 6px 8px; border-radius: 10px; background: var(--panel-3); }
.music-pick button { text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: 7px; cursor: pointer; }
.music-pick button:hover { background: var(--hover); }
/* Вкладка «Эфир»: дни сверху, топ ниже; оба блока скроллятся сами, строки — тот же .music-row. */
.music-air-days { display: flex; flex-direction: column; gap: 5px; max-height: 46vh; overflow: auto; }
.music-air-top { display: flex; flex-direction: column; gap: 5px; max-height: 26vh; overflow: auto; margin-top: 8px; }
.music-air-days .music-group + .music-row { margin-top: 2px; }

/* ==== now-playing v3: горизонтальная полоса ====
   Снизу строка (обложка | артист/название + перемотка), над ней ручка-стрелка и панель
   кнопок, ещё выше — текст песни. id: #music-bar #music-bar-text #music-bar-sub
   #music-progress #music-time-current #music-time-total #music-playpause #music-back
   #music-skip #music-stop #music-lyrics #music-vol #music-sheet #music-sheet-btn
   Пауза от сервера: .music-bar.is-paused. Свёрнутая панель: .music-bar.sheet-closed. */
.music-bar {
  --mm-w: 420px;
  position: fixed; left: 16px; bottom: 96px; z-index: 20;
  /* Полосa тянется от левого края; на узких окнах ширину ограничивает вьюпорт. */
  width: min(var(--mm-w), calc(100vw - 32px));
  animation: player-in .4s var(--ease);
}
@keyframes player-in { from { opacity: 0; transform: translateY(20px) scale(0.95); } }
.music-bar svg { display: block; flex: none; }
/* Контейнер прозрачен: фон рисует каждая карточка сама, поэтому панель кнопок можно
   свернуть, не дёргая геометрию строки. */
.mb-stack { display: flex; flex-direction: column; gap: 6px; }
.mb-row, .mb-sheet, .mb-lyrics {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--panel) 96%, transparent),
    color-mix(in srgb, var(--panel-2) 92%, transparent));
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05);
}
.mb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 16px; min-width: 0;
}
.mb-sheet { padding: 8px 10px; border-radius: 14px; }
.music-bar.sheet-closed .mb-sheet { display: none; }
/* Ручка: стрелка вниз — панель открыта, клик закроет; вверх — закрыта, клик откроет. */
.mb-tab {
  align-self: center; width: 56px; height: 20px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--muted); cursor: pointer;
}
.mb-tab:hover { color: var(--text); background: var(--panel-3); }
.mb-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mb-tab svg { width: 14px; height: 14px; }
.mb-tab .ic-up { display: none; }
.music-bar.sheet-closed .mb-tab .ic-down { display: none; }
.music-bar.sheet-closed .mb-tab .ic-up { display: block; }

/* Обложка в строке — маленький квадрат; нота остаётся фолбэком, пока картинка не приехала. */
.mb-art {
  position: relative; width: 52px; height: 52px; flex: none;
  border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #ffffff;
  background: radial-gradient(circle at 50% 40%, #4f4f4f 0%, #2a2a2a 55%, #161616 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    inset 0 -6px 16px rgba(0,0,0,0.55),
    0 6px 16px rgba(0,0,0,0.5);
  isolation: isolate;
}
.mb-art-glow {
  position: absolute; inset: -30%; z-index: 0;
  background: conic-gradient(from 0deg, #fff 0deg, #8a8a8a 90deg, #fff 180deg, #8a8a8a 270deg, #fff 360deg);
  filter: blur(14px); opacity: .16;
  animation: cover-spin 16s linear infinite;
  pointer-events: none;
}
@keyframes cover-spin { to { transform: rotate(360deg); } }

.mb-note {
  position: relative; z-index: 2;
  width: 24px; height: 24px;
  color: #ffffff;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.75));
  transition: opacity .2s, transform .3s var(--ease);
}
/* Обложка трека: тот же блок, нота остаётся фолбэком, пока картинка не приехала.
   contain, а не cover: целиком даже если превью не квадратное. */
.mb-cover {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transform: scale(1.05);
  transition: opacity .3s var(--ease), transform .5s var(--ease);
  pointer-events: none;
}
.mb-art.has-cover .mb-cover { opacity: 1; transform: none; }
.mb-art.has-cover .mb-note { opacity: 0; transform: scale(.82); }
.mb-art.has-cover .mb-art-glow { opacity: .28; }

/* Сколько треков в очереди — чип на правом краю строки. */
.mb-count {
  order: 4; flex: none;
  min-width: 24px; padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .14);
  color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.3; text-align: center;
  font-variant-numeric: tabular-nums;
}
.mb-count[hidden] { display: none; }

/* Кастомизация плеера из окна «Музыка вместе» (раздел Настройки): music.js вешает эти
   классы на #music-bar и меняет --mm-w / --lyr-size. Всё локально, у соседей не трогаем. */
.music-bar.mm-compact { --mm-w: 320px; }
.music-bar.mm-large { --mm-w: 520px; }
.music-bar.no-cover .mb-cover,
.music-bar.no-cover .mb-art.has-cover .mb-cover { opacity: 0; transform: scale(1.05); }
.music-bar.no-cover .mb-note,
.music-bar.no-cover .mb-art.has-cover .mb-note { opacity: 1; transform: none; }
.music-bar.no-glow .mb-art-glow,
.music-bar.no-glow .mb-art.has-cover .mb-art-glow { opacity: 0; animation: none; }
.music-bar.no-count .mb-count { display: none; }
.music-bar.no-seek #music-back { display: none; }

/* Текст песни — карточкой над панелью кнопок, во всю ширину полосы. При развороте
   (#room-lyrics) нода переезжает в правую колонку, там свои размеры ниже. */
.mb-lyrics {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; overscroll-behavior: contain;
  padding: 0; border-radius: 16px;
  min-height: 118px; max-height: min(34vh, 230px);
  font-size: var(--lyr-size, 13.5px); line-height: 1.5;
  animation: lyrics-in .28s var(--ease);
}
.ly-head { flex: none; display: flex; justify-content: flex-end; padding: 4px 8px 0 14px; }
.ly-expand {
  width: 26px; height: 26px; display: grid; place-items: center; padding: 0;
  border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.06);
  color: var(--muted); cursor: pointer;
}
.ly-expand:hover { color: var(--text); background: var(--panel-3); }
.ly-expand svg { display: block; }
.ly-expand .ic-collapse { display: none; }
.mb-lyrics.is-big .ic-expand { display: none; }
.mb-lyrics.is-big .ic-collapse { display: block; }
/* Прокрутка живёт в списке, а не в панели: шапка с кнопкой разворота остаётся на месте.
   position:relative обязателен — на него ссылается offsetTop строк в updateLyricLine. */
.ly-list {
  position: relative; flex: 1 1 0; min-height: 0;
  overflow-y: auto; scrollbar-width: thin; padding: 3px 14px 12px;
}
/* Полоса лежит внизу, поэтому текст въезжает снизу вверх, а не слева. */
@keyframes lyrics-in { from { opacity: 0; transform: translateY(14px); } }
.mb-lyrics.closing { animation: lyrics-out .18s ease-in forwards; }
@keyframes lyrics-out { to { opacity: 0; transform: translateY(10px); } }
.mb-lyrics[hidden] { display: none; }
/* Крупный текст: панель переезжает в колонку справа от участников. Высота задана числом, а не
   min/max: в row-флекс с align-items:flex-start автовысота по содержимому схлопывалась до min-height.
   210px сверху и снизу резервируем на шапку комнаты и dock. */
.room-lyrics { flex: 1 1 0; min-width: 0; max-width: 820px; }
.room-lyrics .mb-lyrics {
  position: static; inset: auto; width: auto;
  min-height: 0; max-height: none;
  height: min(720px, calc(100dvh - 210px));
  font-size: calc(var(--lyr-size, 13.5px) + 3.5px);
}
.room-lyrics .ly-list { padding: 8px 24px 18px; }
.room-lyrics .ly-head { padding: 12px 14px 0 24px; }
.room-lyrics .ly-expand { width: 32px; height: 32px; }
.room-lyrics .ly-line { padding: 7px 0; }
.ly-line {
  margin: 0; padding: 3px 0; color: var(--muted); opacity: .75;
  transition: color .2s, opacity .2s, transform .2s var(--ease);
}
.ly-line.on { color: var(--text); opacity: 1; font-weight: 700; transform: translateX(2px); }
/* строка с таймкодом — это ещё и кнопка: клик перематывает к ней */
.ly-line[data-t] { cursor: pointer; touch-action: manipulation; }
.ly-line[data-t]:hover { color: var(--text); opacity: .95; }
.ly-line[data-t]:active { transform: translateX(2px); }
/* Текст без строчных таймкодов подсвечивать нечем: рисуем обычный читаемый блок, без «приглушённости». */
.ly-line.is-static { color: var(--text); opacity: .9; }
.ly-note { color: var(--muted); font-size: 12.5px; }
.mb-btn.is-on { background: var(--accent); color: var(--accent-ink); }

.mb-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 0; }
.mb-title {
  font-size: 14.5px; font-weight: 700; line-height: 1.25; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.1px;
}
.mb-sub {
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mb-progress { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0; margin-top: 1px; }
.mb-time {
  flex: none; font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 34px;
}
.mb-time:last-child { text-align: right; }
/* Перемотка. Элемент всегда 22px: hover ставил 6px и вся карточка проседала на 16px.
   Полоса и заполнение живут в треке, ползунок появляется только на наведении.
   .music-bar в селекторах нужен, чтобы перебить базовые input[type="range"]. */
.music-bar .mb-progress-input {
  flex: 1; min-width: 0; height: 22px; padding: 0; border: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; outline: none; background: transparent;
}
.music-bar .mb-progress-input::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--fill, 0%),
    var(--panel-3) var(--fill, 0%), var(--panel-3) 100%);
}
.music-bar .mb-progress-input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -3px;
  border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15), 0 1px 4px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity .15s;
}
.mb-progress:hover .mb-progress-input::-webkit-slider-thumb,
.mb-progress-input:focus::-webkit-slider-thumb { opacity: 1; }
.music-bar .mb-progress-input::-moz-range-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--fill, 0%),
    var(--panel-3) var(--fill, 0%), var(--panel-3) 100%);
}
.music-bar .mb-progress-input::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15); opacity: 0; transition: opacity .15s;
}
.mb-progress:hover .mb-progress-input::-moz-range-thumb,
.mb-progress-input:focus::-moz-range-thumb { opacity: 1; }
.mb-progress-input:disabled { opacity: 0.45; cursor: default; }
.mb-progress-input:disabled::-webkit-slider-thumb { display: none; }
.mb-progress-input:disabled::-moz-range-thumb { display: none; }

.mb-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding-top: 0; min-width: 0;
}
.mb-controls > * { flex: none; }
/* Громкость — единственное, что сжимается: даже на компакте (320px) в строке остаётся
   ~110px запаса, поэтому кнопки не переносятся и не обрезаются. */
.mb-controls .mb-vol { flex: 1 1 auto; min-width: 22px; max-width: 150px; }
.mb-sheet { animation: sheet-in .2s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.mb-btn {
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 50%; background: var(--panel-3); color: #ffffff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s, transform .15s var(--ease);
}
.mb-btn svg { width: 16px; height: 16px; }
.mb-btn:hover:not(:disabled) { background: var(--hover); transform: scale(1.08); }
.mb-btn:active:not(:disabled) { transform: scale(0.9); }
.mb-btn:disabled { opacity: 0.4; cursor: default; }
.mb-stop:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 22%, var(--panel-3)); }

.mb-play {
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%;
  background: #fff; color: #111;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  transition: transform .18s var(--ease);
}
/* Панель свёрнута: кнопка play переезжает в строку (тот же узел, обработчики не дублируем). */
.mb-row .mb-play { order: 3; width: 38px; height: 38px; }
.mb-row .mb-play svg { width: 18px; height: 18px; }
.mb-row .mb-play .ic-play { margin-left: 1px; }
.mb-play[hidden] { display: none; }
.mb-play:hover { transform: scale(1.08); }
.mb-play:active { transform: scale(0.94); }
.mb-play svg { width: 20px; height: 20px; }
.mb-play .ic-play { display: none; margin-left: 2px; }
.mb-play.is-paused .ic-play { display: block; }
.mb-play.is-paused .ic-pause { display: none; }

.mb-vol {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted);
}
.mb-vol svg { width: 15px; height: 15px; }
.music-vol {
  flex: 1 1 auto; width: 100%; min-width: 0; height: 18px;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.music-vol::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--panel-3); }
.music-vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4px;
  border-radius: 50%; background: var(--accent); border: 0;
}
.music-vol::-moz-range-track { height: 3px; border-radius: 2px; background: var(--panel-3); }
.music-vol::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--accent); }

@media (max-height: 620px) {
  /* Низкое окно: режем запас снизу и высоту панели текста, строку оставляем как есть. */
  .music-bar { bottom: 84px; }
  .mb-lyrics { min-height: 84px; max-height: 24vh; }
}

@media (max-width: 760px) {
  /* Узкое окно: полоса тянется на всю ширину, текст кладётся над кнопками. */
  .music-bar { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .mb-title { font-size: 14px; }
  .mb-sub { font-size: 11px; }
  .mb-btn { width: 36px; height: 36px; }
  .mb-play { width: 46px; height: 46px; }
  .wrap:has(#chat:not([hidden])) ~ .music-bar { display: none; }
  /* Узкое окно: отдельной колонки для текста нет, поэтому разворот недоступен. */
  .ly-head { display: none; }
}

@media (max-height: 480px) and (max-width: 760px) {
  /* Совсем низкое окно (телефон альбомом): минимум декора, чтобы текст не схлопнулся в 0px. */
  .mb-stack { gap: 4px; }
  .mb-sub { display: none; }
  .mb-art { width: 40px; height: 40px; }
  .mb-lyrics { min-height: 64px; max-height: 30vh; }
}

@media (max-width: 400px) {
  .mb-btn { width: 32px; height: 32px; }
  .mb-play { width: 42px; height: 42px; }
  .mb-controls { gap: 6px; }
}

/* ==== interface lock ==== */
body {
  --bg-1: #151515 !important; --bg-2: #101010 !important; --tint: #1c1c1c !important;
  --accent: #f2f2f2 !important; --accent-ink: #111111 !important; --accent-2: #bdbdbd !important;
}
#theme-grid, #theme-custom, .set-section:has(+ #theme-grid) { display: none; }
#bg-canvas { filter: grayscale(1); opacity: 0.85; }

/* ==== header ==== */
.head-actions { gap: 6px; }
.icon-btn { transition: background 0.15s, transform 0.2s var(--ease); }
.icon-btn:hover { background: var(--hover); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn svg { transition: transform 0.3s var(--ease); }
#open-settings:hover svg { transform: rotate(70deg); }

#status:empty, .count-chip:empty { display: none; }
#status { max-width: 40vw; }
.room-head .logo { flex: none; }
.head-actions { flex: none; }
#music-q { position: sticky; top: 0; z-index: 1; }

.modal-x { transition: background 0.15s, color 0.15s, transform 0.25s var(--ease); }
.modal-x:hover { transform: rotate(90deg); }
.music-row { transition: background 0.15s, border-color 0.15s, transform 0.15s var(--ease); }
.music-row:hover { transform: translateX(3px); }
.music-row:active { transform: scale(0.99); }
.music-qrow { animation: rise-in 0.2s ease-out; }
.primary { transition: background 0.15s, transform 0.12s var(--ease); }
.primary:active { transform: scale(0.98); }

@media (max-width: 1100px) {
  .wrap:has(#room:not([hidden])) .chat.card { height: auto; max-height: calc(100dvh - 58px); }
}
@media (max-width: 760px) {
  .wrap:has(#room:not([hidden])) .chat.card { height: auto; max-height: calc(100dvh - 52px); }
}

/* ==== Layout v2: full-width dock ==== */
.controls {
  align-self: stretch; margin: 0; padding: 10px 20px; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: color-mix(in srgb, var(--panel) 97%, transparent); backdrop-filter: blur(14px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.dock-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dock-voice { justify-self: start; }
.dock-media { justify-self: center; }
.dock-side { justify-self: end; }

.controls .mic-btn, .controls .vid-btn, .controls .dock-btn, .controls .leave-btn {
  position: relative; flex: none; width: auto; min-width: 70px; height: 60px; padding: 6px 12px; border-radius: 16px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
}
.controls .mic-btn { min-width: 84px; }
.controls .mic-btn svg, .controls .vid-btn svg, .controls .dock-btn svg, .controls .leave-btn svg { width: 22px; height: 22px; flex: none; }
.controls .lbl { font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; opacity: 0.9; white-space: nowrap; }
.controls .dock-btn { background: var(--panel-3); color: var(--text); }
.controls .dock-btn:hover { background: var(--hover); }
.dock-btn .unread { top: 7px; right: 14px; }
.controls .leave-btn { min-width: 74px; padding: 6px 16px; }
.dock-sep { width: 1px; height: 34px; background: var(--line); margin: 0 6px; }
body:has(#chat:not([hidden])) #open-chat,
body:has(#people-modal:not([hidden])) #open-people,
body:has(#music-modal:not([hidden])) #music,
body:has(#screen-menu:not([hidden])) #screen { background: var(--accent); color: var(--accent-ink); }
body:has(#settings-modal:not([hidden])) #open-settings { background: var(--accent); color: var(--accent-ink); }

@media (max-height: 640px) {
  .controls { padding: 6px 16px; }
  .controls .lbl { display: none; }
  .controls .mic-btn, .controls .vid-btn, .controls .dock-btn, .controls .leave-btn { height: 48px; min-width: 52px; }
  .controls .leave-btn { font-size: 0; }
}

@media (max-width: 900px) {
  .controls { padding: 8px 12px; gap: 8px; }
  .dock-group { gap: 6px; }
  .controls .mic-btn, .controls .vid-btn, .controls .dock-btn, .controls .leave-btn { min-width: 58px; padding: 6px 8px; }
  .controls .mic-btn { min-width: 68px; }
  .dock-sep { margin: 0 2px; }
}

@media (max-width: 760px) {
  .controls { grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); max-width: none; flex-wrap: nowrap; }
  .dock-group { display: contents; }
  .dock-sep { display: none; }
  .controls .mic-btn, .controls .vid-btn, .controls .dock-btn, .controls .leave-btn { width: 100%; min-width: 0; height: 58px; }
  .controls .leave-btn { padding: 6px 4px; font-size: 11.5px; }
}

@media (min-width: 1500px) {
  .room-body { padding: 36px 40px 12px; }
  .room-body .peers { max-width: 1240px; grid-template-columns: repeat(auto-fit, minmax(210px, 240px)); gap: 16px; }
  .wrap:has(#room:not([hidden])) .chat.card { flex-basis: 380px; max-width: 380px; }
  .controls { padding: 12px 28px; }
}
@media (hover: hover) {
  .controls .mic-btn:hover, .controls .vid-btn:hover, .controls .dock-btn:hover { transform: translateY(-3px); }
}

/* ==== Dock v3: floating pill (desktop) ==== */
@media (min-width: 761px) {
  .controls {
    display: flex; align-items: center; justify-content: center; gap: 0;
    align-self: center; margin: 8px 0 18px; padding: 8px 12px; max-width: calc(100vw - 24px);
    border: 1px solid var(--line); border-radius: 999px;
    background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  }
  .dock-group { gap: 8px; }
  .dock-group + .dock-group { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); }
  .dock-sep { display: none; }
  .dock-side .leave-btn { margin-left: 4px; }

  .controls .mic-btn, .controls .vid-btn, .controls .dock-btn {
    position: relative; width: 48px; min-width: 0; height: 48px; padding: 0; border-radius: 50%;
    flex-direction: row; gap: 0;
  }
  .controls .mic-btn { width: 54px; height: 54px; }
  .controls .mic-btn svg, .controls .vid-btn svg, .controls .dock-btn svg { width: 22px; height: 22px; }
  .controls .leave-btn {
    width: auto; min-width: 0; height: 48px; padding: 0 18px; border-radius: 999px;
    flex-direction: row; gap: 8px; font-size: 13.5px; font-weight: 600;
  }
  .controls .leave-btn svg { width: 18px; height: 18px; }
  .dock-btn .unread { top: 6px; right: 6px; }

  .controls .lbl {
    display: block; position: absolute; left: 50%; bottom: calc(100% + 12px); z-index: 5;
    transform: translate(-50%, 4px); padding: 5px 9px; border-radius: 8px;
    background: #000; border: 1px solid var(--line); color: #fff; opacity: 0; pointer-events: none;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    transition: opacity 0.15s, transform 0.18s var(--ease);
  }
  .controls button:hover .lbl, .controls button:focus-visible .lbl { opacity: 1; transform: translate(-50%, 0); }
  .controls .mic-btn:hover, .controls .vid-btn:hover, .controls .dock-btn:hover { transform: translateY(-2px); }
}
@media (min-width: 761px) and (max-height: 640px) {
  .controls { margin: 4px 0 10px; padding: 6px 10px; }
  .controls .mic-btn { width: 48px; height: 48px; }
  .controls .mic-btn, .controls .vid-btn, .controls .dock-btn, .controls .leave-btn { height: 44px; }
  .controls .vid-btn, .controls .dock-btn { width: 44px; }
}

/* ==== Top bar v3 ==== */
.room-head {
  height: 60px; padding: 0 20px; gap: 12px;
  background: transparent; backdrop-filter: none; border-bottom: 0;
}
.room-head .logo.small { font-size: 20px; letter-spacing: -0.4px; }
.count-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.count-chip::before {
  content: ""; width: 14px; height: 14px; background: currentColor; opacity: 0.7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center / contain no-repeat;
}
.head-actions {
  margin-left: auto; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.head-actions .icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; }
.head-actions .icon-btn:hover { background: var(--hover); }
.head-actions .icon-btn svg { width: 19px; height: 19px; }
.head-actions .lbl {
  position: absolute; left: 50%; top: calc(100% + 12px); z-index: 5; transform: translate(-50%, -4px);
  padding: 5px 9px; border-radius: 8px; background: #000; border: 1px solid var(--line); color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.15s, transform 0.18s var(--ease);
}
.head-actions .icon-btn:hover .lbl, .head-actions .icon-btn:focus-visible .lbl { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) {
  .room-head { height: 54px; padding: 0 12px; gap: 8px; }
  .head-actions .icon-btn { width: 38px; height: 38px; }
}
.head-actions .icon-btn:last-child .lbl { left: auto; right: 0; transform: translate(0, -4px); }
.head-actions .icon-btn:last-child:hover .lbl, .head-actions .icon-btn:last-child:focus-visible .lbl { transform: translate(0, 0); }
@media (max-width: 760px), (hover: none) { .head-actions .lbl { display: none; } }

/* ---- панели, которые можно двигать зажатием -------------------------------
   Смещение хранится в свойстве translate, а не в transform: тогда ему не мешают
   scale-анимации открытия окон, а окно не «прыгает» на первом кадре. */
.modal-head { padding-left: 16px; cursor: grab; }
.mb-row { padding-left: 24px; cursor: grab; }
@media (min-width: 761px) { .modal-head, .mb-row { touch-action: none; } }
.modal-head::before, .mb-row::before {
  content: ""; position: absolute; left: 4px; top: 50%; width: 7px; height: 11px; margin-top: -5.5px;
  background-image: radial-gradient(currentColor 1.05px, transparent 1.15px);
  background-size: 3.5px 3.7px; opacity: 0.25; pointer-events: none; transition: opacity 0.15s var(--ease);
}
.mb-row::before { left: 8px; }
.modal-head:hover::before, .mb-row:hover::before,
.modal-head:focus-visible::before, body.panel-dragging .modal-head::before, body.panel-dragging .mb-row::before { opacity: 0.7; }
.modal-head:focus-visible, .mb-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
body.panel-dragging { cursor: grabbing; user-select: none; }
body.panel-dragging .modal-head, body.panel-dragging .mb-row { cursor: grabbing; }
.is-dragging { will-change: translate; }
.is-dragging.settling { transition: translate 0.16s var(--ease); }
.modal-card.is-dragging { position: relative; transform: scale(1.004); box-shadow: 0 40px 100px rgba(0, 0, 0, 0.78); }
.music-bar.is-dragging { animation: none; }
.music-bar.is-dragging .mb-row, .music-bar.is-dragging .mb-sheet { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.is-dragging::after {
  content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none;
  background: var(--mag, none); opacity: 0; transition: opacity 0.12s linear;
}
.is-dragging.magging::after { opacity: 0.5; }
@media (prefers-reduced-motion: reduce) {
  .modal-head::before, .mb-row::before, .is-dragging::after { transition: none; }
  .is-dragging.settling { transition: none; }
}

/* Ручка заголовка: ::before с точками привязан к самой строке, без relative она улетала бы к окну. */
.modal-head { position: relative; }
.mb-row { position: relative; }

/* Постоянные части комнаты — логотип, пилюли «на связи»/«в комнате» и панель кнопок. Ручкой
   служит сам элемент, поэтому жест тот же, а вёрстка комнаты не перестраивается. */
#logo, #status, #peer-count, .controls { cursor: grab; }
#logo:focus-visible, #status:focus-visible,
#peer-count:focus-visible, .controls:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 10px; }
@media (min-width: 761px) { #logo, #status, #peer-count, .controls { touch-action: none; } }
body.panel-dragging #logo, body.panel-dragging #status,
body.panel-dragging #peer-count, body.panel-dragging .controls { cursor: grabbing; }
.controls { position: relative; }
/* На десктопе у пилюи есть своя полоса-ручка слева: точки не должны залезать на кнопку микрофона. */
@media (min-width: 761px) {
  .controls { padding-left: 26px; }
  .controls::before {
    content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 11px; margin-top: -5.5px;
    background-image: radial-gradient(currentColor 1.05px, transparent 1.15px);
    background-size: 3.5px 3.7px; opacity: 0.25; pointer-events: none; transition: opacity 0.15s var(--ease);
  }
  .controls:hover::before, .controls:focus-visible::before,
  body.panel-dragging .controls::before { opacity: 0.65; }
}
.controls.moved { z-index: 2; }
@media (prefers-reduced-motion: reduce) { .controls::before { transition: none; } }

/* ==== раздел «Что нового» в настройках ==== */
.news-list { display: flex; flex-direction: column; gap: 4px; }
.news-date { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.news-items { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.news-items li { position: relative; padding-left: 16px; font-size: 13.5px; line-height: 1.5; }
.news-items li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
.news-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* ==== роли комнаты ==== */
.role-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.role-chip {
  padding: 1px 7px; border: 1px solid currentColor; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 16px; letter-spacing: 0.02em;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.peer-roles, .pc-roles { display: flex; justify-content: center; }
.peer-roles:empty, .pc-roles:empty { display: none; }
.person .role-chips { margin-top: 4px; justify-content: flex-start; }
.person-actions button.is-on { border-color: var(--accent); color: var(--accent); }
/* Анкета переехала во вкладку настроек: карточка не тянется в высоту колонки, поле «о себе» не растёт. */
#set-pane-profile .pe-card { flex: none; }
#set-pane-profile > * { flex: none; }
#set-pane-profile { gap: 12px; }

/* ==== индикатор загрузки трека ==== */
.mb-dl {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); white-space: nowrap;
  animation: dl-pulse 1.4s ease-in-out infinite;
}
@keyframes dl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ==== drag-and-drop очереди ==== */
.music-qrow[draggable="true"] { cursor: grab; }
.music-qrow[draggable="true"]:active { cursor: grabbing; }
.music-qrow.drag-over { border-color: var(--accent); box-shadow: 0 -2px 0 0 var(--accent); }
.music-qrow.dragging { opacity: 0.4; }
