        :root {
            --primary: #FF6B00; --primary-dark: #E55A00; --bg-dark: #1E272E; --bg-panel: #2C3A47; --text-primary: #DFE6E9; --text-secondary: #B2BEC3; --white: #FFFFFF;
            /* 主列可视高度；iPhone 上由 setupIosViewportHeightFix() 写入像素值，勿在无关规则里覆盖 */
            --app-vh: 100dvh;
            /* 软键盘占用高度，与 .input-area { bottom: var(--ios-kb-offset) } 配套，仅 JS 写入 */
            --ios-kb-offset: 0px;
            /* 页面字号总缩放（1 = 100%，0.9 = 小 10%） */
            --page-font-scale: 0.92;
            /* 更圆润、简洁的系统字体栈（苹果风格优先，Windows 自动回退） */
            --font-ui: "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Segoe UI", "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
            --font-reply: var(--font-ui);
            --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", "Consolas", "Courier New", monospace;
            /* 助手回复字号阶梯（与左侧 param-input 12px / param-title 13px 对齐，避免主区明显偏大） */
            --reply-font-body: calc(13px * var(--page-font-scale));
            --reply-line-body: 1.68;
            --reply-font-h3: calc(14px * var(--page-font-scale));
            --reply-line-h3: 1.42;
            --reply-font-h4: calc(13px * var(--page-font-scale));
            --reply-line-h4: 1.48;
            --reply-font-table: calc(12px * var(--page-font-scale));
            --reply-line-table: 1.62;
            --reply-font-code: calc(13px * var(--page-font-scale));
            --reply-line-code: 1.56;
            --reply-font-cite-summary: calc(12px * var(--page-font-scale));
            --reply-font-cite-body: calc(12px * var(--page-font-scale));
            --reply-line-cite-body: 1.5;
            --reply-font-time: calc(10px * var(--page-font-scale));
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        html {
            -webkit-text-size-adjust: 100%;
            text-size-adjust: 100%;
        }
        body {
            font-family: var(--font-ui);
            letter-spacing: 0.01em;
            -webkit-font-smoothing: antialiased;
            text-rendering: optimizeLegibility;
            background: var(--bg-dark);
            color: var(--text-primary);
            min-height: 100vh;
        }
        .app-container { display: flex; max-width: 1400px; margin: 0 auto; min-height: 100vh; background: var(--bg-panel); }

        /* ========== 窄屏（≤1100px）布局：栅格主区 / 安全区 / 输入最小字号 ==========
           若改 .main-content 高度，须同步检查下文「窄屏覆盖」块（倚赖 --app-vh），避免只改一处导致 iOS 聊天区高度错乱。 */
        @media (max-width: 1100px) {
            body {
                min-height: 100vh;
                min-height: 100dvh;
            }
            .app-container {
                flex-direction: column;
                min-height: 100vh;
                min-height: 100dvh;
            }
            /* iPhone 上用三行网格固定主区：头部 / 消息区 / 输入区，避免消息区被压扁为 0 高 */
            .main-content {
                order: -1;
                display: grid;
                grid-template-rows: auto minmax(220px, 1fr) auto;
                min-height: 100vh;
                min-height: 100dvh;
                height: 100vh;
                height: 100dvh;
                max-height: none;
            }
            /* 刘海屏：顶栏与内容区避开安全区（需 viewport-fit=cover） */
            .header {
                padding-top: calc(12px + env(safe-area-inset-top, 0px));
                padding-right: calc(20px + env(safe-area-inset-right, 0px));
                padding-bottom: 12px;
                padding-left: calc(20px + env(safe-area-inset-left, 0px));
            }
            .chat-container {
                min-height: 220px;
                padding-left: calc(16px + env(safe-area-inset-left, 0px));
                padding-right: calc(16px + env(safe-area-inset-right, 0px));
            }
            .input-area {
                padding-left: calc(14px + env(safe-area-inset-left, 0px));
                padding-right: calc(14px + env(safe-area-inset-right, 0px));
            }
            /* iOS：输入类字号小于 16px 时聚焦会强制缩放整页 */
            .param-input,
            .param-select,
            .param-textarea {
                font-size: max(16px, calc(12px * var(--page-font-scale)));
            }
            #userInput {
                font-size: max(16px, calc(15px * var(--page-font-scale)));
            }
            .form-input {
                font-size: max(16px, calc(14px * var(--page-font-scale)));
            }
            /* 移动端去掉对话头像，加宽气泡（欢迎页 Kiwi 大图保留） */
            .message .message-avatar { display: none !important; }
            .typing .message-avatar { display: none !important; }
            .message .message-content,
            .message.agent .message-content { max-width: 100%; }
        }
        .history-sidebar {
            width: 260px;
            background: linear-gradient(180deg, #25313b 0%, #18222b 100%);
            border-right: 1px solid rgba(255, 107, 0, 0.22);
            padding: 14px 10px;
            overflow: hidden;
            height: 100vh;
            position: sticky;
            top: 0;
            align-self: flex-start;
            display: flex;
            flex-direction: column;
            color: var(--text-primary);
            box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
        }
        .history-sidebar-scroll {
            flex: 1;
            min-height: 0;
            overflow-x: hidden;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
            padding-right: 2px;
        }
        .history-sidebar-scroll::-webkit-scrollbar {
            width: 5px;
        }
        .history-sidebar-scroll::-webkit-scrollbar-track {
            background: transparent;
            margin: 4px 0;
        }
        .history-sidebar-scroll::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.18);
            border-radius: 999px;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
        }
        .history-sidebar-scroll::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 107, 0, 0.42);
        }
        .history-sidebar-brand {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 4px 4px 12px;
        }
        .history-sidebar-logo {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
            color: var(--text-primary);
            font-weight: 800;
            font-size: calc(15px * var(--page-font-scale));
        }
        .history-sidebar-logo img {
            width: 24px;
            height: 24px;
            border-radius: 7px;
            object-fit: cover;
            flex-shrink: 0;
        }
        .sidebar-account-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin: 0 0 12px;
            padding: 12px;
            border-radius: 14px;
            background: rgba(0, 0, 0, 0.18);
            border: 1px solid rgba(255, 255, 255, 0.07);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
        }
        .sidebar-account-main {
            min-width: 0;
            flex: 1;
            display: flex;
            align-items: center;
            gap: 10px;
            border: none;
            background: transparent;
            color: inherit;
            font-family: inherit;
            text-align: left;
            cursor: pointer;
            padding: 0;
        }
        .sidebar-account-avatar {
            width: 38px;
            height: 38px;
            border-radius: 12px;
            object-fit: cover;
            flex-shrink: 0;
            border: 1px solid rgba(255, 255, 255, 0.12);
        }
        .sidebar-account-copy {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 3px;
        }
        .sidebar-account-name {
            color: var(--text-primary);
            font-size: calc(14px * var(--page-font-scale));
            font-weight: 750;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .sidebar-account-status {
            color: var(--text-secondary);
            font-size: calc(11px * var(--page-font-scale));
        }
        .sidebar-account-settings {
            position: relative;
            width: 32px;
            height: 32px;
            flex: 0 0 32px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 10px;
            border: 1px solid transparent;
            background: transparent;
            color: rgba(255, 255, 255, 0.5);
            cursor: pointer;
            padding: 0;
        }
        .sidebar-account-settings:hover,
        .sidebar-account-settings:focus {
            color: rgba(255, 255, 255, 0.78);
            border-color: rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.04);
            outline: none;
        }
        .sidebar-account-settings svg {
            width: 17px;
            height: 17px;
            fill: currentColor;
        }
        .sidebar-update-dot {
            display: none;
            position: absolute;
            right: 5px;
            top: 5px;
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: #ff6b00;
            box-shadow: 0 0 0 2px #1d2832;
        }
        .sidebar-update-dot.show { display: block; }
        .history-sidebar-toggle {
            display: none;
            width: 32px;
            height: 32px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 9px;
            background: rgba(0, 0, 0, 0.18);
            color: var(--text-primary);
            cursor: pointer;
        }
        .history-sidebar-params {
            flex-shrink: 0;
            overflow: visible;
            padding: 2px 2px 12px 0;
            margin: 0 -2px 10px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        .history-sidebar-params-grid {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
            gap: 10px 20px;
            align-items: start;
            padding: 11px 10px 12px;
            border-radius: 12px;
            background: rgba(0, 0, 0, 0.16);
            border: 1px solid rgba(255, 255, 255, 0.06);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
        }
        .sidebar-param-block {
            margin-bottom: 0;
            text-align: left;
            min-width: 0;
        }
        .sidebar-param-block--full {
            grid-column: 1 / -1;
        }
        .history-sidebar-params-grid .param-select,
        .history-sidebar-params-grid .param-input {
            padding-top: 5px;
            padding-bottom: 5px;
        }
        .sidebar-param-label {
            display: block;
            margin-bottom: 5px;
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 650;
            color: var(--text-secondary);
            letter-spacing: 0.02em;
            line-height: 1.35;
        }
        .sidebar-param-name { display: inline; font-weight: inherit; color: inherit; }
        .sidebar-param-code {
            display: inline;
            font-size: inherit;
            font-weight: inherit;
            color: inherit;
            letter-spacing: 0.02em;
            margin-left: 0;
        }
        .sidebar-param-field { width: 100%; }
        .android-webview-select-fix .sidebar-native-select-hidden {
            display: none !important;
        }
        .android-webview-select-fix .sidebar-custom-select-trigger {
            width: 100%;
            min-height: 32px;
            padding: 5px 28px 5px 8px;
            border: 1px solid #444;
            border-radius: 4px;
            background: #1E272E;
            color: var(--text-primary);
            text-align: left;
            font-family: inherit;
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.35;
            position: relative;
            cursor: pointer;
        }
        .android-webview-select-fix .sidebar-custom-select-trigger:focus {
            outline: none;
            border-color: var(--primary);
        }
        .android-webview-select-fix .sidebar-custom-select-trigger::after {
            content: "";
            position: absolute;
            right: 10px;
            top: 50%;
            margin-top: -2px;
            width: 0;
            height: 0;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-top: 5px solid rgba(255, 255, 255, 0.7);
            pointer-events: none;
        }
        .android-webview-select-fix .sidebar-custom-select-panel {
            position: fixed;
            z-index: 900;
            display: none;
            overflow-y: auto;
            overflow-x: hidden;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: linear-gradient(180deg, #2c3946 0%, #1b2430 100%);
            box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
            padding: 6px 0;
            -webkit-overflow-scrolling: touch;
        }
        .android-webview-select-fix .sidebar-custom-select-panel.is-open {
            display: block;
        }
        .android-webview-select-fix .sidebar-custom-select-option {
            width: 100%;
            display: block;
            border: none;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            background: transparent;
            color: var(--text-primary);
            text-align: left;
            font-family: inherit;
            font-size: calc(13px * var(--page-font-scale));
            line-height: 1.4;
            padding: 9px 12px;
            cursor: pointer;
        }
        .android-webview-select-fix .sidebar-custom-select-option:last-child {
            border-bottom: none;
        }
        .android-webview-select-fix .sidebar-custom-select-option:focus,
        .android-webview-select-fix .sidebar-custom-select-option:hover {
            outline: none;
            background: rgba(255, 107, 0, 0.15);
        }
        .android-webview-select-fix .sidebar-custom-select-option.is-selected {
            background: rgba(255, 107, 0, 0.12);
            color: #ffd1ad;
        }
        .sidebar-param-value-unit {
            display: flex;
            align-items: center;
            gap: 4px;
        }
        .sidebar-param-value-unit .sidebar-param-field { flex: 1; min-width: 0; }
        .sidebar-param-unit {
            flex-shrink: 0;
            min-width: 0;
            text-align: left;
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 600;
            color: rgba(255, 255, 255, 0.58);
        }
        .history-sidebar-params .app-other-wrap { margin-top: 6px; }
        .history-sidebar-history-section {
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            padding-bottom: 4px;
        }
        .history-sidebar-section-label {
            flex-shrink: 0;
            margin-bottom: 6px;
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 700;
            letter-spacing: 0.06em;
            color: rgba(255, 255, 255, 0.62);
            text-align: left;
        }
        .history-sidebar-history-section .history-sidebar-actions {
            flex-shrink: 0;
            padding: 0 0 8px;
        }
        .history-sidebar-history-section .history-list {
            flex: none;
            min-height: 0;
            overflow: visible;
        }
        .history-sidebar-new {
            width: 100%;
            min-height: 30px;
            padding: 5px 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.05);
            color: rgba(255, 255, 255, 0.88);
            font-family: inherit;
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 600;
            cursor: pointer;
            box-shadow: none;
        }
        .history-sidebar-new:hover {
            background: rgba(255, 255, 255, 0.09);
            border-color: rgba(255, 107, 0, 0.38);
            color: var(--text-primary);
        }
        .history-sidebar .history-list {
            overflow: visible;
            padding: 6px 0 10px;
        }
        .history-sidebar .history-empty { color: var(--text-secondary); }
        .history-sidebar .history-item {
            padding: 7px 9px;
            margin-bottom: 6px;
            border-radius: 8px;
            border-color: rgba(255, 255, 255, 0.09);
            background: rgba(0, 0, 0, 0.18);
            box-shadow: none;
            gap: 6px;
        }
        .history-sidebar .history-item.is-active {
            border-color: rgba(255, 107, 0, 0.32);
            background: rgba(255, 107, 0, 0.07);
        }
        .history-sidebar .history-title {
            color: var(--text-primary);
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 650;
        }
        .history-sidebar .history-sub {
            color: var(--text-secondary);
            font-size: calc(11px * var(--page-font-scale));
        }
        .history-sidebar .history-delete {
            width: 26px;
            height: 26px;
            border-radius: 6px;
            border-color: rgba(255, 255, 255, 0.08);
            background: rgba(0, 0, 0, 0.14);
            color: rgba(255, 255, 255, 0.45);
            font-size: 15px;
            line-height: 1;
            padding: 0;
        }
        .history-sidebar .history-delete:hover {
            color: rgba(254, 202, 202, 0.95);
            border-color: rgba(248, 113, 113, 0.35);
            background: rgba(0, 0, 0, 0.22);
        }
        .quick-diagnostic-panel { display: none; }
        .header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
        .history-sidebar-open-btn,
        .history-sidebar-backdrop { display: none; }
        @media (max-width: 1100px) {
            .history-sidebar {
                width: min(88vw, 420px);
                height: var(--app-vh, 100dvh);
                max-height: var(--app-vh, 100dvh);
                position: fixed;
                left: 0;
                top: 0;
                z-index: 120;
                transform: translateX(-105%);
                transition: transform 0.24s ease;
                border-right: 1px solid rgba(255, 107, 0, 0.22);
                border-bottom: none;
                border-top: none;
                box-shadow: 12px 0 36px rgba(0, 0, 0, 0.42);
                padding-left: calc(12px + env(safe-area-inset-left, 0px));
                padding-right: 12px;
                padding-top: calc(12px + env(safe-area-inset-top, 0px));
                padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
            }
            .history-sidebar.is-open { transform: translateX(0); }
            .history-sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
            .history-sidebar-open-btn {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                width: 34px;
                height: 34px;
                flex: 0 0 34px;
                margin-left: -8px;
                border: 1px solid rgba(255, 255, 255, 0.14);
                border-radius: 10px;
                background: rgba(0, 0, 0, 0.16);
                color: var(--text-primary);
                font-family: inherit;
                cursor: pointer;
                transition: background 0.2s, border-color 0.2s, color 0.2s;
            }
            .history-sidebar-open-btn:hover,
            .history-sidebar-open-btn:focus,
            .history-sidebar-open-btn[aria-expanded="true"] {
                border-color: rgba(255, 107, 0, 0.62);
                background: rgba(255, 107, 0, 0.16);
                color: #ffd1ad;
                outline: none;
            }
            .history-sidebar-open-btn svg {
                width: 18px;
                height: 18px;
                stroke: currentColor;
                stroke-width: 2;
                stroke-linecap: round;
                stroke-linejoin: round;
                fill: none;
            }
            .history-sidebar-backdrop {
                position: fixed;
                inset: 0;
                z-index: 110;
                background: rgba(0, 0, 0, 0.46);
            }
            body.history-sidebar-open .history-sidebar-backdrop { display: block; }
            body.history-sidebar-open { overflow: hidden; }
        }
        .param-section { margin-bottom: 20px; }
        .param-title { font-size: calc(13px * var(--page-font-scale)); font-weight: 700; color: var(--primary); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid #444; }
        .param-title--with-check { display: flex; align-items: center; }
        .param-section-check {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            margin: 0;
            font-size: inherit;
            font-weight: inherit;
            color: inherit;
            user-select: none;
        }
        .param-section-check input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: var(--primary);
            cursor: pointer;
            flex-shrink: 0;
        }
        .param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
        .param-group { margin-bottom: 8px; }
        .param-label { display: block; font-size: calc(11px * var(--page-font-scale)); color: var(--text-secondary); margin-bottom: 3px; }
        .param-input { width: 100%; padding: 6px 8px; border: 1px solid #444; border-radius: 4px; font-size: calc(12px * var(--page-font-scale)); background: #1E272E; color: var(--text-primary); }
        .param-input:focus { outline: none; border-color: var(--primary); }
        .param-select { width: 100%; padding: 6px 8px; border: 1px solid #444; border-radius: 4px; font-size: calc(12px * var(--page-font-scale)); background: #1E272E; color: var(--text-primary); }
        .param-select:focus { outline: none; border-color: var(--primary); }
        .gate-hint { font-size: calc(11px * var(--page-font-scale)); color: var(--text-secondary); margin: -4px 0 10px 0; line-height: 1.45; }
        .param-textarea { min-height: 64px; resize: vertical; font-family: inherit; line-height: 1.45; }
        .gate-label { font-size: calc(11px * var(--page-font-scale)); color: var(--text-primary); display: flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.45; }
        .gate-label input { margin-top: 2px; flex-shrink: 0; }
        .nameplate-preview { font-size: calc(11px * var(--page-font-scale)); color: var(--text-secondary); line-height: 1.5; padding: 8px 10px; background: #1E272E; border: 1px solid #444; border-radius: 4px; margin-bottom: 8px; word-break: break-all; }
        .nameplate-preview strong { color: var(--primary); font-weight: 600; }
        .app-other-wrap { display: none; margin-top: 6px; }
        .app-other-wrap.show { display: block; }
        /* min-height:0 + 固定视口高：让 #chatContainer 成为滚动容器；否则内容撑高整列，滚动条在页面右侧，流式更新滚不到底 */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            min-height: 0;
            height: 100vh;
            max-height: 100vh;
        }
        /* 顶栏高度：垂直留白在「紧凑」基础上加约 50%（8px→12px），标题与状态仍靠 flex 垂直居中 */
        .header { background: linear-gradient(180deg, #3D4852 0%, #2D3436 100%); color: var(--white); padding: 12px 20px; border-bottom: 1px solid rgba(255, 107, 0, 0.45); cursor: default; }
        .header-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; min-height: 0; }
        .header-left {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
            flex: 1;
        }
        .header h1 { margin: 0; font-size: calc(17px * var(--page-font-scale)); font-weight: 650; letter-spacing: 0.012em; line-height: 1.32; min-width: 0; }
        .header-title-dot {
            display: inline-block;
            width: 8px;
            height: 8px;
            margin: 0 0.45em;
            border-radius: 50%;
            vertical-align: 0.08em;
            background: #EF4444;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
            cursor: pointer;
        }
        .header-title-dot.connected {
            background: #10B981;
            box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.13);
        }
        .header-title-dot.disconnected {
            background: #EF4444;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
        }
        .header-title-dot:focus {
            outline: 2px solid rgba(255, 107, 0, 0.55);
            outline-offset: 4px;
        }
        .header-right { display: flex; flex-direction: row; align-items: center; justify-content: flex-end; flex-shrink: 0; gap: 8px; }
        .header-action-btn {
            width: 34px;
            height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 10px;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.22) 100%);
            color: rgba(255, 255, 255, 0.88);
            cursor: pointer;
            transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
            flex-shrink: 0;
            box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
        }
        .header-action-btn:hover,
        .header-action-btn:focus {
            border-color: rgba(255, 107, 0, 0.5);
            background: rgba(255, 107, 0, 0.14);
            color: #fff4ec;
            outline: none;
            box-shadow: 0 0 0 1px rgba(255, 107, 0, 0.2);
        }
        .header-action-label {
            display: none;
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 700;
            letter-spacing: 0.02em;
            color: inherit;
            white-space: nowrap;
        }
        @media (min-width: 720px) {
            .header-action-btn--with-label {
                width: auto;
                height: 34px;
                min-width: 34px;
                padding: 0 12px;
                gap: 7px;
            }
            .header-action-btn--with-label .header-action-label { display: inline; }
        }
        .header-action-btn svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
            flex-shrink: 0;
        }
        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px));
        }
        .history-empty {
            padding: 24px 12px;
            color: var(--text-secondary);
            font-size: calc(13px * var(--page-font-scale));
            text-align: center;
        }
        .history-item {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 8px;
            align-items: center;
            width: 100%;
            padding: 10px 10px;
            margin-bottom: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.16);
        }
        .history-item.is-active {
            border-color: rgba(255, 107, 0, 0.5);
            background: rgba(255, 107, 0, 0.12);
        }
        .history-main {
            min-width: 0;
            text-align: left;
            border: none;
            background: transparent;
            color: inherit;
            cursor: pointer;
            font-family: inherit;
            padding: 0;
        }
        .history-title {
            color: var(--text-primary);
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 700;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 4px;
        }
        .history-sub {
            color: var(--text-secondary);
            font-size: calc(11px * var(--page-font-scale));
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .history-time {
            flex: 0 0 auto;
            color: rgba(255, 255, 255, 0.52);
            font-variant-numeric: tabular-nums;
        }
        .history-summary {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .history-delete {
            width: 30px;
            height: 30px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(0, 0, 0, 0.18);
            color: var(--text-secondary);
            cursor: pointer;
        }
        .history-delete:hover { color: #fecaca; border-color: rgba(248, 113, 113, 0.4); }
        .param-workbench {
            position: fixed;
            inset: 0;
            z-index: 260;
            display: none;
            grid-template-rows: auto 1fr;
            background: linear-gradient(180deg, #24313b 0%, #111820 100%);
            color: var(--text-primary);
        }
        .param-workbench.show { display: grid; }
        body.param-workbench-open { overflow: hidden; }
        .param-workbench-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 12px;
            border-bottom: 1px solid rgba(255, 107, 0, 0.34);
            background: linear-gradient(180deg, #3D4852 0%, #2D3436 100%);
        }
        .param-workbench-title { min-width: 0; }
        .param-workbench-title h2 {
            margin: 0;
            font-size: calc(18px * var(--page-font-scale));
            color: var(--white);
            line-height: 1.3;
        }
        .param-workbench-close {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.2);
            color: var(--text-primary);
            cursor: pointer;
            font-size: 22px;
            line-height: 1;
            flex-shrink: 0;
        }
        .param-workbench-body {
            display: grid;
            grid-template-columns: 196px minmax(0, 1fr);
            min-height: 0;
        }
        .param-workbench-sidebar {
            min-height: 0;
            overflow-y: auto;
            padding: 12px 10px;
            border-right: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(0, 0, 0, 0.18);
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
        }
        .param-workbench-sidebar::-webkit-scrollbar,
        .param-table-wrap::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        .param-workbench-sidebar::-webkit-scrollbar-track,
        .param-table-wrap::-webkit-scrollbar-track {
            background: transparent;
        }
        .param-workbench-sidebar::-webkit-scrollbar-thumb,
        .param-table-wrap::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.18);
            border-radius: 999px;
        }
        .param-workbench-sidebar::-webkit-scrollbar-thumb:hover,
        .param-table-wrap::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.28);
        }
        .param-workbench-side-title {
            margin: 2px 4px 10px;
            color: var(--text-secondary);
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 700;
        }
        #paramGroupFilters { display: block; }
        .param-group-filter {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            padding: 7px 8px;
            margin-bottom: 6px;
            border-radius: 9px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(12px * var(--page-font-scale));
            cursor: pointer;
            text-align: left;
        }
        .param-group-filter.is-active {
            border-color: rgba(255, 107, 0, 0.56);
            background: rgba(255, 107, 0, 0.14);
        }
        .param-group-filter-count {
            color: var(--text-secondary);
            font-size: calc(11px * var(--page-font-scale));
        }
        .param-workbench-main {
            min-width: 0;
            min-height: 0;
            display: grid;
            grid-template-rows: auto auto 1fr;
            padding: 14px;
            gap: 12px;
        }
        .param-workbench-diagnostic { display: none; }
        .param-workbench-toolbar,
        .param-workbench-devicebar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
        }
        .param-workbench-search {
            width: min(360px, 100%);
            min-height: 36px;
            padding: 7px 10px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.22);
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(13px * var(--page-font-scale));
        }
        .param-workbench-search:focus { outline: none; border-color: rgba(255, 107, 0, 0.55); }
        .param-workbench-btn {
            min-height: 36px;
            padding: 7px 11px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(255, 255, 255, 0.06);
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 700;
            cursor: pointer;
        }
        .param-workbench-btn.primary {
            border-color: rgba(255, 107, 0, 0.5);
            background: rgba(255, 107, 0, 0.16);
            color: #ffd1ad;
        }
        .param-workbench-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }
        .param-workbench-devicebar {
            display: none;
            padding: 10px 12px;
            border: 1px dashed rgba(59, 130, 246, 0.42);
            border-radius: 12px;
            background: rgba(59, 130, 246, 0.08);
            color: rgba(219, 234, 254, 0.92);
            font-size: calc(12px * var(--page-font-scale));
        }
        .param-workbench-devicebar.show { display: flex; }
        .param-table-wrap {
            min-height: 0;
            overflow: auto;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            background: rgba(0, 0, 0, 0.16);
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
        }
        .param-table {
            width: max-content;
            min-width: 0;
            border-collapse: collapse;
            table-layout: fixed;
            font-size: calc(12px * var(--page-font-scale));
        }
        .param-table th,
        .param-table td {
            padding: 5px 5px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            white-space: nowrap;
            text-align: left;
        }
        .param-table th:nth-child(1),
        .param-table td:nth-child(1) { width: 30px; text-align: center; }
        .param-table th:nth-child(2),
        .param-table td:nth-child(2) { width: 58px; }
        .param-table th:nth-child(3),
        .param-table td:nth-child(3) { width: 160px; }
        .param-table th:nth-child(4),
        .param-table td:nth-child(4) { width: 126px; }
        .param-table th:nth-child(5),
        .param-table td:nth-child(5),
        .param-table th:nth-child(6),
        .param-table td:nth-child(6),
        .param-table th:nth-child(7),
        .param-table td:nth-child(7),
        .param-table th:nth-child(8),
        .param-table td:nth-child(8) { width: 58px; }
        .param-table th:nth-child(9),
        .param-table td:nth-child(9) { width: 70px; }
        .param-table th:nth-child(10),
        .param-table td:nth-child(10) { width: 74px; }
        .param-table th:nth-child(11),
        .param-table td:nth-child(11) { width: 104px; }
        .param-table th:nth-child(12),
        .param-table td:nth-child(12) { width: 54px; }
        .param-table th {
            position: sticky;
            top: 0;
            z-index: 1;
            background: #26323d;
            color: rgba(255, 255, 255, 0.82);
            font-weight: 700;
        }
        .param-table tr.is-changed td { background: rgba(255, 107, 0, 0.08); }
        .param-table-code { font-family: var(--font-mono); color: #ffd1ad; }
        .param-table-name {
            max-width: 160px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .param-table-value {
            width: 68px;
            padding: 3px 5px;
            border-radius: 6px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.25);
            color: var(--text-primary);
            font-family: var(--font-mono);
            font-size: calc(12px * var(--page-font-scale));
        }
        .param-table-value:focus { outline: none; border-color: rgba(255, 107, 0, 0.58); }
        /* 快捷诊断四项：不用原生 select，避免浅色系统下拉与移动端巨型选择器 */
        /* 必须挂在 #paramWorkbench 内：若在 body 且 z-index 高于工作台，会挡住表内面板导致无法点击 */
        .param-workbench-select-backdrop {
            display: none;
            position: absolute;
            inset: 0;
            z-index: 10;
            background: rgba(0, 0, 0, 0.48);
            -webkit-tap-highlight-color: transparent;
        }
        .param-workbench-select-backdrop.show { display: block; }
        .param-custom-select {
            width: 100%;
            min-width: 92px;
            max-width: 100%;
        }
        .param-custom-select-trigger {
            width: 100%;
            box-sizing: border-box;
            min-height: 28px;
            padding: 3px 8px;
            border-radius: 6px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.25);
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(11px * var(--page-font-scale));
            line-height: 1.35;
            cursor: pointer;
            text-align: left;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            -webkit-tap-highlight-color: transparent;
        }
        .param-custom-select-trigger:focus {
            outline: none;
            border-color: rgba(255, 107, 0, 0.58);
        }
        .param-custom-select-trigger-label {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .param-custom-select-trigger::after {
            content: '';
            flex-shrink: 0;
            width: 0;
            height: 0;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-top: 5px solid rgba(255, 255, 255, 0.42);
            margin-top: 1px;
        }
        .param-custom-select-panel {
            display: none;
            position: fixed;
            z-index: 20;
            overflow-x: hidden;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            box-sizing: border-box;
            padding: 6px 0;
            margin: 0;
            list-style: none;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: linear-gradient(180deg, #2c3946 0%, #1b2430 100%);
            box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
        }
        .param-custom-select-panel.is-open {
            display: block;
        }
        .param-custom-select-option {
            display: block;
            width: 100%;
            box-sizing: border-box;
            padding: 8px 12px;
            border: none;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            background: transparent;
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.4;
            text-align: left;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }
        .param-custom-select-option:last-child {
            border-bottom: none;
        }
        .param-custom-select-option:hover,
        .param-custom-select-option:focus {
            background: rgba(255, 107, 0, 0.15);
            outline: none;
        }
        .param-custom-select-option.is-selected {
            background: rgba(255, 107, 0, 0.12);
            color: #ffd1ad;
        }
        @media (max-width: 900px) {
            .param-custom-select-trigger {
                font-size: calc(12px * var(--page-font-scale));
                min-height: 30px;
                padding: 5px 9px;
            }
            .param-custom-select-option {
                padding: 9px 14px;
                font-size: calc(13px * var(--page-font-scale));
            }
        }
        .param-status {
            display: inline-flex;
            align-items: center;
            min-height: 22px;
            padding: 2px 6px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-secondary);
            font-size: calc(11px * var(--page-font-scale));
        }
        .param-status.changed {
            background: rgba(255, 107, 0, 0.15);
            color: #ffd1ad;
        }
        .param-workbench-empty {
            padding: 36px 14px;
            text-align: center;
            color: var(--text-secondary);
            line-height: 1.7;
        }
        @media (max-width: 900px) {
            .param-workbench-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
            .param-workbench-sidebar {
                display: flex;
                gap: 8px;
                overflow-x: auto;
                overflow-y: hidden;
                border-right: none;
                border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            }
            .param-workbench-side-title { display: none; }
            #paramGroupFilters { display: flex; gap: 8px; }
            .param-group-filter { width: auto; min-width: 92px; margin-bottom: 0; }
            .param-workbench-main { padding: 10px; }
            /*
             * 窄屏 / Android WebView：块级 table 易被父容器横向撑满，fixed layout 会把多余宽度摊进前几列，
             * 造成「参数名称」与「当前值」之间大块留白；桌面 Chrome 往往仍按 max-content 排版故不明显。
             */
            .param-table {
                display: inline-table;
                vertical-align: top;
                width: auto;
                max-width: none;
                table-layout: fixed;
            }
            .param-table th:nth-child(3),
            .param-table td:nth-child(3) { width: 128px; }
            .param-table th:nth-child(4),
            .param-table td:nth-child(4) { width: 104px; }
            .param-table-name { max-width: 128px; }
            .param-table-wrap {
                -webkit-overflow-scrolling: touch;
            }
        }
        .apk-install-banner {
            display: none;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 9px 14px;
            background: rgba(18, 24, 31, 0.96);
            border-bottom: 1px solid rgba(255, 107, 0, 0.28);
            color: var(--text-primary);
            box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
        }
        .apk-install-banner.show { display: flex; }
        .apk-install-text {
            min-width: 0;
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.45;
            color: rgba(255, 255, 255, 0.88);
        }
        .apk-install-text strong {
            display: block;
            color: var(--white);
            font-size: calc(13px * var(--page-font-scale));
            margin-bottom: 1px;
        }
        .apk-install-actions {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }
        .apk-install-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 30px;
            padding: 6px 10px;
            border-radius: 999px;
            border: 1px solid rgba(255, 107, 0, 0.42);
            background: rgba(255, 107, 0, 0.14);
            color: #ffd1ad;
            text-decoration: none;
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 700;
            white-space: nowrap;
        }
        .apk-install-close {
            width: 28px;
            height: 28px;
            border: none;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.07);
            color: rgba(255, 255, 255, 0.7);
            cursor: pointer;
            font-size: 18px;
            line-height: 1;
            flex-shrink: 0;
        }
        @media (min-width: 769px) {
            .apk-install-banner.show { display: none; }
        }
        .chat-container {
            flex: 1;
            min-height: 0;
            padding: 16px;
            /* 略留呼吸空间即可；过大会在滚到底时与输入框之间出现大块空白 */
            padding-bottom: 12px;
            overflow-y: auto;
            overflow-x: hidden;
            background: var(--bg-panel);
            -webkit-overflow-scrolling: touch;
            overscroll-behavior-y: contain;
        }
        .chat-scroll-inner {
            min-height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
        }
        /* 有对话时让短会话贴底；用 class 同步，避免 iOS 15.3 及以下不支持 :has() */
        .chat-container.chat-has-messages .chat-scroll-inner {
            justify-content: flex-end;
        }
        .welcome { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
        .welcome-tagline {
            font-size: calc(14px * var(--page-font-scale));
            color: var(--text-primary);
            line-height: 1.55;
            margin: 0;
            max-width: 36em;
            margin-left: auto;
            margin-right: auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: baseline;
            column-gap: 0;
            row-gap: 6px;
        }
        .welcome-tagline-item { white-space: nowrap; }
        .welcome-tagline-item + .welcome-tagline-item::before {
            content: '\00B7';
            margin: 0 0.5em 0 0;
            color: var(--text-secondary);
            opacity: 0.72;
            font-weight: 700;
            user-select: none;
        }
        .welcome-icon {
            width: 80px; height: 80px; margin: 0 auto 16px;
            border-radius: 12px; overflow: hidden;
            border: 2px solid rgba(255, 107, 0, 0.45);
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
            display: flex; align-items: center; justify-content: center;
            background: #1a1f26;
        }
        .welcome-icon .kiwi-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
        .welcome h2 { font-size: calc(17px * var(--page-font-scale)); color: var(--text-primary); margin-bottom: 8px; font-weight: 650; letter-spacing: 0.015em; line-height: 1.35; }
        .message { display: flex; margin-bottom: 14px; }
        .message.user { flex-direction: row-reverse; }
        .message-avatar { width: 36px; height: 36px; border-radius: 4px; display: flex; align-items: center; justify-content: center; margin: 0 8px; flex-shrink: 0; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
        .message.agent .message-avatar { background: transparent; padding: 0; overflow: hidden; border: 1px solid rgba(255, 107, 0, 0.35); }
        .message.agent .message-avatar .kiwi-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
        .message.user .message-avatar { display: none; }
        .message-avatar svg { width: 20px; height: 20px; fill: var(--white); }
        .typing .message-avatar { background: transparent; padding: 0; overflow: hidden; border: 1px solid rgba(255, 107, 0, 0.35); }
        .typing .message-avatar .kiwi-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
        .message-content {
            max-width: 80%;
            min-width: 0;
            padding: 12px 16px;
            border-radius: 6px;
            font-size: calc(14px * var(--page-font-scale));
            line-height: 1.6;
            background: var(--bg-panel);
            border: 1px solid #444;
            word-wrap: break-word;
            overflow-x: hidden;
            position: relative;
        }
        /* 助手回复：拉开行距与段落，避免「字挤在一起」 */
        .message.agent .message-content {
            border-radius: 6px 6px 6px 4px;
            line-height: var(--reply-line-body);
            font-size: var(--reply-font-body);
            padding: 12px 14px;
            font-family: var(--font-reply);
            letter-spacing: 0.012em;
            color: var(--white);
            /* 宽表靠内层 .md-table-wrapper 横向滚动；勿对整泡 hidden，否则表格被压成极窄列 */
            overflow-x: visible;
        }
        .message.agent .message-time { color: var(--white); opacity: 0.92; }
        .message.agent .msg-conversation-id { color: var(--white); opacity: 0.85; }
        .message.agent .quick-option-btn {
            color: var(--white);
            border-color: rgba(255, 255, 255, 0.28);
            background: rgba(0, 0, 0, 0.25);
        }
        .message.agent .quick-option-btn:hover {
            color: var(--white);
            border-color: var(--primary);
            background: rgba(0, 0, 0, 0.35);
        }
        .message.agent .quick-option-btn.selected {
            color: #ffffff;
            border-color: var(--primary);
            background: rgba(14, 165, 233, 0.42);
            box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.22) inset;
        }
        .message.agent.choice-submitted .quick-option-btn,
        .message.agent .quick-option-btn:disabled {
            cursor: not-allowed;
            opacity: 0.58;
        }
        .message.agent.choice-submitted .quick-option-btn.selected,
        .message.agent .quick-option-btn.selected:disabled {
            opacity: 0.95;
        }
        .message.agent .agent-thinking-status {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: rgba(255, 255, 255, 0.72);
            font-size: calc(13px * var(--page-font-scale));
            line-height: 1.5;
        }
        .message.agent .agent-thinking-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.72);
            box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.28);
            animation: agentThinkingPulse 1.2s ease-in-out infinite;
        }
        @keyframes agentThinkingPulse {
            0%, 100% { opacity: 0.45; transform: scale(0.9); }
            50% { opacity: 1; transform: scale(1.08); }
        }
        .message.agent .agent-trace-stream {
            max-width: 100%;
            padding: 8px 10px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.12);
            color: rgba(255, 255, 255, 0.58);
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.55;
        }
        .message.agent .agent-trace-stream-title {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 4px;
            color: rgba(255, 255, 255, 0.68);
            font-size: calc(12.5px * var(--page-font-scale));
        }
        .message.agent .agent-trace-stream-lines {
            display: grid;
            gap: 2px;
        }
        .message.agent .agent-trace-stream-line {
            overflow-wrap: anywhere;
            word-break: break-word;
            white-space: normal;
            opacity: 0.82;
        }
        .message.agent .agent-trace-details {
            margin: 0 0 10px;
            padding: 0;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.10);
            color: rgba(255, 255, 255, 0.58);
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.55;
        }
        .message.agent .agent-trace-details summary {
            cursor: pointer;
            padding: 7px 10px;
            color: rgba(255, 255, 255, 0.68);
            user-select: none;
        }
        .message.agent .agent-trace-details[open] summary {
            border-bottom: 1px solid rgba(255, 255, 255, 0.07);
        }
        .message.agent .agent-trace-details-body {
            display: grid;
            gap: 3px;
            padding: 8px 10px 10px;
        }
        .message.agent .agent-trace-detail-line {
            opacity: 0.85;
            word-break: break-word;
        }
        .message.agent .agent-trace-detail-label {
            color: rgba(255, 255, 255, 0.78);
            white-space: pre-wrap;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .message.agent .agent-trace-io {
            margin: 4px 0 6px 12px;
            border-left: 2px solid rgba(255, 107, 0, 0.34);
            padding-left: 8px;
            color: rgba(255, 255, 255, 0.62);
        }
        .message.agent .agent-trace-io > summary,
        .message.agent .agent-trace-io-block > summary {
            cursor: pointer;
            user-select: none;
            color: rgba(255, 255, 255, 0.72);
        }
        .message.agent .agent-trace-io-body {
            display: grid;
            gap: 6px;
            margin-top: 5px;
        }
        .message.agent .agent-trace-io-block {
            margin: 0;
        }
        .message.agent .agent-trace-io-block pre {
            max-height: 360px;
            margin: 5px 0 0;
            padding: 8px 10px;
            overflow-y: auto;
            overflow-x: hidden;
            border-radius: 6px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(0, 0, 0, 0.22);
            color: rgba(255, 255, 255, 0.78);
            font-size: calc(11px * var(--page-font-scale));
            line-height: 1.45;
            overflow-wrap: anywhere;
            word-break: break-word;
            white-space: pre-wrap;
        }
        .message.agent .msg-content > p { margin: 0 0 8px 0; }
        .message.agent .msg-content > p:last-child { margin-bottom: 0; }
        .message.agent .msg-content p br { line-height: inherit; }
        .message.agent .msg-content ul,
        .message.agent .msg-content ol { margin: 6px 0 10px; padding-left: 20px; }
        .message.agent .msg-content li { margin: 4px 0; line-height: var(--reply-line-body); padding-left: 2px; }
        .message.agent .msg-content li + li { margin-top: 4px; }
        .message.agent .msg-content strong { font-weight: 600; }
        .message.agent .msg-content hr { margin: 16px 0; border: none; border-top: 1px solid #4a5568; }
        .message.agent .msg-content h3,
        .message.agent .msg-content .md-h3 {
            margin: 12px 0 8px;
            font-size: var(--reply-font-h3);
            font-weight: 700;
            color: var(--white);
            line-height: var(--reply-line-h3);
        }
        .message.agent .msg-content h4 {
            margin: 12px 0 8px;
            font-size: var(--reply-font-h4);
            font-weight: 700;
            color: var(--white);
            line-height: var(--reply-line-h4);
        }
        .message.agent .msg-content .md-h3:first-child { margin-top: 0; }
        /* marked(GFM) 输出包在 .md-prose 内，与常见对话预览样式接近：标准 h1/h2、代码块、引用 */
        .message.agent .msg-content .md-prose h1,
        .message.agent .msg-content .md-prose h2 {
            margin: 12px 0 8px;
            font-size: var(--reply-font-h3);
            font-weight: 700;
            color: var(--white);
            line-height: var(--reply-line-h3);
        }
        .message.agent .msg-content .md-prose h1:first-child,
        .message.agent .msg-content .md-prose h2:first-child { margin-top: 0; }
        .message.agent .msg-content .md-prose blockquote {
            margin: 8px 0;
            padding: 8px 12px;
            border-left: 3px solid rgba(255, 107, 0, 0.55);
            background: rgba(0, 0, 0, 0.2);
            color: var(--white);
        }
        .message.agent .msg-content .md-prose pre {
            margin: 8px 0;
            padding: 10px 12px;
            background: rgba(0, 0, 0, 0.28);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            overflow-x: auto;
            font-size: var(--reply-font-code);
            line-height: var(--reply-line-code);
        }
        .message.agent .msg-content .md-prose pre code {
            font-family: var(--font-mono);
            background: transparent;
            padding: 0;
            border: none;
            font-size: inherit;
            color: var(--white);
            white-space: pre;
        }
        /* 与 msg-code-inline 一致：行内 `code` 仅等宽区分，勿深色底块（模型爱给数字加反引号） */
        .message.agent .msg-content .md-prose :not(pre) > code {
            font-family: var(--font-mono);
            font-size: var(--reply-font-code);
            padding: 0 2px;
            border-radius: 0;
            background: transparent;
            border: none;
            color: var(--white);
        }
        .message.agent .msg-content a {
            color: var(--white);
            text-decoration: underline;
            text-underline-offset: 2px;
        }
        /* 用户消息：与主色深灰蓝体系一致，弱化高亮橙；细边框 + 内敛高光，偏简约质感 */
        .message.user .message-content {
            background: linear-gradient(165deg, #3d4a56 0%, #323c46 42%, #2a323a 100%);
            color: rgba(255, 255, 255, 0.94);
            border: 1px solid rgba(255, 255, 255, 0.11);
            border-radius: 10px 10px 6px 10px;
            padding-top: 9px;
            padding-bottom: 9px;
            line-height: 1.5;
            box-shadow:
                0 2px 14px rgba(0, 0, 0, 0.22),
                inset 0 1px 0 rgba(255, 255, 255, 0.07),
                inset 0 0 0 1px rgba(255, 107, 0, 0.12);
            /* 与助手泡一致：勿 hidden，否则右下角元信息浮层被裁切、短消息上看起来像乱版 */
            overflow-x: visible;
            overflow-y: visible;
        }
        /* 仅略增右侧内边距，避免末行文字伸到右下角 ⋯ 下方；bottom 不额外加高（按钮已 absolute，勿撑出一行空白） */
        .message.user .message-content.msg-content { padding-right: 18px; }
        .message.user .msg-content > p {
            margin: 0;
            line-height: inherit;
        }
        .message.user .msg-content > p + p {
            margin-top: 6px;
        }
        .message.agent .message-content.msg-content {
            padding-right: 20px;
        }
        .message.user .msg-content a { color: rgba(255, 255, 255, 0.95); text-decoration: underline; text-underline-offset: 2px; }
        .message.user .user-param-fold {
            margin: 0;
            border: 1px dashed rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            background: rgba(0, 0, 0, 0.12);
            padding: 6px 8px;
        }
        .message.user .user-param-fold > summary {
            list-style: none;
            cursor: pointer;
            color: rgba(255, 255, 255, 0.88);
            font-weight: 600;
            user-select: none;
        }
        .message.user .user-param-fold > summary::-webkit-details-marker {
            display: none;
        }
        .message.user .user-param-fold > summary::before {
            content: '▸';
            margin-right: 6px;
            display: inline-block;
            transition: transform 0.16s ease;
        }
        .message.user .user-param-fold[open] > summary::before {
            transform: rotate(90deg);
        }
        .message.user .user-param-fold-body {
            margin-top: 8px;
            max-height: min(56vh, 420px);
            overflow: auto;
            padding-right: 2px;
        }
        .message.user .message-time { color: rgba(255, 255, 255, 0.52); }
        .message-time { font-size: var(--reply-font-time); color: var(--text-secondary); margin-top: 4px; text-align: right; }
        .message-footer {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: flex-end;
            gap: 6px 12px;
            margin-top: 6px;
            width: 100%;
        }
        .message-footer .message-time { margin-top: 0; text-align: left; flex: 0 0 auto; }
        .msg-conversation-id {
            font-size: calc(10px * var(--page-font-scale));
            color: var(--text-secondary);
            opacity: 0.72;
            text-align: right;
            margin-left: auto;
            max-width: 100%;
            word-break: break-all;
            line-height: 1.3;
        }
        /* 问答元信息：右下角悬浮按钮，不占消息正文高度 */
        .message-meta-inline {
            position: absolute;
            right: 8px;
            bottom: 6px;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            z-index: 3;
        }
        .message-meta-toggle {
            width: 16px;
            height: 16px;
            border-radius: 999px;
            border: none;
            background: transparent;
            color: rgba(255, 255, 255, 0.22);
            cursor: pointer;
            font-size: 12px;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            opacity: 0.18;
            transition: opacity 0.16s ease, color 0.16s ease, background-color 0.16s ease;
        }
        .message-meta-toggle:hover {
            color: rgba(255, 255, 255, 0.72);
            background: rgba(255, 255, 255, 0.06);
            opacity: 0.72;
        }
        .message-meta-popover.is-open + .message-meta-toggle {
            color: rgba(255, 255, 255, 0.88);
            background: rgba(255, 255, 255, 0.09);
            opacity: 0.85;
        }
        @media (hover: hover) and (pointer: fine) {
            .message-content .message-meta-toggle { opacity: 0; }
            .message-content:hover .message-meta-toggle,
            .message-content:focus-within .message-meta-toggle { opacity: 0.55; }
        }
        @media (hover: none), (pointer: coarse) {
            .message-meta-toggle { opacity: 0.34; }
        }
        .message-meta-popover {
            margin-bottom: 6px;
            min-width: 132px;
            max-width: min(320px, 70vw);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 8px;
            background: rgba(26, 32, 41, 0.98);
            box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
            padding: 7px 9px;
            opacity: 0;
            visibility: hidden;
            transform: translateY(4px);
            transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
            pointer-events: none;
            z-index: 8;
        }
        .message-meta-popover.is-open {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
            pointer-events: auto;
        }
        .message-meta-popover .message-footer {
            margin-top: 0;
            flex-direction: column;
            align-items: stretch;
            gap: 6px;
        }
        .message-meta-popover .message-time {
            margin-top: 0;
            text-align: left;
        }
        .message-meta-popover .msg-conversation-id {
            margin-left: 0;
            text-align: left;
        }
        .message-meta-popover .msg-token-usage {
            margin-left: 0;
            text-align: left;
            color: rgba(255, 255, 255, 0.76);
            font-variant-numeric: tabular-nums;
        }
        .typing { display: none; padding: 12px; }
        .typing.show { display: flex; }
        .typing-dots { display: flex; gap: 4px; padding: 10px 14px; background: var(--bg-panel); border: 1px solid #444; border-radius: 6px; }
        .typing-dots span { width: 8px; height: 8px; background: var(--primary); border-radius: 2px; animation: typing 1s infinite; }
        .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
        .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typing { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
        .input-area {
            position: sticky;
            bottom: 0;
            background: transparent;
            border-top: none;
            box-shadow: none;
            padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
            display: flex;
            justify-content: center;
            align-items: flex-end;
        }
        /* 上：多行输入 / 下：工具栏（左操作、右发送），单卡片圆角 */
        .input-composer {
            position: relative;
            flex: 1;
            width: 100%;
            max-width: 100%;
            min-width: 0;
            background: #1E272E;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 14px;
            overflow: hidden;
            box-shadow:
                0 8px 28px rgba(0, 0, 0, 0.38),
                0 2px 8px rgba(0, 0, 0, 0.22),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .input-composer:focus-within {
            border-color: rgba(255, 107, 0, 0.45);
            box-shadow:
                0 10px 32px rgba(0, 0, 0, 0.42),
                0 0 0 1px rgba(255, 107, 0, 0.18),
                0 2px 20px rgba(255, 107, 0, 0.14);
        }
        /* 桌面：输入条收窄 25% 并居中；窄屏保持通栏 */
        @media (min-width: 769px) {
            .input-composer {
                flex: 0 1 auto;
                width: 75%;
                max-width: 75%;
            }
        }
        .input-composer-field {
            padding: 8px 12px 6px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        .input-composer-field textarea {
            width: 100%;
            border: none;
            background: transparent;
            resize: none;
            font-size: calc(15px * var(--page-font-scale));
            line-height: 1.38;
            outline: none;
            color: var(--text-primary);
            font-family: inherit;
            min-height: calc(1.38em * 2);
            max-height: 220px;
            box-sizing: border-box;
            overflow-y: auto;
            display: block;
        }
        .input-composer-field textarea::placeholder { color: var(--text-secondary); }
        .input-guard-hint {
            position: absolute;
            right: 0;
            bottom: calc(100% + 8px);
            width: max-content;
            max-width: min(360px, calc(100vw - 28px));
            padding: 8px 12px;
            border-radius: 10px;
            background: rgba(90, 53, 18, 0.94);
            border: 1px solid rgba(255, 177, 121, 0.36);
            color: #ffd1ad;
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.45;
            box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
            pointer-events: none;
            opacity: 0;
            transform: translateY(6px);
            transition: opacity 0.18s, transform 0.18s;
            z-index: 6;
        }
        .input-guard-hint.show {
            opacity: 1;
            transform: translateY(0);
        }
        .input-guard-hint::after {
            content: "";
            position: absolute;
            right: 16px;
            bottom: -6px;
            width: 12px;
            height: 12px;
            background: rgba(90, 53, 18, 0.94);
            border-right: 1px solid rgba(255, 177, 121, 0.24);
            border-bottom: 1px solid rgba(255, 177, 121, 0.24);
            transform: rotate(45deg);
        }
        .input-composer-toolbar {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 4px 10px 6px;
            flex-wrap: wrap;
        }
        .input-toolbar-left {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
            flex: 1;
            min-width: 0;
        }
        .input-toolbar-right {
            position: relative;
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }
        .toolbar-csv-btn {
            width: 36px;
            height: 36px;
            min-width: 36px;
            min-height: 36px;
            flex-shrink: 0;
            align-self: center;
            border: 1px solid rgba(255, 255, 255, 0.16);
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.28);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s, color 0.2s, border-color 0.2s;
            padding: 0;
            font-family: inherit;
        }
        .toolbar-csv-btn:hover {
            color: var(--text-primary);
            border-color: rgba(255, 107, 0, 0.35);
            background: rgba(255, 107, 0, 0.1);
        }
        .toolbar-csv-btn svg { width: 18px; height: 18px; fill: currentColor; display: block; }
        .param-csv-file-input {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
            opacity: 0;
            pointer-events: none;
        }
        .toolbar-pill {
            padding: 4px 10px;
            font-size: calc(12px * var(--page-font-scale));
            font-weight: 600;
            line-height: 1.25;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.2);
            color: var(--text-secondary);
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.2s, color 0.2s, border-color 0.2s;
            font-family: inherit;
        }
        .toolbar-pill:hover {
            color: var(--text-primary);
            border-color: rgba(255, 255, 255, 0.22);
            background: rgba(0, 0, 0, 0.28);
        }
        .toolbar-pill--clear:hover {
            background: rgba(239, 68, 68, 0.14);
            border-color: rgba(248, 113, 113, 0.4);
            color: #fecaca;
        }
        .toolbar-pill--params:hover {
            background: rgba(255, 107, 0, 0.12);
            border-color: rgba(255, 107, 0, 0.36);
            color: #ffd1ad;
        }
        /* ---- A/B 参数选择卡 ---- */
        .v2-card {
            margin: 12px 0 4px;
            padding: 12px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.045);
        }
        .v2-card-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 10px;
        }
        .v2-card-title {
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 700;
            color: var(--text-primary);
        }
        .v2-card-product {
            flex: 0 0 auto;
            padding: 2px 7px;
            border-radius: 999px;
            border: 1px solid rgba(255, 107, 0, 0.32);
            background: rgba(255, 107, 0, 0.1);
            color: #ffd1ad;
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 700;
        }
        .v2-card-body {
            display: grid;
            gap: 10px;
        }
        .v2-card-body--diagnosis_clarify_card {
            grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
            align-items: start;
        }
        .v2-card-body--parameter_form {
            grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
            align-items: start;
        }
        .v2-card-field,
        .v2-card-param-row {
            display: grid;
            gap: 6px;
        }
        .v2-card-field {
            align-content: start;
            min-width: 0;
        }
        .v2-card-param-row {
            grid-template-columns: auto minmax(0, 1fr);
            align-items: start;
            column-gap: 8px;
            padding: 8px 9px;
            border-radius: 8px;
            background: rgba(0, 0, 0, 0.1);
        }
        .v2-card-label,
        .v2-card-param-code {
            color: var(--text-primary);
            font-size: calc(12.5px * var(--page-font-scale));
            font-weight: 700;
        }
        .v2-card-param-name,
        .v2-card-field-hint {
            color: var(--text-secondary);
            font-size: calc(12px * var(--page-font-scale));
        }
        .v2-card-param-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .v2-card-param-row .v2-card-inline-input,
        .v2-card-param-row .v2-card-field-hint {
            grid-column: 1 / -1;
        }
        .v2-card-required {
            margin-left: 3px;
            color: #fb7185;
        }
        .v2-card-options {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
        }
        .v2-choice-btn,
        .v2-card-submit {
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.06);
            color: var(--text-primary);
            cursor: pointer;
            font-family: inherit;
            font-size: calc(12.5px * var(--page-font-scale));
            line-height: 1.25;
        }
        .v2-choice-btn {
            min-height: 34px;
            padding: 7px 10px;
            flex: 0 1 auto;
        }
        .v2-choice-btn:hover,
        .v2-card-submit:hover {
            border-color: rgba(255, 107, 0, 0.45);
            background: rgba(255, 107, 0, 0.14);
        }
        .v2-choice-btn.selected {
            border-color: rgba(255, 107, 0, 0.72);
            background: rgba(255, 107, 0, 0.22);
            color: #fff7ed;
        }
        .v2-card-inline-input {
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
            max-width: 260px;
        }
        .v2-card-input {
            width: 100%;
            min-width: 0;
            height: 34px;
            padding: 6px 9px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(0, 0, 0, 0.18);
            color: var(--text-primary);
            font-family: inherit;
            font-size: calc(12.5px * var(--page-font-scale));
        }
        .v2-card-input:focus {
            outline: none;
            border-color: rgba(255, 107, 0, 0.6);
            box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.12);
        }
        .v2-card-unit {
            flex: 0 0 auto;
            color: var(--text-secondary);
            font-size: calc(12px * var(--page-font-scale));
        }
        .v2-card-actions {
            display: flex;
            justify-content: flex-end;
            margin-top: 12px;
        }
        .v2-card-submit {
            min-height: 34px;
            padding: 8px 14px;
            border-color: rgba(255, 107, 0, 0.45);
            background: rgba(255, 107, 0, 0.18);
            font-weight: 700;
        }
        .v2-card.is-submitted {
            opacity: 0.72;
        }
        .v2-card button:disabled,
        .v2-card input:disabled {
            cursor: default;
            opacity: 0.62;
        }
        @media (max-width: 760px) {
            .v2-card-body--diagnosis_clarify_card,
            .v2-card-body--parameter_form {
                grid-template-columns: 1fr;
            }
            .v2-card-param-row {
                grid-template-columns: 1fr;
            }
            .v2-card-param-name,
            .v2-card-param-row .v2-card-inline-input,
            .v2-card-param-row .v2-card-field-hint {
                grid-column: auto;
            }
            .v2-card-inline-input {
                max-width: none;
            }
            .v2-card-head {
                align-items: flex-start;
                flex-direction: column;
            }
            .v2-card-actions {
                justify-content: stretch;
            }
            .v2-card-submit {
                width: 100%;
            }
        }

        .param-choice-card {
            margin: 10px 0 4px;
        }
        .param-choice-prompt {
            font-size: calc(12.5px * var(--page-font-scale));
            color: var(--text-secondary);
            margin-bottom: 8px;
        }
        .param-choice-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .param-choice-btn {
            flex: 1 1 140px;
            display: flex;
            flex-direction: column;
            gap: 5px;
            padding: 10px 14px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
            text-align: left;
            cursor: pointer;
            font-family: inherit;
            transition: background 0.18s, border-color 0.18s, transform 0.1s;
        }
        .param-choice-btn:hover {
            background: rgba(255, 107, 0, 0.14);
            border-color: rgba(255, 107, 0, 0.45);
            transform: translateY(-1px);
        }
        .param-choice-btn:active { transform: translateY(0); }
        .param-choice-btn.selected {
            background: rgba(255, 107, 0, 0.2);
            border-color: rgba(255, 107, 0, 0.6);
        }
        .param-choice-btn:disabled {
            opacity: 0.45;
            cursor: default;
            transform: none;
        }
        .choice-header {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .choice-icon { font-size: 15px; line-height: 1; flex-shrink: 0; }
        .choice-title { font-size: calc(13px * var(--page-font-scale)); font-weight: 600; }
        .choice-desc { font-size: calc(11.5px * var(--page-font-scale)); color: var(--text-secondary); padding-left: 2px; }
        .product-choice-card .param-choice-prompt {
            margin-bottom: 6px;
            color: var(--text-primary);
        }
        .product-choice-card .param-choice-buttons {
            gap: 6px;
        }
        .product-choice-card .product-choice-btn {
            flex: 0 1 112px;
            min-height: 34px;
            padding: 7px 12px;
            border-radius: 8px;
            align-items: center;
            justify-content: center;
            text-align: center;
        }
        .product-choice-card .choice-header {
            gap: 0;
        }
        /* ---- end A/B 参数选择卡 ---- */

        /* ---- 步骤引导条 ---- */
        .param-guide-strip {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 14px 7px;
            background: rgba(255, 107, 0, 0.1);
            border-top: 1px solid rgba(255, 107, 0, 0.22);
            font-size: calc(12px * var(--page-font-scale));
            color: var(--text-secondary);
            flex-shrink: 0;
        }
        .param-guide-steps {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }
        .guide-step {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 2px 8px;
            border-radius: 999px;
            border: 1px solid transparent;
            white-space: nowrap;
            transition: all 0.2s;
        }
        .guide-step.active {
            color: #fde68a;
            border-color: rgba(253, 230, 138, 0.35);
            background: rgba(253, 230, 138, 0.1);
            font-weight: 600;
        }
        .guide-step.done {
            color: #6ee7b7;
            border-color: rgba(110, 231, 183, 0.3);
            background: rgba(110, 231, 183, 0.08);
        }
        .guide-step.pending { opacity: 0.45; }
        .guide-step-arrow { opacity: 0.4; font-size: 10px; }
        .param-guide-dismiss {
            flex-shrink: 0;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            border: none;
            background: rgba(255,255,255,0.08);
            color: var(--text-secondary);
            font-size: 14px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
        }
        .param-guide-dismiss:hover { background: rgba(255,255,255,0.16); color: var(--text-primary); }
        /* ---- end 步骤引导条 ---- */

        /* ---- 面板高亮脉冲 ---- */
        @keyframes param-panel-pulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 0, 0); }
            50% { box-shadow: 0 0 0 6px rgba(255, 107, 0, 0.22), inset 0 0 0 2px rgba(255, 107, 0, 0.18); }
        }
        .param-panel-highlight {
            outline: 2px solid rgba(255, 140, 0, 0.6) !important;
            outline-offset: 2px;
            border-radius: 8px;
            animation: param-panel-pulse 1.8s ease-in-out infinite;
            transition: outline 0.2s;
        }
        /* ---- end 面板高亮脉冲 ---- */

        /* ---- 按钮闪烁 ---- */
        @keyframes btn-blink-pulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 0, 0); opacity: 1; }
            50% { box-shadow: 0 0 0 5px rgba(255, 107, 0, 0.35); opacity: 0.82; }
        }
        .btn-blink {
            animation: btn-blink-pulse 1.1s ease-in-out infinite !important;
            border-color: rgba(255, 107, 0, 0.55) !important;
            color: #ffd1ad !important;
        }
        /* ---- end 按钮闪烁 ---- */

        /* ---- 参数同步状态标签 ---- */
        .param-sync-tag {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 3px 10px 3px 8px;
            border-radius: 999px;
            font-size: calc(11.5px * var(--page-font-scale));
            font-weight: 600;
            white-space: nowrap;
            border: 1px solid transparent;
            transition: opacity 0.25s, background 0.25s, color 0.25s;
            user-select: none;
        }
        .param-sync-syncing {
            background: rgba(120, 100, 0, 0.22);
            border-color: rgba(255, 210, 80, 0.32);
            color: #fde68a;
        }
        .param-sync-synced {
            background: rgba(0, 120, 50, 0.22);
            border-color: rgba(52, 211, 153, 0.32);
            color: #6ee7b7;
        }
        .param-sync-error {
            background: rgba(180, 30, 30, 0.22);
            border-color: rgba(248, 113, 113, 0.36);
            color: #fca5a5;
        }
        .param-sync-label { vertical-align: middle; }
        .param-sync-retry {
            display: inline;
            padding: 0 6px;
            border-radius: 4px;
            border: 1px solid rgba(248, 113, 113, 0.45);
            background: rgba(180, 30, 30, 0.28);
            color: #fca5a5;
            font-size: inherit;
            font-family: inherit;
            cursor: pointer;
            line-height: 1.6;
        }
        .param-sync-retry:hover {
            background: rgba(248, 113, 113, 0.28);
            color: #fecaca;
        }
        @keyframes param-sync-spin {
            to { transform: rotate(360deg); }
        }
        .param-sync-spinner {
            display: inline-block;
            width: 10px;
            height: 10px;
            border: 2px solid rgba(253, 230, 138, 0.3);
            border-top-color: #fde68a;
            border-radius: 50%;
            animation: param-sync-spin 0.7s linear infinite;
            flex-shrink: 0;
        }
        /* ---- end 参数同步状态标签 ---- */

        .send-btn {
            width: 36px;
            height: 36px;
            min-width: 36px;
            min-height: 36px;
            flex-shrink: 0;
            align-self: center;
            background: linear-gradient(145deg, var(--primary), var(--primary-dark));
            border: none;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 1px 8px rgba(255, 107, 0, 0.22);
            transition: filter 0.2s, transform 0.15s;
        }
        .send-btn:hover:not(:disabled) { filter: brightness(1.06); }
        .send-btn:active:not(:disabled) { transform: scale(0.96); }
        .send-btn:disabled { background: #4a5568; box-shadow: none; cursor: not-allowed; opacity: 0.85; }
        .send-btn svg { width: 18px; height: 18px; fill: var(--white); display: block; }

        /* ========== 窄屏覆盖（须排在本文件靠前段基础样式之后）==========
           用途：锁定 .main-content 为 var(--app-vh)、输入条随软键盘上抬（--ios-kb-offset）、
           .ios-keyboard-open 时限制多行高度并临时隐藏参数区。
           请勿在更靠后的 @media 里再次覆盖 .main-content 的 height/max-height，除非有意重做 iOS 键盘方案。 */
        @media (max-width: 1100px) {
            .main-content {
                order: -1;
                display: grid;
                grid-template-rows: auto minmax(240px, 1fr) auto;
                min-height: var(--app-vh, 100dvh);
                height: var(--app-vh, 100dvh);
                max-height: var(--app-vh, 100dvh);
            }
            .chat-container {
                min-height: 240px;
                height: auto;
            }
            .input-area {
                position: sticky;
                bottom: var(--ios-kb-offset, 0px);
                z-index: 20;
            }
            .ios-keyboard-open .input-area {
                padding-bottom: 8px;
            }
            .ios-keyboard-open #userInput {
                /* 键盘开启时限制多行高度，避免输入条过高被键盘遮挡 */
                max-height: min(26vh, 120px);
            }
            .ios-keyboard-open .input-composer {
                max-height: min(42vh, 260px);
            }
            .ios-keyboard-open .history-sidebar {
                visibility: hidden;
                pointer-events: none;
            }
        }
        @media (max-width: 560px) {
            .header {
                padding-top: calc(14px + env(safe-area-inset-top, 0px));
                padding-right: calc(12px + env(safe-area-inset-right, 0px));
                padding-bottom: 10px;
                padding-left: calc(12px + env(safe-area-inset-left, 0px));
            }
            .header-inner {
                gap: 8px;
                min-height: 34px;
            }
            .header-left {
                flex: 1 1 auto;
                min-width: 0;
                gap: 7px;
            }
            .header h1 {
                flex: 1 1 auto;
                min-width: 0;
                max-width: 100%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                font-size: calc(15px * var(--page-font-scale));
                line-height: 1.25;
                letter-spacing: 0;
            }
            .history-sidebar-open-btn,
            .header-action-btn {
                width: 32px;
                height: 32px;
                min-width: 32px;
                border-radius: 10px;
            }
            .header-right {
                flex: 0 0 auto;
                gap: 6px;
            }
            .header-action-label {
                display: none !important;
            }
            .header-title-dot {
                width: 7px;
                height: 7px;
                margin: 0 0.35em;
            }
        }
        @media (max-width: 560px) {
            .input-composer-toolbar { padding: 4px 8px 6px; }
            .toolbar-pill { padding: 4px 9px; font-size: calc(11px * var(--page-font-scale)); }
            .input-guard-hint {
                right: 0;
                max-width: min(300px, calc(100vw - 32px));
                font-size: calc(11px * var(--page-font-scale));
            }
        }
        .confirm-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 500; display: none; align-items: center; justify-content: center; }
        .confirm-modal.show { display: flex; }
        .confirm-content { background: var(--bg-panel); border: 2px solid var(--primary); border-radius: 8px; padding: 24px; max-width: 360px; text-align: center; }
        .confirm-title { font-size: calc(16px * var(--page-font-scale)); font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
        .confirm-text { font-size: calc(14px * var(--page-font-scale)); color: var(--text-secondary); margin-bottom: 20px; }
        .confirm-buttons { display: flex; gap: 12px; justify-content: center; }
        .confirm-btn { padding: 10px 24px; border: none; border-radius: 6px; font-size: calc(14px * var(--page-font-scale)); font-weight: 600; cursor: pointer; }
        .confirm-btn.cancel { background: #4A5568; color: var(--white); }
        .confirm-btn.cancel:hover { background: #5A6578; }
        .confirm-btn.confirm { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--white); }
        .confirm-btn.confirm:hover { opacity: 0.9; }
        .account-settings-panel {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 240;
            display: flex;
            flex-direction: column;
            background: #101418;
            color: var(--text-primary);
            transform: translateX(100%);
            transition: transform 0.24s ease;
            pointer-events: none;
        }
        .account-settings-panel.show {
            transform: translateX(0);
            pointer-events: auto;
        }
        .account-settings-panel.profile-edit > .account-settings-header,
        .account-settings-panel.profile-edit > .account-settings-scroll {
            display: none;
        }
        body.account-settings-open { overflow: hidden; }
        .account-settings-header {
            position: sticky;
            top: 0;
            z-index: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 58px;
            padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
            background: rgba(16, 20, 24, 0.96);
            backdrop-filter: blur(14px);
        }
        .account-settings-header h2 {
            margin: 0;
            font-size: calc(18px * var(--page-font-scale));
            font-weight: 800;
        }
        .account-settings-back {
            position: absolute;
            left: calc(14px + env(safe-area-inset-left, 0px));
            bottom: 10px;
            width: 34px;
            height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-primary);
            cursor: pointer;
            padding: 0;
        }
        .account-settings-back svg {
            width: 22px;
            height: 22px;
            fill: currentColor;
        }
        .account-settings-scroll {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 12px calc(14px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
        }
        .account-settings-user,
        .settings-list-card,
        .settings-update-card,
        .settings-logout-btn {
            width: min(100%, 520px);
            margin-left: auto;
            margin-right: auto;
        }
        .account-settings-user {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px;
            margin-bottom: 14px;
            border-radius: 16px;
            background: #202020;
            border: 1px solid rgba(255, 255, 255, 0.06);
        }
        .account-settings-avatar {
            width: 54px;
            height: 54px;
            border-radius: 18px;
            object-fit: cover;
            flex-shrink: 0;
        }
        .account-settings-user-copy {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        .account-settings-user-name {
            font-size: calc(16px * var(--page-font-scale));
            font-weight: 800;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .account-settings-user-meta {
            color: rgba(255, 255, 255, 0.48);
            font-size: calc(12px * var(--page-font-scale));
        }
        .settings-section-title {
            width: min(100%, 520px);
            margin: 18px auto 8px;
            padding-left: 6px;
            color: rgba(255, 255, 255, 0.42);
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 700;
        }
        .settings-list-card {
            overflow: hidden;
            border-radius: 15px;
            background: #202020;
            border: 1px solid rgba(255, 255, 255, 0.06);
        }
        .settings-list-row {
            width: 100%;
            min-height: 54px;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 0 15px;
            border: none;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            background: transparent;
            color: rgba(255, 255, 255, 0.88);
            font-family: inherit;
            font-size: calc(15px * var(--page-font-scale));
            text-align: left;
            cursor: pointer;
        }
        .settings-list-row:last-child { border-bottom: none; }
        .settings-list-row > span:first-child {
            flex: 1;
            min-width: 0;
        }
        .settings-row-value {
            color: rgba(255, 255, 255, 0.46);
            font-size: calc(13px * var(--page-font-scale));
            white-space: nowrap;
        }
        .settings-row-arrow {
            color: rgba(255, 255, 255, 0.3);
            font-size: 24px;
            line-height: 1;
        }
        .settings-update-badge {
            display: none;
            padding: 2px 6px;
            border-radius: 999px;
            background: rgba(255, 107, 0, 0.18);
            color: #ffd1ad;
            border: 1px solid rgba(255, 107, 0, 0.36);
            font-size: calc(11px * var(--page-font-scale));
            font-weight: 700;
        }
        .settings-update-badge.show { display: inline-flex; }
        .settings-update-card {
            display: none;
            margin-top: 14px;
            padding: 14px 15px;
            border-radius: 15px;
            background: rgba(255, 107, 0, 0.1);
            border: 1px solid rgba(255, 107, 0, 0.24);
        }
        .settings-update-card.show { display: block; }
        .settings-update-title {
            color: var(--text-primary);
            font-size: calc(14px * var(--page-font-scale));
            font-weight: 800;
            margin-bottom: 6px;
        }
        .settings-update-desc {
            color: rgba(255, 255, 255, 0.66);
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.55;
            margin-bottom: 12px;
        }
        .settings-update-btn {
            display: none;
            align-items: center;
            justify-content: center;
            min-height: 38px;
            border-radius: 11px;
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: var(--white);
            text-decoration: none;
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 800;
        }
        .settings-update-btn.show { display: flex; }
        .account-profile-page {
            display: none;
            flex: 1;
            min-height: 0;
            flex-direction: column;
        }
        .account-settings-panel.profile-edit .account-profile-page {
            display: flex;
        }
        .profile-save-btn {
            position: absolute;
            right: calc(14px + env(safe-area-inset-right, 0px));
            bottom: 10px;
            min-width: 62px;
            height: 34px;
            padding: 0 14px;
            border: none;
            border-radius: 10px;
            background: rgba(37, 99, 235, 0.86);
            color: rgba(255, 255, 255, 0.9);
            font-family: inherit;
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 750;
            cursor: pointer;
        }
        .profile-edit-scroll {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 28px calc(18px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
        }
        .profile-edit-avatar {
            display: block;
            width: 92px;
            height: 92px;
            margin: 0 auto 28px;
            border-radius: 30px;
            object-fit: cover;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        .profile-edit-card {
            width: min(100%, 520px);
            margin: 0 auto;
            padding: 16px 18px;
            border-radius: 16px;
            background: #202020;
            border: 1px solid rgba(255, 255, 255, 0.06);
        }
        .profile-edit-label {
            display: block;
            color: rgba(255, 255, 255, 0.74);
            font-size: calc(13px * var(--page-font-scale));
            font-weight: 750;
            margin-bottom: 8px;
        }
        .profile-edit-input,
        .profile-edit-textarea {
            width: 100%;
            border: none;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 0;
            background: transparent;
            color: rgba(255, 255, 255, 0.9);
            font-family: inherit;
            font-size: max(16px, calc(15px * var(--page-font-scale)));
            line-height: 1.5;
            padding: 8px 0 14px;
            margin-bottom: 18px;
            outline: none;
        }
        .profile-edit-textarea {
            min-height: 70px;
            resize: none;
            margin-bottom: 0;
        }
        .profile-edit-input:focus,
        .profile-edit-textarea:focus {
            border-bottom-color: rgba(255, 107, 0, 0.52);
        }
        .profile-edit-hint {
            width: min(100%, 520px);
            margin: 14px auto 0;
            color: rgba(255, 255, 255, 0.32);
            text-align: center;
            font-size: calc(11px * var(--page-font-scale));
            line-height: 1.6;
        }
        .settings-logout-btn {
            display: block;
            min-height: 54px;
            margin-top: 22px;
            border: none;
            border-radius: 15px;
            background: #202020;
            color: rgba(255, 255, 255, 0.88);
            font-family: inherit;
            font-size: calc(15px * var(--page-font-scale));
            font-weight: 750;
            cursor: pointer;
        }
        .settings-footer-note {
            width: min(100%, 520px);
            margin: 14px auto 0;
            color: rgba(255, 255, 255, 0.3);
            text-align: center;
            font-size: calc(11px * var(--page-font-scale));
            line-height: 1.7;
        }
        /* 关闭时禁用点击命中，避免全屏层挡在标题栏上导致「点配置无反应」 */
        .settings-panel { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-dark); z-index: 200; overflow-y: auto; transform: translateX(100%); transition: transform 0.3s; pointer-events: none; }
        .settings-panel.show { transform: translateX(0); pointer-events: auto; }
        .settings-header { background: linear-gradient(180deg, #3D4852 0%, #2D3436 100%); color: var(--white); padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--primary); }
        .settings-header h2 { margin: 0; font-size: calc(18px * var(--page-font-scale)); font-weight: 600; }
        .back-btn { width: 32px; height: 32px; background: rgba(255,255,255,0.1); border: 1px solid #555; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
        .back-btn svg { width: 18px; height: 18px; fill: var(--white); }
        .settings-content { padding: 20px; background: var(--bg-panel); }
        .form-group { margin-bottom: 16px; }
        .form-label { display: block; font-size: calc(14px * var(--page-font-scale)); font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
        .form-input { width: 100%; padding: 12px 14px; border: 2px solid #444; border-radius: 6px; font-size: calc(14px * var(--page-font-scale)); background: #1E272E; color: var(--text-primary); }
        .form-input:focus { outline: none; border-color: var(--primary); }
        .save-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--white); border: none; border-radius: 6px; font-size: calc(15px * var(--page-font-scale)); font-weight: 700; cursor: pointer; margin-bottom: 10px; }
        .test-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, #00B894, #00A085); color: var(--white); border: none; border-radius: 6px; font-size: calc(15px * var(--page-font-scale)); font-weight: 700; cursor: pointer; margin-bottom: 10px; }
        .test-btn.testing { background: #F39C12; }
        .test-btn:disabled { background: #636E72; cursor: not-allowed; }
        .status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 4px; font-size: calc(12px * var(--page-font-scale)); font-weight: 600; margin-bottom: 16px; background: #1E272E; border: 1px solid #444; }
        .status-badge.connected { background: #14532d; color: #22c55e; border-color: #22c55e; }
        .status-badge.connecting { background: #78350f; color: #fbbf24; border-color: #fbbf24; }
        .status-badge.disconnected { background: #7f1d1d; color: #ef4444; border-color: #ef4444; }
        .status-dot { width: 8px; height: 8px; border-radius: 50%; }
        .status-badge.connected .status-dot { background: #10B981; }
        .status-badge.connecting .status-dot { background: #F59E0B; }
        .status-badge.disconnected .status-dot { background: #EF4444; }
        .toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: var(--white); padding: 10px 18px; border-radius: 8px; font-size: calc(13px * var(--page-font-scale)); z-index: 300; display: none; }
        .toast.show { display: block; }
        
        /* 表格最小渲染能力：仅保证能看清，不做语义列宽/智能约束 */
        .message.agent .msg-content .md-prose {
            min-width: 0;
        }
        .md-table-wrapper {
            display: block;
            width: 100%;
            max-width: 100%;
            min-width: 0;
            overflow-x: auto;
            margin: 8px 0;
            -webkit-overflow-scrolling: touch;
        }
        .message.agent .msg-content .md-prose table,
        .message.agent .msg-content .md-table {
            border-collapse: collapse;
            table-layout: auto;
            /* 按内容自然列宽；至少铺满气泡宽度，超出由 wrapper 横向滚动 */
            width: max-content;
            min-width: 100%;
            max-width: none;
        }
        .message.agent .msg-content .md-prose th,
        .message.agent .msg-content .md-prose td,
        .message.agent .msg-content .md-table th,
        .message.agent .msg-content .md-table td {
            border: 1px solid rgba(255, 255, 255, 0.16);
            padding: 8px 10px;
            text-align: left;
            vertical-align: top;
            color: var(--white);
            white-space: normal;
            min-width: 0;
            max-width: 28em;
            overflow-wrap: break-word;
            word-break: break-word;
        }
        .message.agent .msg-content .md-prose th,
        .message.agent .msg-content .md-table th {
            font-weight: 600;
            background: rgba(255, 255, 255, 0.04);
        }
        /* 表格内行内代码：勿 nowrap，避免撑破单元格或看起来像被裁切 */
        .message.agent .msg-content .md-prose th code,
        .message.agent .msg-content .md-prose td code,
        .message.agent .msg-content .md-table th code,
        .message.agent .msg-content .md-table td code {
            white-space: normal;
            word-break: break-word;
        }
        
        .msg-citations { margin-top: 10px; border-top: 1px solid #3d4852; padding-top: 8px; }
        .msg-citations summary {
            cursor: pointer; list-style: none; font-size: calc(12px * var(--page-font-scale)); color: var(--text-secondary);
            user-select: none; padding: 4px 0;
        }
        .message.agent .msg-citations summary { font-size: var(--reply-font-cite-summary); color: var(--white); }
        .msg-citations summary::-webkit-details-marker { display: none; }
        .msg-citations summary::before { content: '▸ '; color: var(--primary); }
        .msg-citations[open] summary::before { content: '▾ '; }
        .msg-citations summary:hover { color: var(--primary); }
        .message.agent .msg-citations summary::before { color: var(--white); }
        .message.agent .msg-citations summary:hover { color: var(--white); opacity: 0.9; }
        .msg-citations-body {
            margin-top: 8px;
            padding: 10px 12px;
            background: transparent;
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 4px;
            max-height: 280px;
            overflow-y: auto;
            white-space: pre-wrap;
            word-break: break-word;
            font-size: calc(12px * var(--page-font-scale));
            line-height: 1.45;
            color: var(--text-secondary);
        }
        .message.agent .msg-citations-body {
            font-size: var(--reply-font-cite-body);
            line-height: var(--reply-line-cite-body);
            color: var(--white);
        }
        
        .msg-code-block {
            margin: 8px 0;
            font-family: var(--font-mono);
            font-size: var(--reply-font-code);
            line-height: var(--reply-line-code);
            overflow-x: auto;
            white-space: pre;
        }
        .msg-code-block > code {
            display: block;
            white-space: pre;
            font-family: inherit;
            font-size: inherit;
            line-height: inherit;
            background: transparent;
            border: none;
            padding: 0;
            color: inherit;
        }
        .message.agent .msg-content .msg-code-block {
            background: transparent;
            border: none;
            border-left: 3px solid rgba(255,255,255,0.2);
            border-radius: 0;
            padding: 8px 0 8px 12px;
            color: var(--white);
        }
        .message.user .msg-content .msg-code-block {
            background: transparent;
            border: none;
            border-left: 3px solid rgba(255,255,255,0.35);
            border-radius: 0;
            padding: 8px 0 8px 12px;
            color: inherit;
        }
        .msg-code-inline { font-family: var(--font-mono); }
        /* 行内 `代码`：无底色，仅等宽字体，与正文同色 */
        .message.agent .msg-content .msg-code-inline {
            background: transparent;
            border: none;
            border-radius: 0;
            padding: 0 2px;
            font-size: inherit;
            color: var(--white);
        }
        
        .message.user .msg-content .msg-code-inline {
            background: transparent;
            border: none;
            padding: 0 2px;
            font-size: inherit;
            color: inherit;
        }
        
        /* 修复后的图片样式 */
        .msg-img { max-width: 100%; border-radius: 4px; margin-top: 8px; border: 1px solid #555; display: block; }
        
        /* 修复后的列表样式 */
        .msg-content ul, .msg-content ol { margin: 8px 0; padding-left: 20px; }
        .msg-content li { margin: 4px 0; }
        
        /* 段落样式 */
        .msg-content p { margin: 8px 0; }
        .msg-content p:first-child { margin-top: 0; }
        .msg-content p:last-child { margin-bottom: 0; }
        
        /* 消息内容容器 */
        .msg-content { line-height: 1.72; letter-spacing: 0.01em; }
        .quick-options { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
        .quick-option-btn { padding: 6px 10px; border: 1px solid #4b5563; border-radius: 6px; background: #1f2937; color: var(--text-primary); cursor: pointer; font-size: calc(12px * var(--page-font-scale)); }
        .quick-option-btn:hover { border-color: var(--primary); color: var(--primary); }
        .quick-option-btn.selected { border-color: var(--primary); color: var(--primary); background: rgba(14, 165, 233, 0.18); }
