.ai-loader {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: hsl(232deg 55% 9% / .62);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    cursor: progress;
    animation: ai-loader-fade-in .25s ease-out;
}

.ai-loader__stage {
    position: relative;
    width: min(220px, 56vw);
    aspect-ratio: 1;
    flex: none;
    container-type: inline-size;
}

.ai-loader__ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

    .ai-loader__ring circle {
        fill: none;
        stroke: rgba(201, 206, 230, .2);
        stroke-width: 1;
        stroke-dasharray: 1 9;
        stroke-linecap: round;
        transform-origin: 130px 130px;
        animation: ai-loader-turn 18s linear infinite;
    }

.ai-loader__blob {
    --ai-loader-blob: 3.4s;
    position: absolute;
    inset: 7%;
    mix-blend-mode: screen;
    filter: blur(20px);
    animation: ai-loader-morph var(--ai-loader-blob) ease-in-out infinite alternate, ai-loader-turn calc(var(--ai-loader-blob) * 1.4) linear infinite;
}

.ai-loader__blob--sky { background: radial-gradient(circle at 30% 35%, #5ab8eb 0%, rgba(90, 184, 235, 0) 68%); }

.ai-loader__blob--violet {
    --ai-loader-blob: 4.2s;
    background: radial-gradient(circle at 70% 40%, #a77bff 0%, rgba(167, 123, 255, 0) 66%);
    animation-delay: -1.3s, -2s;
}

.ai-loader__blob--rose {
    --ai-loader-blob: 5s;
    background: radial-gradient(circle at 50% 72%, #D83F87 0%, rgba(216, 63, 135, 0) 64%);
    animation-delay: -2.4s, -5s;
}

.ai-loader__glass {
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .2);
    background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .32) 0%, rgba(255, 255, 255, .05) 40%, rgba(11, 15, 58, .18) 72%);
}

.ai-loader__tile {
    position: absolute;
    inset: 33%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, .12), 0 0 28px rgba(255, 255, 255, .5);
    animation: ai-loader-breathe 2.4s ease-in-out infinite;
}

.ai-loader__logo {
    width: 50%;
    height: 50%;
}

.ai-loader__logo-bracket { fill: #ec1c24; }

.ai-loader__logo-spark {
    fill: var(--ai-topbar-bg);
    transform-box: fill-box;
    transform-origin: center;
    animation: ai-loader-twinkle 1.6s ease-in-out infinite;
}

    .ai-loader__logo-spark--small { animation-delay: .8s; }

.ai-loader__token {
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    color: #fff;
    text-shadow: 0 0 6px var(--c), 0 0 14px var(--c);
    opacity: 0;
    animation: ai-loader-fly 2.4s cubic-bezier(.55, 0, .75, .4) infinite both;
}

.ai-loader__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.25;
    user-select: none;
}

.ai-loader__brand {
    font-size: .95rem;
    letter-spacing: .3em;
    font-weight: 400;
    background: linear-gradient(90deg, #5ab8eb, #fff, #D83F87, #5ab8eb);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: ai-loader-shimmer 3s linear infinite;
}

    .ai-loader__brand strong { font-weight: 800; }

.ai-loader__text {
    margin-top: .6rem;
    font-size: .95rem;
    color: rgba(255, 255, 255, .7);
}

.ai-loader__dots i {
    font-style: normal;
    animation: ai-loader-dot 1.2s infinite;
}

    .ai-loader__dots i:nth-child(2) { animation-delay: .2s; }
    .ai-loader__dots i:nth-child(3) { animation-delay: .4s; }

@keyframes ai-loader-fade-in { from { opacity: 0; } }
@keyframes ai-loader-turn { to { rotate: 360deg; } }
@keyframes ai-loader-morph { 0% { border-radius: 42% 58% 63% 37% / 45% 41% 59% 55%; transform: scale(1); } 50% { border-radius: 61% 39% 44% 56% / 58% 63% 37% 42%; transform: scale(1.08); } 100% { border-radius: 38% 62% 52% 48% / 36% 55% 45% 64%; transform: scale(.94); } }
@keyframes ai-loader-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes ai-loader-twinkle { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.55); opacity: .55; } }
@keyframes ai-loader-fly { 0% { transform: translate(calc(var(--x) * 1cqw), calc(var(--y) * 1cqw)) scale(1.1); opacity: 0; } 18% { opacity: 1; } 85% { opacity: .9; } 100% { transform: translate(0, 0) scale(.25); opacity: 0; } }
@keyframes ai-loader-shimmer { to { background-position: -300% 0; } }
@keyframes ai-loader-dot { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .ai-loader__stage *, .ai-loader__dots i, .ai-loader__brand { animation: none !important; }
}

.ai-loader--splash {
    z-index: 2000;
    gap: 1.25rem;
    background: linear-gradient(160deg, var(--ai-topbar-bg) 0%, #141C5C 55%, var(--ai-topbar-bg) 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transition: opacity .45s ease, visibility .45s;
    animation: none;
}

    .ai-loader--splash::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background: url(ai-loader-tokens.svg) center / 480px 480px;
        -webkit-mask-image: radial-gradient(ellipse 320px 300px at 50% 50%, rgba(0, 0, 0, .1) 65%, #000 100%);
        mask-image: radial-gradient(ellipse 320px 300px at 50% 50%, rgba(0, 0, 0, .1) 65%, #000 100%);
        pointer-events: none;
    }

    .ai-loader--splash .ai-loader__stage { width: min(260px, 62vw); }

    .ai-loader--splash .ai-loader__brand { font-size: 1.15rem; }

.ai-loader--leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ai-splash__progress {
    width: min(240px, 64vw);
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.ai-splash__progress-bar {
    height: 100%;
    width: var(--blazor-load-percentage, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, #5ab8eb, #a77bff, #D83F87);
    box-shadow: 0 0 8px rgba(90, 184, 235, .8);
    transition: width .2s ease-out;
}
