        /* --- 参数预设标签行 --- */
        .preset-tags-area { padding: 0 20px; display: flex; justify-content: center; }
        [data-mode="gen"] .preset-tags-area { display: none !important; }
        [data-mode="gen"] .upload-icon { visibility: hidden !important; }
        .preset-tags-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px 0; max-width: var(--chat-max-width); width: 100%; cursor: grab; user-select: none; scrollbar-width: none; }
        .preset-tags-row::-webkit-scrollbar { display: none; }
        .preset-tags-row.dragging { cursor: grabbing; scroll-behavior: auto; }
        .preset-tag { display: inline-flex; align-items: center; gap: 4px; padding: 5px 14px; border-radius: 20px; font-size: 13px; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-muted); white-space: nowrap; transition: all 0.15s; user-select: none; flex-shrink: 0; }
        .preset-tag:hover { border-color: var(--text-muted); color: var(--text-main); }
        .preset-tag.active { background: var(--text-main); color: var(--text-on-dark); border-color: var(--text-main); }
        .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); }
        .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; }
        .collapse-wrapper.collapsed { max-height: 180px; overflow: hidden; }
        .collapse-wrapper.collapsed::after {
            content: '';
            position: absolute;
            bottom: 0; left: 0; right: 0;
            height: 48px;
            background: linear-gradient(transparent, var(--gradient-fade-to));
            pointer-events: none;
        }
        .collapse-toggle {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 12px;
            color: var(--text-muted);
            cursor: pointer;
            border: 1px solid var(--border-color);
            border-radius: 14px;
            padding: 3px 12px;
            background: var(--bg-surface);
            transition: all 0.15s;
            margin-top: 4px;
            user-select: none;
        }
        .collapse-toggle:hover { border-color: var(--text-main); color: var(--text-main); }
