@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 {
    appearance: none;
    -webkit-appearance: none;
    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-rich-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-rich-text h2, .ai-rich-text h3, .ai-rich-text h4 { font-size: 1rem; font-weight: 700; margin: 0.9rem 0 0.3rem; color: #ffcc00; }
.ai-rich-text p { margin: 0.35rem 0; }
.ai-rich-text ol, .ai-rich-text ul { padding-left: 0.7rem; margin: 0.35rem 0; }
.ai-rich-text li {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
    padding: 0 0 0.4rem 20px;
}
.ai-rich-text ol > li { padding-bottom: 0.6rem; }
.ai-rich-text ul > li { padding-bottom: 0.3rem; }
.ai-rich-text ul > li:last-child,
.ai-rich-text ol > li:last-child { padding-bottom: 0; }
.ai-rich-text strong { font-weight: 700; }
.ai-rich-text em { color: #ffcc00; font-style: italic; font-weight: 600; }
.ai-rich-text a.wiki-link,
.ai-rich-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-rich-text a.wiki-link:hover,
.ai-rich-text a.article-link:hover { background: rgba(255,204,0,0.25); }
.ai-rich-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-rich-text a.article-link::after {
    content: '';
    display: inline-block;
    width: 13px; height: 13px;
    margin-left: 4px;
    background: url('https://mushroomid.org/wp-content/uploads/2025/09/cropped-1024x0w-32x32.webp') no-repeat center / contain;
    vertical-align: text-bottom;
    opacity: 0.8;
}

#ai-alt-bar { display: none; margin-top: 0.7rem; }
.ai-alt-btn {
    width: 100%;
    justify-content: center;
    padding: 1.1rem 1.8rem;
    font-size: 0.8rem;
    background: #4cdb4c;
    border: 1px solid #4cdb4c;
    color: #0a2e0a;
}
.ai-alt-btn:hover { background: #5ee85e; border-color: #5ee85e; }
.ai-alt-btn:disabled { opacity: 0.6; cursor: default; }

#ai-alt-result { display: none; margin-top: 0.9rem; }
#ai-alt-result .ai-alt-heading {
    color: #ffcc00;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.ai-feedback-bar {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.ai-feedback-label {
    color: #aaa;
    font-size: 0.8rem;
}
.ai-feedback-btns {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    width: 100%;
    gap: 0.6rem;
}
.ai-feedback-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    color: #ddd;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
}
.ai-feedback-btn:hover { background: rgba(255,255,255,0.12); }
.ai-feedback-btn:active { transform: scale(0.97); }
.ai-feedback-btn.selected#ai-feedback-up {
    background: rgba(76,219,76,0.18);
    border-color: rgba(76,219,76,0.55);
    color: #7be87b;
}
.ai-feedback-btn.selected#ai-feedback-down {
    background: rgba(255,90,90,0.18);
    border-color: rgba(255,90,90,0.55);
    color: #ff8a8a;
}
.ai-feedback-btn:disabled { cursor: default; }
.ai-feedback-thanks {
    display: none;
    color: #ffcc00;
    font-size: 0.8rem;
    font-weight: 600;
}

#ai-close-btn {
    appearance: none;
    -webkit-appearance: none;
    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;
}
