:root {
            --cursor-size: 20px;
            --cursor-hover-size: 60px;
            --cosmic-blue: #4f8fff;
            --cosmic-purple: #a855f7;
            --cosmic-pink: #ec4899;
            --cosmic-cyan: #22d3ee;
            --cosmic-gold: #fbbf24;

            --bg-primary: #030014;
            --bg-secondary: #0a0520;
            --bg-tertiary: #120a30;
            --text-main: #f3f4f6;
            --text-muted: #94a3b8;
        }

        html.light {
            --bg-primary: #f8fafc;
            --bg-secondary: #f1f5f9;
            --bg-tertiary: #e2e8f0;
            --text-main: #0f172a;
            --text-muted: #475569;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: 'Inter', sans-serif;
            overflow-x: hidden;
            cursor: none;
            background: var(--bg-primary);
            color: var(--text-main);
            transition: background-color 0.4s ease, color 0.4s ease;
        }

        /* Nav & Structural transitions */
        body, nav, footer, section, .glass-cosmic, .card-cosmic, h1, h2, h3, h4, p, label, input, textarea {
            transition: background-color 0.4s ease, border-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
        }

        /* Lenis */
        html.lenis, html.lenis body { height: auto; }
        .lenis.lenis-smooth { scroll-behavior: auto !important; }
        .lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
        .lenis.lenis-stopped { overflow: hidden; }

        /* Custom Cursor - Cosmic Theme */
        .cursor-dot, .cursor-outline {
            position: fixed; top: 0; left: 0;
            border-radius: 50%; z-index: 9999;
            pointer-events: none; will-change: transform;
            transform: translate3d(0,0,0);
        }
        .cursor-dot {
            width: 6px; height: 6px;
            background: var(--cosmic-cyan);
            box-shadow: 0 0 10px var(--cosmic-cyan), 0 0 20px var(--cosmic-cyan);
        }
        .cursor-outline {
            width: var(--cursor-size); height: var(--cursor-size);
            border: 1.5px solid rgba(79, 143, 255, 0.6);
            transition: width 0.3s, height 0.3s, background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
        }
        .cursor-outline.hover {
            width: var(--cursor-hover-size); height: var(--cursor-hover-size);
            background: rgba(79, 143, 255, 0.08);
            border-color: rgba(168, 85, 247, 0.8);
            box-shadow: 0 0 30px rgba(168, 85, 247, 0.2);
        }
        @media (hover: hover) and (pointer: fine) { * { cursor: none !important; } }

        /* Content Visibility */
        .content-auto { content-visibility: auto; contain-intrinsic-size: 1px 800px; }

        /* Galaxy Canvas */
        #galaxy-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; transition: opacity 0.5s ease, filter 0.5s ease; }
        .light #galaxy-canvas { opacity: 0.25; filter: invert(0.9) hue-rotate(180deg) brightness(1.1); }

        /* Glassmorphism - Cosmic */
        .glass-cosmic {
            background: rgba(255, 255, 255, 0.45);
            backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
            border: 1px solid rgba(15, 23, 42, 0.08);
            box-shadow: 0 10px 30px rgba(0,0,0,0.02);
        }
        .dark .glass-cosmic {
            background: rgba(10, 5, 32, 0.6);
            backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
            border: 1px solid rgba(79, 143, 255, 0.1);
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        }
        .glass-cosmic:hover { border-color: rgba(79, 143, 255, 0.25); }

        /* Text Effects */
        .text-cosmic-gradient {
            background: linear-gradient(135deg, #4f8fff 0%, #a855f7 40%, #ec4899 70%, #fbbf24 100%);
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .text-cosmic-animated {
            background: linear-gradient(90deg, #4f8fff, #a855f7, #ec4899, #22d3ee, #4f8fff);
            background-size: 400% 100%;
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;
            background-clip: text;
            animation: cosmic-flow 6s ease infinite;
        }
        @keyframes cosmic-flow {
            0%, 100% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
        }

        /* Glow Effects */
        .glow-cosmic { box-shadow: 0 0 40px rgba(79, 143, 255, 0.15), 0 0 80px rgba(168, 85, 247, 0.08); }
        .glow-text { text-shadow: 0 0 40px rgba(79, 143, 255, 0.5), 0 0 80px rgba(168, 85, 247, 0.3); }

        /* Cards */
        .card-cosmic {
            transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.5s ease, border-color 0.5s ease;
            will-change: transform;
        }
        .card-cosmic:hover {
            transform: translateY(-8px) scale(1.02);
            box-shadow: 0 25px 60px -12px rgba(79, 143, 255, 0.15), 0 0 40px rgba(168, 85, 247, 0.1);
        }

        /* Magnetic Button */
        .magnetic-btn {
            position: relative; display: inline-flex; align-items: center; justify-content: center;
            transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); will-change: transform;
        }

        /* Scroll Progress - Cosmic */
        .scroll-progress {
            position: fixed; top: 0; left: 0; height: 2px;
            background: linear-gradient(90deg, #4f8fff, #a855f7, #ec4899, #22d3ee);
            z-index: 9999; transform-origin: left; transform: scaleX(0); will-change: transform;
            box-shadow: 0 0 10px rgba(79, 143, 255, 0.5);
        }

        /* Reveal Animation */
        .reveal { opacity: 0; transform: translateY(50px); }

        /* Floating Math Equations */
        .math-float {
            position: absolute; font-family: 'JetBrains Mono', monospace;
            color: rgba(79, 143, 255, 0.12); font-size: 0.85rem;
            animation: math-drift 20s linear infinite; pointer-events: none;
            white-space: nowrap;
        }
        @keyframes math-drift {
            0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
            10% { opacity: 1; }
            90% { opacity: 1; }
            100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
        }

        /* Shooting Stars */
        .shooting-star {
            position: fixed; width: 100px; height: 1px;
            background: linear-gradient(90deg, rgba(255,255,255,0.8), transparent);
            animation: shoot 1.5s ease-out forwards; pointer-events: none; z-index: 5;
        }
        @keyframes shoot {
            0% { transform: translateX(0) translateY(0) rotate(-45deg); opacity: 1; }
            100% { transform: translateX(300px) translateY(300px) rotate(-45deg); opacity: 0; }
        }

        /* Constellation Lines */
        .constellation-line {
            stroke: rgba(79, 143, 255, 0.2);
            stroke-width: 1;
            stroke-dasharray: 5 5;
            animation: dash-flow 3s linear infinite;
        }
        @keyframes dash-flow { to { stroke-dashoffset: -20; } }

        /* Terminal (Keeps dark aesthetic in both themes for tech accuracy) */
        .terminal-window {
            background: rgba(3, 0, 20, 0.95) !important;
            border: 1px solid rgba(79, 143, 255, 0.2) !important;
            border-radius: 12px; overflow: hidden;
            font-family: 'JetBrains Mono', monospace;
        }
        .terminal-header {
            background: rgba(79, 143, 255, 0.05);
            border-bottom: 1px solid rgba(79, 143, 255, 0.1);
            padding: 12px 16px; display: flex; align-items: center; gap: 8px;
        }
        .terminal-dot { width: 12px; height: 12px; border-radius: 50%; }
        .terminal-body { padding: 20px; font-size: 0.8rem; line-height: 1.8; color: #e2e8f0; }
        .terminal-prompt { color: #22d3ee; }
        .terminal-cmd { color: #e2e8f0; }
        .terminal-output { color: #64748b; }
        .terminal-success { color: #4ade80; }
        .terminal-cursor-blink { animation: term-blink 1s step-end infinite; }
        @keyframes term-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

        /* Dynamic Grid Pattern */
        .cosmic-grid {
            background-image:
                linear-gradient(var(--grid-color, rgba(79, 143, 255, 0.03)) 1px, transparent 1px),
                linear-gradient(90deg, var(--grid-color, rgba(79, 143, 255, 0.03)) 1px, transparent 1px);
            background-size: 60px 60px;
        }
        :root { --grid-color: rgba(79, 143, 255, 0.03); }
        html.light { --grid-color: rgba(15, 23, 42, 0.03); }

        /* Timeline - Cosmic */
        .timeline-cosmic {
            position: absolute; left: 24px; top: 0; bottom: 0; width: 2px;
            background: linear-gradient(180deg, #4f8fff, #a855f7, #ec4899, transparent);
            box-shadow: 0 0 10px rgba(79, 143, 255, 0.3);
        }

        /* Tech Tags - Cosmic */
        .tech-tag-cosmic {
            display: inline-flex; align-items: center; padding: 4px 12px;
            border-radius: 9999px; font-size: 0.7rem; font-weight: 500;
            background: rgba(79, 143, 255, 0.08); color: #4f8fff;
            border: 1px solid rgba(79, 143, 255, 0.15);
            transition: all 0.3s ease; font-family: 'JetBrains Mono', monospace;
        }
        .light .tech-tag-cosmic {
            background: rgba(79, 143, 255, 0.05);
            color: #1d4ed8;
            border-color: rgba(79, 143, 255, 0.2);
        }
        .tech-tag-cosmic:hover {
            background: rgba(79, 143, 255, 0.15);
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(79, 143, 255, 0.2);
        }

        /* Nav */
        .nav-link-cosmic { position: relative; }
        .nav-link-cosmic::after {
            content: ''; position: absolute; bottom: -4px; left: 0;
            width: 0; height: 2px;
            background: linear-gradient(90deg, #4f8fff, #a855f7);
            transition: width 0.3s ease;
            box-shadow: 0 0 8px rgba(79, 143, 255, 0.5);
        }
        .nav-link-cosmic:hover::after { width: 100%; }

        /* Button Shine */
        .btn-cosmic { position: relative; overflow: hidden; }
        .btn-cosmic::before {
            content: ''; position: absolute; top: 0; left: -100%;
            width: 100%; height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
            transition: left 0.6s ease;
        }
        .btn-cosmic:hover::before { left: 100%; }

        /* Form Inputs */
        .form-cosmic {
            background: rgba(79, 143, 255, 0.03);
            border: 1px solid rgba(79, 143, 255, 0.15);
            transition: all 0.3s ease;
        }
        .light .form-cosmic {
            background: rgba(15, 23, 42, 0.01);
            border-color: rgba(15, 23, 42, 0.1);
            color: #0f172a;
        }
        .form-cosmic:focus {
            background: rgba(79, 143, 255, 0.06);
            border-color: rgba(79, 143, 255, 0.5);
            box-shadow: 0 0 30px rgba(79, 143, 255, 0.1), inset 0 0 20px rgba(79, 143, 255, 0.03);
            outline: none;
        }

        /* Scrollbar */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: var(--bg-primary); }
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(180deg, #4f8fff, #a855f7);
            border-radius: 3px;
        }

        /* Loader */
        .loader-cosmic {
            position: fixed; inset: 0; background: #030014;
            z-index: 10000; display: flex; align-items: center;
            justify-content: center; flex-direction: column;
        }

        /* Euler's Identity Special */
        .euler-glow {
            text-shadow: 0 0 20px rgba(79, 143, 255, 0.8), 0 0 40px rgba(168, 85, 247, 0.5), 0 0 80px rgba(236, 72, 153, 0.3);
        }

        /* Warp Effect */
        .warp-overlay {
            position: fixed; inset: 0; z-index: 9998; pointer-events: none;
            background: radial-gradient(ellipse at center, transparent 0%, rgba(3, 0, 20, 0.8) 100%);
            opacity: 0; transition: opacity 0.3s;
        }

        /* Pulse Ring */
        @keyframes cosmic-pulse {
            0% { transform: scale(1); opacity: 0.6; }
            100% { transform: scale(2.5); opacity: 0; }
        }
        .cosmic-pulse::after {
            content: ''; position: absolute; inset: -4px;
            border-radius: 50%; border: 1px solid var(--cosmic-cyan);
            animation: cosmic-pulse 2s ease-out infinite;
        }

        /* Blob */
        @keyframes cosmic-blob {
            0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
            25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
            50% { border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%; }
            75% { border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%; }
        }
        .cosmic-blob { animation: cosmic-blob 8s ease-in-out infinite; }

        /* Float */
        @keyframes cosmic-float {
            0%, 100% { transform: translateY(0px) rotate(0deg); }
            33% { transform: translateY(-15px) rotate(1deg); }
            66% { transform: translateY(-8px) rotate(-1deg); }
        }
        .cosmic-float { animation: cosmic-float 8s ease-in-out infinite; }

        /* Stat Counter */
        .stat-cosmic {
            font-family: 'Space Grotesk', sans-serif;
            font-size: 3.5rem; font-weight: 700; line-height: 1;
        }

        /* Publication Card */
        .pub-cosmic {
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        .pub-cosmic:hover {
            transform: translateX(8px);
            box-shadow: -8px 0 30px rgba(79, 143, 255, 0.1);
        }

        /* Mobile */
        @media (max-width: 768px) {
            .cursor-dot, .cursor-outline { display: none; }
            body { cursor: auto !important; }
            * { cursor: auto !important; }
            .math-float { display: none; }
        }

        /* Typed cursor */
        .typed-cursor { font-weight: 300; color: var(--cosmic-cyan); }

        /* Selection */
        ::selection { background: rgba(79, 143, 255, 0.3); color: white; }

        /* Noise overlay */
        .noise-cosmic::before {
            content: ''; position: absolute; inset: 0; opacity: 0.015;
            z-index: 1; pointer-events: none;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
        }