/* ═══════════════════════════════════════════════════════════════════════════
   Voice Lobby — дизайн-система интерфейса.

   Тёмная нейтральная база, один акцент — синий #0458cf, умеренные скругления,
   системный шрифт, hairline-границы вместо тяжёлых теней. Ничего лишнего:
   служебных подписей, счётчиков и технических бейджей в интерфейсе нет.

   ВАЖНО: механика анимации «вход ⇄ регистрация» (сдвиг .auth-overlay между
   двумя формами) сохранена без изменений — тайминги .6s ease-in-out,
   translateX(±100%/±20%/50%) и медиазапрос 720px те же, что были.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ---- Поверхности ---- */
  --bg: #0f1115;           /* фон приложения (совпадает с backgroundColor окна Electron) */
  --surface: #15181e;      /* карточки, топбар, панель управления */
  --surface-2: #1b1f27;    /* меню, всплывающие слои */
  --surface-3: #232832;    /* ховер-подложка */

  /* ---- Текст ---- */
  --text: #f2f5f9;
  --text-dim: rgba(242, 245, 249, 0.70);
  --text-faint: rgba(242, 245, 249, 0.48);

  /* ---- Границы ---- */
  --border: rgba(242, 245, 249, 0.12);
  --border-strong: rgba(242, 245, 249, 0.26);

  /* ---- Акцент: синий ---- */
  --accent: #0458cf;           /* заливки, основные кнопки (текст на них — белый) */
  --accent-hover: #0b68e8;     /* ховер заливки */
  --accent-soft: #6ea8f5;      /* текст/иконки/hairline на тёмном: контраст AA */
  --accent-wash: rgba(4, 88, 207, 0.18);
  --accent-glow: rgba(4, 88, 207, 0.30);

  /* ---- Сигнальные цвета (сохраняем различимость) ---- */
  --danger: #d94a3d;
  --danger-soft: #ff9c92;
  --danger-wash: rgba(217, 74, 61, 0.14);
  --success: #3aa86e;
  --success-soft: #7fd8a6;
  --success-wash: rgba(58, 168, 110, 0.14);

  /* ---- Типографика: системный sans ---- */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Liberation Sans", "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;

  /* ---- Геометрия и движение ---- */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.30), 0 16px 40px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }

/* ---------- Выделение текста ----------
   Случайное выделение подписей/кнопок мышью выглядит как поломка, поэтому по
   умолчанию выделение выключено. Поля ввода и редактируемые области — исключение:
   в них выделение и каретка работают штатно (иначе ломается ввод и доступность). */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
input,
textarea,
select,
option,
[contenteditable],
[contenteditable="true"],
.is-selectable {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

/* Цифры в бейджах/счётчиках не должны «прыгать» по ширине */
.tnum, .ctx-slider-value, .room-code-badge { font-variant-numeric: tabular-nums; }

html, body {
  margin: 0;
  padding: 0;
  /* Высота вьюпорта на мобильных: 100vh «прыгает» вместе с адресной строкой,
     поэтому по возрастанию приоритета — vh → svh (минимальный вьюпорт, без
     скачков) → dvh (динамический, самый точный в современных браузерах). */
  height: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

#app-root { height: 100%; width: 100%; position: relative; z-index: 1; }

/* ---------- Фокус с клавиатуры ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* ---------- Полосы прокрутки ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(242, 245, 249, 0.18);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: rgba(242, 245, 249, 0.30); background-clip: padding-box; }

::selection { background: var(--accent); color: #fff; }

h1, h2, h3, h4 { font-family: var(--font); font-weight: 650; letter-spacing: -0.01em; }

/* ═══════════════ АТОМЫ: кнопки ═══════════════
   Один визуальный язык: скруглённые плашки, синяя заливка у главного действия,
   hairline у второстепенных. Внутренности (.btn__x с двойным лейблом и .btn__dot)
   навешивает anker.js; без него кнопка остаётся статичной, но полностью рабочей. */

button {
  font-family: var(--font);
  color: inherit;
}

/* Двойной лейбл: при наведении верхняя строка уезжает вверх, нижняя встаёт на её место */
.btn__x {
  /* --roll — целое число пикселей: при дробной высоте строки вторая копия
     лейбла подглядывает из-под края на экранах с DPR 2 */
  --roll: 20px;
  display: grid;
  grid-auto-rows: var(--roll);
  height: var(--roll);
  overflow: hidden;
  align-items: center;
  justify-items: center;
  text-align: center;
  pointer-events: none;
}
.btn__x b {
  display: block;
  font-weight: inherit;
  white-space: nowrap;
  line-height: var(--roll);
  transition: transform 0.44s var(--ease-io);
}
.ank-btn:hover .btn__x b,
.ank-btn:focus-visible .btn__x b { transform: translateY(calc(-1 * var(--roll))); }

/* Точка-маркер справа от лейбла: раздувается при наведении */
.btn__dot {
  position: absolute;
  top: 50%;
  right: 16px;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.32;
  flex: 0 0 auto;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
  pointer-events: none;
}
.ank-btn:hover .btn__dot { transform: scale(1.7); opacity: 0.6; }

.ank-btn {
  position: relative;
  will-change: transform;
  text-align: center;
}
.ank-btn:has(.btn__x) { justify-content: center; }
.lobby-logout-btn .btn__x,
.btn-secondary .btn__x,
.test-sound-btn .btn__x { --roll: 18px; }
/* В компактных кнопках точка вплотную к подписи — убираем */
.leave-btn .btn__dot,
.join-toggle-btn .btn__dot,
.lobby-logout-btn .btn__dot,
.btn-secondary .btn__dot,
.test-sound-btn .btn__dot,
.solo-copy-btn .btn__dot { display: none; }

/* ═══════════════ АТОМЫ: поля ввода ═══════════════
   Поле — подчёркнутая строка: подпись всплывает над ней, при фокусе
   прочерчивается синяя линия, под строкой — короткая подсказка (anker.js). */

.fld {
  position: relative;
  display: block;
  text-align: left;
  padding-top: 18px;
  margin-bottom: 26px;
}

.fld input,
.password-field input {
  width: 100%;
  display: block;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 0 10px;
  font-family: var(--font);
  /* 16px, а не меньше: на iOS Safari фокус на поле с font-size < 16px зумит страницу */
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.3s var(--ease);
}
.fld input::placeholder { color: transparent; }
.fld input:hover { border-bottom-color: var(--border-strong); }

.fld__lbl {
  position: absolute;
  left: 0;
  top: 28px;
  font: 400 15px/1 var(--font);
  color: var(--text-faint);
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.34s var(--ease-io), color 0.34s var(--ease);
}
/* Всплытие подписи: чистый CSS, без участия JS */
.fld input:focus ~ .fld__lbl,
.fld input:not(:placeholder-shown) ~ .fld__lbl,
.fld.is-filled .fld__lbl {
  transform: translateY(-26px) scale(0.84);
  color: var(--accent-soft);
}

/* Подчёркивание-«прочерк» при фокусе */
.fld__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-io), background 0.3s var(--ease);
}
.fld input:focus ~ .fld__bar,
.fld.is-focus .fld__bar { transform: scaleX(1); }
.fld.is-err .fld__bar { transform: scaleX(1); background: var(--danger); }
.fld.is-ok .fld__bar { transform: scaleX(1); background: var(--success); }

/* Короткая подсказка под строкой */
.fld__msg {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 7px;
  font: 400 12.5px/1.35 var(--font);
  color: var(--text-faint);
  min-height: 16px;
  transition: color 0.3s var(--ease);
}
.fld.is-err .fld__msg { color: var(--danger-soft); }
.fld.is-ok .fld__msg { color: var(--success-soft); }

/* Автозаполнение Chrome красит поле в белый мимо обычных стилей — закрашиваем тенью */
.fld input:-webkit-autofill,
.fld input:-webkit-autofill:hover,
.fld input:-webkit-autofill:focus,
.fld input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent-soft);
  transition: background-color 5000s ease-in-out 0s;
}
.fld input:autofill { background: var(--surface); color: var(--text); }

/* ═══════════════ АТОМЫ: знак продукта, появление блоков, курсор ═══════════════ */

/* Знак Voice Lobby: эмодзи-трубка в синем круге, коротко «звонит» */
.ank-sigil {
  --d: 44px;
  position: relative;
  width: var(--d);
  height: var(--d);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 30%;
  isolation: isolate;
  background: linear-gradient(150deg, #2a7ff0 0%, #0458cf 62%, #0341a0 100%);
  box-shadow: 0 6px 18px rgba(4, 88, 207, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.10) inset;
}
.ank-sigil__g {
  position: relative;
  z-index: 2;
  display: block;
  /* явный эмодзи-стек: иначе глиф пытается рисоваться текстовой гарнитурой */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", sans-serif;
  font-size: calc(var(--d) * 0.5);
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.45));
  transform-origin: 50% 62%;
  animation: ank-ring 4.2s var(--ease) infinite;
}
/* Две расходящиеся волны «звука» */
.ank-sigil::before,
.ank-sigil::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: calc(var(--d) * 0.8);
  height: calc(var(--d) * 0.8);
  margin: calc(var(--d) * -0.4) 0 0 calc(var(--d) * -0.4);
  border: 1px solid var(--accent-soft);
  border-radius: 34%;
  opacity: 0;
  animation: ank-wave 4.2s var(--ease) infinite;
  pointer-events: none;
}
.ank-sigil::after { animation-delay: 0.34s; }

@keyframes ank-ring {
  0%, 62%, 100% { transform: rotate(0deg) scale(1); }
  4%  { transform: rotate(-13deg) scale(1.05); }
  8%  { transform: rotate(11deg) scale(1.05); }
  12% { transform: rotate(-9deg) scale(1.04); }
  16% { transform: rotate(7deg) scale(1.03); }
  20% { transform: rotate(-5deg) scale(1.02); }
  26% { transform: rotate(3deg) scale(1.01); }
  32% { transform: rotate(0deg) scale(1); }
}
@keyframes ank-wave {
  0%   { transform: scale(0.75); opacity: 0; }
  8%   { opacity: 0.5; }
  40%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* След за курсором: тонкая синяя лента и мягкое пятно (только мышь, без reduced-motion) */
.ank-pointer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s var(--ease);
}
.ank-pointer.is-on { opacity: 1; }
.ank-pointer.is-off { opacity: 0 !important; }
.ank-pointer svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.ank-pointer line {
  stroke: var(--accent-soft);
  stroke-linecap: round;
  fill: none;
  transition: stroke 0.4s var(--ease);
}
.ank-pointer.is-hot line { stroke: #fff; }
.ank-aura {
  position: absolute;
  left: 0; top: 0;
  width: 320px; height: 320px;
  margin: -160px 0 0 -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 168, 245, 0.12) 0%, rgba(4, 88, 207, 0.08) 34%, transparent 70%);
  transition: opacity 0.4s var(--ease);
}
.ank-pointer.is-hot .ank-aura { background: radial-gradient(circle, rgba(110, 168, 245, 0.18) 0%, rgba(4, 88, 207, 0.10) 34%, transparent 70%); }
@media (hover: none), (pointer: coarse) { .ank-pointer { display: none; } }

/* Появление блоков: короткий однократный проезд снизу со сдвигом по индексу */
.rv {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  transition-delay: calc(var(--i, 0) * 55ms);
}
.rv.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .rv { opacity: 1; transform: none; }
  .ank-pointer { display: none; }
  .ank-sigil__g { animation: none; }
  .ank-sigil::before, .ank-sigil::after { animation: none; opacity: 0; }
}

/* ═══════════════ ЭКРАН АВТОРИЗАЦИИ ═══════════════
   Карточка из двух половин: форма и синяя панель с призывом к действию,
   которая едет между ними. Механика сдвига — прежняя. */

.auth-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 82% 4%, rgba(4, 88, 207, 0.20) 0%, transparent 60%),
    radial-gradient(90% 70% at 4% 98%, rgba(4, 88, 207, 0.10) 0%, transparent 62%),
    var(--bg);
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 940px;
  flex: 0 0 auto;
  /* высоты хватает и на регистрацию (3 поля), чтобы кнопка не сплющивалась */
  min-height: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* ---- Формы (позиционирование и анимация сдвига — БЕЗ ИЗМЕНЕНИЙ) ---- */
.auth-form-panel {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 48px;
  transition: transform .6s ease-in-out, opacity .6s ease-in-out;
  background: var(--surface);
}

/* Содержимое формы не сжимается: иначе ряды получались бы разной высоты */
.auth-form-panel > * { flex: 0 0 auto; }

.auth-form-panel h1 {
  font-size: clamp(28px, 3.2vw, 36px);
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--text);
}

.auth-form-hint {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
  margin-bottom: 26px;
  max-width: 36ch;
}

/* Поля формы (внутренности навешивает anker.js) */
.auth-form-panel input {
  width: 100%;
  display: block;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  outline: none;
  margin-bottom: 0;
  transition: border-color 0.3s var(--ease);
}
.auth-form-panel .fld { margin-bottom: 30px; }
.auth-form-panel input::placeholder { color: transparent; }

.auth-form-panel input:-webkit-autofill,
.auth-form-panel input:-webkit-autofill:hover,
.auth-form-panel input:-webkit-autofill:focus,
.auth-form-panel input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent-soft);
  transition: background-color 5000s ease-in-out 0s;
}
.auth-form-panel input:autofill { background: var(--surface); color: var(--text); }

/* Поле пароля с «глазиком»: обёртка одновременно работает контейнером поля (.fld) */
.password-field {
  position: relative;
  display: block;
  text-align: left;
}
.password-field input { padding-right: 46px; }

.password-toggle-btn {
  position: absolute;
  right: 0;
  bottom: 4px;
  width: 44px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.password-toggle-btn:hover { color: var(--accent-soft); background: rgba(242, 245, 249, 0.06); }

/* ---- Главная кнопка формы ---- */
.auth-submit-btn,
.lobby-card > button,
.leave-btn {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
  min-height: 54px;
  padding: 15px 22px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: 600 15.5px/1 var(--font);
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.18s var(--ease), box-shadow 0.3s var(--ease);
}
.auth-submit-btn:hover,
.auth-submit-btn:focus-visible,
.lobby-card > button:hover,
.lobby-card > button:focus-visible {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.auth-submit-btn:active,
.lobby-card > button:active { transform: scale(0.99); }
.auth-submit-btn:disabled,
.lobby-card > button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* ---- Сообщение об ошибке/успехе в форме ---- */
.auth-error {
  position: relative;
  background: var(--danger-wash);
  border: 1px solid rgba(217, 74, 61, 0.35);
  color: var(--danger-soft);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 18px;
  text-align: left;
  animation: ank-slot-in 0.4s var(--ease);
}
.auth-error.success {
  background: var(--success-wash);
  border-color: rgba(58, 168, 110, 0.35);
  color: var(--success-soft);
}
@keyframes ank-slot-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Форма входа изначально слева, форма регистрации — справа за пределами видимой области */
.auth-signin { left: 0; z-index: 2; }
.auth-signup { left: 0; opacity: 0; z-index: 1; }

.auth-container.right-panel-active .auth-signin { transform: translateX(100%); opacity: 0; z-index: 1; }
.auth-container.right-panel-active .auth-signup { transform: translateX(100%); opacity: 1; z-index: 5; }

/* ---- Синяя сдвигающаяся панель с призывом к действию ---- */
.auth-overlay-container {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  overflow: hidden;
  transition: transform .6s ease-in-out;
  z-index: 10;
}

.auth-container.right-panel-active .auth-overlay-container { transform: translateX(-100%); }

.auth-overlay {
  position: relative;
  left: -100%;
  height: 100%;
  width: 200%;
  background:
    radial-gradient(120% 100% at 20% 0%, #2a7ff0 0%, transparent 55%),
    linear-gradient(160deg, #0a5fd8 0%, #0458cf 55%, #0341a0 100%);
  transform: translateX(0);
  transition: transform .6s ease-in-out;
}

.auth-container.right-panel-active .auth-overlay { transform: translateX(50%); }

.auth-overlay-panel {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 40px;
  color: #fff;
}
.auth-overlay-panel .ank-sigil {
  --d: 60px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28) inset;
}
.auth-overlay-panel .ank-sigil::before,
.auth-overlay-panel .ank-sigil::after { border-color: rgba(255, 255, 255, 0.55); }

/* Название продукта над формой — только в мобильной раскладке */
.auth-brand-mobile {
  display: none;
  margin: 0 auto 18px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-soft);
  text-align: center;
}

/* Название продукта на акцентной панели */
.auth-brand {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  margin: 0 0 10px;
}

.auth-overlay-panel h1 {
  font-size: clamp(26px, 2.8vw, 32px);
  line-height: 1.18;
  margin: 0 0 12px;
  color: #fff;
}
.auth-overlay-panel p {
  font-size: 15.5px;
  line-height: 1.55;
  margin: 0 0 28px;
  max-width: 28ch;
  color: rgba(255, 255, 255, 0.88);
}

.auth-overlay-left { left: 0; transform: translateX(-20%); transition: transform .6s ease-in-out; }
.auth-overlay-right { right: 0; transform: translateX(0); transition: transform .6s ease-in-out; }
.auth-container.right-panel-active .auth-overlay-left { transform: translateX(0); }
.auth-container.right-panel-active .auth-overlay-right { transform: translateX(20%); }

/* Кнопка-переключатель «Регистрация» / «Войти»: широкая и с крупным тач-таргетом */
.auth-ghost-btn {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  min-width: 200px;
  min-height: 52px;
  padding: 15px 28px;
  border: 1.5px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font: 600 15px/1 var(--font);
  cursor: pointer;
  overflow: hidden;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.18s var(--ease);
}
.auth-ghost-btn:hover,
.auth-ghost-btn:focus-visible {
  background: #fff;
  border-color: #fff;
  color: var(--accent);
}
.auth-ghost-btn:active { transform: scale(0.99); }
.auth-ghost-btn:focus-visible { outline-color: #fff; }

/* Переключатель формы под ней — работает на узких экранах, где слайдера нет */
.auth-mobile-switch {
  display: none;
  margin-top: 22px;
  font-size: 14.5px;
  color: var(--text-dim);
  text-align: center;
}

.auth-switch-link {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  padding: 15px 22px;
  background: transparent;
  border: 1.5px solid var(--accent-soft);
  border-radius: var(--radius);
  color: var(--accent-soft);
  font: 600 15px/1 var(--font);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.auth-switch-link:hover,
.auth-switch-link:focus-visible { background: var(--accent-wash); color: #fff; }

/* На узких экранах (телефон) двухпанельный слайдер не влезает — показываем только
   текущую форму на всю ширину карточки, переключение — крупной кнопкой под ней */
@media (max-width: 720px) {
  .auth-brand-mobile { display: block; }
  .auth-container { max-width: 480px; min-height: 0; }
  .auth-overlay-container { display: none; }
  .auth-form-panel {
    position: relative;
    width: 100%;
    padding: 36px 24px 32px;
    transform: none !important;
    display: none;
    opacity: 1 !important;
  }
  .auth-signin { display: flex; }
  .auth-signup { display: none; }
  .auth-container.right-panel-active .auth-signin { display: none; }
  .auth-container.right-panel-active .auth-signup { display: flex; }
  .auth-mobile-switch { display: block; }
}

/* ═══════════════ ЛОББИ ═══════════════ */

.lobby-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(110% 75% at 86% 2%, rgba(4, 88, 207, 0.18) 0%, transparent 58%),
    radial-gradient(95% 70% at 2% 98%, rgba(4, 88, 207, 0.09) 0%, transparent 62%),
    var(--bg);
}

.lobby-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 28px 22px;
  width: 100%;
  max-width: 468px;
  text-align: left;
  margin: auto;
}

/* Шапка карточки: знак + название продукта (собирает anker.js) */
.ank-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.ank-brand__tx { min-width: 0; }

.lobby-card h1 {
  font-size: clamp(24px, 6vw, 30px);
  line-height: 1.15;
  margin: 0;
  color: var(--text);
}

/* ---- Строка пользователя ---- */
.lobby-userbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(242, 245, 249, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 14.5px;
  color: var(--text);
}
.lobby-userbar > span {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lobby-userbar > span i { color: var(--accent-soft); font-size: 13px; }

/* Вторичные кнопки: hairline + подложка при наведении */
.lobby-card .btn-secondary,
.lobby-logout-btn,
.test-sound-btn {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: 500 14px/1 var(--font);
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.18s var(--ease);
}
.lobby-card .btn-secondary:hover,
.lobby-card .btn-secondary:focus-visible,
.lobby-logout-btn:hover,
.lobby-logout-btn:focus-visible,
.test-sound-btn:hover,
.test-sound-btn:focus-visible {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(242, 245, 249, 0.06);
}
.lobby-card .btn-secondary:active,
.lobby-logout-btn:active,
.test-sound-btn:active { transform: scale(0.98); }
.lobby-card .lobby-logout-btn { width: auto; margin-top: 0; flex-shrink: 0; }

/* ---- Превью камеры: постоянное соотношение 16:9, без сплющивания ---- */
.device-preview {
  background: #05070a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Ключевое: высота считается из ширины (16:9), а не задаётся вручную —
     поэтому превью не сплющивается ни на узком телефоне, ни в окне Electron.
     max-height страхует лобби от вылезания за экран на низких вьюпортах. */
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 38vh;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}
/* Фолбэк для браузеров без aspect-ratio (старые iOS/Safari) */
@supports not (aspect-ratio: 16 / 9) {
  .device-preview { height: 0; padding-bottom: 56.25%; max-height: none; }
}
.device-preview video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* cover + зеркальное отражение: камера показывает «как в зеркале», кадр
     заполняет окно превью целиком, пропорции сохраняются (не сплющено) */
  object-fit: cover;
  transform: scaleX(-1);
  background: #05070a;
}
.device-preview .no-cam {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-faint);
  background: linear-gradient(180deg, #14181f 0%, #0d1015 100%);
}

/* ---- Переключатели «с чем входить»: сегментная пара ---- */
.join-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.join-toggle-btn {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font: 500 14.5px/1 var(--font);
  cursor: pointer;
  overflow: hidden;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.join-toggle-btn:hover { background: rgba(242, 245, 249, 0.05); color: var(--text); }
.join-toggle-btn.on {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-wash);
}
.join-toggle-btn.on i { color: var(--accent-soft); }
.join-toggle-btn.off i { color: var(--danger-soft); }
.join-toggle-btn i { font-size: 14px; transition: color 0.25s var(--ease); }

/* ---- Выбор устройств ---- */
.device-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.device-row { display: flex; align-items: center; gap: 10px; }

.device-row label {
  flex-shrink: 0;
  width: 104px;
  font-size: 13.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.device-row label i { color: var(--accent-soft); font-size: 12px; }

.device-row select {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 30px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: rgba(242, 245, 249, 0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236ea8f5' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
  min-height: 44px;
}
.device-row select:hover { border-color: var(--border-strong); }
.device-row select:focus { border-color: var(--accent-soft); background-color: var(--accent-wash); }
.device-row select option { background: var(--surface-2); color: var(--text); }
.device-row .test-sound-btn { min-height: 44px; flex-shrink: 0; }

/* Индикатор уровня микрофона */
.mic-meter {
  width: 46px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(242, 245, 249, 0.10);
  overflow: hidden;
  flex-shrink: 0;
}
.mic-meter-bar {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: var(--success);
  transition: width .08s linear;
}

.hint-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-faint);
  margin-top: 14px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: 13px;
  margin: 22px 0;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.error-box {
  background: var(--danger-wash);
  border: 1px solid rgba(217, 74, 61, 0.35);
  color: var(--danger-soft);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
  text-align: left;
}

/* ═══════════════ ЭКРАН ЗВОНКА ═══════════════ */

.room-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  /* Внутренние скроллы: сам экран звонка никогда не скроллится целиком,
     иначе на мобильных панель управления уезжает под адресную строку */
  overflow: hidden;
}

.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  flex-shrink: 0;
  min-height: 56px;
}
.room-topbar .ank-sigil { --d: 30px; -webkit-app-region: no-drag; }

.room-topbar .room-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-dim);
  min-width: 0;
}

.room-topbar .room-code-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  background: rgba(242, 245, 249, 0.05);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
  -webkit-app-region: no-drag;
}
.room-topbar .room-code-badge:hover { border-color: var(--accent-soft); color: #fff; background: var(--accent-wash); }

.room-topbar .host-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-soft);
  font-size: 13.5px;
  white-space: nowrap;
}

.room-topbar .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  display: inline-block;
  flex-shrink: 0;
}
.room-topbar .status-dot.connecting { background: var(--accent-soft); animation: ank-pulse 1.4s var(--ease) infinite; }
.room-topbar .status-dot.disconnected { background: var(--danger); }
@keyframes ank-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }

.room-main {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--bg);
}

.stage {
  flex: 1;
  display: grid;
  gap: 12px;
  padding: 14px;
  min-height: 0;
  min-width: 0;
  grid-auto-rows: 1fr;
  overflow: hidden;
}

/* ---- Тайлы участников и демонстраций ---- */
.tile {
  position: relative;
  background: #05070a;
  /* Умеренное скругление: современно и единообразно, без pill-формы */
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.tile.speaking {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 26px var(--accent-glow);
}

.tile video {
  width: 100%;
  height: 100%;
  /* Демонстрация экрана — contain (важен весь кадр), камера — cover (кадрируем
     по тайлу, пропорции не искажаются ни в одном из режимов) */
  object-fit: contain;
  background: #05070a;
  display: block;
}
.tile.camera-tile video { object-fit: cover; }

.tile .tile-label {
  position: absolute; bottom: 10px; left: 10px;
  max-width: calc(100% - 20px);
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(242, 245, 249, 0.12);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.2;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 4;
  overflow: hidden;
}
.tile .tile-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .tile-label .fa-microphone-slash,
.tile .tile-label .fa-video-slash { color: var(--danger-soft); flex-shrink: 0; }
.tile .tile-label .host-crown { color: var(--accent-soft); margin-left: 2px; flex-shrink: 0; }

/* Кнопки на тайле */
.tile-fullscreen-btn,
.tile-kick-btn {
  position: absolute;
  bottom: 10px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(242, 245, 249, 0.16);
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
  z-index: 5;
}
.tile-fullscreen-btn { right: 10px; }
.tile-fullscreen-btn:hover { border-color: var(--accent-soft); color: #fff; background: var(--accent); }
.tile.screen-tile:hover .tile-fullscreen-btn,
.tile.screen-tile.is-fullscreen .tile-fullscreen-btn,
.tile.camera-tile:hover .tile-fullscreen-btn { opacity: 1; }

/* Кнопка «выгнать участника» — видна создателю при наведении на чужой тайл камеры */
.tile-kick-btn {
  right: 58px;
  border-color: rgba(217, 74, 61, 0.55);
  color: var(--danger-soft);
  z-index: 6;
}
.tile-kick-btn:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.tile.camera-tile:hover .tile-kick-btn { opacity: 1; }

/* На тач-устройствах :hover физически не срабатывает — держим элементы видимыми */
@media (hover: none) {
  .tile-fullscreen-btn,
  .tile-kick-btn,
  .volume-control { opacity: .9; }
}

/* Регулятор громкости на тайле */
.volume-control {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(242, 245, 249, 0.12);
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity .25s var(--ease), border-color .25s var(--ease);
  z-index: 5;
  cursor: default;
}
.volume-control:hover { border-color: var(--border-strong); }
.tile:hover .volume-control,
.tile.screen-tile.is-fullscreen .volume-control { opacity: 1; }

.volume-control i {
  font-size: 12px;
  color: var(--accent-soft);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

/* Ползунки */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(242, 245, 249, 0.20);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(6, 8, 12, 0.7);
  cursor: pointer;
  transition: transform .2s var(--ease);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(6, 8, 12, 0.7);
  cursor: pointer;
}
.volume-control input[type="range"] { width: 74px; cursor: pointer; }

.tile.screen-tile { cursor: pointer; }

/* ---- Полноэкранный режим ----
   Нативный Fullscreen API (десктоп, Android) и «внутренний» полный экран
   (.in-app-fullscreen) для iOS Safari, где requestFullscreen() у обычных
   элементов недоступен. Визуально оба режима одинаковы. */
.tile.screen-tile:fullscreen,
.tile.screen-tile.is-fullscreen,
.tile.camera-tile:fullscreen,
.tile.camera-tile.is-fullscreen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile.screen-tile:fullscreen video,
.tile.screen-tile.is-fullscreen video,
.tile.camera-tile:fullscreen video,
.tile.camera-tile.is-fullscreen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile.in-app-fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  /* --app-vh обновляет JS по visualViewport: на iOS адресная строка меняет
     высоту вьюпорта без resize-события у window */
  height: var(--app-vh, 100dvh);
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  flex: none !important;
  margin: 0;
  border: 0;
  border-radius: 0;
  z-index: 3000;
  background: #000;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
body.inapp-fullscreen { overflow: hidden; }
/* В этом режиме кнопка выхода всегда видна — иначе на телефоне из него не выйти */
.tile.in-app-fullscreen .tile-fullscreen-btn { opacity: 1; bottom: calc(12px + env(safe-area-inset-bottom)); }
.tile.in-app-fullscreen .tile-label { bottom: calc(12px + env(safe-area-inset-bottom)); }

/* Заглушка «камера выключена»: инициалы участника */
.tile .no-video-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 38%, #1b2028 0%, #12151b 60%, #0a0d11 100%);
}
.avatar-circle {
  width: clamp(56px, 18%, 84px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(155deg, #2a7ff0 0%, #0458cf 60%, #0341a0 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  font-size: clamp(20px, 6.5vw, 30px);
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #fff;
  box-shadow: 0 10px 30px rgba(4, 88, 207, 0.28);
}

/* ---- Раскладка «я один в комнате»: слева карточка себя, справа приглашение ---- */
.stage.stage-solo {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-content: center;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  padding: clamp(14px, 3vw, 32px);
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
  grid-auto-rows: auto;
}
.stage.stage-solo .tile.camera-tile {
  width: 100%;
  height: 100%;
  min-height: clamp(220px, 42vh, 520px);
  max-height: 72vh;
  aspect-ratio: auto;
  flex: none;
}
.solo-invite {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  padding: clamp(24px, 4vw, 44px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: clamp(220px, 42vh, 520px);
  max-height: 72vh;
}
.solo-invite__title {
  font-size: clamp(19px, 2vw, 25px);
  font-weight: 650;
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
  max-width: 26ch;
}
.solo-invite__hint {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-faint);
  margin: 0;
  max-width: 34ch;
}
.solo-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 54px;
  min-width: 240px;
  max-width: 100%;
  padding: 15px 28px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: 600 15.5px/1 var(--font);
  cursor: pointer;
  transition: background .25s var(--ease), border-color .25s var(--ease), transform .18s var(--ease), box-shadow .25s var(--ease);
}
.solo-copy-btn:hover,
.solo-copy-btn:focus-visible {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.solo-copy-btn:active { transform: scale(0.99); }
.solo-copy-btn.is-copied {
  background: var(--success);
  border-color: var(--success);
  box-shadow: none;
}
.solo-invite__code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
}
.solo-invite__code b { font-weight: 600; color: var(--text); }

/* Сайдбар с тайлами участников рядом с демонстрацией */
.sidebar-participants {
  width: 240px;
  border-left: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-participants .tile { aspect-ratio: 16/9; flex-shrink: 0; }

/* ---- Панель управления звонком ---- */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Круглая кнопка управления */
.ctrl-btn {
  position: relative;
  z-index: 0;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(242, 245, 249, 0.04);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease), transform .18s var(--ease);
}
.ctrl-btn:hover, .ctrl-btn:focus-visible {
  background: rgba(242, 245, 249, 0.10);
  border-color: var(--border-strong);
  color: #fff;
}
.ctrl-btn:active { transform: scale(.95); }
/* Включённое состояние — синяя заливка, белая иконка */
.ctrl-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ctrl-btn.active:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.ctrl-btn.danger, .ctrl-btn.off {
  background: var(--danger-wash);
  border-color: var(--danger);
  color: var(--danger-soft);
}
.ctrl-btn.danger:hover, .ctrl-btn.off:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctrl-btn:disabled { opacity: .4; cursor: not-allowed; }

.ctrl-btn .badge-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--success);
  color: #06210f;
  font: 600 11px/1 var(--font);
  border-radius: var(--radius-pill);
  padding: 4px 6px;
  min-width: 18px;
  text-align: center;
  z-index: 2;
}

.ctrl-divider { width: 1px; height: 32px; background: var(--border); margin: 0 6px; }

/* Кнопка завершения звонка */
.leave-btn {
  width: auto;
  margin-top: 0;
  padding: 0 24px;
  min-height: 52px;
  height: 52px;
  gap: 11px;
  justify-content: center;
  border: 1px solid var(--danger);
  background: var(--danger-wash);
  color: var(--danger-soft);
  border-radius: var(--radius);
  font: 600 15px/1 var(--font);
}
.leave-btn:hover, .leave-btn:focus-visible {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 8px 24px rgba(217, 74, 61, 0.28);
}

/* ---- Уведомления ---- */
.toast-container {
  position: fixed; top: calc(72px + env(safe-area-inset-top)); right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
  max-width: calc(100vw - 40px);
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  box-shadow: var(--shadow-md);
  animation: toast-in .3s var(--ease);
  max-width: 340px;
}
.toast.error { border-left-color: var(--danger); color: var(--danger-soft); }
.toast.success { border-left-color: var(--success); color: var(--success-soft); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- Панель участников ---- */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 7, 10, .62);
  display: flex; justify-content: flex-end;
  /* выше уведомлений (z-index 1000), иначе тост ложится на список участников */
  z-index: 1100;
  animation: ank-fade-in .25s var(--ease);
}
@keyframes ank-fade-in { from { opacity: 0; } to { opacity: 1; } }
.panel {
  width: 340px; height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  overflow-y: auto;
  animation: ank-panel-in .36s var(--ease-io);
}
@keyframes ank-panel-in { from { transform: translateX(100%); } to { transform: none; } }
.panel h3 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 650;
  color: var(--text);
}
.panel-participant {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
}
.panel-participant:last-child { border-bottom: 0; }
.panel-participant .avatar-circle { width: 38px; height: 38px; font-size: 14px; box-shadow: none; }
.panel-participant .panel-participant__meta { font-size: 13px; color: var(--text-faint); margin-left: auto; }
.panel-close {
  float: right;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 17px;
  cursor: pointer;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.panel-close:hover { color: var(--text); background: rgba(242, 245, 249, 0.07); }

/* ---- Контекстное меню на тайле демонстрации ---- */
.screen-ctx-menu,
.screen-ctx-submenu {
  position: fixed;
  z-index: 2000;
  min-width: 240px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-dim);
  animation: ank-ctx-in .16s var(--ease);
}
.screen-ctx-submenu { z-index: 2001; min-width: 200px; }
@keyframes ank-ctx-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.screen-ctx-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.screen-ctx-item:hover,
.screen-ctx-item.open { background: var(--accent); color: #fff; }
.screen-ctx-item.destructive { color: var(--danger-soft); }
.screen-ctx-item.destructive:hover { background: var(--danger); color: #fff; }

.screen-ctx-item .ctx-icon { width: 16px; flex-shrink: 0; text-align: center; font-size: 13px; opacity: .9; }
.screen-ctx-item .ctx-label { flex: 1; }
.screen-ctx-item .ctx-chevron { font-size: 11px; opacity: .7; flex-shrink: 0; }

/* Чекбокс в меню */
.screen-ctx-item .ctx-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.screen-ctx-item.checked .ctx-checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.screen-ctx-item.checked .ctx-checkbox::after { content: "✓"; }
.screen-ctx-item:hover .ctx-checkbox { border-color: #fff; }

.screen-ctx-divider { height: 1px; background: var(--border); margin: 5px 3px; }

/* Пункт-ползунок: подсветки пункта нет, интерактивен только сам range */
.screen-ctx-item.screen-ctx-slider {
  cursor: default;
  align-items: flex-start;
  white-space: normal;
}
.screen-ctx-item.screen-ctx-slider:hover { background: none; color: var(--text-dim); }
.screen-ctx-item.screen-ctx-slider .ctx-icon { margin-top: 3px; }

.ctx-slider-body { flex: 1; min-width: 150px; }
.ctx-slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ctx-slider-value { font-size: 13px; color: var(--accent-soft); flex-shrink: 0; }
.screen-ctx-item.screen-ctx-slider input[type="range"] { display: block; width: 100%; cursor: pointer; }

.screen-ctx-submenu .screen-ctx-item.selected { color: var(--accent-soft); }
.screen-ctx-submenu .screen-ctx-item.selected .ctx-icon { color: var(--accent-soft); }
.screen-ctx-submenu .screen-ctx-item.selected:hover { color: #fff; }

/* ---- Центрированная раскладка сцены ---- */
.stage.stage-centered {
  /* Сетка, а не flex-wrap: число колонок задано явно для каждого числа
     участников, поэтому ряды всегда влезают в высоту сцены при любом размере
     окна — ничего не выталкивается за край и не пропадает. */
  display: grid;
  gap: 12px;
  place-items: center;
  align-content: center;
  grid-auto-rows: minmax(0, 1fr);
}
.stage.stage-centered.cam-count-1 { grid-template-columns: minmax(0, 1fr); }
.stage.stage-centered.cam-count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage.stage-centered.cam-count-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stage.stage-centered.cam-count-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Пятеро: 3 + 2, причём нижний ряд по центру (шесть колонок по span 2) */
.stage.stage-centered.cam-count-5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stage.stage-centered.cam-count-5 .tile { grid-column: span 2; }
.stage.stage-centered.cam-count-5 .tile:nth-child(4) { grid-column: 2 / span 2; }

.stage.stage-centered .tile.camera-tile {
  width: 100%;
  max-width: min(760px, 100%);
  aspect-ratio: 16/10;
  max-height: 100%;
}

/* Демонстрация экрана: занимает всю доступную площадь и ВСЕГДА остаётся видимой,
   как бы ни менялся размер окна. Никаких фиксированных высот и display: none —
   плитка растягивается на ячейку сетки, а само видео вписывается через object-fit: contain. */
.stage.stage-centered .tile.screen-tile {
  width: 100%;
  height: auto;
  max-width: 100%;
  /* плитка повторяет пропорции экрана, а max-height не даёт ей вылезти за сцену */
  aspect-ratio: 16/9;
  max-height: 100%;
  min-height: 120px;
}
.stage.stage-centered.screen-count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---- Бейдж LIVE на тайле демонстрации ---- */
.tile .live-badge-group {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 4;
}
.tile .live-badge {
  background: var(--danger);
  color: #fff;
  font: 600 11.5px/1 var(--font);
  letter-spacing: 0.06em;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile .live-badge .live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #fff;
  animation: live-blink 1.6s infinite;
}
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ═══════════════ АДАПТАЦИЯ ═══════════════ */

/* Узкий рабочий стол / планшет: демонстрация сверху во всю ширину,
   камеры — «плёнкой» под ней. Демка при этом не пропадает, а масштабируется. */
@media (max-width: 860px) {
  .room-main { flex-direction: column; }
  .sidebar-participants {
    width: 100%;
    height: 112px;
    min-height: 112px;
    max-height: 112px;
    flex-direction: row;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar-participants .tile { width: 160px; height: 100%; flex-shrink: 0; }
  .stage.stage-solo {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    overflow-y: auto;
  }
  .stage.stage-solo .tile.camera-tile {
    aspect-ratio: 16/9;
    height: auto;
    min-height: 0;
    max-height: none;
  }
  /* Узкие экраны: не больше двух колонок, иначе лица становятся неразличимыми.
     Четыре колонки по span 2 — чтобы одинокая плитка в последнем ряду стояла по центру. */
  .stage.stage-centered.cam-count-3,
  .stage.stage-centered.cam-count-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stage.stage-centered.cam-count-3 .tile,
  .stage.stage-centered.cam-count-5 .tile { grid-column: span 2; }
  .stage.stage-centered.cam-count-3 .tile:nth-child(3),
  .stage.stage-centered.cam-count-5 .tile:nth-child(5) { grid-column: 2 / span 2; }
  .stage.stage-centered.cam-count-5 .tile:nth-child(4) { grid-column: span 2; }
  .solo-invite { min-height: 0; max-height: none; }
}

@media (max-width: 560px) {
  .lobby-card { padding: 22px 18px 20px; }
  .lobby-screen, .auth-screen { padding: 16px; }
  .device-row { flex-wrap: wrap; }
  .device-row label { width: 100%; }
  .device-row select { flex: 1 1 auto; }
  .join-toggles { gap: 8px; }
  .toast-container { right: 12px; left: 12px; max-width: none; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .room-topbar { gap: 8px; padding: 8px 12px; }
  .room-topbar .room-info { font-size: 13px; gap: 8px; min-width: 0; overflow: hidden; }
  .room-topbar .room-info > span:nth-child(2) { display: none; } /* текст статуса: точки достаточно */
  .room-topbar .ank-sigil { --d: 26px; }
  .room-topbar .host-indicator span { display: none; }

  .stage { padding: 10px; gap: 10px; }
  /* Телефон: вдвоём — одна колонка, трое и больше — две */
  .stage.stage-centered.cam-count-2 { grid-template-columns: minmax(0, 1fr); }
  .stage.stage-centered .tile.camera-tile { max-width: 100%; }
  .stage.stage-centered.screen-count-2 .tile.screen-tile {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }

  .controls-bar {
    gap: 10px;
    padding: 12px 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    flex-wrap: nowrap;
  }
  .ctrl-btn { width: 48px; height: 48px; font-size: 16px; flex-shrink: 0; }
  .leave-btn { padding: 0 18px; height: 48px; min-height: 48px; font-size: 14px; flex-shrink: 0; }
  .ctrl-divider { margin: 0 2px; height: 26px; flex-shrink: 0; }

  .tile { border-radius: 12px; }
  .tile .tile-label { font-size: 12.5px; padding: 5px 9px; }
  .solo-copy-btn { width: 100%; min-width: 0; }
}

/* Узкие портретные окна (телефон вертикально, узкое высокое окно браузера): плитки
   заполняют ячейку целиком, иначе при фиксированном 16/10 половина экрана остаётся пустой */
@media (orientation: portrait) and (max-width: 860px) {
  .stage.stage-centered .tile.camera-tile {
    height: 100%;
    max-width: 100%;
    aspect-ratio: auto;
  }
}

/* Низкие вьюпорты (телефон в ландшафте): панель управления и топбар сжимаются,
   чтобы сцена не осталась без места */
@media (max-height: 480px) and (orientation: landscape) {
  .room-topbar { min-height: 46px; padding: 6px 12px; }
  .controls-bar { padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); gap: 10px; }
  .ctrl-btn { width: 44px; height: 44px; }
  .leave-btn { height: 44px; min-height: 44px; }
  .stage { padding: 8px; }
  .stage.stage-solo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: center; }
  .stage.stage-solo .tile.camera-tile,
  .solo-invite { min-height: 0; }
  .solo-invite { gap: 12px; padding: 16px; }
}

@media (max-width: 380px) {
  .panel { width: 90vw; }
}
