:root {
  --bg: #1b1e35;
  --bg-2: #232745;
  --panel: #282c4c;
  --panel-2: #333862;
  --panel-3: #3d4372;
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #eef0ff;
  --muted: #a5aad0;
  --faint: #6f74a0;
  --accent: #6c72ff;
  --accent-2: #8b90ff;
  --accent-soft: rgba(108, 114, 255, 0.18);
  --green: #3ddc84;
  --red: #ff5d5d;
  --red-soft: rgba(255, 93, 93, 0.16);
  --gold: #ffd166;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  font: 600 11px/1.5 var(--font);
  text-align: center;
}
.ic { flex: none; display: block; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-2);
  font-weight: 600;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--border-2); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: rgba(255, 93, 93, 0.4); }
.btn.danger.ghost:hover { background: var(--red-soft); }
.btn.big { height: 48px; font-size: 15px; border-radius: 12px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .people-search input, .composer input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .people-search input:focus, .composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.shake { animation: shake 0.35s; border-color: var(--red) !important; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* ---------------------------------------------------------------- lobby */
#lobby, .left-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(108, 114, 255, 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(61, 220, 132, 0.18), transparent 60%),
    var(--bg);
}
.lobby-card {
  width: min(1000px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.lobby-card.small { width: min(420px, 100%); text-align: center; display: grid; gap: 10px; justify-items: center; }
.lobby-card.small h1 { margin: 8px 0 0; font-size: 24px; }
.lobby-card.small p { margin: 0 0 12px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.brand-mark {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #9b6cff);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.92), 0 6px 18px rgba(108, 114, 255, 0.45);
}
.brand-mark.big { width: 64px; height: 64px; border-radius: 18px; box-shadow: inset 0 0 0 15px rgba(255, 255, 255, 0.92); }

.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 28px; }
.preview {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3a3f6b, #1a1d33);
  margin-bottom: 12px;
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.preview img {
  position: absolute; left: 50%; top: 44%;
  width: 34%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.preview-meter {
  position: absolute; left: 16px; right: 16px; top: 14px;
  height: 4px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.preview-meter span {
  display: block; height: 100%;
  background: var(--green);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.08s linear;
}
.preview-buttons { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.round-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  background: rgba(30, 33, 60, 0.85);
  backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.round-btn:hover { background: rgba(60, 65, 110, 0.95); }
.round-btn.off { background: var(--red); }
.media-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: #ffc2c2;
  font-size: 13px;
}
.lobby-profile { display: flex; flex-direction: column; }
.lobby-profile #join-btn { margin-top: auto; width: 100%; }

/* ---------------------------------------------------------------- avatar editor */
.avatar-editor { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.avatar-preview {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 35%, #41477c, #262a4a);
  border: 1px solid var(--border);
}
.avatar-preview canvas { image-rendering: pixelated; }
.avatar-rows { display: grid; gap: 10px; align-content: start; }
.avatar-row-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.avatar-options { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 2px solid transparent; padding: 0; transition: transform 0.1s, border-color 0.1s; }
.opt:hover { transform: translateY(-1px); }
.opt.color { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
.opt.thumb { width: 44px; height: 44px; border-radius: 10px; background: var(--bg-2); display: grid; place-items: center; overflow: hidden; }
.opt.thumb canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.opt.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* ---------------------------------------------------------------- office */
#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; display: block; cursor: pointer; touch-action: none; }

#area-badge {
  position: absolute; top: 14px; left: 14px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 8px;
  max-width: min(320px, calc(100% - 28px));
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(30, 33, 60, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
#area-badge small { grid-column: 1 / -1; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
#area-badge.private { border-color: rgba(255, 209, 102, 0.45); }
#area-badge.private .ic { color: var(--gold); }

#video-strip {
  position: absolute; top: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
  max-width: calc(100% - 700px);
  min-width: 190px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
  justify-content: safe center;
}
.vtile {
  --tile-bg: #3a3f6b;
  position: relative; flex: none;
  width: 184px; aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--tile-bg) 45%, #2a2e52), #191c33);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 2px transparent;
  cursor: default;
  transition: box-shadow 0.15s, opacity 0.3s;
}
.vtile.has-video { cursor: zoom-in; }
.vtile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.vtile.has-video video { opacity: 1; }
.vtile.mirror video { transform: scaleX(-1); }
.vtile.screen { width: 230px; background: #0f1122; }
.vtile.screen video { object-fit: contain; }
.vt-avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.vtile.has-video .vt-avatar { display: none; }
.vt-avatar img { width: 58px; height: 58px; image-rendering: pixelated; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.vt-label {
  position: absolute; left: 6px; bottom: 6px; right: 6px;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  pointer-events: none;
}
.vt-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 8px; border-radius: 8px;
  background: rgba(10, 12, 28, 0.7);
}
.vt-mic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--red); flex: none; }
.vtile.screen .vt-mic { background: var(--accent); }
.vt-expand {
  position: absolute; top: 6px; right: 6px;
  display: grid; place-items: center;
  width: 26px; height: 26px; border: 0; border-radius: 8px;
  background: rgba(10, 12, 28, 0.6);
  opacity: 0; transition: opacity 0.15s;
}
.vtile.has-video:hover .vt-expand { opacity: 1; }
.vtile:not(.has-video) .vt-expand { display: none; }
.vtile::before {
  content: '';
  position: absolute; inset: 0; z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--green);
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.vtile.speaking::before { opacity: 1; }
.vtile.far { opacity: 0.55; }
.vtile.connecting::after {
  content: 'Connecting…';
  position: absolute; top: 8px; left: 8px;
  font-size: 11px; color: var(--muted);
  padding: 2px 8px; border-radius: 8px;
  background: rgba(10, 12, 28, 0.6);
}

#hint {
  position: absolute; left: 50%; bottom: 92px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 12px;
  background: rgba(30, 33, 60, 0.92);
  border: 1px solid rgba(255, 209, 102, 0.4);
  box-shadow: var(--shadow);
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  animation: rise 0.18s ease-out;
}
#hint kbd { background: var(--gold); color: #2a2140; border-color: #e0b54d; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

#minimap {
  position: absolute; left: 14px; bottom: 14px;
  width: 180px; height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  cursor: crosshair;
  background: #222;
}
#zoom-controls {
  position: absolute; left: 14px; bottom: 144px;
  display: grid;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
}
#zoom-controls button {
  width: 34px; height: 32px; border: 0;
  background: rgba(30, 33, 60, 0.92);
  font-size: 18px; font-weight: 600;
}
#zoom-controls button + button { border-top: 1px solid var(--border); }
#zoom-controls button:hover { background: var(--panel-3); }

/* ---------------------------------------------------------------- toolbar */
#toolbar {
  position: absolute; left: 50%; bottom: 14px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 7px;
  border-radius: 18px;
  background: rgba(38, 42, 74, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-width: calc(100% - 16px);
  transition: left 0.2s;
}
body.sidebar-open #toolbar, body.sidebar-open #hint { left: calc((100% - 360px) / 2); }
body.sidebar-open #video-strip { left: calc((100% - 360px) / 2); max-width: calc(100% - 360px - 400px); }
.tb-sep { width: 1px; height: 28px; background: var(--border-2); margin: 0 2px; }
.tb-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 10px;
  border: 0; border-radius: 12px;
  background: var(--panel-2);
  transition: background 0.15s, color 0.15s;
}
.tb-btn:hover { background: var(--panel-3); }
.tb-btn.off { background: var(--red-soft); color: var(--red); }
.tb-btn.off:hover { background: rgba(255, 93, 93, 0.26); }
.tb-btn.active { background: var(--accent); color: #fff; }
.tb-btn.danger:hover { background: var(--red); color: #fff; }
.tb-btn.emoji { font-size: 19px; }
.tb-btn.wide { padding: 0 14px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tb-btn.wide:not(.has-desk) { color: var(--muted); }
.tb-btn .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px;
}
.tb-btn .count { font-size: 12px; font-weight: 700; }
.me-chip {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 10px 0 4px;
  border: 0; border-radius: 12px;
  background: transparent;
  text-align: left;
}
.me-chip:hover { background: rgba(255, 255, 255, 0.06); }
.me-portrait-wrap { position: relative; width: 36px; height: 36px; flex: none; }
.me-portrait { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-3); image-rendering: pixelated; }
.status-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--panel);
}
.me-text { display: grid; line-height: 1.2; max-width: 120px; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- popovers */
.popover {
  position: fixed; z-index: 50;
  min-width: 200px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  animation: pop 0.12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }
.menu { display: grid; gap: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px;
  background: transparent; text-align: left;
}
.menu-item span { flex: 1; }
.menu-item:hover { background: rgba(255, 255, 255, 0.07); }
.menu-item .dot { margin: 0; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-note { margin: 2px 10px 6px; font-size: 12px; color: var(--muted); max-width: 220px; }
.emote-grid { display: grid; grid-template-columns: repeat(6, 44px); gap: 4px; min-width: 0; }
.emote {
  position: relative;
  height: 48px; border: 0; border-radius: 10px;
  background: transparent; font-size: 24px;
}
.emote:hover { background: rgba(255, 255, 255, 0.08); transform: scale(1.08); }
.emote kbd { position: absolute; right: 2px; bottom: 2px; min-width: 0; padding: 0 3px; font-size: 9px; }
.player-card { padding: 8px; width: 250px; }
.pc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.pc-head b { font-size: 15px; }
.pc-head .sub { color: var(--muted); font-size: 12px; }
.pc-actions { display: flex; gap: 8px; }
.pc-actions .btn { flex: 1; }

.pf { width: 40px; height: 40px; border-radius: 10px; background: var(--panel-3); image-rendering: pixelated; flex: none; }
.pf.initials { display: grid; place-items: center; font-weight: 700; color: var(--muted); }

/* ---------------------------------------------------------------- sidebar */
#sidebar {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 360px; max-width: 100%;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
  z-index: 10;
  animation: slide 0.18s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.sb-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.sb-tabs { flex: 1; display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--bg-2); }
.sb-tabs button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 600;
}
.sb-tabs button.active { background: var(--panel-3); color: var(--text); }
.sb-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.threads { display: flex; gap: 6px; padding: 10px 12px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.thread {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 30px; padding: 0 12px;
  border-radius: 15px; border: 1px solid var(--border-2);
  background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
}
.thread:hover { color: var(--text); }
.thread.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.thread .unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; }
.messages { flex: 1; overflow-y: auto; padding: 12px 14px; }
.msg { display: flex; gap: 10px; margin-top: 12px; }
.msg.compact { margin-top: 2px; padding-left: 46px; }
.msg .pf { width: 36px; height: 36px; }
.msg .body { min-width: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .meta span { color: var(--faint); font-size: 11px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { margin: 30px 12px; text-align: center; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 12px 12px 4px; border-top: 1px solid var(--border); }
.composer .send {
  flex: none; width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
}
.composer-note { min-height: 22px; padding: 2px 14px 10px; font-size: 12px; color: var(--faint); }
.people-search { padding: 12px; border-bottom: 1px solid var(--border); }
.people-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.people-section { padding: 12px 8px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.person { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.person:hover { background: rgba(255, 255, 255, 0.04); }
.person .pf-wrap { position: relative; }
.person .status-dot { border-color: var(--panel); }
.person .info { flex: 1; min-width: 0; }
.person .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .you { font-size: 11px; color: var(--muted); font-weight: 500; }
.person .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .actions { display: flex; opacity: 0.6; transition: opacity 0.15s; }
.person:hover .actions { opacity: 1; }
.person.offline .name { color: var(--muted); }

/* ---------------------------------------------------------------- stage */
/* Leaves the toolbar visible (and the sidebar, if open) so you can mute/chat while watching. */
#stage {
  position: absolute; top: 0; left: 0; right: 0; bottom: 78px; z-index: 20;
  background: rgba(8, 10, 22, 0.94);
}
body.sidebar-open #stage { right: 360px; }
#stage.is-fullscreen { bottom: 0; right: 0; background: #000; }
body.stage-open #hint, body.stage-open #video-strip { display: none; }
/* Absolute sizing on purpose: the video must never size its container (that made big shares overflow). */
.stage-viewport {
  position: absolute; top: 12px; left: 12px; right: 12px; bottom: 58px;
  overflow: hidden;
  border-radius: 14px;
  background: #05060d;
  touch-action: none;
  user-select: none;
}
#stage.is-fullscreen .stage-viewport { inset: 0 0 52px; border-radius: 0; }
.stage-viewport.can-pan { cursor: grab; }
.stage-viewport.dragging { cursor: grabbing; }
#stage-video {
  position: absolute;
  max-width: none;
  transform-origin: center center;
  will-change: transform;
  background: #000;
}
.stage-bar {
  position: absolute; left: 12px; right: 12px; bottom: 8px; height: 42px;
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.stage-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-stats { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-controls {
  margin-left: auto; flex: none;
  display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
}
.stage-controls button {
  display: inline-grid; place-items: center;
  height: 32px; min-width: 32px; padding: 0 8px;
  border: 0; border-radius: 8px;
  background: transparent; font-weight: 600; font-size: 14px;
}
.stage-controls button:hover { background: rgba(255, 255, 255, 0.08); }
.stage-zoom { min-width: 76px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .stage-stats, .stage-zoom { display: none; } }

/* screen-share menu */
.screen-menu { width: 300px; padding: 8px; display: grid; gap: 10px; }
.sm-title { font-weight: 700; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 10px; border-radius: 10px; background: var(--bg-2); }
.switch-row span { flex: 1; display: grid; gap: 3px; }
.switch-row small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.sm-note { margin: 0; font-size: 12px; color: var(--faint); }
.sm-main { width: 100%; }
.switch {
  appearance: none; flex: none;
  width: 40px; height: 22px; margin-top: 2px;
  border-radius: 11px; background: var(--panel-3);
  position: relative; cursor: pointer; transition: background 0.15s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.15s;
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(18px); }
.tb-btn.active.motion::after {
  content: '60'; position: absolute; right: -4px; top: -4px;
  padding: 0 4px; border-radius: 6px; background: var(--green); color: #0d2b1a;
  font-size: 9px; font-weight: 800; line-height: 14px;
}

/* ---------------------------------------------------------------- modals */
#modal-root { position: relative; z-index: 40; }
.modal-backdrop {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(8, 10, 22, 0.6);
  backdrop-filter: blur(2px);
  animation: fade 0.15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  animation: pop 0.15s ease-out;
}
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 22px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 10px 22px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
.modal-foot:empty { display: none; }
.desk-hero { display: flex; gap: 14px; align-items: center; padding: 14px; margin-bottom: 14px; border-radius: 14px; background: var(--bg-2); }
.desk-hero p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.desk-hero .pf { width: 52px; height: 52px; }
.desk-hero.available { border: 1px solid rgba(61, 220, 132, 0.35); }
.desk-hero.mine { border: 1px solid rgba(255, 209, 102, 0.45); }
.desk-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(61, 220, 132, 0.15); color: var(--green); }
.desk-note { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--gold); border-radius: 6px; background: rgba(255, 209, 102, 0.08); font-style: italic; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 26px; }
.settings-side h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.settings-side h3:not(:first-child) { margin-top: 18px; }
.shortcuts { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- toasts */
#toasts {
  position: fixed; top: 76px; left: 14px; z-index: 60;
  display: grid; gap: 8px; justify-items: start;
  pointer-events: none;
}
.toast {
  max-width: min(360px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(30, 33, 60, 0.95);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.clickable { pointer-events: auto; cursor: pointer; }
.toast.clickable:hover { border-color: var(--accent); }
.toast.out { opacity: 0; transform: translateX(-10px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-10px); } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  /* Not enough room beside the sidebar: keep the toolbar centred and end the sidebar above it. */
  body.sidebar-open #toolbar { left: 50%; z-index: 11; }
  #sidebar { bottom: 76px; border-bottom: 1px solid var(--border); border-bottom-left-radius: 16px; }
}
@media (max-width: 1100px) {
  #video-strip { top: 64px; max-width: calc(100% - 28px); }
  body.sidebar-open #video-strip { max-width: calc(100% - 360px - 28px); }
  .vtile { width: 150px; }
  .vtile.screen { width: 190px; }
  #toasts { top: 150px; }
}
@media (max-width: 820px) {
  .lobby-grid, .settings-grid { grid-template-columns: 1fr; }
  .lobby-card { padding: 20px; }
  .tb-btn.wide span, .me-text { display: none; }
  body.sidebar-open #toolbar, body.sidebar-open #hint, body.sidebar-open #video-strip { left: 50%; }
  #sidebar { width: 100%; }
}
@media (max-width: 640px) {
  #minimap, #zoom-controls { display: none; }
  #toolbar { gap: 3px; padding: 5px; bottom: 8px; }
  .tb-btn { min-width: 38px; height: 38px; padding: 0 6px; }
  .tb-sep, #tb-hand { display: none; }
  .avatar-editor { grid-template-columns: 1fr; }
  .vtile { width: 120px; }
  #hint { bottom: 70px; }
}

/* ---------------------------------------------------------------- auth pages */
.small { font-size: 12px; }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 0.92em; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); }
.auth-screen {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(108, 114, 255, 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(61, 220, 132, 0.18), transparent 60%),
    var(--bg);
}
.auth-card { width: min(440px, 100%); }
.auth-card form .btn { width: 100%; margin-top: 4px; }
.auth-card p { margin: 0 0 14px; }
.auth-notice { padding: 10px 12px; border-radius: 10px; background: rgba(255, 209, 102, 0.12); border: 1px solid rgba(255, 209, 102, 0.35); color: #ffe3a3; font-size: 13px; }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: #ffc2c2; font-size: 13px; }
.pw-change { margin: 0 0 6px; }
.pw-change summary { cursor: pointer; color: var(--accent-2); font-weight: 600; margin-bottom: 10px; }

/* ---------------------------------------------------------------- admin */
.admin-body { min-height: 100%; background: radial-gradient(1200px 500px at 0% -20%, rgba(108, 114, 255, 0.25), transparent 60%), var(--bg); }
.admin-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto; padding: 24px 16px 8px;
}
.admin-top .brand { margin: 0; }
.admin-top-actions { display: flex; gap: 8px; }
.admin-top-actions a { text-decoration: none; color: var(--text); }
.admin-main { max-width: 1180px; margin: 0 auto; padding: 12px 16px 48px; display: grid; gap: 18px; }
.admin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.admin-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-card-head h2 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.admin-card-head p { margin: 0; }
.count-pill { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--panel-3); color: var(--muted); }
.admin-search { width: min(260px, 100%); height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); outline: none; }
.admin-search:focus { border-color: var(--accent); }
.add-user { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.add-user .field { margin: 0; }
.add-user > .btn { height: 40px; }
.pw-row { display: flex; gap: 6px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-row .btn { height: 40px; }
#add-error { margin: 12px 0 0; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr.is-disabled td:not(:last-child) { opacity: 0.55; }
.member-cell { display: flex; align-items: center; gap: 10px; }
.member-cell .pf { width: 36px; height: 36px; }
.member-cell .you { font-size: 11px; color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { margin-left: 4px; }
.empty-row { text-align: center; padding: 24px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--panel-3); color: var(--muted); }
.tag-admin { background: var(--accent-soft); color: var(--accent-2); }
.tag-on { background: rgba(61, 220, 132, 0.15); color: var(--green); }
.tag-off { background: var(--red-soft); color: var(--red); }
.credentials { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--bg-2); margin-bottom: 4px; }
.credentials div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.credentials span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.credentials code { font-size: 15px; user-select: all; }
@media (max-width: 900px) {
  .add-user { grid-template-columns: 1fr 1fr; }
  .add-user > .btn { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .add-user { grid-template-columns: 1fr; } }
