.ar-chat {
    --ar-chat-bg: rgba(12, 18, 33, 0.92);
    --ar-chat-panel: rgba(15, 23, 42, 0.96);
    --ar-chat-card: rgba(255, 255, 255, 0.08);
    --ar-chat-border: rgba(255, 255, 255, 0.14);
    --ar-chat-text: #f8fafc;
    --ar-chat-muted: #a8b3c4;
    --ar-chat-accent: #f97316;
    --ar-chat-accent-2: #ffb000;
    --ar-chat-success: #34d399;
    --ar-chat-danger: #ef4444;

    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99999;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] .ar-chat {
    --ar-chat-bg: rgba(255, 255, 255, 0.92);
    --ar-chat-panel: rgba(255, 255, 255, 0.96);
    --ar-chat-card: rgba(15, 23, 42, 0.055);
    --ar-chat-border: rgba(15, 23, 42, 0.13);
    --ar-chat-text: #0f172a;
    --ar-chat-muted: #5f6b7c;
}

.ar-chat * {
    box-sizing: border-box;
}

.ar-chat button,
.ar-chat input,
.ar-chat textarea {
    font: inherit;
}

.ar-chat-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 18px;
    border: 1px solid rgba(249, 115, 22, 0.45);
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ar-chat-accent), var(--ar-chat-accent-2));
    box-shadow: 0 22px 50px rgba(249, 115, 22, 0.32);
    cursor: pointer;
    font-weight: 900;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.ar-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 28px 70px rgba(249, 115, 22, 0.42);
}

.ar-chat-launcher-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ar-chat-success);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.75);
    animation: arChatPulse 1.8s infinite;
}

.ar-chat-launcher-icon {
    font-size: 20px;
}

.ar-chat-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: min(390px, calc(100vw - 28px));
    overflow: hidden;
    border: 1px solid var(--ar-chat-border);
    border-radius: 28px;
    color: var(--ar-chat-text);
    background: var(--ar-chat-panel);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(22px);
    transform: translateY(14px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.ar-chat.is-open .ar-chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ar-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--ar-chat-border);
    background: var(--ar-chat-bg);
}

.ar-chat-header strong {
    display: block;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.ar-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 6px;
    color: var(--ar-chat-muted);
    font-size: 12px;
}

.ar-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ar-chat-muted);
}

.ar-chat-status-dot.is-online {
    background: var(--ar-chat-success);
}

.ar-chat-status-dot.is-offline {
    background: var(--ar-chat-accent);
}

.ar-chat-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--ar-chat-border);
    border-radius: 50%;
    color: var(--ar-chat-text);
    background: var(--ar-chat-card);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ar-chat-body {
    padding: 18px;
}

.ar-chat-welcome {
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid var(--ar-chat-border);
    border-radius: 22px;
    background: var(--ar-chat-card);
}

.ar-chat-welcome strong {
    display: block;
    margin-bottom: 7px;
    font-size: 18px;
}

.ar-chat-welcome p {
    margin: 0;
    color: var(--ar-chat-muted);
    font-size: 14px;
    line-height: 1.55;
}

.ar-chat-start-form,
.ar-chat-send-form {
    display: grid;
    gap: 10px;
}

.ar-chat-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ar-chat input,
.ar-chat textarea {
    width: 100%;
    border: 1px solid var(--ar-chat-border);
    border-radius: 16px;
    outline: none;
    color: var(--ar-chat-text);
    background: var(--ar-chat-card);
    padding: 12px 13px;
    resize: vertical;
}

.ar-chat input:focus,
.ar-chat textarea:focus {
    border-color: rgba(249, 115, 22, 0.8);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

.ar-chat input::placeholder,
.ar-chat textarea::placeholder {
    color: var(--ar-chat-muted);
}

.ar-chat-hp {
    position: absolute !important;
    left: -99999px !important;
    opacity: 0 !important;
}

.ar-chat-primary {
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--ar-chat-accent), var(--ar-chat-accent-2));
    box-shadow: 0 16px 32px rgba(249, 115, 22, 0.25);
    cursor: pointer;
    font-weight: 900;
}

.ar-chat-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.ar-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 9px;
    height: 330px;
    overflow-y: auto;
    padding: 4px 4px 12px;
    margin-bottom: 12px;
}

.ar-chat-bubble {
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 17px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.ar-chat-bubble small {
    display: block;
    margin-bottom: 5px;
    color: inherit;
    opacity: 0.72;
    font-size: 11px;
    font-weight: 800;
}

.ar-chat-bubble.visitor {
    align-self: flex-end;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ar-chat-accent), var(--ar-chat-accent-2));
    border-bottom-right-radius: 6px;
}

.ar-chat-bubble.dispatcher,
.ar-chat-bubble.system {
    align-self: flex-start;
    color: var(--ar-chat-text);
    background: var(--ar-chat-card);
    border: 1px solid var(--ar-chat-border);
    border-bottom-left-radius: 6px;
}

.ar-chat-send-form {
    grid-template-columns: 1fr auto;
    align-items: end;
}

.ar-chat-send-form textarea {
    min-height: 48px;
    max-height: 120px;
}

.ar-chat-send-form .ar-chat-primary {
    min-width: 86px;
    height: 48px;
}

.ar-chat-reset {
    margin-top: 10px;
    width: 100%;
    border: 1px solid var(--ar-chat-border);
    border-radius: 999px;
    color: var(--ar-chat-muted);
    background: var(--ar-chat-card);
    cursor: pointer;
    padding: 10px 12px;
    font-weight: 800;
}

.ar-chat-message-box {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--ar-chat-border);
    border-radius: 16px;
    color: var(--ar-chat-text);
    background: var(--ar-chat-card);
    font-size: 13px;
    line-height: 1.45;
}

@keyframes arChatPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.75);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(52, 211, 153, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
    }
}

@media (max-width: 560px) {
    .ar-chat {
        right: 14px;
        bottom: 14px;
    }

    .ar-chat-panel {
        right: -2px;
        bottom: 70px;
        width: calc(100vw - 24px);
        border-radius: 24px;
    }

    .ar-chat-two {
        grid-template-columns: 1fr;
    }

    .ar-chat-launcher-text {
        display: none;
    }

    .ar-chat-messages {
        height: 300px;
    }
}