:root {
  --bg-base: #06080e; --bg-surface: #0f131d; --bg-elevated: #171c2b; --bg-hover: #1f263a;
  --border: #242c40; --border-strong: #35405e; --text-primary: #f8fafc; --text-secondary: #cbd5e1;
  --text-muted: #94a3b8; --danger: #f43f5e; --danger-soft: rgba(244, 63, 94, 0.16);
  --success: #10b981; --accent: #818cf8; --topbar-bg: rgba(15, 19, 29, 0.65);
  --tile-bg: rgba(15, 19, 29, 0.88); --dock-bg: #141927;
}
body.solar-theme {
  --bg-base: #181c26; --bg-surface: #222836; --bg-elevated: #2c3446; --bg-hover: #364057;
  --border: #3d4861; --border-strong: #526080; --text-primary: #ffffff; --text-secondary: #e2e8f0;
  --text-muted: #cbd5e1; --accent: #f59e0b; --topbar-bg: rgba(34, 40, 54, 0.75);
  --tile-bg: rgba(34, 40, 54, 0.9); --dock-bg: #222836;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
body { background: var(--bg-base); color: var(--text-primary); height: 100vh; display: flex; overflow: hidden; user-select: none; transition: background 0.3s ease, color 0.3s ease; }

.auth-overlay, .profile-overlay { position: fixed; inset: 0; background: rgba(4, 6, 11, 0.88); backdrop-filter: blur(14px); z-index: 1000; display: flex; align-items: center; justify-content: center; transition: opacity 0.25s ease; overflow: hidden; }
.auth-overlay.hidden, .profile-overlay.hidden { opacity: 0; pointer-events: none; }
#auth-stars-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

.auth-card, .profile-card { position: relative; z-index: 2; background: rgba(15, 19, 29, 0.94); backdrop-filter: blur(20px); border: 1px solid rgba(129, 140, 248, 0.28); border-radius: 18px; padding: 26px 28px; width: 420px; display: flex; flex-direction: column; gap: 11px; box-shadow: 0 24px 60px rgba(0,0,0,0.85); text-align: center; max-height: 94vh; overflow-y: auto; }
.auth-logo { width: 48px; height: 48px; background: linear-gradient(135deg, #818cf8, #c084fc); color: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; margin: 0 auto; box-shadow: 0 0 25px rgba(129, 140, 248, 0.4); }
.auth-title { font-size: 19px; font-weight: 600; color: #f8fafc; letter-spacing: -0.3px; }
.auth-subtitle { font-size: 13px; color: #94a3b8; margin-top: 4px; display: none; }
.field-group { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.auth-input { background: rgba(6, 8, 14, 0.85); border: 1px solid #242c40; border-radius: 8px; padding: 10px 13px; color: #f8fafc; font-size: 13.5px; outline: none; transition: border-color 0.15s; width: 100%; }
.auth-input:focus { border-color: #818cf8; }
.auth-input.input-error { border-color: var(--danger); }
.auth-error-msg { color: #fb7185; font-size: 11.5px; font-weight: 500; padding-left: 4px; display: none; }
.auth-error-msg.visible { display: block; }
.auth-roles { display: flex; gap: 8px; }
.auth-role-btn { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid #242c40; background: rgba(6, 8, 14, 0.7); color: #94a3b8; font-size: 12px; font-weight: 500; cursor: pointer; transition: 0.15s; }
.auth-role-btn.active { background: #171c2b; color: #f8fafc; border-color: #818cf8; font-weight: 600; }

.sticker-picker-section { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.sticker-picker-label { font-size: 11.5px; color: #94a3b8; font-weight: 500; padding-left: 2px; }
.sticker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: rgba(6, 8, 14, 0.65); padding: 8px; border-radius: 10px; border: 1px solid #242c40; }
.sticker-item { aspect-ratio: 1; border-radius: 8px; border: 1.5px solid transparent; background: rgba(23, 28, 43, 0.7); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 3px; transition: 0.15s; font-size: 11px; font-weight: 700; color: #cbd5e1; overflow: hidden; }
.sticker-item:hover { background: var(--bg-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.sticker-item.selected { border-color: var(--accent); background: rgba(129, 140, 248, 0.2); box-shadow: 0 0 12px rgba(129, 140, 248, 0.35); }
.sticker-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; border-radius: 50%; }

.modal-stealth-row { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 2px; user-select: none; }
.custom-circle-check { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; border: 1.5px solid #3b4660; border-radius: 50%; background: rgba(6, 8, 14, 0.85); cursor: pointer; outline: none; transition: all 0.18s ease; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.custom-circle-check:checked { background: #818cf8; border-color: #818cf8; box-shadow: 0 0 12px rgba(129, 140, 248, 0.5); }
.custom-circle-check:checked::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ffffff; }
.modal-stealth-label { font-size: 12.5px; color: #cbd5e1; font-weight: 500; }
.auth-btn { background: #f8fafc; color: #06080e; border: none; border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.15s; margin-top: 2px; }
.auth-btn:hover { opacity: 0.9; }

.profile-header { display: flex; align-items: center; justify-content: space-between; }
.profile-title { font-size: 16px; font-weight: 600; color: #f8fafc; }
.profile-close-btn { background: transparent; border: none; color: #94a3b8; font-size: 16px; cursor: pointer; padding: 4px; }
.profile-close-btn:hover { color: #fff; }
.profile-section { display: flex; flex-direction: column; gap: 10px; align-items: center; width: 100%; }
.profile-avatar-wrap { width: 108px; height: 108px; border-radius: 50%; overflow: hidden; border: 2.5px solid var(--accent); box-shadow: 0 0 20px rgba(129, 140, 248, 0.25); }
.profile-avatar-wrap canvas { width: 100%; height: 100%; display: block; }
.profile-avatar-btns { display: flex; gap: 8px; }
.btn-secondary-sm { background: var(--bg-elevated); border: 1px solid var(--border-strong); color: var(--text-primary); padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer; transition: 0.15s; }
.btn-secondary-sm:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-danger-sm { background: var(--danger-soft); border: 1px solid rgba(244,63,94,0.4); color: #fda4af; padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer; }
.profile-divider { width: 100%; height: 1px; background: var(--border); margin: 2px 0; }
.profile-sec-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.profile-sec-label { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }
.pwd-drawer { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 4px; }

.cropper-box { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; background: rgba(6, 8, 14, 0.7); padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.cropper-Hint { font-size: 11.5px; color: var(--text-muted); }
.cropper-stage-wrap { width: 220px; height: 220px; border-radius: 10px; overflow: hidden; position: relative; cursor: grab; border: 1px solid var(--border-strong); }
.cropper-stage-wrap:active { cursor: grabbing; }
.cropper-stage-wrap canvas { width: 100%; height: 100%; display: block; }
.cropper-zoom-row { display: flex; align-items: center; gap: 8px; width: 85%; color: var(--text-muted); font-size: 14px; }
.cropper-zoom-row input { flex: 1; accent-color: var(--accent); cursor: pointer; }
.cropper-actions { display: flex; gap: 8px; justify-content: flex-end; width: 100%; margin-top: 2px; }
.btn-save-crop { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }

.sidebar { width: 284px; background: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px; gap: 16px; flex-shrink: 0; z-index: 20; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
.ws-identity { display: flex; align-items: center; gap: 9px; }
.theme-toggle-btn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: 0.15s; }
.theme-toggle-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.ws-mark { width: 26px; height: 26px; background: linear-gradient(135deg, var(--accent), #c084fc); color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; }
.ws-name { font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.2px; }

.nav-group-header { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; margin-bottom: -2px; }
.nav-label { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.btn-icon-mini { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); width: 22px; height: 22px; border-radius: 5px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; }
.btn-icon-mini:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.nav-group { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 290px); overflow-y: auto; position: relative; }
.room-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; transition: background 0.12s, border-color 0.12s; position: relative; }
.room-item:hover { background: var(--bg-elevated); }
.room-item.active { background: var(--bg-elevated); border-color: var(--border-strong); }
.room-item-left { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; pointer-events: none; }
.room-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.room-item.active .room-indicator { background: var(--accent); }
.room-name-text { font-size: 13px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.room-item.active .room-name-text { color: var(--text-primary); }

.room-actions { display: flex; align-items: center; gap: 6px; }
.room-hand-badge { background: rgba(245, 158, 11, 0.2); border: 1px solid rgba(245, 158, 11, 0.5); color: #fcd34d; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; display: flex; align-items: center; gap: 3px; animation: pulseHand 1.5s infinite; cursor: pointer; }
.room-hand-badge:hover { background: var(--danger-soft); border-color: var(--danger); color: #fda4af; }
@keyframes pulseHand { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.btn-delete-room { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 4px; opacity: 0; transition: opacity 0.12s; }
.room-item:hover .btn-delete-room { opacity: 1; }
.btn-delete-room:hover { color: var(--danger); background: var(--danger-soft); }

.delete-popover { position: fixed; z-index: 9999; background: #141928; border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 14px 34px rgba(0,0,0,0.85); width: 200px; }
.delete-popover-text { font-size: 12px; color: var(--text-primary); font-weight: 500; text-align: left; }
.delete-popover-btns { display: flex; gap: 6px; justify-content: flex-end; }
.btn-pop-del { background: var(--danger); color: #fff; border: none; border-radius: 6px; padding: 5px 10px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.btn-pop-cancel { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 11.5px; cursor: pointer; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.btn-profile-open { width: 100%; padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-primary); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; cursor: pointer; transition: 0.15s; }
.btn-profile-open:hover { background: var(--bg-hover); border-color: var(--accent); }

.stealth-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px; cursor: pointer; }
.stealth-label { font-size: 12.5px; color: var(--text-secondary); }
.toggle { position: relative; width: 32px; height: 18px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: var(--bg-hover); border: 1px solid var(--border-strong); border-radius: 99px; transition: 0.15s; }
.toggle-track::before { content: ""; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; background: var(--text-secondary); border-radius: 50%; transition: 0.15s; }
.toggle input:checked + .toggle-track { background: var(--text-primary); border-color: var(--text-primary); }
.toggle input:checked + .toggle-track::before { transform: translateX(14px); background: var(--bg-base); }

.main { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--bg-base); overflow: hidden; }
.topbar { height: 52px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; z-index: 10; background: var(--topbar-bg); backdrop-filter: blur(10px); }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.room-heading { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.room-edit-input { background: var(--bg-elevated); border: 1px solid var(--border-strong); color: var(--text-primary); font-size: 14px; font-weight: 600; padding: 3px 8px; border-radius: 6px; outline: none; width: 220px; }
.btn-edit-room { background: transparent; border: 1px solid var(--border); color: var(--text-muted); width: 26px; height: 26px; border-radius: 6px; display: none; align-items: center; justify-content: center; cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.code-pill { background: rgba(129, 140, 248, 0.14); border: 1px solid rgba(129, 140, 248, 0.3); color: var(--text-secondary); padding: 4px 10px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.code-pill strong { color: var(--accent); }
.btn-invite { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--text-secondary); padding: 5px 11px; border-radius: 6px; font-size: 11px; font-weight: 500; cursor: pointer; }
.room-occupancy-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: rgba(129, 140, 248, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.28);
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.ctrl-occupancy {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(129, 140, 248, 0.16);
  border: 1px solid rgba(129, 140, 248, 0.32);
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
body.solar-theme .room-occupancy-text,
body.solar-theme .ctrl-occupancy {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.35);
}

.stage { flex: 1; padding: 12px 20px 84px 20px; display: flex; gap: 16px; overflow: hidden; position: relative; }
#stage-stars-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.celestial-light-beam { position: absolute; top: -150px; right: -150px; width: 850px; height: 850px; background: radial-gradient(circle at center, rgba(200, 220, 255, 0.14) 0%, rgba(120, 145, 215, 0.04) 42%, transparent 70%); pointer-events: none; z-index: 1; }
body.solar-theme .celestial-light-beam { background: radial-gradient(circle at center, rgba(255, 190, 40, 0.26) 0%, rgba(245, 130, 10, 0.09) 45%, transparent 72%); }
.celestial-wrap { position: absolute; top: -90px; right: -90px; width: 390px; height: 390px; pointer-events: none; z-index: 2; display: flex; align-items: center; justify-content: center; }
@keyframes spinCelestial { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#celestial-canvas { width: 100%; height: 100%; display: block; animation: none; transform-origin: 50% 50%; }
body.solar-theme #celestial-canvas { animation: spinCelestial 220s linear infinite; }

.screen-pane { flex: 3; background: #080b12; border: 1px solid var(--border-strong); border-radius: 12px; position: relative; display: none; overflow: hidden; z-index: 10; align-items: center; justify-content: center; box-shadow: 0 16px 40px rgba(0,0,0,0.7); }
.screen-pane.active { display: flex; }
.screen-pane video { width: 100%; height: 100%; object-fit: contain; }
.pane-header-bar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 15; }
.pane-tag { background: rgba(15, 19, 29, 0.9); border: 1px solid var(--border-strong); padding: 5px 11px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: #f8fafc; pointer-events: auto; }
.btn-close-stream { background: rgba(15, 19, 29, 0.9); border: 1px solid var(--border-strong); color: #cbd5e1; padding: 5px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 500; cursor: pointer; pointer-events: auto; }
.btn-kill-stream { background: rgba(244, 63, 94, 0.22); border: 1px solid rgba(244, 63, 94, 0.55); color: #fda4af; padding: 5px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.btn-kill-stream:hover { background: var(--danger); color: #fff; }

.space-arena { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; width: 100%; height: 100%; z-index: 3; }
.space-arena.compact { flex: 0 0 310px; display: flex; flex-direction: column; overflow-y: auto; align-content: flex-start; justify-content: flex-start; }
.ufo-orbit { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 290px)); gap: 14px; padding: 14px; align-content: center; justify-content: center; pointer-events: none; z-index: 3; overflow-y: auto; }
.space-arena.compact .ufo-orbit { grid-template-columns: 1fr; align-content: flex-start; padding: 4px; }

.tile { background: var(--tile-bg); backdrop-filter: blur(12px); border: 1.5px solid var(--border-strong); border-radius: 14px; width: 100%; aspect-ratio: 16 / 9; max-height: 165px; position: relative; overflow: hidden; pointer-events: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.45); transition: border-color 0.15s ease, box-shadow 0.15s ease; margin: auto; }
.tile.speaking { border-color: var(--accent); box-shadow: 0 0 22px rgba(129, 140, 248, 0.35); }
.tile.hand-raised { border-color: #f59e0b; box-shadow: 0 0 20px rgba(245, 158, 11, 0.35); }
.tile canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-video-cam { width: 100%; height: 100%; position: absolute; inset: 0; z-index: 1; display: none; background: #080b12; align-items: center; justify-content: center; }
.tile-video-cam video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.has-camera .tile-video-cam { display: flex; }
.tile.has-camera canvas { display: none; }

.tile-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 4; gap: 6px; }
.tile-top-left { display: flex; align-items: center; gap: 6px; }
.mono-pill { background: rgba(11, 13, 20, 0.85); border: 1px solid rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #cbd5e1; }
.hand-pill { background: rgba(245, 158, 11, 0.22); border: 1px solid rgba(245, 158, 11, 0.55); color: #fde68a; padding: 2px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; animation: pulseHand 1.5s infinite; pointer-events: auto; cursor: pointer; }
.live-stream-pill { background: rgba(16, 185, 129, 0.18); border: 1px solid rgba(52, 211, 153, 0.42); color: #6ee7b7; padding: 2px 8px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; cursor: pointer; pointer-events: auto; }

.tile-bottom { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; align-items: center; justify-content: space-between; z-index: 4; gap: 6px; }
.participant-name { background: rgba(11, 13, 20, 0.88); border: 1px solid rgba(255,255,255,0.08); padding: 3px 7px; border-radius: 5px; font-size: 11px; font-weight: 500; color: #f8fafc; display: flex; align-items: center; gap: 6px; min-width: 0; }
.participant-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mic-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mic-dot.live { background: var(--success); }
.mic-dot.muted { background: var(--danger); }
.muted-icon-badge { color: var(--danger); font-size: 11px; display: flex; align-items: center; flex-shrink: 0; }

.tile-controls { display: flex; align-items: center; gap: 5px; opacity: 0; transition: opacity 0.15s; background: rgba(11, 13, 20, 0.92); padding: 3px 6px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); }
.tile:hover .tile-controls { opacity: 1; }
.vol-wrap { display: flex; align-items: center; gap: 4px; }
.vol-slider { width: 58px; height: 4px; accent-color: var(--accent); cursor: pointer; }
.vol-label { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: #cbd5e1; min-width: 28px; text-align: right; }
.icon-action { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255,255,255,0.12); color: #f8fafc; padding: 2px 6px; border-radius: 4px; font-size: 10px; cursor: pointer; }

.streams-dock { position: fixed; bottom: 20px; left: 304px; z-index: 50; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 880px); }
.stream-card { background: var(--bg-elevated); backdrop-filter: blur(12px); border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 12px; display: flex; align-items: center; gap: 9px; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.stream-card.watching { background: rgba(16, 185, 129, 0.16); border-color: #34d399; }
.stream-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }
.stream-card-title { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.stream-card-action { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: #6ee7b7; background: rgba(16, 185, 129, 0.15); padding: 2px 6px; border-radius: 4px; }

.control-bar { position: fixed; bottom: 20px; right: 24px; z-index: 50; display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--dock-bg); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.6); }
.ctrl-split { display: flex; align-items: center; background: rgba(255,255,255,0.02); border-radius: 8px; }
.ctrl-btn { height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-primary); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; cursor: pointer; transition: 0.12s; }
.ctrl-btn:hover, .ctrl-caret:hover { background: var(--bg-hover); }
.ctrl-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.ctrl-btn.state-muted { background: var(--danger-soft); border-color: rgba(244, 63, 94, 0.35); color: #fca5a5; }
.ctrl-btn.state-active { background: var(--text-primary); color: var(--bg-base); font-weight: 600; }
.ctrl-btn.state-hand { background: rgba(245, 158, 11, 0.22); border-color: rgba(245, 158, 11, 0.5); color: #fde68a; font-weight: 600; }
.btn-leave-room { color: #fda4af; border-color: rgba(244, 63, 94, 0.25); }
.btn-leave-room:hover { background: var(--danger-soft); border-color: var(--danger); color: #fff; }
.ctrl-caret { height: 38px; padding: 0 6px; border-radius: 6px; border: none; background: transparent; color: var(--text-muted); font-size: 9px; cursor: pointer; transition: 0.12s; }
.ctrl-caret:hover { color: var(--text-primary); }
.bar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

.device-menu { position: fixed; bottom: 72px; right: 24px; z-index: 120; background: #131826; border: 1px solid var(--border-strong); border-radius: 11px; padding: 8px; min-width: 260px; max-width: 340px; box-shadow: 0 16px 42px rgba(0,0,0,0.85); display: flex; flex-direction: column; gap: 4px; }
.device-menu-title { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.device-option { padding: 8px 10px; border-radius: 7px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; transition: 0.12s; text-align: left; }
.device-option:hover { background: var(--bg-hover); color: #fff; }
.device-option.active { background: rgba(129, 140, 248, 0.16); color: #fff; font-weight: 600; }

.toast { position: fixed; bottom: 72px; left: 304px; background: var(--bg-elevated); border: 1px solid var(--border-strong); color: var(--text-secondary); padding: 8px 12px; border-radius: 7px; font-size: 12px; pointer-events: none; opacity: 0; transform: translateY(6px); transition: 0.18s; z-index: 100; }
.toast.visible { opacity: 1; transform: translateY(0); }



.chat-pane {
  width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 15;
  flex-shrink: 0;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}
.chat-pane.open {
  display: flex;
}
.chat-header {
  height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.chat-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.chat-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 5px;
}
.chat-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty {
  margin: auto;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.chat-msg {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-msg.own {
  background: rgba(129, 140, 248, 0.09);
  border-color: rgba(129, 140, 248, 0.28);
}
body.solar-theme .chat-msg.own {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}
.chat-msg.highlight-msg {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(129, 140, 248, 0.45);
}
.chat-msg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.chat-sender {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-teacher-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(129, 140, 248, 0.2);
  color: var(--text-primary);
}
.chat-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--text-muted);
}
.chat-reply-quote {
  background: rgba(0, 0, 0, 0.25);
  border-left: 2.5px solid var(--accent);
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-reply-quote-author {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 10.5px;
}
.chat-reply-quote-text {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-text {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-primary);
  word-break: break-word;
  user-select: text;
}
.chat-hover-bar {
  position: absolute;
  top: -12px;
  right: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 2px 4px;
  display: none;
  align-items: center;
  gap: 2px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  z-index: 5;
}

.chat-Hover-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: transform 0.1s, background 0.1s;
}
.chat-Hover-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.15);
  color: var(--text-primary);
}
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.chat-react-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: 0.12s;
}
.chat-react-pill:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.chat-react-pill.active {
  background: rgba(129, 140, 248, 0.2);
  border-color: var(--accent);
  color: var(--text-primary);
}
.chat-reply-preview {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 6px 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-reply-preview.active {
  display: flex;
}
.chat-reply-preview-info {
  min-width: 0;
  flex: 1;
  font-size: 11px;
  border-left: 2px solid var(--accent);
  padding-left: 7px;
}
.chat-reply-preview-name {
  font-weight: 600;
  color: var(--accent);
}
.chat-reply-preview-text {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-input-area {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 7px;
  background: var(--bg-surface);
}
.chat-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-send-btn:hover {
  opacity: 0.9;
}
.chat-unread-badge {
  background: var(--danger);
  color: #fff;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}


.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.3) transparent;
}
.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(129, 140, 248, 0.28);
  border-radius: 99px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.52);
}
body.solar-theme .chat-messages {
  scrollbar-color: rgba(245, 158, 11, 0.35) transparent;
}
body.solar-theme .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.32);
}
.chat-hover-bar {
  position: absolute;
  top: -13px;
  right: 10px;
  background: rgba(34, 43, 69, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(129, 140, 248, 0.42);
  border-radius: 99px;
  padding: 2px 7px;
  display: none;
  align-items: center;
  gap: 3px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  z-index: 6;
}
body.solar-theme .chat-hover-bar {
  background: rgba(52, 62, 85, 0.95);
  border-color: rgba(245, 158, 11, 0.45);
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-clear-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
}
.chat-clear-btn:hover {
  background: var(--danger-soft);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.35);
}
.chat-clear-confirm {
  background: rgba(244, 63, 94, 0.12);
  border-bottom: 1px solid rgba(244, 63, 94, 0.3);
  padding: 8px 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-primary);
}
.chat-clear-confirm.active {
  display: flex;
}
.chat-clear-confirm-btns {
  display: flex;
  gap: 6px;
}
.btn-chat-confirm-cancel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}
.btn-chat-confirm-yes {
  background: var(--danger);
  border: none;
  color: #fff;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.chat-msg-layout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.chat-avatar-wrap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: #202840;
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 1px;
}
body.solar-theme .chat-avatar-wrap {
  background: #3c465e;
}
.chat-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}


.chat-text {
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
  user-select: text;
}
.chat-msg.replying-target {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(129, 140, 248, 0.28);
}
.chat-hover-bar {
  position: absolute;
  top: 26px;
  right: 34px;
  background: rgba(34, 43, 69, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(129, 140, 248, 0.45);
  border-radius: 99px;
  padding: 3px 8px;
  display: none !important;
  align-items: center;
  gap: 3px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
  z-index: 20;
}
.chat-hover-bar.open {
  display: flex !important;
}
.chat-meta-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 6px;
}
.chat-more-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 24px;
  height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.15s;
}
.chat-more-btn:hover,
.chat-more-btn.active {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.chat-input-area {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 7px;
  background: var(--bg-surface);
}
textarea.chat-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.38;
  height: 36px;
  min-height: 36px;
  max-height: 110px;
  resize: none;
  outline: none;
  overflow-y: auto;
  font-family: "Inter", -apple-system, sans-serif;
}
textarea.chat-input:focus {
  border-color: var(--accent);
}
.chat-send-btn {
  height: 36px;
  flex-shrink: 0;
}


:root, body, textarea, input {
  color-scheme: dark;
}
*::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(129, 140, 248, 0.28);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.52);
}
textarea.chat-input {
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.32) transparent;
}
body.solar-theme *::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.32);
}
body.solar-theme textarea.chat-input {
  scrollbar-color: rgba(245, 158, 11, 0.35) transparent;
}
.chat-pane {
  position: relative;
  min-width: 260px;
  min-height: 260px;
}
.chat-pane.floating {
  position: fixed !important;
  z-index: 260 !important;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(129, 140, 248, 0.28) !important;
}
body.solar-theme .chat-pane.floating {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(245, 158, 11, 0.35) !important;
}
.chat-header {
  cursor: grab;
  user-select: none;
}
.chat-header:active {
  cursor: grabbing;
}
.chat-dock-btn {
  background: rgba(129, 140, 248, 0.16);
  border: 1px solid rgba(129, 140, 248, 0.38);
  color: #c7d2fe;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 5px;
  transition: 0.15s;
}
.chat-dock-btn:hover {
  background: rgba(129, 140, 248, 0.28);
  border-color: var(--accent);
  color: #fff;
}
body.solar-theme .chat-dock-btn {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}
.chat-pane.is-modified .chat-dock-btn {
  display: inline-flex;
}
.chat-resizer {
  position: absolute;
  z-index: 30;
}
.resizer-n { top: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer-s { bottom: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.resizer-w { left: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.resizer-e { right: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.resizer-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.resizer-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.resizer-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.resizer-se { bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.resizer-se::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid rgba(148, 163, 184, 0.45);
  border-bottom: 1.5px solid rgba(148, 163, 184, 0.45);
  pointer-events: none;
}
