.dh-chat {
    --dh-chat-primary: var(--primary-color, #f58634);
    --dh-chat-primary-rgb: var(--primary-color-rgb, 245, 134, 52);
    --dh-chat-text: #1f2328;
    --dh-chat-muted: #6b7280;
    --dh-chat-border: #e5e7eb;
    --dh-chat-bg: #f6f7f9;
    font-family: var(--primary-font, inherit);
    font-size: 14px;
    line-height: 1.45;
    color: var(--dh-chat-text);
}

.dh-chat [hidden] {
    display: none !important;
}

.dh-chat__launcher {
    position: fixed;
    inset-inline-end: 30px;
    bottom: 90px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--dh-chat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(var(--dh-chat-primary-rgb), .4);
    transition: transform .2s ease;
}

.dh-chat__launcher:hover {
    transform: scale(1.06);
}

.dh-chat__launcher:focus-visible,
.dh-chat button:focus-visible,
.dh-chat input:focus-visible,
.dh-chat textarea:focus-visible {
    outline: 2px solid var(--dh-chat-primary);
    outline-offset: 2px;
}

.dh-chat__icon-close,
.dh-chat.is-open .dh-chat__icon-open {
    display: none;
}

.dh-chat.is-open .dh-chat__icon-close {
    display: block;
}

.dh-chat__badge {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e11d48;
    border: 2px solid #fff;
}

.dh-chat__panel {
    position: fixed;
    inset-inline-end: 30px;
    bottom: 156px;
    z-index: 1001;
    width: 370px;
    height: 540px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.dh-chat__title {
    font-weight: 600;
    font-size: 16px;
}

.dh-chat__subtitle {
    font-size: 12px;
    opacity: .9;
}

.dh-chat__close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.dh-chat__body {
    flex: 1;
    overflow-y: auto;
    background: var(--dh-chat-bg);
    padding: 14px;
    overscroll-behavior: contain;
}

.dh-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dh-chat__msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.dh-chat__msg--customer {
    align-self: flex-end;
    align-items: flex-end;
}

.dh-chat__msg--operator {
    align-self: flex-start;
    align-items: flex-start;
}

.dh-chat__msg--system {
    align-self: center;
    align-items: center;
    max-width: 100%;
}

.dh-chat__bubble {
    padding: 8px 12px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.dh-chat__msg--customer .dh-chat__bubble {
    background: var(--dh-chat-primary);
    color: #fff;
    border-end-end-radius: 4px;
}

.dh-chat__msg--operator .dh-chat__bubble {
    background: #fff;
    border: 1px solid var(--dh-chat-border);
    border-end-start-radius: 4px;
}

.dh-chat__msg--system .dh-chat__bubble {
    background: transparent;
    color: var(--dh-chat-muted);
    font-size: 12px;
    text-align: center;
    padding: 2px 8px;
}

.dh-chat__meta {
    font-size: 11px;
    color: var(--dh-chat-muted);
    margin-top: 3px;
    padding: 0 4px;
}

.dh-chat__intro {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.dh-chat__intro-text {
    margin: 0 0 4px;
    color: var(--dh-chat-muted);
    font-size: 13px;
}

.dh-chat input,
.dh-chat textarea {
    width: 100%;
    border: 1px solid var(--dh-chat-border);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    color: inherit;
    background: #fff;
    resize: none;
    margin: 0;
    height: auto;
}

.dh-chat .dh-chat__hp {
    position: absolute !important;
    left: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.dh-chat__btn {
    border: 0;
    border-radius: 8px;
    background: var(--dh-chat-primary);
    color: #fff;
    font-weight: 600;
    padding: 10px 14px;
    cursor: pointer;
}

.dh-chat__btn:disabled,
.dh-chat__send:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.dh-chat__notice {
    padding: 8px 14px;
    font-size: 12px;
    background: #fff7ed;
    color: #9a3412;
    border-top: 1px solid #fed7aa;
}

.dh-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--dh-chat-border);
    background: #fff;
}

.dh-chat__composer textarea {
    max-height: 120px;
    min-height: 40px;
}

.dh-chat__send {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--dh-chat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dh-chat__ended {
    padding: 12px 14px;
    border-top: 1px solid var(--dh-chat-border);
    background: #fff;
    text-align: center;
}

.dh-chat__ended p {
    margin: 0 0 8px;
    color: var(--dh-chat-muted);
    font-size: 13px;
}

[dir="rtl"] .dh-chat__send svg {
    transform: scaleX(-1);
}

/* Tablet & mobile: clear the theme's bottom navigation bar. */
@media (max-width: 768px) {
    .dh-chat__launcher {
        inset-inline-end: 16px;
        bottom: 125px;
        width: 52px;
        height: 52px;
    }

    .dh-chat__panel {
        inset-inline-end: 16px;
        bottom: 187px;
        max-height: calc(100vh - 210px);
    }
}

/* Phones: full-screen panel. */
@media (max-width: 575px) {
    .dh-chat__panel {
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .dh-chat.is-open .dh-chat__launcher {
        display: none;
    }

    .dh-chat input,
    .dh-chat textarea {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}
