/* ============================================================
           GLOBAL RESET & DESIGN TOKENS — BLACKISH THEME
           ============================================================ */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        :root {
            --bg-deep: #000000;
            --bg-editor: #0a0a0a;
            --bg-sidebar: #0f0f0f;
            --bg-tab-active: #0a0a0a;
            --bg-tab-inactive: #151515;
            --bg-titlebar: #0f0f0f;
            --bg-statusbar: #0a0a0a;
            --bg-input: #1a1a1a;
            --bg-hover: #1a1a1a;
            --bg-selection: #264f78;

            --border-subtle: #1f1f1f;
            --border-panel: #2a2a2a;

            --text-primary: #e0e0e0;
            --text-secondary: #b0b0b0;
            --text-muted: #707070;
            --text-dim: #505050;

            --accent-blue: #4a9eff;
            --accent-green: #4ec9b0;
            --accent-yellow: #dcdcaa;
            --accent-red: #f44747;

            --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', 'Consolas', 'Monaco', monospace;
            --font-ui: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, sans-serif;

            --radius-sm: 4px;
            --radius-md: 6px;
            --transition-fast: 0.1s ease;
            --transition-normal: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.8);

            --line-height: 1.65;
            --font-size-code: 13.5px;
        }

        html, body {
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: var(--font-ui);
            background: var(--bg-deep);
            color: var(--text-primary);
            font-size: 13px;
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
            display: flex;
            flex-direction: column;
        }

        /* ============================================================
           TOP MENU BAR
           ============================================================ */
        .menubar {
            display: flex;
            align-items: center;
            height: 34px;
            background: var(--bg-titlebar);
            border-bottom: 1px solid var(--border-subtle);
            padding: 0 12px;
            flex-shrink: 0;
            user-select: none;
        }

        .menubar .logo {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0 12px 0 2px;
            font-weight: 600;
            font-size: 12.5px;
            color: var(--text-primary);
            letter-spacing: 0.3px;
        }

        .menubar .logo .logo-icon {
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #4a9eff, #4ec9b0);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            color: #000;
            font-weight: 800;
            box-shadow: 0 0 10px rgba(74, 158, 255, 0.4);
        }

        .menubar .logo .brand {
            font-weight: 700;
            color: var(--text-primary);
        }

        .menubar .logo .brand-accent {
            color: var(--accent-blue);
            font-weight: 600;
            font-size: 11px;
            margin-left: 2px;
            padding: 1px 6px;
            background: rgba(74, 158, 255, 0.12);
            border-radius: 99px;
        }

        .menubar .spacer { flex: 1; }

        /* ============================================================
           DOWNLOAD BUTTON
           ============================================================ */
        .download-btn {
            display: flex;
            align-items: center;
            gap: 7px;
            background: linear-gradient(135deg, #4a9eff, #3a7bcc);
            color: #ffffff;
            border: none;
            padding: 0 16px;
            height: 26px;
            border-radius: var(--radius-md);
            font-family: var(--font-ui);
            font-size: 12.5px;
            font-weight: 600;
            letter-spacing: 0.3px;
            cursor: pointer;
            transition: all var(--transition-fast);
            box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
        }

        .download-btn:hover {
            background: linear-gradient(135deg, #5aadff, #4a8bdc);
            box-shadow: 0 4px 14px rgba(74, 158, 255, 0.5);
            transform: translateY(-1px);
        }

        .download-btn:active {
            transform: translateY(0) scale(0.97);
            box-shadow: 0 2px 6px rgba(74, 158, 255, 0.4);
        }

        .download-btn .dl-icon {
            font-size: 14px;
            line-height: 1;
        }

        /* ============================================================
           MAIN IDE LAYOUT
           ============================================================ */
        .ide-container {
            flex: 1;
            display: flex;
            overflow: hidden;
            background: var(--bg-editor);
        }

        .main-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background: var(--bg-editor);
            min-width: 0;
        }

        /* ============================================================
           TAB BAR
           ============================================================ */
        .tabs-container {
            display: flex;
            background: var(--bg-tab-inactive);
            border-bottom: 1px solid var(--border-subtle);
            flex-shrink: 0;
            overflow-x: auto;
            scrollbar-width: none;
            height: 38px;
        }

        .tabs-container::-webkit-scrollbar { display: none; }

        .editor-tab {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0 22px;
            height: 38px;
            background: var(--bg-tab-inactive);
            border: none;
            border-right: 1px solid var(--border-subtle);
            border-top: 1px solid transparent;
            color: var(--text-muted);
            font-size: 13px;
            font-family: var(--font-mono);
            cursor: pointer;
            transition: all var(--transition-fast);
            white-space: nowrap;
            position: relative;
            flex-shrink: 0;
        }

        .editor-tab:hover {
            background: var(--bg-tab-active);
            color: var(--text-primary);
        }

        .editor-tab.active {
            background: var(--bg-tab-active);
            color: white;
            border-top-color: var(--accent-blue);
        }

        .editor-tab.active::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            right: 0;
            height: 1px;
            background: var(--bg-tab-active);
        }

        .editor-tab .tab-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .editor-tab .tab-dot.html { background: #e44d26; }
        .editor-tab .tab-dot.css { background: #264de4; }
        .editor-tab .tab-dot.js { background: #f7df1e; }
        .editor-tab .tab-dot.preview { background: #4ec9b0; }

        .tabs-container .spacer {
            flex: 1;
            background: var(--bg-tab-inactive);
        }

        .tabs-container .tab-actions {
            display: flex;
            align-items: center;
            padding: 0 10px;
            gap: 6px;
            background: var(--bg-tab-inactive);
        }

        .tabs-container .tab-action-btn {
            width: 30px;
            height: 26px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-fast);
        }

        .tabs-container .tab-action-btn:hover {
            background: rgba(255, 255, 255, 0.08);
            color: white;
        }

        /* ============================================================
           PANELS CONTAINER
           ============================================================ */
        .panels-container {
            flex: 1;
            position: relative;
            overflow: hidden;
        }

        .panel {
            position: absolute;
            inset: 0;
            display: none;
            flex-direction: column;
            background: var(--bg-editor);
            opacity: 0;
            transition: opacity var(--transition-normal);
        }

        .panel.active {
            display: flex;
            opacity: 1;
        }

        /* ============================================================
           BREADCRUMB
           ============================================================ */
        .breadcrumb {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 5px 16px;
            font-size: 12px;
            color: var(--text-muted);
            background: var(--bg-editor);
            border-bottom: 1px solid var(--border-subtle);
            font-family: var(--font-mono);
            flex-shrink: 0;
        }

        .breadcrumb .crumb {
            color: var(--text-secondary);
            cursor: pointer;
        }

        .breadcrumb .crumb:hover {
            color: white;
        }

        .breadcrumb .separator {
            color: var(--text-dim);
        }

        .breadcrumb .crumb.active {
            color: var(--text-primary);
        }

        /* ============================================================
           EDITOR BODY WITH LINE NUMBERS
           ============================================================ */
        .editor-body {
            flex: 1;
            display: flex;
            overflow: hidden;
            position: relative;
            background: var(--bg-editor);
        }

        .line-numbers {
            width: 60px;
            background: var(--bg-editor);
            color: #404040;
            text-align: right;
            font-family: var(--font-mono);
            font-size: var(--font-size-code);
            line-height: var(--line-height);
            user-select: none;
            overflow: hidden;
            flex-shrink: 0;
            border-right: 1px solid transparent;
            transition: border-color var(--transition-fast);
            padding: 12px 14px 12px 0;
            position: relative;
        }

        .editor-body:focus-within .line-numbers {
            border-right-color: var(--border-subtle);
        }

        .line-numbers .line-num {
            display: block;
            height: calc(var(--font-size-code) * var(--line-height));
            line-height: calc(var(--font-size-code) * var(--line-height));
        }

        textarea.code-input {
            flex: 1;
            background: var(--bg-editor);
            border: none;
            outline: none;
            resize: none;
            color: var(--text-primary);
            font-family: var(--font-mono);
            font-size: var(--font-size-code);
            line-height: var(--line-height);
            padding: 12px 16px;
            tab-size: 2;
            white-space: pre;
            overflow: auto;
            caret-color: var(--accent-blue);
            scrollbar-width: thin;
            scrollbar-color: #2a2a2a var(--bg-editor);
            margin: 0;
            letter-spacing: normal;
        }

        textarea.code-input::placeholder {
            color: var(--text-dim);
            font-style: italic;
        }

        textarea.code-input::-webkit-scrollbar {
            width: 14px;
            height: 14px;
        }

        textarea.code-input::-webkit-scrollbar-track {
            background: var(--bg-editor);
        }

        textarea.code-input::-webkit-scrollbar-thumb {
            background: #2a2a2a;
            border-radius: 7px;
            border: 3px solid var(--bg-editor);
        }

        textarea.code-input::-webkit-scrollbar-thumb:hover {
            background: #3a3a3a;
        }

        textarea.code-input::selection {
            background: var(--bg-selection);
        }

        /* ============================================================
           PREVIEW PANEL — WIDE, SPACIOUS, SCROLLABLE
           ============================================================ */
        .preview-header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 7px 16px;
            background: var(--bg-sidebar);
            border-bottom: 1px solid var(--border-subtle);
            flex-shrink: 0;
        }

        .preview-url {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--bg-input);
            border: 1px solid var(--border-panel);
            border-radius: 99px;
            padding: 4px 14px;
            font-size: 12px;
            font-family: var(--font-mono);
            color: var(--text-secondary);
            height: 26px;
            min-width: 0;
        }

        .preview-url .lock-icon {
            color: var(--accent-green);
            font-size: 11px;
            flex-shrink: 0;
        }

        .preview-url .url-text {
            color: var(--text-secondary);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .preview-status {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            color: var(--text-muted);
            font-family: var(--font-mono);
            flex-shrink: 0;
        }

        .preview-status .live-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--accent-green);
            box-shadow: 0 0 8px rgba(78, 201, 176, 0.8);
            animation: livePulse 1.8s ease-in-out infinite;
        }

        @keyframes livePulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.5; transform: scale(0.85); }
        }

        /* Preview control buttons */
        .preview-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(74, 158, 255, 0.1);
            border: 1px solid rgba(74, 158, 255, 0.3);
            color: var(--accent-blue);
            padding: 0 12px;
            height: 26px;
            border-radius: var(--radius-md);
            font-family: var(--font-ui);
            font-size: 11.5px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            flex-shrink: 0;
            letter-spacing: 0.2px;
            white-space: nowrap;
        }

        .preview-btn:hover {
            background: rgba(74, 158, 255, 0.2);
            border-color: rgba(74, 158, 255, 0.5);
            color: #7cc0ff;
            transform: translateY(-1px);
        }

        .preview-btn:active {
            transform: translateY(0) scale(0.97);
        }

        .preview-btn .btn-icon {
            font-size: 12px;
            line-height: 1;
        }

        /* Scrollable preview frame */
        .preview-frame-wrapper {
            flex: 1;
            position: relative;
            background: #ffffff;
            overflow: auto;
            width: 100%;
            -webkit-overflow-scrolling: touch;
        }

        .preview-frame-wrapper::-webkit-scrollbar {
            width: 14px;
            height: 14px;
        }

        .preview-frame-wrapper::-webkit-scrollbar-track {
            background: #1a1a1a;
        }

        .preview-frame-wrapper::-webkit-scrollbar-thumb {
            background: #3a3a3a;
            border-radius: 7px;
            border: 3px solid #1a1a1a;
        }

        .preview-frame-wrapper::-webkit-scrollbar-thumb:hover {
            background: #4a4a4a;
        }

        #previewFrame {
            width: 100%;
            height: 100%;
            border: none;
            display: block;
            background: #ffffff;
        }

        /* ============================================================
           PREVIEW FULLSCREEN MODE
           ============================================================ */
        .preview-fullscreen-overlay {
            position: fixed;
            inset: 0;
            background: #000;
            z-index: 99999;
            display: none;
            flex-direction: column;
        }

        .preview-fullscreen-overlay.active {
            display: flex;
        }

        .preview-fullscreen-overlay .fs-toolbar {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 18px;
            background: var(--bg-titlebar);
            border-bottom: 1px solid var(--border-subtle);
            flex-shrink: 0;
        }

        .preview-fullscreen-overlay .fs-title {
            display: flex;
            align-items: center;
            gap: 8px;
            font-family: var(--font-mono);
            font-size: 12.5px;
            color: var(--text-secondary);
        }

        .preview-fullscreen-overlay .fs-title .fs-live-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--accent-green);
            box-shadow: 0 0 8px rgba(78, 201, 176, 0.8);
            animation: livePulse 1.8s ease-in-out infinite;
        }

        .preview-fullscreen-overlay .fs-spacer { flex: 1; }

        .preview-fullscreen-overlay .fs-exit-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(244, 71, 71, 0.12);
            border: 1px solid rgba(244, 71, 71, 0.35);
            color: #ff7a7a;
            padding: 0 14px;
            height: 30px;
            border-radius: var(--radius-md);
            font-family: var(--font-ui);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            letter-spacing: 0.2px;
        }

        .preview-fullscreen-overlay .fs-exit-btn:hover {
            background: rgba(244, 71, 71, 0.25);
            border-color: rgba(244, 71, 71, 0.6);
            color: #ff9b9b;
        }

        /* Fullscreen scrollable iframe wrapper */
        .preview-fullscreen-overlay .fs-frame-wrap {
            flex: 1;
            background: #ffffff;
            position: relative;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
        }

        .preview-fullscreen-overlay .fs-frame-wrap::-webkit-scrollbar {
            width: 16px;
            height: 16px;
        }

        .preview-fullscreen-overlay .fs-frame-wrap::-webkit-scrollbar-track {
            background: #1a1a1a;
        }

        .preview-fullscreen-overlay .fs-frame-wrap::-webkit-scrollbar-thumb {
            background: #3a3a3a;
            border-radius: 8px;
            border: 3px solid #1a1a1a;
        }

        .preview-fullscreen-overlay .fs-frame-wrap::-webkit-scrollbar-thumb:hover {
            background: #4a4a4a;
        }

        .preview-fullscreen-overlay #fullscreenFrame {
            width: 100%;
            height: 100%;
            border: none;
            display: block;
            background: #ffffff;
        }

        /* ============================================================
           STATUS BAR
           ============================================================ */
        .status-bar {
            display: flex;
            align-items: center;
            height: 24px;
            background: var(--bg-statusbar);
            color: var(--text-secondary);
            font-size: 11.5px;
            padding: 0 14px;
            gap: 16px;
            flex-shrink: 0;
            font-family: var(--font-ui);
            user-select: none;
            border-top: 1px solid var(--border-subtle);
        }

        .status-bar .status-item {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 0 6px;
            height: 100%;
            cursor: default;
            transition: background var(--transition-fast);
            border-radius: 3px;
        }

        .status-bar .status-item:hover {
            background: rgba(255, 255, 255, 0.06);
        }

        .status-bar .status-item .icon {
            font-size: 12px;
        }

        .status-bar .spacer { flex: 1; }

        .status-bar .status-accent {
            background: rgba(74, 158, 255, 0.12);
            color: var(--accent-blue);
            padding: 0 10px;
            border-radius: 3px;
            font-weight: 600;
            font-size: 11px;
        }

        /* ============================================================
           TOAST
           ============================================================ */
        .toast {
            position: fixed;
            bottom: 40px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background: var(--bg-sidebar);
            border: 1px solid var(--border-panel);
            color: var(--text-primary);
            padding: 10px 20px;
            border-radius: var(--radius-md);
            font-size: 12.5px;
            box-shadow: var(--shadow-lg);
            opacity: 0;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 100000;
            pointer-events: none;
            display: flex;
            align-items: center;
            gap: 10px;
            font-family: var(--font-ui);
            min-width: 200px;
            max-width: 90vw;
        }

        .toast.show {
            transform: translateX(-50%) translateY(0);
            opacity: 1;
        }

        .toast .toast-icon {
            color: var(--accent-green);
            font-size: 16px;
            flex-shrink: 0;
        }

        /* ============================================================
           SCROLLBARS (GLOBAL)
           ============================================================ */
        ::-webkit-scrollbar {
            width: 14px;
            height: 14px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: #2a2a2a;
            border-radius: 7px;
            border: 3px solid var(--bg-editor);
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #3a3a3a;
        }

        /* ============================================================
           ANIMATIONS
           ============================================================ */
        @keyframes slideIn {
            from { opacity: 0; transform: translateY(-4px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .panel.active .editor-body {
            animation: slideIn 0.15s ease;
        }

        /* ============================================================
           RESPONSIVE
           ============================================================ */
        @media (max-width: 700px) {
            .menubar .logo .brand-accent { display: none; }
            .download-btn .dl-text { display: none; }
            .download-btn { padding: 0 10px; }
            .preview-btn .btn-text { display: none; }
            .preview-btn { padding: 0 8px; }
        }