.support-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12050;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    background: transparent;
}

.support-chat-backdrop.hidden { display: none; }

.support-chat-panel {
    width: min(460px, 100%);
    height: min(680px, calc(100dvh - 36px));
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
    color: #eef0ff;
    background: linear-gradient(155deg, #171a26, #0d1019 70%);
    border: 1px solid rgba(164, 136, 255, .32);
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .58);
    font: 14px/1.45 Inter, system-ui, sans-serif;
}

.support-chat-panel.is-dragged {
    position: fixed;
    right: auto;
    bottom: auto;
}

.support-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.support-chat-panel.is-dragging .support-chat-header { cursor: grabbing; }

.support-chat-header > div { display: flex; gap: 11px; align-items: center; }
.support-chat-header .support-chat-actions { gap: 8px; }
.support-chat-header h2 { margin: 0; font-size: 18px; }
.support-chat-header p { margin: 2px 0 0; color: #a8acbf; font-size: 12px; }
.support-chat-presence { width: 11px; height: 11px; border-radius: 50%; background: #43d990; box-shadow: 0 0 0 4px rgba(67,217,144,.13); }

.support-chat-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    color: #e9e9f4;
    background: rgba(255,255,255,.08);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.support-chat-new {
    padding: 8px 11px;
    border: 1px solid rgba(164, 136, 255, .32);
    border-radius: 10px;
    color: #dcd6ff;
    background: rgba(111, 82, 221, .12);
    font: 700 12px/1 Inter, system-ui, sans-serif;
    cursor: pointer;
}
.support-chat-new:hover { background: rgba(111, 82, 221, .24); }

.support-chat-status {
    padding: 8px 16px;
    color: #b9b5ff;
    background: rgba(111, 82, 221, .12);
    font-size: 12px;
}
.support-chat-status[data-kind="error"] { color: #ffb6bf; background: rgba(194, 48, 70, .16); }
.support-chat-status[data-kind="success"] { color: #9ce8bf; background: rgba(40, 156, 98, .14); }

.support-chat-messages {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
}

.support-chat-message { max-width: 86%; }
.support-chat-message.is-user { align-self: flex-end; }
.support-chat-message.is-staff { align-self: flex-start; }
.support-chat-message p {
    margin: 0;
    padding: 11px 13px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border-radius: 16px 16px 16px 5px;
    background: #252a3b;
}
.support-chat-message.is-user p {
    border-radius: 16px 16px 5px 16px;
    background: linear-gradient(135deg, #6f4fe4, #8648db);
}
.support-chat-message time { display: block; padding: 4px 5px 0; color: #858ba0; font-size: 10px; }
.support-chat-message.is-user time { text-align: right; }

.support-chat-empty {
    margin: auto;
    display: grid;
    gap: 5px;
    max-width: 280px;
    text-align: center;
    color: #9ca1b5;
}
.support-chat-empty strong { color: #f2f2fa; font-size: 17px; }
.support-chat-closed { padding: 10px; border-radius: 10px; color: #bfc3d3; background: rgba(255,255,255,.05); font-size: 12px; text-align: center; }

.support-chat-compose {
    padding: 13px;
    background: rgba(5, 7, 13, .62);
    border-top: 1px solid rgba(255,255,255,.08);
}
.support-chat-compose textarea {
    box-sizing: border-box;
    width: 100%;
    resize: none;
    padding: 11px 12px;
    color: #f4f4fb;
    background: #171b28;
    border: 1px solid #343a50;
    border-radius: 12px;
    outline: none;
    font: inherit;
}
.support-chat-compose textarea:focus { border-color: #8060ea; box-shadow: 0 0 0 3px rgba(128,96,234,.16); }
.support-chat-compose > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.support-chat-compose small { color: #858ba0; font-size: 10px; }
.support-chat-compose button {
    min-width: 78px;
    padding: 9px 16px;
    border: 0;
    border-radius: 10px;
    color: white;
    background: linear-gradient(135deg, #7656e9, #8e4de0);
    font-weight: 700;
    cursor: pointer;
}
.support-chat-compose button:disabled { opacity: .55; cursor: wait; }

.mobile-popover-menu button[onclick*="openSupportChat"]::before { content: "\1F4AC"; font-size: 14px; }

@media (max-width: 600px) {
    body.support-chat-open { overflow: hidden; }
    .support-chat-backdrop {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        background: #0d1019;
    }
    .support-chat-panel {
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100%;
        height: 100dvh;
        max-width: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .support-chat-header {
        padding-top: max(18px, env(safe-area-inset-top));
        cursor: default;
        touch-action: auto;
    }
    .support-chat-compose { padding-bottom: max(13px, env(safe-area-inset-bottom)); }
}
