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

.assistant-widget {
    margin: 16px 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;
}

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

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

.chat-select-submenu {
    --select-submenu-closed-transform: translateX(-6px) scale(0.98);
    --select-submenu-open-transform: translateX(0) scale(1);
    --select-submenu-transform-origin: top left;
    width: 260px;
    gap: 6px;
    left: calc(100% + 8px);
    right: auto;
}

.add-project-item .chat-select-submenu .select-dropdown-button {
    justify-content: space-between;
    gap: 12px;
}

.has-submenu::after {
    content: "";
    position: absolute;
    right: 100%;
    top: -8px;
    height: calc(100% + 16px);
    width: 10px;
    pointer-events: auto;
}

.add-project-item::after {
    right: auto;
    left: 100%;
    width: 12px;
}

@media (max-width: 1024px) {
    body.sidebar-overlay-mode .sidebar-container .add-project-item.select-dropdown-item.has-submenu,
    .project-sidebar .add-project-item.select-dropdown-item.has-submenu {
        display: flex;
        flex-direction: column;
    }

    body.sidebar-overlay-mode .sidebar-container .add-project-item::after,
    .project-sidebar .add-project-item::after {
        display: none;
    }

    body.sidebar-overlay-mode .sidebar-container .add-project-item .chat-select-submenu,
    .project-sidebar .add-project-item .chat-select-submenu {
        position: static;
        top: auto;
        right: auto;
        left: auto;
        width: 100%;
        min-width: 0;
        margin-top: 4px;
        display: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        transition: none;
    }

    body.sidebar-overlay-mode .sidebar-container .add-project-item.open > .chat-select-submenu,
    body.sidebar-overlay-mode .sidebar-container .add-project-item:focus-within > .chat-select-submenu,
    .project-sidebar .add-project-item.open > .chat-select-submenu,
    .project-sidebar .add-project-item:focus-within > .chat-select-submenu {
        display: flex;
        transform: none;
    }
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--background);
    position: relative;
    overflow-y: visible;
    --scroll-btn-offset-base: 140px;
    --scroll-btn-extra: 0px;
}
.chat-container-main {
    max-height: calc(100dvh - 50px);
    min-height: calc(100dvh - 50px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 1px solid var(--border-color);
    position: relative;
}

.chat-actions-container {
    display: none;
    width: 100%;
    max-height: 100%;
    padding: 48px 20px;
    box-sizing: border-box;
    justify-content: center;
    overflow-y: auto;
}

.chat-container-main.showing-chat-action {
    align-items: center;
}

.chat-container-main.showing-chat-action .chat-actions-container {
    display: flex;
}

.chat-container-main.showing-chat-action .chat-area,
.chat-container-main.showing-chat-action .chat-box-area,
.chat-container-main.showing-chat-action .chat-box-warning,
.chat-container-main.showing-chat-action .chat-container-welcome {
    display: none;
}
.chat-container .background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.chat-container-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--text-color);
    font-size: clamp(18px, 3vw, 24px);
    margin-bottom: 30px;
    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 */;
}

@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;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    container-type: inline-size;
    container-name: chat-files-layout;
}
.chat-area-container {
    height: 100%;
    max-width: 70%;
    min-width: 70%;
}

.chat-area-container::after {
    content: "";
    display: block;
    height: 140px;
}

.dynamic-scroll-spacer {
    flex: 0 0 auto;
}

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

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

.user-message-area {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding-top: 20px;
}
.user-message {
    background-color: 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;
}

.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: var(--user-message-collapsed-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-error {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--error-color);
    border-radius: 10px;
    color: var(--error-color);
    width: fit-content;
}

/* ── 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 {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    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 {
    position: relative;
    width: 100%;
    max-width: 440px;
    margin: 16px;
    background: var(--background, #ffffff);
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 20px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.18);
    transform: translateY(16px) scale(0.96);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    opacity: 0;
    overflow: hidden;
}

.feedback-modal-overlay.is-visible .feedback-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.feedback-modal-overlay.is-closing .feedback-modal {
    transform: translateY(10px) scale(0.97);
    opacity: 0;
}

.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0 24px;
}

.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-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-color, #0f172a);
    line-height: 1.3;
}

.feedback-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-color-secondary, #94a3b8);
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .feedback-modal-close:hover {
        background-color: var(--hover, rgba(148, 163, 184, 0.2));
        color: var(--text-color, #0f172a);
    }
}

.feedback-modal-close svg {
    width: 16px;
    height: 16px;
}

.feedback-modal-body {
    padding: 20px 24px;
}

.feedback-modal-subtitle {
    font-size: 14px;
    color: var(--text-color-secondary, #64748b);
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Initial prompt state */
.feedback-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feedback-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    width: 100%;
    border-radius: 12px;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border: 1px solid var(--border-color, #e5e5e5);
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.2s ease;
    color: var(--text-color, #0f172a);
    background: transparent;
}

.feedback-modal-btn:active {
    transform: scale(0.97);
}

.feedback-modal-btn.submit {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .feedback-modal-btn:hover {background-color: var(--hover, rgba(148, 163, 184, 0.15));}
    .feedback-modal-btn.submit:hover {background: var(--secondary-color, #2563eb);}
     }

/* 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-color, #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 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}

.feedback-modal-char-count {
    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;
}

.feedback-modal-footer-buttons .feedback-modal-btn {
    width: auto;
}

@media (max-width: 480px) {
    .feedback-modal {
        max-width: calc(100vw - 32px);
        border-radius: 16px;
    }
    .feedback-modal-header {
        padding: 16px 20px 0 20px;
    }
    .feedback-modal-body {
        padding: 16px 20px;
    }
     }

.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-inline-files {
    margin: 0;
    gap: 12px;
    width: min(100%, 520px);
    max-height: 168px;
    align-self: flex-end;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Keep a lone edit attachment aligned with the right edge of the user composer. */
.user-message-edit-inline-files.active .inline-files-element:only-child {
    grid-column: -2 / -1;
    justify-self: end;
}

.user-message-edit-inline-files:not(.active) {
    display: none;
}

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

.user-message-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    border: 1px solid transparent;
    outline: none;
    white-space: nowrap;
}

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

.user-message-edit-btn-cancel {
    background-color: var(--background);
    border-color: var(--border-color);
    color: var(--text-color-primary);
}

@media (hover: hover) and (pointer: fine) {
    .user-message-edit-btn-cancel:hover {
        background-color: var(--hover);
    }
}

.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-btn svg {
    width: 14px;
    height: 14px;
}

.user-message-edit-dropdown .select-dropdown {
    top: auto;
    right: auto;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-height: min(420px, calc(100dvh - 24px));
    overflow-y: auto;
    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;
}

/* Sources */
.assistant-message-list-button-sources {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    border-radius: 999px;
    padding: 0px 6px;
    font-size: 13px;
    gap: 6px;
    color: var(--text-color-secondary);
}

.assistant-message-list-button-sources svg {
    height: 16px;
    width: 16px;
    /* Keep color for stroke to work */
    color: var(--text-color-secondary);
}
/* Avoid overriding explicit fill="none" */
.assistant-message-list-button-sources svg:not([fill="none"]) {
    fill: var(--text-color-secondary);
}

/* 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-color);
    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-color));
}

.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-step-content svg {
    fill: 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-live-preview {
    margin-top: 8px;
    border: 1px solid color-mix(in srgb, var(--border-color, rgba(0, 0, 0, 0.08)) 78%, transparent);
    border-radius: 10px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--hover, rgba(0, 0, 0, 0.04)) 70%, transparent), transparent 32%),
        color-mix(in srgb, var(--input-background-color, rgba(255, 255, 255, 0.6)) 88%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.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(--text-color-tertiary, #9b9a97);
}

.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;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.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, color-mix(in srgb, var(--input-background-color, rgba(255, 255, 255, 0.72)) 96%, transparent), transparent);
}

.function-call-live-preview-viewport::after {
    bottom: 0;
    margin-top: -14px;
    background: linear-gradient(0deg, color-mix(in srgb, var(--input-background-color, rgba(255, 255, 255, 0.72)) 96%, transparent), 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(--text-color-secondary);
}

.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;
}

.assistant-thinking.collapsed .thinking-spinner {
    animation-play-state: paused;
    opacity: 0.5;
}

/* Loading skeleton */
.assistant-thinking-loading .assistant-thinking-header {
    pointer-events: none;
}

.assistant-thinking-loading-skeleton {
    display: flex;
    gap: 8px;
    padding: 4px 8px 10px;
}

.assistant-thinking-loading-skeleton span {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--hover, rgba(0, 0, 0, 0.05));
    animation: thinking-skeleton-pulse 1.5s ease-in-out infinite;
}

.assistant-thinking-loading-skeleton span:nth-child(1) { width: 40px; }
.assistant-thinking-loading-skeleton span:nth-child(2) { width: 60px; animation-delay: 0.15s; }
.assistant-thinking-loading-skeleton span:nth-child(3) { width: 30px; animation-delay: 0.3s; }

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

.inline-files {
    display: none;
    margin: 10px 0;
    gap: 12px;
    width: 100%;
}
#chatBoxFiles.inline-files {
    margin: 0 0 12px 0;
    align-self: stretch;
}
.user-message-area .inline-files {
    margin: 0;
    width: min(100%, 520px);
    align-self: flex-end;
}
.user-message-area .inline-files.active .inline-files-element:only-child {
    grid-column: -2 / -1;
    justify-self: end;
}
.inline-files.active {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.inline-files.inline-files-audio-only {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-message-area .inline-files.inline-files-audio-only {
    width: min(100%, 520px);
}
#chatBoxFiles.inline-files.active {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(64px, auto);
    max-height: calc((64px + 12px) * 2);
    overflow-y: scroll;
    overflow-x: hidden;
    padding-right: 4px;
    border-radius: 18px;
    scrollbar-gutter: stable;
}
.inline-files-element {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    border-radius: 16px;
    background-color: var(--input-bg);
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}

.inline-file-unsupported {
    border: 1px solid color-mix(in srgb, var(--error-color) 42%, var(--border-color));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--error-color) 20%, transparent);
}

.inline-file-unsupported-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--error-color) 88%, #000);
    color: #fff;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--error-color) 35%, transparent);
    z-index: 3;
    pointer-events: auto;
}

.inline-file-unsupported-badge svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}
.inline-files-element.is-uploading {
    overflow: hidden;
}
.inline-files-element.inline-files-align-placeholder {
    display: none;
}

@container chat-files-layout (min-width: 621px) {
    .inline-files-element.inline-files-align-placeholder {
        display: block;
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
        min-height: 0;
        height: 0;
        visibility: hidden;
        pointer-events: none;
    }
     }
.inline-files-element-icon {
    min-width: 40px;
    height: 40px;
    background-color: red;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.inline-files-element-icon svg {
    width: 20px;
    height: 20px;
}
.inline-files-element-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: var(--text-color);
    min-width: 0;
}

.inline-files-element-content-top {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    font-weight: 600;
    min-width: 0;
}

.inline-files-element-content-top p {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-files-element-content-bottom {
    display: flex;
    justify-content: space-between;
    color: var(--text-color-secondary);
    gap: 8px;
    flex-wrap: wrap;
}

.inline-files-element-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--text-color);
    color: var(--background);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    cursor: pointer;
    z-index: 2;
}

.inline-files-element-delete svg {
    width: 16px;
    height: 16px;
}

.inline-files-element.inline-files-element-previewable {
    cursor: pointer;
}

#chatBoxFiles.inline-files .inline-files-element {
    height: auto;
    min-height: 64px;
}
#chatBoxFiles.inline-files.active .inline-files-element:only-child {
    grid-column: 1 / 2;
    justify-self: start;
}

.inline-files-upload {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    pointer-events: none;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    background-color: transparent;
}

.inline-files-upload-bar {
    position: absolute;
    inset: 0;
    background-color: var(--border-color);
}

.inline-files-upload-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: var(--primary-color);
    transition: width 0.15s ease-out;
}

@media (hover: hover) and (pointer: fine) {
    .inline-files-element:hover .inline-files-element-delete {
        opacity: 1;
        pointer-events: auto;
    }
}
@media (hover: none), (pointer: coarse) {
    .inline-files-element .inline-files-element-delete {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (hover: none) and (pointer: coarse) {
    .inline-files-element-delete {
        opacity: 1;
        pointer-events: auto;
    }
}

@container chat-files-layout (max-width: 620px) {
    .inline-files.active {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #chatBoxFiles.inline-files.active {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container chat-files-layout (max-width: 360px) {
    .inline-files.active {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .user-message-area .inline-files {
        width: 100%;
    }
    #chatBoxFiles.inline-files.active {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

body.chat-area-compact .inline-files.active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.chat-area-compact #chatBoxFiles.inline-files.active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

    .select-dropdown-button-red:hover {background-color: var(--danger-hover-bg);}
    .assistant-message-list-button-redo:hover {background-color: var(--hover);}
    .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-message-list-button-sources:hover {background-color: var(--hover);}
    .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(16px, 5vw, 18px);
    white-space: normal;
    overflow: visible;
    text-align: center;
    margin-bottom: 20px;
}

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

    .chat-container-welcome {
        font-size: clamp(16px, 5vw, 18px);
        white-space: normal;
        overflow: visible;
        text-align: center;
        margin-bottom: 20px;
    }
     }

.subagent-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(100%, 420px);
    min-height: 44px;
    margin: 12px 0;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-secondary, var(--background-color));
    color: var(--text-color);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.subagent-launcher:focus-visible,
.subagent-modal-close:focus-visible {
    outline: 2px solid var(--focus-color, var(--primary-color));
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .subagent-launcher:hover {
        border-color: var(--primary-color);
        background: var(--hover, var(--background-secondary));
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    }
}

.subagent-launcher-icon,
.subagent-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    color: var(--primary-color);
    flex-shrink: 0;
}

.subagent-launcher-icon svg,
.subagent-modal-icon svg {
    width: 16px;
    height: 16px;
}

.subagent-launcher-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    gap: 2px;
}

.subagent-launcher-title {
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.subagent-launcher-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 12px;
    color: var(--text-color-secondary);
}

.subagent-launcher-count::before {
    content: "•";
    margin-right: 8px;
    color: var(--text-color-secondary);
}

.subagent-launcher-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--background, var(--background-color));
    color: var(--text-color-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.subagent-launcher.is-completed .subagent-launcher-status,
.subagent-modal-status.is-completed {
    color: var(--primary-color);
}

.subagent-launcher.is-error .subagent-launcher-status,
.subagent-modal-status.is-error {
    color: var(--error-color, #d92d20);
}

.subagent-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

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

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

.subagent-modal {
    display: flex;
    flex-direction: column;
    width: min(920px, 100%);
    max-height: min(780px, calc(100vh - 48px));
    background: var(--background, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    color: var(--text-color);
    overflow: hidden;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.subagent-modal-overlay.is-visible .subagent-modal {
    transform: translateY(0) scale(1);
}

.subagent-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-secondary, var(--background-color));
}

.subagent-modal-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.subagent-modal-title-block {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.subagent-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.subagent-modal-status {
    font-size: 12px;
    color: var(--text-color-secondary);
}

.subagent-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .subagent-modal-close:hover {
        background: var(--hover, rgba(148, 163, 184, 0.2));
        color: var(--text-color);
    }
}

.subagent-modal-close svg {
    width: 16px;
    height: 16px;
}

.subagent-modal-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 22px clamp(16px, 4vw, 42px);
}

.subagent-modal-chat {
    max-width: 760px;
    margin: 0 auto;
}

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

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

@media (max-width: 640px) {
    .subagent-modal-overlay {
        align-items: stretch;
        padding: 10px;
    }

    .subagent-modal {
        max-height: calc(100vh - 20px);
        border-radius: 10px;
    }

    .subagent-launcher {
        width: 100%;
    }

    .subagent-launcher-expand {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .subagent-launcher,
    .subagent-modal-overlay,
    .subagent-modal {
        transition: none;
    }
}

.assistant-file {
    margin: 12px 0;
    width: 100%;
}

.assistant-file .inline-files.assistant-generated-file {
    max-width: 280px;
    grid-template-columns: 1fr;
}

.assistant-file .inline-files-element {
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-color);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .assistant-file .inline-files-element:hover {
        background-color: var(--hover);
        border-color: var(--border-color-hover, var(--border-color));
    }
}

.assistant-file .inline-files-element-icon {
    background-color: var(--accent-color, #3b82f6);
}

/* ===== 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.assistant-inline-image-previewable,
.assistant-inline-image.inline-files-element-previewable {
    cursor: pointer;
}

.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;
}

.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 */
