.dm-support-chat {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1040;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --dm-support-chat-safe-top: 8px;
    --dm-support-chat-gutter: 12px;
}

.dm-support-chat__launcher {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: #059669;
    color: #ffffff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.dm-support-chat__launcher:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.26);
}

.dm-support-chat__launcher-icon {
    font-size: 26px;
    line-height: 1;
    font-weight: 800;
}

.dm-support-chat__panel {
    width: min(400px, calc(100vw - 28px));
    height: min(640px, calc(100dvh - var(--dm-support-chat-safe-top) - var(--dm-support-chat-gutter)));
    min-height: min(420px, calc(100dvh - var(--dm-support-chat-safe-top) - var(--dm-support-chat-gutter)));
    background: #ffffff;
    border: 1px solid #dbe3ea;
    border-radius: 8px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
    display: grid;
    grid-template-rows: auto 1fr auto auto auto;
    overflow: hidden;
}

.dm-support-chat__panel[hidden],
.dm-support-chat__launcher[hidden] {
    display: none !important;
}

.dm-support-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.dm-support-chat--dragging .dm-support-chat__header {
    cursor: grabbing;
}

.dm-support-chat__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.dm-support-chat__brand > div:last-child {
    min-width: 0;
}

.dm-support-chat__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex: 0 0 auto;
}

.dm-support-chat__title {
    font-weight: 700;
    color: #111827;
    font-size: 14px;
    line-height: 1.2;
}

.dm-support-chat__status {
    color: #6b7280;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-support-chat__back,
.dm-support-chat__close {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 0;
    background: transparent;
    color: #374151;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.dm-support-chat__back:hover,
.dm-support-chat__close:hover {
    background: #f3f4f6;
}

.dm-support-chat__clear {
    flex: 0 0 auto;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    border-radius: 6px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.dm-support-chat__clear:hover {
    background: #f8fafc;
    color: #1f2937;
}

.dm-support-chat__clear[hidden] {
    display: none !important;
}

.dm-support-chat__header > .dm-support-chat__clear {
    display: none !important;
}

.dm-support-chat__messages {
    overflow-y: auto;
    padding: 18px 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dm-support-chat__empty {
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
    display: grid;
    gap: 6px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.dm-support-chat__message {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.dm-support-chat__message--user {
    align-self: flex-end;
    color: #ffffff;
    background: #059669;
}

.dm-support-chat__message--support {
    align-self: flex-start;
    color: #1f2937;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.dm-support-chat__message-author {
    font-size: 11px;
    color: #64748b;
    margin: 0 0 4px 2px;
}

.dm-support-chat__message--user .dm-support-chat__message-author {
    color: rgba(255, 255, 255, 0.82);
}

.dm-support-chat__message a {
    color: #2563eb;
    font-weight: 600;
}

.dm-support-chat__message--user a {
    color: #ffffff;
}

.dm-support-chat__message strong {
    font-weight: 700;
}

.dm-support-chat__typing {
    align-self: flex-start;
    color: #64748b;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}

.dm-support-chat__contact {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    display: grid;
    gap: 8px;
}

.dm-support-chat__contact[hidden] {
    display: none !important;
}

.dm-support-chat__contact-title {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
}

.dm-support-chat__contact input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
}

.dm-support-chat__files {
    border-top: 1px solid #e5e7eb;
    padding: 8px 14px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
}

.dm-support-chat__files[hidden] {
    display: none !important;
}

.dm-support-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px 10px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.dm-support-chat__file-button,
.dm-support-chat__send {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    min-height: 38px;
}

.dm-support-chat__file-button {
    width: 38px;
    background: #e2e8f0;
    color: #1f2937;
    font-size: 20px;
    line-height: 1;
}

.dm-support-chat__send {
    padding: 0 14px;
    background: #2563eb;
    color: #ffffff;
}

.dm-support-chat__send:disabled,
.dm-support-chat__file-button:disabled,
.dm-support-chat__handoff:disabled,
.dm-support-chat__clear:disabled {
    opacity: 0.62;
    cursor: wait;
}

.dm-support-chat__input {
    flex: 1;
    min-height: 38px;
    max-height: 112px;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.35;
}

.dm-support-chat__input:focus,
.dm-support-chat__contact input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.dm-support-chat__footer {
    padding: 0 14px 12px;
    background: #ffffff;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 8px;
}

.dm-support-chat__handoff {
    grid-column: 2;
    border: 0;
    background: transparent;
    color: #2563eb;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.dm-support-chat__footer .dm-support-chat__clear {
    grid-column: 1;
    justify-self: start;
}

@media (max-width: 520px) {
    .dm-support-chat {
        right: 12px;
        bottom: 12px;
    }

    .dm-support-chat__panel {
        width: calc(100vw - 24px);
        height: calc(100dvh - var(--dm-support-chat-safe-top) - 8px);
        min-height: 0;
    }
}
