.q2u-chat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1050;
    font-size: 13px;
    line-height: 1.45;
    color: #333;
}

.q2u-chat__launcher {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    border: 0;
    border-radius: 24px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--q2u-primary, #cfad3c);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease;
}

.q2u-chat__launcher:hover {
    background: var(--q2u-primary-active, #ba992e);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}

.q2u-chat-launcher-enter {
    transition: opacity .22s cubic-bezier(.16, .84, .44, 1), transform .22s cubic-bezier(.16, .84, .44, 1);
}

.q2u-chat-launcher-enter-start {
    opacity: 0;
    transform: translateY(8px) scale(.7);
}

.q2u-chat-launcher-enter-end {
    opacity: 1;
    transform: none;
}

.q2u-chat-launcher-leave {
    transition: opacity .12s ease, transform .12s ease;
}

.q2u-chat-launcher-leave-start {
    opacity: 1;
    transform: none;
}

.q2u-chat-launcher-leave-end {
    opacity: 0;
    transform: scale(.85);
}

.q2u-chat__launcher-badge,
.q2u-chat__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ee4d2d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.q2u-chat__launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
}

.q2u-chat__panel {
    /* x-cloak (see markup) hides this pre-hydration; x-show needs the
       stylesheet default to be "flex" so it has the right value to restore. */
    width: 660px;
    max-width: calc(100vw - 32px);
    height: 470px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    overflow: hidden;
    transform-origin: bottom right;
}

.q2u-chat-panel-enter {
    transition: opacity .24s cubic-bezier(.16, .84, .44, 1), transform .24s cubic-bezier(.16, .84, .44, 1);
}

.q2u-chat-panel-enter-start {
    opacity: 0;
    transform: translateY(20px) scale(.94);
}

.q2u-chat-panel-enter-end {
    opacity: 1;
    transform: none;
}

.q2u-chat-panel-leave {
    transition: opacity .18s cubic-bezier(.4, 0, 1, 1), transform .18s cubic-bezier(.4, 0, 1, 1);
}

.q2u-chat-panel-leave-start {
    opacity: 1;
    transform: none;
}

.q2u-chat-panel-leave-end {
    opacity: 0;
    transform: translateY(20px) scale(.94);
}

.q2u-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #ededed;
}

.q2u-chat__title {
    font-size: 16px;
    font-weight: 700;
}

.q2u-chat__title-count {
    color: #888;
    font-weight: 400;
}

.q2u-chat__header-actions {
    display: flex;
    gap: 4px;
}

.q2u-chat__icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #fff;
    color: #777;
    font-size: 13px;
    cursor: pointer;
}

.q2u-chat__icon-btn:hover {
    color: #333;
    background: #f5f5f5;
}

.q2u-chat__body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.q2u-chat__list {
    width: 250px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ededed;
}

.q2u-chat__list-tools {
    display: flex;
    gap: 6px;
    padding: 10px;
}

.q2u-chat__search {
    position: relative;
    flex: 1;
}

.q2u-chat__search i {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    color: #bbb;
    font-size: 12px;
}

.q2u-chat__search input,
.q2u-chat__filter {
    width: 100%;
    height: 30px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    font-size: 12px;
    background: #fff;
    color: #333;
}

.q2u-chat__search input {
    padding: 0 8px 0 26px;
}

.q2u-chat__filter {
    width: 64px;
    padding: 0 4px;
}

.q2u-chat__list-scroll {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.q2u-chat__list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-bottom: 1px solid #f5f5f5;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.q2u-chat__list-item:hover {
    background: #fafafa;
}

.q2u-chat__list-item.is-active {
    background: #f2f2f2;
}

/*
 * Q2U Support: a sibling of list-tools/list-scroll inside the flex-column
 * .q2u-chat__list, not nested inside the scrollable area — list-scroll's flex: 1
 * already consumes the remaining height, so this naturally lands pinned at the
 * bottom of the panel (always visible, never scrolled out of view) without needing
 * margin-top: auto. Reordered to the top on mobile — see the media query below.
 */
.q2u-chat__list-item--support {
    border-top: 1px solid #ededed;
    border-bottom: 0;
}

.q2u-chat__list-item--support .q2u-chat__avatar {
    border-radius: 6px;
    object-fit: contain;
    background: #fff;
}

.q2u-chat__avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #f0f0f0;
}

.q2u-chat__list-body {
    flex: 1;
    min-width: 0;
}

.q2u-chat__list-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.q2u-chat__list-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q2u-chat__list-time,
.q2u-chat__list-preview {
    color: #999;
    font-size: 11px;
}

.q2u-chat__list-time {
    flex: none;
}

.q2u-chat__list-preview {
    display: block;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q2u-chat__empty,
.q2u-chat__placeholder {
    padding: 20px 14px;
    color: #999;
    font-size: 12px;
    text-align: center;
}

.q2u-chat__conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.q2u-chat__conversation-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 11px 14px;
    border-bottom: 1px solid #ededed;
    font-weight: 600;
}

.q2u-chat__conversation-header a,
.q2u-chat__conversation-name {
    color: #333;
}

/* Back-to-list control: mobile-only, switched on in the max-width: 767px block. */
.q2u-chat__back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: -6px;
    flex: none;
    border: 0;
    background: none;
    color: #333;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.q2u-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    background: #f5f5f5;
}

.q2u-chat__load-more {
    text-align: center;
    margin-bottom: 10px;
}

.q2u-chat__load-more button {
    border: 0;
    background: none;
    color: #666;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

.q2u-chat__date {
    text-align: center;
    margin: 8px 0 12px;
}

.q2u-chat__date span {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    background: #e8e8e8;
    color: #777;
    font-size: 11px;
}

.q2u-chat__row {
    display: flex;
    margin-bottom: 8px;
}

.q2u-chat__row.is-me {
    justify-content: flex-end;
}

.q2u-chat__bubble {
    max-width: 78%;
    padding: 8px 11px;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    word-break: break-word;
}

.q2u-chat__row.is-me .q2u-chat__bubble {
    background: var(--q2u-primary, #cfad3c);
    color: #fff;
}

.q2u-chat__time {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    color: #aaa;
    text-align: right;
}

.q2u-chat__row.is-me .q2u-chat__time {
    color: rgba(255, 255, 255, .8);
}

.q2u-chat__safety {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #f5e2b8;
    border-radius: 3px;
    background: #fff9e8;
    color: #8a6d3b;
    font-size: 11px;
}

.q2u-chat__composer {
    border-top: 1px solid #ededed;
    padding: 8px 10px;
}

.q2u-chat__composer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.q2u-chat__composer-row input {
    flex: 1;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    font-size: 13px;
}

.q2u-chat__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border: 0;
    border-radius: 3px;
    background: var(--q2u-primary, #cfad3c);
    color: #fff;
    cursor: pointer;
}

.q2u-chat__send:disabled {
    opacity: .6;
    cursor: default;
}

.q2u-chat__guest {
    margin-bottom: 8px;
}

.q2u-chat__guest p {
    margin: 0 0 5px;
    color: #888;
    font-size: 11px;
}

.q2u-chat__guest-fields {
    display: flex;
    gap: 6px;
}

.q2u-chat__guest-fields input {
    flex: 1;
    width: 100%;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    font-size: 12px;
}

.q2u-chat__error {
    display: block;
    margin-top: 4px;
    color: #d9534f;
    font-size: 11px;
}

@media (prefers-reduced-motion: reduce) {

    .q2u-chat-launcher-enter,
    .q2u-chat-launcher-leave,
    .q2u-chat-panel-enter,
    .q2u-chat-panel-leave {
        transition: opacity .01ms !important;
    }
}

@media (max-width: 767px) {
    /*
     * Full-screen takeover, WhatsApp-style. The launcher stays pinned bottom-right;
     * only the open panel escapes to cover the viewport (position: fixed, so it
     * clears the site's sticky header — hence the high z-index to match the
     * stylesheet's top tier).
     */
    .q2u-chat {
        right: 12px;
        bottom: 12px;
        z-index: 9999;
    }

    .q2u-chat__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        transform-origin: center;
    }

    /*
     * The body stops being a two-column row: it shows exactly one full-bleed view
     * at a time, chosen by the is-list / is-conversation class Alpine puts on the
     * panel (bound to listOpen). The other view is display:none, so only one
     * header/composer is in play.
     */
    .q2u-chat__list,
    .q2u-chat__conversation {
        width: 100%;
        border-right: 0;
    }

    .q2u-chat__panel.is-list .q2u-chat__conversation {
        display: none;
    }

    .q2u-chat__panel.is-conversation .q2u-chat__list {
        display: none;
    }

    /* In a conversation the generic "Chat" bar is redundant with the thread's own
       header, which carries the back arrow — so drop it. */
    .q2u-chat__panel.is-conversation .q2u-chat__header {
        display: none;
    }

    .q2u-chat__back {
        display: inline-flex;
    }

    /* Roomier rows and controls for touch. */
    .q2u-chat__list-item {
        padding: 12px 14px;
    }

    .q2u-chat__list-tools {
        padding: 10px 12px;
    }

    /* Pinned ahead of the search bar on mobile — one-tap access to Q2U without
       scrolling past it first. Desktop leaves it in natural (bottom) flow. */
    .q2u-chat__list-item--support {
        order: -1;
        border-top: 0;
        border-bottom: 1px solid #ededed;
    }
}
