#ai-chat-root {
    --ai-chat-accent: #133e56;
    color: #172033;
    font-family: Arial, sans-serif;
}

.ai-chat-button {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9998;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: var(--ai-chat-accent);
    color: #fff;
    box-shadow: 0 14px 36px rgba(18, 33, 64, .24);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.ai-chat-button svg {
    width: 40px;
    height: 40px;
}

.ai-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 92px;
    z-index: 9999;
    width: min(380px, calc(100vw - 28px));
    height: min(620px, calc(100vh - 118px));
    display: none;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dfe5f1;
    border-radius: 14px;
    box-shadow: 0 22px 64px rgba(18, 33, 64, .28);
}

.ai-chat-panel.is-open {
    display: grid;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    color: #fff;
    background: var(--ai-chat-accent);
}

.ai-chat-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
}

.ai-chat-subtitle {
    margin-top: 3px;
    font-size: 12px;
    opacity: .86;
}

.ai-chat-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .18);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.ai-chat-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
}

.ai-chat-message-list {
    flex: 1 0 auto;
}

.ai-chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.ai-chat-message-row.visitor {
    justify-content: flex-end;
}

.ai-chat-message-stack {
    max-width: 82%;
    display: grid;
    gap: 3px;
}

.ai-chat-message-stack.visitor {
    justify-items: end;
}

.ai-chat-message-name {
    color: #687385;
    font-size: 12px;
    line-height: 1.2;
    padding: 0 3px;
}

.ai-chat-message-name.visitor {
    text-align: right;
}

.ai-chat-avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    background: #71809a;
    font-weight: 700;
    font-size: 12px;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(18, 33, 64, .12);
}

.ai-chat-avatar.visitor {
    background: var(--ai-chat-accent);
}

.ai-chat-avatar.system {
    background: #9aa4b5;
    font-family: Georgia, serif;
    font-style: italic;
}

.ai-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-chat-message {
    width: fit-content;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e7f0;
    line-height: 1.38;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ai-chat-message.visitor {
    color: #fff;
    background: var(--ai-chat-accent);
    border-color: var(--ai-chat-accent);
}

.ai-chat-message.system {
    margin-right: auto;
    color: #526072;
    background: #eef2f7;
}

.ai-chat-form {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e4e9f2;
    background: #fff;
}

.ai-chat-contact {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
}

.ai-chat-contact[hidden] {
    display: none;
}

.ai-chat-input,
.ai-chat-contact input,
.ai-chat-contact-send {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cfd7e6;
    border-radius: 10px;
    padding: 10px 11px;
    font: inherit;
    font-size: 14px;
    outline: none;
}

.ai-chat-contact-send {
    width: auto;
    border-color: var(--ai-chat-accent);
    color: var(--ai-chat-accent);
    background: #fff;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.ai-chat-contact-send:disabled {
    cursor: progress;
    opacity: .72;
}

.ai-chat-input:focus,
.ai-chat-contact input:focus {
    border-color: var(--ai-chat-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-chat-accent), transparent 82%);
}

.ai-chat-contact-state {
    color: #687385;
    font-size: 12px;
    line-height: 1.2;
}

.ai-chat-contact-state:empty {
    display: none;
}

.ai-chat-quick-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding: 8px 0 0;
    background: linear-gradient(to bottom, rgba(245, 247, 251, 0), #f5f7fb 38%);
}

.ai-chat-quick-actions[hidden] {
    display: none;
}

.ai-chat-manager-call {
    flex: 0 1 calc(33.333% - 4px);
    min-width: 96px;
    border: 1px solid color-mix(in srgb, var(--ai-chat-accent), #fff 42%);
    border-radius: 8px;
    color: #fff;
    background: color-mix(in srgb, var(--ai-chat-accent), #26364f 10%);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.15;
    padding: 7px 9px;
}

.ai-chat-manager-call:disabled {
    cursor: progress;
    opacity: .72;
}

.ai-chat-manager-call[hidden] {
    display: none;
}

.ai-chat-compose {
    display: grid;
    grid-template-columns: 1fr 42px;
    gap: 8px;
}

.ai-chat-send {
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--ai-chat-accent);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.ai-chat-send:disabled {
    cursor: progress;
    opacity: .7;
}

@media (max-width: 520px) {
    .ai-chat-panel {
        right: 10px;
        bottom: 82px;
        width: calc(100vw - 20px);
        height: min(620px, calc(100vh - 102px));
    }

    .ai-chat-button {
        right: 14px;
        bottom: 14px;
    }

    .ai-chat-contact {
        grid-template-columns: 1fr;
    }

    .ai-chat-contact-send {
        width: 100%;
    }
}
