/* ============================================================
   全能 Agent · 界面样式
   设计令牌（Design Tokens）+ 组件样式
   支持浅色 / 深色两套主题（html[data-theme]）
   ============================================================ */

/* ---------------- 浅色主题 ---------------- */
:root {
  --bg: #ffffff;
  --bg-grad-1: rgba(99, 102, 241, .10);
  --bg-grad-2: rgba(139, 92, 246, .10);

  --surface: #ffffff;
  --surface-2: #f9fafc;
  --surface-3: #f1f3f9;
  --surface-glass: rgba(255, 255, 255, .74);

  --border: #e7eaf3;
  --border-strong: #d7dced;

  --text: #1f2735;
  --text-strong: #0f172a;
  --muted: #667085;
  --muted-2: #98a2b3;

  --primary: #4d53e8;
  --primary-600: #3f46d8;
  --primary-soft: #eef0fe;
  --primary-glow: rgba(77, 83, 232, .18);
  --accent: #7b5cf6;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;

  /* 豆包风：用户气泡为浅紫底 + 深色文字 */
  --user-bubble: #e9ebff;
  --user-bubble-text: #232a52;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 2px 10px rgba(16, 24, 40, .06);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, .10);
  --shadow-primary: 0 8px 22px rgba(79, 70, 229, .28);

  color-scheme: light;
}

/* ---------------- 深色主题 ---------------- */
html[data-theme="dark"] {
  --bg: #0d1117;
  --bg-grad-1: rgba(99, 102, 241, .20);
  --bg-grad-2: rgba(139, 92, 246, .16);

  --surface: #121a2e;
  --surface-2: #16203a;
  --surface-3: #1c2744;
  --surface-glass: rgba(16, 23, 41, .78);

  --border: #26304a;
  --border-strong: #35415f;

  --text: #e5e9f4;
  --text-strong: #f8fafc;
  --muted: #98a2b3;
  --muted-2: #6b7688;

  --primary: #828aff;
  --primary-600: #6d74ff;
  --primary-soft: rgba(109, 116, 255, .18);
  --primary-glow: rgba(109, 116, 255, .34);
  --accent: #a78bfa;

  --user-bubble: #2c3160;
  --user-bubble-text: #e8eaff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, .55);
  --shadow-primary: 0 8px 24px rgba(99, 102, 241, .40);

  color-scheme: dark;
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
    -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  background-color: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { height: 100%; }

/* 启动占位 */
.boot-splash { height: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; }
.boot-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--primary);
  animation: bootBounce 1.2s infinite ease-in-out;
}
.boot-dot:nth-child(2) { animation-delay: .15s; }
.boot-dot:nth-child(3) { animation-delay: .3s; }
@keyframes bootBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-9px); opacity: 1; }
}

/* ---------------- 滚动条 ---------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 表单控件 ---------------- */
input[type=text], input[type=password], textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: .16s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
}
.btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #fff;
}
.btn-primary:disabled { background: var(--primary); border-color: var(--primary); box-shadow: none; }

.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); border-color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-xs { padding: 2px 7px; font-size: 12px; }

/* ============================================================
   登录 / 注册
   ============================================================ */
.auth-wrap {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

/* 背景装饰光斑 */
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  animation: orbFloat 16s ease-in-out infinite alternate;
}
.auth-orb-1 {
  width: 420px; height: 420px; left: -140px; top: -160px;
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}
.auth-orb-2 {
  width: 360px; height: 360px; right: -120px; bottom: -160px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  animation-delay: -8s;
}
@keyframes orbFloat {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(34px, 26px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-orb { animation: none; }
}

/* 右上角主题切换 */
.auth-theme-btn {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-glass);
  backdrop-filter: blur(10px); cursor: pointer; font-size: 16px;
  display: grid; place-items: center; color: var(--text);
  box-shadow: var(--shadow-sm); transition: .16s;
}
.auth-theme-btn:hover {
  border-color: var(--primary); color: var(--primary);
  transform: translateY(-1px);
}

.auth-card {
  position: relative;
  width: 400px;
  max-width: 100%;
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-md);
  animation: cardIn .4s cubic-bezier(.4, 0, .2, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo {
  position: relative;
  width: 64px; height: 64px; margin: 0 auto;
  display: grid; place-items: center;
  color: #fff; line-height: 1;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow-primary);
}
.auth-logo .ic { width: 30px; height: 30px; }
.auth-logo::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
  pointer-events: none;
}
.auth-brand h1 { font-size: 22px; margin: 14px 0 4px; color: var(--text-strong); letter-spacing: .3px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* 分段式 tab，带滑动指示器 */
.auth-tabs {
  position: relative;
  display: flex; gap: 4px; background: var(--surface-3);
  padding: 4px; border-radius: 12px; margin-bottom: 20px;
}
.auth-tabs::before {
  content: ''; position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: var(--surface); border-radius: 9px;
  box-shadow: var(--shadow-sm);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}
.auth-tabs.register::before { transform: translateX(100%); }
.auth-tabs button {
  position: relative; z-index: 1;
  flex: 1; border: none; background: transparent; padding: 8px; border-radius: 9px;
  cursor: pointer; font-size: 14px; color: var(--muted); font-family: inherit;
  transition: color .22s;
}
.auth-tabs button:hover { color: var(--text); }
.auth-tabs button.active { color: var(--primary); font-weight: 600; }

/* 带图标的输入框 */
.auth-card .field {
  position: relative;
  margin-top: 12px;
}
.auth-card .field input {
  height: 42px;
  padding: 0 12px 0 38px;
  font-size: 14.5px;
}
.auth-card .field-has-action input { padding-right: 42px; }
.field-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); display: inline-flex; pointer-events: none;
  transition: color .15s;
}
.field:focus-within .field-icon { color: var(--primary); }
.field-action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; color: var(--muted-2);
  display: grid; place-items: center; padding: 0; transition: .15s;
}
.field-action:hover { color: var(--text); background: var(--surface-3); }

/* 注册模式下昵称字段的出现 / 离场过渡 */
.auth-field-enter-active, .auth-field-leave-active { transition: opacity .22s ease, transform .22s ease; }
.auth-field-enter-from, .auth-field-leave-to { opacity: 0; transform: translateY(-6px); }

.auth-caps {
  margin: 8px 0 0; color: var(--amber); font-size: 13px;
  display: flex; align-items: center; gap: 4px;
}
.auth-error {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 0; padding: 9px 12px;
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--red); font-size: 13.5px; border-radius: var(--radius-sm);
  animation: shakeX .4s;
}
.auth-error-badge {
  flex: 0 0 16px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.auth-submit { width: 100%; margin-top: 20px; height: 44px; font-size: 15px; letter-spacing: 1px; }

/* 按钮内加载指示 */
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ============================================================
   主布局：会话侧栏 + 对话主区
   ============================================================ */
.shell { height: 100%; display: flex; }

.sidebar {
  width: 282px; flex: 0 0 282px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 12px 0;
  min-height: 0;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 12px; }
.sb-logo {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.sb-logo .ic { width: 19px; height: 19px; }
.sb-name { font-size: 16px; font-weight: 700; color: var(--text-strong); letter-spacing: .3px; }

.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 6px;
  border-top: 1px solid var(--border);
}
.sb-avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  font-size: 19px; border-radius: 11px; background: var(--surface-3);
}
.sb-avatar-grad {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: var(--shadow-sm);
}
.sb-avatar .ic { width: 17px; height: 17px; }

/* 账号菜单（点击用户信息弹出） */
.sb-user { position: relative; }
.sb-user-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 5px 7px; margin: -3px -4px;
  border: none; background: transparent; border-radius: 11px;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background .15s;
}
.sb-user-btn:hover { background: var(--surface-2); }
.pop-backdrop { position: fixed; inset: 0; z-index: 45; }
.switch-pop {
  position: absolute; right: 4px; bottom: 52px; z-index: 50;
  width: 232px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 8px;
}
.sw-title { font-size: 12px; color: var(--muted-2); padding: 4px 8px 8px; }
.sw-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 8px; border-radius: 10px;
  cursor: pointer; transition: background .13s;
}
.sw-item:hover { background: var(--surface-2); }
.sw-item.current { background: var(--primary-soft); }
.sw-avatar {
  width: 28px; height: 28px; flex: 0 0 28px;
  display: grid; place-items: center;
  border-radius: 9px; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
.sw-name { flex: 1; min-width: 0; text-align: left; }
.sw-name b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-name small { color: var(--muted); font-size: 11.5px; }
.sw-cur { font-size: 11.5px; color: var(--primary); font-weight: 600; }
.sw-x {
  width: 22px; height: 22px; border: none; border-radius: 7px;
  background: transparent; color: var(--muted-2); cursor: pointer;
  display: grid; place-items: center; transition: .13s;
}
.sw-x:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.sw-x .ic { width: 12px; height: 12px; }
.sw-add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 4px; padding: 8px;
  border: 1px dashed var(--border-strong); border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 13.5px; cursor: pointer; font-family: inherit; transition: .15s;
}
.sw-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.sw-add .ic { width: 14px; height: 14px; }
.sw-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.sw-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 10px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--red);
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: .14s;
}
.sw-logout:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
.sw-logout .ic { width: 15px; height: 15px; }
.sb-uid { flex: 1; min-width: 0; }
.sb-uid b {
  display: block; font-size: 14.5px; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-uid small { color: var(--muted); font-size: 12.5px; }
.sb-ico {
  width: 30px; height: 30px; flex: 0 0 30px;
  border: none; background: transparent; border-radius: 9px;
  color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  transition: .15s;
}
.sb-ico:hover { background: var(--surface-3); color: var(--primary); }
.sb-ico .ic { width: 17px; height: 17px; }

/* 通用线性图标 */
.ic { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; }
.ic svg { width: 100%; height: 100%; display: block; }

/* 对话主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.no-session {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--muted); font-size: 14.5px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); transition: background .2s; }
.dot.running { background: var(--amber); animation: pulse 1s infinite; }
.dot.done { background: var(--green); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.85); } }

/* ============================================================
   会话列表（侧栏内）
   ============================================================ */
.session-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sl-tools { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.sl-new {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; height: 40px;
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 14.5px; font-weight: 600; font-family: inherit;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow-primary);
  transition: .18s ease;
}
.sl-new:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.sl-new:active { transform: translateY(0); }
.sl-new .ic { width: 16px; height: 16px; }

.sl-search {
  position: relative; display: flex; align-items: center;
}
.sl-search .ic {
  position: absolute; left: 11px; width: 15px; height: 15px;
  color: var(--muted-2); pointer-events: none;
}
.sl-search input {
  width: 100%; height: 36px;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--text);
  padding: 0 12px 0 33px; font-size: 14px; font-family: inherit;
  outline: none; transition: .15s;
}
.sl-search input::placeholder { color: var(--muted-2); }
.sl-search input:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.sl-items { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 10px; }
.sl-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 12px; margin-bottom: 2px;
  cursor: pointer; transition: background .15s;
}
.sl-item:hover { background: var(--surface-2); }
.sl-item.active { background: var(--primary-soft); }
.sl-ico {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--surface-3); color: var(--muted);
  transition: .15s;
}
.sl-ico .ic { width: 15px; height: 15px; }
.sl-item.active .sl-ico { background: var(--primary); color: #fff; box-shadow: var(--shadow-primary); }
.sl-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sl-title {
  font-size: 14.5px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sl-item.active .sl-title { color: var(--primary); font-weight: 600; }
.sl-rename {
  width: 100%; font-size: 14px; padding: 3px 7px; border-radius: 7px;
}
.sl-meta {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--muted-2);
}
.sl-meta i { font-style: normal; opacity: .7; }
.sl-pinned { display: inline-flex; color: var(--primary); }
.sl-pinned .ic { width: 12px; height: 12px; }

.sl-acts { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.sl-item:hover .sl-acts, .sl-item.active .sl-acts { opacity: 1; }
.sl-acts button {
  width: 26px; height: 26px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 8px; color: var(--muted-2);
  display: grid; place-items: center; transition: .13s;
}
.sl-acts button:hover { background: var(--surface-3); color: var(--text); }
.sl-acts button.on { color: var(--primary); }
.sl-acts button.danger:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.sl-acts .ic { width: 14px; height: 14px; }
.sl-empty {
  text-align: center; color: var(--muted); font-size: 13.5px;
  padding: 32px 16px; line-height: 1.9;
}

/* ============================================================
   聊天区
   ============================================================ */
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* 头部：标题 + 模型 + 状态 + 主题 */
.chat-head {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ch-menu {
  display: none;
  width: 34px; height: 34px; flex: 0 0 34px;
  border: none; background: transparent; border-radius: 10px;
  color: var(--text); cursor: pointer;
  place-items: center;
}
.ch-menu:hover { background: var(--surface-3); }
.ch-title {
  flex: 1; min-width: 0;
  font-size: 15.5px; font-weight: 600; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-right { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; }
.ch-state {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.ch-icon-btn {
  width: 34px; height: 34px; flex: 0 0 34px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  cursor: pointer; display: grid; place-items: center;
  transition: .15s;
}
.ch-icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.ch-icon-btn .ic { width: 16px; height: 16px; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 26px 22px 12px; scroll-behavior: smooth; }

/* 空状态 */
.chat-empty { max-width: 720px; margin: 64px auto; text-align: center; animation: cardIn .45s ease; }
.empty-logo {
  width: 58px; height: 58px; margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.empty-logo .ic { width: 27px; height: 27px; }
.chat-empty h2 { font-size: 22px; font-weight: 700; margin: 0 0 10px; color: var(--text-strong); }
.chat-empty p { color: var(--muted); font-size: 14.5px; line-height: 1.85; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 24px; padding: 9px 17px;
  font-size: 13.5px; cursor: pointer; color: var(--text); font-family: inherit;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
}
.chip:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

/* 消息 */
.msg {
  display: flex; flex-wrap: wrap; gap: 0 12px; margin-bottom: 14px;
  max-width: 960px; margin-left: auto; margin-right: auto;
  animation: msgIn .3s cubic-bezier(.4, 0, .2, 1);
}
/* 双侧布局：用户消息靠右（头像/气泡在右），AI 回复靠左 */
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-body { text-align: left; border-top-right-radius: 8px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-body {
  flex: 1; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.msg.user .msg-body {
  flex: 0 1 auto;          /* 气泡宽度随内容自适应，短文本不再撑满整行 */
  overflow-wrap: break-word;
  background: var(--user-bubble);
  border-color: transparent; color: #fff;
  box-shadow: var(--shadow-primary);
}
.msg.user .md a { color: #fff; text-decoration: underline; }
.msg.user .md code { background: rgba(255, 255, 255, .22); color: #fff; }
.msg.user .md pre { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); }
.msg.user .md pre code { background: none; }
.msg.user .md blockquote { border-left-color: rgba(255, 255, 255, .5); color: rgba(255, 255, 255, .9); }

/* 思考过程 */
.thinking {
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--accent) 10%, transparent));
  margin-bottom: 12px; overflow: hidden;
}
.msg.user .thinking { display: none; }
.thinking summary {
  cursor: pointer; padding: 9px 13px; font-size: 13.5px;
  color: var(--primary); font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.thinking summary .ic { width: 14px; height: 14px; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking[open] summary { border-bottom: 1px dashed color-mix(in srgb, var(--primary) 25%, transparent); }
.timeline { padding: 10px 13px 13px; max-height: 360px; overflow-y: auto; }
.t-item {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 13.5px; line-height: 1.65; color: var(--muted);
  padding: 5px 0 5px 16px; border-left: 2px solid var(--border); position: relative;
}
.t-item .tag { flex: 0 0 auto; line-height: 1.7; color: var(--muted); display: inline-flex; margin-top: 2px; }
.t-item .tag .ic { width: 13px; height: 13px; }
.t-item.tool .tag { color: var(--amber); }
.t-item.result .tag { color: var(--green); }
.t-item.err .tag { color: var(--red); }
.t-item.skill .tag { color: var(--accent); }
.t-content { flex: 1; min-width: 0; }
/* 思考过程内的 Markdown：整体缩小，避免与正文抢视觉 */
.t-item .md { font-size: 13.5px; line-height: 1.7; }
.t-item .md > :first-child { margin-top: 0; }
.t-item .md > :last-child { margin-bottom: 0; }
.t-item .md p { margin: 3px 0; }
.t-item .md h1, .t-item .md h2, .t-item .md h3, .t-item .md h4 {
  font-size: 14px; margin: 7px 0 4px; padding: 0; border: none;
}
.t-item .md ul, .t-item .md ol { margin: 4px 0; padding-left: 20px; }
.t-item .md li { margin: 2px 0; }
.t-item .md table { margin: 6px 0; font-size: 12.5px; }
.t-item .md th, .t-item .md td { padding: 4px 7px; }
.t-item .md pre { font-size: 12px; padding: 8px; margin: 6px 0 0; }
.t-item .md blockquote { margin: 5px 0; padding: 4px 10px; }
.t-item::before {
  content: ""; position: absolute; left: -5px; top: 11px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 2px var(--surface);
}
.t-item.tool::before { background: var(--amber); }
.t-item.result::before { background: var(--green); }
.t-item.skill::before { background: var(--accent); }
.t-item.err::before { background: var(--red); }
.t-item pre {
  margin: 6px 0 0; padding: 9px; background: var(--surface-3);
  border-radius: 8px; white-space: pre-wrap; word-break: break-word;
  font-size: 12.5px; max-height: 200px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* 提问卡片 */
.ask-card {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), color-mix(in srgb, var(--accent) 4%, transparent));
  border-radius: 12px; padding: 14px 16px; margin: 10px 0;
}
.ask-title {
  font-weight: 600; font-size: 14.5px; margin-bottom: 11px;
  display: flex; align-items: center; gap: 7px;
}
.ask-title .ic { width: 16px; height: 16px; color: var(--accent); }
.ask-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-custom { display: flex; gap: 6px; margin-top: 11px; }
.ask-ignore { margin-top: 11px; }

/* 打字指示 */
.typing { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 4px; }
.cursor {
  display: inline-block; width: 7px; height: 14px; background: var(--primary);
  vertical-align: -2px; animation: blink 1s steps(2) infinite; border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 输入区：悬浮圆角卡片（上行文本 / 下行工具栏，豆包式布局） */
.composer-wrap {
  flex: 0 0 auto;
  width: 100%; max-width: 960px;
  margin: 0 auto;
  padding: 8px 22px 14px;
}
.composer {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow-md);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
}
.composer textarea {
  width: 100%;
  border: none; background: transparent; box-shadow: none;
  resize: none; max-height: 200px; min-height: 48px;
  padding: 4px 4px 2px; font-size: 15px; line-height: 1.6;
}
.composer textarea:focus { border: none; box-shadow: none; }
.composer textarea::placeholder { color: var(--muted-2); }
.cp-main { display: flex; align-items: center; gap: 8px; }
.cp-tools { display: flex; align-items: center; gap: 2px; }
.cp-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }

/* 待发送附件 */
.att-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 0; }
.att-chip {
  display: flex; align-items: center; gap: 7px;
  max-width: 220px; padding: 5px 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px;
}
.att-chip.has-img { padding: 4px; }
.att-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; }
.att-fico { color: var(--muted-2); display: inline-flex; }
.att-fico .ic { width: 16px; height: 16px; }
.att-name {
  font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 130px;
}
.att-x {
  width: 20px; height: 20px; flex: 0 0 20px;
  border: none; border-radius: 6px; background: transparent;
  color: var(--muted-2); cursor: pointer;
  display: grid; place-items: center; transition: .13s;
}
.att-x:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.att-x .ic { width: 12px; height: 12px; }

/* 历史消息里的附件标签 */
.att-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.att-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; padding: 4px 10px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 16px; color: #fff;
}
.att-tag .ic { width: 12px; height: 12px; }
.cp-model {
  display: flex; align-items: center; gap: 6px;
  height: 36px; flex: 0 1 auto; min-width: 0;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.cp-model:hover { border-color: var(--primary); }
.cp-model > .ic { width: 14px; height: 14px; color: var(--muted-2); }
.cp-model-select {
  appearance: none; border: none; outline: none;
  max-width: 180px; height: 100%;
  padding: 0 20px 0 1px;
  font-size: 13px; font-family: inherit;
  background: var(--surface-2) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 3px center/12px;
  color: var(--text); cursor: pointer;
  text-overflow: ellipsis; white-space: nowrap;
}
.cp-model-select:disabled { opacity: .55; cursor: not-allowed; }
.cp-model-select:focus { outline: none; }
.cp-btn {
  width: 34px; height: 34px; flex: 0 0 34px;
  border: none; background: transparent; border-radius: 10px;
  color: var(--muted-2); cursor: pointer;
  display: grid; place-items: center;
  transition: .15s;
}
.cp-btn:hover { background: var(--surface-3); color: var(--primary); }
.cp-btn .ic { width: 17px; height: 17px; }
.cp-send {
  width: 38px; height: 38px; flex: 0 0 38px;
  border: none; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: var(--shadow-primary);
  transition: .16s ease;
}
.cp-send:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.cp-send:active:not(:disabled) { transform: translateY(0); }
.cp-send:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.cp-send .ic { width: 17px; height: 17px; }
.cp-send.cp-stop { background: var(--red); box-shadow: 0 6px 16px rgba(239, 68, 68, .3); }
.cp-send.cp-stop:disabled { opacity: .6; }
.cp-hint {
  text-align: center; color: var(--muted-2);
  font-size: 12px; margin: 8px 0 0;
}

/* ============================================================
   卡片 / 表单（设置弹窗等内容复用）
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.card-head h4 {
  margin: 0; font-size: 15px; font-weight: 600; color: var(--text-strong);
  display: flex; align-items: center; gap: 6px;
}
.card-hint {
  font-size: 13.5px; color: #92400e; background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  border-radius: 9px; padding: 8px 10px; margin: 0 0 11px; line-height: 1.7;
}
html[data-theme="dark"] .card-hint { color: #fcd34d; }
.card-hint code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }

/* 徽标 */
.pill { font-size: 12.5px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.pill.warn { background: color-mix(in srgb, var(--amber) 18%, transparent); color: #92400e; }
.pill.ok { background: color-mix(in srgb, var(--green) 18%, transparent); color: #065f46; }
html[data-theme="dark"] .pill.warn { color: #fcd34d; }
html[data-theme="dark"] .pill.ok { color: #6ee7b7; }
.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 20px; }
.badge.dyn { background: color-mix(in srgb, var(--accent) 16%, transparent); color: #7c3aed; }
.badge.bui { background: var(--surface-3); color: var(--muted); }
.ok-badge { background: color-mix(in srgb, var(--green) 18%, transparent); color: #065f46; }
html[data-theme="dark"] .badge.dyn { color: #c4b5fd; }
html[data-theme="dark"] .ok-badge { color: #6ee7b7; }

/* 表单 */
.form { display: flex; flex-direction: column; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13.5px; color: var(--muted); display: flex; align-items: baseline; gap: 6px; }
.field-label em { font-style: normal; font-size: 12px; color: var(--muted-2); font-family: ui-monospace, monospace; }
.form input, .field-row input {
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px;
  font-size: 14.5px; font-family: inherit; width: 100%; min-width: 0; background: var(--surface);
  color: var(--text);
}
.form input:focus, .field-row input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.field-row { display: flex; align-items: center; gap: 7px; }
.field-row .field-label { flex: 0 0 auto; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row input { flex: 1; }
.row-actions { display: flex; gap: 8px; margin-top: 11px; }

/* 服务健康 */
.svc-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 11px; }
.svc {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 9px;
}
.svc-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; }
.svc-dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.svc-dot.off { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.svc-name { flex: 0 0 58px; color: var(--muted); }
.svc-val {
  flex: 1; text-align: right; color: var(--text); font-family: ui-monospace, monospace;
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 运行指标 */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 11px; }
.metric {
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--accent) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
  border-radius: 10px; padding: 9px 4px; text-align: center;
}
.metric b { display: block; font-size: 18px; color: var(--primary); line-height: 1.2; }
.metric span { font-size: 12px; color: var(--muted); }
.warn-text { color: var(--amber); font-weight: 600; }

/* 键值列表 */
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 3px 0; }
.kv-row code {
  flex: 0 0 42%; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace;
}
.kv-val { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 通知 / 记忆条目 */
.note { border-top: 1px dashed var(--border); padding: 8px 0; }
.note:first-of-type { border-top: none; }
.note-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; color: var(--text-strong); }
.note-detail { font-size: 13.5px; color: var(--muted); white-space: pre-wrap; line-height: 1.65; }
.note.read { opacity: .55; }
.note.read .note-title { color: var(--muted); font-weight: 500; }

/* 未读（未处理）通知：醒目样式 */
.note.unread {
  position: relative;
  background: color-mix(in srgb, var(--amber) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
  border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0;
  padding: 9px 10px 9px 12px;
  margin: 6px 0;
}
.note.unread:first-of-type { border-top: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); }
.note.unread .note-title { color: var(--text-strong); font-weight: 650; }
.note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.note-head .note-title { flex: 1; min-width: 0; margin-bottom: 0; }
.note-dot {
  width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
  background: var(--red); animation: pulse 1.2s infinite;
}
.note-badge {
  flex: 0 0 auto;
  font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 12px;
  background: var(--red); color: #fff;
}
.note-pill {
  background: var(--red); color: #fff;
  padding: 2px 9px;
}
.note-dismiss {
  flex: 0 0 20px; width: 20px; height: 20px;
  border: none; border-radius: 6px; background: transparent;
  color: var(--muted-2); cursor: pointer; font-size: 16px; line-height: 1;
  display: grid; place-items: center; transition: .13s;
}
.note-dismiss:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }

/* 工具条目 */
.tool { border-top: 1px dashed var(--border); padding: 8px 0; }
.tool:first-of-type { border-top: none; }
.tool-head { display: flex; align-items: center; gap: 7px; }
.tool-head code { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; }
.tool-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.55; }

/* 预格式化（设置弹窗内） */
.sp-pre {
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px; font-size: 13.5px; white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow: auto; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* 提示条 */
.sp-toast {
  margin: 10px 12px 0; padding: 8px 11px; border-radius: 9px;
  font-size: 12.5px; line-height: 1.55; border: 1px solid transparent; word-break: break-all;
}
.sp-toast.ok { background: color-mix(in srgb, var(--green) 12%, transparent); border-color: color-mix(in srgb, var(--green) 35%, transparent); color: #065f46; }
.sp-toast.err { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 35%, transparent); color: #991b1b; }
html[data-theme="dark"] .sp-toast.ok { color: #6ee7b7; }
html[data-theme="dark"] .sp-toast.err { color: #fca5a5; }

/* ============================================================
   设置弹窗（系统 / 模型 / 工具箱 / 记忆）
   ============================================================ */
.settings-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
}
.settings-modal {
  width: min(880px, 94vw);
  height: min(640px, 90vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.settings-enter-active, .settings-leave-active { transition: opacity .2s ease; }
.settings-enter-active .settings-modal, .settings-leave-active .settings-modal { transition: transform .22s cubic-bezier(.4, 0, .2, 1); }
.settings-enter-from, .settings-leave-to { opacity: 0; }
.settings-enter-from .settings-modal, .settings-leave-to .settings-modal { transform: translateY(12px) scale(.98); }

.settings-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-head-ico {
  width: 30px; height: 30px; display: grid; place-items: center;
  font-size: 17px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.settings-head h3 { margin: 0; font-size: 17px; font-weight: 650; color: var(--text-strong); }
.settings-close {
  margin-left: auto;
  width: 30px; height: 30px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; font-family: inherit;
  transition: .15s;
}
.settings-close:hover { background: var(--surface-3); color: var(--text); }

.settings-body { flex: 1; display: flex; min-height: 0; }
.settings-rail {
  flex: 0 0 148px; width: 148px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.settings-rail button {
  display: flex; align-items: center; gap: 8px;
  border: none; background: transparent; border-radius: 10px;
  padding: 9px 12px; font-size: 15px; color: var(--muted);
  cursor: pointer; font-family: inherit; text-align: left;
  transition: .15s;
}
.settings-rail button:hover { color: var(--text); background: var(--surface-3); }
.settings-rail button.active {
  color: var(--primary); font-weight: 600;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.rail-ico { font-size: 16px; line-height: 1; }

.settings-content {
  flex: 1; min-width: 0;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface-2);
}
.settings-toast { margin: 0 0 10px; }
.settings-content > div > .card:first-child { margin-top: 0; }

/* 知识库 */
.kb-upload { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.kb-hint { font-size: 12px; color: var(--muted-2); }
.kb-files { display: flex; flex-direction: column; gap: 4px; }
.kb-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  transition: border-color .15s;
}
.kb-file:hover { border-color: var(--border-strong); }
.kb-fico { color: var(--primary); width: 17px; height: 17px; }
.kb-finfo { flex: 1; min-width: 0; }
.kb-finfo b {
  display: block; font-size: 13.5px; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-finfo small { font-size: 12px; color: var(--muted); }
.kb-finfo em.kb-err { font-style: normal; color: var(--red); }
.kb-del {
  width: 28px; height: 28px; flex: 0 0 28px;
  border: none; border-radius: 8px; background: transparent;
  color: var(--muted-2); cursor: pointer;
  display: grid; place-items: center; transition: .14s;
}
.kb-del:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.kb-del .ic { width: 14px; height: 14px; }
.kb-empty { text-align: center; color: var(--muted-2); font-size: 13px; padding: 18px 0; margin: 0; }
.kb-search { display: flex; gap: 8px; }
.kb-search input {
  flex: 1; min-width: 0; height: 34px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; font-size: 13.5px; font-family: inherit;
  background: var(--surface-2); color: var(--text); outline: none;
  transition: .15s;
}
.kb-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.kb-hit {
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.kb-hit-src { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 5px; }
.kb-hit-text {
  font-size: 13px; color: var(--text); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 140px; overflow-y: auto;
}

/* ============================================================
   知识库独立页面
   ============================================================ */
.kbpage-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 26px;
}
.kbpage {
  width: min(760px, 94vw);
  height: min(720px, 92vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.kbpage-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.kbpage-head h3 {
  margin: 0; font-size: 16px; font-weight: 650; color: var(--text-strong);
  display: flex; align-items: center; gap: 8px;
}
.kbpage-head h3 .ic { width: 17px; height: 17px; color: var(--primary); }
.kb-back {
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  padding: 6px 12px; font-size: 13.5px; cursor: pointer; font-family: inherit;
  transition: .15s;
}
.kb-back:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.kb-back .ic { width: 14px; height: 14px; }
.kbpage-shared { margin-left: auto; }
.kbpage-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px;
  background: var(--surface-2);
}
.kbpage-toast { margin: 0 0 10px; }

/* 嵌入模式（设置弹窗内的知识库页） */
.kb-embed-wrap { min-height: 320px; }
.kbpage-embed { display: flex; flex-direction: column; min-height: 0; }
.kbpage-embed .kbpage-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 2px 4px;
  background: transparent;
}
.kbpage-embed .kb-stat-grid { margin-top: 2px; }

/* 文件分页 */
.kb-pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 0 4px;
  font-size: 13.5px; color: var(--muted);
}
.kb-pager button {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  padding: 5px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
  transition: .14s;
}
.kb-pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.kb-pager button:disabled { opacity: .4; cursor: not-allowed; }

/* 知识库主页：统计概览 */
.kb-stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.kb-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 10px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.kb-stat b {
  display: block; font-size: 20px; font-weight: 700; color: var(--primary);
  line-height: 1.3;
}
.kb-stat span { font-size: 12.5px; color: var(--muted); }
.kb-home-actions { display: flex; gap: 10px; align-items: center; }
.kb-open {
  border: none; background: transparent; color: var(--primary);
  font-size: 13px; cursor: pointer; font-family: inherit;
  padding: 4px 8px; border-radius: 8px; flex: 0 0 auto;
  transition: .13s;
}
.kb-open:hover { background: var(--primary-soft); }

/* 客户端下载 */
.dl-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2);
  transition: border-color .15s;
}
.dl-item:hover { border-color: var(--primary); }
.dl-ico { font-size: 23px; flex: 0 0 28px; text-align: center; }
.dl-info { flex: 1; min-width: 0; }
.dl-info b { display: block; font-size: 14px; color: var(--text-strong); margin-bottom: 2px; }
.dl-info small { font-size: 12.5px; color: var(--muted); line-height: 1.6; display: block; }
.dl-btn { flex: 0 0 auto; text-decoration: none; }
.kb-filter {
  position: relative; display: flex; align-items: center;
  margin-bottom: 10px;
}
.kb-filter .ic {
  position: absolute; left: 11px; width: 15px; height: 15px;
  color: var(--muted-2); pointer-events: none;
}
.kb-filter input {
  width: 100%; height: 36px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  padding: 0 36px 0 34px; font-size: 14px; font-family: inherit;
  outline: none; transition: .15s;
}
.kb-filter input::placeholder { color: var(--muted-2); }
.kb-filter input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.kb-refresh {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none; border-radius: 7px; background: transparent;
  color: var(--muted-2); cursor: pointer;
  display: grid; place-items: center; transition: .14s;
}
.kb-refresh:hover:not(:disabled) { background: var(--surface-3); color: var(--primary); }
.kb-refresh:disabled { opacity: .5; }
.kb-refresh .ic { width: 14px; height: 14px; }
.kb-file .kb-time { font-size: 12px; color: var(--muted-2); }

/* 文件表格（知识库文件页） */
.kb-table-card { padding: 6px 10px 10px; }
.kb-table { display: flex; flex-direction: column; }
.kb-tr {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}
.kb-th {
  font-size: 12.5px; color: var(--muted-2);
  padding: 6px 10px; border-bottom: 1px solid var(--border-strong);
  user-select: none;
}
.kb-row { cursor: pointer; transition: background .13s; border-radius: 8px; }
.kb-row:hover { background: var(--surface-2); }
.kb-td-name {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-strong);
}
.kb-td-name b {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-row:hover .kb-td-name b { color: var(--primary); }
.kb-fico { color: var(--primary); width: 16px; height: 16px; flex: 0 0 16px; }
.kb-td-owner {
  flex: 0 0 130px; display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-owner-dot {
  width: 22px; height: 22px; flex: 0 0 22px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
}
.kb-owner-dot .ic { width: 12px; height: 12px; }
.kb-td-time { flex: 0 0 118px; font-size: 13px; color: var(--muted); }
.kb-td-act { flex: 0 0 32px; display: flex; justify-content: flex-end; }

/* 文件内容预览 */
.kbview-mask {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 30px;
}
.kbview {
  width: min(760px, 92vw);
  height: min(680px, 88vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.kbview-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.kbview-title {
  font-size: 15px; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kbview-head small { color: var(--muted); font-size: 13px; }
.kbview-spacer { flex: 1; }
.kbview-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px; }
.kbview-text {
  font-size: 14.5px; line-height: 1.85; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.kb-truncated {
  margin: 0 0 12px; padding: 8px 11px; border-radius: 9px;
  font-size: 13px; color: #92400e;
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
}
html[data-theme="dark"] .kb-truncated { color: #fcd34d; }

@media (max-width: 620px) {
  .kbpage-mask { padding: 0; }
  .kbpage { width: 100%; height: 100%; border-radius: 0; border: none; }
}

@media (max-width: 620px) {
  .settings-mask { padding: 0; }
  .settings-modal { width: 100%; height: 100%; border-radius: 0; border: none; }
  .settings-rail { flex-basis: 108px; width: 108px; padding: 8px 6px; }
  .settings-rail button { padding: 8px 9px; font-size: 14px; gap: 6px; }
}

/* ============================================================
   模型面板（管理员）
   ============================================================ */
.mp-full { width: 100%; }
.mp-check {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.mp-check input { width: auto; }
.mp-test {
  margin-top: 8px; padding: 7px 10px; border-radius: 9px; font-size: 12px;
  line-height: 1.55; word-break: break-all; border: 1px solid transparent;
}
.mp-test.ok { background: color-mix(in srgb, var(--green) 10%, transparent); color: #065f46; border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.mp-test.err { background: color-mix(in srgb, var(--red) 10%, transparent); color: #991b1b; border-color: color-mix(in srgb, var(--red) 30%, transparent); }
html[data-theme="dark"] .mp-test.ok { color: #6ee7b7; }
html[data-theme="dark"] .mp-test.err { color: #fca5a5; }
.mp-models { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.mp-model {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 5px 0; font-size: 12.5px;
}
.mp-model code {
  font-family: ui-monospace, monospace; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 150px;
}
.mp-spacer { flex: 1 1 auto; }
.mp-add-model { display: flex; gap: 6px; margin-top: 8px; }
.mp-add-model input {
  flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 9px; font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.mp-add-model input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.mp-edit-input {
  flex: 1 1 120px; min-width: 0; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 8px; font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.mp-edit-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* 过渡 */
.fade-enter-active, .fade-leave-active { transition: opacity .2s, transform .2s; }
.fade-enter-from, .fade-leave-to { opacity: 0; transform: translateY(-4px); }

/* ============================================================
   Markdown
   ============================================================ */
.md { line-height: 1.78; font-size: 14.5px; word-break: break-word; }
.msg .md { line-height: 1.8; font-size: 15px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1 { font-size: 19px; margin: 14px 0 9px; color: var(--text-strong); }
.md h2 {
  font-size: 17px; margin: 14px 0 9px; color: var(--text-strong);
  padding-left: 9px; border-left: 3px solid var(--primary);
}
.md h3 { font-size: 15.5px; margin: 12px 0 7px; color: var(--text-strong); }
.md h4 { font-size: 14.5px; margin: 10px 0 6px; color: var(--text-strong); }
.md p { margin: 7px 0; }
.md ul, .md ol { margin: 7px 0; padding-left: 24px; }
.md li { margin: 4px 0; }
.md table {
  border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px;
  display: block; overflow-x: auto; border-radius: 10px;
}
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md th { background: var(--surface-3); font-weight: 600; color: var(--text-strong); }
.md tbody tr:nth-child(even) { background: var(--surface-2); }
.md code {
  background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.md pre {
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 12px; border-radius: 10px; overflow-x: auto; margin: 10px 0;
}
.md pre code { background: none; padding: 0; }
.md blockquote {
  margin: 9px 0; padding: 7px 13px; border-left: 3px solid var(--border-strong);
  color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0;
}
.md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md a { color: var(--primary); text-decoration: none; }
.md a:hover { text-decoration: underline; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 960px) {
  .ch-menu { display: grid; }
  .sidebar {
    position: fixed; z-index: 90;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sb-backdrop {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(15, 23, 42, .4);
    backdrop-filter: blur(2px);
  }
}
@media (max-width: 760px) {
  .ch-state { display: none; }
  .chat-scroll { padding: 18px 14px 10px; }
  .composer-wrap { padding: 6px 14px 12px; }
  .msg { gap: 9px; }
}
@media (max-width: 620px) {
  .chat-head { padding: 0 12px; gap: 8px; }
  .cp-model-select { max-width: 96px; }
  .cp-model > .ic { display: none; }
  .chat-scroll { padding: 14px 10px 8px; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

/* ============================================================
   Toast 通知 + 居中确认框（替代原生 alert / confirm）
   ============================================================ */
.btn-solid-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 8px 20px rgba(239, 68, 68, .28);
}
.btn-solid-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #dc2626;
  color: #fff;
}
.btn-solid-danger:disabled { opacity: .6; box-shadow: none; }

.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transition: opacity .25s ease, transform .25s ease;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-icon { flex: none; font-size: 16px; line-height: 1.4; }
.toast-text { flex: 1; word-break: break-word; white-space: pre-wrap; }
.toast-close {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.toast-close:hover { color: var(--text); }
.toast-info { border-left-color: var(--primary); }
.toast-ok { border-left-color: var(--green); }
.toast-warn { border-left-color: var(--amber); }
.toast-error { border-left-color: var(--red); }

.ui-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .2s ease;
}
.ui-modal-mask.show { opacity: 1; }
.ui-modal {
  width: min(420px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px 22px 18px;
  transform: translateY(10px) scale(.97);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.ui-modal-mask.show .ui-modal { transform: translateY(0) scale(1); }
.ui-modal-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.ui-modal-icon { font-size: 20px; }
.ui-modal-title { font-size: 17px; font-weight: 650; color: var(--text-strong); }
.ui-modal-msg { color: var(--muted); font-size: 14.5px; line-height: 1.6; word-break: break-word; }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============================================================
   追加：登录页已保存账号 / 问数页面（DSPage）/ 用户画像
   ============================================================ */

/* ---------- 登录页：已保存账号快捷登录 ---------- */
.auth-accounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 12px;
}
.auth-acc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2, transparent);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.auth-acc:hover, .auth-acc.current { border-color: var(--primary, #4f7cff); }
.auth-acc-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #4f7cff, #8b5cf6);
  flex: none;
}
.auth-acc-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.auth-acc-name b { font-size: 13.5px; font-weight: 600; }
.auth-acc-name small { font-size: 12px; color: var(--muted); }

/* ---------- 问数 ---------- */
.ds-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ds-chip {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2, var(--text));
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ds-chip:hover:not(:disabled) { border-color: var(--primary, #4f7cff); color: var(--primary, #4f7cff); }
.ds-chip:disabled { opacity: .55; cursor: not-allowed; }
.ds-ask { display: flex; gap: 10px; }
.ds-ask input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  background: var(--surface-2, transparent);
  color: var(--text);
  font-size: 14.5px;
}
.ds-ask input:focus { outline: none; border-color: var(--primary, #4f7cff); }
.ds-result { margin-top: 14px; }
.ds-answer { line-height: 1.7; font-size: 14.5px; color: var(--text); }
.ds-answer p { margin: 6px 0; }
.ds-answer table { border-collapse: collapse; margin: 8px 0; }
.ds-answer th, .ds-answer td { border: 1px solid var(--border); padding: 4px 10px; font-size: 13.5px; }
.ds-table-wrap { margin: 10px 0; overflow-x: auto; }
.ds-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.ds-table th, .ds-table td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
  white-space: nowrap;
}
.ds-table th { background: var(--surface-2, rgba(127,127,127,.08)); font-weight: 600; }
.ds-meta { color: var(--muted); font-size: 13px; margin: 6px 0 8px; }
.ds-sql {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-2, rgba(127,127,127,.08));
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2, var(--text));
  white-space: pre-wrap;
  word-break: break-all;
}
.ds-test { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }
.ds-test.ok { background: rgba(34, 197, 94, .12); color: #16a34a; }
.ds-test.err { background: rgba(239, 68, 68, .12); color: #dc2626; }
.ds-cfg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.ds-cfg-form .field { display: flex; flex-direction: column; gap: 4px; }
.ds-cfg-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.ds-table-item { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.ds-table-item:last-of-type { border-bottom: none; }
.ds-table-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-table-head .sp { flex: 1; }
.ds-alias { font-size: 14px; }
.ds-table-desc { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.ds-hist {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.ds-hist:last-of-type { border-bottom: none; }
.ds-hist.error .ds-hist-q { color: #dc2626; }
.ds-hist-q { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-hist-meta { color: var(--muted); font-size: 12.5px; flex: none; }
.ds-import-list { display: flex; flex-direction: column; gap: 6px; }
.ds-import-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s;
}
.ds-import-item:hover { border-color: var(--primary, #4f7cff); }
.ds-import-item small { color: var(--muted); font-size: 13px; }
.ds-edit .ds-cols { margin-top: 8px; font-size: 14px; }
.ds-edit .ds-cols summary { cursor: pointer; color: var(--muted); }
.ds-col-row { display: grid; grid-template-columns: 1.1fr .9fr 1.6fr; gap: 6px; margin-top: 6px; }
.ds-col-row input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.badge.off { background: rgba(127,127,127,.15); color: var(--muted); }

/* ---------- 用户画像（设置中心「记忆」页） ---------- */
.profile-summary {
  margin: 0 0 10px;
  padding: 10px 14px;
  background: var(--surface-2, rgba(127,127,127,.08));
  border-left: 3px solid var(--primary, #4f7cff);
  border-radius: 6px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
}
.profile-traits { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.profile-trait { display: flex; gap: 10px; font-size: 14px; align-items: baseline; }
.profile-key {
  flex: none;
  min-width: 64px;
  font-weight: 600;
  color: var(--primary, #4f7cff);
  font-size: 13.5px;
}
.profile-val { color: var(--text-2, var(--text)); word-break: break-word; }
.profile-topic { color: var(--muted); font-size: 13.5px; margin: 10px 0 0; }
.profile-event { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.profile-event-meta { color: var(--muted); }
.warn-hint { color: #d97706; }

/* ---------- 侧栏问数按钮提示（复用 sb-ico，无额外样式） ---------- */

/* ---------- 输入框「问数」模式开关 / 「本机」授权按钮 ---------- */
.cp-ds, .cp-local {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: auto; flex: 0 0 auto; padding: 0 10px;
  white-space: nowrap;
}
.cp-local .ic { width: 15px; height: 15px; }
.cp-ds .cp-ds-label { font-size: 12.5px; font-weight: 600; line-height: 1; }
.cp-ds.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

/* ---------- 问数：示例库 / 枚举值 ---------- */
.ds-example { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.ds-example:last-of-type { border-bottom: none; }
.ds-example-head { display: flex; align-items: center; gap: 8px; }
.ds-example-head .sp { flex: 1; }
.ds-example-q { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-sql-mini {
  display: block; margin-top: 5px; padding: 7px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; color: var(--muted);
  white-space: pre-wrap; word-break: break-all;
  max-height: 88px; overflow: hidden;
}
.ds-enum-block { margin-top: 10px; }
.ds-enum-title { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.ds-enum-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.ds-enum-row code { font-size: 13px; min-width: 90px; }
.ds-enum-vals { font-size: 13px; color: var(--text-2, var(--text)); word-break: break-all; }

/* ---------- 知识库「公开」徽标（admin 上传 = 全员可见） ---------- */
.kb-shared-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}

/* ---------- 输入框「本机」授权开关 ---------- */
.cp-local.active {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- 消息 meta：时间 / 复制 / 编辑（气泡外部下方） ---------- */
/* meta 独占第二行（气泡下方）：flex-basis 100% 强制换行；
   对齐跟随消息方向（用户行 row-reverse 下 flex-start 即右端，贴齐气泡右缘）；
   操作图标默认隐藏，hover 消息时才显示 */
.msg-meta {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  margin: 14px 0 18px;
  opacity: 0;
  transition: opacity .18s;
}
.msg:hover .msg-meta { opacity: 1; }
.msg.user .msg-meta { justify-content: flex-end; }   /* 用户消息：时间/按钮贴右缘，与气泡对齐 */
.msg-time { font-size: 12px; color: var(--muted-2); }
.msg-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
}
.msg-act:hover { background: var(--surface-3); color: var(--primary); }
.msg-act .ic { width: 13px; height: 13px; }
.msg-edit textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--primary, #4f46e5);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}
.msg-edit textarea:focus { outline: none; }
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- 知识库上传：分块/RAG 模式选择 ---------- */
.kb-mode-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.kb-mode-label { font-size: 13.5px; color: var(--muted); flex: none; }
.kb-mode-select {
  flex: 1; max-width: 320px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 13.5px; font-family: inherit; cursor: pointer;
}
.kb-mode-hint { margin: 2px 0 8px; font-size: 12px; color: var(--muted-2); line-height: 1.5; }

/* ---------- 助手回答用量徽标（耗时 · token，气泡上方） ---------- */
.msg-usage {
  font-size: 11px;
  color: var(--muted-2);
  margin-bottom: 2px;
  user-select: none;
}

/* ============================================================
   登录页精修（v2）：更大留白、更精致输入框、渐变标题、无底部提示
   ============================================================ */
.auth-card {
  padding: 40px 38px 34px;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(2, 20, 34, .18);
}
.auth-brand h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(120deg, var(--text-strong), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-brand p {
  font-size: 13.5px;
  letter-spacing: .5px;
  color: var(--muted);
}
.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  box-shadow: 0 12px 30px var(--primary-glow);
}
.auth-logo .ic { width: 34px; height: 34px; }
.auth-tabs { margin: 22px 0 16px; border-radius: 12px; overflow: hidden; }
.auth-tabs button {
  height: 40px;
  font-size: 14px;
  font-weight: 600;
}
.auth-accounts { margin: 4px 0 10px; }
.auth-card .field {
  border-radius: 12px;
  padding: 3px 12px 3px 40px;
  transition: border-color .18s, box-shadow .18s;
}
.auth-card .field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-card .field input {
  font-size: 14.5px;
  height: 44px;
}
.auth-card .field .field-icon { color: var(--muted-2); }
.auth-submit {
  height: 48px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 12px;
  margin-top: 18px;
}
.auth-caps, .auth-error { font-size: 12.5px; }

/* ============================================================
   登录页 v3：重做视觉（渐变波浪背景/玻璃卡片/协议勾选）
   ============================================================ */
.auth-wrap {
  position: relative;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 12% -10%, var(--primary-glow), transparent 60%),
    radial-gradient(1000px 520px at 108% 112%, rgba(14, 165, 233, .18), transparent 62%),
    linear-gradient(180deg, var(--bg), var(--bg));
}
.auth-orb-1 { width: 420px; height: 420px; background: var(--primary-glow); top: -140px; left: -120px; }
.auth-orb-2 { width: 380px; height: 380px; background: rgba(14, 165, 233, .28); bottom: -130px; right: -110px; animation-delay: -8s; }

.auth-card {
  width: 420px;
  max-width: 100%;
  padding: 42px 40px 30px;
  border-radius: 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(2, 20, 34, .22), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.auth-brand { margin-bottom: 24px; }
.auth-brand h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 6px;
  margin: 14px 0 6px;
  background: linear-gradient(120deg, var(--text-strong), var(--primary) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-logo {
  width: 74px; height: 74px; border-radius: 22px;
  box-shadow: 0 14px 34px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
  animation: logoFloat 5s ease-in-out infinite alternate;
}
@keyframes logoFloat { from { transform: translateY(0); } to { transform: translateY(-6px); } }
.auth-logo .ic, .auth-logo span { width: 36px; height: 36px; }

.auth-tabs {
  margin: 20px 0 18px;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}
.auth-tabs button {
  flex: 1; height: 40px; border: none;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: default;
}
.auth-tabs button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-card .field {
  border-radius: 12px;
  margin-bottom: 14px;
  transition: border-color .18s, box-shadow .18s;
}
.auth-card .field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.auth-card .field input { font-size: 14.5px; height: 46px; }
.auth-card .field-icon { color: var(--muted-2); }
.auth-submit {
  height: 48px; margin-top: 16px;
  font-size: 15px; font-weight: 700; letter-spacing: 3px;
  border-radius: 12px;
  background: var(--primary);
  box-shadow: 0 8px 22px var(--primary-glow);
}
.auth-submit:hover:not(:disabled) { filter: brightness(1.06); }
.auth-error { font-size: 12.5px; }

/* 协议勾选 */
.auth-agree {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; flex-wrap: wrap;
  margin: 14px 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}
.auth-agree.err { animation: agreeShake .4s; }
@keyframes agreeShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.auth-agree-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.auth-agree-check input { accent-color: var(--primary); width: 14px; height: 14px; cursor: pointer; }
.auth-agree.err .auth-agree-check span { color: var(--red); }
.auth-agree-link {
  border: none; background: none; padding: 0;
  color: var(--primary); font-size: 12.5px; font-family: inherit;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.auth-agree-link:hover { color: var(--primary-600); }

.auth-foot {
  text-align: center; margin: 14px 0 0;
  font-size: 11px; color: var(--muted-2); letter-spacing: .5px;
}

/* 协议弹窗 */
.agree-mask {
  position: fixed; inset: 0; z-index: 10010;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 20, 34, .55);
  backdrop-filter: blur(4px);
}
.agree-modal {
  width: min(680px, calc(100vw - 48px));
  height: min(76vh, 720px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(2, 20, 34, .3);
  overflow: hidden;
}
.agree-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.agree-head b { font-size: 16px; color: var(--text-strong); }
.agree-body {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  font-size: 13.5px; line-height: 1.8; color: var(--text);
}
.agree-body h1 { font-size: 18px; margin: 6px 0 12px; }
.agree-body h2 { font-size: 14.5px; margin: 14px 0 6px; color: var(--text-strong); }
.agree-body ul { margin: 4px 0 8px; padding-left: 20px; }
.agree-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===================== 设置面板 · 服务日志页 ===================== */
.log-files {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 10px 0;
}
.log-file-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2, inherit);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.log-file-btn.active {
  border-color: var(--primary, #4a7dff);
  color: var(--primary, #4a7dff);
  font-weight: 600;
}
.log-view {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  background: var(--bg-2, #f6f8fa);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   豆包风格主题层（Doubao-style overrides）
   素白主区 + 浅灰侧栏 / 浅紫用户气泡（深色字）/ AI 回复无卡片 /
   浅灰思考面板 / 圆形发送按钮。深色主题单独适配。
   ============================================================ */

/* ---------- 布局底色 ---------- */
.main { background: #fff; }
.sidebar { background: #f7f8fa; border-right: 1px solid #ececf3; }
html[data-theme="dark"] .sidebar { background: var(--surface-2); border-right-color: var(--border); }
.chat-head { background: rgba(255, 255, 255, .92); }
html[data-theme="dark"] .chat-head { background: rgba(13, 17, 23, .92); }
.chat-scroll { background: #fff; }
html[data-theme="dark"] .chat-scroll { background: var(--bg); }

/* ---------- 用户气泡：浅紫底 + 深色字，大圆角 ---------- */
.msg.user .msg-body {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border: none; box-shadow: none;
  border-radius: 18px; border-top-right-radius: 6px;
  padding: 10px 16px;
}
.msg.user .md { color: var(--user-bubble-text); }
.msg.user .md a { color: var(--primary); text-decoration: underline; }
.msg.user .md code {
  background: rgba(77, 83, 232, .10); color: var(--user-bubble-text);
  border: none;
}
.msg.user .md pre { background: rgba(255, 255, 255, .75); border-color: rgba(77, 83, 232, .18); }
.msg.user .md pre code { background: none; color: var(--user-bubble-text); }
.msg.user .md blockquote { border-left-color: rgba(77, 83, 232, .35); color: color-mix(in srgb, var(--user-bubble-text) 82%, transparent); }
.msg.user .att-tag {
  background: rgba(255, 255, 255, .65); border-color: rgba(77, 83, 232, .22);
  color: var(--user-bubble-text);
}
html[data-theme="dark"] .msg.user .md pre { background: rgba(0, 0, 0, .30); }

/* ---------- AI 回复：去卡片，全宽素排 ---------- */
.msg.assistant .msg-body, .msg.ai .msg-body {
  background: transparent; border: none; box-shadow: none; padding: 2px 0 0;
}
.msg-usage { color: var(--muted-2); }

/* ---------- 思考面板：浅灰素净卡片 ---------- */
.thinking {
  background: #f7f8fa; border: none; border-radius: 14px;
}
.thinking summary { color: var(--muted); font-weight: 500; }
.thinking summary .ic { color: var(--muted-2); }
.thinking[open] summary { border-bottom: 1px solid #ececf3; }
.timeline { background: transparent; }
.t-item { border-left-color: #e5e7ef; color: #5a6478; }
.t-item::before { background: var(--muted-2); box-shadow: 0 0 0 2px #f7f8fa; }
.t-item pre { background: #eef0f4; }
html[data-theme="dark"] .thinking { background: var(--surface-2); }
html[data-theme="dark"] .thinking[open] summary { border-bottom-color: var(--border); }
html[data-theme="dark"] .t-item { border-left-color: var(--border); }
html[data-theme="dark"] .t-item::before { box-shadow: 0 0 0 2px var(--surface-2); }
html[data-theme="dark"] .t-item pre { background: var(--surface-3); }

/* ---------- 输入区：居中窄一档 + 大圆角 + 圆形发送按钮 ---------- */
.composer-wrap { max-width: 840px; padding-bottom: 18px; }
.composer { border-radius: 24px; box-shadow: 0 2px 14px rgba(15, 23, 42, .07); }
.composer:focus-within { box-shadow: 0 0 0 2px var(--primary-glow), 0 2px 14px rgba(15, 23, 42, .07); }
.cp-send {
  border-radius: 50%;
  background: var(--primary); box-shadow: none;
}
.cp-send:hover:not(:disabled) { filter: brightness(1.08); transform: none; }
.cp-send.cp-stop { background: var(--red); box-shadow: none; }
.cp-model { border-radius: 999px; background: transparent; }

/* ---------- 会话列表：浅灰底上的素净项 ---------- */
.sl-new {
  background: var(--primary); color: #fff;
  border: none; border-radius: 12px;
  box-shadow: 0 4px 12px rgba(77, 83, 232, .24);
}
.sl-new:hover:not(:disabled) { filter: brightness(1.08); transform: none; background: var(--primary-600); color: #fff; }
.sl-item { border-radius: 10px; }
.sl-item.active { background: #eceeff; }
.sl-item.active .sl-title { color: var(--text-strong); font-weight: 600; }
.sl-item.active .sl-ico { background: var(--primary); color: #fff; box-shadow: none; }
html[data-theme="dark"] .sl-item.active { background: var(--primary-soft); }
html[data-theme="dark"] .sl-item.active .sl-title { color: var(--text-strong); }

/* ---------- 欢迎页 / 提问卡片：更轻 ---------- */
.chat-empty h2 { font-size: 24px; letter-spacing: .5px; }
.chip { background: #f7f8fa; border-color: #ececf3; }
.chip:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
html[data-theme="dark"] .chip { background: var(--surface-2); border-color: var(--border); }
.ask-card {
  background: #f7f8fa; border-color: #e5e7ef;
}
html[data-theme="dark"] .ask-card { background: var(--surface-2); border-color: var(--border); }

/* ---------- 登录页同步：去光晕、素净卡片 ---------- */
.auth-wrap { background: #fff; }
html[data-theme="dark"] .auth-wrap { background: var(--bg); }
.auth-orb { display: none; }
.auth-card { box-shadow: 0 6px 32px rgba(15, 23, 42, .08); border-radius: 20px; }
