        :root {
            --bg-primary: #0a0a0f;
            --bg-secondary: #12121a;
            --bg-tertiary: #1a1a25;
            --grid-color: #1e1e2a;
            --grid-major: #2a2a3a;
            --panel-bg: rgba(18, 18, 26, 0.85);
            --panel-border: rgba(255, 255, 255, 0.08);
            --text-primary: #f0f0f5;
            --text-secondary: #9898a8;
            --text-muted: #5a5a6a;
            --accent: #6366f1;
            --accent-hover: #818cf8;
            --accent-glow: rgba(99, 102, 241, 0.4);
            --success: #22c55e;
            --success-bg: rgba(34, 197, 94, 0.15);
            --warning: #f59e0b;
            --warning-bg: rgba(245, 158, 11, 0.15);
            --danger: #ef4444;
            --danger-bg: rgba(239, 68, 68, 0.15);
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
            --shadow-glow: 0 0 20px var(--accent-glow);
            --radius-sm: 6px;
            --radius-md: 10px;
            --radius-lg: 16px;
            --radius-xl: 24px;
        }

        body.light-mode {
            --bg-primary: #f8f9fc;
            --bg-secondary: #ffffff;
            --bg-tertiary: #f0f1f5;
            --grid-color: #e8e9f0;
            --grid-major: #d0d1da;
            --panel-bg: rgba(255, 255, 255, 0.92);
            --panel-border: rgba(0, 0, 0, 0.08);
            --text-primary: #1a1a2e;
            --text-secondary: #5a5a70;
            --text-muted: #9898a8;
            --accent: #4f46e5;
            --accent-hover: #6366f1;
            --accent-glow: rgba(79, 70, 229, 0.3);
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            overflow: hidden;
            background: var(--bg-primary);
            color: var(--text-primary);
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            transition: all 0.3s ease;
            height: 100vh;
            width: 100vw;
            position: relative; /* Ensure proper positioning context for absolute children */
        }

        /* Animated Background */
        .bg-pattern {
            position: fixed;
            inset: 0;
            background:
                radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
            pointer-events: none;
            z-index: 0;
        }

        body.light-mode .bg-pattern {
            background:
                radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
        }

        /* Canvas Container */
        #canvas-wrapper {
            position: absolute;
            inset: 0;
            z-index: 1;
            transition: all 0.3s ease;
            overflow: hidden;
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
            max-width: 100%;
            max-height: 100%;
        }
        
        /* Responsive adjustments */
        @media (max-width: 1200px) {
            .analysis-panel {
                width: 280px;
            }
            
            body .analysis-panel.open ~ #canvas-wrapper {
                left: 280px;
                width: calc(100% - 280px);
            }
            
            body .analysis-panel.open .hud {
                left: 300px;
            }
            
            body .analysis-panel.open .toolbar {
                left: 58%;
            }
        }
        
        @media (max-width: 768px) {
            .analysis-panel {
                width: 240px;
            }
            
            .hud {
                width: 240px;
                left: 8px;
            }
            
            body .analysis-panel.open ~ #canvas-wrapper {
                left: 240px;
                width: calc(100% - 240px);
            }
            
            body .analysis-panel.open .hud {
                left: 252px;
            }
            
            body .analysis-panel.open .toolbar {
                left: 60%;
            }
            
            .toolbar {
                top: 12px;
                transform: translateX(-50%) scale(0.9);
            }
        }
        
        @media (max-width: 480px) {
            .analysis-panel {
                width: 200px;
            }
            
            .hud {
                width: 200px;
                left: 6px;
            }
            
            body .analysis-panel.open ~ #canvas-wrapper {
                left: 200px;
                width: calc(100% - 200px);
            }
            
            body .analysis-panel.open .hud {
                left: 212px;
            }
            
            body .analysis-panel.open .toolbar {
                left: 65%;
            }
            
            .toolbar {
                top: 10px;
                transform: translateX(-50%) scale(0.8);
            }
        }
        
        /* Touch device specific adjustments */
        .touch-device .analysis-panel {
            width: 280px;
        }
        
        .touch-device .hud {
            width: 280px;
        }
        
        .touch-device .toolbar {
            gap: 6px;
        }
        
        .touch-device .toolbar-btn {
            width: 40px;
            height: 40px;
            font-size: 18px;
        }

        /* Top Toolbar */
        .toolbar {
            position: fixed;
            top: 16px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 8px 12px;
            border-radius: var(--radius-xl);
            border: 1px solid var(--panel-border);
            box-shadow: var(--shadow-lg);
            z-index: 100;
        }

        .toolbar-group {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .toolbar-divider {
            width: 1px;
            height: 24px;
            background: var(--panel-border);
            margin: 0 6px;
        }

        .toolbar-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            background: transparent;
            border: none;
            border-radius: var(--radius-md);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 16px;
        }

        .toolbar-btn:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
        }

        .toolbar-btn.active {
            background: var(--accent);
            color: white;
        }

        .toolbar-btn.danger:hover {
            background: var(--danger-bg);
            color: var(--danger);
        }

        /* Dropdown Menu */
        .dropdown {
            position: relative;
        }

        .dropdown-menu {
            position: absolute;
            top: calc(100% + 8px);
            left: 50%;
            transform: translateX(-50%);
            min-width: 160px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg);
            padding: 6px;
            opacity: 0;
            visibility: hidden;
            transform: translateX(-50%) translateY(-10px);
            transition: all 0.2s ease;
            z-index: 1000;
        }

        .dropdown.open .dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateX(-50%) translateY(0);
        }

        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 14px;
            color: var(--text-secondary);
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: all 0.15s ease;
            font-size: 13px;
            white-space: nowrap;
        }

        .dropdown-item:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
        }

        .dropdown-item span:first-child {
            font-size: 16px;
        }

        /* Theme Toggle */
        .theme-toggle {
            position: fixed;
            top: 16px;
            right: 16px;
            width: 42px;
            height: 42px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            color: var(--text-primary);
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            box-shadow: var(--shadow-md);
            z-index: 100;
            transition: all 0.2s ease;
        }

        .theme-toggle:hover {
            transform: scale(1.05);
            box-shadow: var(--shadow-lg);
        }

        /* HUD Panel */
        .hud {
            position: fixed;
            top: 80px;
            left: 16px;
            width: 280px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 0;
            border-radius: var(--radius-lg);
            border: 1px solid var(--panel-border);
            box-shadow: var(--shadow-lg);
            max-height: calc(100vh - 100px);
            overflow-y: auto;
            z-index: 90;
            transition: all 0.3s ease;
            transform: scale(1);
            transform-origin: top left;
        }
        
        /* Adjust HUD when analysis panel is open */
        body .analysis-panel.open .hud {
            left: 340px;
        }

        .hud::-webkit-scrollbar {
            width: 6px;
        }

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

        .hud::-webkit-scrollbar-thumb {
            background: var(--text-muted);
            border-radius: 3px;
        }

        .hud-header {
            padding: 16px 18px;
            border-bottom: 1px solid var(--panel-border);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .hud-header h1 {
            margin: 0;
            font-size: 15px;
            font-weight: 600;
            letter-spacing: -0.02em;
        }

        .hud-header .badge {
            background: var(--accent);
            color: white;
            font-size: 10px;
            font-weight: 600;
            padding: 3px 8px;
            border-radius: 20px;
            letter-spacing: 0.03em;
        }

        .hud-section {
            padding: 16px 18px;
            border-bottom: 1px solid var(--panel-border);
        }

        .hud-section:last-child {
            border-bottom: none;
        }

        .section-title {
            font-size: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-muted);
            margin-bottom: 12px;
        }

        /* Acoustic Stats */
        .stat-card {
            background: var(--bg-tertiary);
            border-radius: var(--radius-md);
            padding: 12px 14px;
            margin-bottom: 8px;
        }

        .stat-card:last-child {
            margin-bottom: 0;
        }

        .stat-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .stat-label {
            font-size: 12px;
            color: var(--text-secondary);
        }

        .stat-value {
            font-family: 'JetBrains Mono', monospace;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .stat-value.good {
            color: var(--success);
        }

        .stat-value.warning {
            color: var(--warning);
        }

        .stat-value.bad {
            color: var(--danger);
        }

        /* Ratio Gauge */
        .ratio-gauge {
            margin-top: 10px;
            height: 6px;
            background: var(--bg-primary);
            border-radius: 3px;
            overflow: hidden;
            position: relative;
        }

        .ratio-gauge-fill {
            height: 100%;
            border-radius: 3px;
            transition: all 0.3s ease;
        }

        .ratio-gauge-marker {
            position: absolute;
            top: -2px;
            width: 2px;
            height: 10px;
            background: var(--text-primary);
            border-radius: 1px;
            transform: translateX(-50%);
        }

        /* Object Controls */
        .control-label {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 12px;
        }

        .control-label .icon {
            width: 28px;
            height: 28px;
            background: var(--accent);
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
        }

        .control-label .name {
            font-size: 14px;
            font-weight: 500;
        }

        .control-label .type {
            font-size: 11px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .input-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

        .input-group {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .input-group label {
            font-size: 10px;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
        }

        .input-group input {
            width: 100%;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            color: var(--text-primary);
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            font-family: 'JetBrains Mono', monospace;
            font-size: 13px;
            transition: all 0.2s ease;
        }

        .input-group input:hover {
            border-color: var(--panel-border);
        }

        .input-group input:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-glow);
        }

        .input-group input:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Material Select */
        .input-select {
            width: 100%;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            color: var(--text-primary);
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            font-family: 'Inter', sans-serif;
            font-size: 13px;
            cursor: pointer;
            appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 16px;
        }

        .input-select:hover {
            border-color: var(--panel-border);
        }

        .input-select:focus {
            outline: none;
            border-color: var(--accent);
        }

        .input-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        /* Buttons */
        .btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            width: 100%;
            padding: 12px 16px;
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-family: 'Inter', sans-serif;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn:hover {
            background: var(--accent-hover);
            transform: translateY(-1px);
            box-shadow: var(--shadow-glow);
        }

        .btn.secondary {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .btn.secondary:hover {
            background: var(--grid-major);
            box-shadow: none;
        }

        .btn.danger {
            background: var(--danger);
        }

        .btn.danger:hover {
            background: #dc2626;
        }

        /* JSON Output */
        textarea {
            width: 100%;
            min-height: 80px;
            margin-top: 12px;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            color: var(--text-secondary);
            border-radius: var(--radius-md);
            font-family: 'JetBrains Mono', monospace;
            font-size: 11px;
            padding: 12px;
            resize: vertical;
            transition: all 0.2s ease;
        }

        textarea:focus {
            outline: none;
            border-color: var(--accent);
        }

        /* Help Tips */
        .help-tips {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .help-tip {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: var(--text-muted);
        }

        .help-tip .key {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            font-family: 'JetBrains Mono', monospace;
            font-size: 10px;
            color: var(--text-secondary);
        }

        /* Tooltips */
        [data-tooltip] {
            position: relative;
            cursor: help;
        }

        [data-tooltip]::before {
            content: attr(data-tooltip);
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%) translateY(-8px);
            background: var(--panel-bg);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--panel-border);
            font-size: 11px;
            font-weight: 400;
            white-space: pre-wrap;
            /* Allow multiline */
            text-align: left;
            /* Keep text left-aligned */
            width: max-content;
            max-width: 220px;
            box-shadow: var(--shadow-lg);
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            pointer-events: none;
            z-index: 1100;
            backdrop-filter: blur(12px);
        }

        [data-tooltip]::after {
            content: '';
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%) translateY(-2px);
            border-width: 6px;
            border-style: solid;
            border-color: var(--panel-border) transparent transparent transparent;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            pointer-events: none;
            z-index: 1100;
        }

        [data-tooltip]:hover::before,
        [data-tooltip]:hover::after {
            opacity: 1;
            visibility: visible;
            transform: translateX(-50%) translateY(-4px);
            /* Slight lift */
        }

        /* Tooltips */
        .toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 14px 20px;
            border-radius: var(--radius-md);
            border: 1px solid var(--panel-border);
            box-shadow: var(--shadow-lg);
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 13px;
            z-index: 1000;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s ease;
            pointer-events: none;
        }

        .toast.show {
            opacity: 1;
            transform: translateY(0);
        }

        .toast.success {
            border-color: var(--success);
        }

        .toast.success::before {
            content: '✓';
            color: var(--success);
        }

        /* Welcome Modal */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
            pointer-events: none;
        }

        .modal-overlay.show {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .modal {
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: var(--radius-xl);
            box-shadow: var(--shadow-lg);
            width: 90%;
            max-width: 420px;
            padding: 28px;
            transform: scale(0.95);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            max-height: 85vh;
            overflow-y: auto;
            position: relative;
        }

        .modal-overlay.show .modal {
            transform: scale(1);
        }

        /* Mandatory auth modal - cannot be closed by clicking outside */
        .modal-overlay.mandatory {
            pointer-events: auto;
        }

        .modal-overlay.mandatory .modal {
            pointer-events: auto;
        }

        /* Auth modal specific animation */
        .auth-modal {
            animation: authSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
        }

        @keyframes authSlideIn {
            from {
                opacity: 0;
                transform: translateY(20px) scale(0.95);
            }
            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        /* Interface reveal animation */
        .reveal-animation {
            animation: interfaceReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
        }

        @keyframes interfaceReveal {
            from {
                opacity: 0;
                transform: scale(0.98);
                filter: blur(4px);
            }
            to {
                opacity: 1;
                transform: scale(1);
                filter: blur(0);
            }
        }

        /* Fade out animation for splash button */
        .splash-login-btn.fade-out {
            animation: splashFadeOut 0.3s ease-out both;
        }

        @keyframes splashFadeOut {
            from {
                opacity: 1;
                transform: translateX(-50%) scale(1);
            }
            to {
                opacity: 0;
                transform: translateX(-50%) scale(0.8);
            }
        }

        /* Close button for auth modal */
        .auth-modal-close {
            position: absolute;
            top: 16px;
            right: 16px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-tertiary);
            border: 1px solid var(--panel-border);
            border-radius: 50%;
            color: var(--text-secondary);
            font-size: 20px;
            cursor: pointer;
            transition: all 0.2s ease;
            z-index: 10;
        }

        .auth-modal-close:hover {
            background: var(--accent);
            color: white;
            border-color: var(--accent);
            transform: rotate(90deg);
        }

        /* Splash screen login button */
        .splash-login-btn {
            position: fixed;
            bottom: 40px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(135deg, var(--accent), #4f46e5);
            color: white;
            border: none;
            padding: 14px 28px;
            border-radius: var(--radius-xl);
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            box-shadow: var(--shadow-lg);
            transition: all 0.3s ease;
            z-index: 2001;
            display: flex;
            align-items: center;
            gap: 10px;
            animation: splashPulse 2s ease-in-out infinite;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }

        .splash-login-btn:hover {
            background: linear-gradient(135deg, var(--accent-hover), #6366f1);
            transform: translateX(-50%) translateY(-2px);
            box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
        }

        @keyframes splashPulse {
            0%, 100% {
                transform: translateX(-50%) scale(1);
                box-shadow: var(--shadow-lg);
            }
            50% {
                transform: translateX(-50%) scale(1.05);
                box-shadow: var(--shadow-lg), 0 0 30px var(--accent-glow);
            }
        }

        /* Splash button icon animation */
        .splash-login-btn span {
            display: inline-block;
            animation: iconBounce 1.5s ease-in-out infinite;
        }

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

        /* Auth modal content adjustments */
        .auth-modal .modal-content {
            margin-top: 10px;
        }

        .modal h2 {
            margin: 0 0 8px 0;
            font-size: 20px;
            font-weight: 600;
        }

        .modal p {
            margin: 0 0 20px 0;
            color: var(--text-secondary);
            font-size: 14px;
            line-height: 1.6;
        }

        .modal .feature-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 24px;
        }

        .modal .feature {
            display: flex;
            align-items: center;
            gap: 14px;
            font-size: 13px;
            padding: 12px;
            background: var(--bg-tertiary);
            border-radius: var(--radius-md);
        }

        .modal .feature .icon {
            width: 32px;
            height: 32px;
            background: var(--accent-glow);
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
        }

        /* Preset Buttons */
        .preset-buttons {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .preset-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all 0.2s ease;
            text-align: left;
        }

        .preset-btn:hover {
            background: var(--bg-secondary);
            border-color: var(--accent);
            transform: translateX(4px);
        }

        .preset-icon {
            font-size: 18px;
            width: 28px;
            text-align: center;
        }

        .preset-name {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .preset-desc {
            font-size: 10px;
            color: var(--text-muted);
            margin-left: auto;
        }

        /* Stat hints */
        .stat-hint {
            font-size: 10px;
            color: var(--text-muted);
            margin-top: 6px;
        }

        /* Suggestions list */
        .suggestions-list {
            display: grid;
            gap: 12px;
        }

        /* Imaging Details Dropdown */
        .stat-card.expandable {
            cursor: pointer;
            transition: background 0.2s;
        }

        .stat-card.expandable:hover {
            background: rgba(255, 255, 255, 0.05);
        }

        .expand-icon {
            margin-left: auto;
            font-size: 0.8em;
            opacity: 0.5;
            transition: transform 0.3s;
        }

        .stat-card.expanded .expand-icon {
            transform: rotate(180deg);
        }

        .imaging-details {
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid var(--panel-border);
            animation: slideDown 0.3s ease-out;
            font-size: 0.85em;
            color: var(--text-secondary);
            display: grid;
            gap: 6px;
        }

        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateY(-5px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .detail-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .detail-icon {
            width: 16px;
            text-align: center;
        }

        .suggestion-card {
            background: var(--bg-tertiary);
            border-radius: var(--radius-md);
            padding: 14px;
            border: 1px solid transparent;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .suggestion-card:hover {
            border-color: var(--accent);
            transform: translateX(4px);
        }

        .suggestion-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }

        .suggestion-name {
            font-weight: 600;
            font-size: 13px;
        }

        .suggestion-score {
            font-family: 'JetBrains Mono', monospace;
            font-size: 12px;
            font-weight: 600;
            padding: 2px 8px;
            border-radius: 12px;
        }

        .suggestion-score.excellent {
            background: var(--success-bg);
            color: var(--success);
        }

        .suggestion-score.good {
            background: var(--warning-bg);
            color: var(--warning);
        }

        .suggestion-score.fair {
            background: var(--danger-bg);
            color: var(--danger);
        }

        .suggestion-desc {
            font-size: 11px;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .suggestion-theory {
            font-size: 10px;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Soundstage Legend */
        /* Bottom Legend Container */
        .bottom-legend-container {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            gap: 12px;
            align-items: center;
            z-index: 1001;
            pointer-events: none; /* Let clicks pass through if not on a legend */
        }

        /* Soundstage Legend - Now relative to container */
        .soundstage-legend {
            /* Reset fixed positioning */
            position: relative;
            bottom: auto;
            left: auto;
            transform: none;
            
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 0 20px; /* Horizontal padding only initially */
            border-radius: var(--radius-xl);
            border: 1px solid var(--panel-border);
            box-shadow: var(--shadow-lg);
            display: flex;
            gap: 20px;
            align-items: center;
            
            /* Animation properties */
            max-height: 0;
            opacity: 0;
            margin: 0;
            overflow: hidden; /* Hide content when closed */
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            pointer-events: auto; /* Re-enable clicks */
            visibility: visible; /* Always visible for transition */
        }

        .soundstage-legend.show {
            opacity: 1;
            max-height: 60px; /* Enough for content + vertical padding */
            padding: 12px 20px; /* Add vertical padding when shown */
            margin-top: 0;
            transform: scale(1);
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: var(--text-secondary);
        }

        .legend-color {
            width: 12px;
            height: 12px;
            border-radius: 3px;
        }

        .legend-green {
            background: rgba(0, 255, 100, 0.6);
            border: 1px solid rgba(0, 255, 100, 0.8);
        }

        .legend-lime {
            background: rgba(100, 255, 0, 0.5);
            border: 1px solid rgba(100, 255, 0, 0.7);
        }

        .legend-yellow {
            background: rgba(255, 255, 0, 0.4);
            border: 1px solid rgba(255, 255, 0, 0.6);
        }

        .legend-orange {
            background: rgba(255, 140, 0, 0.4);
            border: 1px solid rgba(255, 140, 0, 0.6);
        }

        .legend-red {
            background: rgba(220, 20, 60, 0.4);
            border: 1px solid rgba(220, 20, 60, 0.6);
        }

        .legend-divider {
            width: 1px;
            height: 16px;
            background: var(--panel-border);
        }

        /* Analysis Panel */
        .analysis-panel {
            position: fixed;
            top: 0;
            left: -320px;
            /* Hidden */
            width: 320px;
            height: 100vh;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border-right: 1px solid var(--panel-border);
            box-shadow: var(--shadow-lg);
            z-index: 1050;
            /* Above HUD (90) and Legend (1001) */
            transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            max-width: 80%;
            /* Prevent panel from being too wide on small screens */
        }

        /* Sidebar Toggle Button */
        .sidebar-toggle {
            position: fixed;
            top: 16px;
            left: 16px;
            width: 42px;
            height: 42px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            color: var(--text-primary);
            border-radius: var(--radius-lg);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            box-shadow: var(--shadow-md);
            z-index: 100;
            transition: all 0.2s ease;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }

        .sidebar-toggle:hover {
            transform: scale(1.05);
            box-shadow: var(--shadow-lg);
        }

        .sidebar-toggle.show {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .analysis-panel.open {
            left: 0;
        }
        
        /* Adjust canvas when panel is open */
        body .analysis-panel.open ~ #canvas-wrapper {
            left: 320px;
            width: calc(100% - 320px);
        }
        
        /* Ensure HUD stays visible when panel is open */
        body .analysis-panel.open .hud {
            left: 340px;
            z-index: 1100;
            /* Above analysis panel */
        }
        
        /* Adjust toolbar position when panel is open */
        body .analysis-panel.open .toolbar {
            left: 55%;
            /* Shift right to avoid panel */
        }

        .canvas-container-sm {
            background: #18181b;
            border-radius: 6px;
            padding: 10px;
            margin-top: 8px;
            display: flex;
            justify-content: center;
            border: 1px solid var(--panel-border);
        }

        .stat-hint strong {
            color: var(--text-primary);
            font-weight: 600;
        }

        .panel-header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--panel-border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .panel-header h2 {
            margin: 0;
            font-size: 15px;
            font-weight: 600;
            letter-spacing: 0.02em;
            margin-right: 16px;
            /* Give space to the button */
        }

        .close-btn {
            width: 32px;
            /* Slightly larger */
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-tertiary);
            /* Subtle background even when not hovered */
            border: 1px solid var(--panel-border);
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            /* More visible default color */
            font-size: 20px;
            /* Larger 'x' */
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
            /* Prevent it from shrinking */
        }

        .close-btn:hover {
            background: var(--accent);
            /* Accent color on hover */
            color: white;
            /* White text on hover */
            border-color: var(--accent);
            /* Accent border on hover */
            box-shadow: 0 0 0 4px var(--accent-glow);
            /* Subtle glow */
        }

        .panel-content {
            padding: 20px;
            overflow-y: auto;
            flex: 1;
            max-height: calc(100vh - 100px);
        }

        .analysis-block {
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .analysis-block h3 {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            margin: 0 0 12px 0;
        }

        .stat-row-detailed {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            font-size: 13px;
        }

        .bar-container {
            width: 100%;
            height: 4px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 2px;
            margin-top: 4px;
            overflow: hidden;
        }

        .bar {
            height: 100%;
            background: var(--accent);
            width: 0%;
            transition: width 0.5s ease;
        }

        .issue-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .issue-item {
            display: flex;
            gap: 8px;
            align-items: start;
            font-size: 12px;
            color: var(--warning);
            background: rgba(245, 158, 11, 0.1);
            padding: 8px;
            border-radius: 4px;
        }

        .issue-item.severe {
            color: var(--danger);
            background: rgba(239, 68, 68, 0.1);
        }

        .empty-state {
            color: var(--success);
            font-size: 12px;
            font-style: italic;
        }

        .stat-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .stat-grid .label {
            font-size: 10px;
            color: var(--text-muted);
        }

        .stat-grid .val {
            font-family: 'JetBrains Mono';
            font-size: 13px;
        }

        /* Suggestion Compromise Toggle */
        .toggle-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 15px;
            font-size: 12px;
            background: var(--bg-tertiary);
            padding: 8px 12px;
            border-radius: 6px;
        }

        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 36px;
            height: 20px;
        }

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

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--grid-major);
            transition: .4s;
            border-radius: 20px;
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 16px;
            width: 16px;
            left: 2px;
            bottom: 2px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        input:checked+.slider {
            background-color: var(--accent);
        }

        input:checked+.slider:before {
            transform: translateX(16px);
        }

        /* Custom Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(99, 102, 241, 0.5);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(99, 102, 241, 0.7);
        }

        /* Auth Specific Styles */
        .auth-modal {
            max-width: 360px;
        }

        .auth-error {
            color: var(--danger);
            font-size: 13px;
            margin: 8px 0;
            min-height: 20px;
        }

        .auth-toggle {
            margin-top: 16px;
            text-align: center;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .auth-toggle a {
            color: var(--accent);
            text-decoration: none;
            font-weight: 500;
            margin-left: 4px;
        }

        .auth-toggle a:hover {
            text-decoration: underline;
        }

        .auth-group {
            position: relative;
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--bg-tertiary);
            padding: 4px 8px;
            border-radius: var(--radius-md);
            border: 1px solid var(--panel-border);
        }

        .avatar {
            width: 24px;
            height: 24px;
            background: var(--accent);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            font-weight: 600;
        }

        .text-btn {
            font-size: 11px;
            padding: 4px 8px;
            height: auto;
            width: auto;
        }

        /* Feature Gating Styles */

        /* Locked Button State */
        .toolbar-btn.locked {
            position: relative;
            opacity: 0.7;
        }

        .toolbar-btn.locked::after {
            content: '🔒';
            position: absolute;
            top: -4px;
            right: -4px;
            font-size: 10px;
            background: var(--bg-primary);
            border-radius: 50%;
            padding: 2px;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        }

        .btn.locked {
            position: relative;
            background: var(--bg-tertiary);
            color: var(--text-muted);
            cursor: pointer;
            /* Still clickable to show modal */
        }

        .btn.locked:hover {
            background: var(--grid-major);
            color: var(--text-secondary);
        }

        .btn.locked::after {
            content: '🔒';
            margin-left: 8px;
            font-size: 12px;
        }

        /* Tier Badge */
        .hud-header .badge {
            transition: all 0.3s ease;
        }

        /* Upgrade Modal Specifics */
        .upgrade-modal {
            max-width: 600px;
            width: 95%;
            padding: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .upgrade-header {
            background: linear-gradient(135deg, var(--accent), #4f46e5);
            padding: 24px;
            text-align: center;
            color: white;
        }

        .upgrade-header h2 {
            margin: 0 0 8px 0;
            font-size: 24px;
        }

        .upgrade-header p {
            margin: 0;
            font-size: 14px;
            color: rgba(255, 255, 255, 0.9);
        }

        .upgrade-content {
            padding: 24px;
            background: var(--panel-bg);
        }

        .tier-comparison {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
            margin: 20px 0;
        }

        .tier-card {
            background: var(--bg-tertiary);
            border: 1px solid var(--panel-border);
            border-radius: var(--radius-md);
            padding: 16px;
            text-align: center;
        }

        .tier-card.highlight {
            border-color: var(--accent);
            background: rgba(99, 102, 241, 0.05);
            transform: scale(1.02);
            box-shadow: var(--shadow-md);
        }

        .tier-name {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-muted);
            margin-bottom: 8px;
        }

        .tier-price {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 16px;
        }

        .tier-features {
            list-style: none;
            padding: 0;
            margin: 0;
            text-align: left;
            font-size: 13px;
            color: var(--text-secondary);
        }

        .tier-features li {
            margin-bottom: 8px;
            display: flex;
            gap: 8px;
        }

        .tier-features li::before {
            content: "✓";
            color: var(--success);
            font-weight: bold;
        }

        .tier-features li.missing {
            color: var(--text-muted);
            text-decoration: line-through;
            opacity: 0.6;
        }

        .tier-features li.missing::before {
            content: "×";
            color: var(--text-muted);
        }

        .upgrade-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            margin-top: 24px;
            border-top: 1px solid var(--panel-border);
            padding-top: 16px;
        }

        /* Mobile Responsive Styles */
        @media (max-width: 768px) {
            .analysis-panel {
                display: none !important;
            }
            
            .sidebar-toggle.show {
                display: block;
            }
            
            .analysis-panel.mobile-open {
                display: flex !important;
                left: 0;
                width: 100% !important;
                max-width: 100% !important;
            }
            
            body .analysis-panel.mobile-open ~ #canvas-wrapper {
                left: 0;
                width: 100%;
            }
            
            body .analysis-panel.mobile-open .hud {
                left: 16px;
                z-index: 1100;
            }
            
            body .analysis-panel.mobile-open .toolbar {
                left: 50%;
            }
        }