* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, Arial, sans-serif;
  background: #0e1013;
  color: #e5e7eb;
  min-height: 100%;
  line-height: 1.5;
}

/* Safe area iPhone (статус-бар/Dynamic Island/домашний индикатор): страницы
   рисуются от края до края (viewport-fit=cover в HTML), поэтому краевым панелям
   добавляются эти отступы. Высоты заданы 100dvh поверх 100vh: в мобильном Safari
   100vh — высота с УБРАННОЙ адресной строкой, и низ страницы прячется за ней. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

a { color: #d49061; text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}

.center-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}

.card {
  background: #1a1d22;
  border: 1px solid #272b31;
  border-radius: 12px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

h1 { margin: 0 0 6px 0; font-size: 28px; letter-spacing: -0.3px; }
h2 { margin: 0 0 20px 0; font-size: 16px; font-weight: 500; color: #9ca3af; }

label { display: block; margin-bottom: 8px; color: #9ca3af; font-size: 14px; }
input[type=text],
input[type=password] {
  width: 100%;
  padding: 12px 14px;
  background: #0e1013;
  border: 1px solid #272b31;
  border-radius: 8px;
  color: #e5e7eb;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
input:focus { border-color: #d49061; }

button {
  background: #d49061;
  color: #0e1013;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
  font-family: inherit;
}
button:hover { background: #e0a076; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary { background: #272b31; color: #e5e7eb; }
button.secondary:hover { background: #343940; }

button.danger { background: #7a3030; color: #fee2e2; }
button.danger:hover { background: #933a3a; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }

.error {
  background: #3a1e1e;
  border: 1px solid #7a3030;
  color: #fecaca;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.success {
  background: #1e3a28;
  border: 1px solid #2f6b40;
  color: #b8e8c8;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Админ-шапка */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(14px + var(--safe-top)) calc(24px + var(--safe-right)) 14px calc(24px + var(--safe-left));
  border-bottom: 1px solid #1a1d22;
  background: #0e1013;
}
.app-header .brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.app-header .sub {
  font-size: 13px;
  color: #6b7280;
  margin-left: 10px;
}

/* Список комнат */
.rooms-list { display: grid; gap: 14px; margin-top: 16px; }

.room-card {
  background: #1a1d22;
  border: 1px solid #272b31;
  border-radius: 12px;
  padding: 18px 20px;
}
.room-card.inactive { opacity: 0.55; }

.room-name {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
/* Три состояния live-статуса:
   .live — кто-то в комнате, зелёный с пульсацией
   .idle — комната активна, но пустая, серый
   .off-red — деактивирована админом, красный */
.status-dot.live {
  background: #7bd88f;
  box-shadow: 0 0 0 0 rgba(123, 216, 143, 0.7);
  animation: live-pulse 1.8s ease-out infinite;
}
.status-dot.idle { background: #6b7280; }
.status-dot.off-red { background: #c53030; }

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(123, 216, 143, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(123, 216, 143, 0); }
  100% { box-shadow: 0 0 0 0   rgba(123, 216, 143, 0); }
}

.room-meta {
  color: #9ca3af;
  font-size: 13px;
  margin-top: 4px;
}

.room-url {
  font-family: ui-monospace, Menlo, Monaco, monospace;
  font-size: 12px;
  background: #0e1013;
  border: 1px solid #272b31;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 10px;
  word-break: break-all;
  color: #c9d1d9;
  user-select: all;
}

.room-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.create-form {
  background: #1a1d22;
  border: 1px solid #272b31;
  border-radius: 12px;
  padding: 18px 20px;
}
.create-form .row { gap: 12px; }
.create-form input { flex: 1; min-width: 200px; }

/* Комната (встреча) */
.setup-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
.setup-card { max-width: 460px; width: 100%; }
.setup-card .room-info {
  color: #9ca3af;
  font-size: 14px;
  margin-bottom: 20px;
}

.meet-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.meet-header {
  position: relative;           /* от шапки отсчитывается панель связи */
  padding: calc(10px + var(--safe-top)) calc(18px + var(--safe-right)) 10px calc(18px + var(--safe-left));
  background: #0e1013;
  border-bottom: 1px solid #1a1d22;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.meet-title { font-size: 15px; font-weight: 600; }
.meet-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #d4d9df;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  height: 28px;
  box-sizing: border-box;
  padding: 0 11px 0 9px;
  border-radius: 999px;
}
.count-pill svg { width: 15px; height: 15px; flex-shrink: 0; stroke-width: 2; }
.count-pill .count-num { font-weight: 600; }

.e2ee-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #86e29b;
  background: rgba(123, 216, 143, 0.10);
  border: 1px solid rgba(123, 216, 143, 0.28);
  height: 28px;
  box-sizing: border-box;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.e2ee-badge svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 2.1; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #08090b;
  padding: 8px calc(8px + var(--safe-right)) 8px calc(8px + var(--safe-left));
  gap: 8px;
}
.spotlight-main {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.spotlight-main .participant {
  width: 100%;
  height: 100%;
}
.spotlight-main .participant video {
  object-fit: contain;
  background: #000;
}

.participants-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  min-height: 0;
  /* grid-template-columns / rows задаются JS'ом в room.js */
}

/* Главное окно: демонстрация экрана ИЛИ закреплённый участник — слева во всю
   высоту, остальные камеры — узкой колонкой справа */
.stage.has-main { flex-direction: row; }
.stage.has-main .spotlight-main { display: flex; }
.stage.has-main .participants-grid {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  grid-template-columns: unset !important;
  grid-template-rows: unset !important;
  overflow-x: hidden;
  overflow-y: auto;
}
.stage.has-main .participants-grid .participant {
  flex: 0 0 auto;
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
}

/* Кнопки в правом верхнем углу видео: .fs-btn — полный экран браузера,
   .spot-btn — развернуть участника в главное окно. Появляются только при hover
   на видео, в fullscreen остаются доступными так же по hover. */
.fs-btn,
.spot-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  box-sizing: border-box;
  /* Стекло поверх видео: размытие только на этой маленькой кнопке. */
  background: rgba(24, 27, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 8px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 3;
}
.fs-btn svg,
.spot-btn svg { width: 18px; height: 18px; pointer-events: none; }
.fs-btn:hover,
.spot-btn:hover { background: rgba(24, 27, 32, 0.78); }
.participant .video-wrap:hover .fs-btn,
.participant .video-wrap:hover .spot-btn,
.fs-btn:focus-visible,
.spot-btn:focus-visible { opacity: 1; }
.fs-btn .icon-collapse { display: none; }
.fs-btn.is-fullscreen .icon-expand { display: none; }
.fs-btn.is-fullscreen .icon-collapse { display: inline; }

/* Полный экран браузера предлагаем только тому, кто уже в главном окне: в
   мелкой плитке сетки он не нужен (сначала разворачивают в главное окно). */
.participants-grid .fs-btn { display: none; }
/* Пока идёт демонстрация экрана, главное окно занято ею — закреплять некуда. */
.stage.screen-active .spot-btn { display: none; }
/* У плитки участника кнопок две — полноэкранную сдвигаем левее «развернуть».
   При демонстрации кнопки закрепления нет, и сдвиг оставил бы пустую дырку. */
.stage:not(.screen-active) .participant:not(.is-screen) .fs-btn { right: 50px; }
/* Иконка «развернуть» → «вернуть в сетку», когда участник уже в главном окне. */
.spot-btn .icon-grid { display: none; }
.participant.is-spot .spot-btn .icon-main { display: none; }
.participant.is-spot .spot-btn .icon-grid { display: inline; }

/* Своё видео показываем зеркально — как в зеркале, а не «глазами собеседника»:
   поднятая правая рука должна оставаться справа. На то, что уходит собеседникам,
   это не влияет — CSS не меняет публикуемый поток. Демонстрацию своего экрана
   (.is-screen — отдельная плитка без .is-local) не зеркалим: текст стал бы нечитаем. */
.participant.is-local video { transform: scaleX(-1); }

/* Узкие экраны (мобильник, окно в полэкрана): возвращаемся к нижней полоске,
   иначе боковая колонка съедает screen до нечитаемого. */
@media (max-width: 900px) {
  .stage.has-main { flex-direction: column; }
  .stage.has-main .participants-grid {
    flex: 0 0 140px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .stage.has-main .participants-grid .participant {
    width: auto;
    height: 100%;
  }
}

.participant {
  position: relative;
  background: #1a1d22;
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Свечение говорящего: оверлей поверх видео (z-index выше .participant video) —
   inset-тени не режутся overflow:hidden и не перекрываются соседними плитками. */
.participant::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;        /* совпадает с радиусом плитки */
  pointer-events: none;       /* не перехватывает клики по кнопкам/видео */
  z-index: 2;                 /* выше видео (z-index:1) — glow виден и при включённой камере */
  box-shadow: none;
  transition: box-shadow .2s ease;
}
.participant.speaking::after {
  box-shadow: inset 0 0 0 3px #7bd88f,                 /* чёткое зелёное кольцо */
              inset 0 0 18px 2px rgba(123, 216, 143, 0.45);  /* мягкое свечение внутрь */
}
.participant .video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0e1013;
}
.participant video {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: none;
}
.participant .video-wrap.has-video video {
  display: block;
}
.participant .video-wrap.has-video .avatar-placeholder {
  display: none;
}

/* Аватар-плейсхолдер когда нет видео */
.avatar-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-circle {
  width: min(40%, 180px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0e1013;
  font-weight: 600;
  user-select: none;
}
.avatar-initials {
  font-size: clamp(28px, 8vw, 72px);
  line-height: 1;
}
.avatar-silhouette {
  width: 58%;
  height: 58%;
  fill: rgba(0, 0, 0, 0.65);
}

/* Пилюля с именем и иконкой микрофона */
.participant .name-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  z-index: 2;
  background: rgba(16, 18, 22, 0.62);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 20px);
}
.participant .name-pill .name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mic-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #e5e7eb;
  /* Мелкой иконке нужна линия толще, иначе она теряется на видео. */
  stroke-width: 2.2;
}
.mic-icon .mic-off-part { display: none; }
.mic-icon.muted { color: #f87171; }
.mic-icon.muted .mic-on-part { display: none; }
.mic-icon.muted .mic-off-part { display: inline; }

/* Сломанный микрофон у собеседника. Отличается от выключенного намеренно:
   выключенный это осознанный выбор человека, а сломанный — беда, о которой
   он может и не знать. Пульсация нужна, чтобы признак заметили: без него
   остальные принимают молчание за нежелание говорить и начинают звать. */
.participant.mic-broken .mic-icon { color: #fbbf24; }
.participant.mic-broken .name-pill {
  outline: 1px solid rgba(251, 191, 36, .55);
  animation: mic-broken-pulse 2s ease-in-out infinite;
}
@keyframes mic-broken-pulse {
  0%, 100% { outline-color: rgba(251, 191, 36, .25); }
  50%      { outline-color: rgba(251, 191, 36, .75); }
}
@media (prefers-reduced-motion: reduce) {
  .participant.mic-broken .name-pill { animation: none; }
}

.controls {
  position: relative;
  padding: 12px calc(14px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: #0e1013;
  border-top: 1px solid #1a1d22;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.call-timer {
  position: absolute;
  right: calc(16px + var(--safe-right));
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  user-select: none;
  pointer-events: none;
}

/* Линейные иконки: толщина и скругления задаются здесь, в разметке остаётся
   только геометрия. */
.ico { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico-fill { fill: currentColor; stroke: none; }
/* Контейнер общих масок иконок (room.html). display:none выключил бы маски. */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* Кнопки встречи в духе iOS и macOS 27: круглые, из матового стекла.
   Заливка полупрозрачная, сверху светлый блик, по краю тонкая тёмная кромка,
   так кнопка отделяется от любого фона. Цвет состояния задаётся переменными,
   чтобы стекло, блик и кромка оставались общими. */
.icon-btn,
.ctl-group {
  --glass-fill: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.07) 100%);
  --glass-edge: rgba(255, 255, 255, 0.10);
  background: var(--glass-fill);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 0 0 0.5px rgba(0, 0, 0, 0.6), 0 3px 10px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color: #f4f5f7;
}
.icon-btn {
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  padding: 0;
  min-width: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, filter .12s ease;
}
/* Общий button:hover красит кнопки в оранжевый: здесь стекло обязано остаться. */
.icon-btn:hover { background: var(--glass-fill); filter: brightness(1.14); }
.icon-btn:active { transform: scale(0.95); }
/* Синяя вспышка при касании в мобильных браузерах: у кнопок Apple её нет,
   нажатие показывает само сжатие кнопки. */
.icon-btn,
.ctl-chev,
.dev-item { -webkit-tap-highlight-color: transparent; }
.icon-btn svg { width: 22px; height: 22px; display: block; }
.icon-btn .off-part { display: none; }
.icon-btn.off .on-part { display: none; }
.icon-btn.off .off-part { display: inline; }
/* Выключенный микрофон или камера по-прежнему красные, только в том же стекле. */
.icon-btn.off,
.ctl-group.off {
  --glass-fill: linear-gradient(180deg, rgba(248, 113, 113, 0.46) 0%, rgba(220, 38, 38, 0.32) 100%);
  --glass-edge: rgba(252, 165, 165, 0.30);
  color: #fff1f1;
}

/* «Выйти» — красная капсула, трубка лежит горизонтально, как в FaceTime. */
.icon-btn.leave-btn {
  width: 64px;
  --glass-fill: linear-gradient(180deg, #f05252 0%, #d42a2a 100%);
  --glass-edge: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 0.5px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(212, 42, 42, 0.35);
  color: #fff;
}
.icon-btn.leave-btn svg { width: 26px; height: 26px; }

/* Микрофон и камера — капсула из кнопки и стрелки выбора устройства. Стекло
   у капсулы целиком, части внутри прозрачные: так она читается одной кнопкой
   и при выключении краснеет вся, вместе со стрелкой. */
.ctl-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 48px;
  box-sizing: border-box;
  border-radius: 999px;
  transition: transform .12s ease;
}
.ctl-group:active { transform: scale(0.97); }
.ctl-group .icon-btn,
.ctl-group .ctl-chev {
  background: transparent;
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: inherit;
  filter: none;
}
.ctl-group .icon-btn {
  width: 47px;
  height: 46px;
  padding-left: 2px;
  border-radius: 999px 0 0 999px;
}
.ctl-group .icon-btn:active { transform: none; }
.ctl-sep {
  width: 1px;
  height: 22px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.16);
}
.ctl-chev {
  width: 30px;
  height: 46px;
  padding: 0 3px 0 0;
  min-width: 0;
  border-radius: 0 999px 999px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ctl-chev svg { width: 16px; height: 16px; display: block; stroke-width: 2.1; transition: transform .15s ease; }
.ctl-group .icon-btn:hover,
.ctl-group .ctl-chev:hover { background: rgba(255, 255, 255, 0.08); filter: none; }
.ctl-group.menu-open .ctl-chev { background: rgba(255, 255, 255, 0.12); }
.ctl-group.menu-open .ctl-chev svg { transform: rotate(180deg); }
/* Одно устройство — выбирать нечего: остаётся круглая кнопка без стрелки. */
.ctl-group.single .ctl-sep,
.ctl-group.single .ctl-chev { display: none; }
.ctl-group.single .icon-btn { width: 46px; padding-left: 0; border-radius: 999px; }

/* Список устройств. Живёт в панели кнопок и ставится над своей капсулой
   (левый край считает room.js). Стекло плотнее, чем у кнопок: на нём текст. */
.dev-menu {
  position: absolute;
  left: var(--dev-menu-left, 0px);
  bottom: calc(100% + 10px);
  z-index: 2500;
  width: 300px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(24, 27, 32, 0.86);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 12px 32px rgba(0, 0, 0, 0.5);
  color: #e5e7eb;
  font-size: 13px;
}
.dev-title { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: #8b949e; }
.dev-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.dev-item:hover,
.dev-item:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.dev-item[aria-checked="true"] { background: rgba(255, 255, 255, 0.07); }
.dev-item:active { transform: none; }
.dev-check { width: 16px; height: 16px; flex-shrink: 0; display: inline-flex; color: #d49061; }
.dev-check svg { width: 16px; height: 16px; stroke-width: 2.2; }
.dev-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.dev-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-note { font-size: 12px; font-weight: 400; color: #8b949e; }
.dev-hint {
  margin: 4px 4px 2px;
  padding: 8px 6px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #8b949e;
  line-height: 1.4;
}
.dev-backdrop { display: none; }

/* Задняя камера телефона: ею снимают не себя, надписи в кадре должны читаться. */
.participant.is-local.no-mirror video { transform: none; }

.build-badge {
  position: fixed;
  bottom: calc(4px + var(--safe-bottom));
  right: calc(8px + var(--safe-right));
  font-size: 10px;
  color: #6b7280;
  opacity: 0.5;
  pointer-events: none;
  font-family: ui-monospace, Menlo, Monaco, monospace;
  z-index: 1000;
}

.icon-btn.share-btn.active {
  --glass-fill: linear-gradient(180deg, rgba(74, 222, 128, 0.42) 0%, rgba(22, 163, 74, 0.30) 100%);
  --glass-edge: rgba(134, 239, 172, 0.30);
  color: #effdf4;
}
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; }
.icon-btn:disabled:hover { filter: none; }

/* Кнопки экранов входа и выхода и модалок — капсулы с бликом, в одном стиле
   с кнопками встречи. Админку и другие страницы это не трогает. */
.setup-card button,
.idle-modal-actions button {
  min-height: 44px;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #e2a273 0%, #cf8a58 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 0 0.5px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(212, 144, 97, 0.28);
  color: #1a120c;
}
.setup-card button:hover,
.idle-modal-actions button:hover { background: linear-gradient(180deg, #e9ae82 0%, #d69463 100%); }
.setup-card button:disabled:hover { background: linear-gradient(180deg, #e2a273 0%, #cf8a58 100%); }
#join-btn,
#return-btn { width: 100%; min-height: 48px; font-size: 15px; }
.idle-modal-actions button.danger {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.46) 0%, rgba(220, 38, 38, 0.32) 100%);
  border-color: rgba(252, 165, 165, 0.30);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 0 0 0.5px rgba(0, 0, 0, 0.6);
  color: #fff1f1;
}
.idle-modal-actions button.danger:hover {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.56) 0%, rgba(220, 38, 38, 0.40) 100%);
}

/* Если в системе включено «Понижение прозрачности», стекло становится плотным,
   как в iOS 27, а при «Повышенном контрасте» кромка кнопок заметнее. */
@media (prefers-reduced-transparency: reduce) {
  .icon-btn,
  .ctl-group,
  .fs-btn,
  .spot-btn,
  .participant .name-pill,
  .dev-menu {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .icon-btn,
  .ctl-group { --glass-fill: #2b3037; }
  .icon-btn.off,
  .ctl-group.off { --glass-fill: #7a3030; }
  .icon-btn.share-btn.active { --glass-fill: #2f6b40; }
  .icon-btn.leave-btn { --glass-fill: #d42a2a; }
  .fs-btn,
  .spot-btn { background: #1c1f24; }
  .participant .name-pill { background: rgba(0, 0, 0, 0.8); }
  .dev-menu { background: #181b20; }
}
@media (prefers-contrast: more) {
  .icon-btn,
  .ctl-group { --glass-edge: rgba(255, 255, 255, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .icon-btn,
  .ctl-group,
  .ctl-chev svg { transition: none; }
  .icon-btn:active,
  .ctl-group:active { transform: none; }
}

/* На телефоне кнопки теснее, а список устройств выезжает снизу шторкой:
   пальцем в узкое меню над кнопкой не попасть, а названия камер длинные. */
@media (max-width: 600px) {
  .dev-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    padding: 8px 12px calc(22px + var(--safe-bottom));
    border-radius: 16px 16px 0 0;
    border-width: 1px 0 0;
    gap: 4px;
    font-size: 15px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  }
  .dev-menu::before {
    content: "";
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #2a2f36;
    align-self: center;
    margin: 2px 0 8px;
  }
  .dev-title { padding: 2px 8px 6px; font-size: 15px; color: #e5e7eb; }
  .dev-item { min-height: 52px; padding: 10px 12px; gap: 12px; font-size: 15px; }
  .dev-check,
  .dev-check svg { width: 20px; height: 20px; }
  .dev-note,
  .dev-hint { font-size: 13px; }
  .dev-backdrop { display: block; position: fixed; inset: 0; z-index: 2490; background: rgba(0, 0, 0, 0.5); }
  /* Таймер в узкой панели лёг бы на кнопки — поднимаем его над панелью. */
  .call-timer {
    top: auto;
    bottom: calc(100% + 8px);
    right: calc(10px + var(--safe-right));
    transform: none;
    background: rgba(14, 16, 19, 0.72);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}
@media (max-width: 480px) {
  .controls { gap: 8px; }
  .icon-btn.leave-btn { width: 56px; }
  .icon-btn.leave-btn svg { width: 24px; height: 24px; }
}

/* Модалка «Вы всё ещё на звонке?» */
.idle-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
}
.idle-modal-card {
  background: #1a1d22;
  border: 1px solid #272b31;
  border-radius: 12px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.idle-modal-card h2 {
  margin: 0 0 12px 0;
  color: #e5e7eb;
  font-size: 22px;
  font-weight: 600;
}
.idle-modal-text {
  color: #9ca3af;
  font-size: 15px;
  margin: 0 0 20px 0;
}
.idle-modal-text #idle-countdown {
  color: #d49061;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.idle-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Предупреждения в шапке: «Вас не слышно» (микрофон не публикуется) и
   «Слабая связь» (ConnectionQuality=poor/lost у себя). Человек должен узнать
   о проблеме от нас, а не от собеседников через минуту разговора в пустоту. */
.warn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #fecaca;
  background: rgba(197, 48, 48, 0.15);
  border: 1px solid rgba(197, 48, 48, 0.45);
  height: 28px;
  box-sizing: border-box;
  padding: 0 11px 0 9px;
  border-radius: 999px;
}
.warn-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 2.1;
}
/* Индикатор связи: точка цвета и задержка в миллисекундах. Цвет по порогам:
   зелёный до 100 мс, жёлтый 100–200, красный выше или при потерях больше 3%. */
.net-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #d4d9df;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  height: 28px;
  box-sizing: border-box;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.net-indicator .ni-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.net-indicator.ni-green .ni-dot { background: #4ade80; }
.net-indicator.ni-yellow .ni-dot { background: #facc15; }
.net-indicator.ni-red .ni-dot { background: #f87171; }
.net-indicator.ni-red {
  color: #fecaca;
  background: rgba(197, 48, 48, 0.15);
  border-color: rgba(197, 48, 48, 0.45);
}
.net-indicator.ni-unknown { color: #8b949e; }
/* Общий button:hover красит кнопки в фирменный оранжевый — индикатору это не нужно. */
.net-indicator:hover { background: rgba(255, 255, 255, 0.09); }
.net-indicator.ni-red:hover { background: rgba(197, 48, 48, 0.22); }

.net-panel {
  position: absolute;
  top: 100%;
  right: calc(12px + var(--safe-right));
  margin-top: 6px;
  z-index: 60;
  min-width: 250px;
  max-width: calc(100vw - 24px);
  /* То же стекло, что у списка устройств. */
  background: rgba(24, 27, 32, 0.86);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  color: #c9d1d9;
}
.net-panel .np-title { font-weight: 600; margin-bottom: 6px; }
.net-panel .np-rows {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 12px;
  margin: 0;
}
.net-panel dt { color: #8b949e; }
.net-panel dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.net-panel .np-note { margin-top: 8px; color: #fde68a; font-size: 12px; }

/* На телефоне в шапке тесно: подпись «мс» убираем, остаются точка и число. У
   отметки шифрования оставляем замок, расшифровка — во всплывающей подсказке:
   иначе на ширине 390 px она ломалась в три строки. */
@media (max-width: 480px) {
  .net-indicator .ni-unit { display: none; }
  .e2ee-badge { padding: 0 7px; }
  .e2ee-badge span { display: none; }
}

/* Плашка «браузер заблокировал звук». Не бейдж в шапке, а призыв к действию:
   пока она висит, человек не слышит вообще никого, и нужен его клик. */
.audio-blocked {
  position: fixed;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, 92vw);
  padding: 10px 12px 10px 14px;
  border-radius: 12px;
  background: #3b1d1d;
  border: 1px solid rgba(197, 48, 48, 0.75);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  color: #fee2e2;
}
.audio-blocked svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #fca5a5;
}
.audio-blocked-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.audio-blocked-text b {
  font-size: 13px;
  font-weight: 600;
}
.audio-blocked-text span {
  font-size: 12px;
  color: #fecaca;
}
.audio-blocked-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, #f05252 0%, #d42a2a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 2px 8px rgba(212, 42, 42, 0.3);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.audio-blocked-btn:hover { background: linear-gradient(180deg, #f46464 0%, #dc3434 100%); }
.audio-blocked-btn:active { background: #b91c1c; }

/* Значок слабой связи на плитке участника (рядом с именем) */
.name-pill .net-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: #fbbf24;
  display: none;
}
.participant.weak-net .name-pill .net-icon { display: inline-block; }

/* Бейдж «Идёт запись» в шапке — показывается у всех участников, пока запись активна */
.recording-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: #fecaca;
  background: rgba(197, 48, 48, 0.15);
  border: 1px solid rgba(197, 48, 48, 0.45);
  height: 28px;
  box-sizing: border-box;
  padding: 0 11px 0 10px;
  border-radius: 999px;
}
.recording-badge .recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53e3e;
  box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.7);
  animation: recording-pulse 1.4s ease-out infinite;
  flex-shrink: 0;
}
@keyframes recording-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(229, 62, 62, 0.7); }
  70%  { box-shadow: 0 0 0 7px rgba(229, 62, 62, 0); }
  100% { box-shadow: 0 0 0 0   rgba(229, 62, 62, 0); }
}

/* Кнопка «Запись / Остановить» в шапке */
.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  height: 28px;
  box-sizing: border-box;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.05) 100%);
  color: #eef0f3;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.record-btn:hover { background: rgba(255, 255, 255, 0.14); }
.record-btn .record-btn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}
.record-btn.active {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.42) 0%, rgba(220, 38, 38, 0.30) 100%);
  color: #fee2e2;
  border-color: rgba(252, 165, 165, 0.34);
}
.record-btn.active:hover { background: linear-gradient(180deg, rgba(248, 113, 113, 0.52) 0%, rgba(220, 38, 38, 0.38) 100%); }
.record-btn.active .record-btn-dot {
  background: #ff5757;
  box-shadow: 0 0 0 0 rgba(255, 87, 87, 0.7);
  animation: recording-pulse 1.4s ease-out infinite;
}
.record-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Toast для meet-view (errorBox живёт только в setup-экране) */
.meet-toast {
  position: fixed;
  top: calc(18px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 3000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  /* По умолчанию — error-цвета */
  background: #3a1e1e;
  border: 1px solid #7a3030;
  color: #fecaca;
}
.meet-toast.info {
  background: #1a2230;
  border: 1px solid #2f4b6b;
  color: #c7d5e6;
}

/* ──────────────────────────────────────────────────────────────────────────
   Боковая панель «Записи» — общая для комнаты (Мои записи) и админки.
   Видна только там, где есть body.recs-avail (lobby / экран выхода / админка);
   в самой конференции класс снимается и панель полностью прячется.
   ────────────────────────────────────────────────────────────────────────── */
:root { --recs-side: clamp(300px, 30%, 440px); }

.recs-panel {
  position: fixed;
  left: 0; top: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--recs-side);
  background: #15181d;
  border-right: 1px solid #272b31;
  display: flex;
  flex-direction: column;
  padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom)) calc(16px + var(--safe-left));
  transform: translateX(-100%);
  transition: transform .28s ease;
  z-index: 1500;
}
body.recs-avail.recs-open .recs-panel { transform: translateX(0); }

.recs-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.recs-head h2 { margin: 0; font-size: 17px; font-weight: 600; color: #e5e7eb; flex: 1; }
.recs-count {
  font-size: 12px; font-weight: 600;
  color: #d49061; background: rgba(212, 144, 97, 0.14);
  border-radius: 20px; padding: 2px 9px;
}
.recs-sub { margin: 4px 0 14px; color: #9ca3af; font-size: 12.5px; }

/* кнопка «свернуть» в шапке панели */
.recs-collapse {
  width: 34px; height: 34px; flex: 0 0 auto;
  background: transparent; border: 1px solid #272b31; border-radius: 9px;
  color: #9ca3af; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: .15s;
}
.recs-collapse:hover { color: #e5e7eb; border-color: #343940; background: #1a1d22; }
.recs-collapse svg { width: 18px; height: 18px; }

/* плавающая кнопка «раскрыть» — видна, когда панель свёрнута */
.recs-fab {
  position: fixed;
  left: calc(16px + var(--safe-left));
  top: calc(16px + var(--safe-top));
  z-index: 1600;
  display: none; align-items: center; gap: 8px;
  background: #1a1d22; border: 1px solid #272b31; color: #e5e7eb;
  border-radius: 11px; padding: 9px 13px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: background .15s, border-color .15s;
}
.recs-fab:hover { background: #21252b; border-color: #343940; }
.recs-fab svg { width: 17px; height: 17px; color: #d49061; }
body.recs-avail:not(.recs-open) .recs-fab { display: flex; }
/* В админке при свёрнутой панели сдвигаем шапку, чтобы FAB не лёг на бренд */
.app-header { transition: padding-left .28s ease; }
body.recs-avail:not(.recs-open) .app-header { padding-left: calc(132px + var(--safe-left)); }

/* список записей внутри панели */
.recs-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.recs-list::-webkit-scrollbar { width: 8px; }
.recs-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.recs-list::-webkit-scrollbar-track { background: transparent; }
.recs-empty { color: #9ca3af; font-size: 14px; text-align: center; padding: 28px 0; }

/* строка записи */
.rec {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  background: #1a1d22; border: 1px solid #272b31;
  margin-bottom: 9px;
}
.rec:last-child { margin-bottom: 2px; }
.rec-ico {
  flex: 0 0 38px; height: 38px; border-radius: 10px;
  background: rgba(212, 144, 97, 0.14); color: #d49061;
  display: flex; align-items: center; justify-content: center;
}
.rec-ico svg { width: 19px; height: 19px; }
.rec.is-dead .rec-ico { background: #2a2024; color: #9ca3af; }
.rec-main { flex: 1; min-width: 0; }
.rec-name {
  font-size: 14.5px; font-weight: 600; color: #e5e7eb;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-date { font-size: 12px; color: #9ca3af; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-status { font-size: 12px; color: #d49061; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec.is-dead .rec-status { color: #c98b8b; }

.rec-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.rec-act {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid #272b31; background: transparent; color: #9ca3af;
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: .15s; text-decoration: none;
}
.rec-act:hover { color: #e5e7eb; border-color: #343940; background: #1a1d22; }
.rec-act.open:hover { color: #d49061; border-color: #d49061; }
.rec-act.del:hover { color: #fca5a5; border-color: #7a3030; background: #2a1a1a; }
.rec-act svg { width: 17px; height: 17px; }
.rec-act.is-disabled { opacity: 0.32; pointer-events: none; }

/* спиннер «идёт обработка» */
.rec-spin {
  width: 19px; height: 19px; border: 2.5px solid rgba(212, 144, 97, 0.2);
  border-top-color: #d49061; border-radius: 50%;
  animation: rec-spin .8s linear infinite;
}
@keyframes rec-spin { to { transform: rotate(360deg); } }

/* контент страницы сдвигается, когда панель раскрыта */
.recs-pushable { transition: margin-left .28s ease; }
body.recs-avail.recs-open .recs-pushable { margin-left: var(--recs-side); }

@media (max-width: 900px) {
  :root { --recs-side: min(86vw, 360px); }
  /* на узких экранах панель выезжает оверлеем, контент не сдвигаем */
  body.recs-avail.recs-open .recs-pushable { margin-left: 0; }
  body.recs-avail.recs-open .recs-panel { box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); }
}
