.ai-support-launcher-root {
    --ai-support-offset: 1rem;
    --ai-support-panel-width: min(25.5rem, calc(100vw - 2rem));
    --ai-support-kb-offset: 0px;
    position: fixed;
    right: 1rem;
    bottom: calc(var(--ai-support-offset) + env(safe-area-inset-bottom));
    z-index: 9800;
    pointer-events: none;
}

.ai-support-launcher-root[hidden] {
    display: none !important;
}

.ai-support-launcher-root[data-banner-visible="true"] {
    --ai-support-offset: 8.75rem;
}

.ai-support-launcher {
    position: relative;
    display: grid;
    justify-items: end;
    pointer-events: auto;
}

.ai-support-launcher__backdrop {
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.ai-support-launcher__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 3.85rem;
    padding: 0.72rem 1rem 0.72rem 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    box-shadow:
        0 18px 36px rgba(15, 23, 42, 0.22),
        0 8px 22px rgba(249, 115, 22, 0.32);
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
}

.ai-support-launcher__trigger:hover {
    transform: translateY(-2px);
    box-shadow:
        0 22px 44px rgba(15, 23, 42, 0.24),
        0 12px 26px rgba(249, 115, 22, 0.38);
}

.ai-support-launcher__trigger:focus-visible,
.ai-support-launcher__close:focus-visible,
.ai-support-launcher__prompt-btn:focus-visible,
.ai-support-launcher__textarea:focus-visible {
    outline: 3px solid rgba(14, 165, 233, 0.28);
    outline-offset: 2px;
}

.ai-support-launcher__trigger-icon {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ai-support-launcher__icon-svg {
    width: 1.35rem;
    height: 1.35rem;
}

.ai-support-launcher__trigger-copy {
    display: grid;
    gap: 0.08rem;
    text-align: left;
}

.ai-support-launcher__trigger-eyebrow {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 0.94rem;
    font-weight: 700;
    line-height: 1.1;
}

.ai-support-launcher__trigger-hint {
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.72rem;
    line-height: 1.1;
    color: rgba(255, 255, 255, 0.82);
}

/* ── Panel (chat window) ── */

.ai-support-launcher__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.95rem);
    width: var(--ai-support-panel-width);
    max-height: min(42rem, 74vh);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1.6rem;
    background:
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), rgba(14, 165, 233, 0) 28%),
        linear-gradient(180deg, rgba(255, 250, 245, 0.98) 0%, rgba(255, 255, 255, 0.98) 28%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow:
        0 30px 60px rgba(15, 23, 42, 0.18),
        0 10px 28px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(1rem) scale(0.96);
    transform-origin: bottom right;
    transition:
        opacity 0.22s ease,
        visibility 0.22s ease,
        transform 0.22s ease;
}

/* ── Header ── */

.ai-support-launcher__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.2rem 1rem;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0));
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.ai-support-launcher__header-copy {
    min-width: 0;
}

.ai-support-launcher__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.35rem;
    padding: 0.34rem 0.72rem;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    color: #c2410c;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ai-support-launcher__title {
    margin: 0;
    color: #0f172a;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(1.05rem, 2vw, 1.22rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
}

.ai-support-launcher__subtitle {
    margin: 0.18rem 0 0;
    color: #64748b;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.72rem;
    line-height: 1.35;
}

.ai-support-launcher__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.35rem;
    min-height: 2.35rem;
    padding: 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #334155;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.ai-support-launcher__close:hover {
    border-color: rgba(249, 115, 22, 0.36);
    background: rgba(255, 247, 237, 0.96);
    color: #c2410c;
}

/* ── Messages area ── */

.ai-support-launcher__messages {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.9rem 1rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ── Bubble base ── */

.ai-support-launcher__bubble {
    max-width: 82%;
    padding: 0.7rem 0.92rem;
    border-radius: 1.1rem;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.9rem;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
    animation: ai-support-bubble-in 0.18s ease both;
}

/* assistant (left) */
.ai-support-launcher__bubble--assistant {
    align-self: flex-start;
    background: rgba(241, 245, 249, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #1e293b;
    border-bottom-left-radius: 0.35rem;
}

/* visitor (right) */
.ai-support-launcher__bubble--visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1) 0%, rgba(234, 88, 12, 0.08) 100%);
    border: 1px solid rgba(249, 115, 22, 0.18);
    color: #1e293b;
    border-bottom-right-radius: 0.35rem;
}

/* system */
.ai-support-launcher__bubble--system {
    align-self: center;
    max-width: 92%;
    padding: 0.42rem 0.72rem;
    border-radius: 0.7rem;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: #64748b;
    font-size: 0.8rem;
    text-align: center;
}

/* error bubble */
.ai-support-launcher__bubble--error {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.16);
    color: #b91c1c;
    border-bottom-left-radius: 0.35rem;
}

/* bubble meta (cached badge etc.) */
.ai-support-launcher__bubble-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.ai-support-launcher__bubble-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.68rem;
    font-weight: 700;
}

/* streaming caret */
.ai-support-launcher__bubble[data-streaming="true"] .ai-support-launcher__bubble-text::after {
    content: '';
    display: inline-block;
    width: 0.52rem;
    height: 0.92rem;
    margin-left: 0.15rem;
    border-radius: 999px;
    vertical-align: -0.1rem;
    background: linear-gradient(180deg, #fb923c 0%, #f97316 100%);
    animation: ai-support-caret 0.92s ease-in-out infinite;
}

/* typing indicator */
.ai-support-launcher__typing {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.55rem 0.72rem;
    align-self: flex-start;
}

.ai-support-launcher__typing-dot {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.72);
    animation: ai-support-typing 1.2s ease-in-out infinite;
}

.ai-support-launcher__typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-support-launcher__typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

.ai-support-launcher__typing-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ── Composer ── */

.ai-support-launcher__composer {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem 1rem calc(0.65rem + var(--ai-support-kb-offset));
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.96);
}

.ai-support-launcher__quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.42rem;
}

.ai-support-launcher__quick-replies:empty,
.ai-support-launcher__quick-replies[hidden] {
    display: none;
}

.ai-support-launcher__prompt-btn {
    padding: 0.38rem 0.68rem;
    border: 1px solid rgba(249, 115, 22, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.28;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.ai-support-launcher__prompt-btn:hover {
    border-color: rgba(249, 115, 22, 0.34);
    background: rgba(255, 247, 237, 0.98);
    transform: translateY(-1px);
}

.ai-support-launcher__prompt-btn:disabled {
    opacity: 0.56;
    cursor: not-allowed;
    transform: none;
}

.ai-support-launcher__form {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
}

.ai-support-launcher__field {
    flex: 1;
    min-width: 0;
}

.ai-support-launcher__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.ai-support-launcher__textarea {
    width: 100%;
    min-height: 2.5rem;
    max-height: 6rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 1rem;
    background: rgba(248, 250, 252, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66);
    color: #0f172a;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.88rem;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-support-launcher__textarea:focus {
    border-color: rgba(14, 165, 233, 0.44);
    box-shadow: 0 0 0 0.2rem rgba(14, 165, 233, 0.1);
}

.ai-support-launcher__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.5rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.ai-support-launcher__submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.32);
}

.ai-support-launcher__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-support-launcher__composer-status {
    color: #64748b;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.75rem;
    min-height: 0;
    overflow: hidden;
    transition: min-height 0.18s ease;
}

.ai-support-launcher__composer-status:not(:empty) {
    min-height: 1.1rem;
}

.ai-support-launcher__noscript {
    margin: 0;
    color: #334155;
    font-family: 'IBM Plex Sans', var(--font-family, sans-serif);
    font-size: 0.92rem;
    line-height: 1.72;
    padding: 0.8rem 1rem;
}

/* ── Panel open states ── */

.ai-support-launcher-root[data-state="open"] .ai-support-launcher__panel,
.ai-support-launcher-root[data-state="submitting"] .ai-support-launcher__panel,
.ai-support-launcher-root[data-state="streaming"] .ai-support-launcher__panel,
.ai-support-launcher-root[data-state="answered"] .ai-support-launcher__panel,
.ai-support-launcher-root[data-state="error"] .ai-support-launcher__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ai-support-launcher-root[data-state="open"] .ai-support-launcher__trigger,
.ai-support-launcher-root[data-state="submitting"] .ai-support-launcher__trigger,
.ai-support-launcher-root[data-state="streaming"] .ai-support-launcher__trigger,
.ai-support-launcher-root[data-state="answered"] .ai-support-launcher__trigger,
.ai-support-launcher-root[data-state="error"] .ai-support-launcher__trigger {
    transform: translateY(-1px);
    box-shadow:
        0 24px 44px rgba(15, 23, 42, 0.28),
        0 12px 28px rgba(249, 115, 22, 0.42);
}

.ai-support-launcher-root[data-state="submitting"] .ai-support-launcher__trigger,
.ai-support-launcher-root[data-state="streaming"] .ai-support-launcher__trigger {
    opacity: 0.92;
}

/* ── Animations ── */

@keyframes ai-support-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.24);
        opacity: 0.6;
    }
}

@keyframes ai-support-caret {
    0%,
    100% {
        opacity: 1;
        transform: translateY(0);
    }

    50% {
        opacity: 0.32;
        transform: translateY(0.08rem);
    }
}

@keyframes ai-support-bubble-in {
    from {
        opacity: 0;
        transform: translateY(0.4rem) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ai-support-typing {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-0.25rem);
        opacity: 1;
    }
}

/* ── Mobile ── */

@media (max-width: 720px) {
    .ai-support-launcher-root {
        right: 1rem;
        left: 1rem;
        bottom: calc(var(--ai-support-offset) + env(safe-area-inset-bottom));
    }

    .ai-support-launcher-root[data-banner-visible="true"] {
        --ai-support-offset: 11rem;
    }

    .ai-support-launcher__backdrop {
        display: block;
    }

    .ai-support-launcher__trigger-copy {
        display: none;
    }

    .ai-support-launcher__trigger {
        min-width: 3.7rem;
        justify-content: center;
        padding-right: 0.82rem;
    }

    .ai-support-launcher__panel {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(var(--ai-support-offset) + env(safe-area-inset-bottom) + 4.6rem);
        width: auto;
        max-height: min(38rem, 78dvh);
        border-radius: 1.5rem;
        transform: translateY(1.4rem);
        transform-origin: bottom center;
    }

    .ai-support-launcher__header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .ai-support-launcher__messages {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .ai-support-launcher__composer {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: calc(0.65rem + var(--ai-support-kb-offset) + env(safe-area-inset-bottom));
    }

    body.ai-support-panel-open {
        overflow: hidden;
    }

    .ai-support-launcher-root[data-state="open"] .ai-support-launcher__backdrop,
    .ai-support-launcher-root[data-state="submitting"] .ai-support-launcher__backdrop,
    .ai-support-launcher-root[data-state="streaming"] .ai-support-launcher__backdrop,
    .ai-support-launcher-root[data-state="answered"] .ai-support-launcher__backdrop,
    .ai-support-launcher-root[data-state="error"] .ai-support-launcher__backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

@media (max-width: 480px) {
    .ai-support-launcher-root {
        right: 0.8rem;
        left: 0.8rem;
    }

    .ai-support-launcher__panel {
        left: 0.4rem;
        right: 0.4rem;
        max-height: min(34rem, 82dvh);
    }

    .ai-support-launcher__title {
        font-size: 1.02rem;
    }

    .ai-support-launcher__bubble {
        font-size: 0.86rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-support-launcher__backdrop,
    .ai-support-launcher__trigger,
    .ai-support-launcher__panel,
    .ai-support-launcher__prompt-btn {
        transition: none;
    }

    .ai-support-launcher__bubble {
        animation: none;
    }

    .ai-support-launcher__bubble[data-streaming="true"] .ai-support-launcher__bubble-text::after {
        animation: none;
    }

    .ai-support-launcher__typing-dot {
        animation: none;
    }
}
