.live-support {
    --ls-bg: #07101b;
    --ls-panel: #0b1522;
    --ls-panel-soft: #101c2c;
    --ls-border: #24445f;
    --ls-text: #edf8ff;
    --ls-muted: #8ca7bb;
    --ls-cyan: #55def4;
    --ls-green: #42e887;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1100;
    color: var(--ls-text);
    font-family: inherit;
}

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

.live-support-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 190px;
    padding: 10px 15px 10px 10px;
    border: 1px solid #32617f;
    border-radius: 15px;
    background: #0b1725;
    color: var(--ls-text);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .38);
    cursor: pointer;
    text-align: left;
}

.live-support-launcher:hover,
.live-support-launcher:focus-visible {
    border-color: var(--ls-cyan);
    outline: none;
}

.live-support-launcher-icon {
    display: block;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    object-fit: contain;
    filter: drop-shadow(0 0 7px rgba(85, 222, 244, .18));
}

.live-support-launcher strong,
.live-support-launcher small { display: block; }
.live-support-launcher strong { font-size: 13px; }
.live-support-launcher small { margin-top: 2px; color: var(--ls-muted); font-size: 10px; }
.live-support-launcher i {
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-radius: 50%;
    background: #ff6678;
}

.live-support-panel {
    position: absolute;
    right: 0;
    /* Keep the panel visibly separated from the launcher. */
    bottom: 72px;
    width: min(370px, calc(100vw - 30px));
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
    overflow: hidden;
    border: 1px solid var(--ls-border);
    border-radius: 16px;
    background: var(--ls-bg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .58);
}

.live-support-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px 14px;
    border-bottom: 1px solid #1a344a;
    background: linear-gradient(135deg, #102237, #0b1725);
}

.live-support-header > div:first-child {
    display: grid;
    grid-template-columns: 34px 9px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
}
.live-support-header-logo { grid-row: 1 / 3; width: 34px; height: 34px; object-fit: contain; }
.live-support-header strong { grid-column: 3; font-size: 14px; }
.live-support-header small { grid-column: 3; color: var(--ls-muted); font-size: 10px; }
.live-support-presence-dot { grid-column: 2; grid-row: 1; }
.live-support-presence-dot { width: 8px; height: 8px; border-radius: 50%; background: #6c7e8e; }
.live-support-presence-dot.online { background: var(--ls-green); box-shadow: 0 0 10px rgba(66, 232, 135, .6); }
.live-support-header-actions { display: flex; align-items: center; gap: 8px; }
.live-support-header-actions a { color: var(--ls-cyan); font-size: 10px; text-decoration: none; }
.live-support-header-actions button,
.live-support-ticket button {
    border: 0;
    background: transparent;
    color: var(--ls-muted);
    cursor: pointer;
}
.live-support-header-actions button { width: 28px; height: 28px; font-size: 18px; }

.live-support-loading { padding: 32px 20px; color: var(--ls-muted); text-align: center; font-size: 12px; }
.live-support-start { display: grid; gap: 10px; max-height: min(650px, calc(100vh - 130px)); max-height: min(650px, calc(100dvh - 130px)); padding: 15px; overflow-y: auto; }
.live-support-intro strong { font-size: 15px; }
.live-support-intro p { margin: 5px 0 2px; color: var(--ls-muted); font-size: 11px; line-height: 1.5; }
.live-support-session-ended {
    margin: 0;
    padding: 9px 10px;
    border: 1px solid rgba(85, 222, 244, .34);
    border-radius: 8px;
    background: rgba(34, 102, 126, .18);
    color: #bdefff;
    font-size: 11px;
    line-height: 1.45;
}
.live-support-start label { display: grid; gap: 5px; color: #c7dceb; font-size: 10px; font-weight: 700; letter-spacing: .03em; }
.live-support-start > div[data-live-support-guest-fields] { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.live-support-start input,
.live-support-start select,
.live-support-start textarea,
.live-support-compose textarea,
.live-desk textarea {
    width: 100%;
    border: 1px solid #29455d;
    border-radius: 8px;
    background: #060d15;
    color: var(--ls-text);
    font: inherit;
    outline: none;
}
.live-support-start input,
.live-support-start select { min-height: 36px; padding: 7px 9px; }
.live-support-start textarea,
.live-support-compose textarea { resize: none; padding: 9px; }
.live-support-start input:focus,
.live-support-start select:focus,
.live-support-start textarea:focus,
.live-support-compose textarea:focus { border-color: var(--ls-cyan); box-shadow: 0 0 0 2px rgba(85, 222, 244, .1); }
.live-support-notice { margin: 0; color: #d6a66c; font-size: 10px; line-height: 1.4; }
.live-support-error { margin: 0; color: #ff8795; font-size: 11px; }
.live-support-primary {
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    background: linear-gradient(90deg, #61e7f4, #46cbea);
    color: #041019;
    font-weight: 800;
    cursor: pointer;
}
.live-support-primary:disabled { opacity: .55; cursor: wait; }

.live-support-chat { display: grid; height: min(560px, calc(100vh - 118px)); height: min(560px, calc(100dvh - 118px)); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.live-support-ticket { display: flex; justify-content: space-between; padding: 8px 13px; border-bottom: 1px solid #172d40; color: var(--ls-muted); font-size: 10px; }
.live-support-ticket button { color: #ff8795; font-size: 10px; }
.live-support-messages,
.live-desk-messages { overflow-y: auto; scrollbar-color: #36536b transparent; }
.live-support-messages { min-height: 0; padding: 14px; background: radial-gradient(circle at 20% 10%, rgba(45, 98, 132, .12), transparent 42%); }
.live-support-message { position: relative; display: flex; flex-direction: column; align-items: flex-start; margin: 8px 0; }
.live-support-message.agent { padding-left: 34px; }
.live-support-message.agent::before {
    position: absolute;
    left: 0;
    bottom: 1px;
    width: 27px;
    height: 27px;
    background: url('/images/cbbot-mark.svg') center / contain no-repeat;
    content: "";
}
.live-support-message.own { align-items: flex-end; }
.live-support-message small { margin-bottom: 4px; color: #71899d; font-size: 8px; }
.live-support-message p { max-width: 82%; margin: 0; padding: 9px 11px; border: 1px solid #213e56; border-radius: 11px 11px 11px 3px; background: var(--ls-panel-soft); color: var(--ls-text); font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.live-support-message.own p { border-color: #24708a; border-radius: 11px 11px 3px 11px; background: #0e3f52; }
.live-support-compose { display: grid; grid-template-columns: 1fr 40px; gap: 8px; padding: 10px; border-top: 1px solid #1a344a; background: #09121d; }
.live-support-compose button { border: 0; border-radius: 9px; background: #46cbea; color: #041019; font-size: 18px; cursor: pointer; }
.live-support-chat > .live-support-error { padding: 0 10px 9px; }

.live-desk-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; min-height: 610px; overflow: hidden; border: 1px solid #233e54; border-radius: 14px; background: #08111b; }
.live-desk-sidebar { border-right: 1px solid #233e54; }
.live-desk-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid #233e54; }
.live-desk-tabs button { padding: 13px 8px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #87a3b8; cursor: pointer; }
.live-desk-tabs button.active { border-color: #55def4; color: #effbff; }
.live-desk-sidebar [data-live-desk-list] { max-height: 560px; overflow-y: auto; }
.live-desk-row { width: 100%; padding: 13px; border: 0; border-bottom: 1px solid #172c3d; background: transparent; color: #e6f5ff; text-align: left; cursor: pointer; }
.live-desk-row:hover,
.live-desk-row.active { background: #102236; }
.live-desk-row strong,
.live-desk-row small { display: block; }
.live-desk-row small { margin-top: 5px; color: #7894a9; }
.live-desk-conversation { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.live-desk-conversation > header { min-height: 55px; padding: 17px 20px; border-bottom: 1px solid #233e54; color: #e9f8ff; font-weight: 700; }
.live-desk-messages { max-height: 500px; padding: 18px; }
.live-desk-message { position: relative; display: flex; flex-direction: column; align-items: flex-start; margin: 9px 0; }
.live-desk-message.agent { align-items: flex-end; padding-right: 36px; }
.live-desk-message.agent::after {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 29px;
    height: 29px;
    background: url('/images/cbbot-mark.svg') center / contain no-repeat;
    content: "";
}
.live-desk-message small { margin-bottom: 4px; color: #7995aa; font-size: 10px; }
.live-desk-message p { max-width: 76%; margin: 0; padding: 10px 12px; border: 1px solid #29475f; border-radius: 11px 11px 11px 3px; background: #111f2d; color: #edf8ff; white-space: pre-wrap; overflow-wrap: anywhere; }
.live-desk-message.agent p { border-color: #24728b; border-radius: 11px 11px 3px 11px; background: #104055; }
.live-desk-conversation form { padding: 14px; border-top: 1px solid #233e54; }
.live-desk-conversation form textarea { min-height: 84px; padding: 10px; }
.live-desk-conversation form > div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.live-desk-availability { display: flex; align-items: center; gap: 8px; color: #a9c0d0; }

@media (max-width: 760px) {
    .live-support {
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
    }
    .live-support-panel {
        position: fixed;
        right: 10px;
        bottom: calc(82px + env(safe-area-inset-bottom));
        left: 10px;
        width: auto;
        max-height: calc(100vh - 106px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 106px - env(safe-area-inset-bottom));
    }
    .live-support-start {
        max-height: calc(100vh - 160px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 160px - env(safe-area-inset-bottom));
    }
    .live-support-chat {
        height: min(560px, calc(100vh - 104px - env(safe-area-inset-bottom)));
        height: min(560px, calc(100dvh - 104px - env(safe-area-inset-bottom)));
        grid-template-rows: auto minmax(0, 1fr) auto auto;
    }
    .live-support-messages { min-height: 0; }
    .live-support-start > div[data-live-support-guest-fields] { grid-template-columns: 1fr; }
    .live-desk-grid { grid-template-columns: 1fr; }
    .live-desk-sidebar { border-right: 0; border-bottom: 1px solid #233e54; }
    .live-desk-sidebar [data-live-desk-list] { max-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
    .live-support * { scroll-behavior: auto !important; }
}
