/* ===== 设计变量（与原站一致） ===== */
:root {
  --Bg-Primary: #fff;
  --Bg-Primary-hover: #f5f5f5;
  --Bg-Secondary: #f5f5f5;
  --Labels-Primary: #000000e5;
  --Labels-Primary-hover: #000000b8;
  --Labels-Secondary: #0000008c;
  --Labels-Tertiary: #00000059;
  --Labels-Quaternary: #0000002e;
  --Separators-S1: #0000000f;
  --Fills-F1: #00000008;
  --Fills-F1-hover: #0000000d;
  --Fills-F2: #0000000a;
  --Fills-F3: #0000000f;
  --Fills-F3-hover: #00000017;
  --Fills-F4: #00000021;
  --Colors-KMBlue: #4f46e5;
  --Colors-Red: #ef4444;
  --Others-KMBlue10: #4f46e514;
  --Others-KMBlue10-hover: #4f46e524;
  --MaskBg-Base: #0006;
  --chat-input-max-width: 768px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  color: var(--Labels-Primary);
  background: var(--Bg-Secondary);
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; outline: none; }
a { color: var(--Colors-KMBlue); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #0002; border-radius: 4px; }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f2f2f4; }
.login-card { display: flex; width: 880px; max-width: 100%; min-height: 560px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.10); }
.login-left { flex: 1; background: #141419; color: #fff; padding: 40px 36px; display: flex; flex-direction: column; }
.login-left .chip { display: inline-flex; align-items: center; gap: 8px; background: #ffffff14; border: 1px solid #ffffff22; border-radius: 999px; padding: 6px 14px; font-size: 13px; color: #e5e5ea; width: fit-content; }
.login-left .chip img { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; }
.login-left h1 { font-size: 34px; margin: 26px 0 14px; }
.login-left p { color: #a1a1aa; line-height: 1.8; font-size: 14px; }
.login-left .tags { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.login-left .tags span { background: #ffffff10; border-radius: 10px; padding: 12px; font-size: 13px; color: #d4d4d8; }
.login-right { flex: 1.1; padding: 44px 48px; display: flex; flex-direction: column; align-items: center; }
.login-right .logo { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; }
.login-right h2 { font-size: 22px; margin: 14px 0 6px; }
.login-right .sub { color: var(--Labels-Secondary); font-size: 13px; margin-bottom: 26px; }
.login-tabs { display: flex; width: 100%; background: var(--Fills-F2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.login-tabs button { flex: 1; padding: 8px; border-radius: 8px; font-size: 14px; color: var(--Labels-Secondary); }
.login-tabs button.active { background: #fff; color: var(--Labels-Primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.login-form input[type=text], .login-form input[type=password], .login-form input[type=email] {
  width: 100%; border: 1px solid var(--Separators-S1); background: var(--Fills-F1);
  border-radius: 12px; padding: 13px 15px; font-size: 14px;
  background: #fff;
}
.login-form input:focus { border-color: var(--Colors-KMBlue); background: #fff; }
.captcha-row { display: flex; gap: 10px; }
.captcha-row input { flex: 1; }
.captcha-img { width: 110px; height: 44px; border-radius: 8px; cursor: pointer; border: 1px solid var(--Separators-S1); background: #f1f5f9; }
.login-submit { margin-top: 6px; background: #141419; color: #fff; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600; }
.login-submit:hover { opacity: .88; }
.login-submit:disabled { opacity: .5; cursor: not-allowed; }
.login-link { margin-top: 16px; font-size: 13px; }
.login-error { color: var(--Colors-Red); font-size: 13px; min-height: 18px; }

/* ===== 主框架 ===== */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--Bg-Primary); border-right: .5px solid var(--Separators-S1);
  display: flex; flex-direction: column; height: 100vh; transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}
.layout.collapsed .sidebar { margin-left: -260px; }
.sidebar-header { border-bottom: .5px solid var(--Separators-S1); height: 50px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; cursor: pointer; }
.sidebar-logo img { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; }
.icon-btn { width: 28px; height: 28px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: var(--Labels-Tertiary); }
.icon-btn:hover { background: var(--Fills-F2); color: var(--Labels-Primary); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 10px 10px 16px; display: flex; flex-direction: column; }
.credits-bar { background: var(--Fills-F1); border-radius: 8px; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; margin-bottom: 8px; cursor: pointer; }
.credits-bar-info { display: flex; align-items: center; gap: 4px; color: var(--Labels-Secondary); font-size: 13px; white-space: nowrap; }
.credits-bar-info svg { width: 14px; height: 14px; flex-shrink: 0; }
.credits-bar-value { color: var(--Labels-Primary); font-weight: 600; font-size: 14px; }
.credits-bar-btn { color: #fff; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 4px; padding: 2px 10px; font-size: 12px; }
.credits-bar-btn:hover { opacity: .85; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--Labels-Primary); width: 100%; text-align: left; }
.nav-item:hover { background: var(--Fills-F2); }
.nav-item.active { background: var(--Fills-F3); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.history-label { display: flex; align-items: center; gap: 6px; color: var(--Labels-Tertiary); font-size: 12px; padding: 14px 10px 6px; white-space: nowrap; }
.history-label svg { width: 13px; height: 13px; flex-shrink: 0; }
.history-list { display: flex; flex-direction: column; gap: 2px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--Labels-Primary); }
.history-item:hover { background: var(--Fills-F2); }
.history-item.active { background: var(--Fills-F3); }
.history-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.history-item .t::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }
.history-item .del { opacity: 0; color: var(--Labels-Tertiary); flex-shrink: 0; border-radius: 4px; padding: 2px; }
.history-item:hover .del { opacity: 1; }
.history-item .del:hover { color: var(--Colors-Red); background: var(--Fills-F3); }
.sidebar-user { border-top: .5px solid var(--Separators-S1); padding: 10px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.sidebar-user:hover { background: var(--Fills-F1); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.sidebar-user .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--Labels-Secondary); }

.main { flex: 1; overflow-y: auto; position: relative; background: var(--Bg-Primary); }

/* ===== 工作台首页 ===== */
.home { max-width: 860px; margin: 0 auto; padding: 56px 24px 80px; }
.home-center { text-align: center; margin-bottom: 26px; }
.home-center .hero-icon { width: 46px; height: 46px; margin: 0 auto 10px; color: var(--Labels-Primary); }
.home-center h1 { font-size: 20px; font-weight: 700; }
.home-center .sub { color: var(--Labels-Secondary); font-size: 13px; margin-top: 6px; }
.home-banner { display: flex; justify-content: center; margin-bottom: 22px; }
.home-banner img { max-width: 460px; width: 100%; border-radius: 16px; }

.chat-input-card {
  max-width: var(--chat-input-max-width); margin: 0 auto; background: #fff;
  border: 1px solid var(--Separators-S1); border-radius: 20px; padding: 14px 16px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
}
.chat-input-card textarea { width: 100%; border: none; resize: none; font-size: 15px; min-height: 44px; background: transparent; }
.chat-input-card textarea::placeholder { color: var(--Labels-Quaternary); }
.chat-input-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chat-input-bar .spacer { flex: 1; }
.attach-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--Separators-S1); display: flex; align-items: center; justify-content: center; color: var(--Labels-Secondary); }
.attach-btn svg { width: 15px; height: 15px; }
.attach-btn:hover { background: var(--Fills-F2); }
.icon-btn svg { width: 16px; height: 16px; }
.mode-pill { display: inline-flex; align-items: center; gap: 5px; background: var(--Others-KMBlue10); color: var(--Colors-KMBlue); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.mode-pill svg { width: 14px; height: 14px; }
.cost-hint { color: var(--Labels-Tertiary); font-size: 12px; }
.model-switch { position: relative; display: inline-flex; align-items: center; gap: 5px; background: var(--Fills-F2); color: var(--Labels-Secondary); border: 1px solid var(--Separators-S1); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; }
.model-switch .model-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.model-switch .model-dot.on { background: #1E6B4F; }
.model-switch .model-dot.off { background: #F59E0B; }
.model-switch .caret { font-size: 9px; opacity: .6; }
.model-menu { display: none; position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 150px; background: #fff; border: 1px solid var(--Separators-S1); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 50; }
.model-menu.open { display: block; }
.model-opt { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 7px; font-size: 12px; color: var(--Labels-Primary); cursor: pointer; }
.model-opt small { color: var(--Labels-Tertiary); font-weight: 400; margin-left: 2px; }
.model-opt:hover { background: var(--Fills-F2); }
.model-opt.active { background: var(--Others-KMBlue10); color: var(--Colors-KMBlue); }
.send-btn { width: 34px; height: 34px; border-radius: 50%; background: #141419; color: #fff; display: flex; align-items: center; justify-content: center; }
.send-btn:hover { opacity: .85; }
.send-btn:disabled { background: var(--Fills-F4); color: #fff; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

.tpl-tabs { display: flex; justify-content: center; gap: 20px; margin: 26px 0 18px; }
.tpl-tabs button { font-size: 13px; color: var(--Labels-Secondary); padding: 4px 2px; position: relative; }
.tpl-tabs button.active { color: var(--Labels-Primary); font-weight: 600; }
.tpl-tabs button.active::after { content: ''; position: absolute; left: 20%; right: 20%; bottom: -4px; height: 2px; border-radius: 2px; background: var(--Labels-Primary); }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.tpl-card { text-align: center; }
.tpl-thumb { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--Separators-S1); aspect-ratio: 4/3; background: #f6f6f8; cursor: pointer; }
.tpl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.tpl-thumb:hover img { transform: scale(1.03); }
.tpl-thumb .mask { position: absolute; inset: 0; background: #0009; opacity: 0; transition: opacity .2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tpl-thumb:hover .mask { opacity: 1; }
.tpl-thumb .mask button { background: #fff; color: var(--Labels-Primary); border-radius: 8px; padding: 7px 16px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.tpl-thumb .selected-mask { position: absolute; inset: 0; background: #0007; display: flex; align-items: center; justify-content: center; gap: 6px; color: #fff; font-size: 13px; font-weight: 600; }
.tpl-thumb.selected { outline: 2px solid var(--Colors-KMBlue); outline-offset: 2px; }
.tpl-name { margin-top: 8px; font-size: 13px; color: var(--Labels-Primary); }

.case-section { margin-top: 30px; }
.case-title { font-size: 13px; color: var(--Labels-Tertiary); margin-bottom: 12px; }
.case-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.case-card { border-radius: 10px; overflow: hidden; background: #e9f0ec; cursor: pointer; }
.case-card img { width: 100%; aspect-ratio: 4/2.6; object-fit: cover; display: block; }
.case-card .n { text-align: center; font-size: 13px; padding: 10px 0 4px; background: #fff; }
.case-card.dark { background: #1c1c22; }

/* ===== 会话页 ===== */
.chat-page { display: flex; flex-direction: column; height: 100vh; }
.chat-scroll { flex: 1; overflow-y: auto; }
.chat-inner { max-width: var(--chat-input-max-width); margin: 0 auto; padding: 20px 24px 30px; }
.msg-user { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.msg-user .bubble { background: var(--Fills-F3); border-radius: 16px 16px 4px 16px; padding: 10px 16px; font-size: 15px; max-width: 80%; }
.msg-assistant { display: flex; gap: 10px; margin-bottom: 16px; }
.assistant-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,#667eea,#764ba2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.assistant-avatar svg { width: 16px; height: 16px; color: #fff; }
.assistant-body { flex: 1; min-width: 0; }
.assistant-text { font-size: 14.5px; line-height: 1.85; white-space: pre-wrap; margin: 8px 0; }
.assistant-text strong { font-weight: 700; }

.think-card { border-left: 2px solid var(--Fills-F4); margin: 8px 0; padding: 2px 0 2px 12px; color: var(--Labels-Secondary); font-size: 13px; cursor: pointer; }
.think-card .th-title { display: flex; align-items: center; gap: 6px; color: var(--Labels-Tertiary); }
.th-title svg { width: 13px; height: 13px; flex-shrink: 0; }
.think-card .th-body { margin-top: 6px; line-height: 1.7; display: none; }
.think-card.open .th-body { display: block; }

.step-card { border: 1px solid var(--Separators-S1); border-radius: 10px; margin: 8px 0; overflow: hidden; background: #fff; }
.step-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: 13px; color: var(--Labels-Secondary); }
.step-head:hover { background: var(--Fills-F1); }
.step-head svg.tool { width: 15px; height: 15px; color: var(--Labels-Tertiary); }
.step-head .tool-name { color: var(--Labels-Primary); }
.step-head .step-label { color: var(--Labels-Tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-head .chev { margin-left: auto; transition: transform .2s; color: var(--Labels-Quaternary); }
.step-card.open .step-head .chev { transform: rotate(180deg); }
.step-detail { display: none; padding: 4px 12px 12px; }
.step-card.open .step-detail { display: block; }
.req-block { background: var(--Fills-F1); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
.req-block .req-label { font-size: 12px; color: var(--Labels-Tertiary); margin-bottom: 4px; }
.req-block pre { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--Labels-Primary); margin: 0; }
.step-running .step-head::after { content: ''; width: 12px; height: 12px; border: 2px solid var(--Colors-KMBlue); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; margin-left: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.file-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--Separators-S1); border-radius: 12px; padding: 12px 14px; margin: 8px 0; background: #fff; }
.file-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.file-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-icon.pptd { background: #fff1e6; color: #ea580c; }
.file-icon.json { background: #eef2ff; color: #4f46e5; }
.file-icon.pptx { background: #fef2f2; color: #dc2626; }
.file-icon.xlsx { background: #ecfdf5; color: #059669; }
.file-icon.docx { background: #eff6ff; color: #2563eb; }
.file-icon.md { background: #f5f3ff; color: #7c3aed; }
.file-icon svg { width: 20px; height: 20px; }
.file-meta { flex: 1; min-width: 0; }
.file-meta .fn { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .fk { font-size: 12px; color: var(--Labels-Tertiary); margin-top: 2px; }
.file-actions { display: flex; gap: 8px; }
.file-actions button { border: 1px solid var(--Separators-S1); background: var(--Fills-F1); border-radius: 8px; padding: 6px 14px; font-size: 13px; }
.file-actions button:hover { background: var(--Fills-F3); }

.chat-bottom { flex-shrink: 0; background: linear-gradient(to top, #fff 70%, transparent); padding: 8px 24px 4px; }
.chat-bottom .chat-input-card { border-radius: 22px; }
.chat-disclaimer { text-align: center; color: var(--Labels-Quaternary); font-size: 11px; padding: 6px 0 8px; }
.scroll-bottom-btn { position: absolute; right: 24px; bottom: 130px; width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 1px solid var(--Separators-S1); box-shadow: 0 2px 8px rgba(0,0,0,.1); display: flex; align-items: center; justify-content: center; color: var(--Labels-Secondary); z-index: 5; }

/* ===== 弹窗 ===== */
.modal-overlay { position: fixed; inset: 0; background: var(--MaskBg-Base); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 16px; width: 400px; max-width: calc(100vw - 40px); padding: 24px; position: relative; animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal h3 { font-size: 17px; }
.modal .modal-sub { color: var(--Labels-Secondary); font-size: 13px; margin: 8px 0 16px; }
.modal input { width: 100%; border: 1px solid var(--Separators-S1); background: var(--Fills-F1); border-radius: 10px; padding: 11px 14px; font-size: 14px; }
.modal input:focus { border-color: var(--Colors-KMBlue); background: #fff; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns button { flex: 1; padding: 10px; border-radius: 10px; font-size: 14px; }
.modal-btns .cancel { background: var(--Fills-F2); }
.modal-btns .cancel:hover { background: var(--Fills-F3); }
.modal-btns .ok { background: #8b83f0; color: #fff; font-weight: 600; }
.modal-btns .ok:hover { background: var(--Colors-KMBlue); }
.modal-btns .ok:disabled { background: var(--Fills-F4); cursor: not-allowed; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.redeem-icon { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg,#667eea,#764ba2); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.redeem-icon svg { width: 22px; height: 22px; color: #fff; }
.credits-current { color: var(--Labels-Secondary); font-size: 13px; padding-bottom: 10px; border-bottom: 1px solid var(--Separators-S1); margin-bottom: 6px; }
.credit-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--Separators-S1); }
.credit-row:last-child { border-bottom: none; }
.credit-row .reason { font-size: 14px; }
.credit-row .at { font-size: 12px; color: var(--Labels-Tertiary); margin-top: 3px; }
.credit-row .delta { font-weight: 700; font-size: 15px; }
.credit-row .delta.plus { color: #16a34a; }
.credit-row .delta.minus { color: var(--Colors-Red); }
.tpl-preview-img { width: 100%; border-radius: 10px; border: 1px solid var(--Separators-S1); margin: 12px 0; }
.modal-error { color: var(--Colors-Red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* toast */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: #141419; color: #fff; border-radius: 10px; padding: 10px 20px; font-size: 14px; z-index: 200; animation: pop .2s; }

@media (max-width: 900px) {
  .tpl-grid, .case-grid { grid-template-columns: repeat(2, 1fr); }
  .login-left { display: none; }
}

/* ---------- 生成进度 / 排队可视化 ---------- */
.gen-status { padding: 6px 2px; }
.gen-stage { font-size: 14px; font-weight: 600; color: var(--Labels-Primary); margin-bottom: 8px; }
.queue-line { font-size: 13px; color: var(--Labels-Secondary); margin-bottom: 10px; }
.gen-progress { position: relative; height: 8px; border-radius: 6px; background: var(--Fills-F1); overflow: hidden; }
.gen-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: linear-gradient(90deg, #4f46e5, #22c55e); transition: width .4s ease; }
.gen-pct { position: absolute; right: 0; top: -22px; font-size: 12px; color: var(--Labels-Tertiary); }
.gen-progress { margin-bottom: 18px; }

/* ---------- 分步折叠式书写进度 ---------- */
.gen-group { margin: 6px 0 4px; border-radius: 10px; border: 1px solid var(--Fills-F1, #eef0f4); overflow: hidden; background: #fff; }
.gen-group-head { cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--Labels-Primary, #1e293b); display: flex; align-items: center; gap: 8px; user-select: none; background: var(--Fills-F1, #f6f7fa); }
.gen-group-head:hover { background: #eef0f4; }
.gen-chev { display: inline-block; transition: transform .2s ease; color: #4f46e5; font-size: 12px; }
.gen-group.open .gen-chev { transform: rotate(90deg); }
.gen-group-count { margin-left: auto; font-size: 11px; color: var(--Labels-Tertiary, #64748b); background: #fff; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--Fills-F1, #eef0f4); }
.gen-group-body { display: none; padding: 8px 12px 8px 30px; border-top: 1px solid var(--Fills-F1, #eef0f4); background: #fafbfc; }
.gen-group.open .gen-group-body { display: block; }
.gen-step { padding: 3px 0; font-size: 13px; color: var(--Labels-Secondary, #475569); line-height: 1.5; }
.gen-step::before { content: '·'; color: #94a3b8; margin-right: 6px; }
.gen-row { padding: 8px 12px; margin: 5px 0; border-radius: 8px; background: #fff; border: 1px solid var(--Fills-F1, #eef0f4); font-size: 13px; color: var(--Labels-Primary); display: flex; align-items: center; gap: 8px; animation: genRowIn .4s ease; transition: border-color .3s, box-shadow .3s; }
.gen-icon { color: #4f46e5; font-size: 14px; flex-shrink: 0; }
.gen-row-latest { border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,.12); background: linear-gradient(90deg, #f8f9ff 0%, #fff 60%); }
@keyframes genRowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Floating fallback：当 chat 视图未建立时，自动挂在 document.body 上 */
.agent-card-fb {
  position: fixed;
  top: 80px;
  right: 24px;
  width: 380px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(79,70,229,.18), 0 0 0 1px rgba(79,70,229,.12);
  z-index: 9999;
  padding: 14px 16px 12px;
  font-size: 13px;
  color: var(--Labels-Primary, #1e293b);
  animation: agentFbIn .3s ease;
}
.agent-card-fb .agent-fb-hint {
  background: linear-gradient(90deg, #fff7ed, #fff);
  border: 1px solid #fed7aa;
  color: #c2410c;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.agent-card-fb .agent-task-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 10px; border-bottom: 1px solid var(--Fills-F1, #eef0f4); margin-bottom: 10px; }
.agent-card-fb .agent-task-dot { color: #4f46e5; font-size: 14px; }
.agent-card-fb .agent-task-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-card-fb .agent-task-tag { background: #eef0ff; color: #4f46e5; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.agent-card-fb .agent-queue { background: #fff7ed; color: #9a3412; font-size: 12px; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; }
.agent-card-fb .agent-status { font-size: 13px; color: var(--Labels-Secondary); margin: 8px 0; }
.agent-card-fb .agent-progress { height: 6px; background: var(--Fills-F1, #eef0f4); border-radius: 3px; overflow: hidden; }
.agent-card-fb .agent-bar { height: 100%; background: linear-gradient(90deg, #4f46e5, #7c3aed); transition: width .35s ease; }
.agent-card-fb .agent-pct { font-size: 11px; color: var(--Labels-Tertiary); margin-top: 4px; text-align: right; }
.agent-card-fb .agent-tool { border: 1px solid var(--Fills-F1); border-radius: 10px; margin: 6px 0; background: #fff; overflow: hidden; }
.agent-card-fb .agent-tool-head { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; background: var(--Fills-F1); font-size: 13px; font-weight: 600; }
.agent-card-fb .agent-tool-body { display: none; padding: 8px 12px; border-top: 1px solid var(--Fills-F1); background: #fafbfc; }
.agent-card-fb .agent-tool.open .agent-tool-body { display: block; }
.agent-card-fb .agent-tool.open .agent-chev { transform: rotate(90deg); }
.agent-card-fb .agent-tool-latest { border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,.12); }
.agent-card-fb .agent-chev { transition: transform .2s ease; color: #4f46e5; }
.agent-card-fb .agent-tool-icon { color: #4f46e5; }
.agent-card-fb .agent-tool-label { flex: 1; }
.agent-card-fb .agent-box-wrap { margin: 4px 0; }
.agent-card-fb .agent-box-label { font-size: 11px; color: var(--Labels-Tertiary); margin-bottom: 2px; font-weight: 600; }
.agent-card-fb .agent-box { background: #fff; border: 1px solid var(--Fills-F1); border-radius: 6px; padding: 6px 8px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; color: var(--Labels-Secondary); }
.agent-card-fb .file-card { background: #f8fafc; border: 1px solid var(--Fills-F1); border-radius: 8px; padding: 8px 10px; margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.agent-card-fb .file-card .fn { font-weight: 600; font-size: 12px; }
.agent-card-fb .file-card .fk { font-size: 11px; color: var(--Labels-Tertiary); }
.agent-card-fb .file-card .file-actions { margin-left: auto; }
.agent-card-fb .file-card button { background: #fff; border: 1px solid var(--Fills-F1); border-radius: 6px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
@keyframes agentFbIn { from { opacity: 0; transform: translateY(-8px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) { .agent-card-fb { width: calc(100vw - 32px); right: 16px; top: 70px; } }

/* ===== 工具调用链式进度（Kimi Agent 风格：顶层任务卡 + 可折叠 Request/Response 工具子卡） ===== */
.agent-card {
  margin: 4px 0 8px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--Separators-S1);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.agent-task-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--Separators-S1);
  margin-bottom: 10px;
}
.agent-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--Colors-KMBlue);
  flex-shrink: 0;
}
.agent-task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--Labels-Primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-task-tag {
  font-size: 11px;
  color: var(--Colors-KMBlue);
  background: var(--Others-KMBlue10);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.agent-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-tool {
  border: 1px solid var(--Fills-F1);
  border-radius: 10px;
  background: #fafbfc;
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.agent-tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--Labels-Primary);
}
.agent-tool-head:hover { background: #f3f4f7; }
.agent-tool-icon { color: var(--Colors-KMBlue); font-size: 14px; flex-shrink: 0; }
.agent-tool-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-chev {
  color: var(--Labels-Tertiary);
  font-size: 11px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.agent-tool-body {
  display: none;
  padding: 4px 12px 12px 34px;
  border-top: 1px solid var(--Fills-F1);
  background: #fff;
}
.agent-tool.open .agent-tool-body { display: block; }
.agent-tool.open {
  background: #fff;
  border-color: var(--Colors-KMBlue);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.08);
}
.agent-tool-latest { animation: agentToolIn 0.45s ease; }
@keyframes agentToolIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.agent-box-wrap { margin-top: 8px; }
.agent-box-label {
  font-size: 11px;
  color: var(--Labels-Tertiary);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.agent-box {
  font-size: 12.5px;
  color: var(--Labels-Secondary);
  background: #f6f7fa;
  border: 1px solid var(--Fills-F1);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.agent-req .agent-box { background: #fff; }
.agent-resp .agent-box {
  background: #f0f4ff;
  border-color: #e0e7ff;
  color: var(--Labels-Primary);
}
.agent-queue {
  font-size: 12px;
  color: var(--Labels-Secondary);
  margin: 8px 2px 6px;
}
.agent-status {
  font-size: 13px;
  color: var(--Labels-Primary);
  margin: 10px 2px 6px;
  font-weight: 500;
}
.agent-progress {
  position: relative;
  height: 6px;
  border-radius: 4px;
  background: var(--Fills-F1);
  overflow: hidden;
  margin: 6px 2px 0;
}
.agent-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #4f46e5, #22c55e);
  transition: width 0.5s ease;
}
.agent-pct {
  text-align: right;
  font-size: 11px;
  color: var(--Labels-Tertiary);
  margin-top: 3px;
}
