/* =========================================================
   Chat widget — shared between /chat, /standalone, /bubble.
   ========================================================= */

.chat-widget {
    --chat-sidebar-width: 17rem;
    --chat-content-max: 48rem;
    --dg-border: var(--color-foreground);
    display: grid;
    grid-template-columns: var(--chat-sidebar-width) 1fr;
    grid-template-rows: 1fr;
    width: 100%;
    height: 100%;
    min-height: 0;
    background:
        radial-gradient(
            1200px 600px at 80% -10%,
            hsl(var(--color-primary) / 6%),
            transparent 60%
        ),
        radial-gradient(
            900px 500px at -10% 110%,
            hsl(var(--color-primary) / 5%),
            transparent 60%
        ),
        hsl(var(--color-background));
    color: hsl(var(--color-foreground));
    position: relative;
    overflow: hidden;
}

.chat-widget--no-history {
    grid-template-columns: 1fr;
}

[hidden] { display: none !important; }

/* ----------------------- History sidebar ----------------------- */

.chat-history {
    grid-column: 1 / 2;
    height: 100%;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-right: 1px solid hsl(var(--dg-border) / 14%);
    background: hsl(var(--color-background) / 60%);
}

.chat-widget--no-history .chat-history { display: none; }

.chat-new-button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid hsl(var(--dg-border) / 18%);
    border-radius: 999px;
    background-color: hsl(var(--color-background));
    color: hsl(var(--color-foreground));
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 120ms ease, transform 120ms ease, background-color 120ms ease;
}
.chat-new-button:hover {
    border-color: hsl(var(--color-primary) / 60%);
    color: hsl(var(--color-primary));
}
.chat-new-button:active { transform: scale(0.98); }
.chat-new-button i { color: hsl(var(--color-primary)); }

.chat-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: hsl(var(--color-foreground) / 45%);
    padding: 2.5rem 1rem;
    font-size: 0.8125rem;
    text-align: center;
}
.chat-history-empty i { font-size: 1.25rem; opacity: 0.6; }

.chat-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.chat-history-item {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: hsl(var(--color-foreground) / 80%);
    font-size: 0.875rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.chat-history-item:hover {
    background-color: hsl(var(--color-foreground) / 5%);
    color: hsl(var(--color-foreground));
}
.chat-history-item.active {
    background-color: hsl(var(--color-primary) / 10%);
    color: hsl(var(--color-primary));
    font-weight: 500;
}

/* ----------------------- Floating actions (top-right of chat area) ----------------------- */

.chat-floating-actions {
    position: absolute;
    top: 0.625rem;
    right: 0.75rem;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-floating-action {
    background: hsl(var(--color-background) / 70%);
    backdrop-filter: saturate(160%) blur(10px);
    border: 1px solid hsl(var(--dg-border) / 12%);
    color: hsl(var(--color-foreground) / 70%);
    width: 2rem; height: 2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.chat-floating-action:hover {
    background: hsl(var(--color-background));
    border-color: hsl(var(--color-primary) / 35%);
    color: hsl(var(--color-foreground));
}

/* ----------------------- Welcome card (empty-state agent identity) ----------------------- */

.chat-welcome {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 2rem 1.5rem;
    color: hsl(var(--color-foreground));
}
.chat-welcome__avatar {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 999px;
    overflow: hidden;
    background: hsl(var(--color-secondary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--color-primary));
    font-size: 1.5rem;
    box-shadow: 0 6px 24px hsl(var(--color-primary) / 18%);
    margin-bottom: 0.4rem;
}
.chat-welcome__avatar img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.chat-welcome__name {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}
.chat-welcome__handle {
    font-size: 0.875rem;
    color: hsl(var(--color-foreground) / 55%);
    margin: 0;
}
.chat-welcome__description {
    max-width: 32rem;
    font-size: 0.9375rem;
    color: hsl(var(--color-foreground) / 75%);
    margin: 0.4rem 0 0;
    line-height: 1.5;
}

/* History popover (used on standalone/bubble where no sidebar exists) */
.chat-history-popover-wrap {
    position: relative;
}
.chat-history-popover {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: min(20rem, calc(100vw - 2rem));
    max-height: 24rem;
    overflow-y: auto;
    padding: 0.5rem;
    background: hsl(var(--color-background));
    border: 1px solid hsl(var(--dg-border) / 16%);
    border-radius: 0.625rem;
    box-shadow: 0 12px 32px hsl(0 0% 0% / 18%);
    z-index: 1000;
}
.chat-history-popover .chat-history-empty { padding: 1.5rem 1rem; }

/* ----------------------- Main column ----------------------- */

.chat-main {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.chat-widget--no-history .chat-main { grid-column: 1 / 2; }

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.25rem 9rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    scroll-behavior: smooth;
}

/* ----------------------- Messages ----------------------- */

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    line-height: 1.55;
    word-wrap: break-word;
    animation: chat-fade-in 240ms ease both;
}
@keyframes chat-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.chat-message__avatar {
    flex-shrink: 0;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 999px;
    overflow: hidden;
    background: hsl(var(--color-secondary));
    color: hsl(var(--color-primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    margin-top: 0.125rem;
}
.chat-message__avatar img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}

.chat-message__content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    flex: 0 1 auto;
}

.chat-message__body {
    min-width: 0;
}

.chat-message__time {
    font-size: 0.6875rem;
    color: hsl(var(--color-foreground) / 40%);
    margin-top: 0.125rem;
}

.chat-message__actions {
    display: inline-flex;
    gap: 0.125rem;
    margin-top: 0.125rem;
    opacity: 0.55;
    transition: opacity 140ms ease;
}
.chat-message:hover .chat-message__actions,
.chat-message__actions:focus-within { opacity: 1; }
.chat-message__action {
    background: none;
    border: 0;
    color: hsl(var(--color-foreground) / 60%);
    width: 1.875rem; height: 1.875rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.chat-message__action:hover {
    background: hsl(var(--color-foreground) / 6%);
    color: hsl(var(--color-foreground));
}
.chat-message__action.is-active {
    color: hsl(var(--color-primary));
    background: hsl(var(--color-primary) / 8%);
}
.chat-message__action.is-success {
    color: hsl(120 60% 40%);
    transform: scale(1.08);
}

/* Counter markdown.css rules that were designed for the full-page Markdown
 * layout (Privacy, Terms, …). They use heading-page-sized fonts/margins and
 * a special `:first-of-type` lead paragraph treatment, neither of which
 * makes sense inside a chat bubble. Match the relevant selectors with at
 * least equal specificity so source-order resolves the tie our way. */
.chat-message__body,
.chat-message__body p,
.chat-message__body > p:first-of-type,
.chat-message__body h1 + p,
.chat-message__body ul li,
.chat-message__body ol li {
    font-size: inherit;
    line-height: inherit;
    font-weight: inherit;
    margin: 0;
    color: inherit;
}
.chat-message__body > * + * { margin-top: 0.5rem; }
.chat-message__body h1,
.chat-message__body h2,
.chat-message__body h3,
.chat-message__body h4,
.chat-message__body h5,
.chat-message__body h6 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 0.5em 0 0.25em;
    border: 0;
    padding: 0;
    letter-spacing: normal;
}
.chat-message__body h1::after,
.chat-message__body h2::after { display: none; content: none; }
.chat-message__body ul,
.chat-message__body ol {
    margin: 0.25em 0;
    padding-left: 1.25em;
    list-style: revert;
}
.chat-message__body ul li,
.chat-message__body ol li {
    padding-left: 0;
    margin-bottom: 0.15em;
}
.chat-message__body ul li::before,
.chat-message__body ol li::before { content: none; display: none; }
.chat-message__body blockquote {
    margin: 0.4em 0;
    padding: 0.4em 0.75em;
    border-left: 3px solid currentColor;
    background: transparent;
    font-style: italic;
    border-radius: 0;
}
.chat-message__body pre {
    margin: 0.4em 0;
    padding: 0.6em 0.75em;
    font-size: 0.85em;
    line-height: 1.5;
}
.chat-message__body > :first-child { margin-top: 0; }
.chat-message__body > :last-child { margin-bottom: 0; }

/* user */
.chat-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 80%;
}
.chat-message--user .chat-message__avatar { display: none; }
.chat-message--user .chat-message__content {
    align-items: flex-end;
}
.chat-message--user .chat-message__body {
    width: fit-content;
    max-width: 100%;
    padding: 0.625rem 0.95rem;
    border-radius: 1.125rem 1.125rem 0.25rem 1.125rem;
    background-color: hsl(var(--color-primary));
    color: hsl(var(--color-primary-foreground));
    box-shadow: 0 2px 14px hsl(var(--color-primary) / 25%);
    line-height: 1.55;
    font-weight: 500;
}
/* Force the bubble color onto everything inside, beating `.markdown p`
 * (0,1,1) and `.markdown > p:first-of-type` (0,2,1). */
.chat-message--user .chat-message__body,
.chat-message--user .chat-message__body p,
.chat-message--user .chat-message__body > p:first-of-type,
.chat-message--user .chat-message__body * {
    color: hsl(var(--color-primary-foreground));
}
.chat-message--user .chat-message__time { text-align: right; }

/* model */
.chat-message--model {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
}
.chat-message--model .chat-message__content {
    flex: 1 1 auto;
    min-width: 0;
}

/* error */
.chat-message--error {
    align-self: flex-start;
}
.chat-message--error .chat-message__body {
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    background-color: hsl(var(--color-destructive) / 8%);
    color: hsl(var(--color-destructive));
    border: 1px solid hsl(var(--color-destructive) / 25%);
}

.chat-message .markdown > :first-child { margin-top: 0; }
.chat-message .markdown > :last-child { margin-bottom: 0; }

/* ----------------------- Attachments ----------------------- */

.chat-message .chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.chat-message .chat-attachments img {
    max-width: 14rem;
    max-height: 14rem;
    border-radius: 0.625rem;
    object-fit: cover;
    box-shadow: 0 4px 18px hsl(0 0% 0% / 8%);
}
.chat-message .chat-attachments a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    background-color: hsl(var(--color-foreground) / 6%);
    font-size: 0.875rem;
    text-decoration: none;
    color: inherit;
}

/* ----------------------- Citations ----------------------- */

.chat-citations {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.chat-citations__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--color-foreground) / 55%);
    font-weight: 600;
}
.chat-citations__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.5rem;
}
.chat-citation {
    display: flex;
    align-items: stretch;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid hsl(var(--dg-border) / 16%);
    border-radius: 0.625rem;
    background: hsl(var(--color-background));
    text-decoration: none;
    color: inherit;
    transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
    overflow: hidden;
    min-width: 0;
}
.chat-citation:hover {
    border-color: hsl(var(--color-primary) / 50%);
    box-shadow: 0 4px 16px hsl(var(--color-primary) / 10%);
    transform: translateY(-1px);
}
.chat-citation__image {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.375rem;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--color-foreground) / 6%);
    color: hsl(var(--color-foreground) / 55%);
}
.chat-citation__image--placeholder i { font-size: 1rem; }
.chat-citation__body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.chat-citation__title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.chat-citation__text {
    font-size: 0.75rem;
    color: hsl(var(--color-foreground) / 65%);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-top: 0.125rem;
}
.chat-citation__url {
    font-size: 0.6875rem;
    color: hsl(var(--color-foreground) / 45%);
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----------------------- Tool calls ----------------------- */

.chat-tool-calls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.chat-tool-call {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: hsl(var(--color-foreground) / 5%);
    border: 1px solid hsl(var(--dg-border) / 14%);
    font-size: 0.75rem;
    color: hsl(var(--color-foreground) / 80%);
    max-width: 100%;
}
.chat-tool-call i { color: hsl(var(--color-primary)); }
.chat-tool-call__name { font-weight: 600; }
.chat-tool-call__args {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.6875rem;
    color: hsl(var(--color-foreground) / 60%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18rem;
}

/* ----------------------- Thoughts (collapsible) ----------------------- */

.chat-thoughts {
    border-left: 2px solid hsl(var(--color-primary) / 35%);
    background: hsl(var(--color-primary) / 4%);
    padding: 0.4rem 0.75rem;
    border-radius: 0 0.5rem 0.5rem 0;
}
.chat-thoughts > summary {
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: hsl(var(--color-foreground) / 70%);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.chat-thoughts > summary::-webkit-details-marker { display: none; }
.chat-thoughts > summary i { color: hsl(var(--color-primary)); }
.chat-thoughts__body {
    margin-top: 0.4rem;
    font-size: 0.8125rem;
    color: hsl(var(--color-foreground) / 75%);
}

/* ----------------------- Thinking indicator ----------------------- */

.chat-message--thinking { align-items: center; }
.chat-thinking {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    color: hsl(var(--color-foreground) / 50%);
}
.chat-thinking span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background-color: currentColor;
    animation: chat-dot 1.2s ease-in-out infinite both;
}
.chat-thinking span:nth-child(1) { animation-delay: -0.32s; }
.chat-thinking span:nth-child(2) { animation-delay: -0.16s; }
@keyframes chat-dot {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ----------------------- Composer ----------------------- */

.chat-composer-wrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.75rem 1rem 0.5rem;
    background: linear-gradient(
        to top,
        hsl(var(--color-background)) 35%,
        hsl(var(--color-background) / 0%)
    );
    pointer-events: none;
    z-index: 2;
}

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 0.5rem 0.75rem;
    border: 1px solid hsl(var(--dg-border) / 20%);
    background-color: hsl(var(--color-background));
    border-radius: 1.25rem;
    box-shadow:
        0 1px 0 hsl(var(--color-foreground) / 4%),
        0 8px 30px hsl(var(--color-foreground) / 8%);
    max-width: 46rem;
    width: 100%;
    margin: 0 auto;
    pointer-events: auto;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.chat-composer:focus-within {
    border-color: hsl(var(--color-primary) / 50%);
    box-shadow:
        0 1px 0 hsl(var(--color-foreground) / 4%),
        0 8px 30px hsl(var(--color-primary) / 12%);
}

.chat-composer textarea {
    flex: 1 1 auto;
    resize: none;
    max-height: 12rem;
    min-height: 1.5rem;
    padding: 0.5rem 0.25rem;
    border: 0;
    background: transparent;
    color: hsl(var(--color-foreground));
    font: inherit;
    line-height: 1.5;
}
.chat-composer textarea:focus { outline: none; }
.chat-composer textarea::placeholder {
    color: hsl(var(--color-foreground) / 40%);
}

.chat-composer .chat-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    cursor: pointer;
    color: hsl(var(--color-foreground) / 60%);
    transition: background-color 120ms ease, color 120ms ease;
}
.chat-composer .chat-attach:hover {
    background-color: hsl(var(--color-foreground) / 6%);
    color: hsl(var(--color-foreground));
}

.chat-composer button[type="submit"] {
    width: 2.25rem;
    height: 2.25rem;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background-color: hsl(var(--color-primary));
    color: hsl(var(--color-primary-foreground));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 120ms ease, background-color 120ms ease;
}
.chat-composer button[type="submit"]:hover {
    background-color: hsl(var(--color-primary-accent));
}
.chat-composer button[type="submit"]:active { transform: scale(0.95); }
.chat-composer button[disabled] { opacity: 0.4; cursor: not-allowed; }

.chat-pending-file {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    margin: 0.5rem auto 0;
    max-width: 46rem;
    width: fit-content;
    background-color: hsl(var(--color-foreground) / 5%);
    border-radius: 999px;
    font-size: 0.8125rem;
    pointer-events: auto;
}
.chat-pending-file button {
    background: none;
    border: 0;
    cursor: pointer;
    color: hsl(var(--color-foreground) / 50%);
    padding: 0.125rem;
}
.chat-pending-file button:hover { color: hsl(var(--color-destructive)); }

.chat-disclaimer {
    text-align: center;
    color: hsl(var(--color-foreground) / 45%);
    font-size: 0.6875rem;
    padding: 0.25rem 1rem 0.5rem;
    margin: 0;
    pointer-events: auto;
}

/* ----------------------- Responsive (history collapses) ----------------------- */

@media (max-width: 768px) {
    .chat-widget {
        grid-template-columns: 1fr;
    }
    .chat-widget .chat-history { display: none; }
    .chat-widget-header { grid-column: 1 / 2; }
    .chat-main { grid-column: 1 / 2; }
    .chat-messages { padding: 1rem 1rem 9rem; }
}

/* =========================================================
   Bubble mode (floating chat for /bubble)
   ========================================================= */

.chat-widget--bubble {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: min(380px, calc(100vw - 2.5rem));
    height: min(620px, calc(100vh - 2.5rem));
    border-radius: 1.125rem;
    border: 1px solid hsl(var(--color-foreground) / 10%);
    /* No box-shadow: the widget is always rendered inside the embed.js
     * iframe whose bounds are sized tight against the panel — any drop
     * shadow would get clipped at the iframe edge and look like a
     * semi-transparent rectangle on the host page. */
    overflow: hidden;
    z-index: 9999;
    /* `visibility` is animated stepwise: it flips to hidden only at the end
     * of the fade-out, and immediately back to visible on open. */
    transition: opacity 200ms ease, transform 220ms ease, visibility 0s linear 220ms;
}
.chat-widget--bubble.is-closed {
    /* `visibility: hidden` cascades and disables hit-testing on every
     * descendant — without it, the composer (which has its own
     * pointer-events: auto so it stays interactive when the widget is
     * open) sits over the left half of the closed FAB and steals clicks. */
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
}
.chat-widget--bubble.is-open {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: none;
    transition: opacity 200ms ease, transform 220ms ease, visibility 0s linear 0s;
}

.chat-bubble-toggle {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 999px;
    border: 0;
    background: hsl(var(--color-primary));
    color: hsl(var(--color-primary-foreground));
    /* No box-shadow: same iframe-clip rationale as .chat-widget--bubble. */
    cursor: pointer;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 160ms ease, background-color 160ms ease;
}
.chat-bubble-toggle:hover {
    background: hsl(var(--color-primary-accent));
    transform: scale(1.05);
}
.chat-bubble-toggle__icon {
    width: 1.75rem;
    height: 1.75rem;
}

/* Unread indicator — shown when a model message arrives while the
 * bubble is closed. Pulses to attract attention; cleared on open. */
.chat-bubble-toggle__dot {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
    background: hsl(0 80% 55%);
    border: 2px solid hsl(var(--color-primary-foreground));
    box-shadow: 0 0 0 0 hsl(0 80% 55% / 60%);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 140ms ease, transform 160ms ease;
    pointer-events: none;
}
.chat-bubble-toggle.has-unread .chat-bubble-toggle__dot {
    opacity: 1;
    transform: scale(1);
    animation: chat-bubble-unread-pulse 1.6s ease-in-out infinite;
}
@keyframes chat-bubble-unread-pulse {
    0%   { box-shadow: 0 0 0 0   hsl(0 80% 55% / 55%); }
    70%  { box-shadow: 0 0 0 10px hsl(0 80% 55% / 0%); }
    100% { box-shadow: 0 0 0 0   hsl(0 80% 55% / 0%); }
}

/* =========================================================
   Standalone mode (chat overlaid on agent background)
   ========================================================= */

.chat-widget--standalone {
    border-radius: 12px;
    box-shadow: 0 22px 60px hsl(0 0% 0% / 35%);
}
