/* ── Modern Premium Design System (Inter & Outfit Typography) ── */
        :root {
            --font-display: 'Outfit', 'Inter', -apple-system, sans-serif;
            --font-body: 'Inter', -apple-system, sans-serif;
            
            /* Curated Harmonies - Sleek Indigo & Royal Purple HSL Palettes */
            --primary: 243 75% 59%;       /* Indigo-600 */
            --primary-light: 242 83% 96%; /* Indigo-50 */
            --primary-hover: 243 75% 50%;
            --accent: 271 76% 53%;        /* Purple-600 */
            
            /* Slate Neutrals */
            --bg-light: 210 40% 98%;      /* Slate-50 */
            --border-light: 214 32% 91%;  /* Slate-200 */
            --text-main: 215 25% 27%;     /* Slate-700 */
            --text-muted: 215 16% 47%;    /* Slate-500 */
        }

        /* ── Frosted Glass Layout Controls (Light Theme) ── */
        header {
            background: rgba(255, 255, 255, 0.75) !important;
            backdrop-filter: blur(20px) !important;
            -webkit-backdrop-filter: blur(20px) !important;
            border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
        }
        #propertiesBar {
            background: rgba(255, 255, 255, 0.8) !important;
            backdrop-filter: blur(16px) !important;
            -webkit-backdrop-filter: blur(16px) !important;
            border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
        }
        #mobilePanelWrapper {
            background: rgba(255, 255, 255, 0.8) !important;
            backdrop-filter: blur(20px) !important;
            -webkit-backdrop-filter: blur(20px) !important;
            border-right: 1px solid rgba(226, 232, 240, 0.8) !important;
        }
        aside {
            background: rgba(15, 23, 42, 0.95) !important;
            backdrop-filter: blur(16px) !important;
            -webkit-backdrop-filter: blur(16px) !important;
            border-right: 1px solid rgba(30, 41, 59, 0.5) !important;
        }
        #projectsModal > div,
        #shortcutsModal > div,
        #settingsModal > div,
        #saveTemplateModal > div,
        #googleSetupModal > div,
        #gmailQuickModal > div,
        #otpInstructionModal > div {
            background: rgba(255, 255, 255, 0.85) !important;
            backdrop-filter: blur(24px) !important;
            -webkit-backdrop-filter: blur(24px) !important;
            border: 1px solid rgba(226, 232, 240, 0.8) !important;
            box-shadow: 0 30px 70px -10px rgba(0, 0, 0, 0.2) !important;
        }
        #projectsModal .bg-slate-50 {
            background: rgba(248, 250, 252, 0.5) !important;
        }

        /* ── Dark Mode Overrides ── */
        body[data-theme="dark"] {
            background: #090d16;
            color: #f1f5f9;
        }
        body[data-theme="dark"] header {
            background: rgba(15, 23, 42, 0.8) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            backdrop-filter: blur(20px) !important;
            -webkit-backdrop-filter: blur(20px) !important;
        }
        body[data-theme="dark"] header * {
            color: #e2e8f0 !important;
        }
        body[data-theme="dark"] header input, 
        body[data-theme="dark"] header select {
            background: rgba(30, 41, 59, 0.6) !important;
            border-color: rgba(71, 85, 105, 0.4) !important;
            color: #f1f5f9 !important;
        }
        body[data-theme="dark"] #propertiesBar {
            background: rgba(15, 23, 42, 0.85) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            color: #f1f5f9 !important;
            backdrop-filter: blur(12px) !important;
            -webkit-backdrop-filter: blur(12px) !important;
        }
        body[data-theme="dark"] #propertiesBar button, 
        body[data-theme="dark"] #propertiesBar select, 
        body[data-theme="dark"] #propertiesBar input[type="number"] {
            background: rgba(30, 41, 59, 0.6) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            color: #e2e8f0 !important;
        }
        body[data-theme="dark"] #mobilePanelWrapper {
            background: rgba(15, 23, 42, 0.85) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            backdrop-filter: blur(20px) !important;
            -webkit-backdrop-filter: blur(20px) !important;
        }
        body[data-theme="dark"] #mobilePanelWrapper * {
            color: #cbd5e1 !important;
        }
        body[data-theme="dark"] #mobilePanelWrapper input, 
        body[data-theme="dark"] #mobilePanelWrapper select, 
        body[data-theme="dark"] #mobilePanelWrapper button {
            background: rgba(30, 41, 59, 0.6) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
        }
        body[data-theme="dark"] #slideTrayBar {
            background: rgba(15, 23, 42, 0.85) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            backdrop-filter: blur(12px) !important;
        }
        body[data-theme="dark"] aside {
            background: rgba(3, 7, 18, 0.96) !important;
            border-color: rgba(31, 41, 55, 0.6) !important;
        }
        body[data-theme="dark"] .popover {
            background: rgba(15, 23, 42, 0.9) !important;
            border-color: rgba(51, 65, 85, 0.6) !important;
            color: #f1f5f9 !important;
            backdrop-filter: blur(16px) !important;
            box-shadow: 0 12px 40px rgba(0,0,0,0.5) !important;
        }
        body[data-theme="dark"] #projectsModal > div,
        body[data-theme="dark"] #shortcutsModal > div,
        body[data-theme="dark"] #settingsModal > div,
        body[data-theme="dark"] #saveTemplateModal > div,
        body[data-theme="dark"] #googleSetupModal > div,
        body[data-theme="dark"] #gmailQuickModal > div,
        body[data-theme="dark"] #otpInstructionModal > div {
            background: rgba(15, 23, 42, 0.85) !important;
            border-color: rgba(51, 65, 85, 0.4) !important;
            box-shadow: 0 30px 70px -10px rgba(0, 0, 0, 0.5) !important;
        }
        body[data-theme="dark"] #projectsModal .bg-slate-50 {
            background: rgba(30, 41, 59, 0.3) !important;
        }
        body[data-theme="dark"] #divideImagePopover {
            background: rgba(15, 23, 42, 0.95) !important;
            border-color: rgba(51, 65, 85, 0.8) !important;
        }
        body[data-theme="dark"] #divideImagePopover h4 { color: #f1f5f9 !important; }
        body[data-theme="dark"] #divideImagePopover p { color: #94a3b8 !important; }
        body[data-theme="dark"] #divideImagePopover button {
            background: rgba(30, 41, 59, 0.6) !important;
            border-color: rgba(51, 65, 85, 0.5) !important;
        }
        body[data-theme="dark"] #divideImagePopover button:hover {
            background: rgba(79, 70, 229, 0.2) !important;
            border-color: #4f46e5 !important;
        }
        body[data-theme="dark"] #divideImagePopover span { color: #cbd5e1 !important; }

        /* ── Core Typography ── */
        body {
            font-family: var(--font-body);
            background: #f8fafc;
            margin: 0;
            padding: 0;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        h1, h2, h3, h4, h5, h6, .font-display {
            font-family: var(--font-display);
        }

        /* ── Canvas Styling ── */
        .canvas-area {
            background-color: #e2e8f0;
            background-image:
                linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
                linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
                linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
            background-size: 16px 16px;
            background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
        }
        body[data-theme="dark"] .canvas-area {
            background-color: #0b0f19;
            background-image:
                linear-gradient(45deg, #161e2e 25%, transparent 25%),
                linear-gradient(-45deg, #161e2e 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #161e2e 75%),
                linear-gradient(-45deg, transparent 75%, #161e2e 75%);
            background-size: 16px 16px;
            background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
        }
        .canvas-container {
            margin: auto !important;
            box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.15), 0 10px 20px -10px rgba(0, 0, 0, 0.08);
            border-radius: 4px;
            background: white;
            will-change: transform;
            transition: box-shadow 0.3s ease;
        }
        .canvas-container:hover {
            box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.20);
        }
        #canvas-wrapper canvas {
            will-change: contents;
        }

        /* ── Dynamic Layout Sidebar & Tabs ── */
        .tool-btn {
            transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
            border-radius: 12px;
            margin: 4px 6px;
            border: none;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .tool-btn::after {
            content: '';
            position: absolute;
            inset: 0;
            background: rgba(255,255,255,0.08);
            opacity: 0;
            transition: opacity 0.2s ease;
        }
        .tool-btn:hover::after {
            opacity: 1;
        }
        .tool-btn.active {
            background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
            color: #ffffff !important;
            box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.4);
            transform: translateY(-1px);
        }
        .tool-btn.active * {
            color: #ffffff !important;
        }
        .tool-btn:hover:not(.active) {
            background: rgba(255, 255, 255, 0.06);
            color: #f1f5f9;
        }
        .tool-btn:active {
            transform: scale(0.95);
        }

        /* ── Swatches ── */
        .swatch {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            cursor: pointer;
            border: 2px solid transparent;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }
        .swatch:hover {
            transform: scale(1.12) translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
        }
        .swatch.active {
            border-color: #4f46e5;
            box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.35);
            transform: scale(1.1);
        }

        /* ── Sleek Custom Scrollbars ── */
        .custom-scroll::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        .custom-scroll::-webkit-scrollbar-track {
            background: transparent;
        }
        .custom-scroll::-webkit-scrollbar-thumb {
            background: rgba(148, 163, 184, 0.3);
            border-radius: 99px;
            border: 1px solid transparent;
        }
        .custom-scroll::-webkit-scrollbar-thumb:hover {
            background: rgba(148, 163, 184, 0.6);
        }
        .custom-scroll {
            overscroll-behavior: contain;
            scrollbar-width: thin;
            scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
        }

        /* ── Frosted Glass Popovers ── */
        .popover {
            display: none;
            position: absolute;
            z-index: 100;
            background: rgba(255, 255, 255, 0.85);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            border: 1px solid rgba(226, 232, 240, 0.8);
            border-radius: 16px;
            box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
            animation: popoverFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
            transform-origin: top left;
        }
        @keyframes popoverFadeIn {
            from { opacity: 0; transform: translateY(8px) scale(0.95); }
            to { opacity: 1; transform: translateY(0) scale(1); }
        }
        .popover.show {
            display: block;
        }

        /* ── Premium Toast Notification ── */
        #toast {
            position: fixed;
            bottom: 32px;
            left: 50%;
            transform: translateX(-50%) translateY(120px);
            background: rgba(15, 23, 42, 0.9);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            color: white;
            padding: 14px 28px;
            border-radius: 99px;
            font-family: var(--font-display);
            font-size: 14px;
            font-weight: 600;
            letter-spacing: 0.01em;
            z-index: 100000;
            opacity: 0;
            box-shadow: 0 20px 40px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
            transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        #toast.show {
            transform: translateX(-50%) translateY(0);
            opacity: 1;
        }
        #toast::before {
            content: '✓';
            background: #10b981;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: 800;
        }

        /* Mobile Touch Interactions */
        canvas {
            touch-action: none;
        }
        #canvas-wrapper {
            -webkit-overflow-scrolling: touch;
        }
        #propertiesBar {
            -webkit-overflow-scrolling: touch;
        }

        /* Range Slider Styling */
        input[type=range] {
            -webkit-appearance: none;
            width: 100%;
            background: transparent;
        }
        input[type=range]::-webkit-slider-thumb {
            -webkit-appearance: none;
            height: 18px;
            width: 18px;
            border-radius: 50%;
            background: #4f46e5;
            cursor: pointer;
            margin-top: -6px;
            box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
            transition: transform 0.1s;
        }
        input[type=range]::-webkit-slider-thumb:hover {
            transform: scale(1.15);
        }
        input[type=range]::-webkit-slider-runnable-track {
            width: 100%;
            height: 5px;
            cursor: pointer;
            background: #cbd5e1;
            border-radius: 99px;
        }

        /* ── Dynamic Loader ── */
        #graphm-loader {
            position: fixed; inset: 0;
            background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
            display: flex; flex-direction: column;
            align-items: center; justify-content: center;
            z-index: 999999;
            transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s ease;
        }
        #graphm-loader.fade-out {
            opacity: 0; visibility: hidden;
        }
        .loader-logo {
            width: 80px; height: 80px;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 24px;
            display: flex; align-items: center; justify-content: center;
            margin-bottom: 24px;
            box-shadow: 0 20px 50px rgba(79, 70, 229, 0.3);
            animation: pulse-logo 2s ease-in-out infinite;
        }
        @keyframes pulse-logo {
            0%, 100% { box-shadow: 0 20px 40px rgba(79, 70, 229, 0.25); transform: scale(1); }
            50% { box-shadow: 0 30px 60px rgba(79, 70, 229, 0.45); transform: scale(1.06); }
        }
        .loader-bar-track {
            width: 200px; height: 4px;
            background: rgba(255, 255, 255, 0.08);
            border-radius: 99px; overflow: hidden;
            margin-top: 32px;
            border: 1px solid rgba(255,255,255,0.03);
        }
        .loader-bar-fill {
            height: 100%;
            background: linear-gradient(90deg, #6366f1, #a855f7);
            border-radius: 99px;
            width: 0%;
            transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        }

        /* ── Multi-Device Responsiveness (Mobile, Tablet, Laptop, PC) ── */
        #canvas-wrapper {
            padding: 16px;
        }
        @media (min-width: 768px) {
            #canvas-wrapper {
                padding: 40px;
            }
        }

        /* Properties Bar Scrollability */
        #propertiesBar {
            min-height: 52px;
            height: auto;
            flex-wrap: nowrap;
            white-space: nowrap;
        }

        /* Mobile Slides/Tray Aspect */
        @media (max-width: 767px) {
            #slide-tray-outer {
                height: 84px !important;
            }
            #slideTray > div > div {
                width: 92px !important;
                height: 60px !important;
                border-radius: 8px !important;
            }
        }

        /* Zoom Positioning */
        @media (max-width: 767px) {
            #zoom-controls {
                bottom: 100px !important;
                right: 14px !important;
            }
        }

        /* Modal Panels: Responsive Scaling */
        @media (max-width: 640px) {
            #projectsModal > div,
            #shortcutsModal > div,
            #settingsModal > div,
            #saveTemplateModal > div {
                margin: 16px;
                max-height: 85vh;
                border-radius: 20px !important;
            }
            #projectsModal > div {
                max-width: calc(100vw - 32px) !important;
            }
            #projectsGrid {
                grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
                gap: 12px !important;
            }
        }

        /* Slide-up option panel on mobile */
        @media (max-height: 600px) {
            #mobilePanelWrapper {
                height: 60vh !important;
            }
        }

        #exportMenu {
            max-height: 80vh;
            overflow-y: auto;
        }

        @media (hover: none) and (pointer: coarse) {
            .tool-btn {
                min-height: 56px;
            }
            .swatch {
                width: 38px;
                height: 38px;
            }
        }

        html, body {
            max-width: 100vw;
            overflow-x: hidden;
        }

        /* ── Premium High-Fidelity Authentication Overlay ── */
        #authOverlay {
            position: fixed; inset: 0; z-index: 99999;
            background: rgba(3, 7, 18, 0.45);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            display: none;
            align-items: center; justify-content: center;
            padding: 20px;
            animation: authFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        }
        @keyframes authFadeIn { from { opacity: 0; } to { opacity: 1; } }
        #authOverlay.hide {
            animation: authFadeOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }
        @keyframes authFadeOut { from { opacity: 1; } to { opacity: 0; } }

        .auth-card {
            display: flex;
            width: 100%; max-width: 920px;
            min-height: 560px;
            background: #ffffff;
            border-radius: 28px;
            overflow: hidden;
            box-shadow: 0 35px 80px -20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.03);
            animation: authCardIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        @keyframes authCardIn {
            from { transform: translateY(32px) scale(0.96); opacity: 0; }
            to   { transform: translateY(0) scale(1); opacity: 1; }
        }

        /* Left brand panel styling */
        .auth-brand {
            width: 44%; 
            background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
            display: flex; flex-direction: column; justify-content: space-between;
            padding: 56px 44px; position: relative; overflow: hidden;
        }
        @media (max-width: 767px) { .auth-brand { display: none; } }
        .auth-brand::before {
            content: ''; position: absolute; width: 340px; height: 340px;
            border-radius: 50%; background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
            top: -100px; right: -120px;
        }
        .auth-brand::after {
            content: ''; position: absolute; width: 240px; height: 240px;
            border-radius: 50%; background: radial-gradient(circle, rgba(168,85,247,0.1) 0%, transparent 70%);
            bottom: -80px; left: -80px;
        }
        
        .auth-feature {
            display: flex; align-items: center; gap: 14px;
            color: rgba(255, 255, 255, 0.85); font-size: 13.5px; margin-bottom: 18px;
            font-family: var(--font-body);
        }
        .auth-feature i { 
            width: 34px; height: 34px; border-radius: 10px;
            background: rgba(255, 255, 255, 0.08); display: flex; align-items: center;
            justify-content: center; flex-shrink: 0; font-size: 13px; color: #a5b4fc; 
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* Form section styling */
        .auth-form-panel {
            flex: 1; display: flex; flex-direction: column;
            padding: 56px 52px; overflow-y: auto;
            background: #ffffff;
        }
        @media (max-width: 640px) { .auth-form-panel { padding: 40px 28px; } }

        /* Unified style inputs */
        .auth-input-group { margin-bottom: 20px; }
        .auth-input-group label { 
            display: block; font-size: 12px; font-weight: 700; 
            color: #475569; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; 
        }
        .auth-input {
            width: 100%; padding: 13px 16px; border: 1.5px solid #e2e8f0; border-radius: 12px;
            font-family: var(--font-body);
            font-size: 14.5px; color: #0f172a; background: #f8fafc; outline: none;
            transition: all 0.2s ease;
            box-sizing: border-box;
        }
        .auth-input:focus { 
            border-color: #4f46e5; 
            background: #ffffff;
            box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12); 
        }

        /* Buttons styling */
        .auth-submit-btn {
            width: 100%; padding: 14px; border: none; border-radius: 12px;
            background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
            color: #ffffff; font-family: var(--font-display);
            font-size: 15px; font-weight: 700; cursor: pointer;
            transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); margin-top: 8px; 
            box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.35);
        }
        .auth-submit-btn:hover { 
            transform: translateY(-1.5px); 
            box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.45); 
        }
        .auth-submit-btn:active { transform: translateY(0); }
        .auth-submit-btn:disabled { 
            opacity: 0.65; cursor: not-allowed; transform: none !important; 
            box-shadow: none !important;
        }
        
        .auth-error {
            background: #fef2f2; border: 1px solid #fee2e2; color: #b91c1c;
            border-radius: 12px; padding: 12px 16px; font-size: 13.5px; margin-bottom: 20px;
            display: none; align-items: center; gap: 10px;
            animation: shake 0.4s ease;
        }
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-4px); }
            75% { transform: translateX(4px); }
        }
        .auth-error.show { display: flex; }

        .auth-guest-btn {
            width: 100%; margin-top: 16px; padding: 12px; border: 1.5px dashed #cbd5e1;
            border-radius: 12px; background: transparent; color: #475569; font-size: 13.5px;
            font-weight: 600; cursor: pointer; transition: all 0.2s ease;
        }
        .auth-guest-btn:hover { 
            border-color: #4f46e5; color: #4f46e5; 
            background: rgba(79, 70, 229, 0.04); 
            transform: translateY(-1px);
        }
        .auth-guest-btn:active { transform: translateY(0); }