/* Chat page stylesheet extracted from template */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Override global layout.css which sets margin-bottom: 30px on html/body
   and overflow-x: hidden on html (which clips position:fixed in Edge/Chrome) */
html {
    height: 100%;
    margin: 0;
    overflow: visible; /* must override layout.css overflow-x:hidden on html */
}

:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f4f4f5;
    --bg-tertiary: #e9e9eb;
    --bg-hover: rgba(0, 0, 0, 0.05);
    --text-primary: #1a1a1a;
    --text-secondary: var(--zgfgray, #75777B);
    --border-color: rgba(0, 0, 0, 0.14);
    --accent: var(--zgfred, #E33B45);
    --accent-hover: #C12E37;
    --accent-color: var(--zgfred, #E33B45);
    --user-msg-bg: #ffffff;
    --assistant-msg-bg: #f4f4f5;
    --error-color: var(--zgfred, #E33B45);
    --warning-color: #b45309;
    --success-color: #1a7a3c;
    --success-bg: rgba(26, 122, 60, 0.12);
    --csv-tint-start: #eaf6ee;
    --csv-border: #bfe0c9;
    /* Subtle overlays used on code blocks / accordions — invert per theme */
    --overlay-border: rgba(0, 0, 0, 0.12);
    --overlay-bg: rgba(0, 0, 0, 0.04);
    --overlay-bg-hover: rgba(0, 0, 0, 0.08);
    --overlay-text: rgba(0, 0, 0, 0.55);
    --overlay-text-strong: rgba(0, 0, 0, 0.7);
    --overlay-text-faint: rgba(0, 0, 0, 0.4);
    --sidebar-width: 260px;
}

/* Dark theme override — matches the original chat palette */
[data-theme="dark"] {
    --bg-primary: var(--appbg, #282828);
    --bg-secondary: var(--darkbg, #202020);
    --bg-tertiary: #303030;
    --bg-hover: rgba(128, 128, 128, 0.08);
    --text-primary: var(--white, #FFFFFF);
    --text-secondary: var(--zgflightgray, #A7A9AC);
    --border-color: var(--zgfgray, #75777B);
    --user-msg-bg: var(--appbg, #282828);
    --assistant-msg-bg: var(--darkbg, #202020);
    --warning-color: #f59e0b;
    --success-color: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --csv-tint-start: #1a2a1a;
    --csv-border: #3a5a3a;
    --overlay-border: rgba(255, 255, 255, 0.08);
    --overlay-bg: rgba(255, 255, 255, 0.03);
    --overlay-bg-hover: rgba(255, 255, 255, 0.18);
    --overlay-text: rgba(255, 255, 255, 0.45);
    --overlay-text-strong: rgba(255, 255, 255, 0.7);
    --overlay-text-faint: rgba(255, 255, 255, 0.35);
}

body.chat-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    margin: 0; /* override global layout.css margin-bottom: 30px */
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    margin-right: 0; /* right panel space added via body.right-panel-visible when panel is shown */
}

/* right-panel removed — no margin-right needed */

/*
 * Use body.chat-root .sidebar (specificity 0,2,1) to decisively
 * override global navbar.css ".sidebar" rules (specificity 0,1,0):
 *   position:fixed  →  relative
 *   width:50px      →  var(--sidebar-width)
 *   transition      →  none
 *   hover width     →  unchanged
 */
body.chat-root .sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: var(--sidebar-width);
    min-width: 160px;
    max-width: 520px;
    height: auto;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: none;
    z-index: 1;
}

body.chat-root .sidebar:hover {
    width: var(--sidebar-width);
    opacity: 1;
}

/* Resize grip between sidebar and main content */
.sidebar-handle {
    width: 12px;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    transition: background .15s, border-color .15s;
}

/* CSS-only grip dots — no font dependency */
.sidebar-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 32px;
    background: repeating-linear-gradient(
        to bottom,
        var(--border-color) 0,
        var(--border-color) 3px,
        transparent 3px,
        transparent 7px
    );
    border-radius: 2px;
    transition: background .15s;
}

.sidebar-handle:hover,
.sidebar-handle.dragging {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

.sidebar-handle:hover::after,
.sidebar-handle.dragging::after {
    background: repeating-linear-gradient(
        to bottom,
        var(--accent) 0,
        var(--accent) 3px,
        transparent 3px,
        transparent 7px
    );
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color .2s;
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable; /* reserve scrollbar space so content doesn't reflow on hover */
    padding: 8px;
}

.conv-group-label {
    padding: 10px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

.conv-group-label.first {
    border-top: none;
}

.conv-empty,
.conv-load-error {
    padding: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.conv-load-error {
    color: #f87171;
}

/* ── Output panel (code execution results) ─────────────────── */
.output-panel {
    flex: none;
    width: var(--output-panel-width, 420px);
    min-width: 300px;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow: hidden;
}

.output-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    gap: 8px;
}

.output-panel-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.output-panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.output-panel-body {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.output-pdf-frame {
    flex: 1;
    width: 100%;
    border: none;
    min-height: 500px;
}

.output-image {
    max-width: 100%;
    object-fit: contain;
    padding: 12px;
    cursor: zoom-in;
}

.output-action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.output-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.output-error-pre {
    padding: 14px;
    font-size: 12px;
    color: #f87171;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: monospace;
}

.output-chart-container {
    flex: 1;
    width: 100%;
    padding: 16px;
}

.output-fallback {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.output-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    padding: 0 4px;
    line-height: 1;
}

.output-close-btn:hover {
    color: var(--text-primary);
}

.output-dl-btn {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
}

@media (max-width: 1100px) {
    .output-panel { display: none !important; }
}

.conversation-item {
    position: relative;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color .2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item:hover {
    background-color: var(--bg-tertiary);
}

.conversation-item.active {
    background-color: var(--bg-tertiary);
}

.delete-conv-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
}

.conversation-item:hover .delete-conv-btn {
    opacity: 1;
}

.delete-conv-btn:hover {
    color: var(--error-color);
}

.conversation-item.deleted {
    opacity: .5;
    text-decoration: line-through;
}

.conversation-item .conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    padding-right: 70px;
    color: var(--text-primary);
}

.conversation-item .conv-actions {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.conversation-item.deleted .conv-title {
    text-decoration: line-through;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0; /* allow flex item to shrink below content width */
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    color: var(--zgfred);
    font-size: 16px;
    font-weight: 600;
}

/* model-selector removed — single model only */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    position: relative;
}

.message.user {
    background-color: var(--user-msg-bg);
}

.message.assistant {
    background-color: var(--assistant-msg-bg);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    background-color: var(--accent);
}

.message.user .message-avatar {
    background-color: var(--zgfgray, #75777B);
}

.message-content {
    flex: 1;
    min-width: 0;
    line-height: 1.6;
    padding-top: 6px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content a {
    color: var(--accent, #4f8ef7);
    text-decoration: underline;
    word-break: break-all;
}

.message-content a:hover {
    opacity: 0.8;
}

.message-content pre {
    background-color: var(--bg-primary);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content code {
    background-color: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: .9em;
}

.message-content pre code {
    padding: 0;
    background: none;
}

.attachment-preview {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
}

.tool-call {
    background-color: var(--bg-primary);
    padding: 12px;
    border-radius: 6px;
    margin: 8px 0;
    border-left: 3px solid var(--accent);
}

.tool-call-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--accent);
}

.tool-call-result {
    font-size: .9em;
    color: var(--text-secondary);
}

/* ---- Code blocks ---- */
.code-block-wrap {
    position: relative;
    margin: 12px 0;
}

.code-block-wrap pre {
    margin: 0;
    border-radius: 8px;
    font-size: 13px;
}

.code-summary {
    padding: 4px 2px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    user-select: none;
}

.code-btns {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
}

.code-copy-btn {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 5px;
    border: 1px solid var(--overlay-border);
    background: var(--overlay-bg);
    color: var(--overlay-text-strong);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.code-block-wrap:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: var(--overlay-bg-hover);
    color: var(--text-primary);
}

/* ---- Multi-file downloads card (create_files tool) ---- */
.files-card {
    margin: 12px 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    max-width: 420px;
}

.files-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.12s;
}

.files-card-row:hover {
    background: var(--bg-hover, rgba(128,128,128,0.08));
}

.files-card-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.files-card-name {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.files-card-dl {
    flex-shrink: 0;
    padding: 2px 9px;
    font-size: 13px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.files-card-dl:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.files-card-zip {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: var(--accent);
    text-decoration: none;
    transition: background 0.12s;
}

.files-card-zip:hover {
    background: var(--bg-hover, rgba(128,128,128,0.08));
}

.dual-image-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 16px 0;
    align-items: flex-start;
}

.single-image-container {
    display: flex;
    margin: 16px 0;
    align-items: flex-start;
}

.image-model-chooser {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 8px 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 360px;
}

.image-model-chooser p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.image-model-chooser .web-search-toggle {
    align-self: flex-start;
}

.image-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 1 1 300px;
    min-width: 200px;
    max-width: 100%;
}

.image-provider-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid var(--border-color);
}

.image-placeholder {
    min-height: 240px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.image-error-card {
    min-height: 120px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid rgba(227, 59, 69, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.image-error-msg {
    font-size: 0.8rem;
    color: var(--error-color);
    opacity: 0.85;
    text-align: center;
    padding: 0 16px;
}

.image-gen-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--overlay-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: img-spin 0.75s linear infinite;
}

@keyframes img-spin {
    to { transform: rotate(360deg); }
}

.generated-image-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 16px 0;
    gap: 8px;
}

.generated-image {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: transform .2s;
    display: block;
}

.generated-image:hover {
    transform: scale(1.02);
}

.image-container {
    margin: 12px 0;
    text-align: center;
}

.image-prompt {
    font-size: .9em;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.input-container {
    padding: 24px 24px 12px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
}

.input-hint {
    max-width: 1100px;
    margin: 8px auto 0;
    font-size: 11px;
    color: var(--border-color);
    text-align: center;
}

.input-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    transition: box-shadow .15s, border-color .15s;
    border-radius: 10px;
}

.input-wrapper.drag-over {
    box-shadow: 0 0 0 2px var(--accent);
    outline: 2px dashed var(--accent);
    outline-offset: 3px;
}

.file-attachments {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.file-attachment {
    background-color: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.file-attachment img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.remove-attachment {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
}

.remove-attachment:hover {
    color: var(--error-color);
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 15px;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

.message-input:focus {
    outline: none;
    border-color: var(--accent);
}

.input-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background-color .2s;
}

.icon-btn:hover {
    background-color: var(--bg-secondary);
}

.icon-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.attach-btn {
    flex-shrink: 0;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.attach-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background-color: var(--bg-tertiary);
}

.send-btn {
    background-color: var(--accent);
    color: #fff;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.error-message {
    background-color: rgba(239, 68, 68, .1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 24px;
}

.empty-state h1 {
    font-size: 32px;
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 16px;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

@media (max-width: 768px) {
    body.chat-root .sidebar {
        position: fixed !important;
        left: -260px !important;
        top: 0 !important;
        width: 260px;
        height: 100vh;
        z-index: 1000;
        transition: left .3s !important;
    }

    body.chat-root .sidebar.open {
        left: 0 !important;
    }

    .sidebar-handle { display: none; }
    .container { margin-right: 0; }

    .message {
        padding: 16px;
    }

    /* Hide sidebar hamburger — bottom tab bar handles navigation */
    .sidebar-toggle { display: none !important; }

}

/* ---- Mobile bottom tab bar ---- */
.mobile-tab-bar,
.mobile-panel,
.mobile-panel-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        z-index: 900;
    }

    .mobile-tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 11px;
        cursor: pointer;
        padding: 6px 8px;
        transition: color .15s;
    }

    .mobile-tab-btn svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .mobile-tab-btn.active {
        color: var(--accent);
    }

    /* Push input area above tab bar — account for home-indicator safe area */
    .input-container {
        padding-bottom: calc(56px + 8px + env(safe-area-inset-bottom, 0px));
    }

    /* Slide-up panels */
    .mobile-panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 950;
        pointer-events: none;
        transition: background .25s;
    }

    .mobile-panel-backdrop.visible {
        background: rgba(0, 0, 0, 0.55);
        pointer-events: auto;
    }

    .mobile-panel {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        height: 72vh;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        border-radius: 14px 14px 0 0;
        z-index: 960;
        transform: translateY(100%);
        transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    }

    .mobile-panel.open {
        transform: translateY(0);
    }

    .mobile-panel-handle {
        width: 36px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        margin: 10px auto 0;
        flex-shrink: 0;
    }

    .mobile-panel-header {
        display: flex;
        align-items: center;
        padding: 12px 14px 10px;
        gap: 8px;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
        font-size: 15px;
        flex-shrink: 0;
    }

    .mobile-panel-new-chat {
        margin-left: auto;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 6px;
        padding: 5px 10px;
        font-size: 13px;
        cursor: pointer;
    }

    .mobile-panel-close {
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 2px;
        display: flex;
        align-items: center;
    }

    .mobile-panel-close svg {
        width: 18px;
        height: 18px;
    }

    /* No new-chat button in files panel — close sits at end */
    #mobileFilesPanel .mobile-panel-header span {
        flex: 1;
    }

    .mobile-panel-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
    }

    /* Chat list inside mobile panel */
    .mobile-chat-list .conv-group-label {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: .04em;
        padding: 8px 16px 4px;
    }

    .mobile-chat-list .conversation-item {
        display: flex;
        align-items: center;
        padding: 10px 16px;
        cursor: pointer;
        border-radius: 6px;
        margin: 0 8px;
        gap: 8px;
    }

    .mobile-chat-list .conversation-item:active {
        background: var(--bg-tertiary);
    }

    .mobile-chat-list .conv-title {
        flex: 1;
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-chat-list .conv-actions {
        display: flex;
        gap: 4px;
    }

    /* File grid inside mobile panel */
    .mobile-file-list {
        padding: 8px 12px;
    }

    .mobile-file-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .mobile-file-tile {
        aspect-ratio: 1;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        position: relative;
        transition: border-color .15s;
    }

    .mobile-file-tile:active {
        border-color: var(--accent);
    }

    .mobile-file-tile img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-file-tile svg {
        width: 36px;
        height: 36px;
        color: var(--text-secondary);
        stroke: currentColor;
    }

    .mobile-file-tile .mf-name {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,0.6);
        color: #fff;
        font-size: 10px;
        padding: 3px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-file-empty {
        color: var(--text-secondary);
        font-size: 14px;
        text-align: center;
        padding: 32px 16px;
    }
}


.confirm-pop {
    position: absolute;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 2000;
    display: flex;
    gap: 8px;
    align-items: center;
}

.confirm-pop button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.confirm-pop button.cancel {
    background: var(--zgfgray, #75777B);
}

.confirm-pop button:hover {
    filter: brightness(1.1);
}

.restore-btn {
    background: var(--bg-tertiary);
}

body.chat-root, .sidebar, .main-content, .conversation-item, .message, .input-container, .new-chat-btn, .model-selector {
    color: var(--text-primary);
}

.sidebar * {
    color: var(--text-primary);
}

.conversation-item .conv-title {
    color: var(--text-primary);
}

.delete-conv-btn, .restore-btn {
    color: var(--text-secondary);
}

.delete-conv-btn:hover {
    color: var(--zgfred, #E33B45);
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}

.sidebar-footer .zgf-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-block;
}

.sidebar-footer .zgf-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ---- Web search toggle pill (below input) ---- */
.input-toolbar {
    max-width: 1100px;
    margin: 6px auto 0;
    display: flex;
    gap: 6px;
}

.web-search-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.web-search-toggle:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.web-search-toggle.active {
    background: rgba(227, 59, 69, .12);
    border-color: var(--accent);
    color: var(--accent);
}

/* Reasoning-effort pill: a <select> dressed as a toolbar toggle */
.reasoning-toggle select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    outline: none;
}

.reasoning-toggle select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ---- Markdown table rendering ---- */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.table-wrapper table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    background-color: var(--bg-secondary);
}

.table-wrapper table th,
.table-wrapper table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-wrapper table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.table-wrapper table tr:last-child td {
    border-bottom: none;
}

.table-wrapper table tr:hover td {
    background-color: var(--bg-tertiary);
}

/* ---- Tool call in-progress indicator ---- */
.tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0 8px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: opacity .3s;
}

.tool-indicator.done {
    opacity: .5;
    border-left-color: var(--success-color);
}

.tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
    animation: spin .8s linear infinite;
}

/* ── Timestamps & response timer ───────────────────────────── */

.time-separator {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 20px 0 8px;
    user-select: none;
}

/* Centered footer under a response: duration + token usage */
.msg-meta {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: .7;
    user-select: none;
}

.stream-timer {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: .7;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- CSV file attachment chip ---- */
.file-attachment.csv-attachment {
    background: linear-gradient(135deg, var(--csv-tint-start), var(--bg-tertiary));
    border: 1px solid var(--csv-border);
}

.csv-icon {
    font-size: 18px;
    line-height: 1;
}

.attachment-name {
    font-size: 13px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csv-meta {
    font-size: 10px;
    color: var(--success-color);
    background: var(--success-bg);
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.doc-icon {
    font-size: 18px;
    line-height: 1;
}

/* ---- Inline attachment chips in message bubbles ---- */
.csv-chip, .doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    margin: 2px;
}

.csv-chip { border-color: var(--csv-border); color: var(--success-color); }

/* ---- Markdown heading styles inside messages ---- */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 14px 0 6px;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.05em; color: var(--text-secondary); }

/* ---- Unordered lists in messages ---- */
.message-content ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.message-content li {
    margin-bottom: 4px;
    line-height: 1.5;
}

/* ---- Sidebar files section ---- */
.sidebar-files-section {
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-secondary);
    padding: 10px 12px 6px;
}

.sidebar-file-list {
    max-height: 160px;
    overflow-y: auto;
    padding: 4px;
}

.file-list-empty {
    padding: 12px;
    font-size: 11px;
    color: var(--border-color);
    text-align: center;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary);
    transition: background .1s;
}

.file-list-item:hover {
    background: var(--bg-tertiary);
}

.fl-icon {
    font-size: 13px;
    flex-shrink: 0;
    line-height: 1;
}

.fl-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.fl-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 1px 4px;
    font-size: 15px;
    flex-shrink: 0;
    border-radius: 3px;
    line-height: 1;
}

.fl-remove:hover {
    color: var(--error-color);
    background: rgba(227, 59, 69, .12);
}

.fl-persistent {
    opacity: .75;
}

.fl-saved {
    font-size: 10px;
    color: var(--success-color);
    flex-shrink: 0;
    padding: 0 2px;
}

.fl-version {
    font-size: 10px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 2px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--bg-secondary);
}

/* ---- Sidebar controls (show deleted toggle area) ---- */
.sidebar-controls {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.show-deleted-label {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color .15s;
}

.show-deleted-label:has(#showDeletedToggle:checked) {
    color: var(--accent);
}

/* ---- Stored files panel (#7 — was inline styles) ---- */
.stored-files-btn {
    margin-top: 8px;
}

.stored-files-panel {
    margin-top: 8px;
    max-height: 240px;
    overflow-y: auto;
    font-size: 12px;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-tertiary);
}

.uf-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.uf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 6px;
}

.uf-tile {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, opacity 0.15s;
    position: relative;
}

.uf-delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    font-size: 11px;
    font-weight: 700;
    color: #e53e3e;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.uf-tile:hover .uf-delete-btn {
    opacity: 1;
}

.mobile-file-tile .uf-delete-btn {
    opacity: 1;
    width: 20px;
    height: 20px;
    font-size: 13px;
    top: 2px;
    right: 2px;
}

.uf-tile:hover {
    border-color: var(--accent-color, #5b8ef8);
    opacity: 0.85;
}

.uf-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.uf-doc-icon {
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
}

.uf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.uf-view-toggle {
    display: flex;
    gap: 4px;
}

.uf-view-toggle .web-search-toggle {
    padding: 3px 8px;
    font-size: 11px;
}

.uf-sort-toggle {
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
}

.uf-sort-toggle select {
    font-size: 11px;
}

.uf-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.uf-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

.uf-list-item:hover {
    background: var(--bg-secondary);
}

.uf-list-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uf-list-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
    display: block;
}

.uf-list-icon .uf-doc-icon {
    width: 16px;
    height: 16px;
}

.uf-list-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.uf-list-date {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding-right: 20px;
}

.uf-list-item .uf-delete-btn {
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
}

/* ---- Message action bar (copy / download / delete) ---- */
.message-actions {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
    /* Full-width overlay: let clicks pass through the empty middle */
    pointer-events: none;
}

.message:hover .message-actions {
    opacity: 1;
}

.message:hover .message-actions button {
    pointer-events: auto;
}

.msg-actions-left,
.msg-actions-right {
    display: flex;
    gap: 4px;
}

.msg-action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.msg-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.msg-action-delete {
    color: var(--error-color);
    border-color: var(--error-color);
}

.msg-action-delete:hover {
    color: #fff;
    background: var(--error-color);
    border-color: var(--error-color);
}

/* ---- Mobile sidebar toggle button ---- */
.sidebar-toggle {
    display: none; /* shown via media query */
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
}

/* ---- Sidebar overlay (mobile backdrop) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 999;
}

.sidebar-overlay.visible {
    display: block;
}

/* ---- Stop streaming (send button converts to stop) ---- */
.send-btn.stop-mode {
    background-color: var(--accent);
}

.send-btn.stop-mode:hover {
    background-color: var(--accent-hover);
}

.stop-icon {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 2px;
    display: block;
    flex-shrink: 0;
}

/* ---- Upload placeholder chip ---- */
.upload-placeholder {
    --progress: 0%;
    background: linear-gradient(
        to right,
        rgba(227, 59, 69, 0.35) var(--progress),
        var(--bg-tertiary) var(--progress)
    );
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    max-width: 220px;
    overflow: hidden;
    transition: background 0.1s linear;
}

/* ---- Generated images ---- */
.generated-image {
    max-width: 100%;
    max-height: 512px;
    border-radius: 8px;
    margin: 8px 0;
    display: block;
    cursor: pointer;
}

/* right-panel removed; 900px breakpoint no longer needed */

/* ── Camera capture modal ─────────────────────────────────────────────────── */

.camera-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.camera-modal-inner {
    background: var(--bg-primary);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: min(96vw, 640px);
    max-height: 90vh;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.camera-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.camera-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.camera-header-actions {
    display: flex;
    gap: 8px;
}

.camera-flip-btn,
.camera-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.camera-flip-btn svg,
.camera-close-btn svg {
    width: 18px;
    height: 18px;
}

.camera-flip-btn:hover,
.camera-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.camera-preview-wrap {
    position: relative;
    flex: 1;
    background: #000;
    min-height: 0;
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-height: 60vh;
}

.camera-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-primary);
}

.camera-capture-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.camera-capture-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 0 0 5px rgba(255,255,255,0.2);
}

.camera-capture-btn:active {
    transform: scale(0.94);
}

.camera-capture-ring {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ccc;
}

/* ---- Lightbox image viewer ---- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 10001; /* above top-menu (9999) and menu-dropdown-panel (10000) */
    display: flex;
    flex-direction: column;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
}

.lightbox-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    gap: 8px;
    flex-shrink: 0;
}

.lightbox-filename {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

.lightbox-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.lightbox-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
    padding: 0;
}

.lightbox-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.lightbox-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.35);
}

.lightbox-close-btn {
    margin-left: 4px;
}

.lightbox-close-btn:hover {
    background: rgba(227, 59, 69, 0.4);
    border-color: var(--accent);
}

.lightbox-stage {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}

.lightbox-stage.dragging {
    cursor: grabbing;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    transform-origin: center center;
    transition: transform .15s ease;
    pointer-events: none;
}

.lightbox-img.no-transition {
    transition: none;
}

/* Make images in chat look clickable */
.generated-image,
.attachment-preview img {
    cursor: zoom-in;
}

@media (max-width: 768px) {
    .lightbox-btn { width: 40px; height: 40px; }
    .lightbox-btn svg { width: 18px; height: 18px; }
}

/* --- Reasoning accordion --- */
.reasoning-accordion {
    margin: 6px 0 10px;
    border: 1px solid var(--overlay-border);
    border-radius: 8px;
    background: var(--overlay-bg);
    overflow: hidden;
}

.reasoning-accordion summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--overlay-text);
    letter-spacing: 0.02em;
    user-select: none;
    list-style: none;
}

.reasoning-accordion summary::-webkit-details-marker { display: none; }

.reasoning-accordion summary::before {
    content: '›';
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.2s ease;
    display: inline-block;
    color: var(--overlay-text-faint);
}

.reasoning-accordion[open] summary::before {
    transform: rotate(90deg);
}

.reasoning-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--overlay-border);
    border-top-color: var(--accent, #7c6af7);
    border-radius: 50%;
    animation: reasoning-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes reasoning-spin {
    to { transform: rotate(360deg); }
}

.reasoning-accordion.done .reasoning-spinner { display: none; }

.reasoning-accordion.done summary::before {
    content: '›';
}

.reasoning-body {
    padding: 0 12px 10px;
    border-top: 1px solid var(--overlay-border);
}

.reasoning-text {
    margin: 8px 0 0;
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--overlay-text-faint);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    max-height: 320px;
    overflow-y: auto;
}

/* --- Routing indicator --- */
.routing-indicator {
    font-size: 0.75rem;
    color: var(--overlay-text-faint);
    font-style: italic;
    letter-spacing: 0.02em;
    padding: 2px 0 6px;
}
