.bookstore-detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1.25rem;
    align-items: center;
}

.bookstore-detail__ai-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.btn--ai {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: linear-gradient(135deg, #7c3aed, #a855f7 45%, #ec4899);
    color: white;
    border: none;
    box-shadow: 0 8px 28px rgba(124, 58, 237, 0.35);
}

.btn--ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 32px rgba(124, 58, 237, 0.45);
}

.btn--ai__icon {
    font-size: 1rem;
}

.book-ai-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 4, 6, 0.62);
    backdrop-filter: blur(4px);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.book-ai-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
}

.book-ai-root {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    left: auto;
    z-index: 200;
    width: min(460px, calc(100vw - 2rem));
}

.book-ai-panel {
    display: flex;
    flex-direction: column;
    height: min(680px, calc(100dvh - 3rem));
    background: rgba(18, 8, 12, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.58),
        0 0 0 1px rgba(124, 58, 237, 0.18);
    backdrop-filter: blur(18px);
    overflow: hidden;
    animation: book-ai-slide-up 0.28s ease;
}

.book-ai-panel[hidden] {
    display: none !important;
}

@keyframes book-ai-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.book-ai-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(220, 38, 38, 0.08));
    flex-shrink: 0;
}

.book-ai-panel__head strong {
    display: block;
    font-size: 0.98rem;
    margin-bottom: 0.2rem;
}

.book-ai-panel__head span {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.book-ai-panel__close {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.book-ai-panel__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.book-ai-msg {
    max-width: 88%;
    padding: 0.7rem 0.85rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.book-ai-msg--bot {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.book-ai-msg--user {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.38), rgba(220, 38, 38, 0.28));
    border: 1px solid rgba(168, 85, 247, 0.35);
}

.book-ai-msg--system {
    align-self: center;
    max-width: 100%;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 0.25rem;
}

.book-ai-msg--typing {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
    min-height: 1.2rem;
    align-self: flex-end;
}

.book-ai-msg--typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: book-ai-dot 1.2s infinite ease-in-out;
}

.book-ai-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.book-ai-msg--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes book-ai-dot {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.book-ai-panel__form {
    display: flex;
    gap: 0.55rem;
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.28);
    flex-shrink: 0;
}

.book-ai-panel__form textarea {
    flex: 1;
    min-height: 48px;
    max-height: 120px;
    resize: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    padding: 0.7rem 0.8rem;
    line-height: 1.5;
}

.book-ai-panel__form textarea:focus {
    outline: none;
    border-color: rgba(168, 85, 247, 0.55);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.book-ai-panel__send {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c3aed, #dc2626);
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-ai-panel__send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

body.book-ai-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .bookstore-detail__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .bookstore-detail__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .book-ai-root {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
    }

    .book-ai-panel {
        height: min(88dvh, 720px);
        border-radius: 22px 22px 0 0;
        border-bottom: none;
    }

    .book-ai-panel__messages {
        padding: 0.85rem;
    }

    .book-ai-msg {
        max-width: 92%;
        font-size: 0.86rem;
    }
}

@media (min-width: 641px) {
    .book-ai-backdrop {
        display: none;
    }
}
