.ai-chat-root {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 9998;
    font-family: inherit;
}

.ai-chat-fab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--site-accent, #f7858d);
    color: #fff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-chat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}

.ai-chat-fab .mdi {
    font-size: 1.35rem;
}

.ai-chat-panel {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    left: 0;
    width: min(360px, calc(100vw - 2rem));
    max-height: min(520px, calc(100vh - 6rem));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-panel[hidden] {
    display: none !important;
}

.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, var(--site-accent, #f7858d), #e86b74);
    color: #fff;
}

.ai-chat-header strong {
    display: block;
    font-size: 0.95rem;
}

.ai-chat-audience-notice {
    display: block;
    margin-top: 0.25rem;
    opacity: 0.92;
    font-size: 0.72rem;
    line-height: 1.5;
}

.ai-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: #fafafa;
    min-height: 200px;
    max-height: 320px;
}

.ai-chat-msg {
    margin-bottom: 0.65rem;
    display: flex;
}

.ai-chat-msg--user {
    justify-content: flex-end;
}

.ai-chat-msg--assistant {
    justify-content: flex-start;
}

.ai-chat-bubble {
    max-width: 88%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-msg--user .ai-chat-bubble {
    background: var(--site-accent, #f7858d);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.ai-chat-msg--assistant .ai-chat-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #eee;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg--typing .ai-chat-bubble {
    opacity: 0.7;
    font-style: italic;
}

.ai-chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: flex-end;
}

.ai-chat-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.5rem 0.65rem;
    font-family: inherit;
    font-size: 0.85rem;
    min-height: 2.5rem;
}

.ai-chat-form textarea:focus {
    outline: none;
    border-color: var(--site-accent, #f7858d);
}

.ai-chat-send {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: var(--site-accent, #f7858d);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-chat-footnote {
    margin: 0;
    padding: 0.35rem 0.75rem 0.65rem;
    font-size: 0.68rem;
    color: #888;
    background: #fff;
}

@media (max-width: 480px) {
    .ai-chat-root {
        left: 0.75rem;
        bottom: 4.5rem;
    }

    .ai-chat-fab-label {
        display: none;
    }

    .ai-chat-panel {
        width: calc(100vw - 1.5rem);
    }
}
