:root { 
    --bg-main: #0a0a0a; --surface: #121212; --surface-hover: #1e1e1e; --border: #2e2e2e;
    --text-primary: #ffffff; --text-secondary: #a1a1aa; 
    --accent: #ffffff; --accent-hover: #e5e5e5; --text-on-accent: #000000;
    --input-bg: #000000; --error: #ff453a; --error-bg: rgba(255, 69, 58, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.8); --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-main: #f4f4f5; --surface: #ffffff; --surface-hover: #f3f4f6; --border: #e5e7eb;
    --text-primary: #000000; --text-secondary: #52525b; 
    --accent: #000000; --accent-hover: #3f3f46; --text-on-accent: #ffffff;
    --input-bg: #ffffff; --error: #ef4444; --error-bg: rgba(239, 68, 68, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.4); --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-font-smoothing: antialiased; }
/* Desktop Native Fullscreen CSS */
body { background: var(--bg-main); color: var(--text-primary); min-height: 100dvh; padding: 0; overflow: hidden; display: flex; transition: background-color 0.2s, color 0.2s; }
.app-window { width: 100vw; max-width: none; height: 100dvh; background: var(--surface); display: flex; flex-direction: column; overflow: hidden; position: relative; animation: appBoot 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; transition: background-color 0.2s; border: none; border-radius: 0; }

@keyframes appBoot { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(0.95); opacity: 0.5; } }

.privacy-blur { filter: blur(25px) grayscale(100%); pointer-events: none; transition: filter 0.3s ease; }

.material-symbols-outlined { vertical-align: middle; font-size: 1.25em; margin-right: 6px; }
.icon-only { margin-right: 0 !important; }
.flex-center { display: flex; align-items: center; }

.setup-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; padding: 2rem; max-width: 420px; margin: 0 auto; width: 100%; overflow-y: auto; }
.setup-screen h2 { font-weight: 700; letter-spacing: -0.5px; margin-bottom: 2rem; text-align: center; display: flex; align-items: center; justify-content: center; }

.intro-box { font-size: 0.85rem; color: var(--text-secondary); background: var(--input-bg); border: 1px solid var(--border); padding: 16px 20px; border-radius: 16px; margin-bottom: 1.5rem; text-align: left; line-height: 1.6; width: 100%; }
.intro-box h4 { color: var(--text-primary); margin-bottom: 8px; font-size: 0.95rem; font-weight: 600; }
.intro-box ul { padding-left: 20px; margin-top: 8px; }
.intro-box li { margin-bottom: 6px; }

.disclaimer { font-size: 0.75rem; color: var(--text-secondary); background: var(--error-bg); border: 1px solid rgba(239, 68, 68, 0.2); padding: 14px 18px; border-radius: 12px; margin-bottom: 1.5rem; text-align: justify; line-height: 1.6; width: 100%; }
.disclaimer strong { color: var(--error); font-weight: 600;}
.legal-notice { background: var(--input-bg); border-color: var(--border); margin-top: -8px; }
.eula-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.welcome-back { display: none; width: 100%; text-align: center; margin-bottom: 1.5rem; }
.welcome-back h3 { color: var(--text-primary); font-weight: 600; margin-bottom: 5px; }
.action-row { display: flex; gap: 12px; width: 100%; margin-top: 10px; }

.input-group { width: 100%; margin-bottom: 1.25rem; }
.input-group label { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 0.5rem; padding-left: 4px; }
input[type="text"], input[type="password"], input[type="number"] { width: 100%; padding: 16px 20px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 14px; color: var(--text-primary); font-size: 1rem; transition: border-color 0.2s; }
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus { outline: none; border-color: var(--accent); }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.custom-select-wrapper { position: relative; width: 100%; user-select: none; }
.custom-select-trigger { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 16px 20px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 14px; color: var(--text-primary); font-size: 1rem; cursor: pointer; transition: border-color 0.2s; }
.custom-select-trigger svg { transition: transform 0.2s; stroke: var(--text-secondary); }
.custom-select-trigger.open { border-color: var(--accent); }
.custom-select-trigger.open svg { transform: rotate(180deg); }
.custom-options { position: absolute; display: none; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; z-index: 50; overflow: hidden; box-shadow: var(--shadow-sm); padding: 4px; }
.custom-select-trigger.open + .custom-options { display: block; animation: popIn 0.15s ease-out; }
.custom-option { padding: 14px 16px; cursor: pointer; transition: background 0.2s; color: var(--text-secondary); font-size: 0.95rem; border-radius: 10px; }
.custom-option:hover { background: var(--surface-hover); color: var(--text-primary); }
.custom-option.selected { background: var(--input-bg); color: var(--accent); font-weight: 500; }

button.btn-primary { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 16px; background: var(--accent); border: none; border-radius: 14px; color: var(--text-on-accent); font-size: 1rem; font-weight: 600; cursor: pointer; transition: 0.2s; }
button.btn-primary:hover { background: var(--accent-hover); }
button:disabled, .btn-primary.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-danger { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--error); color: var(--error); padding: 16px; border-radius: 14px; cursor: pointer; transition: 0.2s; font-weight: 600; flex: 1; }
.btn-danger:hover { background: var(--error-bg); }

.theme-toggle-btn { background: transparent; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 50%; transition: 0.2s; display: flex; align-items: center; justify-content: center; outline: none; }
.theme-toggle-btn:hover { color: var(--text-primary); background: var(--surface-hover); }

/* --- DYNAMIC DESKTOP GRID --- */
.chat-workspace { display: none; height: 100%; animation: popIn 0.4s ease-out forwards; overflow: hidden; transition: grid-template-columns 0.3s ease; }
.chat-workspace.booted { display: grid; grid-template-columns: 320px 1fr; }
.chat-workspace.has-video { grid-template-columns: 320px 1fr 320px; }

.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; }
.sidebar-content { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; overflow-y: auto; flex: 1; }

/* The Stage (Middle Pane) */
.call-stage { display: none; flex-direction: column; flex: 1; height: 100%; background: var(--bg-main); padding: 16px; overflow: hidden; position: relative; }
.chat-workspace.has-video .call-stage { display: flex; animation: popIn 0.3s ease; }

/* The Chat Sidebar (Right Pane) - Now matches surface color */
.chat-sidebar { display: flex; flex-direction: column; height: 100%; background: var(--surface); border-left: 1px solid var(--border); overflow: hidden; }
.chat-workspace:not(.has-video) .chat-sidebar { border-left: none; }

.user-badge { display: flex; align-items: center; gap: 14px; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--text-on-accent); display: flex; justify-content: center; align-items: center; font-weight: 700; font-size: 1.1rem; }
.user-name { font-weight: 600; font-size: 1.05rem; color: var(--text-primary); }

.connection-box { display: flex; flex-direction: column; gap: 10px; }
.connection-box input, .connection-box .custom-select-trigger, .connection-box .custom-option { padding: 12px 16px; font-size: 0.9rem; border-radius: 12px; }
.connection-box button { padding: 12px; font-size: 0.9rem; width: 100%; border-radius: 12px; }

.saved-channels-list { display: flex; flex-direction: column; gap: 8px; }
.channel-item { padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 0.95rem; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; box-shadow: var(--shadow-sm); }
.channel-item:hover { background: var(--surface-hover); border-color: var(--text-secondary); }
.channel-item.active-room { border-color: var(--accent); background: var(--input-bg); box-shadow: none; }
.channel-item-left { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.channel-name-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-primary); }
.channel-name-txt .material-symbols-outlined { font-size: 1.1em; color: var(--text-secondary); margin-right: 0;}
.channel-stats { display: inline-flex; align-items: center; font-size: 0.7rem; color: var(--text-secondary); background: var(--border); padding: 4px 8px; border-radius: 10px; font-weight: 600; }
.channel-stats .material-symbols-outlined { font-size: 1.1em; margin-right: 4px; }
.unread-badge { background: var(--accent); color: var(--text-on-accent); min-width: 20px; height: 20px; border-radius: 10px; font-size: 0.7rem; font-weight: 700; display: flex; justify-content: center; align-items: center; padding: 0 6px; animation: popIn 0.3s ease; }

.btn-group { display: flex; gap: 4px; }
.action-btn { background: transparent; border: 1px solid transparent; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 10px; transition: 0.2s; display: flex; align-items: center; justify-content: center; outline: none;}
.action-btn:hover { color: var(--text-primary); background: var(--border); }
.action-btn.del:hover { color: var(--error); background: var(--error-bg); }

.modal-overlay { display: none; position: absolute; top:0; left:0; width:100%; height:100%; background: var(--modal-overlay); z-index: 3000; justify-content: center; align-items: center; padding: 1rem; animation: popIn 0.2s ease-out forwards; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; padding: 2rem; display: flex; flex-direction: column; gap: 1.25rem; box-shadow: var(--shadow-sm); animation: popIn 0.3s ease-out forwards; }
.modal-close { align-self: flex-end; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; width: 32px; height: 32px; border-radius: 16px; display: flex; justify-content: center; align-items: center; transition: 0.2s; flex-shrink: 0; }
.modal-close:hover { color: var(--text-primary); background: var(--border); }
#qrCanvasContainer { display: flex; justify-content: center; padding: 16px; background: white; border-radius: 16px; width: fit-content; margin: 0 auto; }


/* --- DESKTOP SLIM CALL CONTROLS (Top of Chat Sidebar) --- */
/* ALWAYS VISIBLE ON DESKTOP SO YOU CAN START A CALL */
.voice-control-bar { display: none; justify-content: space-between; align-items: center; background: var(--surface); padding: 4px 12px; border-bottom: 1px solid var(--border); height: 48px; flex-shrink: 0; z-index: 20; }
.call-controls-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; margin: 0; }

.voice-control-actions { display: flex; gap: 6px; height: 100%; align-items: center; }
.control-btn { height: 28px; padding: 0 12px; font-size: 0.75rem; font-weight: 600; border-radius: 6px; border: 1px solid var(--border); display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; outline: none; }
.action-cam { background: var(--input-bg); color: var(--text-primary); }
.action-cam:hover { background: var(--surface-hover); }
.action-cam.active { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }

.action-voice { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.action-voice:hover { opacity: 0.9; }
.action-voice.active { background: var(--error); color: white; border-color: var(--error); }
.action-voice.active:hover { background: #ff3333; }

/* Desktop Shrink State for 3-Pane View */
.chat-workspace.has-video .call-controls-title { display: none !important; }
.chat-workspace.has-video .voice-control-bar { justify-content: center; padding: 4px 6px; }
.chat-workspace.has-video .control-btn { padding: 0 8px; font-size: 0.7rem; height: 28px; }
.chat-workspace.has-video .control-btn .material-symbols-outlined { margin-right: 4px; font-size: 1.1em; }

.mobile-call-actions { display: none; }


/* --- SCREEN SHARE & VIDEO GRID SYSTEM --- */
.video-grid { display: none; gap: 8px; width: 100%; flex: 1; transition: all 0.3s; }
.video-grid.active { display: grid; }

.video-grid.presentation-mode { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)) !important; grid-template-rows: 1fr auto !important; align-items: center; }
.video-grid.presentation-mode .video-frame.featured-presenter { grid-column: 1 / 3; grid-row: 1; width: 100%; height: 100%; max-height: calc(100vh - 220px); }
.video-grid.presentation-mode .video-frame:not(.featured-presenter) { grid-row: 2; aspect-ratio: 16 / 9; height: auto; max-height: 140px; }

.video-frame { position: relative; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--border); display: flex; justify-content: center; align-items: center; }
/* STRICT ASPECT RATIO ENFORCEMENT */
.video-frame video { position: absolute; top:0; left:0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-label { position: absolute; bottom: 12px; left: 12px; background: rgba(0,0,0,0.6); padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 600; color: white; display: flex; align-items: center; z-index: 2;}

.hidden-camera { display: none !important; }

#voiceOnlyPlaceholder { display: none; flex-direction: column; justify-content: center; align-items: center; flex: 1; height: 100%; color: var(--text-secondary); gap: 20px; }
.pulsing-mic { animation: pulse 2s infinite ease-in-out; color: var(--accent); background: var(--surface); padding: 24px; border-radius: 50%; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.pulsing-mic .material-symbols-outlined { font-size: 4rem; margin: 0; }

.messages-container { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; scroll-behavior: smooth; position: relative; z-index: 10; }
.msg-wrapper { display: flex; flex-direction: column; max-width: 85%; animation: popIn 0.3s ease-out forwards; }
.msg-wrapper.me { align-self: flex-end; }
.msg-wrapper.peer { align-self: flex-start; }
.sender-name { font-size: 0.75rem; margin-bottom: 4px; color: var(--text-secondary); font-weight: 600; padding: 0 4px; display: flex; align-items: center;}
.bubble { padding: 12px 16px; border-radius: 18px; font-size: 0.95rem; line-height: 1.5; word-break: break-word; box-shadow: var(--shadow-sm); position: relative; }
.me .bubble { background: var(--accent); color: var(--text-on-accent); border-bottom-right-radius: 4px; }
.peer .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text-primary); }

.sys-note { align-self: center; display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); padding: 6px 14px; border-radius: 16px; animation: popIn 0.3s ease-out forwards; box-shadow: var(--shadow-sm); }
.sys-note .material-symbols-outlined { font-size: 1.1em; margin-right: 6px; }

.file-box-container { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.file-box { background: var(--input-bg); border: 1px dashed var(--text-secondary); padding: 12px; border-radius: 12px; cursor: pointer; transition: 0.2s; color: inherit; font-size: 0.85rem; font-weight: 500; display: flex; justify-content: center; align-items: center; gap: 6px;}
.me .file-box { border-color: rgba(255,255,255,0.4); background: rgba(0,0,0,0.1); }
.file-box:hover { transform: translateY(-2px); border-style: solid; }
.peer .file-box:hover { background: var(--border); border-color: var(--accent); color: var(--accent); }

.msg-status-icons { font-size: 14px; margin-left: 8px; opacity: 0.7; }
.msg-meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 0.7rem; opacity: 0.7; }

.input-tray { padding: 1.25rem 1.5rem; background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; z-index: 1000; position: relative; transition: all 0.2s; }
.input-tray form { display: flex; gap: 10px; }
.tray-action-btn { background: var(--input-bg); border: 1px solid var(--border); color: var(--text-secondary); width: 48px; height: 48px; border-radius: 14px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; user-select: none; outline: none; }
.tray-action-btn .material-symbols-outlined { margin: 0; font-size: 1.5em; }
.tray-action-btn:hover:not(.disabled) { background: var(--border); color: var(--text-primary); }
.tray-action-btn.disabled { opacity: 0.4; pointer-events: none; }

.input-tray input[type="text"] { flex: 1; padding: 14px 18px; border-radius: 14px; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-primary); transition: 0.2s; } 
.input-tray input[type="text"]:focus { outline: none; border-color: var(--accent); }
.input-tray button[type="submit"] { width: 60px; border-radius: 14px; padding: 0; } 

.preview-content-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; max-height: 55vh; background: #000000; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.preview-content-wrapper img, .preview-content-wrapper video { max-width: 100%; max-height: 55vh; object-fit: contain; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* STRICT DESKTOP HIDING RULES */
@media (min-width: 901px) {
    .mobile-header { display: none !important; }
    .mobile-call-actions { display: none !important; }
}

@media(max-width: 900px) {
    body { padding: 0; }
    .app-window { position: absolute; top: 0; bottom: 0; left: 0; right: 0; width: 100%; height: 100dvh; border-radius: 0; max-width: none; border: none; }
    
    /* MOBILE WORKSPACE IS STRICTLY HIDDEN UNTIL LOGGED IN */
    .chat-workspace { display: none !important; }
    .chat-workspace.booted { display: flex !important; flex-direction: column; width: 100%; height: 100%; position: relative; overflow: hidden; }
    
    .sidebar { border-right: none; border-bottom: 1px solid var(--border); flex: none; height: auto; z-index: 1000; }
    
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 16px 16px; color: var(--text-primary); cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); background: var(--surface); position: relative; z-index: 1000; }
    .header-icon-box { width: 72px; display: flex; align-items: center; }
    .mobile-header-center { display: flex; align-items: center; justify-content: center; flex: 1; pointer-events: none; }
    .mobile-header:active { background: var(--surface-hover); }
    
    .sidebar-content { padding: 1.5rem; gap: 1.25rem; }
    .sidebar-content.collapsed { display: none; }
    .user-badge { display: none; }
    
    .chat-sidebar { flex: 1; display: flex; flex-direction: column; height: 100%; background: var(--bg-main); border: none; z-index: 5; }
    .input-tray { padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
    .setup-screen { padding-top: calc(2rem + env(safe-area-inset-top)); padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
    .eula-grid { grid-template-columns: 1fr; gap: 12px; }

    /* COMPLETELY DISABLE DESKTOP UI ON MOBILE - Specificity overrides any JS */
    .voice-control-bar, .voice-control-bar.active { display: none !important; }

    /* 1. Mobile In-Call (Not Chatting) - Make Dock Transparent and Anchored */
    .chat-workspace.in-call .call-stage { position: absolute; top: 70px; left: 0; right: 0; bottom: 0; padding: 0; z-index: 1; background: #000; display: flex; }
    .chat-workspace.in-call:not(.chat-open) .chat-sidebar { background: transparent; pointer-events: none; position: absolute; top: 70px; left: 0; right: 0; bottom: 0; z-index: 1000; justify-content: flex-end;}
    
    /* ABSOLUTE BOTTOM ANCHOR FIX FOR MOBILE CONTROLS */
    .chat-workspace.in-call:not(.chat-open) .input-tray { 
        background: transparent !important; border-top: none !important; pointer-events: auto; 
        position: absolute; bottom: 0; left: 0; width: 100%; 
        padding: 16px 16px calc(96px + env(safe-area-inset-bottom)) 16px !important; 
        box-sizing: border-box; z-index: 1000;
    }
    .chat-workspace.in-call:not(.chat-open) .mobile-call-actions { display: flex; width: 100%; gap: 12px; justify-content: space-between; }
    .chat-workspace.in-call:not(.chat-open) .messages-container, 
    .chat-workspace.in-call:not(.chat-open) #chatForm { display: none !important; }
    
    .chat-workspace.in-call:not(.chat-open) .video-grid.active { padding: 0; padding-bottom: 110px; gap: 2px; display: grid !important; opacity: 1 !important;}
    .chat-workspace.in-call:not(.chat-open) .video-frame { border-radius: 0; border: none; }
    
    /* ELEVATED PIP Local Camera Overlay - Z-index 500 keeps it safely above controls */
    .chat-workspace.in-call:not(.chat-open) #video-local {
        position: fixed !important; bottom: 130px !important; right: 16px !important; 
        width: 100px !important; height: 140px !important; z-index: 500 !important; 
        border-radius: 12px; border: 2px solid var(--surface-hover); box-shadow: var(--shadow-sm);
    }
    
    /* 2. Mobile In-Call (Chat Open) */
    .chat-workspace.in-call.chat-open .chat-sidebar { position: absolute; top: 70px; left: 0; right: 0; bottom: 0; z-index: 1000; background: var(--bg-main); pointer-events: auto; justify-content: space-between; }
    .chat-workspace.in-call.chat-open .mobile-call-actions { display: none; }
    .chat-workspace.in-call.chat-open #chatForm { display: flex; }
    .chat-workspace.in-call.chat-open #voiceOnlyPlaceholder { display: none !important; }
	
    .chat-workspace.in-call.chat-open .input-tray { 
        position: absolute; bottom: 0; left: 0; width: 100%; 
        padding: 16px 16px calc(96px + env(safe-area-inset-bottom)) 16px !important; 
        box-sizing: border-box; z-index: 1000;
    }
    
    /* Hide grid stage logic while Chatting */
    .chat-workspace.in-call.chat-open .call-stage { opacity: 0; pointer-events: none; display: flex; }
    
    /* Loudest Speaker PIP overlay when chat is open */
    .chat-workspace.in-call.chat-open .video-frame.pip-floating {
        opacity: 1; display: block; position: fixed !important; top: 86px !important; right: 16px !important; 
        width: 100px !important; height: 140px !important; z-index: 2000 !important; 
        border-radius: 12px; border: 2px solid var(--border); box-shadow: var(--shadow-sm); 
        pointer-events: auto; cursor: pointer;
    }

    /* Scaling Box Mobile Tray Buttons */
    .mobile-call-actions button { padding: 12px; border-radius: 16px; display: flex; justify-content: center; align-items: center; border: none; cursor: pointer; transition: 0.2s; outline: none; }
    #mobileChatToggle { flex: 0 0 60px; height: 60px; background: var(--accent); color: var(--text-on-accent); }
    #mobileVideoToggle { flex: 1; height: 60px; background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
    #mobileVideoToggle.active-cam { background: var(--accent); color: var(--text-on-accent); border: none; }
    #mobileEndCall { flex: 1; height: 60px; background: var(--error); color: white; border: none; }
    #mobileEndCall:hover { background: #ff3333; }
    
    .mobile-call-actions button .material-symbols-outlined { margin: 0; font-size: 28px; }
}