*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #202124;
  --bg-surface: #2d2e30;
  --bg-surface-hover: #3c3d40;
  --bg-elevated: #37383b;
  --bg-controls: #1f1f1f;
  --border-color: #3c4043;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #6e7681;
  --accent-primary: #8ab4f8;
  --accent-danger: #f28b82;
  --accent-warning: #fbbc04;
  --accent-success: #81c995;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-controls: 0 2px 8px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Google Sans', 'Roboto', 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.fullscreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.center { align-items: center; justify-content: center; }

/* ── Join screen ────────────────────────────────────── */
.join-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  max-width: 400px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.brand { margin-bottom: 28px; }
.brand-icon { font-size: 40px; display: block; margin-bottom: 14px; color: var(--accent-primary); }
.brand h1 { font-size: 22px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; letter-spacing: -0.01em; }
.brand p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.join-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}
.join-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 2px rgba(138,180,248,0.2); }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--accent-primary);
  color: #202124;
  width: 100%;
}
.btn-primary:hover { background: #aecbfa; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.btn-leave {
  background: transparent;
  color: var(--text-primary);
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.btn-leave:hover { background: rgba(232,234,237,0.08); }
.btn-leave.ending { color: var(--accent-danger); }
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background var(--transition-fast);
}
.btn-sm:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* ── Top bar (Google Meet style) ───────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-deep);
  flex-shrink: 0;
  min-height: 52px;
  border-bottom: 1px solid transparent;
}
.top-left { display: flex; align-items: center; gap: 12px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.meeting-title {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.peer-count {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}

/* ── Tab bar ────────────────────────────────────────── */
#tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-deep);
  flex-shrink: 0;
  min-height: 44px;
}
.tab-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.tab-btn.active {
  background: var(--accent-primary);
  border-color: transparent;
  color: #202124;
  box-shadow: none;
}
.tab-btn:disabled {
  cursor: default;
  opacity: 0.45;
}
.tab-btn:disabled:hover {
  background: transparent;
  color: var(--text-secondary);
}
#tab-hint {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ── Main area ──────────────────────────────────────── */
#main-area {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* ── Layout root ────────────────────────────────────── */
#layout-root {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}
#layout-root.layout-meet { flex-direction: column; }
#layout-root.layout-whiteboard { flex-direction: column; }
#layout-root.layout-both {
  flex-direction: row;
  gap: 0;
}

/* ── Video section ──────────────────────────────────── */
#video-section {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.layout-whiteboard #video-section { display: none; }
.layout-both #video-section { flex: 0 0 360px; max-width: 360px; }

/* Resize handle */
#resize-handle {
  display: none;
  width: 4px;
  flex-shrink: 0;
  background: var(--border-color);
  cursor: col-resize;
  position: relative;
  transition: background var(--transition-fast);
  z-index: 5;
}
#resize-handle:hover,
#resize-handle.active {
  background: var(--accent-primary);
  width: 4px;
}
.layout-both #resize-handle { display: block; }

/* ── Video grid ───────────────────────────────────── */
#video-grid {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: stretch;
  justify-content: stretch;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
  min-height: 0;
  transition: gap var(--transition-smooth), padding var(--transition-smooth);
}

/* 1-2 participants: fill entire area */
#video-grid.has-1 .video-tile,
#video-grid.has-2 .video-tile {
  flex: 1 1 0;
  max-width: none;
  min-width: 0;
  min-height: 0;
}

/* 3-4 participants: 2×2 grid */
#video-grid.has-3 .video-tile,
#video-grid.has-4 .video-tile {
  flex: 1 1 calc(50% - 8px);
  max-width: calc(50% - 8px);
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}

/* 5-9 participants: 3 columns */
#video-grid.has-5 .video-tile,
#video-grid.has-6 .video-tile,
#video-grid.has-7 .video-tile,
#video-grid.has-8 .video-tile,
#video-grid.has-9 .video-tile {
  flex: 1 1 calc(33.333% - 8px);
  max-width: calc(33.333% - 8px);
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}

/* 10+ participants: 4 columns */
#video-grid.has-many .video-tile {
  flex: 1 1 calc(25% - 8px);
  max-width: calc(25% - 8px);
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}

/* Side-by-side layout: stack videos vertically, each fills half */
.layout-both #video-grid {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 6px;
}
.layout-both #video-grid .video-tile {
  flex: 1 1 0;
  max-width: none;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}

/* ── Video tile ───────────────────────────────────── */
.video-tile {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 0;
  transition: all var(--transition-smooth);
}
.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #1a1a1a;
}
.video-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(32,33,36,0.75);
  backdrop-filter: blur(4px);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  z-index: 3;
  pointer-events: none;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-tile.hand-raised {
  box-shadow: 0 0 0 2px var(--accent-warning);
}
.video-tile .hand-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent-warning);
  color: #202124;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  z-index: 4;
  animation: handPulse 1.5s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(251,188,4,0.4);
}
@keyframes handPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ── Screen share container ────────────────────────── */
#screen-share-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0a0a0a;
  position: relative;
}
#screen-share-main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#screen-share-main .video-tile {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: transparent;
}
#screen-share-main .video-tile video {
  object-fit: contain;
  background: #0a0a0a;
}
#screen-share-main .video-name {
  bottom: 8px;
  left: 8px;
  background: rgba(32,33,36,0.8);
}

/* ── Participant strip (shown during screen share) ── */
#participant-strip {
  flex-shrink: 0;
  min-height: 0;
  background: rgba(32,33,36,0.95);
  border-top: 1px solid var(--border-color);
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
#participant-strip::-webkit-scrollbar { display: none; }
#participant-strip-inner {
  display: flex;
  gap: 8px;
  height: 90px;
  min-width: min-content;
  justify-content: center;
  align-items: center;
}
#participant-strip .video-tile {
  flex: 0 0 auto;
  width: 120px;
  height: 90px;
  border-radius: var(--radius-sm);
  min-height: auto;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
#participant-strip .video-tile:hover {
  border-color: var(--accent-primary);
}
#participant-strip .video-tile.speaking {
  border-color: var(--accent-primary);
}
#participant-strip .video-tile .video-name {
  bottom: 4px;
  left: 4px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Controls bar (Google Meet floating pill) ──────── */
#controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-controls);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-controls);
  z-index: 20;
  transition: opacity var(--transition-fast);
}
#controls:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
}

/* Split control (main button + caret) */
.ctrl-split {
  display: flex;
  align-items: stretch;
  gap: 0;
  position: relative;
}
.ctrl-split .ctrl-btn {
  border-radius: 20px 0 0 20px;
  min-width: 52px;
}
.ctrl-split .ctrl-btn::after {
  content: '';
  position: absolute;
  right: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: rgba(255,255,255,0.1);
}
.ctrl-caret {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 6px;
  border-radius: 0 20px 20px 0;
  font-size: 10px;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.ctrl-caret:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-width: 48px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.08); }
.ctrl-btn.off {
  background: var(--accent-danger);
  color: #202124;
}
.ctrl-btn.off:hover {
  background: #f59e98;
}
.ctrl-btn.raised {
  background: var(--accent-warning);
  color: #202124;
}
.ctrl-btn.raised:hover {
  background: #fcc934;
}
.ctrl-icon { font-size: 18px; }
.ctrl-label { font-size: 12px; font-weight: 500; }

/* ── Device popup ───────────────────────────────────── */
.device-popup {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  width: 300px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.device-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-fast);
}
.device-popup-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}
.device-popup-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-right: 28px;
}
.device-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.device-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}
.device-item:hover { background: rgba(138,180,248,0.08); color: var(--text-primary); }
.device-item.selected {
  background: rgba(138,180,248,0.12);
  border-color: rgba(138,180,248,0.3);
  color: var(--accent-primary);
}
.device-item.selected::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: auto;
  color: var(--accent-primary);
  font-size: 11px;
}

/* ── Whiteboard section ──────────────────────────────── */
#whiteboard-section {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}
.layout-whiteboard #whiteboard-section { display: flex; }
.layout-both #whiteboard-section { display: flex; flex: 1; }

.whiteboard-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

#wb-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wb-colors {
  display: flex;
  align-items: center;
  gap: 5px;
}
.wb-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  flex-shrink: 0;
}
.wb-color:hover { transform: scale(1.15); }
.wb-color.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.wb-separator {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  flex-shrink: 0;
}
.wb-size-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wb-size {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.wb-size::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid #fff;
}
.wb-size::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid #fff;
}
.wb-size-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 22px;
  text-align: center;
}

#whiteboard-canvas {
  flex: 1;
  cursor: crosshair;
  background: #fff;
  border-radius: 0 0 0 8px;
}

.wb-cursor {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(138,180,248,0.85);
  border: 2px solid #fff;
  pointer-events: none;
  z-index: 10;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(138,180,248,0.4);
  transition: left 0.06s linear, top 0.06s linear;
}

/* ── Right-panel toolbar ─────────────────────────────── */
#right-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 8px;
}
.right-panel-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.right-panel-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.right-panel-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.right-panel-btn.active {
  background: var(--accent-primary);
  border-color: transparent;
  color: #202124;
}
.code-language-select {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}
.code-language-select:focus { border-color: var(--accent-primary); }

/* ── Code editor panel ──────────────────────────────── */
#code-editor-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  gap: 0;
  background: var(--bg-deep);
}
.code-row {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
  gap: 4px;
}
.code-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.code-pane-header {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.teacher-pane .code-pane-header { border-left: 3px solid var(--accent-primary); }
.student-pane .code-pane-header { border-left: 3px solid var(--accent-success); }
.code-editor-pane .monaco-container {
  flex: 1;
  min-height: 0;
  min-width: 0;
  border: none;
}
.code-editor-pane:not(.monaco-loaded) .monaco-container {
  background: #1a1a30;
}
.code-divider {
  flex-shrink: 0;
  height: 4px;
  background: var(--border-color);
  border: none;
}

.code-pane-title {
  display: flex;
  align-items: center;
  gap: 4px;
}

.code-font-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.code-font-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-family: inherit;
}
.code-font-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.code-font-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 20px;
  text-align: center;
}

.code-run-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: var(--accent-primary);
  color: #202124;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}
.code-run-btn:hover {
  background: #aecbfa;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.code-run-btn:active { transform: scale(0.96); }

.code-preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-left: 2px solid var(--border-color);
}
.teacher-preview-pane { border-left-color: var(--accent-primary); }
.student-preview-pane { border-left-color: var(--accent-success); }
.code-preview-header {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.code-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.code-preview-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}
.code-preview-console {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-clear-btn,
.code-hide-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}
.code-clear-btn:hover,
.code-hide-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.code-hide-btn:hover { background: rgba(242,139,130,0.12); color: var(--accent-danger); }

/* ── Chat panel ─────────────────────────────────────── */
#chat-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-left: 1px solid var(--border-color);
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  background: var(--bg-surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}
.chat-msg .msg-name {
  font-weight: 500;
  color: var(--accent-primary);
  font-size: 12px;
  margin-right: 4px;
}
#chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-deep);
}
#chat-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}
#chat-input:focus { border-color: var(--accent-primary); }
#chat-input::placeholder { color: var(--text-muted); }

/* ── Video avatar placeholder ───────────────────────── */
.video-avatar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(56px, 12vw, 96px);
  height: clamp(56px, 12vw, 96px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 500;
  color: #fff;
  text-transform: uppercase;
  z-index: 3;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.video-avatar.visible {
  opacity: 1;
}
/* On the video tile itself when we know camera is off */
.video-tile.has-avatar .video-avatar {
  opacity: 1;
}
.video-tile.has-avatar video {
  opacity: 0.4;
}

/* ── Responsive breakpoints ─────────────────────────── */

/* Tablet / smaller screens */
@media (max-width: 1024px) {
  .layout-both #video-section {
    flex: 0 0 300px;
    max-width: 300px;
  }
  #chat-panel { width: 280px; }
  #controls {
    gap: 1px;
    padding: 4px 6px;
  }
  .ctrl-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .ctrl-icon { font-size: 16px; }
  .ctrl-label { display: none; }
  #participant-strip-inner { height: 70px; }
  #participant-strip .video-tile {
    width: 90px;
    height: 70px;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .layout-both {
    flex-direction: column !important;
  }
  .layout-both #video-section {
    flex: 0 0 180px;
    max-width: 100%;
  }
  .layout-both #resize-handle { display: none; }
  .layout-both #whiteboard-section {
    flex: 1;
  }
  #controls {
    bottom: 8px;
    padding: 4px 6px;
    gap: 0;
    border-radius: var(--radius-md);
  }
  .ctrl-btn {
    padding: 8px 12px;
    min-width: auto;
  }
  .ctrl-label { display: none; }
  .ctrl-caret { display: none; }
  .ctrl-split .ctrl-btn {
    border-radius: 16px;
    padding-right: 8px;
  }
  .ctrl-split .ctrl-btn::after { display: none; }
  #chat-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 320px;
    z-index: 15;
    box-shadow: -4px 0 16px rgba(0,0,0,0.3);
  }
  #video-grid {
    gap: 4px;
    padding: 4px;
  }
  .video-tile { border-radius: var(--radius-sm); }
  #participant-strip-inner { height: 60px; }
  #participant-strip .video-tile {
    width: 70px;
    height: 60px;
  }
  .join-card { padding: 32px 24px; }
}

/* Small mobile */
@media (max-width: 400px) {
  #video-grid .video-tile {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
  }
  #video-grid.has-2 .video-tile,
  #video-grid.has-3 .video-tile,
  #video-grid.has-4 .video-tile {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  #controls {
    bottom: 4px;
    padding: 4px;
    gap: 0;
  }
  .ctrl-btn { padding: 6px 10px; }
  .ctrl-icon { font-size: 14px; }
}
