.ai-stage {
    isolation: isolate;
    min-height: 180px;
    position: relative;
}

.ai-stage .ai-loader {
    align-items: center;
    background: radial-gradient(circle at 82% 20%, rgba(34, 211, 238, 0.1), transparent 38%), linear-gradient(180deg, rgba(15, 23, 42, 0.94) 0%, rgba(30, 41, 59, 0.92) 100%);
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 16px;
    color: #e2e8f0;
    display: none;
    flex-direction: column;
    inset: 0;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
    position: absolute;
    z-index: 3;
}

.ai-stage .ai-logo-wrap {
    margin: 0 auto;
    max-width: 360px;
    width: min(100%, 360px);
}

.ai-stage .ai-logo-svg {
    display: block;
    height: auto;
    width: 100%;
}

.ai-stage .ai-logo-wrap #mark {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.ai-stage .ai-status {
    color: #64748b;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.2px;
    margin-top: 10px;
}

.ai-stage .ai-ripple {
    display: none;
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

.ai-stage .ai-results {
    min-height: inherit;
    opacity: 1;
    transition: opacity 350ms ease, filter 350ms ease, transform 350ms ease;
}

.ai-stage .ai-particles use {
    animation: rippleOut 700ms ease-out forwards;
    color: rgba(34, 211, 238, 0.9);
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.22));
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.ai-stage[data-ai-state="thinking"] .ai-loader,
.ai-stage[data-ai-state="coalescing"] .ai-loader,
.ai-stage[data-ai-state="reveal"] .ai-loader {
    display: flex;
}

.ai-stage[data-ai-state="thinking"] .ai-results,
.ai-stage[data-ai-state="coalescing"] .ai-results,
.ai-stage[data-ai-state="reveal"] .ai-results {
    filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.ai-stage[data-ai-state="thinking"] .ai-logo-wrap #mark {
    animation: breath 4s ease-in-out infinite;
}

.ai-stage[data-ai-state="thinking"] .ai-logo-wrap .node,
.ai-stage[data-ai-state="coalescing"] .ai-logo-wrap .node {
    animation: nodePulse 3s ease-in-out infinite;
}

.ai-stage[data-ai-state="coalescing"] .ai-logo-wrap #mark {
    animation: breath 1.2s ease-in-out infinite;
}

.ai-stage[data-ai-state="coalescing"][data-ai-ramp="2"] .ai-logo-wrap #mark {
    animation-duration: 1.2s;
}

.ai-stage[data-ai-state="coalescing"][data-ai-ramp="3"] .ai-logo-wrap #mark {
    animation-duration: 0.9s;
}

.ai-stage[data-ai-state="coalescing"][data-ai-ramp="4"] .ai-logo-wrap #mark {
    animation-duration: 0.55s;
}

.ai-stage[data-ai-state="reveal"] .ai-ripple {
    display: block;
    opacity: 1;
}

.ai-stage[data-ai-state="done"] .ai-loader {
    display: none;
}

.ai-stage[data-ai-state="done"] .ai-results {
    filter: none;
    opacity: 1;
    transform: none;
}

.ai-stage[data-ai-state="execution"] .ai-logo-wrap #mark,
.ai-stage .ai-logo-wrap #mark.execution-state {
    animation: snap 600ms ease-out;
}

.ai-widget-stage .ai-loader {
    border-radius: 14px;
}

.ai-widget-stage {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.ai-widget-stage .ai-logo-wrap {
    max-width: 280px;
}

.ai-widget-stage .ai-status {
    color: #cbd5e1;
}

.ai-widget-stage .ai-results {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 16rem;
}

.ai-widget-stage #ai-widget-history {
    min-height: 16rem;
}

.guide-results-stage {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.guide-results-stage .ai-results {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

@keyframes breath {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.92;
        transform: scale(1.03);
    }
}

@keyframes nodePulse {
    0%,
    100% {
        r: 4;
    }

    50% {
        r: 5;
    }
}

@keyframes snap {
    0% {
        filter: drop-shadow(0 0 0 rgba(34, 211, 238, 0));
        transform: scale(1.05);
    }

    50% {
        filter: drop-shadow(0 0 18px #22d3ee) drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
        transform: scale(1.15);
    }

    100% {
        filter: drop-shadow(0 0 0 rgba(34, 211, 238, 0));
        transform: scale(1);
    }
}

@keyframes rippleOut {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.28);
    }

    15% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(1.08);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-stage .ai-logo-wrap #mark,
    .ai-stage .ai-logo-wrap .node,
    .ai-stage .ai-particles use {
        animation: none !important;
    }

    .ai-stage .ai-ripple {
        display: none !important;
    }

    .ai-stage .ai-results {
        transition: none !important;
    }
}
