/* --- FACEJAM futurist neon css layout --- */

:root {
    --bg-color: #05070a;
    --panel-bg: rgba(10, 15, 25, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --cyan-glow: #00f0ff;
    --blue-glow: #0072ff;
    --red-glow: #ff0055;
    --text-color: #ffffff;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    height: 100dvh;
    width: 100dvw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Safe margins framing the app console to avoid notched bezel & Safari toolbar cuts */
    padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
}

.glass-container {
    display: flex;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    background: radial-gradient(circle at top left, rgba(0, 114, 255, 0.1), transparent),
                radial-gradient(circle at bottom right, rgba(255, 0, 85, 0.05), transparent);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.sidebar {
    width: 280px;
    background-color: rgba(0, 0, 0, 0.95);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    overflow-y: auto; /* Enable vertical scrolling for overflowing menu content */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.25) transparent;
}

/* Translucent futuristic cyber scrollbar styles */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.18);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.45);
    box-shadow: 0 0 10px var(--cyan-glow);
}


.logo-area {
    margin-bottom: 8px;
}

.logo-area h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--blue-glow);
    text-shadow: 0 0 10px rgba(0, 114, 255, 0.4);
}

.sub-logo {
    font-size: 9px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 1.5px;
}

.divider {
    border: none;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.08);
    margin: 20px 0;
}

.menu-section {
    margin-bottom: 24px;
}

.menu-section h2 {
    font-size: 10px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.asset-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset-btn, .bg-btn {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.asset-btn:hover, .bg-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.asset-btn.active, .bg-btn.active {
    background-color: var(--text-color);
    color: #000;
    border-color: var(--blue-glow);
    box-shadow: 0 0 15px rgba(0, 114, 255, 0.25);
}

.asset-btn .icon, .bg-btn .icon {
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

/* 3D VIEW RENDER MODES */
.render-mode-btn {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Share Tech Mono', inherit;
    font-weight: 600;
    font-size: 11px;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    justify-content: center;
    gap: 4px;
}

.render-mode-btn:hover {
    background-color: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.35);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}

.render-mode-btn.active {
    background-color: var(--cyan-glow);
    color: #000;
    border-color: var(--cyan-glow);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.45);
    font-weight: 800;
}

.switches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.switch-control {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 12px;
}

.switch-control input {
    cursor: pointer;
    accent-color: var(--blue-glow);
}

.switch-lbl {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

.spacer {
    flex-grow: 1;
}

/* High-tech Record button styling */
.record-btn {
    background-color: rgba(255, 0, 85, 0.15);
    border: 2px solid var(--red-glow);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.35s ease;
}

.record-btn:hover {
    background-color: rgba(255, 0, 85, 0.3);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

.record-btn.recording {
    background-color: var(--red-glow);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    animation: pulse 1.5s infinite alternate;
}

.record-btn .dot {
    width: 10px;
    height: 10px;
    background-color: var(--red-glow);
    border-radius: 50%;
}

.record-btn.recording .dot {
    background-color: #fff;
}

/* 2. Workspace Viewport splits */
.workspace {
    flex-grow: 1;
    display: flex;
    background-color: #000;
    position: relative;
}

.panel {
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Full-Screen Render Panel occupying entire workspace background */
.render-panel.full-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Picture-in-Picture (PIP) Floating Camera card in bottom-right corner */
.camera-panel.pip-mode {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    width: 280px;
    height: 157.5px; /* Locked 16:9 aspect ratio */
    z-index: 20;
    border: 2px solid rgba(0, 240, 255, 0.45);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 240, 255, 0.15), 
                0 0 15px rgba(0, 240, 255, 0.3),
                inset 0 0 10px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.85);
    transition: all 0.3s ease;
}

/* Subtle highlight when camera is active */
.camera-panel.pip-mode:hover {
    border-color: var(--cyan-glow);
    box-shadow: 0 12px 48px rgba(0, 240, 255, 0.25), 
                0 0 25px rgba(0, 240, 255, 0.5);
    transform: translateY(-2px);
}

/* Zoom HUD controls styling */
.zoom-hud {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: calc(24px + env(safe-area-inset-left, 0px));
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    background: rgba(10, 15, 25, 0.8);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 30;
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 0 10px rgba(0, 240, 255, 0.05);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    border-radius: 8px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: var(--blue-glow);
    border-color: var(--cyan-glow);
    box-shadow: 0 0 10px rgba(0, 114, 255, 0.4);
    color: #fff;
}

.zoom-btn:active {
    transform: scale(0.92);
}

.zoom-slider {
    width: 140px;
    accent-color: var(--cyan-glow);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.zoom-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.zoom-slider::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--cyan-glow);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -6px;
    box-shadow: 0 0 8px var(--cyan-glow);
    transition: transform 0.1s ease;
}

.zoom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative !important;
    z-index: 5;
    pointer-events: auto !important;
}

.tag {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 4px 10px;
    background-color: rgba(0, 0, 0, 0.75);
    border-radius: 6px;
    pointer-events: auto;
}

.tag-cyan {
    color: var(--cyan-glow);
    border: 1px solid rgba(0, 240, 255, 0.15);
}

.tag-blue {
    color: var(--blue-glow);
    border: 1px solid rgba(0, 114, 255, 0.15);
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* mirror webcam */
}

#landmarks-canvas {
    position: absolute;
    pointer-events: none;
    transform: scaleX(-1); /* mirror drawn points to align with mirrored camera */
}

#webgl-container {
    width: 100%;
    height: 100%;
    background-color: transparent;
    position: relative;
    cursor: grab;
}

#webgl-container:active {
    cursor: grabbing;
}

canvas {
    display: block;
}

/* Diagnostics Panel */
.diagnostics-hud {
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px;
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    pointer-events: auto;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
}

.hud-lbl {
    color: rgba(255, 255, 255, 0.6);
}

.text-green { color: #00ff66; text-shadow: 0 0 5px rgba(0, 255, 102, 0.3); }
.text-blue { color: var(--blue-glow); }

/* Initialization Loader overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    transition: opacity 0.5s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 114, 255, 0.1);
    border-top: 3px solid var(--blue-glow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--blue-glow);
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

/* Custom 3D Mesh Uploader styling */
.uploader-area {
    padding: 16px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 2px dashed rgba(0, 240, 255, 0.25);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 6px;
}

.uploader-area:hover {
    background-color: rgba(0, 240, 255, 0.04);
    border-color: var(--cyan-glow);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.uploader-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.upload-icon {
    font-size: 22px;
    color: var(--cyan-glow);
}

.upload-lbl {
    font-size: 10px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 1px;
}

#export-rig-btn {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#export-rig-btn:hover {
    background-color: rgba(0, 240, 255, 0.25) !important;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.35);
    transform: scale(1.02);
}

#export-rig-btn:active {
    transform: scale(0.98);
}

/* Smoothing control styles */
.smoothing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.smoothing-hud-val {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    color: var(--cyan-glow);
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
    letter-spacing: 0.5px;
    text-align: center;
    margin-top: 4px;
}

/* Custom Background Uploader cards overrides */
.bg-uploader {
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.bg-uploader:hover {
    background-color: rgba(0, 240, 255, 0.10) !important;
    border-color: var(--cyan-glow) !important;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
    transform: scale(1.02);
}

.bg-uploader:active {
    transform: scale(0.98);
}

/* Responsive Hamburger Menu Button */
.hamburger-btn {
    display: none; /* Hidden on desktop viewports */
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    width: 44px;
    height: 44px;
    background: rgba(10, 15, 25, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.35);
    border-radius: 50%;
    color: var(--cyan-glow);
    font-size: 20px;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    z-index: 90;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5),
                0 0 15px rgba(0, 240, 255, 0.15);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hamburger-btn:hover {
    background: var(--blue-glow);
    border-color: var(--cyan-glow);
    box-shadow: 0 0 15px rgba(0, 114, 255, 0.45);
    transform: scale(1.05);
}

.hamburger-btn:active {
    transform: scale(0.95);
}

/* Sidebar Blur Background Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Blender Import Script Button Override */
#download-blender-btn {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#download-blender-btn:hover {
    background-color: rgba(255, 136, 0, 0.25) !important;
    border-color: #ffaa44 !important;
    box-shadow: 0 0 15px rgba(255, 136, 0, 0.35);
    transform: scale(1.02);
}

#download-blender-btn:active {
    transform: scale(0.98);
}

/* Responsive Media Query for smaller iPad Portrait & Mobile Screens */
@media (max-width: 850px) {
    .hamburger-btn {
        display: flex; /* Show floating hamburger toggle button */
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%); /* Tuck offscreen by default */
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
        z-index: 10;
        border-radius: 0;
        border-right: 1px solid rgba(0, 240, 255, 0.15);
    }
    
    .sidebar.open {
        transform: translateX(0); /* Slide open seamlessly */
    }
    
    /* Optimize workspace padding and spacing for floating triggers */
    .zoom-hud {
        left: calc(16px + env(safe-area-inset-left, 0px)) !important;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    .camera-panel.pip-mode {
        right: calc(16px + env(safe-area-inset-right, 0px)) !important;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        width: 240px !important; /* Slightly smaller PIP on split view */
        height: 135px !important;
    }
}

/* --- Warp Calibration Studio CSS --- */
.calibration-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(3, 5, 8, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    animation: modal-fadeIn 0.3s ease;
}

@keyframes modal-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.calibration-content {
    background: rgba(10, 15, 25, 0.95);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 16px;
    width: 90%;
    max-width: 820px;
    max-height: 90%;
    box-shadow: 0 0 50px rgba(0, 240, 255, 0.15), 0 20px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: content-slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes content-slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.calibration-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-calibration-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-calibration-btn:hover {
    color: #ff3366;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.4);
}

.calibration-body {
    padding: 24px;
    display: flex;
    gap: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.workspace-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
    align-items: center;
}

.calibration-canvas-container {
    position: relative;
    width: 420px;
    height: 420px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.calibration-canvas-container img {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

#calibration-grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.calibration-pin {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.85);
    border: 2px solid var(--pin-color, #00f0ff);
    box-shadow: 0 0 10px var(--pin-color, #00f0ff);
    color: #fff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 8px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    touch-action: none;
}

.calibration-pin:hover {
    transform: translate(-50%, -50%) scale(1.25);
    box-shadow: 0 0 16px var(--pin-color, #00f0ff);
    z-index: 100;
}

.calibration-pin.active {
    transform: translate(-50%, -50%) scale(1.35);
    border-color: #fff;
    box-shadow: 0 0 20px #fff, 0 0 10px var(--pin-color, #00f0ff);
    z-index: 1000;
}

.calibration-status {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--cyan-glow);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
    text-align: center;
    letter-spacing: 0.5px;
}

.calibration-controls {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calibration-instruction {
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.65);
    font-family: 'Outfit', sans-serif;
}

.calibration-btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

/* Responsive adjustment for calibrator modal on smaller screens */
@media (max-width: 850px) {
    .calibration-content {
        max-width: 500px;
        max-height: 95%;
    }
    
    .calibration-body {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
    
    .calibration-canvas-container {
        width: 320px;
        height: 320px;
    }
    
    .calibration-controls {
        width: 100%;
    }
}

#mouth-studio-header,
#eye-studio-header,
#body-studio-header,
#face-layer-header {
    pointer-events: auto !important;
}

#close-mouth-studio-btn,
#close-eye-studio-btn,
#close-body-studio-btn,
#close-face-layer-btn {
    pointer-events: auto !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.6) !important;
    cursor: pointer !important;
    font-size: 16px !important;
    outline: none !important;
    transition: all 0.2s ease-in-out !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    margin-left: 10px !important;
}

#close-mouth-studio-btn:hover,
#close-eye-studio-btn:hover,
#close-body-studio-btn:hover,
#close-face-layer-btn:hover {
    background-color: rgba(255, 51, 102, 0.2) !important;
    border-color: rgba(255, 51, 102, 0.5) !important;
    color: #ff3366 !important;
    box-shadow: 0 0 8px rgba(255, 51, 102, 0.4) !important;
    transform: scale(1.05) !important;
}

/* Glassmorphism Neon Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 10px;
    width: 10px;
    left: 2px;
    bottom: 2px;
    background-color: #aaa;
    transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
}

input:checked + .slider {
    background-color: rgba(255, 153, 0, 0.2);
    border-color: #ff9900;
    box-shadow: 0 0 8px rgba(255, 153, 0, 0.35);
}

input:checked + .slider:before {
    transform: translateX(12px);
    background-color: #ff9900;
    box-shadow: 0 0 6px #ff9900;
}

.slider.round {
    border-radius: 16px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- High-Fidelity Mobile Responsive Floating Studio Panels --- */
/* --- High-Fidelity Mobile Responsive Floating Studio Panels --- */
@media (max-width: 768px) {
    #mouth-studio-panel,
    #eye-studio-panel,
    #body-studio-panel,
    #face-layer-panel {
        width: 100% !important;
        max-width: none !important;
        height: 45vh !important; /* Strictly lock to exactly 45% of the screen height */
        max-height: 45vh !important;
        min-height: 0 !important; /* Clear min-height overrides to prevent pushing above the viewport! */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important; /* Anchor firmly to the bottom */
        top: auto !important; /* Reset absolute top values */
        transform: none !important; /* Disable drag coordinates on mobile sheet layout */
        border-radius: 20px 20px 0 0 !important; /* Elegant top rounded corners only */
        border-bottom: none !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.75) !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Pin headers to the top of the sheets so close buttons are permanently visible & clickable! */
    .panel-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        background: rgba(10, 15, 25, 0.98) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        height: 44px !important;
        min-height: 44px !important;
        box-sizing: border-box !important;
    }

    /* Force the panel-body to scroll vertically on mobile so all content is reachable! */
    #mouth-studio-panel .panel-body,
    #eye-studio-panel .panel-body,
    #body-studio-panel .panel-body,
    #face-layer-panel .panel-body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex: 1 !important;
        padding-top: 10px !important;
    }
    
    /* Position webcam feed safely below the Hide UI button at the top right */
    .camera-panel.pip-mode {
        width: 120px !important;
        height: 67.5px !important;
        right: 12px !important;
        top: 76px !important; /* Clear the Hide UI button vertical footprint */
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        z-index: 100 !important;
        box-shadow: 0 4px 15px rgba(0, 240, 255, 0.25) !important;
    }
    
    .mouth-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 columns on mobile for readable touch targets */
        gap: 8px !important;
    }
    
    .uploader-area {
        height: 52px !important;
    }
    
    .uploader-label {
        font-size: 8px !important;
    }
}

@media (max-width: 480px) {
    #mouth-studio-panel,
    #eye-studio-panel,
    #body-studio-panel,
    #face-layer-panel {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        height: 45vh !important;
        max-height: 45vh !important;
        min-height: 0 !important;
    }
    
    .camera-panel.pip-mode {
        width: 100px !important;
        height: 56.25px !important;
        right: 8px !important;
        top: 76px !important;
        bottom: auto !important;
    }
    
    .tab-btn {
        padding: 6px 8px !important;
        font-size: 9px !important;
    }
}

/* --- Premium Mobile Hide UI Toggle --- */
.mobile-hide-ui-btn {
    display: none;
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    z-index: 9999; /* Maintain clickability above all layers */
    background: rgba(10, 15, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 240, 255, 0.35);
    color: var(--cyan-glow);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5),
                0 0 15px rgba(0, 240, 255, 0.15);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.mobile-hide-ui-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 12px var(--cyan-glow);
    transform: scale(1.02);
}

/* --- Premium Mobile Stop Export Button --- */
.mobile-stop-export-btn {
    display: none;
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(72px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    z-index: 10000; /* Maintain clickability above all layers */
    background: rgba(255, 51, 102, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid #ff3366;
    color: #ff3366;
    border-radius: 50%;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5),
                0 0 15px rgba(255, 51, 102, 0.4),
                inset 0 0 10px rgba(255, 51, 102, 0.2);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.mobile-stop-export-btn:hover {
    background: rgba(255, 51, 102, 0.35);
    box-shadow: 0 0 20px #ff3366;
    transform: scale(1.05);
}

.mobile-stop-export-btn:active {
    transform: scale(0.95);
}

@media (max-width: 850px) {
    .mobile-hide-ui-btn {
        display: block; /* Render only on mobile screen widths */
    }
    .mobile-stop-export-btn.active {
        display: flex !important; /* Render only when recording is active on mobile screen widths */
    }
}

/* Hide UI active state rules */
body.ui-hidden #sidebar,
body.ui-hidden .hamburger-btn,
body.ui-hidden .zoom-hud,
body.ui-hidden #diagnostics-hud,
body.ui-hidden .sidebar-overlay {
    display: none !important;
}

/* Hide all studio panels and camera feed when UI is hidden */
body.ui-hidden #mouth-studio-panel,
body.ui-hidden #eye-studio-panel,
body.ui-hidden #body-studio-panel,
body.ui-hidden #face-layer-panel,
body.ui-hidden .camera-panel.pip-mode {
    display: none !important;
}

/* --- Premium Floating Global Slider Overlay for Mobile Adjustments --- */
.mobile-slider-overlay {
    position: fixed !important;
    bottom: 24px !important;
    left: 20px !important;
    right: 20px !important;
    z-index: 100000 !important; /* High enough to float over everything including camera feed */
    background: rgba(10, 15, 25, 0.92) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(0, 240, 255, 0.45) !important;
    border-radius: 14px !important;
    padding: 14px 18px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7) !important;
    display: none; /* Controlled dynamically in JS */
    flex-direction: column !important;
    gap: 8px !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
}

.slider-overlay-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
}

.slider-overlay-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-family: 'Share Tech Mono', monospace !important;
    font-size: 11px !important;
    color: rgba(0, 240, 255, 0.9) !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
}

#slider-overlay-value {
    color: #00ff66 !important;
    font-weight: 800 !important;
}

#slider-overlay-range {
    width: 100% !important;
    margin-top: 4px !important;
    display: block !important;
    cursor: pointer !important;
}

/* --- Smooth Non-destructive Panel Hiding during mobile slide --- */
.panel.panel-hidden-sliding {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(100vh) !important;
    transition: transform 0.2s ease, opacity 0.2s ease !important;
}

/* --- High-Tech Accordion System --- */
.accordion-header {
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 6px;
}

/* Specific theme classes for headers */
.accordion-header.theme-2d {
    border: 1px solid rgba(255, 204, 0, 0.25);
    background: rgba(255, 204, 0, 0.05);
    box-shadow: inset 0 0 10px rgba(255, 204, 0, 0.05);
}
.accordion-header.theme-2d:hover {
    background: rgba(255, 204, 0, 0.08);
    border-color: rgba(255, 204, 0, 0.45);
}

.accordion-header.theme-3d {
    border: 1px solid rgba(0, 240, 255, 0.25);
    background: rgba(0, 240, 255, 0.05);
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.05);
}
.accordion-header.theme-3d:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.45);
}

.accordion-header.theme-config {
    border: 1px solid rgba(0, 240, 255, 0.25);
    background: rgba(0, 240, 255, 0.05);
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.05);
}
.accordion-header.theme-config:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.45);
}

.accordion-header.theme-save {
    border: 1px solid rgba(224, 64, 251, 0.25);
    background: rgba(224, 64, 251, 0.05);
    box-shadow: inset 0 0 10px rgba(224, 64, 251, 0.05);
}
.accordion-header.theme-save:hover {
    background: rgba(224, 64, 251, 0.08);
    border-color: rgba(224, 64, 251, 0.45);
}

.accordion-content {
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, margin 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 12px !important;
    border: 1px solid transparent !important;
    background: transparent;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.accordion-content.expanded.theme-2d {
    max-height: 2000px;
    opacity: 1;
    margin: 4px 0 10px 0 !important;
    padding: 12px !important;
    border: 1px solid rgba(255, 204, 0, 0.15) !important;
    background: rgba(255, 204, 0, 0.02);
}

.accordion-content.expanded.theme-3d {
    max-height: 2000px;
    opacity: 1;
    margin: 4px 0 10px 0 !important;
    padding: 12px !important;
    border: 1px solid rgba(0, 240, 255, 0.15) !important;
    background: rgba(0, 240, 255, 0.02);
}

.accordion-content.expanded.theme-config {
    max-height: 2000px;
    opacity: 1;
    margin: 4px 0 10px 0 !important;
    padding: 12px !important;
    border: 1px solid rgba(0, 240, 255, 0.15) !important;
    background: rgba(0, 240, 255, 0.02);
}

.accordion-content.expanded.theme-save {
    max-height: 2000px;
    opacity: 1;
    margin: 4px 0 10px 0 !important;
    padding: 12px !important;
    border: 1px solid rgba(224, 64, 251, 0.15) !important;
    background: rgba(224, 64, 251, 0.02);
}




