/* ============================================================
 * ClassMeet — Design System
 * Light blue + white · mobile-first · animated
 * ============================================================ */
:root {
  --blue: #38bdf8;
  --blue-dark: #0ea5e9;
  --blue-deep: #0284c7;
  --blue-ink: #0c4a6e;
  --blue-tint: #f0f9ff;
  --grad: linear-gradient(135deg, #38bdf8, #0ea5e9);
  --grad-deep: linear-gradient(135deg, #0ea5e9, #0284c7);
  --bg: #f0f9ff;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e0f2fe;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 2px 12px rgba(2, 132, 199, 0.10);
  --shadow-lg: 0 10px 34px rgba(2, 132, 199, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ctl-size: 60px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; color: var(--blue-ink); }
p { margin: 0 0 0.8rem; }
button { font-family: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.55);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Views ---------- */
.view { display: none; min-height: 100dvh; }
.view.active { display: flex; flex-direction: column; animation: viewIn 0.35s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Lobby ---------- */
#view-lobby {
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #e0f2fe 0%, #f0f9ff 45%, #ffffff 100%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; pointer-events: none; }
.blob-1 { width: 340px; height: 340px; background: #7dd3fc; top: -110px; left: -90px; animation: drift 11s ease-in-out infinite alternate; }
.blob-2 { width: 280px; height: 280px; background: #bae6fd; bottom: -100px; right: -70px; animation: drift 13s ease-in-out infinite alternate-reverse; }
.blob-3 { width: 180px; height: 180px; background: #e0f2fe; top: 40%; right: 12%; animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(34px, 26px) scale(1.08); } }

.lobby-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem 1.5rem;
  border: 1px solid var(--border);
}
.anim-rise { animation: rise 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(0.98); } to { opacity: 1; transform: none; } }

.logo-wrap { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.logo-badge {
  width: 54px; height: 54px; border-radius: 16px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.4);
  animation: logoFloat 3.4s ease-in-out infinite;
}
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.logo-text { font-size: 1.9rem; margin: 0; color: var(--blue-ink); font-weight: 800; letter-spacing: -0.5px; }
.logo-text span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.25rem; }

.field-label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--blue-ink); margin: 0.9rem 0 0.4rem; }
.text-input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.text-input:focus { outline: none; border-color: var(--blue-dark); box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15); }
.code-input { text-transform: uppercase; letter-spacing: 0.35em; font-weight: 700; text-align: center; font-size: 1.25rem; }

.role-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.5rem; }
.role-card {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 0.9rem 0.5rem;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  min-height: 48px;
}
.role-card:hover { transform: translateY(-2px); }
.role-card[aria-checked="true"] {
  border-color: var(--blue-dark);
  background: var(--blue-tint);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}
.role-icon { font-size: 1.8rem; }
.role-name { font-weight: 700; color: var(--blue-ink); }
.role-desc { font-size: 0.78rem; color: var(--muted); }

.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0.8rem 0; font-size: 0.9rem;
  animation: shake 0.4s ease;
}
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.hint { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 0.5rem; }
.secure-note { font-size: 0.78rem; color: var(--muted); text-align: center; margin-top: 1.25rem; margin-bottom: 0; }

/* ---------- Buttons ---------- */
.btn {
  border: none; cursor: pointer;
  font-size: 1rem; font-weight: 700;
  padding: 0.8rem 1.4rem;
  border-radius: 12px;
  transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
  min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.35);
}
.btn-primary:hover:not(:disabled) { background: var(--grad-deep); box-shadow: 0 8px 22px rgba(14, 165, 233, 0.45); transform: translateY(-1px); }
.btn-secondary { background: var(--blue-tint); color: var(--blue-deep); border: 2px solid var(--border); }
.btn-secondary:hover { border-color: var(--blue-dark); }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.1rem; padding: 0.95rem 1.4rem; }
.icon-btn {
  background: var(--blue-tint); border: 1px solid var(--border);
  border-radius: 10px; width: 44px; height: 44px; font-size: 1.15rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s, background 0.2s;
  flex: 0 0 auto;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn:hover { background: #e0f2fe; }
.icon-btn.active { background: var(--grad); color: #fff; border-color: transparent; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Room ---------- */
#view-room { height: 100dvh; background: #0b1e33; }
.room-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.room-id { display: flex; align-items: center; gap: 0.4rem; }
.room-code {
  font-weight: 800; letter-spacing: 0.25em; font-size: 1.05rem;
  background: var(--grad); color: #fff;
  padding: 0.35rem 0.7rem 0.35rem 0.95rem; border-radius: 10px;
}
.conn-status { font-size: 0.82rem; color: var(--muted); margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.conn-status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #fbbf24; display: inline-block; }
.conn-status.live { color: var(--ok); }
.conn-status.live::before { background: var(--ok); animation: pulseSoft 2s infinite; }
@keyframes pulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.rec-indicator {
  display: flex; align-items: center; gap: 0.4rem;
  background: #fef2f2; color: #b91c1c; font-weight: 700; font-size: 0.9rem;
  padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid #fecaca;
}
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: recPulse 1.1s infinite; }
@keyframes recPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: 0.6; } }

.banner { padding: 0.6rem 1rem; font-size: 0.88rem; text-align: center; }
.banner.warn { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.banner.info { background: var(--blue-tint); color: var(--blue-deep); border-bottom: 1px solid var(--border); }

/* ---------- Video grid ---------- */
#video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  padding: 0.6rem;
  overflow-y: auto;
  align-content: start;
  position: relative;
  min-height: 0;
}
@media (min-width: 640px) {
  #video-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  #video-grid { grid-template-columns: repeat(3, 1fr); }
}
.tile {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #12263f;
  border-radius: var(--radius);
  overflow: hidden;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  animation: tileIn 0.35s ease;
}
@keyframes tileIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.tile.speaking { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #12263f; }
.tile .tile-name {
  position: absolute; left: 0.55rem; bottom: 0.55rem;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 0.8rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .tile-mic {
  position: absolute; top: 0.55rem; right: 0.55rem;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.tile .tile-mic.muted { background: var(--danger); }
.tile .tile-screen-tag {
  position: absolute; top: 0.55rem; left: 0.55rem;
  background: var(--grad); color: #fff; font-size: 0.72rem; font-weight: 700;
  padding: 0.2rem 0.55rem; border-radius: 999px;
}
.tile.cam-off video { display: none; }
.tile .avatar-fallback {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  font-size: 2.6rem; font-weight: 800; color: #fff;
  background: var(--grad-deep);
}
.tile.cam-off .avatar-fallback { display: flex; }

.waiting-state {
  grid-column: 1 / -1;
  text-align: center; color: #cbd5e1;
  padding: 3rem 1rem;
  align-self: center;
}
.waiting-pulse { font-size: 3rem; animation: pulseSoft 1.8s infinite; }
.waiting-state p { margin: 0.4rem 0; }
.waiting-state .muted { color: #94a3b8; }

/* ---------- Control bar ---------- */
#control-bar {
  display: flex;
  gap: 0.35rem;
  padding: 0.6rem 0.5rem calc(0.6rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  justify-content: safe center;
  z-index: 5;
}
.ctl {
  border: none; background: transparent; cursor: pointer;
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  min-width: var(--ctl-size); min-height: 48px;
  padding: 0.45rem 0.3rem;
  border-radius: 12px;
  color: var(--blue-ink);
  transition: background 0.18s, transform 0.12s;
  position: relative;
  flex: 0 0 auto;
}
.ctl:hover { background: var(--blue-tint); }
.ctl:active { transform: scale(0.92); }
.ctl-icon {
  font-size: 1.35rem;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-tint);
  border-radius: 50%;
  transition: background 0.2s, transform 0.2s;
}
.ctl[aria-pressed="false"] .ctl-icon { background: #fee2e2; }
.ctl.danger .ctl-icon { background: #fee2e2; }
.ctl.danger:hover .ctl-icon { background: var(--danger); }
.ctl.danger:hover { color: #fff; }
.ctl.danger:hover .ctl-label { color: #fff; }
.ctl.rec-on .ctl-icon { background: var(--danger); animation: recPulse 1.1s infinite; }
.ctl-label { font-size: 0.68rem; font-weight: 600; }
.badge {
  position: absolute; top: 2px; right: 6px;
  background: var(--danger); color: #fff;
  font-size: 0.68rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ---------- Overlay panels ---------- */
.overlay-panel {
  position: fixed; inset: 0; z-index: 40;
  background: #fff;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(4%); opacity: 0.6; } to { transform: none; opacity: 1; } }

.wb-toolbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #fff;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  flex: 0 0 auto;
}
.wb-tools { display: flex; gap: 0.3rem; }
.wb-tool {
  width: 46px; height: 46px; font-size: 1.25rem;
  border: 2px solid transparent; background: var(--blue-tint); border-radius: 12px;
  cursor: pointer; transition: transform 0.12s, border-color 0.2s, background 0.2s;
  flex: 0 0 auto;
}
.wb-tool:active { transform: scale(0.9); }
.wb-tool.active { border-color: var(--blue-dark); background: #fff; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2); }
.wb-colors { display: flex; gap: 0.3rem; }
.wb-color {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 0 0 1px #cbd5e1;
  transition: transform 0.12s;
  flex: 0 0 auto;
}
.wb-color.active { box-shadow: 0 0 0 2px var(--blue-deep); transform: scale(1.15); }
.wb-width { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 700; color: var(--blue-deep); }
.wb-width input { width: 90px; accent-color: var(--blue-dark); }
.wb-actions { display: flex; gap: 0.3rem; margin-left: auto; }
.wb-pages { display: flex; gap: 0.3rem; }
.wb-page-tab {
  min-width: 44px; height: 44px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: #fff; font-weight: 700; color: var(--muted);
}
.wb-page-tab.active { border-color: var(--blue-dark); color: var(--blue-deep); background: var(--blue-tint); }

#wb-canvas-wrap { position: relative; flex: 1; min-height: 0; background: #fff; touch-action: none; }
#wb-canvas, #wb-preview { position: absolute; inset: 0; width: 100%; height: 100%; }
#wb-canvas { cursor: crosshair; }
#wb-preview { pointer-events: none; }
.wb-text-input {
  position: absolute; z-index: 5;
  font-size: 18px; padding: 0.3rem 0.5rem;
  border: 2px dashed var(--blue-dark); border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}
.wb-toolbar.locked .wb-tools,
.wb-toolbar.locked .wb-colors,
.wb-toolbar.locked .wb-width,
.wb-toolbar.locked .wb-actions { opacity: 0.35; pointer-events: none; }

/* ---------- Side panels ---------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(360px, 92vw);
  background: #fff;
  display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(2, 132, 199, 0.18);
  animation: slideInRight 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  border-left: 1px solid var(--border);
}
@keyframes slideInRight { from { transform: translateX(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; border-bottom: 2px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.55rem; }
.chat-msg { max-width: 85%; animation: tileIn 0.25s ease; }
.chat-msg .chat-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.15rem; }
.chat-msg .chat-bubble {
  background: var(--blue-tint); border-radius: 4px 14px 14px 14px;
  padding: 0.55rem 0.8rem; font-size: 0.93rem; word-wrap: break-word;
}
.chat-msg.mine { align-self: flex-end; }
.chat-msg.mine .chat-bubble { background: var(--grad); color: #fff; border-radius: 14px 4px 14px 14px; }
.chat-msg.mine .chat-meta { text-align: right; }
.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: 0.92rem; }
.chat-form { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 2px solid var(--border); }
.chat-form .text-input { flex: 1; }
#chat-send { min-width: 52px; }

.participants-list { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
#btn-mute-all { margin: 0.75rem 0.75rem 0; }
.person {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 0.75rem; background: var(--blue-tint);
  border-radius: 12px; animation: tileIn 0.25s ease;
}
.person-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; flex: 0 0 auto;
}
.person-info { flex: 1; min-width: 0; }
.person-name { font-weight: 700; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-role { font-size: 0.75rem; color: var(--muted); }
.person-flags { font-size: 0.85rem; }
.person .icon-btn { width: 40px; height: 40px; }

/* ---------- Toasts / modal / loading ---------- */
#toasts {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  width: min(420px, 92vw); pointer-events: none;
}
.toast {
  background: #0b1e33; color: #fff;
  padding: 0.7rem 1.1rem; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  max-width: 100%; text-align: center;
}
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger-dark); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.95); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(11, 30, 51, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: viewIn 0.25s ease;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  padding: 1.5rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal h3 { margin-bottom: 0.5rem; }
.modal p { color: var(--muted); font-size: 0.93rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.2rem; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(240, 249, 255, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  font-weight: 600; color: var(--blue-deep);
}
.spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 5px solid var(--border); border-top-color: var(--blue-dark);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Desktop tweaks ---------- */
@media (min-width: 900px) {
  :root { --ctl-size: 68px; }
  .room-header { padding: 0.7rem 1.5rem; }
  #control-bar { gap: 0.6rem; }
}

/* ---------- Elapsed time + network health ---------- */
.elapsed-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 0.88rem; color: var(--blue-deep);
  background: var(--blue-tint); border: 1px solid var(--border);
  padding: 0.3rem 0.65rem; border-radius: 999px;
  white-space: nowrap;
}
.net-health {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.net-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.net-health.degraded .net-dot { background: #f59e0b; animation: pulseSoft 1.6s infinite; }
.net-health.degraded { color: #b45309; }
.net-health.poor .net-dot { background: var(--danger); animation: recPulse 1.1s infinite; }
.net-health.poor { color: var(--danger-dark); }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--blue-deep); font-weight: 700; font-size: 0.88rem;
  text-decoration: underline; padding: 0.2rem 0.4rem;
  min-height: 44px;
}

/* ---------- Quality menu ---------- */
.quality-menu {
  position: fixed; z-index: 60;
  bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  width: min(340px, 92vw);
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  padding: 0.5rem;
  animation: rise 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.q-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  width: 100%; text-align: left; cursor: pointer;
  border: 2px solid transparent; background: transparent; border-radius: 12px;
  padding: 0.65rem 0.8rem; min-height: 48px;
  transition: background 0.15s, border-color 0.15s;
}
.q-opt:hover { background: var(--blue-tint); }
.q-opt.active { border-color: var(--blue-dark); background: var(--blue-tint); }
.q-name { font-weight: 700; color: var(--blue-ink); font-size: 0.95rem; }
.q-desc { font-size: 0.78rem; color: var(--muted); }

/* ---------- Waiting room: join requests (teacher) ---------- */
.join-requests {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.75rem 1rem 0;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.join-request {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: #fff; border: 2px solid var(--blue-dark); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 0.7rem 0.9rem;
  animation: jr-slide 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes jr-slide {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.jr-info { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.jr-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff;
  animation: jr-pulse 1.6s ease-in-out infinite;
}
@keyframes jr-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(14, 165, 233, 0); }
}
.jr-actions { display: flex; gap: 0.5rem; flex: none; }
.btn-sm { padding: 0.55rem 1rem; font-size: 0.9rem; min-height: 44px; }

/* Loading overlay cancel button */
#loading-cancel { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .join-request, .jr-avatar { animation: none; }
}

/* ---------- Classroom features: hand, reactions, pin, lock ---------- */
.version-note { text-align: center; font-size: 0.75rem; color: var(--muted); margin-top: 0.75rem; }

.tile { position: relative; cursor: pointer; }
.tile-hand {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  font-size: 1.5rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  animation: hand-wave 1.2s ease-in-out infinite;
}
@keyframes hand-wave {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(14deg); }
}
.hand-badge { font-size: 0.9rem; }

/* Pinned video layout */
#video-grid.has-pinned { grid-template-columns: 1fr 1fr; }
#video-grid.has-pinned .tile.pinned {
  grid-column: 1 / -1; order: -1;
  aspect-ratio: 16 / 9; max-height: 52vh;
  outline: 3px solid var(--blue-dark); outline-offset: -3px;
}
#video-grid.has-pinned .tile.pinned::after {
  content: '📌 Pinned — tap to unpin';
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(12, 74, 110, 0.85); color: #fff; font-size: 0.75rem;
  padding: 0.25rem 0.7rem; border-radius: 999px; white-space: nowrap;
}

/* Reactions */
.react-menu {
  display: flex; flex-direction: row; gap: 0.25rem;
  padding: 0.6rem; width: auto; max-width: 94vw;
}
.react-opt {
  font-size: 1.7rem; background: transparent; border: 2px solid transparent;
  border-radius: 12px; padding: 0.4rem 0.55rem; cursor: pointer; min-width: 52px; min-height: 52px;
  transition: transform 0.15s, background 0.15s;
}
.react-opt:hover { transform: scale(1.25); background: var(--blue-tint); }
#reaction-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden;
}
.reaction-float {
  position: absolute; bottom: -40px; font-size: 2.6rem;
  animation: react-rise 2.6s ease-out forwards;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}
@keyframes react-rise {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  12% { opacity: 1; transform: translateY(-6vh) scale(1.15); }
  100% { transform: translateY(-72vh) scale(1); opacity: 0; }
}

/* Teacher controls in participants panel */
.teacher-controls { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.teacher-controls[hidden] { display: none; }
.ctl.active { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; }
.ctl.active .ctl-label { color: #fff; }
.ctl .badge {
  position: absolute; top: 2px; right: 6px;
  background: #e11d48; color: #fff; font-size: 0.7rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

@media (prefers-reduced-motion: reduce) {
  .tile-hand, .reaction-float { animation: none; }
  .reaction-float { opacity: 1; }
}

/* ---------- Audio fixes: mic test + tap-to-hear ---------- */
.mic-test { margin-top: 0.75rem; }
.mic-test-bar {
  height: 14px; border-radius: 999px; background: var(--blue-tint);
  border: 1px solid var(--border); overflow: hidden;
}
.mic-test-level {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  border-radius: 999px; transition: width 0.08s linear;
}
#mic-test-msg.test-ok { color: #1a7f37; font-weight: 600; }
.tap-to-hear {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem;
  background: rgba(12, 74, 110, 0.72); color: #fff; border: none; cursor: pointer;
  font-size: 2rem; border-radius: inherit;
}
.tap-to-hear span { font-size: 0.9rem; font-weight: 600; }

/* ---------- Media connection states ---------- */
.tile.media-connecting::after {
  content: 'Connecting…';
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 74, 110, 0.55); color: #fff;
  font-size: 0.85rem; font-weight: 600; border-radius: inherit;
}
.tile.media-failed::after {
  content: '⚠️ Media failed — retrying…';
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(153, 27, 27, 0.6); color: #fff;
  font-size: 0.8rem; font-weight: 600; border-radius: inherit; padding: 0.5rem;
}
