@keyframes mushroom-spin { to { transform: rotate(360deg); } }

#ai-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.82);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1.5rem 1.2rem;
    box-sizing: border-box;
    overflow-y: auto;
}

#ai-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 160px;
    gap: 1rem;
    color: #fff;
}
#ai-loading-state .ai-spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #ffcc00;
    border-radius: 50%;
    animation: mushroom-spin 0.8s linear infinite;
}
#ai-loading-state p { margin: 0; font-size: 1rem; font-weight: 500; }

#ai-result-state { display: none; width: 100%; max-width: 520px; }

#ai-result-img {
    display: block;
    width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border-radius: 6px;
    margin: 0 auto 0.75rem;
}
#ai-result-date {
    text-align: center;
    color: #aaa;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.ai-copy-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
}
.ai-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: rgba(255,204,0,0.12);
    border: 1px solid rgba(255,204,0,0.4);
    border-radius: 8px;
    color: #ffcc00;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.ai-copy-btn:hover { background: rgba(255,204,0,0.22); }
.ai-copy-btn:active { transform: scale(0.96); }
.ai-copy-btn.copied {
    background: rgba(76,219,76,0.2);
    border-color: rgba(76,219,76,0.5);
    color: #7be87b;
}

#ai-result-text {
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.65;
    background: rgba(0,0,0,0.95);
    border-radius: 12px;
    padding: 1.2rem 1.4rem;
}
#ai-result-text h2, #ai-result-text h3, #ai-result-text h4 { font-size: 1rem; font-weight: 700; margin: 0.9rem 0 0.3rem; color: #ffcc00; }
#ai-result-text p { margin: 0.35rem 0; }
#ai-result-text ol, #ai-result-text ul { padding-left: 0.7rem; margin: 0.35rem 0; }
#ai-result-text li {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
    padding: 0 0 0.4rem 20px;
}
#ai-result-text ol > li { padding-bottom: 0.6rem; }
#ai-result-text ul > li { padding-bottom: 0.3rem; }
#ai-result-text ul > li:last-child,
#ai-result-text ol > li:last-child { padding-bottom: 0; }
#ai-result-text strong { font-weight: 700; }
#ai-result-text em { color: #ffcc00; font-style: italic; font-weight: 600; }
#ai-result-text a.wiki-link,
#ai-result-text a.article-link {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    background: rgba(255,204,0,0.1);
    border: 1px solid rgba(255,204,0,0.5);
    border-radius: 5px;
    color: #ffcc00;
    text-decoration: none;
    font-style: italic;
    font-size: 0.85em;
    line-height: 1.4;
}
#ai-result-text a.wiki-link:hover,
#ai-result-text a.article-link:hover { background: rgba(255,204,0,0.25); }
#ai-result-text a.wiki-link::after {
    content: '';
    display: inline-block;
    width: 13px; height: 13px;
    margin-left: 4px;
    background: url('https://ru.wikipedia.org/favicon.ico') no-repeat center / contain;
    vertical-align: text-bottom;
    opacity: 0.8;
}
#ai-result-text a.article-link::after {
    content: '';
    display: inline-block;
    width: 13px; height: 13px;
    margin-left: 4px;
    background: url('https://mushroomid.ru/wp-content/uploads/2025/09/cropped-1024x0w-32x32.webp') no-repeat center / contain;
    vertical-align: text-bottom;
    opacity: 0.8;
}

#ai-close-btn {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #ffcc00;
    color: #000;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
