/* SoundChat — тёмная тема в стиле Discord (этап 1 редизайна, #20) */

/* ---------- шрифт Inter: локальные woff2, subsets latin + cyrillic ---------- */
/* Никаких внешних запросов — LAN работает офлайн. Fallback — системный стек. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- токены (палитра Discord dark) ---------- */

:root {
  /* поверхности */
  --rail: #1e1f22;     /* рельса серверов */
  --sidebar: #2b2d31;  /* сайдбар каналов */
  --chat: #313338;     /* основная область */
  --panel: #232428;    /* панель пользователя */
  --input: #383a40;    /* поле ввода (в чате) */
  --hover: #35373c;
  --active: #404249;

  /* текст */
  --txt-bright: #f2f3f5;
  --txt: #dbdee1;
  --txt-dim: #949ba4;
  --txt-label: #b5bac1;

  /* акценты */
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a55a;
  --green-btn: #248046;
  --red: #da373c;
  --red-hover: #a12828;
  --yellow: #f0b232;
  --secondary: #4e5058;
  --secondary-hover: #6d6f78;

  /* радиусы Discord: кнопки/инпуты/карточки 4px, модалки 5px */
  --radius: 5px;
  --radius-sm: 4px;

  /* сторона квадрата аватара в плитке (#25: меняется на мобиле/широких экранах) */
  --tile-media: 96px;
}

* { box-sizing: border-box; }

/* атрибут hidden должен побеждать любые display: flex и т.п. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--chat);
  color: var(--txt);
  font-family: "Inter", "-apple-system", "BlinkMacSystemFont", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* динамическая высота вьюпорта на мобильных (адресная строка не отрезает UI, #18 п.3) */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

/* формы не наследуют шрифт сами — форсируем */
button, input, select, textarea { font-family: inherit; }

/* универсальная клавиатурная фокусировка (п.1 #17) */
:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 1px;
}

/* ---------- SVG-иконки из спрайта ---------- */

.ico {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: none;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- оболочка Discord: рельса + сайдбар каналов + основная область ---------- */

.shell {
  display: flex;
  height: 100%;
}

/* основная область: lobby-состояние = предпросмотр канала, room-состояние = экран комнаты */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat);
}

.main > .screen {
  flex: 1;
  min-height: 0;
}

/* --- рельса: один «домашний» сервер --- */

.rail {
  flex: none;
  width: 72px;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 16px;
}

.rail-item {
  position: relative;
  flex: none;
}

/* белый индикатор-пилюля активного сервера (сервер у нас один — активен всегда) */
.rail-pill {
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 40px;
  border-radius: 0 4px 4px 0;
  background: #fff;
}

.rail-home {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 16px;
  background: var(--chat);
  color: var(--txt-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-radius 100ms, background 100ms, transform 100ms;
}

.rail-home .ico { width: 26px; height: 26px; }

/* при наведении «всплывает» и красится blurple, сквиркл поджимается — как у Discord */
.rail-home:hover {
  border-radius: 13px;
  background: var(--blurple);
  transform: scale(1.06);
}

.rail-sep {
  margin-top: auto;
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: #35363c;
}

/* --- сайдбар: поиск, каналы, недавние, панель пользователя --- */

.sidebar {
  flex: none;
  width: 240px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  flex: none;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.24); /* разделитель тенью, как у Discord */
  position: relative;
  z-index: 1;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 8px 4px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--rail);
}

.sidebar-search .ico {
  width: 15px;
  height: 15px;
  color: var(--txt-dim);
}

.sidebar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--txt);
  font-size: 13.5px;
  padding: 0;
}

.sidebar-search input:focus { outline: none; }

.sidebar-search input::placeholder { color: var(--txt-dim); }

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 8px;
}

/* категория: «ГОЛОСОВЫЕ КАНАЛЫ» / «НЕДАВНИЕ» (+ кнопка создания) */
.sidebar-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  padding: 10px 8px 2px;
}

.sidebar-cat span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--txt-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-plus {
  flex: none;
  position: relative;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.cat-plus .ico { width: 16px; height: 16px; }

/* тач-таргет ≥36px без роста визуального квадрата (паттерн угловых кнопок плиток) */
.cat-plus::after { content: ''; position: absolute; inset: -8px; }

.cat-plus:hover { color: #fff; background: var(--hover); }

.sidebar-empty {
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--txt-dim);
  font-style: italic;
}

/* строка канала: иконка + имя (БЕЗ «#» — иконка её заменяет) + счётчик.
   Одиночный клик = выбор (предпросмотр), двойной = вход. */
.channel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-dim);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.channel-row:hover { background: var(--hover); color: var(--txt-bright); }

/* выбранная (предпросмотр) и текущая (я в канале) */
.channel-row.selected { background: var(--active); color: var(--txt-bright); }

.channel-row-ico {
  flex: none;
  display: flex;
  color: var(--txt-dim);
}

.channel-row-ico .ico { width: 18px; height: 18px; }

.channel-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-row-count {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--txt-dim);
}

/* #22: «кто в канале» прямо в строке — стопка перекрывающихся аватарок
   (до 3), остаток — чипом «+N». Кружки в userColor, внутри — зверушка. */
.channel-row-members {
  flex: none;
  display: flex;
  align-items: center;
}

.channel-member {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-left: -6px; /* перекрытие: наезжаем на предыдущий кружок */
}

.channel-member:first-child { margin-left: 0; }

.channel-member-glyph { font-size: 12px; line-height: 1; }

.channel-members-more {
  flex: none;
  margin-left: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--txt-dim);
}

/* #61: колокольчик «тихий канал» на строке канала — глушит звуки событий и
   уведомления ЭТОГО канала (клик не выбирает канал — stopPropagation в app.js).
   Стиль сдержанный, как у замка: тихий — не ошибка, НЕ красный. */
.channel-bell {
  flex: none;
  position: relative;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.channel-bell .ico { width: 16px; height: 16px; }

/* тач-таргет ≥36px без роста визуального квадрата (паттерн cat-plus) */
.channel-bell::after { content: ''; position: absolute; inset: -5px; }

.channel-bell:hover { color: #fff; background: var(--hover); }

/* тихий канал: перечёркнутый колокол чуть приметнее обычного (состояние видно
   без наведения), но мягко — txt-label, не яркий */
.channel-row.is-muted .channel-bell { color: var(--txt-label); }

/* строки «НЕДАВНИХ» — компактнее */
.channel-row.channel-recent {
  height: 28px;
  font-size: 14px;
}

.history-clear {
  display: block;
  margin: 2px 8px 0;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: color 100ms, background 100ms;
}

/* ховер должен читаться как «это кнопка»: текст до яркого + плитка var(--hover) */
.history-clear:hover {
  color: var(--txt-bright);
  background: var(--hover);
}

/* затемнение под мобильной шторкой сайдбара; видимость — атрибутом hidden из JS */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 55;
  cursor: pointer;
}

/* --- панель пользователя (низ сайдбара) --- */

.user-panel {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 53px;
  padding: 0 8px;
  background: var(--panel);
}

.user-panel-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-panel-avatar {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--active); /* перекрывается userColor() из app.js */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.user-panel-glyph { font-size: 17px; line-height: 1; }

/* статус-точка: зелёная «в сети», жёлтая «подключение…» */
.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--panel);
  box-sizing: border-box;
  background: var(--yellow);
}

.status-dot.ok { background: var(--green); }

.status-dot.bad { background: var(--red); }

.user-panel-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.user-panel-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel-status {
  font-size: 12px;
  color: var(--txt-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel-actions {
  flex: none;
  display: flex;
  gap: 2px;
}

.up-btn {
  flex: none;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-label);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 100ms;
}

.up-ico { display: flex; }

.up-btn .ico { width: 18px; height: 18px; }

.up-btn:hover { color: var(--txt-bright); }

/* мьют/глушение — красная иконка (фон не трогаем, как у Discord) */
.up-btn.active { color: #f07075; }

/* --- предпросмотр канала (lobby-состояние основной области) --- */

.preview-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* полоска сверху с гамбургером — только на мобильном */
.preview-top {
  flex: none;
  display: none;
  align-items: center;
  min-height: 48px;
  padding: 0 8px;
  border-bottom: 1px solid #26272b;
}

/* гамбургеры — только в мобильной раскладке (см. media ниже).
   Специфичность выше .head-icon-btn: иначе его display:flex (объявлен позже
   в файле) перебивает display:none и кнопка торчит на десктопе */
.head-icon-btn.menu-btn { display: none; }

.menu-btn { color: var(--txt-dim); }

.preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 560px;
}

/* большой скруглённый квадрат с иконкой канала */
.preview-ico {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background: #4e5058;
  color: var(--txt-bright);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-ico .ico { width: 64px; height: 64px; }

.preview-title {
  margin: 24px 0 6px;
  font-size: 28px;
  font-weight: 800;
  color: var(--txt-bright);
  overflow-wrap: break-word;
}

.preview-sub {
  margin: 0;
  font-size: 16px;
  color: var(--txt-label);
}

/* #22: «В канале» — состав участников в предпросмотре, заглянуть без входа.
   Карточка предпросмотра центрирована, поэтому блоку нужен свой text-align. */
.preview-members {
  margin-top: 20px;
  width: min(360px, 100%);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--sidebar);
  text-align: left;
}

.preview-members-head {
  margin: 2px 4px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--txt-label);
}

.preview-member {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px; /* тач-таргет */
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.preview-member-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.preview-member-glyph { font-size: 15px; line-height: 1; }

.preview-member-name {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere; /* длинное имя не выпирает из блока */
}

.preview-actions {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-join {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--blurple);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

.preview-join:hover { background: var(--blurple-hover); }

.preview-join:disabled { opacity: 0.5; cursor: wait; }

/* #61: дублирующий переключатель «тихий канал» в предпросмотре — вторичная
   кнопка под «Присоединиться»; клик не входит в канал, только флаг */
.preview-mute {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px; /* тач-таргет */
}

.preview-mute .ico { width: 18px; height: 18px; }

.preview-error { min-height: 18px; margin: 0; }

/* ---------- комната: две колонки (голос + чат) ---------- */

#screen-room {
  flex-direction: row;
  align-items: stretch;
}

.room-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- текстовый чат (в стиле Discord) ---------- */

.chat-panel {
  position: relative;
  width: 360px;
  display: flex;
  flex-direction: column;
  background: var(--chat);
  border-left: 1px solid var(--rail);
}

/* на десктопе панель можно спрятать кнопкой чата (на мобильном — шторка, см. ниже) */
.chat-panel.closed { display: none; }

/* шапка панели: иконка канала + имя; X-закрывалка — только на мобильном */
.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid #26272b; /* разделитель Discord на #313338 */
}

/* X-закрытие шторки — только в мобильной раскладке (см. media ниже);
   id-селектор перебивает .head-icon-btn с его display:flex */
#chat-close { display: none; }

/* затемнение под мобильной шторкой чата; видимость — атрибутом hidden из JS */
.chat-backdrop {
  position: fixed;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 45;
  cursor: pointer;
}

.chat-header-ico {
  display: flex;
  color: var(--txt-dim);
}

.chat-room-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-bright);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
}

.msg {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 2px 16px;
}

.msg:hover { background: #2e3035; }

.msg-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-top: 2px;
}

.msg-avatar-glyph { font-size: 21px; line-height: 1; }

.msg-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.msg-head {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.msg-author { font-size: 16px; font-weight: 600; }

.msg-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
}

.msg-text {
  font-size: 15px;
  line-height: 1.375;
  color: var(--txt);
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

/* разметка сообщений (#29): **жирный**, *курсив*, ~~зачёркнутый~~, `код`,
   ```блок``` и ссылки — сдержанно, в духе Discord */
.msg-text strong { font-weight: 700; color: var(--txt-bright); }

.msg-text em { font-style: italic; }

.msg-text s { opacity: 0.6; }

.msg-text a {
  color: #00a8fc; /* голубой ссылок Discord */
  text-decoration: none;
}

.msg-text a:hover { text-decoration: underline; }

/* код: монопечать на тёмной подложке (инлайн и блок — одна семья) */
.msg-text .md-code,
.msg-text .md-pre {
  font-family: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  background: var(--rail);
  border-radius: 3px;
}

.msg-text .md-code {
  padding: 0 4px;
  font-size: 13px;
  line-height: 1.3;
}

/* блок кода ```…``` — переводов строк не бывает (сервер чистит \n), блок
   однострочный: капсула на всю ширину, длинная строка СКРОЛЛИТСЯ, а не мнёт
   layout (анормально длинные слова уже обрезаны рендером #29) */
.msg-text .md-pre {
  display: block;
  max-width: 100%;
  margin: 2px 0;
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1.35;
  overflow-x: auto;
  white-space: pre;
}

.msg-text .md-pre code {
  font-family: inherit;
  background: none;
  padding: 0;
}

/* спойлер ||…||: чёрная плашка до клика, текст под ней невидим и НЕ выделяется
   (подсмотреть выделением нельзя); раскрытие — класс .revealed из app.js,
   скрытое правило сильнее цвета ссылок (:.not поднимает специфичность) */
.msg-text .md-spoiler {
  padding: 0 2px;
  border-radius: 3px;
  background: #111214;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.msg-text .md-spoiler:not(.revealed),
.msg-text .md-spoiler:not(.revealed) * {
  color: transparent;
}

.msg-text .md-spoiler.revealed {
  background: var(--sidebar);
  user-select: text;
  -webkit-user-select: text;
}

/* группировка подряд идущих: аватар скрыт, но колонка сохранена — текст
   выровнен по колонке текста; при ховере в освободившемся гуттере — КОРОТКОЕ
   время «HH:MM» строго в колонке аватара: правый край 56px < 68px текста,
   полный формат («сегодня в 14:05», ~90px) наезжал на сообщения (#40) */
.msg.compact .msg-avatar { visibility: hidden; }

.msg.compact .msg-head {
  position: absolute;
  left: 16px;
  top: 0;
  visibility: hidden;
  padding: 0;
}

.msg.compact .msg-author { display: none; }
.msg.compact .msg-time { display: none; }
.msg.compact:hover .msg-head { visibility: visible; }

/* гуттер-время (#40): рендерится всегда рядом с .msg-time, включается CSS
   по .compact — regroup переключает классы без пересборки DOM. Внутри
   absolute-шапки (left:16px) координата left:0 = 16px ряда, width:40px =
   ширина аватара → правый край ровно 56px, до текста (68px) не достаёт;
   line-height как у .msg-text (15×1.375) и top:2px (= padding-top ряда) —
   строка времени ложится на первую строку текста */
.msg-time-gutter { display: none; }

.msg.compact .msg-time-gutter {
  display: block;
  position: absolute;
  left: 0;
  top: 2px;
  width: 40px;
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
  line-height: calc(15px * 1.375);
}

/* панель действий над сообщением (#27/#28): «Ответить» у любого, корзина —
   только у своих текущей сессии; на десктопе — по ховеру строки, на
   тач-экранах (hover:none) — всегда видима, но приглушена; тач-таргеты 36px.
   Клики ждут подтверждения сервером: сообщение уберёт delete{id}. */
.msg-actions {
  position: absolute;
  top: 0;
  right: 10px;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--chat);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none; /* невидимая не ловит клики */
  z-index: 2;
}

.msg:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.msg-act {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--txt-dim);
  cursor: pointer;
}

.msg-act .ico { width: 17px; height: 17px; }

.msg-act:hover { background: #3f4147; color: var(--txt); }

@media (hover: none) {
  /* тач: ховера нет — панель всегда доступна (приглушена), тач-таргеты 36px;
     текст сообщений не подлезает под неё отступом справа */
  .msg-actions { opacity: 0.6; pointer-events: auto; }
  .msg-act { width: 36px; height: 36px; }
  .msg-text { padding-right: 96px; }
  .msg.own .msg-text { padding-right: 132px; }
}

/* хвостик-цитата ответа (#27): имя автора оригинала в его цвете, сниппет с
   многоточием; клик — прыжок к оригиналу; оригинал удалён — приглушён */
.msg-reply {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  padding: 1px 0 2px;
  border: none;
  background: none;
  color: var(--txt-dim);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.msg-reply-ico { display: flex; flex: none; }
.msg-reply-ico .ico { width: 14px; height: 14px; }

.msg-reply-name {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.msg-reply-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-reply:hover { color: var(--txt); }

.msg-reply.orphan { opacity: 0.55; cursor: default; }
.msg-reply.orphan:hover { color: var(--txt-dim); }

/* вспышка оригинала при прыжке по хвостику (background-переход — не движение) */
.msg { transition: background 150ms; }
.msg.flash { background: rgba(88, 101, 242, 0.18); }

/* реакции (#26): пилюли «эмодзи N» под текстом, своя подсвечена рамкой
   blurple; тултип (title) — кто поставил */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 3px;
}

.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #2b2d31;
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.msg-reaction-emoji { font-size: 15px; line-height: 1; }

.msg-reaction:hover { background: #3f4147; }

.msg-reaction.mine {
  border-color: var(--blurple);
  background: rgba(88, 101, 242, 0.16);
  color: #dee0fc;
}

@media (hover: none) {
  .msg-reaction { min-height: 36px; }
}

/* панель выбора реакции у конкретного сообщения (#26): те же 20 смайликов;
   по умолчанию — вниз от кнопки (у верхней кромки ленты), класс up — вверх */
.react-panel {
  position: absolute;
  top: 38px;
  right: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--sidebar);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 35;
}

.react-panel.up { top: auto; bottom: calc(100% + 2px); }

.react-panel button {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 21px;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.2;
}

.react-panel button:hover { background: #3f4147; }

/* системные («вошёл/вышел») — по центру с маленькой иконкой */
.msg-sys {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px;
  font-size: 12px;
  color: var(--txt-dim);
  overflow-wrap: break-word;
  text-align: center;
}

.msg-sys-ico { display: flex; }

.msg-sys-ico .ico { width: 14px; height: 14px; }

/* пилюля «↓ новые» над инпутом */
.chat-jump {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 6px;
  padding: 5px 12px;
  border: none;
  border-radius: 999px;
  background: var(--blurple);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-jump .ico { width: 14px; height: 14px; }

.chat-jump:hover { background: var(--blurple-hover); }

/* капсула-цитата «Ответ Имени: сниппет…» над инпутом (#27); крестик снимает */
.chat-reply {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 8px;
  background: var(--input);
  color: var(--txt-dim);
  font-size: 13px;
}

.chat-reply > .ico { width: 15px; height: 15px; flex: none; }

.chat-reply-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-reply-name { font-weight: 600; }

.chat-reply .chat-icon-btn { width: 26px; height: 26px; flex: none; }
.chat-reply .chat-icon-btn .ico { width: 15px; height: 15px; }

/* капсула «Редактирование: текст…» над инпутом (#50) — паттерн ответа (#27);
   основной инпут подставлен текущим текстом сообщения */
.chat-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 8px;
  background: var(--input);
  color: var(--txt-dim);
  font-size: 13px;
}

.chat-edit > .ico { width: 15px; height: 15px; flex: none; }

.chat-edit-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-edit-name { font-weight: 600; }

.chat-edit .chat-icon-btn { width: 26px; height: 26px; flex: none; }
.chat-edit .chat-icon-btn .ico { width: 15px; height: 15px; }

/* пометка «(изменено)» у времени (#50): в свёрнутой группе видна по ховеру
   вместе со скрытой шапкой (.msg.compact:hover .msg-head, #40) */
.msg-edited {
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
}

/* индикатор «печатает…» (#49): строка фиксированной высоты над инпутом —
   текст появляется/исчезает БЕЗ сдвига layout (место зарезервировано всегда);
   имена — в userColor автора, точки «дышат» (кроме reduced-motion) */
.chat-typing {
  height: 18px;
  margin: 0 16px 2px;
  padding: 0 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--txt-dim);
  font-size: 12px;
  line-height: 18px;
}

.chat-typing b { font-weight: 600; }

.chat-typing .typing-dots { margin-left: 1px; }

.chat-typing .typing-dots i {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-left: 2px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.chat-typing .typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .typing-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing .typing-dots i { animation: none; }
}

/* инпут: сама форма — скруглённый контейнер #383a40 с круглыми кнопками по краям */
.chat-form {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 16px 16px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--input);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 4px;
  border: none;
  background: transparent;
  color: var(--txt);
  font-size: 15px;
}

.chat-form input:focus { outline: none; }

.chat-form input::placeholder { color: var(--txt-dim); }

.chat-icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--txt-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 100ms, background 100ms;
}

.chat-icon-btn .ico { width: 21px; height: 21px; }

.chat-icon-btn:hover { color: var(--txt-bright); }

#chat-send:hover { color: var(--blurple); }

/* бейдж непрочитанных на кнопке чата в шапке — красная пилюля Discord */
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px var(--chat);
}

/* панель смайликов — над инпутом */
.emoji-panel {
  position: absolute;
  right: 16px;
  bottom: 72px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--sidebar);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.emoji-panel button {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 21px;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.2;
}

.emoji-panel button:hover { background: #3f4147; }

/* ---------- список участников (#48): колонка справа, на мобиле — шторка ---------- */

/* колонка правее чат-панели, фон сайдбара — как member list у Discord */
.member-panel {
  flex: none;
  width: 240px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar);
  border-left: 1px solid var(--rail);
}

/* на десктопе колонку можно спрятать кнопкой участников (на мобиле — шторка, см. media) */
.member-panel.closed { display: none; }

/* шапка — по образцу шапки чат-панели */
.member-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid #26272b;
}

.member-header-ico { display: flex; color: var(--txt-dim); }

.member-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-bright);
}

/* X-закрытие шторки — только в мобильной раскладке (паттерн #chat-close);
   id-селектор перебивает .head-icon-btn с его display:flex */
#member-close { display: none; }

/* затемнение под мобильной шторкой участников; видимость — атрибутом hidden из JS */
.member-backdrop {
  position: fixed;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 45;
  cursor: pointer;
}

.member-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

/* группа «В ГОЛОСЕ — N» — категория как в сайдбаре (верхний регистр — CSS) */
.member-group {
  margin: 10px 8px 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--txt-label);
}

/* строка участника: аватар-зверь в userColor + точка-статус + имя цветом;
   клик — карточка профиля (#47); тач-таргет ≥40px (#18) */
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.member:hover { background: var(--hover); }

.member-avatar {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.member-glyph { font-size: 17px; line-height: 1; }

/* точка-статус у аватара — паттерн панели пользователя; семантика та же, что
   точка у имени в плитке: зелёная ок, жёлтая «нет звука»/«соединение…», красная обрыв */
.member-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--sidebar);
  box-sizing: border-box;
  background: var(--yellow);
}

.member-dot.ok { background: var(--green); }

.member-dot.bad { background: var(--red); }

.member-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* мини-иконки статусов рядом с именем — те же .flag, что у плиток */
.member-flags { flex: none; display: inline-flex; align-items: center; gap: 3px; }

/* ---------- кнопки (стиль Discord: primary/secondary/danger) ---------- */

/* primary — blurple */
#join-btn,
#create-btn,
#unblock-btn,
.vt-primary {
  border: none;
  border-radius: var(--radius-sm);
  background: var(--blurple);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

#join-btn:hover,
#create-btn:hover,
#unblock-btn:hover,
.vt-primary:hover:not(:disabled) { background: var(--blurple-hover); }

#join-btn:disabled,
#create-btn:disabled { opacity: 0.5; cursor: wait; }

/* danger — красная (стоп проверки, разрушительные действия) */
#vt-start-btn.running {
  background: var(--red);
}

#vt-start-btn.running:hover:not(:disabled) { background: var(--red-hover); }

.secondary-btn {
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

.secondary-btn:hover { background: var(--secondary-hover); }

/* ---------- экран входа ---------- */

#screen-join {
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(1100px 700px at 15% -10%, rgba(88, 101, 242, 0.16), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(88, 101, 242, 0.08), transparent 55%),
    var(--chat);
}

.join-card {
  background: var(--rail);
  border-radius: var(--radius);
  padding: 32px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* логотип: наушники в blurple-кружке */
.join-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--blurple);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-logo .ico { width: 36px; height: 36px; }

.join-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--txt-bright);
}

.tagline {
  margin: 0 0 24px;
  color: var(--txt-label);
  font-size: 16px;
}

#join-form { display: flex; flex-direction: column; gap: 10px; }

/* лейблы форм — как у Discord: UPPERCASE 12px bold */
#join-form label,
.vt-field {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--txt-label);
}

#name-input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--active);
  background: var(--sidebar);
  color: var(--txt);
  font-size: 16px;
}

#name-input:focus { border-color: var(--blurple); }

#join-btn {
  padding: 12px;
  margin-top: 6px;
  width: 100%;
}

/* выбор аватарки */
.avatar-picker {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.avatar-opt {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid transparent;
  background: var(--sidebar);
  font-size: 26px;
  cursor: pointer;
  transition: transform 100ms, border-color 100ms, background 100ms;
  padding: 0;
  line-height: 1;
}

.avatar-opt:hover { transform: scale(1.12); background: var(--hover); }

.avatar-opt.selected {
  border-color: var(--blurple);
  background: var(--active);
  transform: scale(1.12);
}

.error {
  /* осветлённый красный: #da373c на тёмной карточке мелким кеглем читается плохо */
  color: #f07075;
  font-size: 13px;
  font-weight: 500;
  margin: 4px 0 0;
}

/* ---------- проверка микрофона ---------- */

.mic-test {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.mic-test .secondary-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mic-test-status {
  margin: 0;
  font-size: 12.5px;
  color: var(--txt-dim);
  text-align: left;
}

.mic-test-status.warn { color: var(--yellow); }

/* окно проверки звука */
.voice-test {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.vt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vt-field select {
  background: var(--rail);
  color: var(--txt);
  border: 1px solid var(--active);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 500;
  text-transform: none; /* лейбл капсом, содержимое — как есть */
}

.vt-buttons {
  display: flex;
  gap: 10px;
}

.vt-buttons button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--secondary); /* «Отмена» и прочие без явного цвета */
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

.vt-buttons button:hover:not(:disabled) { background: var(--secondary-hover); }

.vt-buttons button:disabled { opacity: 0.5; cursor: default; }

#vt-start-btn {
  background: var(--blurple);
  color: #fff;
}

#vt-start-btn:hover:not(:disabled) { background: var(--blurple-hover); }

#vt-loop-btn {
  background: var(--secondary);
  color: #fff;
}

#vt-loop-btn:hover:not(:disabled) { background: var(--secondary-hover); }

.vt-note {
  margin: 0;
  font-size: 12px;
  color: var(--txt-dim);
  text-align: center;
}

/* окно выбора клавиши PTT */
.ptt-capture {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.ptt-capture-hint {
  margin: 0;
  font-size: 13px;
  color: var(--txt-dim);
}

.ptt-capture-key {
  padding: 18px 10px;
  border-radius: var(--radius-sm);
  background: var(--rail);
  border: 2px dashed var(--active);
  font-size: 20px;
  font-weight: 600;
  color: var(--txt);
}

.ptt-capture-key.captured {
  border-color: var(--green);
  border-style: solid;
  color: var(--green);
}

/* индикатор уровня (полоска) */
.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--rail);
  border: 1px solid var(--active);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green) 0%, var(--green) 60%, var(--yellow) 80%, var(--red) 100%);
  transition: width 90ms linear;
}

.hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--txt-dim);
}

/* ---------- комната ---------- */

/* шапка как у Discord-канала: иконка канала + имя + подстрока-статус */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  min-height: 48px;
  padding: 0 8px 0 12px;
  background: var(--chat);
  border-bottom: 1px solid #26272b; /* разделитель Discord на #313338 */
}

.room-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.room-head-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--active);
  color: var(--txt);
}

.chip-ok { color: var(--green); }
.chip-warn { color: var(--yellow); }
.chip-bad { color: #f07075; }

/* иконки-кнопки в шапке (настройки, чат, закрыть) */
.head-icon-btn {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt-label);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 100ms, color 100ms;
}

.head-icon-btn:hover { background: var(--hover); color: var(--txt-bright); }

/* тост-капсула («Ссылка скопирована», #15): тёмная капсула как у Discord-тостов,
   по центру над плавающей пилюлей; не ловит клики и не перетаскивает фокус */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px; /* над пилюлей управления (desktop: 24px + высота пилюли) */
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(88vw, 420px);
  padding: 9px 16px;
  border-radius: 999px;
  background: #111214;
  color: var(--txt-bright);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* ---------- карточка профиля (#47): синглтон-поповер ---------- */

/* z-index 70: над мобильными шторками чата (50) и сайдбара (60), под
   модалками (100) — карточка живёт в комнате/лобби поверх основной области */
.profile-card {
  position: fixed;
  z-index: 70;
  width: min(300px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  background: var(--sidebar);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* баннер-полоса цветом пользователя */
.profile-banner {
  height: 60px;
  background: var(--active); /* перекрашивается userColor() из app.js */
}

/* большой аватар-зверь, наполовину заезжает на баннер (как в Discord) */
.profile-avatar {
  margin: -34px 0 0 14px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 5px solid var(--sidebar);
  background: var(--active); /* перекрашивается userColor() */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.profile-avatar-glyph { font-size: 40px; line-height: 1; }

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 14px;
}

.profile-name {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--txt-bright); /* перекрашивается userColor() */
  overflow-wrap: break-word;
}

.profile-status {
  margin: -2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
}

/* точка в карточке — статичная (глобальная .status-dot абсолютна: стоит в
   аватаре панели пользователя); цвет — теми же классами ok/bad */
.profile-status .status-dot {
  position: static;
  flex: none;
  width: 9px;
  height: 9px;
  border: none;
}

.profile-bio {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.profile-bio-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--txt-label);
}

/* текст bio — plain text (textContent в app.js, никакого HTML) */
.profile-bio-text {
  margin: 0;
  font-size: 14px;
  color: var(--txt);
  overflow-wrap: break-word;
}

.profile-room {
  margin: 0;
  font-size: 12.5px;
  color: var(--txt-dim);
}

/* «Выключить звук» — плоская кнопка с рамкой, тач-таргет ≥36px (#18) */
.profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 2px;
  padding: 7px 10px;
  border: 1px solid var(--active);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.profile-btn:hover { background: var(--hover); color: var(--txt-bright); }

/* замьюченный собеседник — перечёркнутый динамик красным (паттерн плитки) */
.profile-btn.muted { color: #f07075; }

.profile-btn-ico { display: flex; }

.profile-btn-ico .ico { width: 17px; height: 17px; }

/* якоря открытия карточки: имя/аватар в чате, плитке, предпросмотре, панели */
.profile-open { cursor: pointer; }

.user-panel-info { cursor: pointer; border-radius: var(--radius-sm); }

.user-panel-info:hover { background: var(--hover); }

/* квадратик-заглушка канала, как иконка голосового канала у Discord */
.channel-ico {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #4e5058;
  color: var(--txt-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-ico .ico { width: 19px; height: 19px; }

.room-titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.25;
}

.room-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* #conn-chip: в него пишет setChip (источник правды о статусе соединения),
   визуально статус дублируется в .room-sub — сам чип скрыт */
#conn-chip { display: none; }

/* ---------- сцена комнаты: плитки + плавающая пилюля ---------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tiles {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 24px 32px;
  padding: 24px 24px 120px; /* снизу запас под плавающую пилюлю */
  overflow-y: auto;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 150px;
  user-select: none;
}

/* медиа-контейнер плитки (#25): аватар-заглушка ИЛИ видео; угловые кнопки
   позиционируются относительно него. Без видео — квадрат --tile-media,
   с видео — прямоугольник на всю ширину плитки (4:3). */
.tile-media {
  position: relative;
  flex: none;
  width: var(--tile-media);
  height: var(--tile-media);
}

.avatar {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--active); /* перекрывается userColor() из app.js */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 3px solid transparent;
  transition: border-color 120ms;
}

/* кольцо «говорит» — зелёное 3px */
.tile.speaking .avatar { border-color: var(--green); }

/* аватар-животное — в собственном элементе-глифе */
.avatar-glyph {
  font-size: 46px;
  line-height: 1;
}

/* круглая кнопка в углу аватара: свой микрофон / локальный мьют собеседника.
   Тач-таргет 36px (#18); фон #232428, при мьюте — красный #da373c */
.tile-btn {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel);
  border: 4px solid var(--chat);
  color: var(--txt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 100ms, background 100ms;
}

.tile-btn .ico { width: 15px; height: 15px; }

.tile-btn:hover { transform: scale(1.12); }

.tile-btn.muted { background: var(--red); color: #fff; }

/* вторая угловая кнопка (мьют камеры у себя) — правый ВЕРХНИЙ угол (#25) */
.tile-btn.tr { right: -3px; top: -3px; bottom: auto; }

/* ---------- видео в плитках (#25) ---------- */

/* видео пира/своё: вписано кропом, muted+playsinline ставит app.js (звук едет
   отдельным аудиопутём — иначе эхо; muted заодно снимает проблему автоплея) */
.tile-video {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  border: 3px solid transparent;
}

.tile.has-video .tile-media {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.tile.has-video .tile-video { display: block; }

/* аватар остаётся заглушкой, пока камеры нет */
.tile.has-video .avatar { display: none; }

/* кольцо «говорит» остаётся и на видео */
.tile.speaking .tile-video { border-color: var(--green); }

/* своё видео — зеркальное превью, как в Discord */
.tile-video.mirror { transform: scaleX(-1); }

/* клик по видео-плитке = фокус-режим */
.tile.has-video .tile-media { cursor: pointer; }

/* мьют СВОЕЙ камеры (enabled=false — у пиров просто чёрный кадр): клиент знает
   своё состояние — поверх видео заглушка с аватаром (порядок правил важен:
   cam-muted перебивает has-video одинаковой специфичности) */
.tile.cam-muted .tile-media { width: var(--tile-media); height: var(--tile-media); aspect-ratio: auto; }
.tile.cam-muted .tile-video { display: none; }
.tile.cam-muted .avatar { display: flex; }

/* ---------- фокус-режим (#25): выбранный крупно, остальные — мини-строкой ---------- */

/* кнопка «вернуться к сетке» в правом верхнем углу сцены */
.focus-exit {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  background: var(--chat);
}

.tiles.focus {
  flex-wrap: nowrap;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tiles.focus .tile.focused {
  order: 1; /* большое видео сверху, мини-строка — ПОД ним, как в Discord
                (своя плитка prepend'ом первая в DOM — order выправляет порядок) */
  width: min(100%, 960px, calc((100dvh - 280px) * 4 / 3));
}

.tiles.focus .tile.mini {
  order: 2;
  flex-direction: row;
  width: auto;
  max-width: 90%;
  gap: 10px;
}

.tiles.focus .tile.mini .tile-media { width: 120px; }
.tiles.focus .tile.mini:not(.has-video) .tile-media { width: var(--tile-media); height: var(--tile-media); }
.tiles.focus .tile.mini .meter { display: none; }
.tiles.focus .tile.mini .name { max-width: 160px; }

/* имя + мини-индикаторы статусов рядом */
.tile-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
}

.tile .name {
  font-size: 15px;
  font-weight: 600;
  color: var(--txt-bright);
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-flags { display: inline-flex; align-items: center; gap: 3px; }

/* mic-off/headphones-off при мьюте/глушении — красные */
.flag { display: inline-flex; color: #f07075; }

/* зелёный «демонстрирует экран» у имени (#10) */
.flag-green { color: var(--green); }

.flag .ico { width: 14px; height: 14px; }

/* точка соединения собеседника: зелёная ок, жёлтая «нет звука», красная обрыв */
.tile .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
}

.tile .dot.ok { background: var(--green); }
.tile .dot.warn { background: var(--yellow); }
.tile .dot.bad { background: var(--red); }

/* полоска уровня — тонкая и неброская: 4px, заполнение #23a55a */
.tile .meter {
  width: 96px;
  height: 4px;
  background: var(--input);
  border: none;
  border-radius: 2px;
}

.tile .meter i {
  background: var(--green);
  border-radius: 2px;
}

/* ---------- демонстрация экрана (#10): карточки в основной области ---------- */

/* область демонстраций занимает основную сцену ВМЕСТО плиток (автопереключение
   при старте демонстрации + чип #btn-view в шапке; [hidden] побеждает всё —
   глобальное правило в начале файла) */
.screens {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 20px 28px;
  padding: 24px 24px 120px; /* снизу запас под плавающую пилюлю */
  overflow-y: auto;
}

.screen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(100%, 640px);
  min-width: 280px;
  user-select: none;
}

.screen-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid transparent;
  cursor: pointer; /* клик — укрупнить (фокус демонстрации, #10) */
}

/* экран НЕ кропаем (в отличие от камеры): контент демонстрации — текст,
   графики — должен быть читаем целиком; muted+playsinline ставит app.js */
.screen-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* подпись «Экран · Имя»: имя цветом пользователя, у себя — «Вы» */
.screen-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt-dim);
}

.screen-name-user { color: var(--txt-bright); /* перекрашивается userColor() из app.js */ }

/* фокус демонстрации: выбранная карточка крупно, остальные — мини-строкой
   (по образцу фокус-режима плиток #25; выход — повторный клик/#focus-exit) */
.screens.focus {
  flex-wrap: nowrap;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screens.focus .screen-card.focused {
  order: 1; /* крупный экран сверху, мини-строка — ПОД ним */
  width: min(100%, 1280px, calc((100dvh - 280px) * 16 / 9));
}

.screens.focus .screen-card.mini {
  order: 2;
  flex-direction: row;
  width: auto;
  max-width: 90%;
  gap: 10px;
}

.screens.focus .screen-card.mini .screen-media { width: 160px; }
.screens.focus .screen-card.mini .screen-name { white-space: nowrap; }

/* PTT-подсказка — маленькая строка над пилюлей */
.ptt-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-dim);
  pointer-events: none;
}

/* плавающая пилюля управления по центру внизу основной области */
.controls {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 999px;
  background: var(--rail);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pill-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--txt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 100ms, color 100ms;
}

.pill-btn .ico { width: 20px; height: 20px; }

.pill-btn:hover { background: var(--hover); color: var(--txt-bright); }

/* мьют/глушение: иконка перечёркнута, фон кнопки НЕ красный (красный — только disconnect) */
.pill-btn.active { color: #f07075; }

.pill-sep {
  flex: none;
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: #35373c;
}

.pill-danger { background: var(--red); color: #fff; }

.pill-danger:hover { background: var(--red-hover); color: #fff; }

/* ---------- саундборд (#54): панель звуков над пилюлей ---------- */

/* поповер-панель над пилюлей (absolute внутри .controls — bottom:100%).
   Сетка «эмодзи + подпись» по образцу панели эмодзи (#26); на узких экранах
   не вылезает за вьюпорт (width min(...)) */
.soundboard-panel {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  width: min(372px, calc(100vw - 24px));
  background: var(--sidebar);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

/* плитка звука: эмодзи + подпись, тач-таргет заметно больше 36px (#18) */
.sb-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 58px;
  padding: 8px 4px 6px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 0;
}

.sb-tile:hover { background: #3f4147; }

.sb-emoji { font-size: 22px; line-height: 1.2; }

.sb-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--txt-dim);
}

/* кулдаун 3с: плитки приглушены, клики тихо игнорируются (pointer-events
   живы — клик просто ни к чему не приводит) */
.soundboard-panel.cooldown .sb-tile { opacity: 0.5; }

/* пилюля «кто запустил звук» внизу плитки поверх .tile-media: имя цветом
   userColor (app.js) + эмодзи звука; pointer-events:none — не крадёт клики
   по видео (фокус-режим #25) и угловые кнопки; правый край освобождён под
   угловую кнопку mic/speaker */
.tile-sb-pill {
  position: absolute;
  left: 2px;
  right: 34px;
  bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 11px;
  line-height: 1.2;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

.tile-sb-pill b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

/* мини-плитки фокус-режима (#25) слишком малы для пилюли */
.tiles.focus .tile.mini .tile-sb-pill { display: none; }

/* ---------- оверлеи (модалки в стиле Discord) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.overlay-card {
  position: relative;
  background: var(--chat);
  border-radius: var(--radius);
  padding: 24px 28px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* заголовок модалки: слева иконка, 20px/700 */
.overlay-card h2 {
  margin: 0 0 4px;
  padding-right: 36px; /* не наезжать на крестик */
  font-size: 20px;
  font-weight: 700;
  color: var(--txt-bright);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ico-h2 { width: 24px; height: 24px; }

/* крестик в правом верхнем углу — закрывает те же обработчики, что и «Закрыть/Отмена» */
.overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--txt-label);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.overlay-close .ico { width: 18px; height: 18px; }

.overlay-close:hover { background: var(--hover); color: var(--txt-bright); }

.overlay-msg {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  color: var(--txt-bright);
}

#unblock-btn {
  margin-top: 14px;
  padding: 11px 24px;
}

#fatal-msg { color: var(--txt-bright); margin: 0; }

/* ---------- модалка настроек ---------- */

.settings-card {
  width: min(440px, 100%);
  /* карточка с «Профилем» (#47) + превью камеры выше вьюпорта на низких
     экранах — оверлей фиксирован и не скроллится, поэтому скроллится сама
     карточка (иначе нижние кнопки/крестик становились некликабельны) */
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.settings-card select { width: 100%; }

.settings-ptt {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-check {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--txt);
  cursor: pointer;
}

.settings-check input { accent-color: var(--blurple); }

/* громкость саундборда (#54): подпись не растягивается (flex:none у
   .settings-check), ползунок забирает остаток, справа — проценты/«выкл» */
.settings-volume input[type='range'] {
  flex: 1;
  min-width: 0;
  accent-color: var(--blurple);
}

.settings-volume .settings-check { flex: none; }

.settings-volume-val {
  min-width: 38px;
  text-align: right;
  font-size: 12px;
  color: var(--txt-dim);
}

.settings-card .secondary-btn { padding: 10px 12px; }

/* раздел «Камера» (#25): селект устройства + живое зеркальное превью */
.settings-cam {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cam-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: #000;
  object-fit: cover;
  transform: scaleX(-1); /* превью всегда своё — зеркалим, как в плитке */
}

.settings-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* раздел «Профиль» в настройках (#47): textarea «О себе» + счётчик символов */
.settings-profile {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* имя+аватар на лету (#34): блок живёт только в комнате (в лобби — экран входа) */
.settings-rename {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--active);
}

.rename-error {
  margin: 0;
}

.bio-input {
  resize: none;
  min-height: 66px;
  line-height: 1.35;
}

.bio-counter {
  margin: 0;
  text-align: right;
  font-size: 11px;
  color: var(--txt-dim);
}

/* danger в варианте secondary-кнопки (Discord: красная плоская кнопка в футере модалки) */
.danger-secondary {
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

.danger-secondary:hover { background: var(--red-hover); }

/* ---------- модалка «Создать канал» ---------- */

#create-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

#create-password-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--active);
  background: var(--rail);
  color: var(--txt);
  font-size: 14px;
  width: 100%;
}

.line-input:focus { border-color: var(--blurple); }

/* ---------- тип канала: ЯВНЫЙ выбор из двух строк-радио (#60) ----------
   Раньше «Голосовой» был молчаливым дефолтом выключенного свитка. Выбранная
   строка — фон --active, паттерн выбранного канала сайдбара; кружок радио —
   blurple. Инпут накрывает ВСЮ строку — клик в любое место выбирает вариант
   (паттерн .switch input), нативные радио дают и клавиатуру (стрелки). */
.type-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.type-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--txt-label);
}

.type-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.type-row:hover { background: var(--hover); }

.type-row.selected { background: var(--active); }
.type-row.selected .switch-row-text { color: var(--txt-bright); }
.type-row.selected .ico { color: var(--txt); }

.type-row .ico {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--txt-dim);
}

.type-row input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  border-radius: var(--radius-sm); /* фокус-кольцо повторяет форму строки */
  cursor: pointer;
  z-index: 1;
}

.type-radio {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--txt-dim);
  border-radius: 50%;
  transition: border-color 100ms;
}

.type-radio::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blurple);
  transform: scale(0);
  transition: transform 100ms ease;
}

.type-row.selected .type-radio { border-color: var(--blurple); }
.type-row.selected .type-radio::after { transform: scale(1); }

/* строка «Личный канал» со свитчем Discord: текст слева, переключатель справа */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.switch-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt);
  transition: color 100ms;
}

.switch-row-text small {
  font-weight: 400;
  font-size: 12px;
  color: var(--txt-dim);
}

.switch-row:hover .switch-row-text { color: var(--txt-bright); }

/* сам свитч: чекбокс визуально скрыт, но остаётся поверх трека — клики
   попадают в него (и в label вокруг), трек рисует <i> */
.switch {
  position: relative;
  flex: none;
  display: inline-block;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch i {
  position: relative;
  display: block;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: #80848e;
  transition: background 150ms ease;
}

/* белый knob — псевдоэлемент трека */
.switch i::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 150ms ease;
}

.switch input:checked + i { background: var(--blurple); }

.switch input:checked + i::after { left: 18px; }

.remember-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--txt-label);
  cursor: pointer;
}

.remember-label input { accent-color: var(--blurple); }

#create-btn {
  padding: 12px;
}

/* окно пароля комнаты */
.room-pass {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.room-pass-name {
  margin: -4px 0 0;
  color: var(--txt-dim);
  font-size: 14px;
}

#room-pass-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#room-pass-form .vt-field {
  gap: 6px;
}

/* ---------- мобильная версия ---------- */

/* уважаем настройку «уменьшить движение»: остаёмся на месте без анимаций */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 760px) {
  /* чат — шторка во всю высоту с собственной шапкой и X-закрытием (#12);
     слева затемнение-Backstage, тап по нему закрывает */
  .chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(90vw, 400px); /* слева остаётся полоса затемнения — тап по ней закрывает */
    z-index: 50;
    transform: translateX(105%);
    transition: transform 200ms ease;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  }

  .chat-panel.mobile-open { transform: none; }
  .chat-panel.closed { display: flex; } /* управляется transform, не display */

  #chat-close { display: flex; }

  /* участники (#48) — шторка по образцу чат-шторки (#12): взаимоисключающи
     (открытие одной закрывает другую — app.js), X и backdrop закрывают */
  .member-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 320px);
    z-index: 50;
    transform: translateX(105%);
    transition: transform 200ms ease;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  }

  .member-panel.mobile-open { transform: none; }
  .member-panel.closed { display: flex; } /* управляется transform, не display */

  #member-close { display: flex; }

  .member { min-height: 44px; }

  /* плитки и пилюля масштабируются, кнопки — с запасом под палец (#18) */
  .tiles { gap: 14px 18px; padding: 14px 14px 110px; }
  .tile { width: 124px; }
  :root { --tile-media: 72px; }
  .avatar-glyph { font-size: 35px; }
  .tile-btn { width: 40px; height: 40px; border-width: 5px; }
  .tile .meter { width: 72px; }
  .tile .name { max-width: 100px; font-size: 14px; }

  /* фокус-режим на мобиле — почти весь экран по ВЫСОТЕ (~60dvh с учётом
     пилюли внизу): медиа-бокс тянем в высоту, aspect-ratio выключаем,
     object-fit: cover у видео слегка обрежет кадр по бокам — как в Discord */
  .tiles.focus .tile.focused { width: 100%; }
  .tiles.focus .tile.focused .tile-media {
    height: 60dvh;
    aspect-ratio: auto;
  }
  .tiles.focus .tile.mini .tile-media { width: 96px; }
  .tiles.focus .tile.mini .name { max-width: 96px; }

  .pill-btn { width: 44px; height: 44px; }
  .pill-sep { height: 26px; }
  .controls { bottom: 16px; }
  .ptt-hint { bottom: 92px; }

  /* саундборд (#54): плитка 72px — пилюля «кто запустил» слегка выходит за
     края медиа-бокса (pointer-events:none, живёт секунды — читаемость важнее) */
  .tile-sb-pill { left: -14px; right: -14px; }

  /* демонстрации экрана (#10): та же мобильная дисциплина, что у плиток */
  .screens { gap: 14px 18px; padding: 14px 14px 110px; }
  .screen-card { min-width: 0; }

  /* фокус демонстрации на мобиле — почти весь экран по высоте (object-fit:
     contain слегка зальёт фон чёрным — приемлемо, контент не режется) */
  .screens.focus .screen-card.focused { width: 100%; }
  .screens.focus .screen-card.focused .screen-media {
    height: 56dvh;
    aspect-ratio: auto;
  }
  .screens.focus .screen-card.mini .screen-media { width: 120px; }

  /* сайдбар каналов — выдвижная шторка (гамбургер в шапке основной области) */
  .rail { display: none; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(80vw, 300px);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open { transform: none; }

  /* гамбургеры появляются только в мобильной раскладке */
  .head-icon-btn.menu-btn { display: flex; }

  /* полоска с гамбургером над предпросмотром — только на мобильном */
  .preview-top { display: flex; }

  .room-header { flex-wrap: wrap; row-gap: 6px; }
  .room-titles { max-width: 60vw; }

  .join-card { padding: 24px 20px; }
}

/* на широких экранах аватар крупнее */
@media (min-width: 1400px) {
  .tile { width: 170px; }
  :root { --tile-media: 110px; }
  .avatar-glyph { font-size: 54px; }
  .tile .meter { width: 110px; }
}

/* ---------- текстовый канал (#45): лента чата — основная область ---------- */

/* точка-«непрочитанно» на строке канала в сайдбаре: загорается, когда в канале
   есть сообщения новее курсора последнего прочитанного (курсор — localStorage) */
.channel-unread {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blurple);
  margin-left: 4px;
}

/* Текстовая комната: шапка канала сверху (шапка живёт в .room-col, она нужна —
   гамбургер/пригласить/настройки), сцена с плитками и пилюля скрываются,
   чат-панель становится основной областью на всю оставшуюся высоту/ширину.
   Специфичность #screen-room.text-room перебивает и десктопные (.closed),
   и мобильные (fixed/transform) правила .chat-panel. */
#screen-room.text-room { flex-direction: column; }

#screen-room.text-room .room-col { flex: none; }

#screen-room.text-room .stage { display: none; }

#screen-room.text-room .chat-panel,
#screen-room.text-room .chat-panel.closed,
#screen-room.text-room .chat-panel.mobile-open {
  position: relative;
  transform: none;
  width: auto;
  max-width: none;
  flex: 1;
  min-height: 0;
  z-index: auto;
  box-shadow: none;
  border-left: none;
  border-top: 1px solid var(--rail);
}

/* X-закрывалка и шторечные атрибуты чата в текстовой комнате не нужны: чат — main */
#screen-room.text-room #chat-close,
#screen-room.text-room #chat-toggle,
#screen-room.text-room #members-toggle,
#screen-room.text-room .member-panel { display: none; }
