/* ========== Design tokens ========== */
:root {
  color-scheme: dark;
  --bg: #0e0f13;
  --sidebar: #131419;
  --surface: #17181e;
  --surface-2: #1d1f26;
  --surface-3: #252731;
  --line: #262833;
  --line-strong: #343746;
  --text: #ececf1;
  --text-2: #b4b6c2;
  --muted: #7d8090;
  --accent: #7c8cff;
  --accent-2: #a78bfa;
  --accent-soft: rgba(124, 140, 255, .14);
  --accent-grad: linear-gradient(135deg, #6f7dff 0%, #a07bff 100%);
  --user-bubble: #262a3a;
  --green: #3ecf8e;
  --yellow: #f2b84b;
  --red: #f26d6d;
  --code-bg: #0b0c10;
  --code-head: #15161c;
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-md: 0 10px 32px rgba(0, 0, 0, .35);
  --composer-shadow: 0 8px 40px rgba(0, 0, 0, .38), 0 0 0 1px var(--line);
  --radius: 14px;
  --sb-w: 272px;
  --content-w: 800px;
}
:root.light {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --surface-3: #ebebf0;
  --line: #e8e8ee;
  --line-strong: #d7d8e0;
  --text: #16171d;
  --text-2: #464855;
  --muted: #8a8c99;
  --accent: #4f5fe8;
  --accent-2: #7c5cf0;
  --accent-soft: rgba(79, 95, 232, .09);
  --accent-grad: linear-gradient(135deg, #4f5fe8 0%, #8660f2 100%);
  --user-bubble: #eef0fb;
  --code-bg: #f7f8fa;
  --code-head: #eef0f3;
  --shadow-lg: 0 24px 64px rgba(20, 22, 40, .16), 0 0 0 1px rgba(20, 22, 40, .05);
  --shadow-md: 0 10px 30px rgba(20, 22, 40, .10);
  --composer-shadow: 0 6px 28px rgba(20, 22, 40, .08), 0 0 0 1px var(--line-strong);
}

/* ========== Base ========== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

input:not([type=checkbox]), textarea, select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2);
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:not([type=checkbox]):focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--muted); }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8090' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; cursor: pointer; }
textarea { resize: vertical; }

/* ========== Buttons ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 10px; font-weight: 550; font-size: 13.5px; transition: background .15s, border-color .15s, color .15s, transform .05s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 4px 14px rgba(111, 125, 255, .28); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 16%, transparent); }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::before { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.ghost-icon { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; color: var(--muted); transition: background .15s, color .15s; }
.ghost-icon:hover { background: var(--surface-3); color: var(--text); }
.ghost-icon.sm { width: 28px; height: 28px; border-radius: 7px; }
.ghost-icon.sm svg { width: 16px; height: 16px; }

/* ========== App layout: 左右布局 ========== */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar { width: var(--sb-w); flex: 0 0 var(--sb-w); background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; transition: margin-left .25s ease, transform .25s ease; }
.app.sb-collapsed .sidebar { margin-left: calc(var(--sb-w) * -1); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }

/* Sidebar */
.sb-top { padding: 14px 12px 8px; display: grid; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--accent-grad); box-shadow: 0 6px 18px rgba(111, 125, 255, .35); }
.brand-logo svg { width: 20px; height: 20px; }
.brand-text { display: grid; line-height: 1.25; flex: 1; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .01em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }
.new-chat { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 550; transition: border-color .15s, background .15s; }
.new-chat:hover { border-color: var(--accent); background: var(--accent-soft); }
.new-chat svg { color: var(--accent); }
.new-chat kbd { margin-left: auto; font: 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 5px; padding: 3px 5px; }
.sb-search { position: relative; }
.sb-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.sb-search input { height: 36px; padding-left: 33px; border-radius: 10px; background: transparent; border-color: transparent; font-size: 13px; }
.sb-search input:hover { background: var(--surface-2); }
.sb-section-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px 16px; font-size: 12px; color: var(--muted); font-weight: 600; }
.sb-section-actions { display: flex; gap: 2px; }
.sb-section-actions .active { color: var(--accent); background: var(--accent-soft); }
.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 8px; }
.conv-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }
.conv, .conv-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; transition: background .12s; margin-bottom: 2px; }
.conv:hover, .conv-item:hover { background: var(--surface-2); }
.conv.active, .conv-item.selected { background: var(--surface-3); }
.conv.active::before, .conv-item.selected::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent-grad); }
.conv-item.agent-mode::before { display: none; }
.conv .conv-check, .conv-item .conv-check { display: none; }
.managing .conv .conv-check, .managing .conv-item .conv-check { display: block; }
.avatar { position: relative; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-weight: 650; font-size: 13px; color: #fff; flex: 0 0 auto; }
.avatar .badge-dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sidebar); background: var(--yellow); }
.avatar .badge-dot.online { background: var(--green); }
.avatar .badge-dot.error, .avatar .badge-dot.offline { background: var(--muted); }
.avatar .badge-dot.error { background: var(--red); }
.conv-meta { flex: 1; min-width: 0; display: grid; gap: 1px; }
.conv-line { display: flex; align-items: baseline; gap: 6px; }
.conv-name { flex: 1; min-width: 0; font-weight: 550; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.conv-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tag { font-size: 10px; padding: 0 5px; border-radius: 4px; background: rgba(62, 207, 142, .14); color: var(--green); flex: 0 0 auto; line-height: 16px; }
.conv-tag.agent { background: rgba(124, 140, 255, .18); color: var(--accent); display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.conv-tag.agent svg { width: 12px; height: 12px; }
.conv-actions { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); opacity: 0; transition: opacity .12s; }
.conv:hover .conv-actions,
.conv-item:hover .conv-actions,
.conv-actions:hover,
.conv-actions:has(.conv-menu-btn.active) { opacity: 1; }
.conv-menu-btn { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); background: var(--surface-3); transition: color .12s, background .12s; position: relative; }
.conv-menu-btn svg { width: 15px; height: 15px; }
.conv-menu-btn:hover { color: var(--text); background: var(--surface-2); }
.conv-menu-btn.active { color: var(--text); background: var(--surface-2); }
.conv-dropdown { position: absolute; right: 0; top: calc(100% + 4px); min-width: 140px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-md); z-index: 1050; overflow: hidden; display: none; pointer-events: none; }
.conv-dropdown.show { display: block; pointer-events: auto; }
.conv-item:has(.conv-menu-btn.active) { z-index: 30; }
.conv-dropdown-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; color: var(--text-2); cursor: pointer; transition: background .12s, color .12s; border: none; width: 100%; text-align: left; background: transparent; }
.conv-dropdown-item svg { width: 16px; height: 16px; color: var(--muted); }
.conv-dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.conv-dropdown-item:hover svg { color: var(--text); }
.conv-dropdown-item.danger:hover { color: var(--red); }
.conv-dropdown-item.danger:hover svg { color: var(--red); }
.managing .conv-actions { display: none; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 8px 8px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); }
.bulk-all { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.bulk-actions { display: flex; gap: 6px; }
.sb-footer { display: flex; align-items: center; gap: 4px; padding: 10px; border-top: 1px solid var(--line); }
.user-card { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 11px; text-align: left; transition: background .15s; }
.user-card:hover { background: var(--surface-2); }
.avatar-user { background: var(--accent-grad); border-radius: 50%; }
.user-meta { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.user-meta strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.user-gear { color: var(--muted); width: 16px; height: 16px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(62, 207, 142, .15); }
.sb-scrim { display: none; }

/* ========== Chat header ========== */
.chat-head { height: 56px; flex: 0 0 56px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid transparent; transition: border-color .2s; }
.chat-head.scrolled { border-bottom-color: var(--line); }
.head-menu { display: none; }
.app.sb-collapsed .head-menu { display: inline-grid; }
.head-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.head-title h1 { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 6px; }
.pill { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.online { color: var(--green); background: rgba(62, 207, 142, .1); }
.pill.pending { color: var(--yellow); background: rgba(242, 184, 75, .1); }
.pill.error { color: var(--red); background: rgba(242, 109, 109, .1); }
.pill.ready { color: var(--green); background: rgba(62, 207, 142, .1); }
.pill.warn { color: var(--yellow); background: rgba(242, 184, 75, .1); cursor: pointer; }

/* ========== Messages ========== */
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: auto; }
.msg-list { max-width: var(--content-w); margin: 0 auto; padding: 24px 24px 40px; display: flex; flex-direction: column; gap: 26px; }
.msg-empty { text-align: center; color: var(--muted); padding: 80px 0 20px; }
.msg-empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.msg { display: flex; gap: 14px; animation: rise .22s ease both; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 30px; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent-grad); margin-top: 2px; }
.msg-avatar svg { width: 17px; height: 17px; }
.msg-avatar.wx { background: linear-gradient(135deg, #1fc16b, #0ea35a); }
.msg-main { flex: 1; min-width: 0; }
.msg-name { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg-name b { color: var(--text-2); font-weight: 600; }
/* 用户消息：右侧气泡 */
.msg.user { justify-content: flex-end; }
.msg.user .msg-main { flex: 0 1 auto; max-width: 78%; display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { background: var(--user-bubble); padding: 10px 16px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* 微信来信：左侧气泡 */
.msg.wx .bubble { display: inline-block; max-width: 100%; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 4px 18px 18px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* 指令回复：浅色卡片 + 纯文本 */
.msg.cmd .bubble { display: inline-block; max-width: 100%; background: var(--surface-2); border: 1px dashed var(--line-strong); padding: 10px 16px; border-radius: 4px 14px 14px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.msg.wx .bubble.is-cmd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
/* AI：无气泡、全宽 Markdown */
.msg.ai .md { overflow-wrap: anywhere; }
.msg-tools { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools, .msg.ai:last-child .msg-tools { opacity: 1; }
.msg-tools button { height: 28px; padding: 0 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.msg-tools button:hover { background: var(--surface-2); color: var(--text); }
.msg-tools svg { width: 15px; height: 15px; }
.msg-tools time { font-size: 11.5px; color: var(--muted); padding: 0 6px; align-self: center; }
/* Markdown */
.md { font-size: 15px; line-height: 1.75; color: var(--text); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.4; font-weight: 650; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--muted); }
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.md a:hover { border-bottom-color: var(--accent); }
.md blockquote { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 14px; color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 7px 12px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md :not(pre) > code { font: 13px/1.5 "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; color: color-mix(in srgb, var(--accent-2) 65%, var(--text)); }
.md img { max-width: 100%; border-radius: 10px; }

/* 代码块：头部语言 + 单独复制 */
.code-block { margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 8px 0 14px; background: var(--code-head); border-bottom: 1px solid var(--line); }
.code-lang { font: 12px/1 ui-monospace, monospace; color: var(--muted); text-transform: lowercase; }
.code-copy { height: 26px; padding: 0 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.code-copy:hover { background: var(--surface-3); color: var(--text); }
.code-copy svg { width: 14px; height: 14px; }
.code-copy.done { color: var(--green); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block pre code, .code-block pre code.hljs { font: 13px/1.65 "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: transparent; padding: 0; white-space: pre; }

/* 正在输入 */
.typing { display: inline-flex; gap: 5px; padding: 12px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }

/* ========== Welcome ========== */
.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px 80px; gap: 10px; }
.welcome-logo { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: var(--accent-grad); box-shadow: 0 16px 40px rgba(111, 125, 255, .35); margin-bottom: 10px; }
.welcome-logo svg { width: 32px; height: 32px; }
.welcome h2 { font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.welcome > p { color: var(--muted); }
.welcome-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: min(560px, 100%); margin-top: 26px; }
.welcome-card { text-align: left; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); display: grid; gap: 3px; transition: border-color .15s, transform .15s, background .15s; }
.welcome-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.welcome-card b { font-weight: 600; font-size: 14px; }
.welcome-card span { color: var(--muted); font-size: 12.5px; }

/* ========== Composer：全新输入框 ========== */
.composer-wrap { position: relative; padding: 0 24px 12px; }

/* 空会话配置卡片 - 垂直居中，不遮挡输入框 */
.empty-config { 
  max-width: 720px;
  margin: 0 auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  z-index: 5;
  pointer-events: none;
}
.empty-config[hidden] { display: none; }
.empty-config-content { pointer-events: auto; }
.empty-config-hint { font-size: 15px; color: var(--text-2); margin-bottom: 24px; text-align: center; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mode-option { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 24px; border: 1.5px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--text-2); text-align: center; transition: border-color .15s, background .15s, color .15s, transform .15s; box-shadow: 0 2px 12px rgba(0, 0, 0, .08); }
.mode-option svg { width: 36px; height: 36px; flex-shrink: 0; opacity: .7; }
.mode-option div { display: flex; flex-direction: column; gap: 4px; }
.mode-option b { display: block; font-size: 16px; font-weight: 600; color: var(--text); }
.mode-option span { display: block; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.mode-option:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); background: var(--surface-2); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 0, 0, .15); }
.mode-option.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 4px 20px rgba(111, 125, 255, .2); }
.mode-option.active svg { opacity: 1; }
.mode-option.active b { color: var(--accent); }

.composer { max-width: var(--content-w); margin: 0 auto; background: var(--surface-2); border-radius: 22px; box-shadow: var(--composer-shadow); padding: 12px 12px 10px 16px; transition: box-shadow .2s; position: relative; z-index: 10; }
.composer:focus-within { box-shadow: 0 8px 40px rgba(0, 0, 0, .3), 0 0 0 1px color-mix(in srgb, var(--accent) 55%, var(--line-strong)); }
:root.light .composer { background: var(--surface); }
.composer textarea { display: block; width: 100%; border: 0; background: transparent !important; box-shadow: none !important; padding: 4px 2px; resize: none; min-height: 28px; max-height: 240px; font-size: 15px; line-height: 1.6; overflow-y: auto; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.composer-tools { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chip-wrap { position: relative; }
.chip { height: 32px; padding: 0 10px 0 9px; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-2); font-size: 12.5px; max-width: 220px; transition: background .15s, border-color .15s, color .15s; }
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 15px; height: 15px; }
.chip .chev { width: 14px; height: 14px; opacity: .6; }
.chip.on { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); color: var(--accent); }
.composer-send { display: flex; align-items: center; gap: 10px; }
.counter { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--yellow); }
.send { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent-grad); box-shadow: 0 4px 14px rgba(111, 125, 255, .35); transition: transform .12s, filter .15s, opacity .15s, background .15s; }
.send:hover:not(:disabled) { transform: scale(1.05); filter: brightness(1.1); }
.send:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; opacity: 1; }
.send .i-spin { display: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; border-right-color: transparent; animation: spin .7s linear infinite; }
.send.busy .i-send { display: none; }
.send.busy .i-spin { display: block; }
.send.busy { background: var(--accent-grad); color: #fff; }
.composer-note { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.to-bottom { position: absolute; left: 50%; top: -52px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md); color: var(--text-2); }
.to-bottom:hover { color: var(--text); }
/* Popover 菜单 */
.menu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; min-width: 240px; max-width: 320px; max-height: 340px; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); animation: pop .14s ease both; }
.menu-group { padding: 8px 10px 4px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; text-align: left; font-size: 13px; color: var(--text); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .mi-text { flex: 1; min-width: 0; display: grid; }
.menu-item .mi-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-text small { color: var(--muted); font-size: 11.5px; }
.menu-item .mi-check { width: 16px; height: 16px; color: var(--accent); visibility: hidden; }
.menu-item.selected .mi-check { visibility: visible; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-empty { padding: 14px 10px; color: var(--muted); font-size: 12.5px; text-align: center; }
.menu-link { color: var(--accent); }

/* ========== Overlays / dialogs ========== */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(6, 7, 10, .6); backdrop-filter: blur(6px); animation: fade .15s ease both; }
.overlay.top { z-index: 60; }
.overlay.topmost { z-index: 70; }
:root.light .overlay { background: rgba(20, 22, 40, .32); }
.dialog { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease both; width: min(480px, 100%); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.d-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 22px; }
.d-head h2 { font-size: 17px; font-weight: 650; }
.d-body { padding: 10px 22px 6px; overflow-y: auto; display: grid; gap: 14px; }
.d-body.center { justify-items: center; text-align: center; }
.d-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }
.d-foot-info { margin-right: auto; font-size: 12.5px; color: var(--muted); }
.confirm { width: min(400px, 100%); padding: 22px 22px 0; }
.confirm h2 { font-size: 16px; font-weight: 650; }
.confirm p { color: var(--text-2); margin-top: 8px; font-size: 13.5px; }
.confirm .d-foot { padding: 20px 0; }
.prompt { width: min(420px, 100%); padding: 22px 22px 0; }
.prompt h2 { font-size: 16px; font-weight: 650; }
.prompt p { color: var(--text-2); margin-top: 6px; font-size: 13px; margin-bottom: 12px; }
.prompt .input { width: 100%; }
.prompt .d-foot { padding: 18px 0; }

/* Forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.field label em { color: var(--red); font-style: normal; }
.field-row { display: flex; gap: 12px; }
.field.grow { flex: 1; }
.field.w-sm { width: 110px; flex: 0 0 110px; }
.field.w-md { width: 190px; flex: 0 0 190px; }
.hint { font-size: 12px; color: var(--muted); }
.field-err { font-size: 12px; color: var(--red); }
.field.invalid input { border-color: var(--red); box-shadow: 0 0 0 3px rgba(242, 109, 109, .15); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ========== Settings dialog ========== */
.settings { width: min(940px, 100%); height: min(660px, calc(100dvh - 40px)); flex-direction: row; overflow: hidden; }
.settings-nav { width: 210px; flex: 0 0 210px; padding: 20px 12px; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.settings-nav h2 { font-size: 17px; font-weight: 650; padding: 0 10px 14px; }
.s-tab { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 10px; color: var(--text-2); font-size: 13.5px; text-align: left; transition: background .12s, color .12s; }
.s-tab:hover { background: var(--surface-2); color: var(--text); }
.s-tab.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.s-tab.active svg { color: var(--accent); }
.settings-body { position: relative; flex: 1; min-width: 0; overflow-y: auto; padding: 26px 30px 30px; }
.dialog-x { position: absolute; right: 14px; top: 14px; z-index: 2; }
.s-view { display: grid; gap: 18px; align-content: start; animation: rise .18s ease both; }
.s-head { padding-right: 40px; }
.s-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.s-head h3 { font-size: 18px; font-weight: 650; }
.s-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.s-group { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.s-actions { display: flex; justify-content: flex-end; gap: 8px; }
.card-list { display: grid; gap: 10px; }
.list-empty { padding: 36px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 14px; font-size: 13px; }
.item-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 14px 16px; display: grid; gap: 10px; transition: border-color .15s, box-shadow .3s; }
.item-card:hover { border-color: var(--line-strong); }
.item-card.flash { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.item-head { display: flex; align-items: center; gap: 12px; }
.item-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.item-title { flex: 1; min-width: 0; display: grid; }
.item-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title strong .tag { margin-left: 4px; font-weight: 500; vertical-align: 1px; }
.item-title span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.item-edit { display: grid; gap: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.doc-list { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px dashed var(--line-strong); display: grid; gap: 4px; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.doc-list li:hover { background: var(--surface-2); }
.doc-list .doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-list .doc-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.binding { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.binding strong { color: var(--text); display: block; }

/* 知识库上传弹窗 */
.kb-dialog { width: min(560px, 100%); }
.drop { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; border: 1.5px dashed var(--line-strong); border-radius: 14px; color: var(--muted); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 4px; }
.drop strong { color: var(--text); font-size: 13.5px; font-weight: 600; }
.drop span { font-size: 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.invalid { border-color: var(--red); }
.drop.disabled { pointer-events: none; opacity: .5; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.file-item .f-ext { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font: 600 10px/1 ui-monospace, monospace; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); flex: 0 0 auto; }
.file-item .f-info { flex: 1; min-width: 0; display: grid; }
.file-item .f-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-sub { font-size: 11.5px; color: var(--muted); }
.file-item.bad { border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.file-item.bad .f-ext { color: var(--red); background: rgba(242, 109, 109, .12); }
.file-item.bad .f-sub { color: var(--red); }
.file-item.ok .f-sub { color: var(--green); }
.file-item .f-remove { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.file-item .f-remove:hover { background: var(--surface-3); color: var(--red); }
.file-item .f-remove svg { width: 14px; height: 14px; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-bar { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--accent-grad); transition: width .15s; }

/* QR */
.qr-dialog { width: min(400px, 100%); }
.qr-box img { width: 220px; height: 220px; object-fit: contain; background: #fff; padding: 10px; border-radius: 14px; }
.qr-status { font-size: 13px; color: var(--text-2); min-height: 20px; }
/* 流式输出 */
.send .i-stop { display: none; width: 16px; height: 16px; }
.send.streaming .i-send, .send.streaming .i-spin { display: none; }
.send.streaming .i-stop { display: block; }
.send.streaming { background: var(--text); color: var(--bg); box-shadow: none; }
.md.streaming > :last-child::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
/* 思考过程：可展开/收起 */
.think { margin-bottom: 12px; }
.think summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); padding: 5px 10px 5px 8px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); user-select: none; transition: background .15s; }
.think summary:hover { background: var(--surface-3); }
.think summary::-webkit-details-marker { display: none; }
.think summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); margin-left: 4px; transition: transform .18s; opacity: .7; }
.think[open] summary::after { transform: rotate(45deg) translate(-1px, -1px); }
.think-icon svg { width: 14px; height: 14px; display: block; }
.think.live .think-icon { color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.think.live .think-label { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2s linear infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes shimmer { to { background-position: -200% 0; } }
.think-body { margin-top: 8px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line-strong); font-size: 13px; line-height: 1.75; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }

/* 数学公式 */
.md .math-block { margin: 12px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.md .katex { font-size: 1.08em; }
.md .katex-display { margin: 0; }
.md .katex-error { color: var(--red) !important; font-family: ui-monospace, monospace; font-size: 13px; }

/* 回到底部 */
.to-bottom { transition: opacity .15s, transform .15s; }
.to-bottom.has-label { width: auto; padding: 0 14px 0 10px; border-radius: 999px; gap: 6px; display: inline-flex; align-items: center; font-size: 12.5px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); }
.to-bottom svg { width: 16px; height: 16px; }
.msg-error { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; color: var(--red); background: rgba(242, 109, 109, .08); border: 1px solid rgba(242, 109, 109, .25); }
.msg-error button { margin-left: auto; flex: 0 0 auto; color: var(--accent); font-size: 12.5px; }
.msg-model { font-size: 11.5px; color: var(--muted); padding: 0 6px; align-self: center; }

/* 模型接口弹窗 */
.pv-dialog { width: min(540px, 100%); }
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type-card { text-align: left; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; display: grid; gap: 2px; transition: border-color .15s, background .15s; }
.type-card b { font-size: 13.5px; font-weight: 600; }
.type-card span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); }
.type-card[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.input-affix { position: relative; }
.input-affix input { padding-right: 42px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.input-affix .ghost-icon { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.field.invalid .input-affix input { border-color: var(--red); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.switch-row span { display: grid; }
.switch-row b { font-size: 13.5px; font-weight: 550; }
.switch-row small { font-size: 12px; color: var(--muted); }
input.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--surface-3); position: relative; flex: 0 0 auto; transition: background .15s; border: 0; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }
.test-result { font-size: 12.5px; padding: 10px 12px; border-radius: 10px; line-height: 1.6; }
.test-result.ok { color: var(--green); background: rgba(62, 207, 142, .08); border: 1px solid rgba(62, 207, 142, .25); }
.test-result.bad { color: var(--red); background: rgba(242, 109, 109, .08); border: 1px solid rgba(242, 109, 109, .25); }
.test-result.pending { color: var(--muted); background: var(--surface-2); }
.d-foot .grow { flex: 1; }
.model-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.model-tags .tag { font: 11.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }
.item-card.is-default { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
@media (max-width: 600px) { .type-grid { grid-template-columns: 1fr; } }

/* ========== 登录页 ========== */
.auth-body { overflow: auto; min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-wrap { width: min(400px, calc(100% - 32px)); padding: 40px 0; display: grid; gap: 22px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.auth-brand div:last-child { display: grid; line-height: 1.3; }
.auth-brand strong { font-size: 17px; }
.auth-brand span { font-size: 12px; color: var(--muted); }
.auth-card { display: grid; gap: 16px; padding: 28px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 20px; font-weight: 650; }
.auth-sub { color: var(--muted); font-size: 13px; margin-top: -10px; }
.auth-error { font-size: 13px; color: var(--red); background: rgba(242, 109, 109, .08); border: 1px solid rgba(242, 109, 109, .25); border-radius: 10px; padding: 9px 12px; }
.auth-submit { height: 42px; width: 100%; font-size: 14px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); }
.account-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Toast */
.toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md); font-size: 13px; animation: drop .2s ease both; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.toast.success::before { background: var(--green); }
.toast.error::before { background: var(--red); }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }

/* ========== Agent 消息样式 ========== */
.agent-msg { border-left: 2px solid var(--accent); padding-left: 12px; }
.agent-status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; margin-bottom: 12px; background: var(--surface-3); color: var(--text-2); }
.agent-status.status-running { background: var(--accent-soft); color: var(--accent); }
.agent-status.status-waiting_approval { background: rgba(242, 180, 75, .14); color: var(--yellow); }
.agent-status.status-completed { background: rgba(62, 207, 142, .14); color: var(--green); }
.agent-status.status-failed, .agent-status.status-cancelled { background: rgba(242, 109, 109, .14); color: var(--red); }

.agent-steps { display: grid; gap: 10px; margin-bottom: 16px; }
.agent-step { display: flex; gap: 10px; padding: 10px 12px; background: var(--surface); border-radius: 10px; border: 1px solid var(--line); }
.agent-step.thinking { border-color: var(--accent); background: var(--accent-soft); }
/* 工具步骤：单列三行（工具名 / 工具指令 / 执行结果） */
.agent-step.tool-call { flex-direction: column; align-items: stretch; gap: 10px; border-color: var(--yellow); background: rgba(242, 180, 75, .05); }
@keyframes agentRunningPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 180, 75, 0); } 50% { box-shadow: 0 0 0 3px rgba(242, 180, 75, .14); } }
.agent-step.tool-call:not(.finished) { animation: agentRunningPulse 1.6s ease-in-out infinite; }
.agent-step.tool-call.completed { border-color: var(--accent); background: rgba(88, 132, 240, .06); box-shadow: none; animation: none; }
.agent-step.tool-call.failed { border-color: var(--red); background: rgba(242, 109, 109, .06); box-shadow: none; animation: none; }
.agent-step .step-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.agent-step .step-icon { flex: 0 0 auto; width: 20px; height: 20px; color: var(--accent); display: grid; place-items: center; }
.agent-step .step-icon svg { width: 18px; height: 18px; }
.agent-step .step-content { flex: 1; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.agent-step .step-label { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.agent-step .step-cmd { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace; font-size: 11.5px; color: var(--muted); }
.agent-step .step-details { margin-top: 8px; }
.agent-step .step-details summary { cursor: pointer; width: fit-content; font-size: 11px; color: var(--accent); user-select: none; }
.agent-step .step-details .step-args, .agent-step .step-details .step-result { margin-top: 6px; }
.agent-step .step-args, .agent-step .step-result { margin: 0; padding: 8px; background: var(--code-bg); border-radius: 6px; font-size: 11.5px; font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace; color: var(--text-2); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.agent-step .sandbox-unlock { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--yellow); background: rgba(242, 180, 75, .08); border-radius: 8px; }
.agent-step .sandbox-unlock .unlock-tip { font-size: 12px; color: var(--yellow); margin-bottom: 6px; }
.agent-step .sandbox-unlock .unlock-row { display: flex; gap: 8px; }
.agent-step .sandbox-unlock .unlock-input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; color: var(--text); background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 6px; }
.agent-step .sandbox-unlock .unlock-btn { white-space: nowrap; }
.agent-step .sandbox-unlock.unlocked { border-color: var(--green); background: rgba(62, 207, 142, .08); }
.agent-step .sandbox-unlock.unlocked .unlock-tip { color: var(--green); }

.agent-approval { border: 1px solid var(--yellow); background: rgba(242, 180, 75, .08); border-radius: 12px; padding: 14px; margin: 12px 0; }
.agent-approval.approved { border-color: var(--green); background: rgba(62, 207, 142, .08); }
.agent-approval.rejected { border-color: var(--red); background: rgba(242, 109, 109, .08); }
.approval-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.approval-icon { font-size: 18px; }
.approval-title { font-size: 14px; font-weight: 600; color: var(--text); }
.approval-body { margin-bottom: 12px; }
.approval-tool { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.approval-summary { font-size: 13px; color: var(--text); line-height: 1.5; margin-bottom: 8px; }
.approval-risk { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.approval-risk.risk-low { background: rgba(62, 207, 142, .14); color: var(--green); }
.approval-risk.risk-medium { background: rgba(242, 180, 75, .14); color: var(--yellow); }
.approval-risk.risk-high { background: rgba(242, 109, 109, .14); color: var(--red); }
.approval-actions { display: flex; gap: 8px; }
.approval-actions .btn { height: 32px; padding: 0 14px; font-size: 12px; }

.agent-output { font-size: 14.5px; line-height: 1.65; color: var(--text); min-height: 24px; }
.agent-output:empty::before { content: '正在生成回复...'; color: var(--muted); font-style: italic; }

/* 会话列表模式标识增强 */
.conv-item[data-mode="agent"] { border-left: 2px solid var(--accent); }
.conv-item[data-mode="agent"] .conv-title::before { content: '🛠️ '; margin-right: 4px; }
.conv-item[data-mode="chat"] .conv-title::before { content: '💬 '; margin-right: 4px; }
.conv-item.selected[data-mode="agent"] { background: linear-gradient(90deg, var(--accent-soft) 0%, var(--surface-2) 100%); }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ========== Responsive ========== */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; margin-left: 0 !important; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app.sb-open .sidebar { transform: none; }
  .app.sb-open .sb-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .45); }
  .head-menu { display: inline-grid !important; }
  .sb-collapse { display: none; }
  .new-chat kbd { display: none; }
  .settings { flex-direction: column; height: calc(100dvh - 24px); }
  .settings-nav { width: auto; flex: 0 0 auto; flex-direction: row; overflow-x: auto; padding: 14px 12px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-nav h2 { display: none; }
  .s-tab { flex: 0 0 auto; }
  .settings-body { padding: 20px 16px; }
  .dialog-x { top: 8px; right: 8px; }
}
@media (max-width: 600px) {
  .overlay { padding: 12px; }
  .msg-list { padding: 18px 14px 30px; }
  .composer-wrap { padding: 0 10px 8px; }
  .msg.user .msg-main { max-width: 88%; }
  .welcome-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; }
  .field.w-sm, .field.w-md { width: auto; flex: auto; }
  .s-head.row { flex-direction: column; align-items: stretch; }
  .head-sub { display: none; }
  .chip { max-width: 150px; }
}

/* ========== Agent 模式样式 ========== */
.conv-item[data-mode="agent"] { border-left: 2px solid var(--accent); }
.conv-item[data-mode="agent"] .conv-icon { color: var(--accent); }
.mode-badge { 
  display: inline-flex; 
  align-items: center; 
  gap: 4px; 
  padding: 3px 8px; 
  border-radius: 999px; 
  font-size: 11px; 
  font-weight: 500; 
  background: var(--surface-2); 
  color: var(--text-2); 
  margin-left: 8px;
}
.mode-badge.agent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.msg.agent-task { background: var(--surface-2); border-left: 3px solid var(--accent); }
.agent-tool { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  padding: 12px 16px; 
  margin: 8px 0; 
  border-radius: 10px; 
  background: var(--surface-3); 
  border: 1px solid var(--line); 
  font-size: 13px;
}
.agent-tool-icon { 
  width: 20px; 
  height: 20px; 
  color: var(--accent); 
  flex-shrink: 0;
}
.agent-tool-name { font-weight: 500; color: var(--text); }
.agent-tool-status { 
  margin-left: auto; 
  padding: 4px 10px; 
  border-radius: 999px; 
  font-size: 11px; 
  background: var(--surface); 
  color: var(--muted);
}
.agent-tool-status.running { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
.agent-tool-status.success { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.agent-tool-status.error { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.agent-approval { 
  padding: 16px; 
  margin: 12px 0; 
  border-radius: 12px; 
  background: color-mix(in srgb, var(--yellow) 10%, var(--surface-2)); 
  border: 1px solid color-mix(in srgb, var(--yellow) 30%, var(--line));
}
.agent-approval-title { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  font-weight: 600; 
  color: var(--text); 
  margin-bottom: 8px;
}
.agent-approval-desc { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.agent-approval-actions { display: flex; gap: 8px; }
.agent-approval-btn { 
  padding: 8px 16px; 
  border-radius: 8px; 
  font-size: 13px; 
  font-weight: 500; 
  cursor: pointer; 
  transition: all .15s;
  border: none;
}
.agent-approval-btn.approve { background: var(--accent); color: white; }
.agent-approval-btn.approve:hover { opacity: 0.9; }
.agent-approval-btn.deny { background: var(--surface); color: var(--text-2); border: 1px solid var(--line); }
.agent-approval-btn.deny:hover { background: var(--surface-2); }
