/* === CSS 变量: 亮色主题 === */
:root {
    --bg-page: #f5f6f8;
    --bg-surface: #fff;
    --bg-surface-alt: #fafbff;
    --bg-input: #fff;
    --bg-hover: #f3f4f6;
    --bg-active: #eef2ff;
    --bg-user-msg: #eef2ff;
    --bg-code: #f6f8fa;
    --bg-blockquote: #f9fafb;
    --bg-table-head: #f6f8fa;
    --bg-table-stripe: #f9fafb;
    --bg-badge: #e0e7ff;
    --bg-tag-on: #d1fae5;
    --bg-tag-off: #fee2e2;
    --bg-icon: #f3f4f6;
    --border: #e5e7eb;
    --border-light: #f1f2f4;
    --border-active: #c7d2fe;
    --border-code: #e1e4e8;
    --text-primary: #222;
    --text-secondary: #333;
    --text-muted: #6b7280;
    --text-hint: #9ca3af;
    --text-code: #d63384;
    --text-code-block: #24292e;
    --text-badge: #4338ca;
    --text-tag-on: #065f46;
    --text-tag-off: #991b1b;
    --text-link: #5b8def;
    --text-blockquote: #6a737d;
    --accent: #5b8def;
    --accent-hover: #4a7ce0;
    --shadow: rgba(0,0,0,0.08);
}

/* === CSS 变量: 暗黑主题 === */
[data-theme="dark"] {
    --bg-page: #0f1117;
    --bg-surface: #1a1b23;
    --bg-surface-alt: #21222d;
    --bg-input: #21222d;
    --bg-hover: #2a2b36;
    --bg-active: #252a3a;
    --bg-user-msg: #252a3a;
    --bg-code: #2a2b36;
    --bg-blockquote: #1e1f28;
    --bg-table-head: #21222d;
    --bg-table-stripe: #1e1f28;
    --bg-badge: #2e3450;
    --bg-tag-on: #1a3a2a;
    --bg-tag-off: #3a1a1a;
    --bg-icon: #2a2b36;
    --border: #2e3040;
    --border-light: #252636;
    --border-active: #4a5080;
    --border-code: #2e3040;
    --text-primary: #e4e5eb;
    --text-secondary: #c8c9d0;
    --text-muted: #8b8d9a;
    --text-hint: #5f6170;
    --text-code: #f472b6;
    --text-code-block: #d1d5db;
    --text-badge: #a5b4fc;
    --text-tag-on: #6ee7b7;
    --text-tag-off: #fca5a5;
    --text-link: #7ba4f7;
    --text-blockquote: #8b8d9a;
    --accent: #5b8def;
    --accent-hover: #7ba4f7;
    --shadow: rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text-primary); background: var(--bg-page); }
body { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 240px; background: var(--bg-surface); border-right: 1px solid var(--border);
    padding: 16px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #5b8def, #7c3aed); }
.logo b { color: #5b8def; }

.btn-primary {
    background: var(--accent); color: #fff; border: none; padding: 7px 14px; border-radius: 6px;
    cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
    background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); padding: 8px 12px;
    border-radius: 6px; cursor: pointer; font-size: 13px; width: 100%;
}
.btn-ghost.small { padding: 6px 10px; font-size: 12px; }
.btn-ghost:hover { background: var(--bg-active); }

.panel h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

/* 模型选择折叠面板 */
.panel-models .panel-header {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 8px 10px; margin: 0 -10px; border-radius: 8px;
    user-select: none; background: var(--bg-active);
    border: 1px solid var(--border-active);
    transition: background 0.15s ease;
}
.panel-models .panel-header:hover { background: var(--bg-hover); }
.panel-models .panel-header h4 { margin-bottom: 0; flex-shrink: 0; color: var(--accent); font-size: 13px; }
.panel-models .model-summary {
    flex: 1; font-size: 11px; color: var(--accent); text-align: right; font-weight: 500;
}
.panel-models .panel-arrow {
    color: var(--accent); transition: transform 0.2s ease; flex-shrink: 0;
}
.panel-models.open .panel-header { background: transparent; border-color: transparent; }
.panel-models.open .panel-header h4 { color: var(--text-muted); }
.panel-models.open .model-summary { color: var(--text-hint); font-weight: 400; }
.panel-models.open .panel-arrow { color: var(--text-hint); transform: rotate(180deg); }
.panel-models .model-list { margin-top: 8px; }

.model-list { display: flex; flex-direction: column; gap: 4px; }
.model-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
    cursor: pointer; font-size: 13px; border: 1px solid transparent;
}
.model-item:hover { background: var(--bg-hover); }
.model-item.active { background: var(--bg-active); border-color: var(--border-active); }
.model-item.disabled { opacity: 0.45; cursor: not-allowed; }
.model-item-icon {
    display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; flex-shrink: 0;
}
.model-item-icon svg { width: 16px; height: 16px; }
.model-item-icon img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.model-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-item .tag { font-size: 10px; padding: 1px 5px; border-radius: 3px; margin-left: auto; flex-shrink: 0; }
.model-item .tag.on { background: var(--bg-tag-on); color: var(--text-tag-on); }
.model-item .tag.off { background: var(--bg-tag-off); color: var(--text-tag-off); }

.rag-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.upload-box { display: flex; flex-direction: column; gap: 6px; }
.upload-status { font-size: 11px; color: var(--text-muted); min-height: 14px; }

.session-id { font-size: 11px; color: var(--text-hint); margin-bottom: 6px; word-break: break-all; }

/* 对话历史列表 */
.panel-history {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.history-list {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
    margin: 0 -4px; padding: 0 4px;
}
.history-empty {
    color: var(--text-hint); font-size: 12px; text-align: center; padding: 20px 0;
}
.history-item {
    padding: 8px 10px; border-radius: 6px; cursor: pointer;
    border: 1px solid transparent; transition: background 0.15s ease;
}
.history-item:hover { background: var(--bg-hover); }
.history-item:hover .btn-del-history { opacity: 1; }
.history-item.active { background: var(--bg-active); border-color: var(--border-active); }
.history-title {
    font-size: 13px; color: var(--text-secondary); line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 4px;
}
.history-meta {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; color: var(--text-hint);
}
.btn-del-history {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-hint); font-size: 16px; line-height: 1;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s ease, background 0.15s ease;
    padding: 0;
}
.btn-del-history:hover { background: var(--bg-tag-off); color: #dc2626; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    padding: 8px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-size: 15px; font-weight: 600; }
.topbar .hint { color: var(--text-hint); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* 主题切换按钮 */
.btn-theme {
    background: var(--bg-hover); border: 1px solid var(--border); cursor: pointer;
    width: 30px; height: 30px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: background 0.15s, color 0.15s;
}
.btn-theme:hover { background: var(--bg-active); color: var(--accent); }
.btn-theme .icon-moon { display: none; }
[data-theme="dark"] .btn-theme .icon-sun { display: none; }
[data-theme="dark"] .btn-theme .icon-moon { display: inline-block; }

.columns {
    flex: 1; display: grid; gap: 6px; padding: 6px; overflow: auto;
}
/* 1个模型: 单列 */
.columns.cols-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
/* 2个模型: 两列并排 */
.columns.cols-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
/* 3个模型: 一行三列 */
.columns.cols-3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }
/* 4个模型: 上面2个下面2个 */
.columns.cols-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
/* 5个及以上: 每行最多 3 个, 自动换行 */
.columns.cols-5plus {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(280px, 1fr);
    overflow-y: auto;
}
.col {
    background: var(--bg-surface); border-radius: 10px; border: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.col.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}
.col.drag-over {
    border: 2px dashed var(--accent);
    background: var(--bg-active);
}
.col-head {
    padding: 4px 10px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 4px;
    font-size: 13px; font-weight: 500;
    background: var(--bg-surface-alt);
    cursor: grab;
    user-select: none;
}
.col-head .head-spacer { flex: 1; }
.col-head:active {
    cursor: grabbing;
}
.col-head .model-icon {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 4px;
    background: var(--bg-icon); flex-shrink: 0;
}
.col-head .model-icon svg { width: 16px; height: 16px; }
.col-head .model-icon svg {
    width: 20px; height: 20px;
}
.col-head .model-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 模型切换下拉 */
.model-switcher {
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    padding: 2px 6px; border-radius: 6px; position: relative;
    transition: background 0.15s ease;
}
.model-switcher:hover { background: var(--bg-hover); }
.model-switcher .model-name { white-space: nowrap; }
.model-switcher .switcher-arrow {
    color: var(--text-hint); flex-shrink: 0; transition: transform 0.2s ease;
}
.switch-dropdown {
    display: none; position: absolute; top: 100%; left: 0; margin-top: 4px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 4px 16px var(--shadow);
    min-width: 160px; z-index: 100; padding: 4px; overflow: hidden;
}
.switch-dropdown.show { display: block; }
.switch-option {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    border-radius: 6px; cursor: pointer; font-size: 13px;
    color: var(--text-secondary); transition: background 0.12s ease;
}
.switch-option:hover { background: var(--bg-hover); }
.switch-option.current { background: var(--bg-active); color: var(--accent); font-weight: 500; }
.switch-option-icon {
    display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; flex-shrink: 0;
}
.switch-option-icon svg { width: 16px; height: 16px; }
.switch-option-icon img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.col-head .badge { font-size: 10px; padding: 2px 6px; border-radius: 3px; background: var(--bg-badge); color: var(--text-badge); }

/* 放大按钮 */
.col-head .btn-expand {
    background: transparent; border: none; cursor: pointer;
    width: 22px; height: 22px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); flex-shrink: 0; padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.col-head .btn-expand:hover {
    background: var(--bg-active); color: var(--text-badge);
}

/* 关闭窗口按钮 */
.col-head .btn-close-col {
    background: transparent; border: none; cursor: pointer;
    width: 22px; height: 22px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-hint); flex-shrink: 0; padding: 0;
    margin-left: 2px;
    opacity: 0; transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.col-head:hover .btn-close-col { opacity: 1; }
.col-head .btn-close-col:hover { background: var(--bg-tag-off); color: #dc2626; }
.col:hover .btn-close-col { opacity: 1; }
.col-head .btn-close-col:hover { background: var(--danger-light); color: var(--danger); }
.col-head .btn-expand .icon-collapse { display: none; }
.col.expanded .col-head .btn-expand .icon-expand { display: none; }
.col.expanded .col-head .btn-expand .icon-collapse { display: inline-block; }

/* 放大状态：占满整个聊天区 */
.columns.has-expanded {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}
.columns.has-expanded .col {
    display: none;
}
.columns.has-expanded .col.expanded {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 1 / -1;
}

/* 总结区域 */
.summary-col {

    grid-column: 1 / -1; border: 1px solid var(--accent);
    background: var(--bg-surface);
}
.summary-col .col-body { white-space: normal; max-height: 400px; }
.summary-head { background: var(--bg-active) !important; }
.col-body { flex: 1; overflow-y: auto; padding: 12px 14px; font-size: 14px; line-height: 1.7; white-space: normal; word-break: break-word; }
.col-body .u-msg { background: var(--bg-user-msg); padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }
.col-body .a-msg { margin-bottom: 10px; }
.col-body .cursor::after { content: "▊"; color: var(--accent); animation: blink 1s infinite; }

/* Token 用量标签 */
.token-badge {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 8px; padding: 3px 10px; border-radius: 12px;
    background: var(--bg-badge); color: var(--text-badge);
    font-size: 11px; line-height: 1.4; opacity: 0.85;
}
.token-badge b { font-weight: 600; }
.token-badge .token-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; margin-right: 2px;
}

/* Markdown 样式 */
.col-body .a-msg h1, .col-body .a-msg h2, .col-body .a-msg h3,
.col-body .a-msg h4, .col-body .a-msg h5, .col-body .a-msg h6 {
    margin: 0.8em 0 0.4em 0; font-weight: 600; line-height: 1.3;
}
.col-body .a-msg h1 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.col-body .a-msg h2 { font-size: 1.3em; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3em; }
.col-body .a-msg h3 { font-size: 1.15em; }
.col-body .a-msg h4 { font-size: 1em; }

.col-body .a-msg p { margin: 0.5em 0; }

.col-body .a-msg code {
    background: var(--bg-code); padding: 2px 6px; border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace; font-size: 0.9em;
    color: var(--text-code);
}

.col-body .a-msg pre {
    background: var(--bg-code); border: 1px solid var(--border-code); border-radius: 6px;
    padding: 12px; margin: 0.8em 0; overflow-x: auto;
}
.col-body .a-msg pre code {
    background: none; padding: 0; color: var(--text-code-block); font-size: 0.85em;
}

.col-body .a-msg ul, .col-body .a-msg ol {
    margin: 0.5em 0; padding-left: 2em;
}
.col-body .a-msg li { margin: 0.3em 0; }

.col-body .a-msg blockquote {
    border-left: 4px solid var(--border); padding-left: 1em; margin: 0.8em 0;
    color: var(--text-blockquote); background: var(--bg-blockquote); padding: 0.5em 1em; border-radius: 0 4px 4px 0;
}

.col-body .a-msg table {
    border-collapse: collapse; width: 100%; margin: 0.8em 0;
}
.col-body .a-msg table th, .col-body .a-msg table td {
    border: 1px solid var(--border); padding: 6px 12px; text-align: left;
}
.col-body .a-msg table th { background: var(--bg-table-head); font-weight: 600; }
.col-body .a-msg table tr:nth-child(even) { background: var(--bg-table-stripe); }

.col-body .a-msg a { color: var(--text-link); text-decoration: none; }
.col-body .a-msg a:hover { text-decoration: underline; }

.col-body .a-msg hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

.col-body .a-msg img { max-width: 100%; border-radius: 4px; }
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* 总结栏 */
.summarize-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 16px; background: var(--bg-surface); border-top: 1px solid var(--border);
    gap: 10px;
}
.summarize-left { display: flex; align-items: center; gap: 8px; }
.summarize-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.summarize-select {
    padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text-primary); font-size: 12px;
    outline: none; cursor: pointer;
}
.summarize-select:focus { border-color: var(--accent); }
.btn-summarize {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 12px; border: 1px solid var(--accent); border-radius: 6px;
    background: transparent; color: var(--accent); font-size: 12px; font-weight: 500;
    cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.btn-summarize:hover { background: var(--accent); color: #fff; }
.btn-summarize:disabled { opacity: 0.5; cursor: not-allowed; }

.input-area {
    border-top: 1px solid var(--border); background: var(--bg-surface);
    padding: 12px 18px 14px; box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
    display: flex; gap: 10px; align-items: flex-end;
}
.input-wrapper {
    flex: 1; display: flex; flex-direction: column; gap: 0;
}
.input-area textarea {
    flex: 1; border: 1.5px solid var(--border); border-radius: 12px;
    padding: 12px 14px; min-height: 48px;
    font-size: 15px; font-family: inherit; resize: none; outline: none;
    background: var(--bg-input); color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-area textarea::placeholder { color: var(--text-hint); }
.input-area textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15), 0 1px 3px rgba(0,0,0,0.03);
}
.input-actions { display: flex; gap: 8px; align-items: flex-end; }

/* 发送按钮:强视觉重心,渐变 + 图标 */
.input-area .btn-primary {
    min-width: 96px; height: 48px;
    padding: 0 20px; border-radius: 12px;
    font-size: 15px; font-weight: 600; letter-spacing: 1px;
    background: linear-gradient(135deg, #5b8def 0%, #7c3aed 100%);
    box-shadow: 0 4px 12px rgba(91, 141, 239, 0.35);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.input-area .btn-primary:hover {
    background: linear-gradient(135deg, #5b8def 0%, #7c3aed 100%);
    filter: brightness(1.08);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.45);
    transform: translateY(-1px);
}
.input-area .btn-primary:active { transform: translateY(0); filter: brightness(0.95); }
.input-area .btn-primary:disabled {
    background: var(--border); box-shadow: none; cursor: not-allowed;
    filter: none; transform: none; color: var(--text-hint);
}

/* 文档上传按钮 */
.btn-doc {
    background: var(--bg-hover); border: 1px solid var(--border); cursor: pointer;
    width: 44px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all 0.15s ease;
}
.btn-doc:hover { background: var(--bg-active); color: var(--accent); border-color: var(--accent); }

/* 展开/收起按钮 */
.btn-expand-input {
    background: var(--bg-hover); border: 1px solid var(--border); cursor: pointer;
    width: 44px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all 0.15s ease;
}
.btn-expand-input:hover { background: var(--bg-active); color: var(--accent); border-color: var(--accent); }
.btn-expand-input .icon-collapse-input { display: none; }
.input-area.expanded .btn-expand-input .icon-expand-input { display: none; }
.input-area.expanded .btn-expand-input .icon-collapse-input { display: inline-block; }
.input-area.expanded .btn-expand-input { background: var(--bg-active); color: var(--accent); }

/* 文档预览条 */
.doc-preview {
    display: flex; align-items: center; gap: 6px; padding: 6px 10px;
    background: var(--bg-active); border: 1px solid var(--border-active);
    border-radius: 8px 8px 0 0; border-bottom: none; font-size: 13px;
    color: var(--text-secondary);
}
.doc-preview + textarea { border-radius: 0 0 8px 8px; }
.doc-icon { font-size: 16px; }
.doc-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-remove {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 18px; line-height: 1;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.doc-remove:hover { color: #dc2626; background: var(--bg-tag-off); }

/* === 模型独立输入框 === */
.col-input-area {
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface-alt);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 8px;
    animation: slideUp 0.2s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.col-input-area .model-input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 13px; font-family: inherit;
    resize: none; outline: none; line-height: 1.5;
    background: var(--bg-input); color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.col-input-area .model-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.15);
}
.col-input-area .model-input::placeholder {
    color: var(--text-hint); font-size: 12px;
}
.col-input-area .input-actions {
    display: flex; gap: 6px; justify-content: flex-end; align-items: center;
}
.col-input-area .btn-send {
    background: var(--accent); color: #fff; border: none;
    padding: 5px 16px; border-radius: 6px; font-size: 12px;
    font-weight: 500; cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.col-input-area .btn-send:hover {
    background: var(--accent-hover); transform: translateY(-1px);
}
.col-input-area .btn-send:active { transform: translateY(0); }
.col-input-area .btn-cancel {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
    padding: 5px 12px; border-radius: 6px; font-size: 12px;
    cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.col-input-area .btn-cancel:hover {
    background: var(--bg-hover); color: var(--text-secondary);
}

/* 聊天框底部的展开对话按钮 */
.col-footer {
    display: flex; align-items: center; justify-content: center;
    padding: 6px 0; background: transparent;
    position: relative;
}
.btn-open-input {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); border: 1px solid var(--border);
    cursor: pointer; color: var(--text-hint);
    padding: 4px 28px; border-radius: 8px;
    transition: all 0.2s ease;
    opacity: 0;
}
.col:hover .btn-open-input { opacity: 1; }
.btn-open-input:hover {
    color: var(--text-secondary); background: var(--bg-active);
    border-color: var(--border-active);
}
.btn-open-input svg { flex-shrink: 0; }

/* === 移动端汉堡菜单按钮 === */
.btn-menu {
    display: none; background: var(--bg-hover); border: 1px solid var(--border);
    cursor: pointer; width: 34px; height: 34px; border-radius: 6px;
    align-items: center; justify-content: center;
    color: var(--text-muted); transition: background 0.15s, color 0.15s;
}
.btn-menu:hover { background: var(--bg-active); color: var(--accent); }

/* 侧边栏遮罩 */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 199; opacity: 0; transition: opacity 0.25s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* === 移动端响应式 (@media max-width: 768px) === */
@media (max-width: 768px) {
    body { flex-direction: column; }

    /* 侧边栏：抽屉式 */
    .sidebar {
        position: fixed; left: -260px; top: 0; bottom: 0; width: 250px;
        z-index: 200; transition: left 0.3s ease;
        box-shadow: none;
    }
    .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }

    /* 显示汉堡菜单按钮 */
    .btn-menu { display: flex; }

    /* 主区域占满 */
    .main { width: 100%; height: 100vh; }

    /* 顶栏 */
    .topbar { padding: 6px 12px; }
    .topbar h2 { font-size: 14px; }

    /* 聊天区域：单列纵向滚动 */
    .columns, .columns.cols-1, .columns.cols-2,
    .columns.cols-3, .columns.cols-4, .columns.cols-5plus {
        grid-template-columns: 1fr !important;
        grid-auto-flow: row !important;
        grid-auto-columns: unset !important;
        grid-template-rows: none !important;
        overflow-x: hidden; overflow-y: auto;
        padding: 4px; gap: 4px;
    }
    .col { min-height: 300px; max-height: 50vh; }

    /* 移动端放大：占满整个聊天区 */
    .columns.has-expanded {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr !important;
        overflow: hidden;
    }
    .columns.has-expanded .col {
        display: none;
    }
    .columns.has-expanded .col.expanded {
        display: flex;
        min-height: unset; max-height: unset;
        height: 100%;
    }

    /* 总结区域 */
    .summary-col .col-body { max-height: 300px; }

    /* 输入区域 */
    .input-area { padding: 6px 10px; gap: 6px; }
    .input-area textarea { font-size: 16px; }
    .input-area .btn-primary { min-width: 60px; font-size: 13px; padding: 7px 10px; }

    /* 总结栏 */
    .summarize-bar { padding: 4px 10px; flex-wrap: wrap; gap: 6px; }

    /* 底部展开按钮在手机端始终可见 */
    .btn-open-input { opacity: 0.7; }
    .col:hover .btn-open-input { opacity: 1; }

    /* 关闭按钮在手机端始终可见 */
    .col-head .btn-close-col { opacity: 0.8; }
}

/* === 用户面板 === */
.panel-user {
    margin-top: auto; border-top: 1px solid var(--border);
    padding-top: 12px;
}
.user-info {
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.user-detail { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-tokens { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-actions a { text-decoration: none; text-align: center; }

/* === 登录弹窗 === */
.login-modal-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.login-modal {
    background: var(--bg-surface); border-radius: 16px; padding: 32px 28px;
    width: 380px; max-width: 90vw; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2); position: relative;
}
.login-modal-close {
    position: absolute; top: 12px; right: 16px; background: none; border: none;
    font-size: 22px; color: var(--text-muted); cursor: pointer; line-height: 1;
}
.login-modal-close:hover { color: var(--text-primary); }
.login-modal-icon { font-size: 40px; margin-bottom: 12px; }
.login-modal h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.login-modal p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
.login-modal-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-modal-primary {
    display: block; padding: 11px 0; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
    text-decoration: none; text-align: center; cursor: pointer; transition: background 0.2s;
}
.btn-modal-primary:hover { background: #4f46e5; }
.btn-modal-ghost {
    padding: 9px 0; border-radius: 8px; border: 1.5px solid var(--border);
    background: transparent; color: var(--text-muted); font-size: 14px;
    cursor: pointer; transition: all 0.2s;
}
.btn-modal-ghost:hover { border-color: var(--accent); color: var(--accent); }
}