body:has(#appContainer:not([style*="display: none"]))::before {
    content: '';
    position: fixed;
    top: var(--topbar-height);
    left: -10px;
    right: 0;
    height: 2px;
    background:
        linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.8) 45%, rgba(255,255,255,0.8) 55%, transparent 100%) -100vw 0 / 30px 100% no-repeat,
        linear-gradient(90deg, #489E46, #2489BD, #7CC8E6);
    animation: shine-horizontal 16s ease-in-out infinite, topBorderBreathe 4s ease-in-out infinite;
    z-index: calc(var(--z-fixed) + 3);
    pointer-events: none;
}

@keyframes topBorderBreathe {
    0%, 100% {
        box-shadow: 0 4px 24px rgba(0,0,0,0.3),
            0 2px 8px rgba(36,137,189,0.55),
            0 4px 18px rgba(36,137,189,0.3),
            0 6px 30px rgba(36,137,189,0.12);
    }
    50% {
        box-shadow: 0 4px 24px rgba(0,0,0,0.3),
            0 2px 12px rgba(36,137,189,0.75),
            0 5px 24px rgba(36,137,189,0.45),
            0 8px 40px rgba(36,137,189,0.2);
    }
}

/* body::before border line stays visible when AI panel is open */


/* Light mode: use darker gradient stops for the top-bar line */
body.light-mode:has(#appContainer:not([style*="display: none"]))::before {
    background:
        linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.8) 45%, rgba(255,255,255,0.8) 55%, transparent 100%) -100vw 0 / 30px 100% no-repeat,
        linear-gradient(90deg, #1BA8E0, #5CE0FF);
    animation: shine-horizontal 16s ease-in-out infinite, topBorderBreatheLight 4s ease-in-out infinite;
}

@keyframes topBorderBreatheLight {
    0%, 100% {
        box-shadow:
            0 2px 10px rgba(36,137,189,0.5),
            0 4px 20px rgba(36,137,189,0.35),
            0 6px 36px rgba(36,137,189,0.18);
    }
    50% {
        box-shadow:
            0 2px 14px rgba(36,137,189,0.7),
            0 5px 28px rgba(36,137,189,0.5),
            0 8px 44px rgba(36,137,189,0.28);
    }
}

/* Hide gradient line when any modal is open */
body:has(.modal.active)::before,
body:has(.modal-water.active)::before {
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   ELECTRIFIED GRID BACKGROUND — 3-layer system
   Layer 1: CSS static grid lines (body::after pseudo)
   Layer 2: CSS shimmer sweep (#gridShimmer div)
   Layer 3: Canvas lightning chains (#electrified-grid canvas)
   ═══════════════════════════════════════════════════════ */

/* Layer 1: Static grid lines via body::after */
body:not(.light-mode)::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(74, 173, 224, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 173, 224, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}
body.light-mode::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(36, 137, 189, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36, 137, 189, 0.08) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* Layer 2: Shimmer sweep — brighter grid with diagonal mask animation */
body:not(.light-mode) #gridShimmer {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(74, 173, 224, 0.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 173, 224, 0.09) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: linear-gradient(220deg, transparent 30%, rgba(0,0,0,0.5) 45%, rgba(0,0,0,0.8) 50%, rgba(0,0,0,0.5) 55%, transparent 70%);
    mask-image: linear-gradient(220deg, transparent 30%, rgba(0,0,0,0.5) 45%, rgba(0,0,0,0.8) 50%, rgba(0,0,0,0.5) 55%, transparent 70%);
    -webkit-mask-size: 400% 400%;
    mask-size: 400% 400%;
    animation: grid-shimmer 8s ease-in-out infinite;
}
body.light-mode #gridShimmer {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(36, 137, 189, 0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36, 137, 189, 0.12) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: linear-gradient(220deg, transparent 30%, rgba(0,0,0,0.4) 45%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0.4) 55%, transparent 70%);
    mask-image: linear-gradient(220deg, transparent 30%, rgba(0,0,0,0.4) 45%, rgba(0,0,0,0.6) 50%, rgba(0,0,0,0.4) 55%, transparent 70%);
    -webkit-mask-size: 400% 400%;
    mask-size: 400% 400%;
    animation: grid-shimmer 8s ease-in-out infinite;
}
@keyframes grid-shimmer {
    0% { -webkit-mask-position: 100% 0%; mask-position: 100% 0%; }
    100% { -webkit-mask-position: 0% 100%; mask-position: 0% 100%; }
}

/* Layer 3: Canvas for lightning sparks */
#electrified-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* Ensure all content is above canvas/grid layers */
body > *:not(#electrified-grid):not(#gridShimmer):not(#splashScreen):not(#loginPage):not(#appContainer):not(#profilePopover):not(#searchResults):not(#aiFloatButton):not(#aiPanelWrapper) {
    position: relative;
    z-index: var(--z-content);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

.text-gradient {
    background: var(--grad-corona);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    width: fit-content;
}

.text-gradient-shine {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    background: linear-gradient(
        90deg,
        #489E46 0%, #2489BD 15%, #7CC8E6 30%,
        #7CC8E6 32%, #fff 34%, #7CC8E6 36%,
        #2489BD 50%, #489E46 65%,
        #2489BD 80%, #7CC8E6 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: text-shine 6s ease-in-out infinite;
}

@keyframes text-shine {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ───────────────────────────────────────────────────────────
   SCRAMBLE EFFECT - FONT RENDERING CRITICAL
   ───────────────────────────────────────────────────────────
   DO NOT REMOVE: Font smoothing properties prevent pixelation
   Used by TextScramble class in JavaScript section
   ─────────────────────────────────────────────────────────── */
.scramble-char {
    color: var(--corona);
    opacity: 0.85;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
}

