.site-chat {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 220;
    font-family: "Source Sans 3", system-ui, sans-serif;
}

.site-chat__launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 56px;
    padding: 0 1.2rem 0 1rem;
    color: #fff;
    background: #2563eb;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.32);
    cursor: pointer;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 600;
}

.site-chat__launcher:hover {
    background: #1d4ed8;
}

.site-chat__launcher[aria-expanded="true"],
.site-chat.is-open .site-chat__launcher {
    display: none;
}

.site-chat__panel {
    width: min(calc(100vw - 32px), 360px);
    max-height: min(70vh, 520px);
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}

.site-chat.is-open .site-chat__panel {
    display: flex;
}

.site-chat__panel[hidden] {
    display: none !important;
}

.site-chat__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 0.9rem 0.75rem;
    background: #f8fbff;
    border-bottom: 1px solid #e2e8f0;
}

.site-chat__eyebrow {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #2563eb;
}

.site-chat__title {
    margin: 0.15rem 0 0;
    font-size: 1rem;
    color: #0f172a;
}

.site-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    background: #e8eefc;
    color: #475569;
    cursor: pointer;
    border-radius: 999px;
}

.site-chat__close:hover {
    background: #dbe6fb;
    color: #0f172a;
}

.site-chat__close svg {
    display: block;
}

.site-chat__log {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0.9rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 160px;
}

.site-chat__bubble {
    max-width: 92%;
    padding: 0.55rem 0.7rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.site-chat__bubble--user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
}

.site-chat__bubble--bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #0f172a;
}

.site-chat__bubble--streaming::after {
    content: "|";
    display: inline-block;
    margin-left: 0.1rem;
    color: #64748b;
    animation: site-chat-caret 1s steps(1) infinite;
}

.site-chat__bubble--waiting {
    color: #64748b;
    font-style: italic;
}

.site-chat__bubble--waiting::after {
    content: none;
}

@keyframes site-chat-caret {
    0%,
    49% {
        opacity: 1;
    }
    50%,
    100% {
        opacity: 0;
    }
}

.site-chat__bubble a {
    color: #1d4ed8;
    word-break: break-all;
}

.site-chat__form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.site-chat__input {
    width: 100%;
    resize: none;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    font-size: 0.9rem;
    color: #0f172a;
}

.site-chat__input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.site-chat__send {
    align-self: end;
    padding: 0.55rem 0.85rem;
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.site-chat__send:disabled {
    opacity: 0.6;
    cursor: wait;
}

.site-chat__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

@media (max-width: 640px) {
    .site-chat {
        right: 12px;
        bottom: 12px;
    }

    .site-chat__launcher-label {
        display: none;
    }

    .site-chat__launcher {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }
}
