/* ───────────────────────── токены ───────────────────────── */
:root {
  --bg: #0a0c10;
  --bg-2: #12161d;
  --bg-3: #1a2029;
  --line: #262e3a;
  --text: #e8edf5;
  --muted: #8d99ab;
  --accent: #6c8cff;
  --accent-ink: #ffffff;
  --danger: #ff5a5a;
  --ok: #3ddc97;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; }
[hidden] { display: none !important; }

/* ───────────────────────── элементы ───────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #222a35; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover:not(:disabled) { background: #5b7cf5; }
.btn--big { padding: 14px 22px; font-size: 16px; width: 100%; text-align: center; text-decoration: none; display: block; }
.btn--small { padding: 7px 12px; font-size: 13px; }
.btn--icon { padding: 4px 10px; font-size: 20px; line-height: 1; background: none; border: none; color: var(--muted); }
.btn--toggle[aria-pressed="false"] { background: #2a1a1f; border-color: #4a2630; color: #ffb4b4; }

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }

.link { color: var(--muted); font-size: 14px; text-align: center; display: block; margin-top: 14px; }
.link:hover { color: var(--text); }

.error {
  background: #2a1418;
  border: 1px solid #5b2430;
  color: #ffc2c2;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 14px;
  margin: 14px 0 0;
}

.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ───────────────────────── стартовая страница ───────────────────────── */
.page-start { display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }

.start {
  width: 100%;
  max-width: 520px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.start__title { margin: 0 0 10px; font-size: 26px; letter-spacing: -.02em; }
.start__lead { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.start__foot { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.created { margin-top: 4px; }
.created__label, .join__label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.created__row { display: flex; gap: 8px; margin-bottom: 14px; }
.created__row .btn { flex: 0 0 auto; }
.created__hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

.join { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ───────────────────────── экран перед входом ───────────────────────── */
.prejoin {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
}
.prejoin__card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.prejoin__title { margin: 0 0 16px; font-size: 20px; letter-spacing: -.01em; }

.prejoin__preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05070a;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.preview__video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview__off {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: 14px;
  background: #05070a;
}
.preview__meter {
  position: absolute; left: 12px; right: 12px; bottom: 12px; height: 4px;
  background: rgba(255, 255, 255, .15); border-radius: 99px; overflow: hidden;
}
.preview__level { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }

.prejoin__toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.prejoin__toggles .btn { padding: 9px 8px; font-size: 13px; }
.prejoin__status { color: var(--muted); font-size: 13px; margin: 0 0 14px; min-height: 1em; }

/* ───────────────────────── звонок ───────────────────────── */
.call {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.topbar__left { display: flex; gap: 8px; align-items: center; min-width: 0; }

.pill {
  font-size: 13px; color: var(--muted);
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 12px; white-space: nowrap;
}
.pill--quiet { color: #ffca7a; border-color: #4a3a22; background: #241d12; }

.stage { position: relative; overflow: auto; padding: 14px; min-height: 0; }

.grid {
  display: grid;
  gap: 12px;
  min-height: 100%;
  grid-template-columns: 1fr;
  align-content: center;
}
/* Втроём и больше даже на телефоне лучше сетка в два столбца, чем лента. */
.grid[data-count="3"], .grid[data-count="4"],
.grid[data-count="5"], .grid[data-count="6"] { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) {
  .grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
  /* Вшестером два ряда по три — плитки остаются крупнее, чем 2x3. */
  .grid[data-count="5"], .grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  position: relative;
  background: #05070a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 0;
}
/* Зеркалим только фронтальную камеру: заднюю и экран — как есть. */
.tile--mirror .tile__video { transform: scaleX(-1); }
.tile--sharing .tile__video { transform: none; }
.tile--speaking { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }

.tile__video { width: 100%; height: 100%; object-fit: cover; display: block; background: #05070a; }
.tile--novideo .tile__video { visibility: hidden; }

.tile__placeholder { position: absolute; inset: 0; display: none; place-items: center; background: linear-gradient(160deg, #161c26, #0b0f15); }
.tile--novideo .tile__placeholder { display: grid; }
.tile__initials {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 600; color: var(--muted);
}

.tile__bar {
  position: absolute; left: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 20px);
  background: rgba(5, 7, 10, .72);
  backdrop-filter: blur(6px);
  border-radius: 99px; padding: 5px 11px;
  font-size: 13px;
}
.tile__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__mic, .tile__share {
  flex: 0 0 auto; width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.tile__mic { color: #ff9a9a; }
.tile__share { color: #9dbcff; }

.tile__status {
  position: absolute; inset: 0;
  display: none; place-items: center;
  font-size: 13px; color: var(--muted);
  background: rgba(5, 7, 10, .65);
  text-align: center; padding: 16px;
}
.tile--pending .tile__status { display: grid; }

/* Режим «крупно»: на экране остаётся только выбранный собеседник, и кадр
   занимает всё окно — панели в этом режиме уезжают поверх видео
   (.call--immersive), поэтому места им резервировать не нужно.
   Два класса в селекторе не для красоты: .grid[data-count="3"] весит больше,
   чем одиночный .grid--spot, и кадр оставался в своей колонке — то есть ровно
   на половине экрана. Отсюда и брались те самые 50%. */
.grid.grid--spot { grid-template-columns: 1fr; grid-template-rows: 1fr; height: 100%; gap: 0; }
.grid--spot > .tile { display: none; }
.grid--spot > .tile--spot {
  display: block;
  aspect-ratio: auto;
  height: 100%;
  width: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
}
.grid--spot > .tile--spot.tile--speaking { box-shadow: none; }

.lonely {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  margin: 0; max-width: min(520px, calc(100% - 32px));
  text-align: center; color: var(--muted); font-size: 13px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 99px;
}

/* ───────────────────────── панель управления ───────────────────────── */
.controls {
  position: relative;
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.ctl {
  position: relative;
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 14px;
  min-width: 78px;
  display: grid; justify-items: center; gap: 2px;
  font: inherit;
  transition: background .15s, border-color .15s;
}
.ctl:hover { background: #222a35; }
.ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl__icon {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.ctl__icon .slash { display: none; }
#micBtn[aria-pressed="false"] .slash, #camBtn[aria-pressed="false"] .slash { display: inline; stroke: #ff9a9a; stroke-width: 2; }
.ctl__label { font-size: 11px; color: var(--muted); }
#micBtn[aria-pressed="false"], #camBtn[aria-pressed="false"] { background: #2a1a1f; border-color: #4a2630; }
#micBtn[aria-pressed="false"] .ctl__label, #camBtn[aria-pressed="false"] .ctl__label { color: #ffb4b4; }
#shareBtn[aria-pressed="true"], #chatBtn[aria-pressed="true"] { background: #1c2a4a; border-color: #2f4a80; }
#shareBtn[aria-pressed="true"] .ctl__label, #chatBtn[aria-pressed="true"] .ctl__label { color: #b9ccff; }
.ctl--danger { background: #3a1620; border-color: #5f2231; }
.ctl--danger:hover { background: #4a1c29; }
.ctl--danger .ctl__label { color: #ffb4b4; }
.ctl__badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}

/* ───────────────────────── чат ───────────────────────── */
.chat {
  grid-row: 2;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  min-height: 0;
}
@media (min-width: 900px) {
  .call:has(.chat:not([hidden])) { grid-template-columns: 1fr 320px; }
  .call:has(.chat:not([hidden])) .topbar { grid-column: 1 / -1; }
  .call:has(.chat:not([hidden])) .controls { grid-column: 1 / -1; }
  .chat { grid-column: 2; }
}
@media (max-width: 899px) {
  .chat {
    position: fixed; inset: auto 0 0 0;
    height: min(70vh, 460px);
    border-left: none; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    z-index: 20;
    padding-bottom: var(--safe-bottom);
    box-shadow: var(--shadow);
  }
}

.chat__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 14px;
}
.chat__log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.chat__form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.chat__form .btn { flex: 0 0 auto; }
.chat__note { margin: 0; padding: 0 14px 12px; font-size: 11px; color: var(--muted); }

.msg { max-width: 92%; }
.msg__meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg__body {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 11px; font-size: 14px;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg--self { margin-left: auto; }
.msg--self .msg__meta { text-align: right; }
.msg--self .msg__body { background: #23365e; border-color: #2f4a80; }
.msg--sys { max-width: 100%; text-align: center; color: var(--muted); font-size: 12px; }

/* ───────────────────────── завершение и уведомления ───────────────────────── */
.ended { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.ended__card {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow);
}
.ended__title { margin: 0 0 10px; font-size: 22px; }
.ended__text { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); font-size: 14px;
  padding: 10px 16px; border-radius: 99px;
  box-shadow: var(--shadow); z-index: 50;
  max-width: calc(100% - 32px); text-align: center;
}

@media (max-width: 520px) {
  .controls { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .ctl { min-width: 0; padding: 8px 9px; }
  .ctl__label { font-size: 10px; }
}

/* Выпадающий список камер над панелью управления */
.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 230px;
  max-width: calc(100vw - 32px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu__title {
  font-size: 11px; color: var(--muted);
  padding: 6px 12px 4px;
}
.menu__item {
  appearance: none; border: none; background: none;
  color: var(--text); font: inherit; text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu__item:hover { background: var(--bg-3); }
.menu__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu__item--on { color: var(--accent); }
.menu__item--on::after { content: ' ✓'; }

.build { margin: 14px 0 0; text-align: center; font-size: 11px; color: var(--muted); opacity: .7; }


/* ═══════════════════ полноэкранный кадр ═══════════════════
   Пропорции у собеседника почти никогда не совпадают с нашим экраном:
   телефон снимает вертикально, ноутбук показывает горизонтально. Обрезать
   лицо жалко, чёрные поля уродливы — поэтому кадр вписываем целиком, а пустоту
   заливаем его же размытой копией. Второй <video> берёт тот же поток,
   так что лишнего трафика нет.                                              */
.tile__backdrop {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
  filter: blur(34px) saturate(1.3) brightness(.45);
  pointer-events: none;
  display: none;
}
.tile--fill .tile__backdrop { display: block; }
.tile--fill .tile__video {
  object-fit: contain;
  position: relative;   /* иначе абсолютный фон рисуется поверх кадра */
  z-index: 1;
  background: transparent;
}
.tile--novideo .tile__backdrop { display: none; }

/* ═══════════════════ разговор вдвоём ═══════════════════
   Собеседник во весь экран, вы — окошком в углу, кнопки поверх видео и
   прячутся, когда экран не трогают.                                         */
.call--immersive { grid-template-rows: 1fr; }
.call--immersive .stage { grid-row: 1; grid-column: 1; padding: 0; overflow: hidden; }
.call--solo .grid { display: block; height: 100%; min-height: 0; gap: 0; }

.call--solo .grid > .tile {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}
.call--solo .grid > .tile.tile--speaking { box-shadow: none; }

/* подпись собеседника — под верхней панелью, уезжает вместе с ней */
.call--solo .grid > .tile:not(.tile--self) .tile__bar {
  left: 16px;
  top: calc(58px + var(--safe-top));
  bottom: auto;
  z-index: 3;
  font-size: 14px;
  padding: 7px 14px;
  transition: opacity .28s ease;
}

/* ── окошко с собой ── */
.call--solo .grid > .tile--self {
  position: absolute;
  inset: auto;
  width: clamp(92px, 25vw, 164px);
  height: auto;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .55);
  overflow: hidden;
  z-index: 8;
  touch-action: none;
  cursor: grab;
  transition: opacity .2s ease;
}
.call--solo .grid > .tile--self:active { cursor: grabbing; }
.call--solo .grid > .tile--self .tile__video { object-fit: cover; }
.call--solo .grid > .tile--self .tile__backdrop { display: none; }
.call--solo .tile--self .tile__name { display: none; }
.call--solo .tile--self .tile__bar { left: 6px; bottom: 6px; padding: 3px 7px; }
.call--solo .tile--self .tile__bar:empty { display: none; }
.call--solo .tile--self .tile__initials { width: 44px; height: 44px; font-size: 16px; }

/* четыре угла, между которыми прыгает окошко после перетаскивания */
.call--solo .tile--self.pip--tl { top: calc(104px + var(--safe-top)); left: 14px; }
.call--solo .tile--self.pip--tr { top: calc(66px + var(--safe-top)); right: 14px; }
.call--solo .tile--self.pip--bl { bottom: calc(106px + var(--safe-bottom)); left: 14px; }
.call--solo .tile--self.pip--br { bottom: calc(106px + var(--safe-bottom)); right: 14px; }
.call--solo .tile--self.pip--dragging { transition: none; cursor: grabbing; }

/* «Крупно» в разговоре вдвоём просто убирает окошко с собой */
.call--solo.call--hideself .grid > .tile--self { display: none; }

/* ── панели поверх видео ── */
.call--immersive .topbar,
.call--immersive .controls {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 12;
  border: none;
  transition: opacity .28s ease, transform .28s ease;
}
.call--immersive .topbar {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
  padding-bottom: 26px;
}
.call--immersive .controls {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
  padding-top: 28px;
}
.call--immersive .ctl,
.call--immersive .pill,
.call--immersive .btn--small {
  background: rgba(16, 20, 27, .66);
  border-color: rgba(255, 255, 255, .14);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.call--immersive .ctl:hover { background: rgba(32, 39, 50, .8); }
.call--immersive #micBtn[aria-pressed="false"],
.call--immersive #camBtn[aria-pressed="false"] { background: rgba(74, 32, 40, .8); }
.call--immersive .ctl--danger { background: rgba(88, 28, 42, .8); }

.call--immersive .chat { grid-row: 1; }

/* ── бездействие: убираем всё лишнее с экрана ── */
.call--immersive.call--idle .topbar { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.call--immersive.call--idle .controls { opacity: 0; transform: translateY(16px); pointer-events: none; }
.call--immersive.call--idle .grid > .tile:not(.tile--self) .tile__bar { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .call--immersive .topbar,
  .call--immersive .controls { transition: none; }
}


/* На узком экране панель становится рядом круглых кнопок: семь штук в одну
   строку, меньше загораживают собеседника и ближе к тому, как это выглядит
   в обычных видеозвонилках. */
@media (max-width: 560px) {
  .controls { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .ctl {
    width: 46px;
    height: 46px;
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    place-items: center;
  }
  .ctl__label { display: none; }
  .ctl__icon { width: 21px; height: 21px; }
  .ctl__badge { top: -3px; right: -3px; }
  .call--immersive .grid > .tile:not(.tile--self) .tile__bar { font-size: 13px; padding: 6px 12px; }
}

/* Кнопок стало восемь — на узких телефонах ужимаем, чтобы влезли в одну строку. */
@media (max-width: 430px) {
  .controls { gap: 5px; padding-left: 6px; padding-right: 6px; }
  .ctl { width: 40px; height: 40px; }
  .ctl__icon { width: 19px; height: 19px; }
}


/* ═══════════════════ подсветка лица ═══════════════════
   В тёмной комнате камера телефона показывает собеседнику силуэт. Светлая
   рамка поверх видео превращает экран в лампу: лицо освещено, а картинка
   собеседника остаётся на месте. Яркость переключается кнопкой «Свет».    */
.glow {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  --glow-a: .6;
  box-shadow:
    inset 0 0 0 9vmin rgba(255, 246, 232, var(--glow-a)),
    inset 0 0 14vmin 9vmin rgba(255, 246, 232, calc(var(--glow-a) * .5));
  transition: box-shadow .2s ease;
}
#lightBtn[aria-pressed="true"] { background: #3a3220; border-color: #6b5a2e; }
#lightBtn[aria-pressed="true"] .ctl__label { color: #ffe6b0; }
.call--immersive #lightBtn[aria-pressed="true"] { background: rgba(88, 74, 36, .8); }

/* ═══════════════════ фотографии в чате ═══════════════════ */
.btn--attach {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: var(--muted);
}
.btn--attach svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn--attach:hover:not(:disabled) { color: var(--text); background: none; }

.msg__photo {
  display: block;
  width: 260px;
  max-width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  cursor: zoom-in;
}
.msg--self .msg__photo { margin-left: auto; }
.msg__note { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg--self .msg__note { text-align: right; }

.msg__link { color: #9dbcff; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg__link:hover { color: #c8d8ff; }

.chat--drop { outline: 2px dashed var(--accent); outline-offset: -6px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 5, 8, .93);
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 14px;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; }
.lightbox__bar { display: flex; gap: 8px; }
.lightbox__bar .btn { text-decoration: none; }


/* ═══════════════════ совместный просмотр ═══════════════════
   Фильм занимает центр, лица всех участников уезжают в ленту справа
   (на телефоне — под фильм). Кнопки плеера свои: так любое нажатие
   уходит всем, а не только в плеер того, кто нажал.                        */
#watchBtn[aria-pressed="true"] { background: #1c2a4a; border-color: #2f4a80; }
#watchBtn[aria-pressed="true"] .ctl__label { color: #b9ccff; }
.call--watching #spotBtn[aria-pressed="true"] { background: #1c2a4a; border-color: #2f4a80; }

.call--watching .stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(150px, 17vw, 240px);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}
.call--watching .lonely { display: none; }

.watch {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.watch__screen { position: relative; flex: 1; min-height: 0; background: #000; }
.watch__mount, .watch__mount > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.watch__mount iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.watch__video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.watch__shield { position: absolute; inset: 0; z-index: 2; cursor: pointer; }

.watch__wait {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  z-index: 3; max-width: calc(100% - 28px);
  background: rgba(10, 12, 16, .82); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 99px; padding: 7px 14px;
  font-size: 13px; color: #ffe0a8; text-align: center;
  pointer-events: none;
}

.watch__notice {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 4; width: min(440px, calc(100% - 24px));
  background: rgba(10, 12, 16, .9); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-radius: 14px; padding: 14px 16px;
  display: grid; gap: 10px; justify-items: center; text-align: center;
  box-shadow: var(--shadow);
}
.watch__notice-text { margin: 0; font-size: 14px; }

.watch__bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
}
.watch__time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.wbtn {
  appearance: none; border: none; background: none; color: var(--text);
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 8px; cursor: pointer;
}
.wbtn:hover:not(:disabled) { background: var(--bg-3); }
.wbtn:disabled { opacity: .4; cursor: not-allowed; }
.wbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wbtn--play { background: var(--accent); color: #fff; border-radius: 50%; }
.wbtn--play:hover:not(:disabled) { background: #5b7cf5; }
.wbtn--play svg { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.wbtn__pause { display: none; }
.wbtn--play.is-playing .wbtn__pause { display: block; }
.wbtn--play.is-playing .wbtn__play { display: none; }
.wbtn__x { display: none; }
.wbtn--mute.is-muted .wbtn__x { display: inline; }
.wbtn--mute.is-muted .wbtn__waves { display: none; }

.watch__seek, .watch__vol {
  -webkit-appearance: none; appearance: none;
  height: 22px; background: none; cursor: pointer; margin: 0;
}
.watch__seek { flex: 1; min-width: 60px; --p: 0%; }
.watch__vol { width: 80px; flex: 0 0 auto; }
.watch__seek::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p), #2c3542 var(--p));
}
.watch__vol::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: #2c3542; }
.watch__seek::-moz-range-track, .watch__vol::-moz-range-track { height: 5px; border-radius: 99px; background: #2c3542; }
.watch__seek::-moz-range-progress { height: 5px; border-radius: 99px; background: var(--accent); }
.watch__seek::-webkit-slider-thumb, .watch__vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -4.5px;
  border-radius: 50%; background: #fff; border: none;
}
.watch__vol::-webkit-slider-thumb { margin-top: -5px; }
.watch__seek::-moz-range-thumb, .watch__vol::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: none; }
.watch__seek:disabled { opacity: .4; cursor: not-allowed; }

/* во весь экран — только фильм и его кнопки */
.watch:fullscreen { border: none; border-radius: 0; }
.watch:-webkit-full-screen { border: none; border-radius: 0; width: 100%; height: 100%; }

/* ── лента с лицами ── */
.call--watching .grid {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  justify-content: flex-start;
}
.call--watching .grid > .tile {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  cursor: default;
}
.call--watching .tile__bar { left: 6px; bottom: 6px; padding: 3px 9px; font-size: 12px; }
.call--watching .tile__initials { width: 46px; height: 46px; font-size: 17px; }

/* «Крупно» во время фильма: лента прячется, фильм на всю ширину */
.call--theater .stage { grid-template-columns: minmax(0, 1fr); }
.call--theater .grid { display: none !important; }

/* Телефон вертикально: фильм сверху во всю ширину, лица двумя колонками под ним */
@media (max-width: 760px), (max-width: 1000px) and (orientation: portrait) {
  .call--watching .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    gap: 8px;
  }
  .call--watching .watch { border-left: none; border-right: none; border-top: none; border-radius: 0; }
  .call--watching .watch__screen { flex: none; aspect-ratio: 16 / 9; }
  .call--watching .grid {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    padding: 0 8px 8px;
  }
  .call--watching .grid > .tile { width: calc(50% - 5px); max-width: 260px; }
  .call--theater .stage { grid-template-rows: minmax(0, 1fr); }
  .call--theater .watch__screen { flex: 1; aspect-ratio: auto; }
  .watch__vol { display: none; }
  .watch__bar { gap: 6px; padding: 6px 8px; }
}

/* Телефон горизонтально: места по высоте мало — лента узкая */
@media (max-height: 520px) and (orientation: landscape) {
  .call--watching .stage { grid-template-columns: minmax(0, 1fr) 132px; padding: 6px; gap: 6px; }
  .call--watching .grid { gap: 6px; }
  .watch__vol { display: none; }
}

/* ── окно «что смотрим» ── */
.modal {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(3, 5, 8, .72);
  display: grid; place-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.modal__card {
  width: 100%; max-width: 480px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
  display: grid; gap: 12px;
}
.modal__title { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal__text { margin: 0; color: var(--muted); font-size: 14px; }
.modal__hint { margin: 0; color: var(--muted); font-size: 12px; padding: 9px 12px; background: var(--bg-3); border-radius: 10px; }
.modal__card .error { margin: 0; }
.modal__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal__actions .btn--primary { flex: 1; }
.btn--quiet-danger { background: none; border-color: transparent; color: #ff9a9a; justify-self: center; }
.btn--quiet-danger:hover:not(:disabled) { background: #2a1a1f; }

/* Кнопок в панели теперь девять — на самых узких телефонах ужимаем ещё. */
@media (max-width: 400px) {
  .controls { gap: 3px; padding-left: 4px; padding-right: 4px; }
  .ctl { width: 36px; height: 36px; }
  .ctl__icon { width: 18px; height: 18px; }
}

/* Уведомления не должны перекрывать кнопки: во время фильма в этом месте
   лежит полоса перемотки, и тост «Маша перематывает на…» съедал клики. */
.toast { pointer-events: none; }
body:has(.call--watching) .toast { bottom: auto; top: calc(64px + var(--safe-top)); }

/* Вход зрителем: для телевизора и всех, у кого нет камеры или она не отвечает */
.btn--viewer { margin-top: 8px; background: none; color: var(--muted); }
.btn--viewer:hover:not(:disabled) { color: var(--text); }

/* ═══════════════════ кино: камеры и сообщения поверх фильма ═══════════════════ */

/* кнопка «камеры» на полосе плеера: перечёркнута, когда камеры скрыты */
.wbtn--faces .slash { display: none; stroke: #ff9a9a; }
.wbtn--faces[aria-pressed="false"] .slash { display: inline; }
.wbtn--faces[aria-pressed="false"] { color: var(--muted); }

/* сообщения чата пролетают по фильму справа налево */
.danmaku {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}
.danmaku__item {
  position: absolute;
  left: 0;
  white-space: nowrap;
  font-weight: 700;
  font-size: clamp(16px, 2.3vw, 30px);
  line-height: 1.2;
  letter-spacing: .01em;
  will-change: transform, opacity;
  /* обводка, чтобы текст читался и на светлом, и на тёмном кадре */
  text-shadow:
    0 0 2px rgba(0, 0, 0, .95),
    0 1px 3px rgba(0, 0, 0, .9),
    0 0 12px rgba(0, 0, 0, .55);
}
.danmaku__who { font-weight: 600; opacity: .8; font-size: .8em; }


/* ═══════════════════ кино: участник рядом с фильмом ═══════════════════
   Фильм 60–70% ширины, выбранный участник (камера или показ экрана) — на всё
   остальное место; остальные лица маленькой строкой под ним. Граница между
   ними перетаскивается (--film / --side ставит app.js).                    */
.splitter { display: none; }

.call--focus .stage {
  grid-template-columns: minmax(0, var(--film, 66fr)) 16px minmax(0, var(--side, 34fr));
  gap: 0;
}
.call--focus .watch { grid-column: 1; }
.call--focus .splitter {
  display: block;
  grid-column: 2;
  grid-row: 1;
  position: relative;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}
.splitter::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 4px; height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 99px;
  background: rgba(255, 255, 255, .16);
  transition: background .15s, height .2s, box-shadow .2s;
}
.splitter:hover::before,
.splitter:focus-visible::before,
.call--resizing .splitter::before {
  background: var(--accent);
  height: 84px;
  box-shadow: 0 0 18px rgba(108, 140, 255, .65);
}
.call--resizing, .call--resizing * { cursor: col-resize !important; user-select: none; -webkit-user-select: none; }
/* иначе курсор «проваливается» в iframe YouTube и граница перестаёт тянуться */
.call--resizing .watch__mount,
.call--resizing .watch__shield,
.call--resizing .grid { pointer-events: none; }

.call--focus .grid {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  grid-template-rows: minmax(0, 1fr);
  grid-auto-rows: auto;
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  align-content: stretch;
  padding: 0;
}
.call--focus .grid > .tile { width: auto; max-width: none; aspect-ratio: 4 / 3; }
.call--focus .grid > .tile--focus {
  grid-column: 1 / -1;
  grid-row: 1;
  order: -1;
  aspect-ratio: auto;
  height: 100%;
  min-height: 0;
}
.call--focus .grid > .tile:not(.tile--focus) .tile__name { font-size: 11px; }
.call--focus .grid > .tile:not(.tile--focus) .tile__bar { left: 4px; bottom: 4px; padding: 2px 7px; }
.call--focus .grid > .tile:not(.tile--focus) .tile__initials { width: 34px; height: 34px; font-size: 13px; }
.call--focus .tile--focus .tile__bar { left: 12px; bottom: 12px; padding: 6px 13px; font-size: 14px; }
.call--focus .tile--focus .tile__initials { width: 84px; height: 84px; font-size: 30px; }

/* кнопка «рядом» на полосе плеера горит, когда режим включён */
.wbtn--split[aria-pressed="true"] { color: #b9ccff; background: rgba(108, 140, 255, .18); }

/* Телефон вертикально: фильм сверху, выбранный — на всё место под ним */
@media (max-width: 760px), (max-width: 1000px) and (orientation: portrait) {
  .call--focus .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
  }
  .call--focus .splitter { display: none; }
  .call--focus .grid {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    padding: 0 8px 8px;
  }
  .call--focus .grid > .tile { width: auto; max-width: none; }
}

/* ═══════════════════ громкость участника у себя ═══════════════════ */
.tile__vol {
  display: none;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  height: 22px;
  margin: -3px -6px -3px 1px;
  padding: 0 6px;
  border: none;
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
  color: inherit;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s;
}
.tile__vol:hover { background: rgba(255, 255, 255, .22); }
.tile__vol:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tile__vol svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile__vol-x { display: none; }
.tile__vol.is-off { color: #ff9a9a; background: rgba(255, 90, 90, .18); }
.tile__vol.is-off .tile__vol-x { display: inline; }
.tile__vol.is-off .tile__vol-waves { display: none; }
.tile__vol-val:empty { display: none; }
.tile:hover .tile__vol,
.call--watching .tile .tile__vol,
.tile--quiet .tile__vol { display: inline-flex; }
.call--idle .tile__vol { pointer-events: none; }


/* ═══════════════════ оформление: стекло, свет, движение ═══════════════════ */
.page-room {
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(108, 140, 255, .14), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(61, 220, 151, .08), transparent 60%),
    var(--bg);
}

/* шапка и панель — стекло вместо сплошных плашек */
.topbar {
  background: rgba(14, 17, 23, .62);
  border-bottom-color: rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}
.pill { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .09); }

/* панель управления — парящий док по центру */
.call:not(.call--immersive) .controls {
  justify-self: center;
  width: fit-content;
  max-width: calc(100% - 16px);
  margin: 4px 0 calc(10px + var(--safe-bottom));
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 22px;
  background: rgba(16, 20, 27, .72);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.ctl {
  border-color: rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .045);
  border-radius: 14px;
  transition: background .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.ctl:hover { background: rgba(255, 255, 255, .1); transform: translateY(-1px); }
.ctl:active { transform: translateY(0) scale(.96); }

/* включённые режимы — подсветка акцентом */
#shareBtn[aria-pressed="true"],
#chatBtn[aria-pressed="true"],
#watchBtn[aria-pressed="true"],
.call--watching #spotBtn[aria-pressed="true"],
#spotBtn[aria-pressed="true"] {
  background: linear-gradient(160deg, rgba(108, 140, 255, .38), rgba(108, 140, 255, .16));
  border-color: rgba(140, 165, 255, .55);
  box-shadow: 0 6px 22px rgba(108, 140, 255, .28);
}
#shareBtn[aria-pressed="true"] .ctl__label,
#chatBtn[aria-pressed="true"] .ctl__label,
#watchBtn[aria-pressed="true"] .ctl__label,
#spotBtn[aria-pressed="true"] .ctl__label { color: #dbe4ff; }
#micBtn[aria-pressed="false"], #camBtn[aria-pressed="false"] {
  background: linear-gradient(160deg, rgba(255, 90, 90, .3), rgba(255, 90, 90, .12));
  border-color: rgba(255, 120, 120, .45);
}
.ctl--danger {
  background: linear-gradient(160deg, #e5484d, #b8323a);
  border-color: rgba(255, 140, 140, .35);
  box-shadow: 0 6px 22px rgba(229, 72, 77, .32);
}
.ctl--danger:hover { background: linear-gradient(160deg, #f05a5f, #c63a42); }
.ctl--danger .ctl__label, .ctl--danger .ctl__icon { color: #fff; }

/* плитки: мягче углы, плавное появление, живое свечение у говорящего */
.tile {
  border-radius: 16px;
  border-color: rgba(255, 255, 255, .07);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  transition: box-shadow .25s ease, border-color .25s ease;
  animation: tile-in .35s ease both;
}
@keyframes tile-in {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: none; }
}
.tile--speaking {
  border-color: rgba(61, 220, 151, .9);
  box-shadow: 0 0 0 2px rgba(61, 220, 151, .55), 0 0 26px rgba(61, 220, 151, .32);
}
.tile__bar { background: rgba(8, 10, 14, .55); border: 1px solid rgba(255, 255, 255, .08); }
.call--watching .grid > .tile:not(.tile--self):hover { border-color: rgba(140, 165, 255, .55); }
.tile__placeholder { background: radial-gradient(120% 90% at 50% 0%, #1d2533, #0b0f15 70%); }
.tile__initials {
  background: linear-gradient(160deg, #2a3550, #1a2131);
  border-color: rgba(255, 255, 255, .1);
  color: #c9d5ee;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .4);
}

/* ── кино ── */
.call--watching .stage { position: relative; }
/* «амбилайт»: размытый отсвет кадра вокруг фильма (только для видеофайла) */
.watch__ambient {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  filter: blur(46px) saturate(1.5);
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.2s ease;
}
.watch__ambient.is-on { opacity: .5; }
.call:not(.call--watching) .watch__ambient,
.call--theater .watch__ambient { display: none; }
.watch { z-index: 1; }
.call--watching .watch {
  border-color: rgba(255, 255, 255, .07);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.watch__bar {
  background: rgba(14, 17, 23, .85);
  border-top-color: rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.wbtn { transition: background .15s, color .15s, transform .12s; }
.wbtn:active:not(:disabled) { transform: scale(.92); }
.wbtn--play {
  background: linear-gradient(160deg, #7f9bff, #5574f0);
  box-shadow: 0 6px 18px rgba(108, 140, 255, .45);
}
.wbtn--play:hover:not(:disabled) { background: linear-gradient(160deg, #91a9ff, #6383f5); }
.watch__seek::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #8aa3ff, var(--accent) var(--p), rgba(255, 255, 255, .12) var(--p));
}
.watch__seek::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(108, 140, 255, .28), 0 2px 8px rgba(0, 0, 0, .5); }
.watch__seek:hover::-webkit-slider-thumb { transform: scale(1.15); }

/* модальные окна, тосты, чат — то же стекло */
.modal { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal__card, .prejoin__card, .ended__card {
  background: linear-gradient(180deg, rgba(26, 32, 43, .92), rgba(16, 20, 27, .94));
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.toast {
  background: rgba(22, 27, 36, .86);
  border-color: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: toast-in .25s ease both;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.chat { background: rgba(14, 17, 23, .82); border-left-color: rgba(255, 255, 255, .06); }
.msg__body { border-radius: 14px; border-color: rgba(255, 255, 255, .07); background: rgba(255, 255, 255, .05); }
.msg--self .msg__body { background: linear-gradient(160deg, #3a56a8, #2a3f80); border-color: rgba(140, 165, 255, .35); }
.btn--primary { background: linear-gradient(160deg, #7f9bff, #5574f0); border-color: transparent; box-shadow: 0 8px 22px rgba(108, 140, 255, .3); }
.btn--primary:hover:not(:disabled) { background: linear-gradient(160deg, #91a9ff, #6383f5); }

@media (prefers-reduced-motion: reduce) {
  .tile, .toast { animation: none; }
  .ctl, .wbtn { transition: none; }
}

/* кадр во весь размер лежит на z-index 1 — подпись и кнопка громкости должны быть над ним */
.tile--fill .tile__bar { z-index: 3; }
.tile--fill .tile__status { z-index: 4; }
.call--immersive .ctl--danger { background: linear-gradient(160deg, rgba(229, 72, 77, .92), rgba(184, 50, 58, .92)); }
.call--immersive #micBtn[aria-pressed="false"],
.call--immersive #camBtn[aria-pressed="false"] { background: linear-gradient(160deg, rgba(255, 90, 90, .42), rgba(120, 36, 44, .7)); }
/* в своём окошке подпись нужна, только если на ней есть значок (микрофон выключен, показ экрана) */
.call--solo .tile--self .tile__bar:not(:has(.tile__mic:not([hidden]), .tile__share:not([hidden]))) { display: none; }

/* Во весь экран вместе с участником: разворачивается весь «стол» (#stage) —
   фильм, граница и выбранный собеседник, раскладка та же, что в окне. */
.stage:fullscreen { background: var(--bg); padding: 12px; overflow: hidden; }
.stage:-webkit-full-screen { background: var(--bg); padding: 12px; overflow: hidden; width: 100%; height: 100%; }
.stage:fullscreen .watch__ambient.is-on { opacity: .35; }


/* ═══════════════════ кино: собеседник окошком поверх фильма ═══════════════════
   Как у стримеров: фильм во всю ширину, камера собеседника — в углу кадра.
   Размер и место считает app.js (layoutOverlay), здесь только вид.        */
.call--overlay .stage { grid-template-columns: minmax(0, 1fr); }
.call--overlay .grid {
  position: absolute;
  inset: 0;
  grid-column: auto;
  grid-row: auto;
  display: block !important;
  height: auto;
  padding: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}
.call--overlay .grid > .tile { display: none; }
.call--overlay .grid > .tile.tile--overlay {
  display: block;
  position: absolute;
  inset: auto;
  aspect-ratio: auto;
  max-width: none;
  margin: 0;
  pointer-events: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .65), 0 0 0 1px rgba(0, 0, 0, .35);
  cursor: grab;
  touch-action: none;
  animation: tile-in .3s ease both;
  transition: box-shadow .2s, border-color .2s;
}
.call--overlay .grid > .tile--overlay.ov--dragging,
.call--overlay .grid > .tile--overlay.ov--sizing { transition: none; cursor: grabbing; box-shadow: 0 24px 60px rgba(0, 0, 0, .75), 0 0 0 2px var(--accent); }
.call--overlay .grid > .tile--overlay.tile--speaking { border-color: rgba(61, 220, 151, .9); box-shadow: 0 18px 48px rgba(0, 0, 0, .65), 0 0 0 2px rgba(61, 220, 151, .55); }
.tile--overlay .tile__video { object-fit: cover; }
.tile--overlay.tile--sharing .tile__video { object-fit: contain; background: #000; }
.tile--overlay .tile__backdrop { display: none; }
.tile--overlay .tile__initials { width: 44px; height: 44px; font-size: 16px; }
/* подпись — только когда навели: в кадре ничего лишнего */
.tile--overlay .tile__bar { left: 6px; bottom: 6px; padding: 3px 8px; font-size: 12px; opacity: 0; transition: opacity .2s; z-index: 3; }
.tile--overlay:hover .tile__bar,
.tile--overlay.tile--quiet .tile__bar { opacity: 1; }
/* пока тянем окошко, курсор не должен проваливаться в iframe YouTube */
.call--ovdrag .watch__mount, .call--ovdrag .watch__shield { pointer-events: none; }
.call--ovdrag, .call--ovdrag * { user-select: none; -webkit-user-select: none; }

/* уголок для размера — на внутреннем углу, со стороны центра кадра */
.tile__grip { display: none; }
.tile--overlay .tile__grip {
  display: block;
  position: absolute;
  z-index: 4;
  width: 26px;
  height: 26px;
  opacity: 0;
  transition: opacity .2s;
}
.tile--overlay .tile__grip::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 0 solid rgba(255, 255, 255, .9);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .8));
}
.tile--overlay:hover .tile__grip, .tile--overlay.ov--sizing .tile__grip { opacity: 1; }
.ov--br .tile__grip { left: 0; top: 0; cursor: nwse-resize; }
.ov--br .tile__grip::before { border-left-width: 2.5px; border-top-width: 2.5px; border-top-left-radius: 4px; }
.ov--bl .tile__grip { right: 0; top: 0; cursor: nesw-resize; }
.ov--bl .tile__grip::before { border-right-width: 2.5px; border-top-width: 2.5px; border-top-right-radius: 4px; }
.ov--tr .tile__grip { left: 0; bottom: 0; cursor: nesw-resize; }
.ov--tr .tile__grip::before { border-left-width: 2.5px; border-bottom-width: 2.5px; border-bottom-left-radius: 4px; }
.ov--tl .tile__grip { right: 0; bottom: 0; cursor: nwse-resize; }
.ov--tl .tile__grip::before { border-right-width: 2.5px; border-bottom-width: 2.5px; border-bottom-right-radius: 4px; }
@media (hover: none) {
  .tile--overlay .tile__grip { opacity: .75; }
}

/* кнопка на полосе плеера: в режиме «поверх» значок — окошко в углу кадра */
.wbtn--split[data-mode="overlay"] { color: #b9ccff; background: rgba(108, 140, 255, .18); }

/* Телефон вертикально: фильм остаётся 16:9 сверху (иначе картинка — полоска
   посреди чёрного), окошко ходит по нему */
@media (max-width: 760px), (max-width: 1000px) and (orientation: portrait) {
  .call--overlay .stage { grid-template-rows: auto minmax(0, 1fr); }
}
.stage:fullscreen .grid { z-index: 5; }
.toast { border-radius: 18px; }
/* поверх фильма во весь экран — плеер от края до края, окошко прижимается к самому краю экрана */
.call--overlay .stage:fullscreen { padding: 0; }
.call--overlay .stage:-webkit-full-screen { padding: 0; }
.call--overlay .stage:fullscreen .watch,
.call--overlay .stage:-webkit-full-screen .watch { border: none; border-radius: 0; box-shadow: none; }

/* ═══════════════════ весь звук у себя — выкл ═══════════════════ */
.topbar__right { display: flex; gap: 8px; align-items: center; }
.btn--sound { display: inline-flex; align-items: center; gap: 6px; }
.btn--sound svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn--sound .sound__x { display: none; }
.btn--sound[aria-pressed="true"] { background: rgba(255, 90, 90, .22); border-color: rgba(255, 120, 120, .5); color: #ffc4c4; }
.btn--sound[aria-pressed="true"] .sound__x { display: inline; }
.btn--sound[aria-pressed="true"] .sound__waves { display: none; }
/* пока звук выключен, кнопка не прячется вместе с шапкой — иначе легко забыть */
.call--immersive.call--idle.call--silent .topbar { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 560px) {
  .btn--sound .sound__label { display: none; }
  .btn--sound { padding: 7px 10px; }
}
/* шапка на узком телефоне: кнопки в одну строку, счётчик участников ужимается */
#copyLink { white-space: nowrap; }
.topbar__left { flex: 1 1 auto; }
.topbar__left .pill { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar__right { flex: 0 0 auto; }
@media (max-width: 430px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .topbar__left .pill { max-width: 40vw; }
  #copyLink { padding: 7px 10px; font-size: 12px; }
}
