/* ИИ-помощник электронной библиотеки. Все классы начинаются с ai-, чтобы не задеть стили сайта. */
.ai-chat-toggle {
    position: fixed; right: 20px; bottom: 20px; z-index: 9998;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 18px; border: 0; border-radius: 24px;
    background: #285a8f; color: #fff; font: 600 15px/1.2 Arial, sans-serif;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25); cursor: pointer;
}
.ai-chat-toggle:hover, .ai-chat-toggle:focus { background: #1f4874; outline: none; }
.ai-chat-toggle.is-hidden { display: none; }
.ai-chat-toggle-icon { font-size: 18px; }

.ai-chat {
    position: fixed; right: 20px; bottom: 20px; z-index: 9999;
    width: 380px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    background: #fff; border-radius: 10px; overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3); font: 14px/1.45 Arial, sans-serif; color: #222;
}
.ai-chat[hidden] { display: none; }
.ai-chat-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; background: #285a8f; color: #fff; font-weight: 600;
}
.ai-chat-close { background: none; border: 0; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.ai-chat-log { flex: 1; overflow-y: auto; padding: 12px; background: #f3f5f8; }
.ai-msg { max-width: 92%; margin: 0 0 10px; padding: 9px 12px; border-radius: 10px; word-wrap: break-word; }
.ai-msg-bot { background: #fff; border: 1px solid #dde3ea; }
.ai-msg-user { margin-left: auto; background: #285a8f; color: #fff; }
.ai-msg-wait { color: #777; font-style: italic; }
.ai-msg a { color: #1f5fa5; }
.ai-books { margin: 8px 0 0; padding-left: 20px; }
.ai-books li { margin-bottom: 6px; }
.ai-book-meta { display: block; color: #666; font-size: 12px; }
.ai-chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #dde3ea; }
.ai-chat-form input {
    flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid #c5ced8; border-radius: 6px; font: inherit;
}
.ai-chat-form button {
    padding: 9px 14px; border: 0; border-radius: 6px; background: #285a8f; color: #fff; font: inherit; cursor: pointer;
}
.ai-chat-form button:disabled, .ai-chat-form input:disabled { opacity: .6; }
.ai-chat-foot { padding: 6px 10px 10px; font-size: 11px; color: #777; }
.ai-chat-foot a { color: #1f5fa5; }

@media (max-width: 480px) {
    .ai-chat { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
    .ai-chat-toggle { right: 16px; bottom: 16px; }
}
