/* Sozvon — интерфейс звонилки.
   Чернильная глубина, стекло, одна живая деталь: аура вокруг говорящего. */

:root {
  --bg: #07080c;
  --bg-2: #0c0e16;
  --panel: rgba(17, 19, 29, 0.82);
  --panel-solid: #12141d;
  --surface: #171a25;
  --surface-hi: #202433;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f6;
  --muted: #98a0b3;
  --faint: #626a7d;

  --accent: #7c5cff;
  --accent-2: #5ce1ff;
  --accent-soft: rgba(124, 92, 255, 0.18);
  --live: #3ef0a3;
  --danger: #ff4d6d;
  --warn: #ffb347;

  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));

  --r-tile: 18px;
  --r-panel: 20px;
  --r-chip: 10px;

  --topbar-h: 56px;
  --dock-h: 96px;
  --side-w: 248px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  --font-ui: Manrope, ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: Unbounded, Manrope, ui-sans-serif, system-ui, sans-serif;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(92, 225, 255, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* зерно — чтобы чёрный не был плоским */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

::selection {
  background: rgba(124, 92, 255, 0.4);
}

/* ---------------------------------------------------------------- вход */

.join {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 520px);
  gap: 56px;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px;
  z-index: 1;
}

.join__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* одна оркестрованная сцена появления */
.join__form > *,
.join__preview {
  animation: rise 0.7s var(--ease) both;
}

.join__form > :nth-child(1) { animation-delay: 0.02s; }
.join__form > :nth-child(2) { animation-delay: 0.08s; }
.join__form > :nth-child(3) { animation-delay: 0.14s; }
.join__form > :nth-child(4) { animation-delay: 0.20s; }
.join__form > :nth-child(5) { animation-delay: 0.24s; }
.join__form > :nth-child(6) { animation-delay: 0.28s; }
.join__form > :nth-child(7) { animation-delay: 0.32s; }
.join__form > :nth-child(8) { animation-delay: 0.36s; }
.join__preview { animation-delay: 0.18s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--grad);
  box-shadow: 0 10px 30px -10px rgba(124, 92, 255, 0.9);
}

.brand__mark svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand__name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.join h1 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.join h1 em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.join__sub {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 15px;
}

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

.field > span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

.field input,
.field select {
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.field input::placeholder {
  color: var(--faint);
}

.field input:hover,
.field select:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--surface-hi);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field--room input {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field small {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

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

.row > .field {
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-hi);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s var(--spring), border-color 0.15s, box-shadow 0.15s;
}

.btn:hover {
  background: #283042;
  border-color: var(--line-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  position: relative;
  border-color: transparent;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 14px 34px -14px rgba(124, 92, 255, 0.9);
}

.btn--primary:hover {
  background: var(--grad);
  filter: brightness(1.08);
  box-shadow: 0 18px 40px -14px rgba(124, 92, 255, 1);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface);
  color: var(--text);
}

.btn--big {
  height: 56px;
  font-size: 16px;
  border-radius: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.join__note {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

.join__error {
  padding: 12px 14px;
  border: 1px solid rgba(255, 77, 109, 0.4);
  border-radius: var(--r-chip);
  background: rgba(255, 77, 109, 0.1);
  color: #ffb3c0;
  font-size: 13px;
}

/* превью камеры на входе — карточка с живой рамкой */

.preview {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-panel);
  background: #05060a;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--line),
    0 40px 90px -40px rgba(0, 0, 0, 0.9),
    0 0 80px -30px rgba(124, 92, 255, 0.5);
}

.preview::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(124, 92, 255, 0.7), transparent 40%, transparent 60%, rgba(92, 225, 255, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview__off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--faint);
  text-align: center;
}

.preview__bar {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview__bar .btn {
  height: 40px;
  padding: 0 12px;
  background: rgba(10, 12, 18, 0.7);
  backdrop-filter: blur(10px);
}

.preview__meter {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.preview__meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--live), var(--accent-2));
  transition: width 0.08s linear;
}

/* ---------------------------------------------------------------- вход в комнату: створки */

.curtain {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  pointer-events: none;
}

.curtain__half {
  flex: 1;
  height: 100%;
  background: radial-gradient(120% 120% at 50% 50%, #f0b39d 0%, #d98a72 55%, #a85d49 100%);
  box-shadow: inset 0 0 120px rgba(80, 30, 20, 0.5);
  will-change: transform;
}

.curtain__half:first-child {
  border-radius: 0 48% 48% 0 / 0 50% 50% 0;
  transform-origin: left center;
}

.curtain__half:last-child {
  border-radius: 48% 0 0 48% / 50% 0 0 50%;
  transform-origin: right center;
}

.curtain--open .curtain__half:first-child {
  animation: cheekLeft 1.1s var(--spring) forwards;
}

.curtain--open .curtain__half:last-child {
  animation: cheekRight 1.1s var(--spring) forwards;
}

@keyframes cheekLeft {
  0% { transform: translateX(0) scaleX(1); }
  35% { transform: translateX(-4%) scaleX(1.06); }
  100% { transform: translateX(-104%) scaleX(0.92); }
}

@keyframes cheekRight {
  0% { transform: translateX(0) scaleX(1); }
  35% { transform: translateX(4%) scaleX(1.06); }
  100% { transform: translateX(104%) scaleX(0.92); }
}

/* ---------------------------------------------------------------- звонок */

.call {
  position: relative;
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "side stage";
  height: 100%;
  z-index: 1;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.topbar__room {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.topbar__room b {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar__copy {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-hi);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.topbar__copy:hover {
  background: var(--accent);
  color: #fff;
}

.topbar__spacer {
  flex: 1;
}

.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

.conn__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.conn--live .conn__dot {
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(62, 240, 163, 0.18), 0 0 12px rgba(62, 240, 163, 0.6);
}

.conn--bad .conn__dot {
  background: var(--warn);
}

.conn--off .conn__dot {
  background: var(--danger);
}

/* сайдбар участников */

.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--panel);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.side__head {
  padding: 16px 16px 8px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
}

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

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}

.member:hover {
  background: rgba(255, 255, 255, 0.05);
}

.member--speaking {
  background: rgba(62, 240, 163, 0.09);
}

.member__av {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--av, var(--surface-hi));
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.member--speaking .member__av {
  box-shadow: 0 0 0 2px var(--live), 0 0 14px rgba(62, 240, 163, 0.5);
}

.member__name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}

.member__icons {
  display: flex;
  gap: 5px;
  color: var(--danger);
}

.member__icons svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.member__vol {
  color: var(--muted);
}

.member__screen {
  color: var(--accent-2);
}

.side__hint {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

/* сцена и сетка */

.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0 16px calc(var(--dock-h) + 8px);
  overflow: hidden;
}

.grid {
  display: grid;
  gap: 12px;
  width: 100%;
  height: 100%;
  align-content: center;
  justify-content: center;
}

.tile {
  position: relative;
  /* Плитка держит кадр 16:9 (3:4 на телефоне в портрете) и центрируется в ячейке. */
  aspect-ratio: var(--tile-ar, 16 / 9);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  border-radius: var(--r-tile);
  background: #05060a;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  box-shadow: 0 0 0 1px var(--line), 0 30px 60px -40px rgba(0, 0, 0, 0.9);
  transition: box-shadow 0.2s;
}

/* аура говорящего: вращающийся градиент, толщина — от громкости */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: calc(2px + var(--lvl, 0) * 4px);
  background: conic-gradient(from var(--spin, 0deg), var(--live), var(--accent-2), var(--accent), var(--live));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: var(--ring, 0);
  transition: opacity 0.12s, padding 0.09s linear;
  pointer-events: none;
  z-index: 3;
  animation: spin 3s linear infinite;
}

@property --spin {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes spin {
  to { --spin: 360deg; }
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05060a;
}

.tile--self video {
  transform: scaleX(-1);
}

.tile--screen video {
  object-fit: contain;
}

.tile--dragging {
  cursor: grabbing;
}

.tile--novideo video {
  display: none;
}

.tile:not(.tile--novideo) .tile__avatar {
  display: none;
}

.tile__avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 30%, #161a26, #07080c);
}

.tile__avatar span {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--av, var(--surface-hi));
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
}

.tile__label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 20px);
  padding: 6px 11px;
  border: 0;
  border-radius: 999px;
  background: rgba(8, 10, 16, 0.7);
  backdrop-filter: blur(10px);
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  z-index: 4;
  transition: background 0.14s;
}

.tile__label:hover {
  background: rgba(124, 92, 255, 0.55);
}

.tile__label span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile__label svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: var(--danger);
}

.tile__stat {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(8, 10, 16, 0.7);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  z-index: 4;
}

.tile__stat--bad {
  color: var(--warn);
}

.tile__fs {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(8, 10, 16, 0.7);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  z-index: 4;
  transition: opacity 0.15s, background 0.15s;
}

.tile__fs svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.tile__fs:hover {
  background: var(--accent);
}

.tile:hover .tile__fs,
.tile:focus-within .tile__fs {
  opacity: 1;
}

@media (hover: none) {
  .tile__fs {
    opacity: 0.8;
  }
}

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

.grid--focus > .tile--focus {
  grid-column: 1 / -1;
  grid-row: 1;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
}

.grid--focus > .tile--focus.tile--screen {
  background: #000;
}

.grid--focus > .tile:not(.tile--focus) {
  grid-row: 2;
}

.tile:fullscreen {
  border-radius: 0;
  background: #000;
  aspect-ratio: auto;
  max-width: none;
  max-height: none;
}

.tile:fullscreen video {
  object-fit: contain;
}

.tile:fullscreen .tile__fs {
  opacity: 0.6;
}

.zoom-badge {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(8, 10, 16, 0.78);
  backdrop-filter: blur(8px);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 5;
}

.empty {
  position: absolute;
  inset: 0 16px var(--dock-h);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.empty h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.empty p {
  margin: 0;
  max-width: 42ch;
}

.empty b {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

/* парящий док */

.dock {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  z-index: 10;
}

.ctl {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.12s var(--spring);
}

.ctl:hover {
  background: var(--surface-hi);
  border-color: var(--line-strong);
}

.ctl:active {
  transform: scale(0.92);
}

.ctl svg {
  width: 22px;
  height: 22px;
  fill: var(--text);
}

.ctl--off {
  background: var(--danger);
  border-color: var(--danger);
}

.ctl--off:hover {
  background: #ff6682;
}

.ctl--off svg {
  fill: #fff;
}

.ctl--on {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ctl--on svg {
  fill: var(--accent-2);
}

.ctl--leave {
  width: 68px;
  border-radius: 999px;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 10px 24px -10px rgba(255, 77, 109, 0.9);
}

.ctl--leave:hover {
  background: #ff6682;
}

.ctl--leave svg {
  fill: #fff;
}

.ctl--badge::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--panel-solid);
}

.dock__sep {
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: var(--line-strong);
}

.ctl-group {
  position: relative;
}

.ctl__more {
  position: absolute;
  right: -6px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-hi);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.14s, color 0.14s;
}

.ctl__more:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ctl__more--on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* чат */

.chat {
  position: absolute;
  right: 16px;
  top: 0;
  bottom: calc(var(--dock-h) + 8px);
  width: 320px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--panel);
  backdrop-filter: blur(16px);
  overflow: hidden;
  animation: slideIn 0.3s var(--ease);
  z-index: 6;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat__msg b {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.chat__msg--own b {
  color: var(--live);
}

.chat__msg p {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.chat__sys {
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}

.chat__form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.chat__form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.chat__form input:focus {
  border-color: var(--accent);
  outline: none;
}

.chat__form .btn {
  height: 40px;
  padding: 0 14px;
}

/* ---------------------------------------------------------------- всплывашки */

.popover {
  position: fixed;
  z-index: 35;
  width: 264px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 70px -30px #000;
  animation: pop 0.18s var(--spring);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.popover__name {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.popover__row {
  display: grid;
  grid-template-columns: auto 1fr 44px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.popover__row b {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.popover__actions {
  display: flex;
  gap: 8px;
}

.popover__actions .btn {
  flex: 1;
  height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
}

.popover--voice {
  width: 240px;
}

.popover--fx {
  width: 312px;
  max-height: 80vh;
  overflow-y: auto;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 10px;
}

.voice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.voice-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.voice-item--on {
  background: var(--accent-soft);
  color: #cfc4ff;
}

.voice-item i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.voice-item--on i {
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}

.fx-section {
  margin-bottom: 8px;
}

.fx-section__title {
  margin: 4px 0 4px 10px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 800;
}

.fx-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  max-height: none;
  margin-bottom: 0;
}

.fx-list .voice-item {
  padding: 7px 9px;
  font-size: 13px;
}

.fx-note {
  margin: 6px 10px 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 5, 8, 0.6);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.sheet__card {
  width: min(480px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  background: var(--panel-solid);
  box-shadow: 0 40px 100px -40px #000;
  animation: pop 0.22s var(--spring);
}

.sheet__card h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.sheet__card .field {
  margin-bottom: 14px;
}

.toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.14s;
}

.toggle:hover {
  border-color: var(--line-strong);
}

.toggle input {
  margin: 2px 0 0;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
}

.toggle div {
  min-width: 0;
}

.toggle b {
  font-weight: 700;
}

.toggle p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.sheet__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ---------------------------------------------------------------- недавние, тост, обновление */

.recent {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.recent__label {
  margin-right: 4px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}

.chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 20px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-solid);
  font-weight: 600;
  z-index: 30;
  box-shadow: 0 16px 40px -20px #000;
  animation: pop 0.18s var(--spring);
}

.update {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(var(--panel-solid), var(--panel-solid)) padding-box,
    var(--grad) border-box;
  box-shadow: 0 20px 50px -20px #000, 0 0 40px -10px rgba(124, 92, 255, 0.5);
  font-weight: 600;
  z-index: 50;
  animation: pop 0.25s var(--spring);
}

.update .btn {
  height: 38px;
  padding: 0 16px;
  white-space: nowrap;
}

/* ------------------------------------------- компактный режим (PiP / поверх всех) */

body.pip {
  background: #000;
}

body.pip::before,
body.pip .topbar,
body.pip .side,
body.pip .dock,
body.pip .chat,
body.pip .sheet,
body.pip .toast,
body.pip .update,
body.pip .tile__stat,
body.pip .tile__fs,
body.pip .empty {
  display: none !important;
}

body.pip .call {
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stage";
}

body.pip .stage {
  padding: 0;
}

body.pip .grid {
  gap: 2px;
}

body.pip .tile {
  border-radius: 0;
  box-shadow: none;
}

body.pip .tile__label {
  left: 4px;
  bottom: 4px;
  padding: 2px 8px;
  font-size: 11px;
}

.unmini {
  position: fixed;
  right: 8px;
  top: 8px;
  display: none;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.78);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  z-index: 40;
}

body.pip.pip--desktop .unmini {
  display: inline-flex;
}

.unmini:hover {
  background: var(--accent);
}

/* ---------------------------------------------------------------- мобилка */

@media (max-width: 900px) {
  .join {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-content: center;
    overflow-y: auto;
  }

  .join__preview {
    order: -1;
  }

  .preview {
    aspect-ratio: 16 / 10;
  }

  .join h1 {
    font-size: 30px;
  }
}

@media (max-width: 760px) {
  :root {
    --dock-h: 90px;
  }

  .call {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "stage";
  }

  .side {
    display: none;
  }

  .stage {
    padding: 0 8px calc(var(--dock-h) + 4px);
  }

  .grid {
    gap: 8px;
  }

  .grid--focus {
    grid-template-rows: minmax(0, 1fr) minmax(0, 22%) !important;
  }

  .chat {
    right: 8px;
    left: 8px;
    top: 0;
    width: auto;
  }

  .dock {
    bottom: 10px;
    gap: 8px;
    padding: 8px 10px;
    max-width: calc(100vw - 16px);
  }

  .ctl {
    width: 50px;
    height: 50px;
  }

  .ctl--leave {
    width: 64px;
  }

  .dock__sep {
    display: none;
  }

  .popover {
    width: min(300px, calc(100vw - 16px));
  }

  .popover--fx {
    width: min(320px, calc(100vw - 16px));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .tile::before {
    animation: none;
  }
}
