:root {
  --bg-0: #0b0c10;
  --bg-1: #14151b;
  --bg-2: #1c1e26;
  --stroke: rgba(255,255,255,.08);
  --stroke-strong: rgba(255,255,255,.14);
  --text-0: #f4f4f7;
  --text-1: #9a9ba8;
  --accent: #5b8cff;
  --accent-2: #8fb3ff;
  --danger: #ff5c72;
  --ok: #3ddc97;
  --r-m: 14px;
  --r-l: 20px;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(91,140,255,.10), transparent 60%), var(--bg-0);
  color: var(--text-0);
  overflow: hidden;
}
button { font: inherit; }
svg { width: 100%; height: 100%; display: block; }

.screen { height: 100vh; height: 100dvh; }

/* ── Landing ─────────────────────────────────────────────────────── */
#landing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  border-radius: var(--r-l);
  padding: 32px 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .02em;
  color: var(--text-1);
  margin-bottom: 22px;
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(91,140,255,.18);
}
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 8px; }
.lede { color: var(--text-1); font-size: 14.5px; line-height: 1.5; margin: 0 0 26px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-1); margin-bottom: 7px; }
.field {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--stroke-strong);
  color: var(--text-0);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 14.5px;
  outline: none;
}
.field:focus { border-color: var(--accent); }
.join-row { display: flex; gap: 8px; }
.join-row .field { flex: 1; }

.btn {
  border: none;
  border-radius: 11px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { width: 100%; margin-top: 18px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06070a; }
.btn-secondary { background: var(--bg-2); border: 1px solid var(--stroke-strong); color: var(--text-0); }
.btn-ghost { background: transparent; border: 1px solid var(--stroke-strong); color: var(--text-0); display: inline-flex; align-items: center; gap: 7px; }
.btn-ghost svg { width: 15px; height: 15px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-1); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

.error-text { color: var(--danger); font-size: 13px; margin: 14px 0 0; }

/* ── Room ────────────────────────────────────────────────────────── */
#room { display: flex; flex-direction: column; }

.room-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--stroke);
  flex: 0 0 auto;
}
.room-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14.5px; }
.room-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,151,.18); }

.room-body { flex: 1; display: flex; min-height: 0; }

.stage-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Participant strip (always camera thumbnails) ─────────────────── */
.participant-strip {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 14px 14px 4px;
  overflow-x: auto;
}
.strip-tile {
  position: relative;
  flex: 0 0 auto;
  width: 168px;
  aspect-ratio: 16 / 10;
  background: var(--bg-1);
  border: 2px solid transparent;
  border-radius: var(--r-m);
  overflow: hidden;
  transition: border-color .2s;
}
.strip-tile.is-speaking { border-color: var(--ok); }
.strip-tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
.strip-tile-label {
  position: absolute; left: 8px; bottom: 7px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  display: flex; align-items: center; gap: 5px;
  max-width: calc(100% - 16px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip-tile-label .mic-off { width: 11px; height: 11px; color: var(--danger); flex: 0 0 auto; }
.strip-tile-avatar {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #fff;
}

/* ── Stage (screen-share focus) ───────────────────────────────────── */
.stage-wrap { position: relative; flex: 1; min-height: 0; padding: 10px 14px 14px; display: flex; }
.stage {
  position: relative;
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  border-radius: var(--r-l);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-1); font-size: 13.5px; }
.stage-empty-icon { width: 34px; height: 34px; opacity: .5; }
.stage-label {
  position: absolute; left: 14px; top: 12px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  padding: 5px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
}

.rec-badge {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5;
  display: flex; align-items: center; gap: 7px;
  background: rgba(20,10,12,.75);
  border: 1px solid rgba(255,92,114,.4);
  color: #ffb3bd;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
}
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.4s ease-in-out infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.chat-panel {
  width: 280px;
  flex: 0 0 auto;
  border-left: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
}
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--stroke); font-weight: 700; font-size: 13.5px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { font-size: 13px; line-height: 1.4; }
.chat-msg .who { font-weight: 700; color: var(--accent-2); margin-right: 6px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--stroke); }
.chat-form input { flex: 1; background: var(--bg-2); border: 1px solid var(--stroke-strong); border-radius: 99px; padding: 9px 13px; color: var(--text-0); outline: none; font-size: 13px; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--bg-2); color: var(--text-1);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  padding: 7px;
}
.icon-btn-accent { background: var(--accent); color: #06070a; }

.control-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--stroke);
  background: var(--bg-1);
}
.ctrl-cluster { display: flex; align-items: center; gap: 8px; }
.ctrl-cluster-center { flex: 1; justify-content: center; }

.ctrl-icon {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-2);
  color: var(--text-0);
  cursor: pointer;
  padding: 11px;
  transition: background .15s, color .15s;
}
.ctrl-icon[data-active="false"] { background: transparent; color: var(--danger); border-color: rgba(255,92,114,.4); }

.ctrl-labeled {
  display: flex; align-items: center; gap: 7px;
  height: 42px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-2);
  color: var(--text-0);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ctrl-labeled svg { width: 17px; height: 17px; flex: 0 0 auto; }
.ctrl-labeled[data-active="true"] { background: var(--accent); color: #06070a; border-color: transparent; }
.count-badge {
  background: rgba(255,255,255,.14);
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 11.5px; font-weight: 700;
}
.ctrl-labeled[data-active="true"] .count-badge { background: rgba(0,0,0,.18); }

.hangup-btn {
  width: 50px; height: 50px; border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  padding: 13px;
  flex: 0 0 auto;
}

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid var(--stroke-strong);
  padding: 10px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  z-index: 20;
}

@media (max-width: 720px) {
  .chat-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 10; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
  .strip-tile { width: 118px; }
  .ctrl-labeled span:not(.count-badge) { display: none; }
  .ctrl-labeled { padding: 0 11px; }
  .ctrl-icon, .hangup-btn { width: 44px; height: 44px; }
}

/* ── Shared whiteboard ───────────────────────────────────────────── */
.board-overlay {
  position: fixed; inset: 0; z-index: 15;
  background: #16171d;
  display: flex; flex-direction: column;
}
.board-toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke);
}
.board-colors, .board-sizes { display: flex; align-items: center; gap: 8px; }
.board-color {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sw); border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.board-color.is-active { border-color: #fff; }
.board-size {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--stroke-strong); color: var(--text-1);
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.board-size.is-active { background: var(--accent); color: #06070a; border-color: transparent; }
.board-toolbar .btn-ghost { margin-left: auto; }
#board-canvas { flex: 1; width: 100%; touch-action: none; cursor: crosshair; background: #1b1c23; }
