:root {
  color-scheme: dark;
  --bg: #080d19;
  --card: rgba(18, 26, 47, .64);
  --glass: rgba(255,255,255,.075);
  --muted: #aab9d6;
  --text: #ecf3ff;
  --line: rgba(255,255,255,.13);
  --accent: #6ea8ff;
  --accent2: #6effd2;
  --danger: #ff6e83;
  --warn: #ffe7a0;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(76, 130, 255, .24), transparent 36%),
    radial-gradient(circle at bottom right, rgba(42, 241, 194, .12), transparent 34%),
    linear-gradient(135deg, #050814, var(--bg) 54%, #0a1429);
  color: var(--text);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.22rem, 2vw, 1.85rem); letter-spacing: -.03em; }
h2 { font-size: 1.05rem; letter-spacing: -.02em; }
h3 { color: var(--text); font-size: .88rem; margin-bottom: 8px; }
p { color: var(--muted); margin-top: 3px; line-height: 1.45; }
button, input, select { font: inherit; }
button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #061020;
  font-weight: 800;
  border-radius: 13px;
  padding: 11px 14px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,.22);
}
button:disabled { opacity: .45; cursor: not-allowed; }
input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(4, 10, 22, .72);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
}
select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, #ecf3ff 50%),
    linear-gradient(135deg, #ecf3ff 50%, transparent 50%);
  background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus, select:focus { border-color: rgba(110,168,255,.86); box-shadow: 0 0 0 3px rgba(110,168,255,.16); }
label { color: var(--muted); font-size: .86rem; display: grid; gap: 7px; }
.glassbar, .glasscard {
  background: linear-gradient(145deg, rgba(255,255,255,.105), rgba(255,255,255,.035));
  border: 1px solid rgba(255,255,255,.17);
  box-shadow: 0 18px 60px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.12);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.topbar, .shell { width: min(1320px, 94vw); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 10px;
  z-index: 50;
  margin-top: 12px;
  border-radius: 24px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logoMark {
  width: 42px; height: 42px; border-radius: 15px;
  display: grid; place-items: center;
  background: rgba(110,168,255,.16);
  border: 1px solid rgba(255,255,255,.18);
  font-weight: 900;
}
.topnav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.navBtn {
  background: rgba(255,255,255,.075);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: none;
  padding: 9px 12px;
}
.navBtn.active { background: linear-gradient(135deg, rgba(110,168,255,.95), rgba(110,255,210,.90)); color: #061020; }
.pill {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 14px; background: rgba(255,255,255,.06);
  white-space: nowrap;
  color: var(--text);
}
.webinarShell { padding: 16px 0 32px; }
.stageHeader {
  border-radius: 22px;
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.quickActions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.participantGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px;
  align-items: stretch;
}
.remoteGrid { display: contents; }
.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 230px;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(5,8,18,.88);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 16px 50px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
video {
  width: 100%; height: 100%;
  min-height: 230px;
  object-fit: cover;
  background: #050812;
  display: block;
}
.tileLabel {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(0,0,0,.58);
  padding: 7px 10px; border-radius: 999px;
  color: white; font-size: .86rem;
  border: 1px solid rgba(255,255,255,.12);
}
.statsPanel {
  position: absolute;
  left: 12px; right: 12px; top: 12px;
  z-index: 5;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  background: rgba(8, 13, 24, .58);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: #d7f7ff;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0,0,0,.65);
  max-height: 40%;
  overflow: hidden;
}
.panelDock { margin-top: 14px; }
.sidePanel {
  display: none;
  border-radius: 22px;
  padding: 16px;
}
.sidePanel.active { display: block; }
.panelHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.formGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}
.panelActions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.check input { width: auto; min-height: auto; }
.shareBlock { margin-top: 12px; color: var(--muted); }
.shareBlock input { margin-top: 10px; }
.chatLayout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; }
ul { list-style: none; padding: 0; margin: 0; }
li, .logline {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  color: var(--muted);
}
.usersBox, .messageBox, .helpCell, #log, .chatMirror {
  background: rgba(0,0,0,.18);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
#log { height: 310px; overflow: auto; font-size: 13px; }
.chatMirror { min-height: 190px; color: var(--muted); }
.msgbar { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 10px; }
.helpGrid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; }
.helpCell.warn { background: rgba(255, 193, 7, .10); border-color: rgba(255, 193, 7, .22); }
.helpCell.warn p, .helpCell.warn b { color: var(--warn); }
@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr; }
  .topnav { justify-content: flex-start; }
  .stageHeader { align-items: flex-start; flex-direction: column; }
  .quickActions { justify-content: flex-start; }
  .formGrid, .chatLayout, .helpGrid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .topbar, .shell { width: min(100% - 20px, 1320px); }
  .navBtn, button { width: 100%; }
  .topnav, .quickActions, .panelActions { width: 100%; }
  .participantGrid { grid-template-columns: 1fr; }
}
.chatMirror { height: 220px; overflow: auto; }
.chatLine { padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.chatLine b { color: var(--text); }

.menuToggle {
  display: none;
  width: auto;
  min-width: 44px;
  height: 44px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: none;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 10px;
    top: env(safe-area-inset-top, 0px);
    margin-top: 8px;
    border-radius: 18px;
  }
  .brand p { display: none; }
  .brand h1 { font-size: 1rem; }
  .logoMark { width: 36px; height: 36px; border-radius: 12px; }
  .menuToggle { display: inline-grid; place-items: center; }
  .topnav {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
  }
  body.menuOpen .topnav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .pill {
    grid-column: 1 / -1;
    width: 100%;
    text-align: center;
    padding: 8px 10px;
    font-size: .88rem;
  }
  .navBtn, button { width: 100%; }
  .webinarShell { padding-top: 10px; }
  .stageHeader { padding: 12px; }
  .quickActions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .quickActions #joinBtn,
  .quickActions #leaveBtn { grid-column: span 1; }
  .tile, video { min-height: 210px; }
  .sidePanel { padding: 13px; border-radius: 18px; }
  .formGrid, .chatLayout, .helpGrid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .quickActions { grid-template-columns: 1fr; }
  .tile, video { min-height: 190px; }
}

/* v11 mobile cleanup: keep the hamburger compact and stop the top bar from covering controls on iPhone scroll. */
@media (max-width: 760px) {
  .topbar {
    position: relative;
    top: auto;
    padding: 10px;
    margin-top: 6px;
  }
  .pill {
    order: 4;
    padding: 8px 10px;
    font-size: .82rem;
  }
  .stageHeader {
    margin-top: 8px;
  }
  .stageHeader > div:first-child {
    display: none;
  }
  .quickActions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .quickActions button {
    min-height: 42px;
    padding: 9px 10px;
    font-size: .9rem;
  }
  .sidePanel:not(.active) {
    display: none !important;
  }
}

/* v12: stats are opened from a compact button on the participant tile. */
.tileStatsBtn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 8;
  width: auto;
  min-width: 70px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.58);
  color: #fff;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: none;
  font-size: .82rem;
}
.statsPanel {
  display: none;
  max-height: 58%;
  overflow: auto;
  pointer-events: auto;
}
.statsPanel.visible {
  display: block;
}
@media (max-width: 760px) {
  .tileStatsBtn {
    right: 10px;
    bottom: 10px;
    min-width: 64px;
    padding: 6px 9px;
    font-size: .78rem;
  }
}

/* v13: visible iPhone mic recovery button on the local participant tile. */
.tileMicBtn {
  position: absolute;
  right: 92px;
  bottom: 12px;
  z-index: 9;
  width: auto;
  min-width: 92px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 193, 7, .86);
  color: #071018;
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: none;
  font-size: .82rem;
  font-weight: 800;
}
.tileMicBtn[hidden] { display: none !important; }
@media (max-width: 760px) {
  .tileMicBtn {
    right: 82px;
    bottom: 10px;
    min-width: 86px;
    padding: 6px 9px;
    font-size: .76rem;
  }
}
