body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: none;
    background-color: var(--background);
}

.assistant-widget {
    margin: 8px 0;
    max-width: 100%;
}

.assistant-widget-backend-rendered {
    width: 100%;
}

.assistant-widget-backend-frame {
    display: block;
    width: 100%;
    min-height: 160px;
    border: 0;
    background: transparent;
    overflow: hidden;
}

.assistant-widget-backend-error {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--error-color) 35%, var(--border-color));
    border-radius: var(--border-radius);
    background: color-mix(in srgb, var(--error-color) 10%, var(--surface-muted));
    color: var(--error-color);
    line-height: 1.45;
}

body.sidebar-locked {
    overflow: hidden;
}
.space-between {
    justify-content: space-between;
}

.color-red {
    color: var(--error-color) !important;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    width: 100%;
    background: var(--background);
    position: relative;
    overflow-y: visible;
    --scroll-btn-offset-base: 140px;
    --scroll-btn-extra: 0px;
}
.chat-container-main {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}
.chat-container-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--text-color);
    font-size: clamp(25px, 2.2vw, 30px);
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: clamp(44px, 5vh, 58px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    -webkit-user-select: none;
    /* Safari, Chrome, Opera, iOS Safari */
    -moz-user-select: none;
    /* Firefox */
    -ms-user-select: none;
    /* Internet Explorer/Edge */;
}

/* The first-run experience uses the same modal shell as Archived Chats. Its
   feature styles only control compact sizing and the welcome-specific body. */
.first-run-welcome-overlay {
    --shared-modal-z-index: 8000;
}

.search-modal.first-run-welcome-modal {
    --shared-modal-width: 520px;
}

.first-run-welcome-modal__body {
    color: var(--text-color-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.first-run-welcome-modal__body p {
    margin: 0;
}

.first-run-welcome-modal__privacy {
    margin-top: 16px !important;
    padding: 12px 14px;
    border: 1px solid var(--search-modal-border);
    border-radius: 10px;
    color: var(--text-color);
    background: var(--surface-muted);
}

.first-run-welcome-modal__actions .om-button.border {
    min-height: 40px;
}

.first-run-welcome-modal__actions .om-button.border:disabled {
    cursor: wait;
    opacity: 0.55;
}

@media (max-width: 600px) {
    .chat-container-welcome {
        display: block;
        padding: 0 16px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        text-align: center;
        line-height: 1.4;
    }

}

body.project-chat-placeholder-mode .chat-box-area {
    display: none !important;
}

.chat-area {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    height: auto;
    overflow-y: auto;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    position: relative;
    container-type: inline-size;
    container-name: chat-files-layout;
}
.chat-area-container {
    --chat-trailing-spacer-height: 140px;
    height: 100%;
    max-width: 70%;
    min-width: 70%;
}

.chat-area-container::after {
    content: "";
    display: block;
    height: var(--chat-trailing-spacer-height);
}

/* The main-chat loader is a sibling of the transcript log. This keeps loading
   feedback accessible without inserting non-message content into the log. */
.chat-load-status {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-color-secondary);
    background: color-mix(in srgb, var(--background) 92%, transparent);
    text-align: center;
}

.chat-load-status[hidden],
.chat-load-spinner[hidden],
.chat-load-retry-button[hidden] {
    display: none;
}

.chat-load-status-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 320px;
}

.chat-load-status-content p {
    margin: 0;
    line-height: 1.5;
}

.chat-load-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chat-container[data-chat-load-error] .chat-load-status {
    color: var(--error-color);
}

.chat-load-retry-button {
    color: var(--text-color);
    background: var(--background);
}

/* A disabled composer remains visible to preserve the final chat layout while
   preventing sends from racing the transcript hydration. */
.chat-container[data-chat-loading] .chat-box-area,
.chat-container[data-chat-load-error] .chat-box-area {
    opacity: 0.65;
}

@media (prefers-reduced-motion: reduce) {
    .chat-load-spinner {
        animation: none;
    }
}

.dynamic-scroll-spacer {
    flex: 0 0 auto;
    height: 0;
    overflow-anchor: none;
    pointer-events: none;
}

/* The coordinator owns scroll movement while a new prompt is aligning. This
   prevents browser scroll anchoring and inherited smooth-scroll rules from
   starting a competing movement during the transaction. */
.chat-scroll-aligning {
    overflow-anchor: none;
    scroll-behavior: auto;
}

.assistant-message-container {
    margin-top: 10px;
    max-width: 100%;
}

.assistant-message-container[data-is-streaming="true"] {
    overflow-anchor: none;
}

.user-message-area.chat-message-bookmark-target,
.user-message-container.chat-message-bookmark-target,
.assistant-message-container.chat-message-bookmark-target {
    border-radius: 20px;
    animation: bookmark-message-highlight 1.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .chat-message-bookmark-target {
        animation: none;
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 32%, transparent);
    }
}

.user-message-area {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding-top: 20px;
}
.user-message {
    /* Dark color themes provide a dedicated tint without recoloring all inputs. */
    background-color: var(--user-message-bg, var(--input-bg));
    border-radius: 18px;
    padding: 12px 16px;
    color: var(--text-color);
    overflow-wrap: anywhere;
    word-break: break-word;
    border-bottom-right-radius: 5px;
    width: fit-content;
    /* A wide Markdown descendant (for example, a non-wrapping code line) can
       contribute its intrinsic width to this right-aligned flex item. Cap the
       bubble itself so that dedicated inner scrollers handle that overflow
       instead of pushing the bubble's left edge outside the chat viewport. */
    max-width: 100%;
}

.user-message-expandable-content {
    position: relative;
    max-width: 100%;
}

.user-message-container[data-user-message-collapsible="true"][data-user-message-expanded="false"] .user-message-expandable-content {
    max-height: 220px;
    overflow: hidden;
}

.user-message-container[data-user-message-collapsible="true"][data-user-message-expanded="false"] .user-message-expandable-content::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 58px;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--input-bg) 82%);
}

.user-message-expand-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    margin-top: 6px;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-color-secondary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.user-message-expand-toggle[hidden] {
    display: none;
}

.user-message-expand-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.user-message-expand-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
}

.user-message-expand-icon svg {
    width: 18px;
    height: 18px;
    color: currentColor;
}
.user-message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
}

.user-message-container:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
    border-radius: 20px;
}

.user-message-container:focus:not(:focus-visible) {
    outline: none;
}
.assistant-message {
    margin-top: 4px;
    color: var(--text-color);
}

.assistant-message-stream-enter {
    animation: assistant-stream-block-in 180ms ease-out both;
}

.assistant-stream-text-arrival {
    animation: assistant-stream-text-in 65ms ease-out both;
}

.assistant-stream-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-inline-start: 3px;
    border-radius: 999px;
    background: currentColor;
    vertical-align: -0.12em;
    pointer-events: none;
    animation: assistant-stream-caret-pulse 1.1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .assistant-message-stream-enter,
    .assistant-stream-text-arrival {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .assistant-stream-caret {
        display: none;
        animation: none;
    }
}

.assistant-message-error {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--error-color);
    border-radius: 10px;
    color: var(--error-color);
    width: fit-content;
}

.assistant-response-cancelled-status {
    margin-top: 8px;
    color: var(--text-color-secondary);
    font-size: 0.875rem;
}

/* ── Rate-limit inline card ── */
.chat-rate-limit-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 16px 0 4px;
    padding: 18px 20px;
    border-radius: 14px;
    border: 1px solid var(--rate-limit-border);
    background: var(--rate-limit-bg);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-rate-limit-card--visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-rate-limit-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--rate-limit-icon-bg);
    color: var(--rate-limit-icon-color);
}

.chat-rate-limit-icon svg {
    width: 20px;
    height: 20px;
}

.chat-rate-limit-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-rate-limit-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--rate-limit-title-color);
    letter-spacing: -0.01em;
}

.chat-rate-limit-message {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-color-secondary, #666);
}

.chat-rate-limit-meta {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-color-secondary, #666);
    opacity: 0.9;
}

.chat-rate-limit-tip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-color-secondary, #666);
}

.user-message-list, .assistant-message-list {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding-top: 4px;
}
.assistant-version-switcher {
    order: -1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.user-message-list {
    justify-content: flex-end;
}
.user-message-list-button, .assistant-message-list-button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    width: 32px;
    border-radius: 8px;
}
.assistant-feedback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.assistant-feedback-button {
    position: relative;
    color: var(--text-color-secondary, #475569);
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-feedback-button:hover {
        background-color: var(--hover, rgba(148, 163, 184, 0.2));
        color: var(--text-color, #111827);
        border-color: var(--border-color, rgba(15, 23, 42, 0.12));
    }
}

.assistant-feedback-button.is-selected {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-color, #3b82f6);
    border-color: rgba(59, 130, 246, 0.4);
}

.assistant-feedback-button.showing-check {
    color: var(--success-color, #16a34a);
}

/* ===== Feedback Modal ===== */
.feedback-modal-overlay {
    --shared-modal-z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.feedback-modal-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.feedback-modal-overlay.is-closing {
    opacity: 0;
    pointer-events: none;
}

.feedback-modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.feedback-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
}

.feedback-modal-icon.thumbs-up {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.feedback-modal-icon.thumbs-down {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.feedback-modal-icon svg {
    width: 20px;
    height: 20px;
}

.feedback-modal-subtitle {
    margin: 0;
}

/* Expanded / comment state */
.feedback-modal-textarea {
    width: 100%;
    min-height: 100px;
    max-height: 200px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-color, #0f172a);
    background-color: var(--background, #fff);
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 12px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.feedback-modal-textarea:focus {
    border-color: var(--text-color, #0f172a);
}

.feedback-modal-textarea::placeholder {
    color: var(--text-color-secondary, #94a3b8);
}

.feedback-modal-input-footer {
    justify-content: flex-end;
}

.feedback-modal-char-count {
    margin-right: auto;
    font-size: 12px;
    color: var(--text-color-secondary, #94a3b8);
    transition: color 0.15s ease;
}

.feedback-modal-char-count.is-warning {
    color: #f59e0b;
}

.feedback-modal-footer-buttons {
    display: flex;
    gap: 8px;
}

@media (max-width: 480px) {
    .feedback-modal-header-left {
        gap: 10px;
    }
}

.user-message-list-button svg, .assistant-message-list-button svg {
    height: var(--svg-size);
    width: var(--svg-size);
    /* Always set color so stroke="currentColor" works */
    color: var(--text-color-secondary);
}
/* Do not override SVGs that explicitly set fill="none" (e.g., branch icon) */
.user-message-list-button svg:not([fill="none"]),
.assistant-message-list-button svg:not([fill="none"]) {
    fill: var(--text-color-secondary);
}

.user-message-container.editing {
    width: 100%;
    max-width: 100%;
}

.user-message-container.editing .user-message {
    width: 100%;
    background-color: transparent;
    border: none;
    padding: 0;
}

.user-message-container.editing .user-message-content {
    display: none;
}

.user-message-container.editing .user-message-expandable-content,
.user-message-container.editing .user-message-expand-toggle {
    display: none;
}

.user-message-edit-container {
    display: flex;
    flex-direction: column;
    /* The shared chat-box styles intentionally constrain the editor width.
       Anchor every edit-mode row to the same right edge as the user message. */
    align-items: flex-end;
    width: 100%;
    gap: 10px;
}

.user-message-edit-chat-box {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-color);
    background: var(--background-secondary);
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    container-type: inline-size;
    container-name: chat-files-layout;
}

.user-message-edit-textarea {
    min-height: 44px;
    max-height: 320px;
    margin-bottom: 10px;
}

.user-message-edit-textarea:focus {
    box-shadow: none;
}

.user-message-edit-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-message-edit-btn:active {
    transform: scale(0.98);
}

.user-message-edit-btn-save {
    background-color: var(--primary-color);
    color: white;
}

@media (hover: hover) and (pointer: fine) {
    .user-message-edit-btn-save:hover {
        filter: brightness(1.1);
    }
}

.user-message-edit-btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.user-message-edit-save-actions {
    /* Unified pill that visually merges the Save action and its options
       trigger into one modern, fully rounded control. */
    position: relative;
    display: inline-flex;
    align-items: stretch;
    border-radius: 12px;
    background-color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

@media (hover: hover) and (pointer: fine) {
    .user-message-edit-save-actions:hover {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 8px 20px rgba(0, 0, 0, 0.1);
    }
}

/* When the split Save button lives inside the pill it should share the pill's
   background/shadow rather than paint its own, so the two halves read as one
   seamless control. */
.user-message-edit-save-actions .user-message-edit-btn-save-split {
    background-color: transparent;
    box-shadow: none;
}

.user-message-edit-btn-save-split {
    /* Flatten only the trailing edge so it butts up against the options
       trigger while keeping the leading edge fully rounded. */
    border-start-end-radius: 0;
    border-end-end-radius: 0;
    padding-inline-end: 12px;
}

.user-message-edit-save-menu-btn {
    /* Circular options trigger tucked into the trailing end of the pill. */
    position: relative;
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: white;
    background-color: transparent;
    border: none;
    border-start-end-radius: 999px;
    border-end-end-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

/* Soft, short, translucent segment divider instead of a hard full-height
   vertical border line between the Save action and the options trigger. */
.user-message-edit-save-menu-btn::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    width: 1px;
    height: 16px;
    transform: translateY(-50%);
    border-radius: 1px;
    background-color: rgba(255, 255, 255, 0.28);
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.user-message-edit-save-menu-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.user-message-edit-save-menu-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.15s ease;
}

/* Rotate the chevron while the options menu is open for a modern,
   state-aware affordance. */
.user-message-edit-save-menu-btn[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

@media (hover: hover) and (pointer: fine) {
    .user-message-edit-save-menu-btn:hover:not(:disabled) {
        background-color: rgba(255, 255, 255, 0.16);
    }

    /* Fade the divider away on hover so the hovered segment feels continuous. */
    .user-message-edit-save-menu-btn:hover:not(:disabled)::before,
    .user-message-edit-btn-save-split:hover ~ .user-message-edit-save-menu-btn::before {
        opacity: 0;
    }
}

/* Disable the pill's shared hover lift when either half is disabled. */
.user-message-edit-save-actions:has(.user-message-edit-btn-save-split:disabled) {
    box-shadow: none;
}

.user-message-edit-save-dropdown {
    /* Place the save-options menu below the split-button trigger. */
    --select-dropdown-closed-transform: translateY(-8px) scale(0.96);
    --select-dropdown-transform-origin: top right;
    top: calc(100% + 8px);
    right: 0;
    bottom: auto;
    left: auto;
    width: max-content;
    min-width: min(210px, calc(100vw - 32px));
    max-width: min(280px, calc(100vw - 32px));
    z-index: 70;
}

.user-message-edit-save-regenerate-btn {
    width: 100%;
    white-space: normal;
}

/* Respect the operating-system preference. The menu remains fully functional; its visual
   states simply change without scaling, rotating, or fading between them. */
@media (prefers-reduced-motion: reduce) {
    .user-message-edit-save-actions,
    .user-message-edit-save-menu-btn,
    .user-message-edit-save-menu-btn::before,
    .user-message-edit-save-menu-btn svg,
    .user-message-edit-save-dropdown {
        transition: none;
    }

    .user-message-edit-save-dropdown {
        transform: none;
    }
}

.user-message-edit-dropdown .select-dropdown {
    top: auto;
    right: auto;
    bottom: calc(100% + 8px);
    left: 0;
    width: 320px;
    min-width: min(320px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    max-height: min(420px, calc(100dvh - 24px));
    overflow: hidden;
    overscroll-behavior: contain;
    transform-origin: bottom left;
    z-index: 60;
}

.user-message-edit-dropdown .select-dropdown[data-vertical-placement="up"] {
    top: auto;
    bottom: calc(100% + 8px);
    transform-origin: bottom left;
}

.user-message-edit-dropdown .select-dropdown[data-vertical-placement="down"] {
    top: calc(100% + 8px);
    bottom: auto;
    transform-origin: top left;
}

/* Hide button list when editing */
.user-message-container.editing .user-message-list {
    display: none !important;
}

@media (max-width: 640px) {
    .user-message-edit-chat-box {
        border-radius: 18px;
    }

    .user-message-edit-toolbar {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
     }
/* ===== End User Message Edit Mode ===== */

/* Show user buttons only on hover; assistant always visible */
.user-message-container .user-message-list {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 150ms ease, transform 150ms ease;
    will-change: opacity, transform;
}

/* Ensure assistant's list always visible (already flex by default) */
.assistant-message-container .assistant-message-list {
    display: flex;
}

.assistant-message-container .assistant-message-list .assistant-copy-btn {
    order: -999;
}

/* Version Switcher for Regenerated Messages */
.assistant-version-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
    padding: 2px 4px;
    border-radius: 6px;
}

.assistant-version-display {
    font-size: 12px;
    color: var(--text-color-secondary);
    min-width: 32px;
    text-align: center;
    user-select: none;
}

.assistant-version-prev:disabled,
.assistant-version-next:disabled,
.assistant-version-prev.disabled,
.assistant-version-next.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Assistant More Menu (Three-dot dropdown) */
.assistant-more-menu-container,
.user-more-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.assistant-regenerate-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.assistant-more-btn,
.user-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant-regenerate-popover {
    position: absolute;
    bottom: 100%;
    right: 0;
    width: min(420px, calc(100vw - 24px));
    margin-bottom: 6px;
    padding: 14px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 110;
}

.assistant-regenerate-popover.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* When the popover has to open below the toolbar, move it toward the trigger
   while closed so its opening and closing motion follows its placement. */
.assistant-regenerate-popover.assistant-regenerate-popover-below:not(.open) {
    transform: translateY(-6px);
}

.assistant-regenerate-popover.assistant-regenerate-popover-portal {
    position: fixed;
    right: auto;
    bottom: auto;
    margin-bottom: 0;
    z-index: 1200;
}

.assistant-regenerate-popover-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.assistant-regenerate-popover-description {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-color-secondary);
}

.assistant-regenerate-preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.assistant-regenerate-preset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--background);
    color: var(--text-color);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.assistant-regenerate-preset-btn:focus-visible {
    background: var(--hover);
    border-color: var(--text-color-secondary);
}

@media (hover: hover) and (pointer: fine) {
    .assistant-regenerate-preset-btn:hover {
        background: var(--hover);
        border-color: var(--text-color-secondary);
    }
}

.assistant-regenerate-custom-row {
    margin-top: 12px;
}

.assistant-regenerate-input {
    width: 100%;
    min-height: 96px;
    max-height: 220px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--background);
    color: var(--text-color);
    font-size: 13px;
    line-height: 1.45;
    outline: none;
    resize: vertical;
}

.assistant-regenerate-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.assistant-regenerate-input::placeholder {
    color: var(--text-color-secondary);
}

.assistant-regenerate-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.assistant-regenerate-shortcut-hint,
.assistant-regenerate-char-count {
    font-size: 11px;
    color: var(--text-color-secondary);
}

.assistant-regenerate-char-count.near-limit {
    color: var(--warning-color, #b45309);
}

.assistant-regenerate-actions-row {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.assistant-regenerate-secondary-btn,
.assistant-regenerate-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.assistant-regenerate-secondary-btn {
    border: 1px solid var(--border-color);
    background: var(--background);
    color: var(--text-color);
}

.assistant-regenerate-apply-btn {
    border: 1px solid transparent;
    background: var(--primary-color);
    color: #fff;
}

.assistant-regenerate-secondary-btn:focus-visible,
.assistant-regenerate-apply-btn:focus-visible {
    filter: brightness(1.05);
}

@media (hover: hover) and (pointer: fine) {
    .assistant-regenerate-secondary-btn:hover {
        background: var(--hover);
        border-color: var(--text-color-secondary);
    }

    .assistant-regenerate-apply-btn:hover {
        filter: brightness(1.05);
    }
}

.assistant-regenerate-secondary-btn:active,
.assistant-regenerate-apply-btn:active {
    transform: scale(0.98);
}

.assistant-regenerate-secondary-btn:disabled,
.assistant-regenerate-preset-btn:disabled,
.assistant-regenerate-apply-btn:disabled,
.assistant-regenerate-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .assistant-regenerate-meta-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .assistant-regenerate-actions-row {
        justify-content: stretch;
    }

    .assistant-regenerate-secondary-btn,
    .assistant-regenerate-apply-btn {
        flex: 1 1 160px;
    }
}

.message-more-dropdown {
    top: auto;
    bottom: 100%;
    margin-bottom: 4px;
    min-width: 220px;
    z-index: 100;
}

.message-more-dropdown.more-dropdown-portal {
    position: fixed;
    right: auto;
    bottom: auto;
    margin-bottom: 0;
    z-index: 1200;
}

.assistant-speech-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 2px;
}

.assistant-speech-toggle-btn.is-loading {
    background: color-mix(in srgb, var(--primary-color) 10%, var(--background));
}

.assistant-speech-toggle-btn.is-active {
    background: var(--hover);
    color: var(--text-color);
}

.assistant-speech-loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 18px;
}

.assistant-speech-loading-indicator span {
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: var(--primary-color);
    opacity: 0.35;
    animation: assistantSpeechPulse 0.9s ease-in-out infinite;
}

.assistant-speech-loading-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.assistant-speech-loading-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

.assistant-speech-speed-control {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 2px 4px 0;
}

.assistant-speech-speed-label,
.assistant-speech-speed-value {
    font-size: 12px;
    color: var(--text-color-secondary);
    white-space: nowrap;
}

.assistant-speech-speed-range {
    width: 100%;
    min-width: 96px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.assistant-speech-speed-range:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.assistant-bookmark-btn.bookmarked svg,
.user-bookmark-btn.bookmarked svg {
    color: var(--primary-color);
    fill: var(--primary-color);
}

/* Assistant Thinking Component */
.assistant-thinking {
    overflow: hidden;
    border-radius: 10px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.assistant-thinking-header {
    width: 100%;
    cursor: pointer;
    gap: 6px;
    padding: 6px 2px;
    border: none;
    background: none;
    transition: opacity 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-thinking-header:hover {
        opacity: 0.7;
    }
}

.assistant-thinking-header, .assistant-thinking-title, .thinking-step-header {
    display: flex;
    align-items: center;
}

.assistant-thinking-title {
    color: var(--text-color-secondary);
    transition: color 0.2s ease;
    text-align: left;
    font-size: 13px;
}

/* Chevron indicator */
.assistant-thinking-header::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid var(--text-color-tertiary, #9b9a97);
    border-bottom: 1.5px solid var(--text-color-tertiary, #9b9a97);
    transform: rotate(45deg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-right: 2px;
    margin-bottom: 1px;
}

.assistant-thinking.collapsed .assistant-thinking-header::before {
    transform: rotate(-45deg);
    margin-bottom: 0;
    margin-top: 1px;
}

/* Shimmer animation for active thinking */
.assistant-thinking-title .assistant-thinking-shimmer {
    background: linear-gradient(
        90deg,
        var(--text-color-secondary) 0%,
        var(--text-color) 50%,
        var(--text-color-secondary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: assistant-thinking-shimmer 3s ease-in-out infinite;
}

/* Expandable content area */
.assistant-thinking-content {
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

.assistant-thinking-content > * {
    overflow: hidden;
}

.assistant-thinking.collapsed .assistant-thinking-content {
    grid-template-rows: 0fr;
    opacity: 0;
}

/* Body container */
.assistant-thinking-body {
    padding: 2px 0 8px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Individual step */
.thinking-step {
    padding: 4px 8px;
    position: relative;
    border-radius: 6px;
    border-left: none;
    transition: background-color 0.15s ease;
}

.thinking-step::before {
    display: none;
}

.thinking-step:first-child {
    margin-top: 0;
}

.thinking-step:last-child {
    margin-bottom: 0;
}

.thinking-step-header {
    gap: 6px;
    margin-bottom: 2px;
}

.thinking-step-title, .thinking-step-content {
    font-size: 13px;
}

.thinking-step-title {
    font-weight: 500;
    color: var(--text-color);
}

.thinking-step-content {
    line-height: 1.5;
    color: var(--text-color-secondary);
}

/*
 * Thinking steps use the shared Markdown renderer, but they intentionally keep
 * the compact reasoning typography from the non-Markdown presentation. The
 * generic .markdown-body defaults are sized for full assistant answers.
 */
.thinking-step-content.markdown-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-color-secondary);
}

.thinking-step-content.markdown-body p {
    line-height: 1.5;
}

.thinking-step-content svg {
    color: var(--text-color-secondary);
    min-height: 14px;
    min-width: 14px;
}

/* Function Call Styling — unified with thinking steps */
.thinking-step-function-call {
    border-left: none;
}

.thinking-step-function-call::before {
    display: none;
}

.function-call-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.function-call-icon svg {
    width: 13px;
    height: 13px;
    fill: var(--text-color-tertiary, #9b9a97);
}

.function-call-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-color);
}

.function-call-params {
    font-size: 12px;
    color: var(--text-color-secondary);
    line-height: 1.5;
    margin-top: 1px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px;
}

.function-call-params-label {
    font-weight: 500;
    color: var(--text-color-tertiary, #9b9a97);
    margin-right: 2px;
    font-size: 12px;
}

.function-call-param {
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", monospace;
    font-size: 11px;
    color: var(--text-color-secondary);
    background-color: var(--hover, rgba(0, 0, 0, 0.04));
    padding: 1px 5px;
    border-radius: 4px;
}

.function-call-error {
    margin-top: 6px;
    padding: 6px 8px;
    border: 1px solid var(--error-border);
    border-radius: 6px;
    background: var(--error-background);
    color: var(--error-color);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.thinking-step-function-call.is-tool-call-failed .function-call-name,
.thinking-step-function-call.is-tool-call-failed .function-call-icon svg {
    color: var(--error-color);
    fill: var(--error-color);
}

.function-call-live-preview {
    /*
     * Keep the streaming preview on the same semantic surface as other input
     * controls. In particular, do not use a light-only fallback here: the
     * preview must also follow live theme changes without being rebuilt.
    */
    --tool-input-preview-surface: var(--surface-control, var(--input-bg, var(--background)));
    --tool-input-preview-border: var(--surface-control-border, var(--border-color));
    --tool-input-preview-text: color-mix(in srgb, var(--text-color-secondary) 82%, var(--text-color));
    margin-top: 8px;
    border: 1px solid var(--tool-input-preview-border);
    border-radius: 10px;
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--surface-interactive-hover, var(--hover)) 44%, transparent),
            transparent 32%
        ),
        var(--tool-input-preview-surface);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-color) 7%, transparent);
}

.function-call-live-preview-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tool-input-preview-text);
}

.function-call-live-preview-label::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 72%, transparent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary-color) 26%, transparent);
}

.function-call-live-preview[data-preview-mode="live"] .function-call-live-preview-label::before {
    animation: function-call-live-dot 1.3s ease-in-out infinite;
}

.function-call-live-preview-viewport {
    position: relative;
    height: clamp(96px, 16vh, 160px);
    overflow: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--text-color-tertiary) 72%, transparent) transparent;
}

.function-call-live-preview-viewport::before,
.function-call-live-preview-viewport::after {
    content: "";
    position: sticky;
    left: 0;
    right: 0;
    display: block;
    height: 14px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.function-call-live-preview-viewport::before {
    top: 0;
    margin-bottom: -14px;
    background: linear-gradient(180deg, var(--tool-input-preview-surface), transparent);
}

.function-call-live-preview-viewport::after {
    bottom: 0;
    margin-top: -14px;
    background: linear-gradient(0deg, var(--tool-input-preview-surface), transparent);
}

.function-call-live-preview.is-overflowing .function-call-live-preview-viewport::after,
.function-call-live-preview.is-manual-scroll .function-call-live-preview-viewport::before {
    opacity: 1;
}

.function-call-live-preview-code {
    margin: 0;
    padding: 0 10px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--tool-input-preview-text);
}

.function-call-live-preview-code::selection {
    background: var(--code-token-selection, color-mix(in srgb, var(--primary-color) 28%, transparent));
    color: var(--text-color);
}

.thinking-step-function-call.is-tool-call-streaming .function-call-name {
    background: linear-gradient(
        90deg,
        var(--text-color-secondary) 0%,
        var(--text-color) 50%,
        var(--text-color-secondary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: assistant-thinking-shimmer 2.4s ease-in-out infinite;
}

/* Collapsed state */
.assistant-thinking.collapsed .assistant-thinking-header {
    border-radius: 10px;
}

/* Pending assistant state */
.assistant-thinking-loading .assistant-thinking-header {
    pointer-events: none;
}

/* Step entry animation */
.thinking-step {
    animation: fadeInUp4 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@media (hover: hover) and (pointer: fine) {
    .select-dropdown-button:hover {background-color: var(--surface-interactive-hover, var(--hover));
        cursor: pointer;}

    .select-dropdown-button-red:hover {background-color: var(--danger-hover-bg);}
    .user-message-list-button:hover, .assistant-message-list-button:hover {background-color: var(--hover);}
    .user-message-expand-toggle:hover {background-color: var(--hover);}
    .user-message-container:hover .user-message-list,
    .user-message-container:focus-within .user-message-list {opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);}
    .assistant-thinking-title:hover {color: var(--text-color);}
}
@media (hover: none), (pointer: coarse) {
    .user-message-container .user-message-list {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }
}

/* Chat-area-container full-width – CSS-first with JS fallback for older browsers */
body.chat-area-compact .chat-area-container {
    max-width: 100% !important;
    min-width: 100% !important;
}

body.chat-area-compact .chat-container-welcome {
    font-size: clamp(22px, 4cqw, 28px);
    white-space: normal;
    overflow: visible;
    text-align: center;
    margin-bottom: 38px;
}

@container chat-layout (max-width: 1000px) {
    .chat-area-container {
        max-width: 100% !important;
        min-width: 100% !important;
    }

    .chat-container-welcome {
        font-size: clamp(26px, 4cqw, 32px);
        white-space: normal;
        overflow: visible;
        text-align: center;
        margin-bottom: clamp(44px, 5cqw, 52px);
    }
}

.subagent-transcript-chat {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
}

.subagent-transcript-chat .assistant-message {
    max-width: 100%;
}

.subagent-transcript-empty {
    padding: 18px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-color-secondary);
    font-size: 14px;
    text-align: center;
}

/* ===== Assistant Inline Images ===== */
.assistant-inline-image {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-color);
}

.assistant-inline-image-img {
    display: block;
    max-width: 100%;
    max-height: 512px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 11px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/*
 * SVG files may declare a 1x1 intrinsic size while placing the actual artwork
 * in a much larger viewBox. Give vector previews a useful responsive canvas;
 * the image's aspect ratio and max-height still prevent distortion/overflow.
 * A document-colored surface also keeps transparent black vectors visible in
 * dark mode (QR codes are a common example).
 */
.assistant-inline-image[data-file-type="image/svg+xml"] {
    display: block;
    width: min(100%, 512px);
    background-color: var(--document-preview-background);
}

.assistant-inline-image[data-file-type="image/svg+xml"] .assistant-inline-image-img {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
}

.assistant-inline-image.loaded .assistant-inline-image-img {
    opacity: 1;
}

.assistant-inline-image-download {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
    z-index: 10;
}

.assistant-inline-image:focus-within .assistant-inline-image-download {
    opacity: 1;
    visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-inline-image:hover .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}
@media (hover: none), (pointer: coarse) {
    .assistant-inline-image .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}

.assistant-inline-video:focus-within .assistant-inline-image-download {
    opacity: 1;
    visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-inline-video:hover .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}
@media (hover: none), (pointer: coarse) {
    .assistant-inline-video .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}

.assistant-inline-audio:focus-within .assistant-inline-image-download {
    opacity: 1;
    visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-inline-audio:hover .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}
@media (hover: none), (pointer: coarse) {
    .assistant-inline-audio .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
}

@media (hover: hover) and (pointer: fine) {
    .assistant-inline-image-download:hover {
        background-color: rgba(0, 0, 0, 0.8);
        transform: scale(1.05);
    }
}

.assistant-inline-image-download:active {
    transform: scale(0.95);
}

.assistant-inline-image-download:focus-visible {
    outline: 2px solid var(--accent-color, #3b82f6);
    outline-offset: 2px;
    opacity: 1;
    visibility: visible;
}

.assistant-inline-image-download svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===== Assistant Inline Videos ===== */
.assistant-inline-video {
    position: relative;
    display: inline-block;
    width: min(720px, 100%);
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-color);
}

.assistant-inline-audio {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(720px, 100%);
    margin: 12px 0;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--accent-color, #3b82f6) 22%, transparent), transparent 54%),
        linear-gradient(145deg, var(--surface-secondary), color-mix(in srgb, var(--surface-secondary) 70%, #0f172a 30%));
    padding: 14px 14px 12px;
}

.assistant-inline-audio-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.assistant-inline-audio-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent-color, #3b82f6) 24%, transparent);
    color: var(--text-color);
    flex-shrink: 0;
}

.assistant-inline-audio-icon svg {
    width: 18px;
    height: 18px;
}

.assistant-inline-audio-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.assistant-inline-audio-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assistant-inline-audio-details {
    font-size: 11px;
    color: var(--text-color-secondary, #64748b);
}

.assistant-inline-audio-player {
    width: 100%;
    display: block;
}

.assistant-inline-audio .assistant-inline-image-download {
    top: 10px;
    right: 10px;
}

.assistant-inline-video-player {
    display: block;
    width: 100%;
    max-height: min(70vh, 540px);
    background: #000;
}

.assistant-inline-video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 66px;
    height: 66px;
    border-radius: 999px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(4px);
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
    z-index: 5;
}

.assistant-inline-video-play-overlay svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.assistant-inline-video.is-playing .assistant-inline-video-play-overlay {
    opacity: 0;
    pointer-events: none;
}

.assistant-inline-video-buffering {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.14) 35%,
        rgba(255, 255, 255, 0.04) 70%
    );
    background-size: 460px 100%;
    animation: imageGenShimmer 1.6s linear infinite;
    z-index: 4;
}

.assistant-inline-video-buffering.active {
    display: flex;
}

.assistant-inline-video-buffering span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    animation: imageGenPulse 0.95s ease-in-out infinite;
}

.assistant-inline-video-buffering span:nth-child(2) {
    animation-delay: 0.14s;
}

.assistant-inline-video-buffering span:nth-child(3) {
    animation-delay: 0.28s;
}

.assistant-inline-video-placeholder {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 6;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.2) 0%,
        rgba(0, 0, 0, 0.35) 35%,
        rgba(0, 0, 0, 0.2) 70%
    );
    transition: opacity 0.25s ease;
}

.assistant-inline-video-placeholder.is-hidden {
    opacity: 0;
}

/* Mobile: always show download button */
@media (max-width: 768px) {
    .assistant-inline-image-download {
        opacity: 1;
        visibility: visible;
    }
     }

/* ===== Image Generation Placeholder ===== */

.assistant-image-gen-placeholder,
.assistant-video-gen-placeholder,
.assistant-audio-gen-placeholder {
    max-width: 100%;
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant-image-gen-placeholder {
    width: 512px;
    aspect-ratio: 1 / 1;
}

.assistant-video-gen-placeholder {
    width: min(720px, 100%);
    aspect-ratio: 16 / 9;
}

.assistant-audio-gen-placeholder {
    width: min(720px, 100%);
    min-height: 120px;
}

.image-gen-placeholder-shimmer,
.audio-gen-placeholder-shimmer,
.video-gen-placeholder-shimmer {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        var(--surface-secondary) 0%,
        var(--hover, rgba(255, 255, 255, 0.06)) 40%,
        var(--surface-secondary) 80%
    );
    background-size: 600px 100%;
    animation: imageGenShimmer 2s ease-in-out infinite;
}

.image-gen-placeholder-shimmer,
.video-gen-placeholder-shimmer {
    height: 100%;
    gap: 14px;
}

.audio-gen-placeholder-shimmer {
    min-height: 120px;
    gap: 12px;
}

.image-gen-placeholder-icon,
.audio-gen-placeholder-icon,
.video-gen-placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color-secondary, #64748b);
    opacity: 0.5;
    animation: imageGenPulse 2.4s ease-in-out infinite;
}

.image-gen-placeholder-icon svg,
.video-gen-placeholder-icon svg {
    width: 48px;
    height: 48px;
}

.image-gen-placeholder-label,
.audio-gen-placeholder-label,
.video-gen-placeholder-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color-secondary, #64748b);
    letter-spacing: 0.01em;
    animation: imageGenPulse 2.4s ease-in-out infinite;
    user-select: none;
}

.assistant-image-gen-placeholder-fade-out {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.assistant-music-gen-placeholder {
    width: min(720px, 100%);
    min-height: 148px;
    max-width: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 187, 92, 0.14), transparent 42%),
        linear-gradient(135deg, var(--surface-secondary), color-mix(in srgb, var(--surface-secondary) 86%, #f59e0b 14%));
    border: 1px solid color-mix(in srgb, var(--border-color) 78%, #f59e0b 22%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-gen-placeholder-shimmer {
    position: relative;
    width: 100%;
    min-height: 148px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        rgba(245, 158, 11, 0.06) 0%,
        rgba(255, 255, 255, 0.12) 40%,
        rgba(245, 158, 11, 0.06) 80%
    );
    background-size: 600px 100%;
    animation: imageGenShimmer 2s ease-in-out infinite;
}

.music-gen-placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: color-mix(in srgb, var(--text-color-secondary, #64748b) 72%, #f59e0b 28%);
    opacity: 0.8;
    animation: imageGenPulse 2.4s ease-in-out infinite;
}

.music-gen-placeholder-icon svg {
    width: 40px;
    height: 40px;
}

.music-gen-placeholder-label {
    font-size: 13px;
    font-weight: 600;
    color: color-mix(in srgb, var(--text-color-secondary, #64748b) 78%, #f59e0b 22%);
    letter-spacing: 0.01em;
    animation: imageGenPulse 2.4s ease-in-out infinite;
    user-select: none;
}

.assistant-inline-music {
    border-color: color-mix(in srgb, var(--border-color) 78%, #f59e0b 22%);
    background:
        radial-gradient(circle at top left, rgba(255, 187, 92, 0.12), transparent 38%),
        var(--surface-primary, var(--surface-secondary));
}

.assistant-inline-music-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.assistant-inline-music-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--border-color) 74%, #f59e0b 26%);
    background: color-mix(in srgb, var(--surface-secondary) 84%, #f59e0b 16%);
    color: var(--text-color-secondary);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.assistant-inline-music-details {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-secondary) 92%, #000 8%);
}

.assistant-inline-music-details summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color-secondary);
}

.assistant-inline-music-text,
.assistant-inline-music-lyrics {
    margin-top: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.5;
}

.assistant-inline-music-lyrics {
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-primary) 82%, #000 18%);
    overflow-x: auto;
}

.audio-gen-placeholder-icon svg {
    width: 38px;
    height: 38px;
}

/* ===== Scroll to Bottom Button ===== */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: calc(var(--scroll-btn-offset-base, 140px) + var(--scroll-btn-extra, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-normal-elevated, var(--background));
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    color: var(--text-color-secondary, #64748b);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: 
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease,
        background-color 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

@media (hover: hover) and (pointer: fine) {
    .scroll-to-bottom-btn:hover {
        background: linear-gradient(var(--hover), var(--hover)), var(--bg-normal-elevated, var(--background));
        color: var(--text-color);
        border-color: var(--border-color-hover, var(--border-color));
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.08);
    }
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) translateY(0) scale(0.95);
}

.scroll-to-bottom-btn:focus-visible {
    outline: 2px solid var(--accent-color, #3b82f6);
    outline-offset: 2px;
}

.scroll-to-bottom-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Tablet & smaller desktop */
@media (max-width: 1024px) {
    .scroll-to-bottom-btn {
        width: 38px;
        height: 38px;
    }
     }

/* Mobile */
@media (max-width: 700px) {
    .scroll-to-bottom-btn {
        width: 44px;
        height: 44px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
    }
    
    .scroll-to-bottom-btn svg {
        width: 22px;
        height: 22px;
    }
     }

/* Small mobile */
@media (max-width: 420px) {
    .scroll-to-bottom-btn {
        width: 42px;
        height: 42px;
    }
     }

/* Edit Chat Modal Styles */
.edit-chat-form {
    margin: 20px 0;
}

.edit-chat-input-group {
    margin-bottom: 16px;
}

.edit-chat-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.edit-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.edit-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.edit-chat-input:focus {
    border-color: var(--primary-color);
}

.edit-chat-input::placeholder {
    color: var(--text-color-secondary);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .scroll-to-bottom-btn {
        width: 48px;
        height: 48px;
    }
    
    .scroll-to-bottom-btn:active {
        background: linear-gradient(var(--hover), var(--hover)), var(--bg-normal-elevated, var(--background));
        transform: translateX(-50%) translateY(0) scale(0.92);
    }
     }

/* BYOK styles moved to /css/userSettings/byok.css */
