* { box-sizing: border-box; }
:root { color-scheme: dark; --bg:#0b0c10; --panel:#111217; --bdr:#1f2330; --txt:#e5e7eb; --accent:#2563eb; --danger:#ef4444; }
html, body { height: 100%; }
body { margin:0; font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif; background: var(--bg); color: var(--txt); }
.container { max-width: 980px; margin: 16px auto 32px; padding: 0 16px; }
h1 { margin: 0 0 14px; font-size: 22px; }

.active-rooms { background: var(--panel); border:1px solid var(--bdr); border-radius:12px; padding:12px; margin-bottom:12px; }
.rooms-header { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.rooms { display:flex; flex-wrap:wrap; gap:10px; }
.rooms .room-btn {
  padding: 14px 18px;
  border-radius:12px;
  border:1px solid var(--bdr);
  background: #0f1117;
  color: var(--txt);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform .05s ease, background .2s ease;
}
.rooms .room-btn:hover { transform: translateY(-1px); background:#151823; }
.rooms .badge { opacity: .85; font-weight: 500; font-size: 12px; margin-left: 6px; padding:2px 6px; border-radius: 999px; border:1px solid var(--bdr); }

.controls { background: var(--panel); border:1px solid var(--bdr); border-radius:12px; padding:12px; margin-bottom:12px; }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
input, button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bdr);
  background: #0f1117; color: var(--txt);
}
input { min-width: 260px; flex: 1 1 260px; }
button { cursor:pointer; }
button.primary { background: var(--accent); border-color: #1d4ed8; }
button.primary:hover { background:#1d4ed8; }
button.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; padding:0; }
button.icon-btn img { width:26px; height:26px; }
button.danger { background: var(--danger); border-color:#b91c1c; }
button.danger:hover { background:#dc2626; }

.videos.mobile-portrait .video-wrap {
  position: relative;
  width: 100%;
  height: calc(100dvh - 320px); /* 100dvh учитывает динамические панели на мобилках */
  background: #000;
  border: 1px solid var(--bdr);
  border-radius: 12px;
  overflow: hidden;
}
#remoteVideo { width:100%; height:100%; object-fit: cover; background:#000; }

/* мини-окно локального видео — теперь через left/top */
#localVideo.pip {
  position: absolute;
  left: auto; top: auto;  /* будут выставляться скриптом */
  right: 10px; bottom: 10px; /* стартовая позиция */
  width: 32vw;
  max-width: 180px;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 2px solid var(--bdr);
  border-radius: 10px;
  background: #000;
  touch-action: none;
  cursor: move;
  z-index: 2;
}

.callbar {
  position: sticky;
  bottom: 8px;
  display:flex;
  justify-content: flex-end;
  gap:8px;
  margin-top: 8px;
}

/* Во время звонка скрываем лишнее */
.in-call .active-rooms,
.in-call .controls,
.in-call .log { display: none; }
.in-call .videos .video-wrap { height: calc(100dvh - 120px); }

/* -------- Псевдо-фуллскрин (мобилки, в т.ч. iOS) -------- */
.pseudo-fs .videos .video-wrap {
  position: fixed !important;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw; height: 100dvh !important;
  border-radius: 0;
  z-index: 1;
}
.pseudo-fs #remoteVideo { width:100vw; height:100dvh; }
.pseudo-fs #localVideo.pip { z-index: 2; }
.pseudo-fs .callbar {
  position: fixed;
  bottom: 12px; left: 16px; right: 16px;
  justify-content: flex-end;
  z-index: 3;
}

@media (min-width: 900px) {
  .videos.mobile-portrait .video-wrap { height: 70dvh; }
  .in-call .videos .video-wrap { height: 82dvh; }
  #localVideo.pip { width: 20vw; max-width: 260px; }
}

