.lb-storefront-chat {
    position: fixed;
    z-index: 90;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
}

.lb-storefront-chat [hidden] {
    display: none;
}

.lb-storefront-chat .lb-storefront-chat-launcher:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: #41789f;
    color: #fff;
    box-shadow: 0 8px 22px rgb(34 34 34 / 24%);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.lb-storefront-chat .lb-storefront-chat-launcher::before {
    content: "";
    flex: 0 0 18px;
    height: 18px;
    border-radius: 50% 50% 15% 50%;
    background: currentColor;
}

.lb-storefront-chat .lb-storefront-chat-launcher:not([hidden]):hover,
.lb-storefront-chat .lb-storefront-chat-launcher:not([hidden]):active {
    background: #356486;
}

.lb-storefront-chat .lb-storefront-chat-launcher:not([hidden]):focus-visible {
    outline: 2px solid #222;
    outline-offset: 3px;
    box-shadow: 0 0 0 3px #fff, 0 8px 22px rgb(34 34 34 / 24%);
}

.lb-storefront-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + .75rem);
    display: flex;
    flex-direction: column;
    width: min(25rem, calc(100vw - 2rem));
    height: min(36rem, calc(100vh - 7rem));
    height: min(36rem, calc(100dvh - 7rem));
    overflow: hidden;
    color: #222;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: .5rem;
    box-shadow: 0 .25rem 1.25rem rgb(0 0 0 / 18%);
}

.lb-storefront-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid #ddd;
}

.lb-storefront-chat-header h2 {
    margin: 0;
    font-size: 1.6rem;
}

.lb-storefront-chat-frame {
    flex: 1;
    min-height: 0;
}

.lb-storefront-chat-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.lb-storefront-chat-status {
    padding: 1rem;
}

@media (max-width: 767px) {
    .lb-storefront-chat {
        /* Clear Claue's fixed bottom navigation and the home indicator. */
        --lb-chat-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        --lb-chat-top: max(12px, env(safe-area-inset-top, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: var(--lb-chat-bottom);
        left: max(12px, env(safe-area-inset-left, 0px));
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
        max-height: calc(100vh - var(--lb-chat-bottom) - var(--lb-chat-top));
        max-height: calc(100dvh - var(--lb-chat-bottom) - var(--lb-chat-top));
        pointer-events: none;
    }

    .lb-storefront-chat .lb-storefront-chat-launcher:not([hidden]) {
        /* Leave a 10px gap beside the 40px back-to-top button at right: 15px. */
        order: 1;
        flex: none;
        max-width: calc(100% - 53px);
        margin-right: 53px;
        pointer-events: auto;
    }

    .lb-storefront-chat-panel {
        position: static;
        box-sizing: border-box;
        width: min(25rem, 100%);
        min-height: 0;
        height: 36rem;
        pointer-events: auto;
    }

    .lb-storefront-chat-header {
        flex-shrink: 0;
    }
}
