.search-box.ai-thinking {
    border-color: rgba(13, 110, 253, .6);
    box-shadow:
        0 0 0 2px rgba(13, 110, 253, .15),
        0 0 18px rgba(13, 110, 253, .18);
    animation: aiShimmer 1.6s ease-in-out infinite;
}

.search-btn.ai-mode {
    width: 72px;
}

.search-btn.ai-thinking {
    animation: aiPulseBtn 1.6s ease-in-out infinite;
}


/* AI query plan */
.ai-query-plan {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    color: #5b6b82;
    gap: 0.5rem;
}

/* Pulsing (thinking) */
.ai-query-plan.is-thinking::before {
    content: "";
    width: 1.1rem;
    height: 1.1rem;
    background: radial-gradient(circle at 30% 30%, #818cf8, #6366f1);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
    animation: ai-pulse 1.8s ease-in-out infinite;
}

/* Static (done) */
.ai-query-plan.is-done::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    background: rgba(99, 102, 241, 0.6);
    border-radius: 50%;
    box-shadow: none;
    animation: none;
}

.ai-summary-card {
    background: rgba(13, 110, 253, 0.06);
    /* Bootstrap primary tint */
    border-left: 4px solid rgba(13, 110, 253, 0.55);
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .08) !important;
}

.ai-summary-badge {
    background: rgba(13, 110, 253, 0.12);
    color: rgba(13, 110, 253, 1);
    border: 1px solid rgba(13, 110, 253, 0.25);
    font-weight: 600;
    letter-spacing: .02em;
}

.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
}

.results-toolbar-action,
.ai-summary-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 36px;
    padding: 0 0.9rem;
    border-radius: 999px;
    background: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        background-color 140ms ease,
        color 140ms ease;
}

.results-sort-action-btn {
    border: 1px solid rgba(0, 153, 171, 0.28);
    color: var(--brand-dark);
}

.results-sort-action-btn:hover,
.results-sort-action-btn:focus-visible,
.results-sort-action-btn[aria-expanded="true"] {
    border-color: rgba(0, 103, 146, 0.42);
    background: rgba(0, 153, 171, 0.08);
    box-shadow: 0 0 0 3px rgba(0, 153, 171, 0.14);
    outline: none;
}

.ai-summary-action-btn {
    border: 1px solid rgba(13, 110, 253, 0.22);
    color: #0d6efd;
}

.ai-summary-action-btn:hover,
.ai-summary-action-btn:focus-visible {
    border-color: rgba(13, 110, 253, 0.38);
    background: rgba(13, 110, 253, 0.04);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
    outline: none;
}

.ai-summary-action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

/* AI Summary slide-up hide (on new search) */
#aiSummaryWrap {
    transition:
        transform 180ms ease,
        opacity 180ms ease,
        margin 180ms ease;
    transform: translateY(0);
    opacity: 1;
    max-height: none;
}

#aiSummaryWrap.is-hiding {
    transform: translateY(-8px);
    opacity: 0;
    max-height: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    #aiSummaryWrap {
        transition: none;
    }
}

.ai-key-callout {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .45rem .6rem;
    margin-bottom: .4rem;

    background: rgba(13, 110, 253, 0.06);
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: .5rem;
}

.ai-key-pill {
    background: rgba(13, 110, 253, .15);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, .35);
    font-weight: 700;
}

.ai-key-text strong {
    font-weight: 700;
}

.ai-summary-body ul {
    margin: 0;
    padding-left: 1.1rem;
}

.ai-summary-body li {
    margin: 0.3rem 0;
    line-height: 1.35;
}

.ai-summary-notes {
    margin-top: 0.6rem;
    color: rgba(0, 0, 0, .68);
}

.ai-summary-verification-note {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(13, 110, 253, 0.12);
    color: rgba(0, 0, 0, .56);
    font-size: 0.84rem;
    line-height: 1.4;
}

.ai-summary-section {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(13, 110, 253, 0.14);
}

.ai-summary-section-title {
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #42526b;
    text-transform: uppercase;
}

.ai-related-news-list {
    display: grid;
    gap: 0.65rem;
}

.ai-related-news-item {
    padding: 0.7rem 0.8rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(13, 110, 253, 0.12);
    border-radius: 0.45rem;
}

.ai-related-news-title {
    display: inline-block;
    font-weight: 700;
}

.ai-related-news-meta {
    margin-top: 0.15rem;
    color: rgba(0, 0, 0, .55);
    font-size: 0.82rem;
}

.ai-related-news-snippet {
    margin-top: 0.35rem;
    color: rgba(0, 0, 0, .72);
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-related-news-empty {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(13, 110, 253, 0.14);
    color: rgba(0, 0, 0, .55);
    font-size: 0.88rem;
}

.ai-media-loading-section {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    background: rgba(13, 110, 253, 0.075);
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 0.5rem;
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.16);
    animation: ai-media-section-pulse 1.9s ease-in-out infinite;
}

.ai-media-loading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    background: rgba(13, 110, 253, 0.12);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.24);
    animation: ai-media-loading-pulse 1.25s ease-in-out infinite;
}

.ai-media-loading-title {
    font-weight: 700;
    color: #213547;
}

.ai-media-loading-text {
    margin-top: 0.15rem;
    color: rgba(0, 0, 0, .62);
    font-size: 0.88rem;
    line-height: 1.35;
}

.ai-summary-footnote {
    color: rgba(0, 0, 0, .55);
}


@keyframes aiPulseBtn {

    0%,
    100% {
        box-shadow: 0 0 0 rgba(99, 102, 241, .3);
    }

    50% {
        box-shadow: 0 0 18px rgba(99, 102, 241, .65);
    }
}

@keyframes aiShimmer {
    0% {
        box-shadow:
            0 0 0 2px rgba(13, 110, 253, .12),
            0 0 12px rgba(13, 110, 253, .12);
    }

    50% {
        box-shadow:
            0 0 0 2px rgba(13, 110, 253, .22),
            0 0 22px rgba(13, 110, 253, .22);
    }

    100% {
        box-shadow:
            0 0 0 2px rgba(13, 110, 253, .12),
            0 0 12px rgba(13, 110, 253, .12);
    }
}

@keyframes ai-pulse {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

@keyframes ai-media-loading-pulse {

    0%,
    100% {
        opacity: 0.72;
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.28);
    }

    50% {
        opacity: 1;
        transform: scale(1.14);
        box-shadow: 0 0 0 0.45rem rgba(13, 110, 253, 0);
    }
}

@keyframes ai-media-section-pulse {

    0%,
    100% {
        border-color: rgba(13, 110, 253, 0.16);
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.12);
    }

    50% {
        border-color: rgba(13, 110, 253, 0.34);
        box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.08);
    }
}


@media (prefers-reduced-motion: reduce) {
    .search-box.ai-thinking {
        animation: none;
    }

    .ai-media-loading-icon {
        animation: none;
    }

    .ai-media-loading-section {
        animation: none;
    }
}
