* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #111;
}

.logo { font-weight: 700; font-size: 18px; }
.muted { color: #666; }
.tiny { font-size: 12px; }

.meet-shell {
  max-width: 520px;
  margin: 40px auto;
  padding: 20px;
}

.meet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.badge {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
}

.meet-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.meet-card h1 { margin-bottom: 10px; }

.lbl {
  display: block;
  margin-top: 14px;
  font-size: 13px;
}

.inp {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #ccc;
  outline: none;
  background: #fff;
}

.inp:focus { border-color: #999; }

.btn {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: transform .05s ease;
}

.btn:active { transform: translateY(1px); }

.btn.primary {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn.danger {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn.active {
  border-color: #111;
  font-weight: 600;
}

.btn.mini {
  padding: 6px 10px;
  border-radius: 10px;
}

.result { margin-top: 16px; }
.hidden { display: none; }

.row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.row .btn { margin-top: 0; flex: 1; }

.foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
}

/* ===== PREVIEW PAGE ===== */
.preview {
  margin-top: 14px;
  border-radius: 14px;
  overflow: hidden;
  background: #0f0f10;
  position: relative;
  height: 260px;
}

.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.preview-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.35);
  font-size: 14px;
}

.preview-hint.hidden { display: none; }

.preview-badges {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
}

.pill.on {
  background: rgba(16,185,129,.25);
  border-color: rgba(16,185,129,.5);
}

.pill.meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.meter-bar {
  position: relative;
  width: 64px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.18);
  --lvl: 0.02;
}

.meter-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  transform-origin: left center;
  transform: scaleX(var(--lvl));
  transition: transform .06s linear;
  background: rgba(16,185,129,.95);
}

.meter-bar.peak::before {
  background: rgba(220,38,38,.95);
}

.meter-text { opacity: .9; }

/* Controls для preview */
.controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls .btn {
  margin-top: 0;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
}

.controls #previewBtn {
  flex: 1;
}

.toggles {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
}

.toggle {
  min-width: 160px;
  margin-top: 0;
  flex: 0 0 auto;
  height: 44px;
}

.toggle.is-on {
  background: #111;
  color: #fff;
  border-color: #111;
}

.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 520px) {
  .device-grid { grid-template-columns: 1fr; }
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .controls .toggles {
    width: 100%;
  }
  .controls .toggle {
    flex: 1;
    min-width: 0;
  }
}

/* ===== ROOM PAGE - ПОЛНОСТЬЮ ПЕРЕРАБОТАН ===== */
body.room-page {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  height: 100vh;
}

.room-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding: 10px 16px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ddd;
  z-index: 200;
}

.room-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status {
  font-size: 12px;
  opacity: .75;
  padding: 6px 10px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 999px;
  background: #fff;
}

/* FaceTime Layout */
.p2p-room.ft {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.video-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 180px);
  background: #000;
}

#remoteVideo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#pip {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 140px;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.15);
  z-index: 10;
  opacity: 0;
  transform: scale(.96);
  transition: opacity .25s ease, transform .25s ease;
  touch-action: none;
  cursor: grab;
}

#pip.is-live {
  opacity: 1;
  transform: scale(1);
}

#pip:active { cursor: grabbing; }

#localVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#pip .pip-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

#pip.is-controls-open .pip-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#pip .pip-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.45);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#pip .pip-btn:active {
  transform: scale(0.96);
}

.waiting {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  background: rgba(0,0,0,0.3);
  z-index: 5;
  pointer-events: none;
}

.tap-to-unmute {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  z-index: 5;
  border: 1px solid rgba(255,255,255,.18);
}

/* Панель управления внизу */
.controls-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 15, 15, 0.98);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  z-index: 150;
  border-top: 1px solid rgba(255,255,255,.08);
  max-height: 180px;
  overflow-y: auto;
}

.controls-bar > .btn {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  white-space: nowrap;
  margin: 0;
}

.btn.rec {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: #16a34a;
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn.rec.is-recording {
  background: #dc2626;
}

.btn.rec.is-recording::before {
  content: "●";
  margin-right: 8px;
  animation: recPulse 1s infinite;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.room-devices {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}

.room-devices > div {
  flex: 1;
  min-width: 0;
}

.room-devices .lbl {
  font-size: 11px;
  margin-bottom: 4px;
  color: #fff;
  opacity: 0.7;
  margin-top: 0;
}

.room-devices .inp {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  margin-top: 0;
}

.room-devices #flipCam {
  grid-column: 1 / -1;
  margin-top: 0;
}

.start-playback {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 16px;
}

/* Chat */
.chat {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.chat-head {
  font-weight: 600;
  margin: 8px 0;
}

.chat-list {
  height: 220px;
  overflow: auto;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  padding: 10px;
  background: #fff;
}

.chat-msg {
  margin: 6px 0;
  line-height: 1.25;
}

.chat-msg b { margin-right: 6px; }

.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  outline: none;
}

.chat-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
}

.chat-panel {
  position: fixed;
  right: 16px;
  bottom: 72px;
  width: min(420px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 140px));
  z-index: 9999;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.chat-panel.chat-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-panel .chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  font-weight: 600;
}

.chat-panel .chat-list {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  border: none;
}

.chat-panel .chat-form {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(0,0,0,.08);
  margin-top: 0;
}

.chat-panel .chat-input {
  flex: 1;
}

/* Dialogue Panel */
.dialogue-toggle {
  position: fixed;
  right: 18px;
  bottom: 78px;
  z-index: 60;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,.14);
}

.dialogue-panel {
  position: fixed;
  right: 18px;
  bottom: 130px;
  width: min(520px, calc(100vw - 36px));
  height: min(70vh, 640px);
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  display: none;
  flex-direction: column;
  z-index: 70;
}

.dialogue-panel.dialogue-open { display: flex; }

.dialogue-head {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialogue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dialogue-stream {
  flex: 1;
  padding: 12px;
  overflow: auto;
  background: #fafafa;
  font-size: 14px;
  line-height: 1.35;
}

.dlg-line {
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eee;
  margin-bottom: 8px;
}

.dlg-meta {
  font-size: 12px;
  opacity: .65;
  margin-bottom: 4px;
}

.dialogue-foot {
  padding: 10px 12px;
  border-top: 1px solid #eee;
}

.dialogue-hint {
  font-size: 12px;
  opacity: .7;
}

/* Mobile responsive */
@media (max-width: 720px) {
  .video-stage {
    height: calc(100% - 220px);
  }

  .controls-bar {
    max-height: 220px;
  }

  #pip {
    width: 110px;
    right: 12px;
    bottom: 12px;
  }

  .room-devices {
    flex-direction: column;
  }

  .controls-bar > .btn {
    font-size: 13px;
    padding: 0 14px;
  }
}

@media (max-width: 900px) {
  .controls-bar {
    padding: 10px 12px;
  }
}
/* ===== ФИНАЛЬНЫЕ ФИКСЫ ===== */

/* 1. Адаптивная шапка для мобилки */
@media (max-width: 600px) {
  .room-top {
    padding: 8px 12px;
    height: 52px;
  }

  .logo {
    font-size: 16px;
  }

  .room-actions {
    gap: 6px;
  }

  .room-actions .status {
    display: none; /* скрываем статус на мобилке */
  }

  .room-actions .btn {
    padding: 8px 12px;
    font-size: 13px;
    margin: 0;
  }
}

/* 2. AV AL DIALOGUE кнопка (была забыта) */
.dialogue-toggle {
  position: fixed;
  right: 18px;
  bottom: 78px;
  z-index: 9998;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,.14);
  padding: 10px 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  font-size: 14px;
  font-weight: 600;
}

/* 3. Белый фон внизу вместо черного */
.controls-bar {
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0,0,0,.12);
}

.controls-bar .btn {
  color: #111;
  background: #fff;
  border: 1px solid #ddd;
}

.controls-bar .btn.toggle.is-on {
  background: #111;
  color: #fff;
  border-color: #111;
}

.room-devices .lbl {
  color: #666 !important;
}

.room-devices .inp {
  background: #fff !important;
  color: #111 !important;
  border: 1px solid #ccc !important;
}

/* Кнопка записи на белом фоне */
.btn.rec {
  background: #16a34a;
  color: #fff;
  border: 1px solid #16a34a;
}

.btn.rec.is-recording {
  background: #dc2626;
  border: 1px solid #dc2626;
}
/* ===== ДЕСКТОПНАЯ АДАПТАЦИЯ ===== */

/* На десктопе видео занимает всё пространство */
@media (min-width: 900px) {
  .video-stage {
    height: calc(100vh - 56px - 100px); /* полная высота минус header и controls */
  }

  .controls-bar {
    max-height: 100px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 20px;
  }

  .room-devices {
    max-width: 500px;
    flex-direction: row;
  }

  #pip {
    width: 180px;
    right: 20px;
    bottom: 20px;
  }

  /* Кнопки в ряд на десктопе */
  .controls-bar > .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }

  .room-devices > div {
    flex: 1;
  }
}

/* Для больших экранов (1920px+) */
@media (min-width: 1400px) {
  #pip {
    width: 220px;
  }

  .video-stage {
    height: calc(100vh - 56px - 90px);
  }
}

/* Убираем лишние отступы на десктопе */
@media (min-width: 900px) {
  .p2p-room.ft {
    padding: 0;
  }

  .video-stage {
    border-radius: 0;
  }

  #remoteVideo {
    border-radius: 0;
  }
}
/* ===== КНОПКИ DIALOGUE И CHAT - МОБИЛЬНАЯ ВЕРСИЯ ===== */

/* AV AL DIALOGUE кнопка */
.dialogue-toggle {
  position: fixed;
  right: 16px;
  bottom: 72px;
  z-index: 9998;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
  padding: 10px 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  font-size: 13px;
  font-weight: 600;
}
/* ===== ФИНАЛЬНЫЕ ПРАВКИ ===== */

/* 1. Адаптивная шапка для мобилки */
@media (max-width: 600px) {
  .room-top {
    padding: 8px 12px;
    height: 52px;
  }
  .logo {
    font-size: 16px;
  }
  .room-actions {
    gap: 6px;
  }
  .room-actions .status {
    display: none;
  }
  .room-actions .btn {
    padding: 8px 12px;
    font-size: 13px;
    margin: 0;
  }
}

/* 2. Кнопки Dialogue и Chat */
.dialogue-toggle {
  position: fixed;
  right: 16px;
  bottom: 72px;
  z-index: 9998;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
  padding: 10px 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  font-size: 13px;
  font-weight: 600;
}

.chat-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
}

.dialogue-panel {
  position: fixed;
  right: 16px;
  bottom: 120px;
  width: min(420px, calc(100vw - 32px));
  height: min(60vh, 500px);
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  display: none;
  flex-direction: column;
  z-index: 9997;
}

.dialogue-panel.dialogue-open {
  display: flex;
}

.chat-panel {
  position: fixed;
  right: 16px;
  bottom: 64px;
  width: min(420px, calc(100vw - 32px));
  height: min(60vh, 500px);
  z-index: 9998;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.chat-panel.chat-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-panel .chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(0,0,0,.08);
  margin-top: 0;
  align-items: center;
  flex-wrap: nowrap;
}

.chat-panel .chat-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 14px;
  height: 40px;
}

.chat-panel .chat-form button[type="submit"],
.chat-panel .chat-form .btn {
  flex: 0 0 auto;
  padding: 10px 14px !important;
  margin: 0 !important;
  height: 40px !important;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
  min-width: auto;
}

@media (max-width: 600px) {
  .dialogue-toggle {
    right: 12px;
    bottom: 60px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .chat-toggle {
    right: 12px;
    bottom: 12px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .dialogue-panel {
    right: 12px;
    bottom: 110px;
    width: calc(100vw - 24px);
    height: min(55vh, 450px);
  }
  .chat-panel {
    right: 12px;
    bottom: 56px;
    width: calc(100vw - 24px);
    height: min(55vh, 450px);
  }
  .chat-panel .chat-form button[type="submit"],
  .chat-panel .chat-form .btn {
    padding: 10px 12px !important;
    font-size: 12px;
  }
}

/* 3. Белый фон панели управления */
.controls-bar {
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0,0,0,.12);
}

.controls-bar .btn {
  color: #111;
  background: #fff;
  border: 1px solid #ddd;
}

.controls-bar .btn.toggle.is-on {
  background: #111;
  color: #fff;
  border-color: #111;
}

.room-devices .lbl {
  color: #666 !important;
}

.room-devices .inp {
  background: #fff !important;
  color: #111 !important;
  border: 1px solid #ccc !important;
}

.btn.rec {
  background: #16a34a;
  color: #fff;
  border: 1px solid #16a34a;
}

.btn.rec.is-recording {
  background: #dc2626;
  border: 1px solid #dc2626;
}

/* 4. Десктопная адаптация */
@media (min-width: 900px) {
  .video-stage {
    height: calc(100vh - 56px - 100px);
  }
  .controls-bar {
    max-height: 100px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 20px;
  }
  .room-devices {
    max-width: 500px;
    flex-direction: row;
  }
  #pip {
    width: 180px;
    right: 20px;
    bottom: 20px;
  }
  .controls-bar > .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }
  .room-devices > div {
    flex: 1;
  }
  .p2p-room.ft {
    padding: 0;
  }
  .video-stage {
    border-radius: 0;
  }
  #remoteVideo {
    border-radius: 0;
  }
}

@media (min-width: 1400px) {
  #pip {
    width: 220px;
  }
  .video-stage {
    height: calc(100vh - 56px - 90px);
  }
}
.pill-btn{
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.18);
}

.pill-btn:active{
  transform: translateY(1px);
}
/* ===== toggles under selects (like 2nd screenshot) ===== */
.toggle-row{
  display:flex;
  gap:12px;
  margin:12px 0 10px;
}

.toggle-btn{
  flex:1;
  height:44px;
  border-radius:12px;
  border:1px solid #dcdcdc;
  background:#fff;
  color:#111;
  font-weight:700;
  cursor:pointer;
}

.toggle-btn:hover{
  filter: brightness(0.98);
}

/* ON state (JS will add .is-on) */
.toggle-btn.is-on{
  background:#111;
  color:#fff;
  border-color:#111;
}

/* hide old bottom bar if it still exists somewhere */
.bottom-bar,
.meet-bottom,
.bottom-controls{
  display:none !important;
}

/* mobile */
@media (max-width: 520px){
  .toggle-row{
    flex-direction:column;
  }
  .toggle-btn{
    width:100%;
  }
}
/* Убираем старые кнопки превью (если они ещё есть в HTML) */
.controls .toggles{
  display:none !important;
}
/* ===== toggles under selects (like 2nd screenshot) ===== */
.toggle-row{
  display:flex;
  gap:12px;
  margin:12px 0 10px;
}

.toggle-btn{
  flex:1;
  height:44px;
  margin-top: 0;          /* чтобы не было отступа как у .btn */
  border-radius:12px;
  border:1px solid #dcdcdc;
  background:#fff;
  color:#111;
  font-weight:700;
  cursor:pointer;
}

/* активное состояние — как у твоего .toggle.is-on */
.toggle-btn.is-on,
.toggle-btn.active{
  background:#111;
  color:#fff;
  border-color:#111;
}

/* mobile */
@media (max-width: 520px){
  .toggle-row{
    flex-direction:column;
  }
}
/* =========================================
   FIX: вернуть нижнюю панель как БЫЛО РАНЬШЕ
   (кнопки столбиком по центру даже на DESKTOP)
   ========================================= */

@media (min-width: 900px) {
  body.room-page .controls-bar{
    flex-direction: column !important;   /* главное */
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center !important;

    max-height: 180px !important;        /* как раньше */
    padding: 12px !important;
  }

  /* кнопки — одна под другой и одинаковой ширины */
  body.room-page .controls-bar > .btn{
    width: min(320px, 92vw) !important;
    margin: 0 !important;
  }

  /* селекты в одну линию снизу */
  body.room-page .room-devices{
    max-width: 700px !important;
    flex-direction: row !important;
    gap: 12px !important;
  }
}
/* ===== FORCE: увеличить видео ещё на +15% (desktop) ===== */
@media (min-width: 900px){
  /* панель снизу — ещё компактнее */
  body.room-page .controls-bar{
    max-height: 85px !important;   /* было 110 */
    height: 85px !important;
    overflow: hidden !important;
  }

  /* видео становится ещё выше */
  body.room-page .p2p-room.ft .video-stage{
    height: calc(100vh - 56px - 70px) !important;
  }
}
/* =========================================
   ✅ FINAL FIX: один скролл на всю страницу
   Убираем fixed-верстку у комнаты и нижней панели
   ========================================= */

html, body{
  height: auto !important;
  overflow-y: auto !important;
}

/* 1) BODY должен скроллиться */
body.room-page{
  height: auto !important;
  min-height: 100vh !important;
  overflow: auto !important;
  overflow-x: hidden !important;
  background: #f6f7f9 !important;
}

/* 2) Комната НЕ fixed (иначе нет скролла) */
body.room-page .p2p-room.ft{
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;

  /* чтобы контент начинался под шапкой */
  padding-top: 56px !important;
  background: transparent !important;
}

/* 3) Видео-сцена — обычный блок */
body.room-page .video-stage{
  position: relative !important;
  width: 100% !important;

  /* размер видео (можешь менять) */
  height: 70vh !important;
  min-height: 420px !important;

  background: #000 !important;
  overflow: hidden !important;
}

/* 4) Убираем чёрную полосу: нижняя панель НЕ fixed */
body.room-page .controls-bar{
  position: relative !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;

  max-height: none !important;     /* убираем внутренний скролл */
  height: auto !important;
  overflow: visible !important;

  background: #fff !important;
  border-top: 1px solid rgba(0,0,0,.12) !important;

  padding: 14px 16px !important;
  margin: 12px 0 18px !important;
}

/* 5) PiP остаётся поверх видео */
body.room-page #pip{
  position: absolute !important;
}

/* 6) Start playback не должен прилипать снизу (иначе мешает) */
body.room-page .start-playback{
  position: absolute !important;
  bottom: 22px !important;
}

/* 7) На мобилке видео выше, чтобы кнопки были видны */
@media (max-width: 720px){
  body.room-page .video-stage{
    height: 62vh !important;
    min-height: 360px !important;
  }
}
/* ================================
   FIX: Tree НЕ вылезает + красиво
   ================================ */

/* 1) Сама панель обязана резать всё лишнее */
.dialogue-panel{
  overflow: hidden;              /* ключ: ничего не вылезает наружу */
}

/* 3) Хедер фикс, контент занимает остаток */
.dialogue-head{
  flex: 0 0 auto;
}

/* 4) Контент (Live/Tree) — только он скроллится */
.dialogue-stream{
  flex: 1 1 auto;
  min-height: 0;                 /* СУПЕР ВАЖНО для скролла внутри flex */
  overflow: auto;                /* скролл внутри */
  overscroll-behavior: contain;
  padding: 12px;
  background: #fafafa;
}

/* 5) Если Tree у тебя рисуется списком — делаем “чистый” список */
.dialogue-stream ul,
.dialogue-stream ol{
  list-style: none;
  margin: 0;
  padding: 0;
}

.dialogue-stream li{
  padding: 7px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eee;
  margin-bottom: 8px;

  white-space: normal;
  overflow-wrap: anywhere;       /* длинные куски не ломают блок */
  word-break: break-word;
}

/* 6) Чуть приятнее скролл */
.dialogue-stream::-webkit-scrollbar{ width: 10px; }
.dialogue-stream::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,.18);
  border-radius: 999px;
  border: 3px solid #fafafa;
}
/* Красивые вкладки-пилюли */
.dialogue-tabs{
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  background: #f3f4f6;
  border-radius: 999px;
}

.dialogue-tab{
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.dialogue-tab.is-active{
  background: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  font-weight: 700;
}
/* FIX: panel должна быть скрыта по умолчанию */
.dialogue-panel{
  display: none !important;
  overflow: hidden;            /* чтобы Tree не вылезал */
}

/* открытие только через класс */
.dialogue-panel.dialogue-open{
  display: flex !important;
  flex-direction: column;
}

/* скролл только внутри контента */
.dialogue-stream{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
/* ===== Dialogue: fixed, scroll inside, close works ===== */

.dialogue-panel{
  display: none !important;
  overflow: hidden !important;
  flex-direction: column;
}

.dialogue-panel.dialogue-open{
  display: flex !important;
}

.dialogue-head{
  flex: 0 0 auto;
}

.dialogue-stream{
  flex: 1 1 auto;
  min-height: 0;          /* важно */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: #fafafa;
}

/* Превращаем ЛЮБОЙ контент Tree/Live в “карточки” */
.dialogue-stream > *{
  margin: 0;
}

.dialogue-stream .dlg-line,
.dialogue-stream li,
.dialogue-stream .line,
.dialogue-stream .item,
.dialogue-stream .row{
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eee;
  margin-bottom: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* если Tree рисуется ul/ol — убираем точки */
.dialogue-stream ul,
.dialogue-stream ol{
  list-style: none;
  margin: 0;
  padding: 0;
}

/* scrollbar */
.dialogue-stream::-webkit-scrollbar{ width: 10px; }
.dialogue-stream::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,.18);
  border-radius: 999px;
  border: 3px solid #fafafa;
}
/* === DIALOGUE: один скролл внутри === */
.dialogue-panel{ overflow:hidden !important; }
.dialogue-panel.dialogue-open{ display:flex !important; flex-direction:column; }

.dialogue-head, .dialogue-foot{ flex:0 0 auto; }

.dialogue-stream{
  flex:1 1 auto;
  min-height:0;              /* КЛЮЧ */
  overflow-y:auto;           /* КЛЮЧ */
  overflow-x:hidden;
  padding:12px;
  background:#fafafa;
}
/* === Chat bubbles === */
.dlg-line{
  display:flex;
  flex-direction:column;
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid #eee;
  background:#fff;
  margin: 8px 0;
}

.dlg-line .dlg-meta{
  font-size: 11px;
  opacity: .6;
  margin-bottom: 4px;
}

/* мое сообщение слева */
.dlg-line.me{
  margin-right:auto;
  border-top-left-radius: 6px;
}

/* его сообщение справа */
.dlg-line.other{
  margin-left:auto;
  border-top-right-radius: 6px;
  background:#111;
  color:#fff;
  border-color:#111;
}

.dlg-line.other .dlg-meta{
  opacity:.65;
  color: rgba(255,255,255,.8);
}
/* панель должна быть колонкой */
#dialoguePanel{
  display: flex;
  flex-direction: column;
  overflow: hidden; /* чтобы скролл был только в body */
}

/* фиксируем высоту панели относительно окна */
#dialoguePanel.dialogue-panel{
  max-height: calc(100vh - 170px); /* подгони под твой header/низ */
}

/* контейнер, который реально скроллится */
#dialoguePanel .dialogue-body{
  flex: 1 1 auto;
  min-height: 0;          /* КРИТИЧНО для flex */
  overflow-y: auto;       /* ✅ появится скролл */
  overflow-x: hidden;
  padding: 10px 12px;
  -webkit-overflow-scrolling: touch;
}

/* чтобы Tree красиво переносил строки */
#dialogueTree{
  white-space: pre-wrap;
  word-break: break-word;
}
/* ===== Tree: жёстко нормализуем отступы ===== */
#dialogueTree{
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;          /* важно: не pre-wrap */
  word-break: break-word;
}

/* Сброс ВСЕХ отступов/паддингов внутри Tree */
#dialogueTree *{
  margin: 0 !important;
  padding: 0 !important;
}

/* Классический абзац: одна строка между абзацами */
#dialogueTree p{
  margin: 0 0 12px 0 !important;
}

/* Заголовки компактно */
#dialogueTree h1{ margin: 0 0 10px 0 !important; font-size: 18px; font-weight: 700; }
#dialogueTree h2{ margin: 14px 0 8px 0 !important; font-size: 16px; font-weight: 700; }
#dialogueTree h3{ margin: 12px 0 6px 0 !important; font-size: 15px; font-weight: 700; }

/* Списки компактные */
#dialogueTree ul,
#dialogueTree ol{
  margin: 0 0 12px 18px !important;
}
#dialogueTree li{
  margin: 0 0 6px 0 !important;
}

/* Убираем "дырки" от пустых div */
#dialogueTree div:empty{
  display: none !important;
}

/* Если у тебя отчёт в div без <p>, делаем строки аккуратными */
#dialogueTree div{
  margin: 0 0 8px 0 !important;
}
/* ==============================
   AV AL DIALOGUE — Messenger UI
   (one scroll, clean bubbles)
   ============================== */

/* 1) Панель: сама не скроллится, скролл только у контента */
.dialogue-panel{
  display:flex;
  flex-direction:column;
  overflow:hidden;
  max-height: 80vh;          /* чтобы панель не уплывала за экран */
}

/* контейнер для вкладок (если есть) */
.dialogue-tabs{
  flex: 0 0 auto;
}

/* тело панели занимает всё между верхом и низом */
.dialogue-body{
  flex: 1 1 auto;
  min-height: 0;             /* КЛЮЧЕВО: иначе появится второй скролл */
  overflow:hidden;
  display:flex;
}

/* 2) Стрим сообщений — ЕДИНСТВЕННЫЙ скролл */
#dialogueStream.dialogue-stream{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y:auto;
  overflow-x:hidden;

  padding: 12px 12px 14px;
  display:flex;
  flex-direction:column;
  gap: 8px;

  /* лёгкий фон как в мессенджере */
  background: linear-gradient(180deg, rgba(255,241,228,.7), rgba(255,255,255,.9));
}

/* 3) Дерево — тоже один скролл (когда вкладка Tree включена) */
#dialogueTree.dialogue-tree{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y:auto;
  overflow-x:hidden;
  padding: 12px;
}

/* ------------------------------
   Ряд сообщения
-------------------------------- */
.al-msg{
  display:flex;
  align-items:flex-end;
  gap: 6px;
}

.al-msg.left  { justify-content:flex-start; }
.al-msg.right { justify-content:flex-end; }
.al-msg.system{ justify-content:center; }

/* ------------------------------
   Пузырь
-------------------------------- */
.al-bubble{
  max-width: min(78%, 520px);
  padding: 9px 11px;
  border-radius: 16px;
  line-height: 1.28;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  position: relative;
}

/* текст + мета */
.al-text{
  font-size: 13px;
  white-space: pre-wrap;
}

.al-meta{
  margin-top: 5px;
  font-size: 11px;
  opacity: .7;
  display:flex;
  gap: 6px;
  justify-content:flex-end;
}

/* ------------------------------
   Стили сторон
-------------------------------- */
.al-msg.left .al-bubble{
  background:#ffffff;
  border:1px solid #ececec;
  border-top-left-radius: 8px;
  color:#111;
}

.al-msg.right .al-bubble{
  /* более приятный персиковый */
  background: linear-gradient(180deg, #ffcf9a, #ffb463);
  border:1px solid #f3a445;
  border-top-right-radius: 8px;
  color:#111;
}

/* SYSTEM */
.al-msg.system .al-bubble{
  background:#f4f5f7;
  border:1px solid #e6e7ea;
  color:#555;
  box-shadow:none;
}

/* ------------------------------
   “Хвостики” (аккуратные)
   Можно убрать, если не надо
-------------------------------- */
.al-msg.left .al-bubble::before,
.al-msg.right .al-bubble::before{
  content:"";
  position:absolute;
  bottom:10px;
  width:10px;
  height:10px;
  transform: rotate(45deg);
}

.al-msg.left .al-bubble::before{
  left:-5px;
  background:#fff;
  border-left:1px solid #ececec;
  border-bottom:1px solid #ececec;
}

.al-msg.right .al-bubble::before{
  right:-5px;
  background:#ffbf78;
  border-right:1px solid #f3a445;
  border-bottom:1px solid #f3a445;
}

.al-msg.system .al-bubble::before{ display:none; }

/* если подряд два сообщения одной стороны — хвост у второго скрываем */
.al-msg.left  + .al-msg.left  .al-bubble::before { display:none; }
.al-msg.right + .al-msg.right .al-bubble::before { display:none; }

/* лёгкая “склейка” подряд идущих сообщений одной стороны */
.al-msg.left  + .al-msg.left  { margin-top:-4px; }
.al-msg.right + .al-msg.right { margin-top:-4px; }

/* опционально: тонкий скролл */
#dialogueStream::-webkit-scrollbar,
#dialogueTree::-webkit-scrollbar{
  width: 10px;
}
#dialogueStream::-webkit-scrollbar-thumb,
#dialogueTree::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,.12);
  border-radius: 10px;
  border: 3px solid rgba(255,255,255,.7);
}

