/* ==========================================================================
   LIBRYZO BOOK AI CHAT - PREMIUM REDESIGN
   Obsidian, Crimson & Gold Luxury Glassmorphism
   ========================================================================== */

.book-ai-section {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(60px, 8vw, 110px) 0;
    background:
        radial-gradient(circle at 12% 18%, rgba(199, 40, 50, 0.16), transparent 38%),
        radial-gradient(circle at 88% 82%, rgba(216, 173, 82, 0.12), transparent 34%),
        radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.6), transparent 60%),
        #060c18;
}

.book-ai-ambient {
    position: absolute;
    z-index: -1;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.24;
    pointer-events: none;
    animation: ambientFloat 14s ease-in-out infinite alternate;
}

.book-ai-ambient-one {
    top: -160px;
    left: -120px;
    background: #ef3340;
}

.book-ai-ambient-two {
    right: -140px;
    bottom: -180px;
    background: #d8ad52;
    animation-delay: -7s;
}

@keyframes ambientFloat {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.12); }
}

.book-ai-container {
    position: relative;
    max-width: 1220px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --------------------------------------------------------------------------
   Main Glassmorphic Shell
   -------------------------------------------------------------------------- */
.book-ai-shell {
    display: grid;
    grid-template-columns: minmax(290px, 0.76fr) minmax(0, 1.74fr);
    min-height: 740px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    background: rgba(9, 17, 32, 0.82);
    box-shadow:
        0 30px 96px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(199, 40, 50, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.book-ai-sidebar {
    position: relative;
    padding: clamp(28px, 3.6vw, 42px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(165deg, rgba(199, 40, 50, 0.14) 0%, rgba(7, 14, 27, 0.45) 45%, rgba(216, 173, 82, 0.07) 100%);
    display: flex;
    flex-direction: column;
}

.book-ai-sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.02;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M0 30h60M30 0v60' stroke='%23fff' stroke-width='.5'/%3E%3C/svg%3E");
}

.book-ai-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.book-ai-orb {
    position: relative;
    display: grid;
    flex: 0 0 54px;
    height: 54px;
    place-items: center;
    border: 1px solid rgba(240, 215, 140, 0.45);
    border-radius: 17px;
    color: #fff3c9;
    font-size: 1.55rem;
    background: linear-gradient(140deg, #c72832, #7a0e19);
    box-shadow:
        0 10px 28px rgba(199, 40, 50, 0.38),
        0 0 20px rgba(216, 173, 82, 0.25);
}

.book-ai-orb span {
    position: absolute;
    inset: -5px;
    border: 1px solid rgba(240, 215, 140, 0.22);
    border-radius: 20px;
    animation: bookAiOrb 3s ease-in-out infinite;
}

@keyframes bookAiOrb {
    0%, 100% { transform: scale(1); opacity: 0.35; }
    50% { transform: scale(1.1); opacity: 0.8; border-color: rgba(240, 215, 140, 0.5); }
}

.book-ai-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: #e6c975;
    font: 700 0.68rem/1.2 var(--font-raleway, sans-serif);
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.book-ai-brand h2 {
    margin: 0;
    color: #ffffff;
    font: 700 clamp(1.35rem, 2.5vw, 1.75rem)/1.2 var(--font-playfair, serif);
    letter-spacing: -0.01em;
}

.book-ai-intro {
    position: relative;
    z-index: 1;
    margin: 24px 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.92rem;
    line-height: 1.68;
}

.book-ai-intro strong {
    color: #ffffff;
    font-weight: 600;
}

/* Status Cards in Sidebar */
.book-ai-index-card {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(8px);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.book-ai-index-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
}

.book-ai-status-dot {
    flex: 0 0 10px;
    height: 10px;
    border-radius: 50%;
    background: #9299a8;
    box-shadow: 0 0 0 4px rgba(146, 153, 168, 0.15);
}

[data-index-status="indexed"] .book-ai-status-dot {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2), 0 0 16px rgba(16, 185, 129, 0.65);
}

[data-index-status="ready"] .book-ai-status-dot {
    background: #38bdf8;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.2), 0 0 14px rgba(56, 189, 248, 0.6);
}

[data-index-status="indexing"] .book-ai-status-dot,
[data-index-status="pending"] .book-ai-status-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
    animation: bookAiPulse 1.4s infinite;
}

[data-index-status="failed"] .book-ai-status-dot {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

@keyframes bookAiPulse {
    50% { opacity: 0.3; transform: scale(0.8); }
}

.book-ai-index-card strong,
.book-ai-index-card small {
    display: block;
}

.book-ai-index-card strong {
    color: #f8fafc;
    font-size: 0.83rem;
    font-weight: 600;
}

.book-ai-index-card small {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.48);
    font-size: 0.72rem;
}

.book-ai-usage-card {
    margin-top: 10px;
}

.book-ai-usage-icon {
    display: grid;
    flex: 0 0 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    color: #e6c975;
    background: rgba(216, 173, 82, 0.12);
    border: 1px solid rgba(216, 173, 82, 0.2);
}

/* Flow list */
.book-ai-flow {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 8px;
    margin: 26px 0;
    padding: 0;
    list-style: none;
}

.book-ai-flow li {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 10px;
    border-radius: 12px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.book-ai-flow li:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.04);
}

.book-ai-flow li > span {
    display: grid;
    flex: 0 0 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(216, 173, 82, 0.28);
    border-radius: 10px;
    color: #e6c975;
    font: 700 0.7rem var(--font-raleway, sans-serif);
    background: rgba(216, 173, 82, 0.08);
}

.book-ai-flow strong,
.book-ai-flow small {
    display: block;
}

.book-ai-flow strong {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.82rem;
}

.book-ai-flow small {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.46);
    font-size: 0.71rem;
    line-height: 1.4;
}

.book-ai-privacy {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.74rem;
    line-height: 1.45;
}

.book-ai-privacy i {
    color: #10b981;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Main Chat Viewport
   -------------------------------------------------------------------------- */
.book-ai-chat {
    display: grid;
    min-width: 0;
    grid-template-rows: auto 1fr auto;
    background: linear-gradient(180deg, rgba(11, 20, 36, 0.92) 0%, rgba(6, 12, 23, 0.98) 100%);
}

.book-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 82px;
    padding: 18px clamp(20px, 3.5vw, 36px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 15, 28, 0.6);
}

.book-ai-live {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.book-ai-live i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.75);
}

.book-ai-chat-header h3 {
    max-width: 520px;
    margin: 4px 0 0;
    overflow: hidden;
    color: #ffffff;
    font: 600 clamp(0.95rem, 1.8vw, 1.15rem) var(--font-playfair, serif);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* New Chat Button */
.book-ai-clear {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.74rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.book-ai-clear:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
}

.book-ai-clear:hover i {
    transform: rotate(-60deg);
}

.book-ai-clear i {
    font-size: 0.85rem;
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Save Chat Button Pill */
.book-ai-save {
    display: inline-grid;
    grid-template-columns: 28px auto 30px;
    align-items: center;
    gap: 8px;
    min-width: 156px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    color: rgba(255, 255, 255, 0.72);
    text-align: left;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.22s ease;
}

.book-ai-save:hover {
    transform: translateY(-1px);
    border-color: rgba(216, 173, 82, 0.32);
    background: rgba(216, 173, 82, 0.07);
}

.book-ai-save.active {
    border-color: rgba(16, 185, 129, 0.38);
    color: #ecfff7;
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.14), rgba(216, 173, 82, 0.05));
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.1);
}

.book-ai-save-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 8px;
    color: #e4c875;
    background: rgba(216, 173, 82, 0.1);
}

.book-ai-save.active .book-ai-save-icon {
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
}

.book-ai-save-copy strong {
    display: block;
    color: inherit;
    font-size: 0.73rem;
    line-height: 1.2;
}

.book-ai-save-copy small {
    display: block;
    margin-top: 1px;
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.58rem;
}

.book-ai-save-switch {
    position: relative;
    display: block;
    width: 28px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

.book-ai-save-switch i {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.52);
    transition: all 0.2s ease;
}

.book-ai-save.active .book-ai-save-switch {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.22);
}

.book-ai-save.active .book-ai-save-switch i {
    left: 14px;
    background: #34d399;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* --------------------------------------------------------------------------
   Messages Area
   -------------------------------------------------------------------------- */
.book-ai-messages {
    overflow-y: auto;
    min-height: 420px;
    max-height: 580px;
    padding: clamp(24px, 3.5vw, 36px);
    scrollbar-width: thin;
    scrollbar-color: rgba(216, 173, 82, 0.28) transparent;
}

.book-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.book-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(216, 173, 82, 0.28);
    border-radius: 6px;
}

/* Welcome Hero Box */
.book-ai-welcome {
    max-width: 640px;
    margin: 30px auto 20px;
    text-align: center;
}

.book-ai-welcome-icon {
    display: grid;
    width: 66px;
    height: 66px;
    margin: 0 auto 16px;
    place-items: center;
    border: 1px solid rgba(216, 173, 82, 0.32);
    border-radius: 20px;
    color: #f0d78c;
    font-size: 1.85rem;
    background: linear-gradient(145deg, rgba(216, 173, 82, 0.16), rgba(199, 40, 50, 0.18));
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35), 0 0 24px rgba(216, 173, 82, 0.15);
}

.book-ai-welcome-kicker {
    display: inline-block;
    color: #e6c975;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.book-ai-welcome h4 {
    margin: 8px 0 10px;
    color: #ffffff;
    font: 700 clamp(1.45rem, 2.8vw, 1.95rem) var(--font-playfair, serif);
}

.book-ai-welcome p {
    max-width: 520px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.88rem;
    line-height: 1.65;
}

/* Prompt Suggestion Cards (2x2 grid) */
.book-ai-prompts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 28px;
}

.book-ai-prompts button {
    display: flex;
    min-height: 78px;
    padding: 14px 16px;
    align-items: center;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.8);
    text-align: left;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.035);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.book-ai-prompts button:hover {
    transform: translateY(-2px);
    border-color: rgba(216, 173, 82, 0.36);
    color: #ffffff;
    background: linear-gradient(145deg, rgba(216, 173, 82, 0.08), rgba(255, 255, 255, 0.04));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3), 0 0 14px rgba(216, 173, 82, 0.12);
}

.book-ai-prompts button i {
    display: grid;
    flex: 0 0 36px;
    height: 36px;
    place-items: center;
    border-radius: 10px;
    color: #e6c975;
    font-size: 1.15rem;
    background: rgba(216, 173, 82, 0.1);
    border: 1px solid rgba(216, 173, 82, 0.18);
    transition: transform 0.2s ease;
}

.book-ai-prompts button:hover i {
    transform: scale(1.08);
    color: #fff3c9;
    background: rgba(216, 173, 82, 0.18);
}

/* --------------------------------------------------------------------------
   Message Items & Bubbles
   -------------------------------------------------------------------------- */
.book-ai-message {
    display: flex;
    gap: 13px;
    max-width: 86%;
    margin-bottom: 24px;
    animation: bookAiMessageIn 0.26s ease both;
}

@keyframes bookAiMessageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.book-ai-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.book-ai-avatar {
    display: grid;
    flex: 0 0 36px;
    height: 36px;
    place-items: center;
    border-radius: 12px;
    color: #f0d78c;
    font-size: 0.95rem;
    background: linear-gradient(135deg, rgba(216, 173, 82, 0.16), rgba(199, 40, 50, 0.16));
    border: 1px solid rgba(216, 173, 82, 0.24);
}

.book-ai-message.user .book-ai-avatar {
    color: #ffffff;
    background: linear-gradient(145deg, #c72832, #83121b);
    border-color: rgba(199, 40, 50, 0.4);
}

.book-ai-bubble {
    min-width: 0;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 6px 18px 18px 18px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.91rem;
    line-height: 1.76;
    background: rgba(14, 23, 42, 0.75);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.book-ai-message.user .book-ai-bubble {
    border-color: rgba(199, 40, 50, 0.28);
    border-radius: 18px 6px 18px 18px;
    color: #ffffff;
    background: linear-gradient(145deg, #c72832, #8a131e);
    box-shadow: 0 8px 26px rgba(199, 40, 50, 0.25);
}

.book-ai-bubble p {
    margin: 0 0 12px;
}

.book-ai-bubble p:last-child {
    margin-bottom: 0;
}

/* Markdown elements inside assistant bubble */
.book-ai-heading {
    margin: 16px 0 8px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -0.01em;
}

h5.book-ai-heading { font-size: 1.04rem; color: #f0d78c; }
h6.book-ai-heading { font-size: 0.94rem; color: #ffffff; }

.book-ai-list {
    margin: 8px 0 14px 20px;
    padding: 0;
}

.book-ai-list li {
    margin-bottom: 6px;
    line-height: 1.65;
}

.book-ai-quote {
    margin: 12px 0;
    padding: 8px 14px;
    border-left: 3px solid #d8ad52;
    background: rgba(216, 173, 82, 0.06);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: rgba(255, 255, 255, 0.84);
}

.book-ai-inline-code {
    padding: 2px 7px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    color: #fde047;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.84em;
    background: rgba(0, 0, 0, 0.35);
}

/* Citation Badges [1] */
.book-ai-citation {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 3px;
    padding: 2px 7px;
    border: 1px solid rgba(216, 173, 82, 0.35);
    border-radius: 6px;
    color: #f0d78c;
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: 1px;
    background: rgba(216, 173, 82, 0.1);
    cursor: pointer;
    transition: all 0.18s ease;
}

.book-ai-citation i {
    font-size: 0.65rem;
}

.book-ai-citation:hover {
    color: #070d18;
    background: #f0d78c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 215, 140, 0.4);
}

/* --------------------------------------------------------------------------
   Answer Action Controls (Listen, Copy, Sources)
   -------------------------------------------------------------------------- */
.book-ai-speech-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.book-ai-speech-button {
    display: inline-flex;
    min-width: 90px;
    height: 32px;
    padding: 0 12px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 9px;
    color: #6ee7b7;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
}

.book-ai-speech-button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(16, 185, 129, 0.55);
    color: #ecfdf5;
    background: rgba(16, 185, 129, 0.16);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}

.book-ai-speech-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.book-ai-speech-button[data-speech-state="playing"] {
    border-color: rgba(216, 173, 82, 0.45);
    color: #f0d78c;
    background: rgba(216, 173, 82, 0.12);
}

/* Copy Answer Button */
.book-ai-copy-button {
    display: inline-flex;
    height: 32px;
    padding: 0 11px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.18s ease;
}

.book-ai-copy-button:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
}

.book-ai-copy-button.copied {
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
}

.book-ai-voice-badge {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.64rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.book-ai-voice-badge i {
    color: #34d399;
}

/* Typing animation */
.book-ai-typing {
    display: inline-flex;
    gap: 5px;
    padding: 6px 4px;
}

.book-ai-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e6c975;
    animation: bookAiTyping 1.1s infinite ease-in-out;
}

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

@keyframes bookAiTyping {
    0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-4px); background: #34d399; }
}

/* Sources accordion */
.book-ai-sources {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.book-ai-sources-toggle {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto 14px;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid rgba(216, 173, 82, 0.16);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(216, 173, 82, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.book-ai-sources-label {
    display: flex;
    align-items: center;
    gap: 7px;
    text-align: left;
}

.book-ai-sources-label b {
    display: inline-grid;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    place-items: center;
    border-radius: 6px;
    color: #f0d78c;
    font-size: 0.64rem;
    background: rgba(216, 173, 82, 0.15);
}

.book-ai-sources-action {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.62rem;
}

.book-ai-sources-toggle:hover {
    border-color: rgba(216, 173, 82, 0.35);
    color: #f0d78c;
    background: rgba(216, 173, 82, 0.08);
}

.book-ai-sources-toggle > i {
    transition: transform 0.2s ease;
}

.book-ai-sources-toggle[aria-expanded="true"] > i {
    transform: rotate(180deg);
}

.book-ai-source-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    animation: bookAiMessageIn 0.22s ease both;
}

.book-ai-source-list[hidden] {
    display: none;
}

.book-ai-source {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: inherit;
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.book-ai-source:hover,
.book-ai-source.highlight {
    border-color: rgba(216, 173, 82, 0.4);
    background: rgba(216, 173, 82, 0.08);
    transform: translateX(2px);
}

.book-ai-source-number {
    display: grid;
    height: 28px;
    place-items: center;
    border-radius: 8px;
    color: #f0d78c;
    font-size: 0.7rem;
    font-weight: 800;
    background: rgba(216, 173, 82, 0.12);
}

.book-ai-source-copy strong {
    display: block;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.74rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-ai-source-copy small {
    display: block;
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.68rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-ai-source > i {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.8rem;
}

.book-ai-error {
    color: #f87171;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Toast Notice */
.book-ai-storage-toast {
    position: absolute;
    z-index: 12;
    top: 94px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: min(360px, calc(100% - 48px));
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.74rem;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(-8px);
    transition: all 0.22s ease;
}

.book-ai-storage-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.book-ai-storage-toast i {
    color: #e4c875;
}

.book-ai-storage-toast.saved {
    border-color: rgba(16, 185, 129, 0.3);
}

.book-ai-storage-toast.saved i {
    color: #34d399;
}

/* --------------------------------------------------------------------------
   Composer Wrap (Bottom Input Bar)
   -------------------------------------------------------------------------- */
.book-ai-composer-wrap {
    padding: 16px clamp(18px, 3.5vw, 36px) 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(6, 12, 23, 0.78);
    backdrop-filter: blur(16px);
}

.book-ai-locked {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
    padding: 9px 14px;
    border: 1px solid rgba(216, 173, 82, 0.25);
    border-radius: 12px;
    color: #f0d78c;
    font-size: 0.78rem;
    background: rgba(216, 173, 82, 0.08);
}

.book-ai-locked a {
    color: #ffffff;
    font-weight: 700;
    text-decoration: underline;
}

.book-ai-composer {
    position: relative;
    padding: 12px 14px 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.book-ai-composer:focus-within {
    border-color: rgba(216, 173, 82, 0.45);
    background: rgba(255, 255, 255, 0.065);
    box-shadow:
        0 16px 44px rgba(0, 0, 0, 0.35),
        0 0 0 3px rgba(216, 173, 82, 0.08);
}

.book-ai-composer textarea {
    display: block;
    width: 100%;
    max-height: 150px;
    resize: none;
    border: 0;
    outline: 0;
    color: #ffffff;
    font: 400 0.94rem/1.55 var(--font-raleway, sans-serif);
    background: transparent;
}

.book-ai-composer textarea::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

.book-ai-composer textarea:disabled {
    cursor: not-allowed;
}

.book-ai-composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.book-ai-composer-footer > span {
    color: rgba(255, 255, 255, 0.34);
    font-size: 0.65rem;
}

.book-ai-composer kbd {
    padding: 2px 5px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.58);
    font: inherit;
    background: rgba(255, 255, 255, 0.05);
}

.book-ai-composer button {
    display: inline-flex;
    min-width: 80px;
    height: 36px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #c72832, #8b121d);
    box-shadow: 0 6px 18px rgba(199, 40, 50, 0.32);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.book-ai-composer button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(199, 40, 50, 0.45);
}

.book-ai-composer button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
    box-shadow: none;
}

.book-ai-disclaimer {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.32);
    font-size: 0.64rem;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Responsive Layout & Media Queries
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .book-ai-shell {
        grid-template-columns: 1fr;
    }

    .book-ai-sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        padding: 26px 22px;
    }

    .book-ai-flow {
        grid-template-columns: repeat(3, 1fr);
    }

    .book-ai-flow li {
        align-items: flex-start;
    }

    .book-ai-privacy {
        padding-top: 16px;
    }
}

@media (max-width: 680px) {
    .book-ai-section {
        padding: 44px 0;
    }

    .book-ai-shell {
        min-height: 0;
        border-radius: 20px;
    }

    .book-ai-sidebar {
        padding: 22px 16px;
    }

    .book-ai-flow {
        grid-template-columns: 1fr;
    }

    .book-ai-flow li {
        padding: 7px 5px;
    }

    .book-ai-chat-header {
        min-height: 72px;
        padding: 14px 16px;
    }

    .book-ai-save-copy,
    .book-ai-composer-footer > span {
        display: none;
    }

    .book-ai-save {
        grid-template-columns: 28px 28px;
        min-width: 0;
        padding: 6px 7px;
    }

    .book-ai-storage-toast {
        top: 80px;
        right: 14px;
    }

    .book-ai-messages {
        min-height: 380px;
        max-height: 480px;
        padding: 20px 14px;
    }

    .book-ai-welcome {
        margin-top: 14px;
    }

    .book-ai-prompts {
        grid-template-columns: 1fr;
    }

    .book-ai-prompts button {
        min-height: 60px;
        padding: 12px 14px;
    }

    .book-ai-message {
        max-width: 96%;
    }

    .book-ai-composer-wrap {
        padding: 12px 14px 16px;
    }
}
