/* ============================================================
   Video Chat Room — Meet-style dark UI
   ============================================================ */

:root {
  --bg: #0a0c12;
  --bg-2: #0f1320;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-3: rgba(255, 255, 255, 0.14);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #e9ecf5;
  --text-dim: rgba(233, 236, 245, 0.6);
  --text-faint: rgba(233, 236, 245, 0.38);
  --accent: #7c93ff;
  --accent-2: #a78bfa;
  --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.16);
  --ok: #34d399;
  --warn: #fbbf24;
  --speak: #4ade80;
  --radius: 16px;
  --tile-radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input:focus, select:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}

select option { background: #181c28; color: var(--text); }

svg { width: 22px; height: 22px; flex: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- ambient background ---------- */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  animation: drift 26s ease-in-out infinite alternate;
}

.b1 { background: #4f46e5; top: -20vmax; left: -12vmax; }
.b2 { background: #7c3aed; bottom: -25vmax; right: -15vmax; animation-delay: -8s; }
.b3 { background: #0ea5e9; top: 40%; left: 55%; width: 30vmax; height: 30vmax; opacity: 0.08; animation-delay: -16s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(6vmax, 4vmax) scale(1.15); }
}

/* ---------- brand ---------- */
.logo-mark {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 7px;
  background: var(--accent-grad);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.55);
  position: relative;
}

.logo-mark::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}

/* ============================================================
   PRE-JOIN
   ============================================================ */
#prejoin {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
}

.pj-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.pj-card {
  display: flex;
  gap: 36px;
  align-items: center;
  max-width: 980px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 32px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.pj-left { flex: 1.2; min-width: 0; }

.pj-video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #11141d;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.pj-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.pj-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 72px;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.pj-controls {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.pj-level {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 6px;
  height: 60px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.pj-level i {
  display: block;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #34d399, #a3e635);
  border-radius: 4px;
  transition: height 0.08s linear;
}

.pj-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}

.pj-right h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.3px; }

.pj-room { color: var(--text-dim); font-size: 14px; margin-bottom: 4px; }

.room-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 13px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
}

.pj-devices { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.pj-devices select { width: 100%; }

.join-btn {
  margin-top: 10px;
  padding: 13px 28px;
  border-radius: 999px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

.join-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(99, 102, 241, 0.6); }
.join-btn:active { transform: translateY(0) scale(0.98); }
.join-btn:disabled { filter: grayscale(0.7) brightness(0.6); cursor: not-allowed; box-shadow: none; }

.ghost-btn {
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}

.ghost-btn:hover { background: var(--surface-2); }

.pj-error { color: #fca5a5; font-size: 13px; line-height: 1.5; }
.pj-hint { color: var(--text-faint); font-size: 12.5px; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  flex: none;
}

.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.tb-room {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-divider { width: 1px; height: 16px; background: var(--stroke); }

.tb-timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-dim);
}

.tb-right { display: flex; align-items: center; gap: 8px; }

.chip, .chip-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  backdrop-filter: blur(12px);
}

.chip svg, .chip-btn svg { width: 16px; height: 16px; }

.chip-btn { transition: background 0.15s, color 0.15s; }
.chip-btn:hover { background: var(--surface-2); color: var(--text); }

#main {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 0 14px;
  gap: 14px;
}

/* ============================================================
   STAGE & TILES
   ============================================================ */
#stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
}

#mainArea {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 12px;
  padding: 6px;
}

#filmstrip {
  flex: none;
  height: 116px;
  display: flex;
  gap: 10px;
  padding: 8px 6px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* center the strip without clipping when it overflows */
#filmstrip > :first-child { margin-left: auto; }
#filmstrip > :last-child { margin-right: auto; }

#filmstrip .tile {
  width: 178px !important;
  height: 100px !important;
  flex: none;
}

.tile {
  position: relative;
  border-radius: var(--tile-radius);
  overflow: hidden;
  background: linear-gradient(160deg, #161a26, #10131c);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  animation: tile-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition: box-shadow 0.2s;
}

@keyframes tile-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0c0f16;
}

.tile.fit-contain video { object-fit: contain; }
.tile.mirror video { transform: scaleX(-1); }

.tile.video-off video { visibility: hidden; }

.tile.speaking {
  box-shadow: 0 0 0 3px var(--speak), 0 0 24px rgba(74, 222, 128, 0.35);
}

/* avatar shown when camera is off */
.tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-avatar span {
  width: 30%;
  max-width: 110px;
  min-width: 48px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: clamp(16px, 3.2vw, 34px);
  color: #fff;
  background: var(--avatar-grad, var(--accent-grad));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  user-select: none;
}

.tile .nameplate {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 20px);
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(8, 10, 16, 0.6);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  font-weight: 600;
}

.tile .nameplate .tname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mic-ind { display: inline-flex; }
.mic-ind svg { width: 14px; height: 14px; }
.mic-ind.muted { color: #f87171; }
.mic-ind.live { color: var(--speak); }

.tile .badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
}

.hand-badge {
  display: none;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.92);
  color: #1c1300;
  font-size: 13px;
  animation: hand-bounce 1s ease infinite;
}

.tile.hand .hand-badge { display: block; }

@keyframes hand-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.share-badge {
  display: none;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.92);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.tile.sharing .share-badge { display: block; }

/* connection quality */
.signal {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 5px 6px;
  border-radius: 7px;
  background: rgba(8, 10, 16, 0.55);
  opacity: 0;
  transition: opacity 0.2s;
}

.tile:hover .signal, .signal[data-q="1"], .signal[data-q="0"] { opacity: 1; }

.signal i {
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
}

.signal i:nth-child(1) { height: 5px; }
.signal i:nth-child(2) { height: 8px; }
.signal i:nth-child(3) { height: 11px; }

.signal[data-q="3"] i { background: var(--ok); }
.signal[data-q="2"] i:nth-child(-n+2) { background: var(--warn); }
.signal[data-q="1"] i:nth-child(1) { background: var(--danger); }
.signal[data-q="0"] i { background: rgba(239, 68, 68, 0.5); }

/* tile hover actions */
.tile-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.18s;
}

.tile:hover .tile-actions { opacity: 1; }

.tile-actions button {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(8, 10, 16, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.tile-actions button:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.tile-actions button svg { width: 16px; height: 16px; }
.tile.pinned .tile-actions { opacity: 1; }
.tile.pinned .tile-actions .pin-btn { color: var(--accent); }

/* tile reaction burst */
.tile-react {
  position: absolute;
  left: 50%;
  bottom: 18%;
  font-size: 36px;
  pointer-events: none;
  animation: tile-react 1.6s ease-out forwards;
}

@keyframes tile-react {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1); }
}

/* ---------- empty state ---------- */
#emptyState {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 5;
}

.empty-card {
  background: rgba(13, 16, 26, 0.82);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.empty-card h2 { font-size: 17px; margin-bottom: 6px; }
.empty-card p { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }

.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px 8px 8px 14px;
}

.invite-row span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.mini-btn:hover { background: var(--surface-3); }
.mini-btn svg { width: 16px; height: 16px; }

/* ---------- self PiP ---------- */
#selfPip {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 224px;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #11141d;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--stroke);
  z-index: 20;
  cursor: grab;
  transition: box-shadow 0.2s;
  touch-action: none;
}

#selfPip:active { cursor: grabbing; }
#selfPip.dragging { transition: none; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7), 0 0 0 2px var(--accent); }
#selfPip.snapping { transition: left 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s; }

#selfPip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#selfPip.mirror video { transform: scaleX(-1); }
#selfPip.fit-contain video { object-fit: contain; }
#selfPip.video-off video { visibility: hidden; }

#selfPip .tile-avatar span { font-size: 22px; min-width: 40px; }

.pip-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
}

#selfPip:hover .pip-bar { opacity: 1; }

.pip-name { flex: 1; }

.pip-bar button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.pip-bar button:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.pip-bar button svg { width: 14px; height: 14px; }

.pip-presenting {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(99, 102, 241, 0.92);
  font-size: 10.5px;
  font-weight: 700;
}

#pipChip {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(13, 16, 26, 0.85);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

#pipChip:hover { background: var(--surface-3); }
#pipChip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

/* push-to-talk pill */
#pttPill {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #6ee7b7;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(12px);
  animation: rise 0.2s ease;
}

#pttPill svg { width: 16px; height: 16px; }

/* ---------- floating reactions ---------- */
#reactionOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.float-react {
  position: absolute;
  bottom: -60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: float-up 3.2s cubic-bezier(0.2, 0.6, 0.35, 1) forwards;
}

.float-react .emoji { font-size: 44px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); }

.float-react .who {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(13, 16, 26, 0.8);
  border: 1px solid var(--stroke);
  white-space: nowrap;
}

@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(0.5) rotate(0deg); }
  10% { opacity: 1; transform: translateY(-8vh) scale(1.1) rotate(-4deg); }
  60% { opacity: 1; transform: translateY(-42vh) scale(1) rotate(4deg); }
  100% { opacity: 0; transform: translateY(-70vh) scale(0.92) rotate(-3deg); }
}

/* ============================================================
   CONTROL BAR
   ============================================================ */
#controlbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 22px 18px;
  gap: 12px;
}

.cb-left { justify-self: start; }
.cb-center { display: flex; align-items: center; gap: 12px; justify-self: center; }
.cb-right { display: flex; align-items: center; gap: 10px; justify-self: end; }

.cb-room {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text-faint);
}

.cbtn {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  backdrop-filter: blur(14px);
  transition: background 0.15s, transform 0.12s, border-color 0.15s, color 0.15s;
}

.cbtn:hover { background: var(--surface-3); transform: translateY(-2px); }
.cbtn:active { transform: translateY(0) scale(0.94); }

.cbtn.off {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.cbtn.off:hover { background: #dc2626; }

.cbtn.on-accent {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.5);
}

.cbtn.on-warn {
  background: var(--warn);
  border-color: transparent;
  color: #221a00;
}

.cbtn.leave {
  width: 64px;
  border-radius: 999px;
  background: var(--danger);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.45);
}

.cbtn.leave:hover { background: #dc2626; }

.cbtn.ghost { width: 46px; height: 46px; background: var(--surface); }
.cbtn.ghost:hover { background: var(--surface-2); }
.cbtn.ghost.active { background: var(--accent-grad); border-color: transparent; color: #fff; }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* tooltips */
[data-tip] { position: relative; }

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 11px;
  border-radius: 8px;
  background: #1c2130;
  border: 1px solid var(--stroke);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  animation: tip-in 0.15s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

@keyframes tip-in {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- reaction bar popover ---------- */
#reactionBar {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(18, 22, 34, 0.92);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#reactionBar button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.12s;
}

#reactionBar button:hover { transform: scale(1.25) translateY(-3px); background: var(--surface-2); }

/* ---------- more menu ---------- */
#moreMenu {
  position: fixed;
  bottom: 92px;
  right: 22px;
  z-index: 60;
  min-width: 248px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(18, 22, 34, 0.95);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#moreMenu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
}

#moreMenu button:hover { background: var(--surface-2); }
#moreMenu .mi { display: flex; color: var(--text-dim); }
#moreMenu .mi svg { width: 18px; height: 18px; }
#moreMenu .check { margin-left: auto; color: var(--accent); font-weight: 700; }
.menu-sep { height: 1px; background: var(--stroke); margin: 5px 8px; }

/* ============================================================
   DRAWER (chat / people)
   ============================================================ */
#drawer {
  flex: none;
  width: 348px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 18, 28, 0.85);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  overflow: hidden;
  animation: drawer-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  margin-bottom: 2px;
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 0;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
}

.drawer-tabs button {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.drawer-tabs button.active { background: var(--accent-grad); color: #fff; }

.drawer-tabs #tabPeopleCount {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.8;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* chat */
#chatPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#chatList {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.6;
}

.chat-msg { display: flex; flex-direction: column; max-width: 88%; animation: msg-in 0.2s ease; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.chat-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 10px 2px 3px;
  font-size: 11.5px;
}

.chat-meta .cname { font-weight: 700; color: var(--text-dim); }
.chat-meta .ctime { color: var(--text-faint); }

.chat-bubble {
  padding: 8px 12px;
  border-radius: 4px 14px 14px 14px;
  background: var(--surface-2);
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-msg.mine .chat-bubble {
  background: var(--accent-grad);
  border-radius: 14px 4px 14px 14px;
}

.chat-bubble a { color: #bfdbfe; text-decoration: underline; }

#typingLine {
  padding: 2px 16px 6px;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

.chat-inputrow {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--stroke);
}

.chat-inputrow input { flex: 1; border-radius: 999px; padding: 10px 16px; }

.chat-inputrow button {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, opacity 0.15s;
}

.chat-inputrow button:hover { transform: scale(1.06); }
.chat-inputrow button svg { width: 18px; height: 18px; }

/* people */
#peoplePanel { flex: 1; overflow-y: auto; padding: 12px; }

.person-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  transition: background 0.15s;
}

.person-row:hover { background: var(--surface); }

.person-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--avatar-grad, var(--accent-grad));
}

.person-info { flex: 1; min-width: 0; }

.person-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-name .you-tag { color: var(--text-faint); font-weight: 500; }

.person-sub { font-size: 11.5px; color: var(--text-faint); display: flex; gap: 5px; align-items: center; }

.person-volume {
  width: 100%;
  margin-top: 5px;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 3px;
  background: var(--surface-3);
  padding: 0;
  border: none;
  cursor: pointer;
}

.person-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
}

.person-icons { display: flex; gap: 7px; align-items: center; color: var(--text-faint); }
.person-icons svg { width: 16px; height: 16px; }
.person-icons .p-muted { color: #f87171; }
.person-icons .p-hand { font-size: 15px; animation: hand-bounce 1s ease infinite; }

.person-icons button { color: var(--text-faint); display: flex; padding: 4px; border-radius: 6px; }
.person-icons button:hover { color: var(--text); background: var(--surface-2); }
.person-icons button.active { color: var(--accent); }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 12, 0.6);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(440px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: #141826;
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-head h3 { font-size: 17px; font-weight: 700; }

.modal-body { padding: 8px 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }

.modal-body h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-faint);
  margin-top: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  padding: 7px 2px;
  cursor: pointer;
}

.toggle-row input {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
  border: none;
}

.toggle-row input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}

.toggle-row input:checked { background: var(--accent); }
.toggle-row input:checked::after { left: 19px; }

.shortcuts { gap: 0; }

.shortcuts div {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 2px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--stroke);
}

.shortcuts div:last-child { border-bottom: none; }

.shortcuts kbd {
  min-width: 28px;
  text-align: center;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-bottom-width: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* ============================================================
   LEAVE SCREEN
   ============================================================ */
#leaveScreen {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.leave-card {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 44px 56px;
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.leave-card h2 { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.leave-card p { color: var(--text-dim); font-size: 14px; margin-bottom: 26px; }
.leave-actions { display: flex; gap: 12px; justify-content: center; }
.leave-actions .join-btn { margin-top: 0; }

/* ============================================================
   TOASTS
   ============================================================ */
#toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 17px;
  border-radius: 13px;
  background: rgba(18, 22, 34, 0.94);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 320px;
}

.toast.leaving { animation: toast-out 0.25s ease forwards; }

.toast .t-emoji { font-size: 17px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(28px); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
  .pj-card { flex-direction: column; gap: 22px; padding: 22px; }
  .pj-left, .pj-right { width: 100%; }
  .pj-right { min-width: 0; }

  #drawer {
    position: fixed;
    inset: 0;
    width: 100%;
    border-radius: 0;
    z-index: 70;
    margin: 0;
  }

  #main { padding: 0 8px; }
  #controlbar { padding: 10px 10px 14px; grid-template-columns: 0 1fr 0; }
  .cb-left, .cb-right .cb-room { display: none; }
  .cb-center { gap: 8px; flex-wrap: wrap; justify-content: center; }
  .cb-right { position: fixed; right: 10px; bottom: 84px; flex-direction: column; }
  .cbtn { width: 46px; height: 46px; }
  .cbtn.leave { width: 56px; }
  #selfPip { width: 130px; }
  .tb-right .chip-btn span { display: none; }
  #moreMenu { right: 10px; }
  [data-tip]:hover::after { display: none; }
}
