:root {
  --bg: #070b14;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #263248;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #4f46e5;
  --emerald: #10b981;
  --rose: #ef4444;
  --amber: #f59e0b;
  --sky: #0ea5e9;
  --video-fit: contain;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font-family: inherit; }

.meet-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------- TOP BAR ---------------- */
.meet-topbar {
  min-height: 54px;
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  z-index: 30;
}

.meet-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.meet-logo {
  height: 30px;
  background: #fff;
  padding: 2px 5px;
  border-radius: 6px;
  flex-shrink: 0;
}

.meet-title-wrap {
  min-width: 0;
  flex: 1;
}

.meet-title {
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meet-sub {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  overflow: hidden;
  margin-top: 2px;
}

.meet-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.layout-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mpill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: #e2e8f0;
  white-space: nowrap;
}

.mpill-rec {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fecaca;
}

.mpill-yt {
  background: rgba(220, 38, 38, 0.25);
  border-color: #ef4444;
  color: #ffffff;
}

.mpill-live {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.6);
  color: #a7f3d0;
}

.mpill-bo {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.7);
  color: #c7d2fe;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---------------- BUTTONS ---------------- */
.mbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: #f8fafc;
  background: var(--surface-2);
  transition: background 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
  text-decoration: none;
}

.mbtn:hover { background: #2d3d56; }
.mbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.mbtn-sm { padding: 5px 9px; font-size: 11px; border-radius: 7px; }
.mbtn-primary { background: var(--primary); }
.mbtn-primary:hover { background: #6366f1; }
.mbtn-emerald { background: #059669; }
.mbtn-emerald:hover { background: #10b981; }
.mbtn-danger { background: #dc2626; }
.mbtn-danger:hover { background: #ef4444; }
.mbtn-amber { background: #d97706; }
.mbtn-outline { background: transparent; border-color: #334155; color: #cbd5e1; }
.mbtn-outline:hover { background: #1e293b; color: #fff; }

/* ---------------- MAIN BODY: STAGE + RIGHT DRAWER + LOBBY ---------------- */
.meet-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

.meet-stage-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at center, #0e1628 0%, #060911 100%);
}

/* Banners inside stage */
.stage-banners {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 0;
  z-index: 15;
}

.stage-banners:empty { display: none; }

.stage-banner {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.banner-pin {
  background: rgba(79, 70, 229, 0.25);
  border: 1px solid rgba(129, 140, 248, 0.6);
}

.banner-bo {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.65);
}

.banner-announce {
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.7);
}

/* ---------------- VIDEO STAGE ---------------- */
.video-stage {
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

/* Screen Share Layout */
.screen-share-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
}

.screen-main-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  border: 2px solid #0ea5e9;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen-main-pane video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.screen-side-strip {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Grid View */
.video-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: center;
  justify-content: center;
}

.video-grid.cols-1 { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
.video-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.video-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.video-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.video-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }

/* Speaker / Spotlight Layout */
.speaker-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.speaker-hero {
  flex: 1;
  min-height: 0;
  display: flex;
}

.speaker-hero .vtile {
  flex: 1;
  width: 100%;
  height: 100%;
}

.speaker-strip {
  height: 128px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.speaker-strip .vtile {
  width: 200px;
  min-width: 180px;
  height: 100%;
}

/* Video Tile */
.vtile {
  position: relative;
  background: #050810;
  border: 2px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vtile.speaking {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

.vtile.spotlighted {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.vtile video {
  width: 100%;
  height: 100%;
  object-fit: var(--video-fit, contain);
  background: #000;
  display: block;
  transform: translateZ(0);
}

.vtile.mirror video {
  transform: scaleX(-1) translateZ(0);
}

.vtile-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #cbd5e1;
  text-align: center;
  padding: 12px;
}

.avatar-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}

.vtile-overlay-bottom {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.vtile-nameplate {
  background: rgba(2, 6, 23, 0.84);
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 86%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vtile-top-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.vtile-actions {
  display: none;
  gap: 4px;
  pointer-events: auto;
}

.vtile:hover .vtile-actions { display: flex; }

/* Per-Tile Fullscreen Button (Always tappable on Phone & Laptop!) */
.vtile-fs-btn {
  pointer-events: auto;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.78);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, transform 0.14s ease;
}
.vtile-fs-btn:hover { background: rgba(79, 70, 229, 0.85); transform: scale(1.06); }

/* Native Fullscreen & iOS Pseudo-Fullscreen Modes */
.vtile:fullscreen,
.vtile:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: 0 !important;
  background: #000 !important;
}

.vtile.tile-pseudo-fs {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  z-index: 88 !important;
  border-radius: 0 !important;
  border: 0 !important;
  background: #000 !important;
}

.meet-shell.stage-pseudo-fs .meet-topbar,
.meet-shell.stage-pseudo-fs .meet-drawer {
  display: none !important;
}

.meet-shell.stage-pseudo-fs .video-stage {
  padding: 4px !important;
}

.exit-fs-pill {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 99;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.exit-fs-pill:hover { background: #dc2626; }

/* Pagination Bar */
.grid-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 0 0;
  font-size: 12px;
  color: #cbd5e1;
}

/* Hybrid Webinar Player */
.webinar-player-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.webinar-video-box {
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 14px;
  border: 2px solid #10b981;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.webinar-video-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.webinar-info-bar {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

/* Floating Reactions Layer */
.reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.float-reaction {
  position: absolute;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: floatUp 3.2s ease-out forwards;
}

.float-reaction .em { font-size: 34px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6)); }
.float-reaction .nm {
  font-size: 10px; font-weight: 800; background: rgba(2, 6, 23, 0.8);
  padding: 2px 6px; border-radius: 99px; color: #f8fafc; margin-top: 2px;
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  15% { opacity: 1; transform: translateY(-30px) scale(1.1); }
  100% { transform: translateY(-360px) scale(0.95); opacity: 0; }
}

/* ---------------- BOTTOM CONTROL DOCK ---------------- */
.meet-dock {
  min-height: 68px;
  background: #0b1120;
  border-top: 1px solid var(--border);
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 30;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.meet-dock::-webkit-scrollbar { display: none; }

.dock-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  height: 50px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.dock-btn:hover { background: #1e293b; }
.dock-btn .ico { font-size: 18px; line-height: 1; }
.dock-btn .lbl { font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.dock-btn.off { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.55); color: #fecaca; }
.dock-btn.on { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.65); color: #a7f3d0; }
.dock-btn.active-tab { background: rgba(79, 70, 229, 0.28); border-color: #6366f1; color: #fff; }
.dock-btn.hand-on { background: rgba(245, 158, 11, 0.25); border-color: #f59e0b; color: #fde68a; }
.dock-btn.leave { background: #dc2626; color: #fff; min-width: 76px; }
.dock-btn.leave:hover { background: #ef4444; }

.dock-badge {
  position: absolute;
  top: 2px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-size: 9.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dock-badge.alert { background: #ef4444; }

/* ---------------- RIGHT COLLAPSIBLE DRAWER ---------------- */
.meet-drawer {
  width: 370px;
  max-width: 100%;
  background: #0f172a;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  z-index: 35;
}

.meet-drawer.closed { display: none; }

.drawer-tabs {
  display: flex;
  align-items: stretch;
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-tab {
  flex: 1;
  min-width: 0;
  padding: 9px 4px;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.drawer-tab.active {
  color: #fff;
  border-bottom-color: #6366f1;
  background: rgba(99, 102, 241, 0.14);
}

.drawer-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  flex-shrink: 0;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border);
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.drawer-close-btn:hover { background: #1e293b; color: #fff; }

.drawer-pane {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.drawer-pane.active { display: flex; }

.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.drawer-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #0b1120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.dcard {
  background: #162033;
  border: 1px solid #26344d;
  border-radius: 10px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.dcard.highlight {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.dcard.warn {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.sec-title {
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="email"],
input[type="url"],
select,
textarea {
  background: #0b1120;
  border: 1px solid #334155;
  color: #f8fafc;
  color-scheme: dark;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  min-width: 0;
  max-width: 100%;
}

input:focus, select:focus, textarea:focus { border-color: #6366f1; }

/* ---------------- POPOVERS (REACTIONS, BG/APPEARANCE, DEVICES) ---------------- */
.popover {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.72);
  z-index: 65;
  max-width: calc(100vw - 20px);
  max-height: 78dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.popover-bg { width: 440px; }
.popover-dev { width: 350px; }
.popover-share { width: 420px; }

.share-mobile-note {
  font-size: 11.5px;
  line-height: 1.4;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 9px;
}

.share-opt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.share-card-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid #334155;
  background: #162033;
  color: #f8fafc;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.share-card-btn:hover { background: #1e293b; border-color: #6366f1; }
.share-card-btn.primary {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.65);
}
.share-card-btn.primary:hover { background: rgba(16, 185, 129, 0.28); }
.share-card-btn .sc-ico { font-size: 22px; flex-shrink: 0; line-height: 1; }
.share-card-btn .sc-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.share-card-btn .sc-txt strong { font-size: 12px; color: #fff; }
.share-card-btn .sc-txt small { font-size: 10.5px; color: #94a3b8; line-height: 1.3; }

/* Interactive Presenter Annotation Overlay & Floating Toolbar */
.presenter-draw-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  cursor: crosshair;
  touch-action: none;
}

.presenter-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 16px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.pt-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pt-page-info {
  font-size: 11.5px;
  font-weight: 800;
  color: #e2e8f0;
  padding: 0 4px;
  white-space: nowrap;
}

.pt-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.pt-color-dot.active {
  transform: scale(1.18);
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #10b981;
}

.reaction-strip {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.reaction-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  font-size: 22px;
  cursor: pointer;
}

.reaction-btn:hover { transform: scale(1.12); background: #334155; }

.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.bg-opt {
  padding: 8px 6px;
  border-radius: 10px;
  border: 2px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-opt:hover { border-color: #64748b; }
.bg-opt.active { border-color: #10b981; background: rgba(16, 185, 129, 0.22); }

.bg-toggle-row {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #e0f2fe;
  cursor: pointer;
  line-height: 1.35;
}

/* Studio Appearance Sliders */
.appear-box {
  margin-top: 8px;
  padding: 10px 11px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.32);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appear-row {
  display: grid;
  grid-template-columns: 122px 1fr 38px;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #e2e8f0;
}

.appear-row input[type="range"] {
  width: 100%;
  accent-color: #10b981;
  cursor: pointer;
}

.appear-val {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 800;
  color: #a7f3d0;
  text-align: right;
}

/* ---------------- SCHEDULE MODAL ---------------- */
.sched-modal-card {
  width: 100%;
  max-width: 920px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 18px;
  -webkit-overflow-scrolling: touch;
}

.sched-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  margin-top: 12px;
}

.sched-dt-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 8px;
}

.sched-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 58dvh;
  overflow-y: auto;
  padding-right: 2px;
}

/* Push-to-Talk & Mic Level Meter */
.ptt-pill {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.94);
  color: #022c22;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  z-index: 75;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  white-space: nowrap;
}

.mic-meter-track {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: #1e293b;
  overflow: hidden;
  margin-top: 5px;
}

.mic-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #34d399, #fbbf24);
  transition: width 0.08s linear;
}

/* ---------------- PRE-JOIN LOBBY & WAITING ROOM OVERLAY ---------------- */
.lobby-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, #13203b 0%, #070b14 78%);
  z-index: 45;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lobby-card {
  width: 100%;
  max-width: 900px;
  margin: auto 0;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.lobby-media-col,
.lobby-form-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 11px;
}

.lobby-form-col { justify-content: center; }

.lobby-preview-box {
  background: #000;
  border: 1px solid #334155;
  border-radius: 12px;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.lobby-preview-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.lobby-media-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.lobby-media-btns .mbtn { flex: 1 1 auto; }

.lobby-dev-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

/* ---------------- MODALS ---------------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 80;
}

.modal-bg.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 18px;
}

/* ---------------- POLLS ---------------- */
.poll-opt-btn {
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1120;
  color: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.poll-opt-btn:hover { border-color: #6366f1; }
.poll-opt-btn.voted { border-color: #10b981; }

.poll-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(99, 102, 241, 0.28);
  pointer-events: none;
  transition: width 0.35s ease;
}

.poll-opt-inner {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  z-index: 1;
}

/* ---------------- TOAST ---------------- */
.toast-wrap {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 340px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  border: 1px solid #475569;
  color: #fff;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.toast.ok { background: #064e3b; border-color: #10b981; }
.toast.err { background: #7f1d1d; border-color: #ef4444; }

.hidden { display: none !important; }

/* ================================================================
 * RESPONSIVE BREAKPOINTS (TABLET & MOBILE-FIRST POLISH)
 * ================================================================ */

/* Tablet & Small Laptop (<= 960px) */
@media (max-width: 960px) {
  .meet-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 92vw;
    box-shadow: -12px 0 36px rgba(0, 0, 0, 0.72);
  }
  .drawer-close-btn { display: flex; }

  .screen-share-wrap { flex-direction: column; }
  .screen-side-strip {
    width: 100%;
    height: 112px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .screen-side-strip .vtile { min-width: 150px; height: 100%; }
}

/* Mobile & Phablet (<= 768px) */
@media (max-width: 768px) {
  .meet-topbar {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 48px;
  }

  .meet-brand {
    gap: 7px;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
  }

  .meet-logo { height: 24px; padding: 2px 4px; }
  .meet-title { font-size: 12px; }
  .meet-sub { font-size: 10px; gap: 4px; }
  .meet-sub .mpill { padding: 1px 6px; font-size: 9.5px; }

  .meet-badges {
    gap: 5px;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .meet-badges::-webkit-scrollbar { display: none; }
  .meet-badges .mbtn-sm { padding: 5px 8px; font-size: 11px; }

  /* Hide per-page dropdown & desktop-only switch on phones */
  #gridPerPageSelect,
  #btnBackToModes { display: none !important; }

  /* Stage & Video Grid */
  .video-stage { padding: 6px; gap: 6px; }
  .stage-banners { padding: 6px 6px 0; }
  .stage-banner { padding: 7px 10px; font-size: 11.5px; }

  .video-grid { gap: 6px; }
  .video-grid.cols-3,
  .video-grid.cols-4,
  .video-grid.cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .speaker-strip { height: 92px; gap: 6px; }
  .speaker-strip .vtile { width: 136px; min-width: 130px; }

  .vtile { border-radius: 10px; }
  .vtile-overlay-bottom { left: 6px; right: 6px; bottom: 6px; }
  .vtile-nameplate { font-size: 10.5px; padding: 3px 6px; max-width: 92%; }
  .vtile-top-badges { top: 6px; left: 6px; right: 6px; }
  .avatar-circle { width: 48px; height: 48px; font-size: 18px; }

  /* Lobby Mobile Card: single column, zero horizontal overflow, clean spacing */
  .lobby-overlay {
    padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
  }
  .lobby-card {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
    gap: 12px;
    border-radius: 14px;
    margin: 0;
  }
  .lobby-media-col,
  .lobby-form-col { gap: 8px; }
  .lobby-preview-box {
    aspect-ratio: 16 / 9;
    max-height: 205px;
  }
  .lobby-media-btns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .lobby-media-btns .mbtn {
    padding: 7px 4px;
    font-size: 10.5px;
    gap: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lobby-dev-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }

  /* Bottom Control Dock: touch-friendly horizontal bar */
  .meet-dock {
    min-height: 60px;
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    justify-content: flex-start;
    gap: 4px;
  }
  .dock-group { gap: 4px; }
  .dock-btn {
    min-width: 56px;
    height: 48px;
    padding: 4px 6px;
    border-radius: 9px;
  }
  .dock-btn .ico { font-size: 17px; }
  .dock-btn .lbl { font-size: 9.5px; }
  .dock-btn.leave { min-width: 60px; }
  .dock-badge { top: 1px; right: 3px; min-width: 15px; height: 15px; font-size: 9px; }

  /* Drawer: full-screen overlay sheet with stacked icon tabs */
  .meet-drawer {
    width: 100%;
    max-width: 100%;
    border-left: 0;
  }
  .drawer-tab {
    flex-direction: column;
    gap: 2px;
    padding: 7px 2px;
    font-size: 10px;
  }
  .drawer-tab .dt-ico { font-size: 14px; line-height: 1; }

  /* Popovers: full-width mobile bottom sheet */
  .popover,
  .popover-bg,
  .popover-dev,
  .popover-share {
    left: 8px;
    right: 8px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    transform: none;
    width: auto;
    max-width: none;
    max-height: 74dvh;
    padding: 12px;
    border-radius: 16px;
  }

  .share-opt-grid { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .presenter-toolbar { top: 6px; padding: 5px 6px; gap: 5px; }

  /* Schedule Modal: single column, smooth single scroll */
  .modal-bg { padding: 8px; }
  .sched-modal-card {
    padding: 14px;
    border-radius: 14px;
    max-height: 92dvh;
  }
  .sched-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sched-list { max-height: none; overflow-y: visible; }

  /* Prevent iOS auto-zoom on input focus */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 15px;
    padding: 8px 10px;
  }

  /* Toast centered cleanly on mobile */
  .toast-wrap {
    top: auto;
    bottom: calc(74px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    max-width: none;
  }
  .toast { text-align: center; }
}

/* Zoom-style Vertical 2-Up Stack on Portrait Phones (2 participants = top & bottom!) */
@media (max-width: 640px) and (orientation: portrait) {
  .video-grid.cols-2 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

/* Compact Phones (<= 480px) */
@media (max-width: 480px) {
  .meet-topbar { padding: 5px 8px; }
  .meet-title { font-size: 11.5px; }
  .mbtn-lbl-hide-xs { display: none; }

  .appear-row {
    grid-template-columns: 102px 1fr 34px;
    gap: 6px;
    font-size: 11px;
  }

  .bg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .avatar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .bg-opt { padding: 7px 4px; font-size: 10.5px; }

  .sched-dt-row { grid-template-columns: minmax(0, 1fr); }

  .lobby-preview-box { max-height: 180px; }
}
