:root {
            --bg: #000000;
            --fg: #ffffff;
            --accents-1: #111;
            --accents-2: #333;
            --accents-8: #888;
            --border: rgba(255, 255, 255, 0.15);
            --border-hover: rgba(255, 255, 255, 0.4);
            --ui-blur: blur(20px);
            --font-sans: 'Inter', sans-serif;
            --font-mono: 'JetBrains Mono', monospace;
            --panel-width: 380px;
        }

        * { box-sizing: border-box; outline: none; -webkit-font-smoothing: antialiased; }

        body, html {
            margin: 0; padding: 0; width: 100%; height: 100%;
            background-color: var(--bg); color: var(--fg);
            font-family: var(--font-sans); overflow: hidden;
        }

        /* Progress Bar */
        .render-progress {
            position: absolute; top: 0; left: 0; height: 2px;
            background: #fff; width: 0%; z-index: 20; transition: width 0.1s linear;
        }

        /* Canvas */
        #mandelbrotCanvas {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
            z-index: 1; display: block;
            image-rendering: optimizeSpeed; 
        }

        /* --- UI Layers --- */
        .ui-layer {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            z-index: 10; pointer-events: none;
            display: flex; flex-direction: column; justify-content: space-between;
            opacity: 1;
            transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        }

        body.is-idle {
            cursor: none;
        }

        body.is-idle .ui-layer {
            opacity: 0;
            transition: opacity 2.0s ease-in-out;
            pointer-events: none;
        }

        /* HEADER & BRAND */
        .header {
            padding: 24px; display: flex; justify-content: space-between; align-items: flex-start;
            pointer-events: auto;
        }

        .brand {
            font-weight: 600; font-size: 14px;
            background: rgba(0, 0, 0, 0.6); backdrop-filter: var(--ui-blur);
            padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border);
            display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
            transition: border-color 0.2s, background 0.2s;
        }
        .brand:hover { background: rgba(20,20,20,0.8); border-color: var(--border-hover); }

        /* Brand shimmer animation - 1 slow wave left to right */
        @keyframes shimmer {
            0% { background-position: -100% center; }
            100% { background-position: 200% center; }
        }
        .brand.shimmer {
            background: linear-gradient(90deg, 
                rgba(0,0,0,0.6) 0%, 
                rgba(0,0,0,0.6) 40%, 
                rgba(255,255,255,0.2) 50%, 
                rgba(0,0,0,0.6) 60%, 
                rgba(0,0,0,0.6) 100%);
            background-size: 50% 100%;
            animation: shimmer 4s ease-in-out;
        }

        /* --- BOTTOM CONTROL CLUSTER --- */
        .control-container {
            width: 100%; display: flex; flex-direction: column; align-items: center; 
            padding-bottom: 40px; pointer-events: auto; gap: 16px;
        }

        /* DOCK */
        .dock-wrapper {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            max-width: 95%;
        }
        .dock {
            background: rgba(0, 0, 0, 0.85); backdrop-filter: var(--ui-blur);
            border: 1px solid var(--border); border-radius: 12px; padding: 8px;
            display: flex; align-items: center; gap: 8px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
            transition: border-color 0.2s; width: auto;
        }
        .dock:focus-within { border-color: var(--border-hover); }
        .side-dock {
            background: rgba(0, 0, 0, 0.85); backdrop-filter: var(--ui-blur);
            border: 1px solid var(--border); border-radius: 12px; padding: 8px;
            display: flex; align-items: center; justify-content: center;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
            transition: border-color 0.2s;
        }
        .dock-wrapper:hover .dock, .dock-wrapper:hover .side-dock,
        .dock-wrapper:focus-within .dock, .dock-wrapper:focus-within .side-dock { border-color: var(--border-hover); }

        /* Discovery glow effect for dock */
        .dock-wrapper.discover-glow {
            position: relative;
        }
        .dock-wrapper.discover-glow::before {
            content: "";
            position: absolute;
            inset: -22px;
            border-radius: 18px;
            pointer-events: none;
            background:
                radial-gradient(60% 60% at 50% 46%, rgba(255,255,255,0.35), rgba(255,255,255,0) 70%),
                conic-gradient(from 0deg, rgba(255,255,255,0.35), rgba(255,255,255,0) 25%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0) 75%, rgba(255,255,255,0.35));
            filter: blur(16px);
            opacity: 0;
            transform-origin: 50% 50%;
            z-index: -1;
            mix-blend-mode: screen;
            animation: aura-spin 6.5s linear infinite;
            transition: opacity 1s ease;
        }
        .dock-wrapper.discover-glow::after {
            content: "";
            position: absolute;
            inset: -18px;
            border-radius: 16px;
            pointer-events: none;
            background: radial-gradient(60% 60% at 50% 45%, rgba(255,255,255,0.55), rgba(255,255,255,0) 65%);
            filter: blur(14px);
            opacity: 0;
            z-index: -1;
            transition: opacity 1s ease;
        }
        .dock-wrapper.discover-glow.active::before,
        .dock-wrapper.discover-glow.active::after {
            opacity: 1;
        }
        @keyframes aura-spin {
            to { transform: rotate(360deg); }
        }

        input {
            flex: 1; background: transparent; border: none; color: #fff;
            padding: 10px 12px; font-size: 15px; font-family: var(--font-sans); min-width: 200px;
        }
        input::placeholder { color: #555; }

        .divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

        button.icon-btn {
            background: transparent; border: none; color: var(--accents-8);
            cursor: pointer; padding: 8px; border-radius: 6px;
            display: flex; align-items: center; justify-content: center; transition: all 0.2s;
        }
        button.icon-btn:hover { background: var(--accents-1); color: #fff; }
        button.icon-btn.active { color: #fff; background: var(--accents-2); }
        button.icon-btn.fav-active { color: #fff; }
        button.icon-btn.fav-active svg { fill: currentColor; }

        .btn-primary {
            background: #fff; color: #000; border: none; font-weight: 500;
            font-size: 14px; padding: 8px 16px; border-radius: 6px;
            cursor: pointer; transition: transform 0.1s, background 0.2s; white-space: nowrap;
        }
        .btn-primary:hover { background: #e6e6e6; }
        .btn-primary:active { transform: scale(0.96); }

        .btn-apply {
            width: 100%; margin-top: 20px; background: #fff; color: #000; height: 40px;
            font-weight: 600; border: none; border-radius: 6px; cursor: pointer;
        }
        .btn-apply:hover { background: #ddd; }

        /* BOTTOM INFO */
        .bottom-info {
            display: flex; flex-direction: column; align-items: center; gap: 6px;
            text-shadow: 0 2px 4px rgba(0,0,0,1), 0 1px 2px rgba(0,0,0,0.8);
            pointer-events: none;
        }
        .info-coords {
            font-family: var(--font-mono); font-size: 13px; color: #fff; opacity: 0.95;
            display: flex; align-items: center; gap: 10px;
        }
        .copy-link-btn {
            background: transparent;
            border: none;
            color: var(--accents-8);
            cursor: pointer;
            padding: 2px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            pointer-events: auto;
        }
        .copy-link-btn svg {
            width: 14px;
            height: 14px;
        }
        .copy-link-btn:hover {
            color: #fff;
            background: rgba(255,255,255,0.1);
        }
        .copy-link-btn.copied {
            color: #4ade80;
        }
        .info-founder {
            font-family: var(--font-sans); font-size: 11px; color: var(--accents-8); 
            text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500;
            display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
            text-align: center;
        }
        .founder-hl { color: #fff; border-bottom: 1px solid rgba(255,255,255,0.3); padding-bottom: 1px; }
        .founder-id-clickable { 
            cursor: pointer !important; 
            pointer-events: auto !important;
            transition: all 0.2s; 
            text-decoration: underline;
            user-select: none;
        }
        .founder-id-clickable:hover { 
            border-bottom-color: #fff; 
            background: rgba(255,255,255,0.15);
        }

        /* --- SIDE PANELS (Win 8 Style) --- */
        .side-panel {
            position: fixed; top: 0; right: 0; width: var(--panel-width); height: 100%;
            background: rgba(0, 0, 0, 0.95); backdrop-filter: blur(40px);
            border-left: 1px solid var(--border);
            z-index: 100; transform: translateX(100%); 
            transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
            display: flex; flex-direction: column; 
            box-shadow: none;
            pointer-events: auto; max-width: 85vw;
            opacity: 1;
        }
        body.preload .side-panel { transition: none !important; }
        .side-panel.open { transform: translateX(0); box-shadow: -20px 0 60px rgba(0,0,0,0.8); }
        body.is-idle .side-panel { opacity: 0; }

        .panel-header {
            padding: 24px; border-bottom: 1px solid var(--accents-1);
            display: flex; justify-content: space-between; align-items: center;
            font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
        }
        .panel-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px; }
        .panel-content::-webkit-scrollbar { width: 6px; }
        .panel-content::-webkit-scrollbar-track { background: transparent; }
        .panel-content::-webkit-scrollbar-thumb { 
            background: var(--accents-2); 
            border-radius: 3px; 
            border: 1px solid var(--border);
        }
        .panel-content::-webkit-scrollbar-thumb:hover { 
            background: var(--accents-8); 
            border-color: var(--border-hover);
        }
        .panel-content { scrollbar-width: thin; scrollbar-color: var(--accents-2) transparent; }
        
        .panel-footer { padding: 20px; border-top: 1px solid var(--accents-1); font-size: 12px; color: var(--accents-8); text-align: center; }

        /* Auth Styles */
        .auth-card {
            background: var(--accents-1); border: 1px solid var(--border);
            border-radius: 8px; padding: 20px; text-align: center; margin-bottom: 24px;
        }
        .id-badge {
            font-family: var(--font-mono); font-size: 20px; color: #fff; 
            margin: 10px 0; display: block; letter-spacing: 1px;
        }
        .input-box {
            background: #000; border: 1px solid var(--accents-2); color: #fff;
            width: 100%; padding: 10px; border-radius: 6px; margin-bottom: 10px;
            font-family: var(--font-mono); text-align: center;
        }
        .stats-grid {
            display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 24px;
        }
        .stat-item {
            background: var(--accents-1); padding: 12px; border-radius: 6px; text-align: center; border: 1px solid rgba(255,255,255,0.05);
            cursor: pointer; transition: all 0.2s;
        }
        .stat-item:hover { background: var(--accents-2); border-color: rgba(255,255,255,0.15); }
        .stat-item.active { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
        .stat-val { font-size: 18px; font-weight: 600; display: block; margin-bottom: 2px; }
        .stat-lbl { font-size: 10px; text-transform: uppercase; color: var(--accents-8); }
        
        /* Fav Items */
        .fav-header { font-size: 11px; text-transform: uppercase; color: var(--accents-8); font-weight: 700; margin-bottom: 12px; letter-spacing: 0.5px; }
        .fav-item {
            padding: 12px; margin: 0 -10px; border-bottom: 1px solid var(--accents-1);
            cursor: pointer; transition: background 0.2s; padding-left: 12px; border-radius: 4px; color: #ddd; font-size: 14px;
            display: flex; justify-content: space-between; align-items: center;
        }
        .fav-item:hover { background: var(--accents-1); color: white; }
        .fav-item-content {
            flex: 1;
            min-width: 0;
        }
        .fav-item-delete {
            background: transparent;
            border: none;
            color: var(--accents-8);
            cursor: pointer;
            padding: 6px;
            margin-left: 8px;
            border-radius: 4px;
            opacity: 0;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .fav-item:hover .fav-item-delete {
            opacity: 1;
        }
        .fav-item-delete:hover {
            color: #ff4444;
            background: rgba(255,68,68,0.1);
        }

        /* Settings UI */
        .setting-group { margin-bottom: 24px; }
        .setting-label {
            font-size: 11px; color: var(--accents-8); text-transform: uppercase;
            letter-spacing: 0.5px; margin-bottom: 10px; font-weight: 700;
        }
        .control-row {
            display: flex; justify-content: space-between; align-items: center;
            margin-bottom: 14px; margin-top: 14px;
        }
        .control-row span { font-size: 14px; color: #d0d0d0; }

        select {
            background: var(--accents-1); color: #fff; border: 1px solid var(--border);
            padding: 6px 10px; border-radius: 6px; font-family: var(--font-sans);
            font-size: 13px; cursor: pointer; outline: none; width: 140px;
        }
        select:focus { border-color: #666; }

        .switch { position: relative; display: inline-block; width: 40px; height: 22px; 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: var(--accents-2); transition: .2s; border-radius: 34px;
        }
        .slider:before {
            position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
            background-color: white; transition: .2s; border-radius: 50%;
        }
        input:checked + .slider { background-color: var(--accents-8); }
        input:checked + .slider:before { transform: translateX(18px); background-color: #fff; }

        /* --- INFO MODAL --- */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6); backdrop-filter: blur(10px);
            z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s;
            display: flex; align-items: center; justify-content: center;
        }
        .modal-overlay.open { opacity: 1; pointer-events: auto; }
        
        .info-modal {
            background: #000; border: 1px solid var(--border); border-radius: 12px;
            width: 420px; max-width: 90vw; padding: 30px;
            box-shadow: 0 40px 80px rgba(0,0,0,0.8);
            transform: scale(0.95); transition: transform 0.3s;
        }
        .modal-overlay.open .info-modal { transform: scale(1); }
        .modal-desc { line-height: 1.6; color: #ccc; font-size: 14px; margin-bottom: 24px; border-bottom: 1px solid var(--accents-1); padding-bottom: 24px; }
        .modal-links a { display: inline-block; color: #fff; text-decoration: none; margin-right: 16px; font-size: 13px; font-weight: 500;}
        .modal-links a:hover { text-decoration: underline; }
        .coffee-btn { display: inline-block; background: #fff; color: #000 !important; padding: 6px 12px; border-radius: 4px; font-size: 13px; font-weight: 500; text-decoration: none; }
        .coffee-btn:hover { background: #e6e6e6; color: #000 !important; }
        .modal-links { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
        .modal-links .social-links { display: flex; gap: 16px; }

        /* --- EXPORT SCALE MENU --- */
        .export-menu {
            position: absolute;
            bottom: calc(100% + 12px);
            left: 50%;
            transform: translateX(-50%) scale(0.95);
            background: rgba(0, 0, 0, 0.95);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 8px;
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 120px;
            opacity: 0;
            pointer-events: none;
            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
            z-index: 100;
        }
        .export-menu.open {
            opacity: 1;
            pointer-events: auto;
            transform: translateX(-50%) scale(1);
        }
        .export-menu-item {
            background: transparent;
            border: none;
            color: #fff;
            padding: 10px 16px;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s;
            text-align: left;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }
        .export-menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        .export-menu-item .scale-label {
            font-family: var(--font-mono);
            font-size: 12px;
            color: var(--accents-8);
        }

        /* --- EXPORT MODAL --- */
        .export-modal {
            background: #000; border: 1px solid var(--border); border-radius: 12px;
            width: 420px; max-width: 90vw; padding: 30px;
            box-shadow: 0 40px 80px rgba(0,0,0,0.8);
            transform: scale(0.95); transition: transform 0.3s;
        }
        .modal-overlay.open .export-modal { transform: scale(1); }
        
        .export-title {
            font-size: 18px; font-weight: 600; margin: 0 0 8px 0;
        }
        .export-subtitle {
            font-size: 14px; color: var(--accents-8); margin: 0 0 24px 0;
        }
        
        .export-progress-wrapper {
            display: flex; align-items: center; gap: 12px;
        }
        
        .export-progress-container {
            flex: 1;
            height: 40px;
            background: rgba(0, 0, 0, 0.85); 
            backdrop-filter: blur(20px);
            border: 1px solid var(--border); 
            border-radius: 12px;
            display: flex; align-items: center;
            padding: 4px;
            position: relative;
            overflow: hidden;
        }
        
        .export-progress-bar {
            position: absolute; left: 4px; top: 4px; bottom: 4px;
            background: #fff;
            border-radius: 8px;
            width: 0%;
            transition: width 0.1s linear;
        }
        
        .export-progress-text {
            position: relative;
            z-index: 1;
            width: 100%;
            text-align: center;
            font-family: var(--font-mono);
            font-size: 14px;
            font-weight: 500;
            color: #fff;
            mix-blend-mode: difference;
        }
        
        .export-cancel-btn {
            height: 40px;
            padding: 0 20px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 12px;
            color: #fff;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            backdrop-filter: blur(20px);
        }
        .export-cancel-btn:hover {
            background: #fff;
            color: #000;
            border-color: #fff;
        }

        /* Loading */
        .loading-overlay {
            position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
            background: rgba(0,0,0,0.9); padding: 16px 28px; border-radius: 50px;
            border: 1px solid var(--border); display: flex; align-items: center; gap: 12px;
            font-size: 14px; font-weight: 500; color: #fff; z-index: 50;
            opacity: 0; pointer-events: none; transition: opacity 0.2s;
        }
        .loading-overlay.show { opacity: 1; }

        .spinner {
            width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.2);
            border-left-color: #ffffff; border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        svg { width: 20px; height: 20px; display: block; }