/* ═══ WIRECALL DESIGN SYSTEM ═══ */
:root {
  --bg: #0b0b0e;
  --surface: #131317;
  --surface-elevated: #1c1c24;
  --surface-hover: #242430;
  --border: #26262e;
  --border-light: #33333e;
  --text: #e4e4ec;
  --text-muted: #88889a;
  --text-dim: #5c5c6e;
  
  --accent: #6c5ce7;
  --accent-hover: #7c6df0;
  --accent-soft: rgba(108, 92, 231, 0.15);
  
  --danger: #e53935;
  --danger-hover: #d32f2f;
  --danger-soft: rgba(229, 57, 53, 0.15);
  
  --success: #30d158;
  --warning: #ffd60a;
  --info: #0a84ff;
  
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ═══ ACCESSIBILITY & FOCUS ═══ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ═══ BUTTONS ═══ */
button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn {
  padding: 12px 20px;
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-light); }
.btn-secondary:active { transform: scale(0.98); }

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger:active { transform: scale(0.98); }

.btn-ghost {
  color: var(--text-muted);
  padding: 10px 16px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }

/* Круглые иконки управления */
.btn-icon {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}
.btn-icon:active {
  transform: scale(0.93);
}

/* Активные и выключенные состояния */
.btn-icon.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn-icon.is-muted {
  background: var(--surface);
  border-color: var(--border-light);
  color: var(--text-muted);
}
.btn-icon.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
}
.btn-icon.danger:hover {
  background: var(--danger-hover);
}

/* ═══ INPUTS ═══ */
input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  outline: none;
}
input[type="text"]::placeholder {
  color: var(--text-dim);
}

/* ═══ ICONS ═══ */
.icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }

/* ═══ TOAST NOTIFICATIONS ═══ */
#notificationContainer {
  position: fixed;
  top: max(16px, var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 440px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.toast-leaving {
  opacity: 0;
  transform: translateY(-8px);
}
.toast.toast-info { border-left: 4px solid var(--info); }
.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-error { border-left: 4px solid var(--danger); }
.toast-icon { flex-shrink: 0; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-close {
  padding: 4px;
  color: var(--text-dim);
  border-radius: 4px;
}
.toast-close:hover { color: var(--text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ SCREENS ═══ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  z-index: 1;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
.screen.is-active {
  display: flex;
}

/* ═══ LOBBY SCREEN ═══ */
#screenLobby {
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.lobby-container {
  width: 100%;
  max-width: 420px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
  animation: fadeIn 0.4s ease;
}

.lobby-brand {
  text-align: center;
}
.lobby-brand h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.lobby-brand h1 span {
  color: var(--accent);
}
.lobby-brand p {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 8px;
}

.lobby-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lobby-or::before, .lobby-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 8px;
}
.join-row input {
  flex: 1;
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

/* ═══ PRE-CALL SCREEN ═══ */
#screenPrecall {
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.precall-container {
  width: 100%;
  max-width: 440px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.precall-header {
  text-align: center;
}
.precall-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.precall-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.precall-preview-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  border: 1px solid var(--border);
}
.precall-preview-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.precall-cam-off {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  color: var(--text-dim);
}
.precall-cam-off.show {
  display: flex;
}

.precall-controls-overlay {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10;
}

.precall-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ═══ CALL SCREEN ═══ */
#screenCall {
  background: #000000;
}

/* Call Top Bar */
.call-top-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(19, 19, 23, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.call-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.call-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.call-timer {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  cursor: pointer;
}
.quality-badge:hover {
  background: rgba(255, 255, 255, 0.12);
}
.quality-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.quality-dot.fair { background: var(--warning); }
.quality-dot.poor { background: var(--danger); }

/* Video Container & Areas */
.call-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 1:1 Quick Call Layout */
.quickcall-view {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-main-tile {
  position: absolute;
  inset: 8px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.remote-main-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  z-index: 2;
}
.remote-placeholder.show {
  display: flex;
}
.avatar-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

/* Draggable PIP stack for Quick Call */
.quickcall-pip-stack {
  position: absolute;
  right: 16px;
  bottom: 84px;
  width: 130px;
  z-index: 30;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.quickcall-pip-stack.dragging {
  cursor: grabbing;
}
.pip-sub-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000000;
  overflow: hidden;
}
.pip-sub-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#quickcallLocalVideo {
  transform: scaleX(-1);
}

/* Screen Share View for 1:1 */
.screen-share-wrap {
  position: absolute;
  inset: 8px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  z-index: 10;
  display: none;
}
.screen-share-wrap.active {
  display: flex;
}
.screen-share-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ═══ MEETING GRID LAYOUT ═══ */
.meeting-view {
  position: absolute;
  inset: 8px;
  display: none;
  gap: 8px;
  overflow: hidden;
}
.meeting-view.active {
  display: grid;
}

/* Dynamic Grid Classes */
.meeting-grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.meeting-grid-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.meeting-grid-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.meeting-grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.meeting-grid-5, .meeting-grid-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; }
.meeting-grid-7, .meeting-grid-8 { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr; }

@media (max-width: 767px) {
  .meeting-grid-2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .meeting-grid-3 { grid-template-columns: 1fr; grid-template-rows: repeat(3, 1fr); }
  .meeting-grid-5, .meeting-grid-6 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); }
  .meeting-grid-7, .meeting-grid-8 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, 1fr); }
}

/* Presentation Mode (Screen Share Active in Meeting) */
.meeting-presentation-view {
  position: absolute;
  inset: 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 12;
}
.meeting-presentation-view.active {
  display: flex;
}
.presentation-main-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
}
.presentation-main-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.presentation-header-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 2;
  pointer-events: none;
}
.presentation-strip {
  height: 100px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  padding-bottom: 2px;
}
.presentation-strip .meeting-tile {
  width: 140px;
  height: 100%;
  flex-shrink: 0;
}

/* Individual Meeting Tile */
.meeting-tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 2px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.meeting-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.meeting-tile.is-local video {
  transform: scaleX(-1);
}
.meeting-tile.is-speaking {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-soft);
}

.meeting-tile-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 1;
}
.meeting-tile.cam-off .meeting-tile-placeholder {
  display: flex;
}

.tile-badge-name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  max-width: calc(100% - 40px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 3;
}

.tile-badge-mic {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  z-index: 3;
}
.meeting-tile.mic-off .tile-badge-mic {
  display: flex;
}

/* ═══ CALL CONTROLS BAR ═══ */
.call-bottom-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(19, 19, 23, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Reconnect Overlay */
.reconnect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 14, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
.reconnect-overlay.show {
  display: flex;
}
.reconnect-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ═══ POST-CALL SCREEN ═══ */
#screenPostcall {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.postcall-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.postcall-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-elevated);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.postcall-title {
  font-size: 22px;
  font-weight: 700;
}
.postcall-duration {
  font-size: 15px;
  color: var(--text-muted);
}
.postcall-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ═══ MODAL DIALOGS & MORE MENU ═══ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.is-open {
  display: flex;
}

.modal-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
}
.modal-close-btn,
.popover-close-btn {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 6px !important;
  margin: -6px !important;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.15s ease, transform 0.15s ease;
}
.modal-close-btn:hover,
.popover-close-btn:hover {
  color: var(--text);
  transform: scale(1.08);
}
.modal-close-btn:focus-visible,
.popover-close-btn:focus-visible {
  outline: 2px solid var(--accent) !important;
}

/* ═══ POPOVER "MORE" MENU ═══ */
.popover-backdrop {
  background: rgba(0, 0, 0, 0.25) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  align-items: flex-end !important;
  justify-content: center !important;
  padding: 0 !important;
}

.popover-bubble {
  position: fixed !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  bottom: calc(76px + var(--safe-b)) !important;
  width: calc(100% - 24px) !important;
  max-width: 360px !important;
  background: var(--surface-elevated) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: 18px !important;
  padding: 16px 18px !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6) !important;
  animation: popoverSlideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 101;
}

.popover-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: calc(50% + 54px);
  width: 12px;
  height: 12px;
  background: var(--surface-elevated);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  transform: rotate(45deg);
  pointer-events: none;
}

@media (min-width: 768px) {
  .popover-backdrop {
    justify-content: center !important;
  }
  .popover-bubble {
    bottom: calc(86px + var(--safe-b)) !important;
    max-width: 380px !important;
  }
}

@keyframes popoverSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.popover-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.popover-menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popover-row-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s ease;
}
.popover-row-btn:hover {
  background: var(--surface-hover);
}

.popover-row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.popover-row-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.popover-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popover-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-ghost-sm {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.btn-ghost-sm:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* ═══ TOGGLE SWITCH ═══ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background-color: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text);
  border-radius: 50%;
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background-color: #ffffff;
}

/* ═══ CALL TOP STATS STRIP ═══ */
.call-stats-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--success);
}
.stat-pill {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.stat-pill-lbl {
  color: var(--text-muted);
  margin-right: 2px;
}

/* "More" Menu items */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  width: 100%;
}
.menu-item:hover {
  background: var(--surface-hover);
}
.menu-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Participant list item */
.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.participant-row:last-child {
  border-bottom: none;
}
.participant-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.participant-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-elevated);
  color: var(--text-muted);
}

/* Quality stats table */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-box {
  background: var(--surface-elevated);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══ DESKTOP ADAPTATION ═══ */
@media (min-width: 768px) {
  .lobby-card { padding: 32px; }
  .lobby-actions { flex-direction: row; }
  .lobby-actions .btn { flex: 1; }
  
  .quickcall-pip-stack {
    width: 180px;
    right: 24px;
    bottom: 96px;
  }
  
  .remote-main-tile {
    inset: 16px;
  }
  .meeting-view {
    inset: 16px;
    gap: 12px;
  }
  .screen-share-wrap {
    inset: 16px;
  }
  
  .call-bottom-bar {
    gap: 20px;
  }
  .call-bottom-bar .btn-icon {
    width: 52px;
    height: 52px;
  }
  .call-bottom-bar .btn-icon.danger {
    width: 60px;
    height: 60px;
  }
}
