        /* --- 参数预设列表 --- */
        [data-mode="gen"] .top-preset-panel,
        [data-mode="fav"] .top-preset-panel { display: none !important; }
        [data-mode="gen"] .upload-icon { visibility: hidden !important; }
        .top-preset-panel {
            position: relative;
            display: inline-flex;
            align-items: center;
            margin-left: 12px;
        }
        .top-preset-trigger {
            min-height: 32px;
            max-width: 190px;
            padding: 6px 12px;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            background: var(--bg-surface);
            color: var(--text-muted);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            transition: all 0.2s;
        }
        .top-preset-trigger span {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .top-preset-trigger:hover,
        .top-preset-panel.open .top-preset-trigger {
            color: var(--text-main);
            border-color: var(--text-muted);
            background: var(--bg-hover);
        }
        .top-preset-popover {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            width: 236px;
            display: none;
            flex-direction: column;
            gap: 8px;
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 16px;
            background: var(--bg-surface);
            box-shadow: 0 16px 42px rgba(0,0,0,0.14);
            z-index: 60;
        }
        .top-preset-panel.open .top-preset-popover {
            display: flex;
        }
        .sidebar-presets-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 4px;
            color: var(--text-muted);
            font-size: 12px;
            font-weight: 600;
        }
        .sidebar-preset-add {
            width: 26px;
            height: 26px;
            border: none;
            border-radius: 8px;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .sidebar-preset-add:hover {
            background: var(--bg-hover);
            color: var(--text-main);
        }
        .preset-tags-row {
            display: flex;
            flex-direction: column;
            gap: 3px;
            max-height: 240px;
            overflow-y: auto;
            overflow-x: visible;
            padding: 0;
            user-select: none;
            scrollbar-width: none !important;
        }
        .preset-tags-row::-webkit-scrollbar { display: none; }
        .preset-list-item {
            position: relative;
            display: flex;
            align-items: center;
            gap: 4px;
            border-radius: 10px;
            color: var(--text-muted);
        }
        .preset-list-item:hover,
        .preset-list-item.active {
            background: var(--bg-active-chat);
            color: var(--text-main);
        }
        .preset-main-btn {
            min-width: 0;
            flex: 1;
            border: none;
            background: transparent;
            color: inherit;
            cursor: pointer;
            padding: 8px 8px;
            text-align: left;
            font-size: 13px;
        }
        .preset-main-btn span {
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .preset-action-btn {
            width: 28px;
            height: 28px;
            margin-right: 4px;
            border: none;
            border-radius: 8px;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
        }
        .preset-list-item:hover .preset-action-btn,
        .preset-action-btn:focus {
            opacity: 1;
            pointer-events: auto;
        }
        .preset-action-btn:hover {
            background: var(--bg-hover);
            color: var(--text-main);
        }
        .preset-action-menu {
            position: absolute;
            top: 30px;
            right: 0;
            display: none;
            min-width: 126px;
            padding: 7px;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            background: var(--bg-surface);
            box-shadow: 0 14px 36px rgba(0,0,0,0.14);
            z-index: 45;
        }
        .preset-action-menu.show {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .preset-action-menu button {
            border: none;
            background: transparent;
            color: var(--text-main);
            cursor: pointer;
            border-radius: 8px;
            padding: 8px;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            text-align: left;
            white-space: nowrap;
        }
        .preset-action-menu button:hover {
            background: var(--bg-active-chat);
        }
        .preset-action-menu button.danger {
            color: #c84646;
        }
        .preset-edit-row { display: flex; align-items: center; gap: 10px; }
        .preset-edit-row label { min-width: 80px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
        .preset-edit-row input, .preset-edit-row textarea, .preset-edit-row select { flex: 1; padding: 7px 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 13px; outline: none; background: var(--bg-surface); color: var(--text-main); }
        .preset-edit-row input:focus, .preset-edit-row textarea:focus { border-color: var(--black-btn); }
        .preset-edit-row textarea { min-height: 60px; resize: vertical; scrollbar-color: var(--text-main) var(--border-color); scrollbar-width: thin; }
        .preset-edit-row textarea::-webkit-scrollbar { width: 6px; }
        .preset-edit-row textarea::-webkit-scrollbar-track { background: var(--border-color); border-radius: 3px; }
        .preset-edit-row textarea::-webkit-scrollbar-thumb { background: var(--text-main); border-radius: 3px; }

        /* 滑动条参数区 */
        .preset-slider-group { margin: 1px 0; display: flex; align-items: center; gap: 6px; }
        .preset-slider-group .slider-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; min-width: 64px; }
        .preset-slider-group .slider-val { font-size: 10px; font-weight: 500; color: var(--text-muted); background: transparent; padding: 0; border-radius: 0; min-width: 28px; text-align: right; }
        .preset-slider { flex: 1; -webkit-appearance: none; appearance: none; height: 2px; border-radius: 1px; background: var(--border-color); outline: none; transition: background 0.15s; accent-color: var(--text-main); }
        .preset-slider:hover { background: var(--text-muted); }
        .preset-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text-main); cursor: pointer; border: none; box-shadow: 0 0 0 2px rgba(128,128,128,0.15); transition: transform 0.15s, box-shadow 0.15s; }
        .preset-slider::-webkit-slider-thumb:hover { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(128,128,128,0.15); }
        .preset-slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text-main); cursor: pointer; border: none; box-shadow: 0 0 0 2px rgba(128,128,128,0.15); }
        .preset-slider::-moz-range-track { height: 2px; border-radius: 1px; background: var(--border-color); }
        .preset-slider::-moz-range-progress { height: 2px; border-radius: 1px; background: var(--text-main); }
        .preset-stream-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
        .preset-stream-row .stream-label { font-size: 13px; font-weight: 500; color: var(--text-main); }
        .preset-stream-opt { font-size: 12px; padding: 5px 16px; border-radius: 16px; border: 1px solid var(--border-color); cursor: pointer; background: var(--bg-surface); color: var(--text-muted); transition: all 0.15s; }
        .preset-stream-opt.active { background: var(--text-main); color: var(--text-on-dark); border-color: var(--text-main); }

        /* 图片预览：在输入框内部显示 */
        .image-preview-area { padding: 0 0 6px 0; width: 100%; }
        .image-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
        .image-preview-item { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: visible; border: 1px solid var(--border-color); flex-shrink: 0; }
        .image-preview-item img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; }
        .image-preview-item .img-remove-btn { position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: var(--black-btn); color: var(--text-on-dark); border: 2px solid var(--bg-gray); display: none; align-items: center; justify-content: center; cursor: pointer; font-size: 10px; line-height: 1; z-index: 2; }
        .image-preview-item:hover .img-remove-btn { display: flex; }
        .user-image { max-width: 200px; max-height: 200px; border-radius: 12px; display: block; margin-top: 6px; cursor: pointer; }

        /* Markdown 渲染（正文与思考过程共用） */
        .message-content, .thought-content { word-wrap: break-word; overflow-wrap: break-word; }
        .message-content p, .thought-content p { margin: 6px 0; line-height: 1.7; }
        .message-content h1, .thought-content h1 { font-size: 1.5em; font-weight: 700; margin: 16px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border-color); }
        .message-content h2, .thought-content h2 { font-size: 1.35em; font-weight: 700; margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border-light); }
        .message-content h3, .thought-content h3 { font-size: 1.2em; font-weight: 600; margin: 12px 0 4px; }
        .message-content h4, .thought-content h4 { font-size: 1.1em; font-weight: 600; margin: 10px 0 4px; }
        .message-content h5, .thought-content h5 { font-size: 1em; font-weight: 600; margin: 8px 0 2px; }
        .message-content h6, .thought-content h6 { font-size: 0.9em; font-weight: 600; margin: 8px 0 2px; color: var(--text-muted); }
        .message-content pre, .thought-content pre { background: var(--bg-gray); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 10px 0; border: 1px solid var(--border-light); }
        .message-content code, .thought-content code { font-family: "SF Mono", "Fira Code", "Fira Mono", monospace; font-size: 13px; }
        .message-content :not(pre) > code, .thought-content :not(pre) > code { background: var(--bg-gray); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; font-weight: 500; }
        .message-content pre code, .thought-content pre code { background: none; padding: 0; font-weight: 400; }
        /* 代码块包装器：语言标记 + 复制按钮 */
        .code-block-wrapper,
        .mermaid-wrapper { width: 100%; max-width: 100%; margin: 10px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-light); background: var(--bg-gray); box-sizing: border-box; }
        .mermaid-wrapper { display: flex; flex-direction: column; }
        .code-block-header,
        .mermaid-toolbar { display: flex; align-items: center; min-height: 34px; padding: 6px 14px; background: var(--bg-hover); border-bottom: 1px solid var(--border-color); font-size: 12px; gap: 8px; user-select: none; box-sizing: border-box; }
        .code-lang { color: var(--text-muted); font-family: "SF Mono", "Fira Code", monospace; text-transform: lowercase; margin-right: auto; }
        .code-block-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
        .code-copy-btn,
        .code-run-btn,
        .mermaid-tool-btn,
        .mermaid-tool-copy { color: var(--text-muted); cursor: pointer; padding: 3px 8px; border-radius: 4px; transition: color 0.15s, background 0.15s; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; line-height: 1; white-space: nowrap; }
        .code-copy-btn:hover,
        .code-run-btn:hover,
        .mermaid-tool-btn:hover,
        .mermaid-tool-copy:hover { color: var(--text-main); background: var(--bg-hover); }
        .code-copy-btn.disabled,
        .code-run-btn.disabled { opacity: 0.45; cursor: default; pointer-events: none; }
        .code-copy-btn.copied { color: #2da44e; }
        .code-copy-btn svg, .code-copy-btn svg *,
        .code-run-btn svg, .code-run-btn svg *,
        .mermaid-tool-btn svg, .mermaid-tool-btn svg *,
        .mermaid-tool-copy svg, .mermaid-tool-copy svg *,
        #chatContainer .code-copy-btn svg, #chatContainer .code-copy-btn svg *,
        #chatContainer .code-run-btn svg, #chatContainer .code-run-btn svg *,
        #chatContainer .mermaid-tool-btn svg, #chatContainer .mermaid-tool-btn svg *,
        #chatContainer .mermaid-tool-copy svg, #chatContainer .mermaid-tool-copy svg * {
            fill: none !important;
            stroke: currentColor !important;
        }
        .code-block-wrapper > pre { margin: 0; border: none; border-radius: 0; }
        .message-content blockquote, .thought-content blockquote { border-left: 3px solid var(--border-color); padding: 4px 12px; margin: 8px 0; color: var(--text-muted); background: var(--bg-hover); border-radius: 0 6px 6px 0; }
        .message-content blockquote p, .thought-content blockquote p { margin: 4px 0; }
        .message-content table, .thought-content table { border-collapse: collapse; margin: 10px 0; border: 1px solid var(--border-color); width: 100%; }
        .message-content th, .thought-content th { border: 1px solid var(--border-color); padding: 8px 12px; font-size: 13px; font-weight: 600; background: var(--bg-gray); text-align: left; }
        .message-content td, .thought-content td { border: 1px solid var(--border-color); padding: 8px 12px; font-size: 13px; }
        .message-content tbody tr:nth-child(even), .thought-content tbody tr:nth-child(even) { background: var(--bg-hover); }
        [data-table-style="compact"] .message-content table,
        [data-table-style="compact"] .thought-content table { border-collapse: collapse; border: none; font-size: 12px; }
        [data-table-style="compact"] .message-content th,
        [data-table-style="compact"] .thought-content th,
        [data-table-style="compact"] .message-content td,
        [data-table-style="compact"] .thought-content td { padding: 5px 8px; border-left: none; border-right: none; }
        [data-table-style="ledger"] .message-content table,
        [data-table-style="ledger"] .thought-content table { border-collapse: separate; border-spacing: 0; overflow: hidden; border-radius: 10px; }
        [data-table-style="ledger"] .message-content th,
        [data-table-style="ledger"] .thought-content th { background: var(--text-main); color: var(--text-on-dark); border-color: var(--text-main); }
        [data-table-style="ledger"] .message-content tbody tr:nth-child(odd),
        [data-table-style="ledger"] .thought-content tbody tr:nth-child(odd) { background: var(--bg-surface); }
        [data-table-style="ledger"] .message-content tbody tr:nth-child(even),
        [data-table-style="ledger"] .thought-content tbody tr:nth-child(even) { background: var(--bg-gray); }
        [data-table-style="card"] .message-content table,
        [data-table-style="card"] .thought-content table { border-collapse: separate; border-spacing: 0 8px; border: none; }
        [data-table-style="card"] .message-content th,
        [data-table-style="card"] .thought-content th { border: none; background: transparent; color: var(--text-muted); padding: 4px 12px; font-size: 12px; }
        [data-table-style="card"] .message-content td,
        [data-table-style="card"] .thought-content td { border: none; background: var(--bg-gray); padding: 10px 12px; }
        [data-table-style="card"] .message-content td:first-child,
        [data-table-style="card"] .thought-content td:first-child { border-radius: 10px 0 0 10px; }
        [data-table-style="card"] .message-content td:last-child,
        [data-table-style="card"] .thought-content td:last-child { border-radius: 0 10px 10px 0; }
        [data-table-style="minimal"] .message-content table,
        [data-table-style="minimal"] .thought-content table { border: none; border-collapse: collapse; }
        [data-table-style="minimal"] .message-content th,
        [data-table-style="minimal"] .thought-content th { border: none; border-bottom: 2px solid var(--text-main); background: transparent; padding: 8px 4px; }
        [data-table-style="minimal"] .message-content td,
        [data-table-style="minimal"] .thought-content td { border: none; border-bottom: 1px solid var(--border-color); padding: 8px 4px; }
        [data-table-style="minimal"] .message-content tbody tr:nth-child(even),
        [data-table-style="minimal"] .thought-content tbody tr:nth-child(even) { background: transparent; }
        .message-content ul, .thought-content ul { padding-left: 22px; margin: 6px 0; list-style: disc; }
        .message-content ol, .thought-content ol { padding-left: 22px; margin: 6px 0; }
        .message-content li, .thought-content li { margin: 3px 0; line-height: 1.7; }
        .message-content a, .thought-content a { color: var(--text-main); text-decoration: underline; text-decoration-color: var(--text-muted); text-underline-offset: 2px; transition: text-decoration-color 0.15s; }
        .message-content a:hover, .thought-content a:hover { text-decoration-color: var(--text-main); }
        .message-content hr, .thought-content hr { border: none; height: 1px; background: var(--border-color); margin: 16px 0; }
        .message-content img, .thought-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
        .message-content strong, .thought-content strong { font-weight: 700; color: var(--text-main); }
        .mermaid-tool-btn.active { color: var(--text-main); background: var(--bg-active-chat); font-weight: 500; }
        .mermaid-tool-copy { margin-left: auto; }
        .mermaid-preview { width: 100%; max-width: 100%; min-width: 0; padding: 12px 14px; box-sizing: border-box; overflow: auto; display: block; background: var(--bg-gray); }
        div.mermaid { display: block; width: 100%; }
        div.mermaid svg { margin: 0 auto; display: block; max-width: 100%; }
        .mermaid-wrapper.is-gantt .mermaid-preview {
            padding: 16px 18px;
            overflow: hidden;
        }
        .mermaid-wrapper.is-gantt div.mermaid svg {
            width: 100% !important;
            max-width: 100% !important;
            height: auto !important;
            margin: 0 auto !important;
        }
        .mermaid-wrapper.is-gantt div.mermaid svg .titleText { font-size: 18px !important; }
        .mermaid-wrapper.is-gantt div.mermaid svg .sectionTitle,
        .mermaid-wrapper.is-gantt div.mermaid svg .section-title,
        .mermaid-wrapper.is-gantt div.mermaid svg .taskText,
        .mermaid-wrapper.is-gantt div.mermaid svg .taskTextOutsideRight,
        .mermaid-wrapper.is-gantt div.mermaid svg .taskTextOutsideLeft { font-size: 12px !important; }
        .mermaid-wrapper.is-gantt div.mermaid svg g.tick text {
            font-size: 10px !important;
        }
        .mermaid-code { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
        .mermaid-code pre { margin: 0; border: none; border-radius: 0; background: var(--bg-gray); }
        .mermaid-source-text { display: block; padding: 12px 14px; font-size: 13px; line-height: 1.55; overflow-x: auto; }
        .math-render { max-width: 100%; }
        .math-render-inline { display: inline; }
        .math-render-block { display: block; margin: 12px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
        .message-content .katex-display, .thought-content .katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
        .message-content .katex, .thought-content .katex { font-size: 1.05em; }

        /* --- 消息折叠 --- */
        .collapse-wrapper { position: relative; display: flex; flex-direction: column; align-items: flex-start; }
        .message.user .collapse-wrapper {
            background-color: var(--bg-gray);
            padding: 12px 20px;
            border-radius: 20px;
        }
        .message.user .collapse-wrapper .message-content {
            background: transparent;
            padding: 0;
            border-radius: 0;
        }
        .collapse-content { width: 100%; }
        .collapse-wrapper.collapsed .collapse-content { max-height: 180px; overflow: hidden; }
        .collapse-toggle {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 12px;
            color: var(--text-main);
            cursor: pointer;
            border: none;
            border-radius: 8px;
            padding: 4px 0;
            background: transparent;
            transition: color 0.15s;
            margin-top: 8px;
            user-select: none;
            width: fit-content;
        }
        .collapse-toggle:hover { color: var(--text-muted); }
