/* ============================================================================
 * InboxAide · 设计系统（遵循 DESIGN.md 与 tokens.css）
 *
 * 核心：
 * - 自动/手动明暗三态主题（color-scheme + light-dark() + data-theme）
 * - 统一信号蓝（Signal Blue）品牌体系 · 克制发丝线 · tabular 数字对齐
 * - 零外部阻塞 CDN 字体，原生高质量系统字体栈
 * ========================================================================== */

:root {
  /* 字体栈（零外部阻塞，对齐 DESIGN.md） */
  --font-display: var(--mc-font-display, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif);
  --font-body: var(--mc-font-sans, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif);
  --font-mono: var(--mc-font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace);

  /* ============ 主题色板（自动/手动 light-dark） ============ */
  color-scheme: light dark;

  /* 表面 */
  --surface-0: light-dark(oklch(98.4% 0.004 250), oklch(15.5% 0.012 258));       /* 页面底层画布 */
  --surface-1: light-dark(oklch(100% 0 0), oklch(19.5% 0.014 258));              /* 主工作区 / 卡片 */
  --surface-2: light-dark(oklch(96.4% 0.006 250), oklch(23.5% 0.016 258));       /* 悬停 / 嵌套表面 */
  --surface-sunken: light-dark(oklch(95.2% 0.008 250), oklch(17.2% 0.012 258));  /* 输入框 / 凹陷区 */

  /* 文本 */
  --text-1: light-dark(oklch(18% 0.024 258), oklch(96% 0.008 250));              /* 主文本 */
  --text-2: light-dark(oklch(37% 0.02 258), oklch(80% 0.014 255));               /* 次文本 */
  --text-3: light-dark(oklch(48% 0.018 255), oklch(68% 0.016 255));              /* 辅助文本 / 占位 */
  --text-inverse: light-dark(#ffffff, oklch(15.5% 0.012 258));

  /* 发丝边框 */
  --border-1: light-dark(oklch(91% 0.008 255), oklch(29% 0.014 258));            /* 弱分隔线 */
  --border-2: light-dark(oklch(83% 0.012 255), oklch(38% 0.016 258));            /* 控件边框 */

  /* 品牌主色（统一信号蓝 Signal Blue — 对齐 DESIGN.md #2563EB / #60A5FA） */
  --brand: light-dark(oklch(55% 0.19 262), oklch(72% 0.14 256));
  --brand-fill: light-dark(oklch(55% 0.19 262), oklch(68% 0.15 256));
  --brand-soft: light-dark(oklch(94.5% 0.032 260), oklch(26% 0.045 258));
  --brand-text: light-dark(oklch(47% 0.19 262), oklch(78% 0.13 256));
  --brand-shadow: light-dark(oklch(55% 0.19 262 / 0.16), oklch(68% 0.15 256 / 0.28));

  /* 强调色（暖橙 · 徽章 / 高亮） */
  --accent: oklch(72% 0.18 50);
  --accent-soft: light-dark(oklch(95% 0.05 50), oklch(28% 0.04 50));
  --accent-text: light-dark(oklch(48% 0.18 50), oklch(82% 0.16 50));

  /* 语义色 */
  --success: oklch(70% 0.18 150);
  --success-fill: light-dark(oklch(48% 0.13 150), oklch(70% 0.18 150));
  --warning: oklch(78% 0.16 80);
  --danger: oklch(64% 0.22 25);                                                    /* 红橙未读徽章 */
  --danger-text: light-dark(oklch(48% 0.18 25), oklch(76% 0.15 25));
  --danger-soft: light-dark(oklch(95% 0.04 25), oklch(27% 0.04 25));

  /* 渠道类型色 */
  --ch-feishu: oklch(60% 0.2 240);        /* 飞书蓝 */
  --ch-chat: oklch(70% 0.18 160);         /* 在线客服 绿 */
  --ch-wechat: oklch(66% 0.18 245);      /* 企业微信蓝（im_wechat 是企业微信，不是个人微信） */
  --ch-dingtalk: oklch(60% 0.16 250);    /* 钉钉蓝紫 */
  --ch-slack: oklch(60% 0.18 30);        /* Slack 红橙 */
  --ch-whatsapp: oklch(72% 0.18 145);    /* WhatsApp 绿 */
  --ch-line: oklch(65% 0.16 180);        /* LINE 青 */
  --ch-telegram: oklch(65% 0.18 220);    /* Telegram 蓝 */
  --ch-email: oklch(65% 0.14 60);        /* 邮箱 琥珀 */
  --ch-webhook: oklch(60% 0.08 280);     /* webhook 紫 */

  /* 间距（不规则节奏：刻意差异创造层次） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 48px;
  --sp-9: 64px;

  /* 圆角 */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-4: 16px;
  --r-pill: 999px;

  /* Icon 尺寸（与设计令牌保持同一节奏，避免 14/15/16/18 混用） */
  --ico-xs: 12px;   /* 行内微图标（chip、按钮内） */
  --ico-sm: 14px;   /* 会话列表 / 菜单项 */
  --ico-md: 16px;   /* 工具按钮 / 输入区按钮 */
  --ico-lg: 20px;   /* 渠道卡片 / 操作区强调 */
  --ico-xl: 28px;   /* 状态空态 / 欢迎页 */
  --ico-2xl: 48px;  /* 巨型装饰 / 启动屏 */
  --ico-stroke: 1.75;
  --ico-stroke-thin: 1.5;
  --ico-stroke-bold: 2;

  /* 默认 16px 浏览器字号下为 12 / 13 / 14 / 15px，随用户字体偏好缩放。 */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2.25rem;

  /* 动效（对齐 tokens.css 标准曲线与时长） */
  --ease-out-expo: var(--mc-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring: var(--mc-ease-spring, cubic-bezier(0.22, 1.2, 0.36, 1));
  --dur-fast: var(--mc-dur-fast, 150ms);
  --dur-base: var(--mc-dur-base, 240ms);
  --dur-slow: var(--mc-dur-slow, 380ms);

  /* 控件高度（按钮 / 输入框统一节奏 · 主次按钮必须同高才有"按钮组"感） */
  --ctl-h: 36px;
  --ctl-h-sm: 30px;   /* 气泡内联操作（草稿气泡的改 / 发 / 忽略） */
  --ctl-h-lg: 44px;   /* 页面级 CTA（登录等） */
  --ctl-h-touch: 44px;

  /* 工作台三栏的共用节拍：收件箱 / 会话 / Harness 的头与尾必须同高 */
  --wb-pane-head-h: 50px;
  --wb-pane-foot-h: 96px;
  --wb-resizer-w: 10px;

  /* 阴影与精密发丝高光（对齐 tokens.css 表面层级） */
  --inner-highlight: var(--mc-inner-shadow, light-dark(inset 0 1px 0 oklch(100% 0 0 / 0.85), inset 0 1px 0 oklch(100% 0 0 / 0.06)));
  --shadow-1: var(--mc-shadow-sm, light-dark(0 1px 2px oklch(15% 0.02 255 / 0.05), 0 1px 2px oklch(0% 0 0 / 0.32)));
  --shadow-2: var(--mc-shadow-md, light-dark(0 6px 20px oklch(15% 0.02 255 / 0.07), 0 8px 28px oklch(0% 0 0 / 0.42)));
  --shadow-elevated: var(--mc-shadow-lg, light-dark(
    0 18px 44px -12px oklch(15% 0.03 255 / 0.14), 0 2px 6px oklch(15% 0.02 255 / 0.05),
    0 24px 56px -12px oklch(0% 0 0 / 0.62), 0 1px 3px oklch(0% 0 0 / 0.4)
  ));
  --surface-glass: var(--mc-bg-glass, light-dark(oklch(100% 0 0 / 0.86), oklch(19.5% 0.014 258 / 0.84)));
}

/* ============ 全局基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 100%; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-1);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  font-variant-numeric: tabular-nums;  /* 数字对齐 */
}
body { font-size: var(--fs-base); line-height: 1.5; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button, input, select { line-height: 1.4; }

a { color: inherit; text-decoration: none; }

::selection {
  background: oklch(from var(--brand) l c h / 0.25);
  color: var(--text-1);
}

/* ============ 登录视图 ============ */
.auth-loading-view { min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:var(--sp-7); background:var(--surface-0); text-align:center; }
.auth-loading-content { max-width:380px; }
.auth-loading-content h1 { margin:20px 0 10px; font:650 22px var(--font-display); }
.auth-loading-content p { color:var(--text-2); font-size:14px; line-height:1.7; }
.auth-loading-content button { margin-top:22px; }
.auth-loading-content [hidden] { display:none !important; }
.auth-loading-mark { display:inline-block; width:32px; height:32px; border:3px solid var(--border-1); border-top-color:var(--brand-text); border-radius:50%; animation:auth-loading-spin 900ms linear infinite; }
.auth-loading-view[aria-busy="false"] .auth-loading-mark { animation:none; border-color:var(--border-2); }
@keyframes auth-loading-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .auth-loading-mark { animation:none; } }

.login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7);
  background:
    radial-gradient(ellipse at 30% 20%, oklch(from var(--brand) l c h / 0.12), transparent 60%),
    radial-gradient(ellipse at 80% 80%, oklch(from var(--accent) l c h / 0.08), transparent 50%),
    var(--surface-0);
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-8) var(--sp-7) var(--sp-7);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-2);
  position: relative;
  overflow: hidden;
}
/* 顶部品牌渐变条（大胆有性格细节） */
.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--ch-feishu) 0%,
    var(--brand) 50%,
      var(--accent) 100%);
}

.login-header { text-align: center; margin-bottom: var(--sp-7); }
.login-header h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-2);
  color: var(--text-1);
}
.login-header p {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.form-row { margin-bottom: var(--sp-4); }
.form-row label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-row input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  outline: none;
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart);
}
/* 注册同意条款：复选框必须保持原生尺寸，不能被 .form-row input 的 width:100% 撑满。
 * 之前用内联样式写 flex，但全局输入框规则把 checkbox 拉成整行，条款文字被挤成一条窄柱。 */
.form-row label.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: 0;
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
  cursor: pointer;
}
.auth-consent-row { margin-top: var(--sp-3); }
.auth-consent input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.auth-consent span { min-width: 0; }
.auth-consent a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-consent a:hover { text-decoration-thickness: 2px; }

.form-row input:focus {
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.15);
}

/* 主按钮 = 品牌实心。
 * 尺寸必须与 .btn-secondary 完全对齐（同高 --ctl-h / 同圆角 / 同字号），
 * 层级只靠「颜色 + 字重 + 略宽」表达。
 * ⚠️ 绝不在此写 width:100% / margin-top —— 那是登录页的页面级布局，
 * 混进通用按钮会让每个弹窗 footer 的主按钮撑满、把次按钮挤扁变形。 */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--ctl-h);
  padding: 0 var(--sp-4);
  background: var(--brand-fill);
  color: var(--text-inverse);
  border: 1px solid transparent;
  border-radius: var(--r-2);
  font-family: inherit;
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart);
  box-shadow: 0 1px 2px var(--brand-shadow);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--brand-shadow);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* 登录页的「登录」是全宽 CTA —— 页面级布局，限定在登录卡片内，不外泄 */
.login-card .btn-primary {
  width: 100%;
  min-height: var(--ctl-h-lg);
  margin-top: var(--sp-5);
  padding: 0 var(--sp-5);
  font-size: var(--fs-md);
}

.login-error {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--danger-soft);
  color: var(--danger-text);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  display: none;
  border: 1px solid oklch(from var(--danger) l c h / 0.3);
}
.login-error.show { display: block; }
.login-error:focus-visible { outline: 2px solid var(--danger); outline-offset: 3px; }

.auth-mode-switch {
  display: flex;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: var(--sp-5);
}
.auth-mode-switch button {
  flex: 1;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  font: 500 var(--fs-sm) var(--font-body);
  cursor: pointer;
}
.auth-mode-switch button:hover { color: var(--text-1); }
.auth-mode-switch button[aria-pressed="true"] { border-bottom-color: var(--brand); color: var(--brand-text); }
.auth-mode-switch button:focus-visible, .auth-google-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.auth-mode-switch button:disabled { opacity: .55; cursor: not-allowed; }
.login-card [hidden] { display: none !important; }
.auth-field-help { margin: var(--sp-2) 0 0; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.6; }
.auth-code-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); align-items: stretch; }
.auth-code-controls input { min-width: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
#verification-code-send { min-height: var(--ctl-h-lg); padding-inline: var(--sp-3); font-variant-numeric: tabular-nums; }
#verification-code-send:disabled { opacity: .6; cursor: not-allowed; }
.auth-code-status { color: var(--success); overflow-wrap: anywhere; }
.auth-code-error { margin: var(--sp-2) 0 0; color: var(--danger-text); font-size: var(--fs-xs); line-height: 1.6; overflow-wrap: anywhere; }
.auth-alternative { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-4); color: var(--text-3); font-size: var(--fs-xs); }
.auth-alternative::before, .auth-alternative::after { content: ""; flex: 1; height: 1px; background: var(--border-1); }
.auth-google-button { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); width: 100%; min-height: 44px; }
.auth-google-button svg { flex-shrink: 0; }
.auth-google-button:disabled { opacity: .6; cursor: not-allowed; }
.auth-google-help { text-align: center; }
.auth-qr-panel { text-align: center; }
.auth-qr-instruction { margin: 0 0 var(--sp-4); color: var(--text-2); font-size: var(--fs-sm); line-height: 1.65; }
.auth-qr-image-frame { display: flex; align-items: center; justify-content: center; width: 236px; min-height: 236px; max-width: 100%; margin: 0 auto var(--sp-4); padding: 8px; background: #fff; border: 1px solid var(--border-2); border-radius: var(--r-2); }
.auth-qr-image-frame img { display: block; width: 220px; height: 220px; max-width: 100%; object-fit: contain; }
#auth-qr-placeholder { padding: var(--sp-4); color: #46505a; font-size: var(--fs-sm); line-height: 1.6; }
.auth-qr-code-row { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); }
.auth-qr-code-row strong { color: var(--text-1); font: 600 24px var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: .13em; }
.auth-qr-status { margin: var(--sp-3) 0 0; color: var(--text-1); font-size: var(--fs-sm); line-height: 1.6; }
.auth-qr-status[data-status="scanned"] { color: var(--success); }
.auth-qr-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.auth-qr-actions button { min-height: 44px; padding-inline: var(--sp-3); }
#auth-qr-copy:disabled { opacity: .6; cursor: not-allowed; }
.auth-qr-safety { margin-top: var(--sp-4); }
#auth-qr-error { text-align: left; }

.login-tip {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-1);
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-align: center;
  font-family: var(--font-mono);
}
.auth-text-button { border: 0; background: transparent; padding: 2px 4px; color: var(--text-1); font-family: var(--font-body); font-size: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.auth-text-button:hover { color: var(--brand-text); }
.auth-text-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.auth-text-button:disabled { opacity: .55; cursor: not-allowed; }

/* ============ 应用框架 ============ */
.app-view { height: 100dvh; display: flex; flex-direction: column; }

/* ============================================================
 * 顶部栏（AI 工作台顶栏 · v2）
 * 结构：品牌区 | 搜索 | 筛选器 | 操作区
 * 保留兼容：project-filter / status-filter / unread-badge / config-btn / logout-btn / user-name
 * ============================================================ */
.app-header {
  height: 64px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border-1);
  box-shadow: var(--inner-highlight);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-5);
  gap: var(--sp-4);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}
/* 顶部精密信号蓝微光线（克制高端，与登录卡同源） */
.app-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    oklch(from var(--brand) l c h / 0.55) 25%,
    var(--brand) 50%,
    oklch(from var(--brand) l c h / 0.55) 75%,
    transparent 100%);
  opacity: 0.75;
}

/* ===== ① 品牌区 ===== */
.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  flex-shrink: 0;
}
.brand-logo {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  border-radius: var(--r-3);
  background:
    radial-gradient(circle at 30% 25%, oklch(100% 0 0 / 0.35), transparent 60%),
    linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  box-shadow:
    0 1px 0 oklch(100% 0 0 / 0.2) inset,
    0 4px 12px oklch(from var(--brand) l c h / 0.35);
  position: relative;
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-out-expo);
}
.brand-logo .mc-icon { width: 22px; height: 22px; stroke-width: var(--ico-stroke-bold); }
.brand-logo::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, oklch(100% 0 0 / 0.25), transparent 60%);
  pointer-events: none;
}
.brand-logo:hover { transform: rotate(-6deg) scale(1.04); }

/* ============ 产品 Logo（品牌图） ============
   页面里的产品标识改用品牌图 app-icon.png 导出的 /icon-192.png，不再叠渐变方块
   与白色描边图标：品牌图自带完整配色，直接放进 .brand-logo 原先的渐变底里，
   透明圆角会露出底色、图标自身的颜色也会被中和，所以另起 .app-logo 一类。
   .brand-logo 本身不动 —— 渠道卡片那里它是 <img>（brand-logos/*.svg），仍在用。 */
.app-logo {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  /* 品牌图四周透明，drop-shadow 跟随 alpha 轮廓，明暗主题下都能与背景分开 */
  filter: drop-shadow(0 2px 6px oklch(from var(--brand) l c h / 0.28));
  transition: transform var(--dur-base) var(--ease-out-expo);
}
.app-logo-lg {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--sp-3);
  filter: drop-shadow(0 4px 14px oklch(from var(--brand) l c h / 0.32));
}
.header-brand .app-logo:hover { transform: rotate(-6deg) scale(1.04); }

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.brand-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-1);
  line-height: 1.1;
  white-space: nowrap;
}
.brand-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ai-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 oklch(from var(--success) l c h / 0.6);
  animation: ai-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(from var(--success) l c h / 0.55); }
  50%      { box-shadow: 0 0 0 6px oklch(from var(--success) l c h / 0); }
}

/* ===== 分隔条 ===== */
.header-divider {
  width: 1px;
  height: 28px;
  background: var(--border-1);
  flex-shrink: 0;
}

/* ===== ② 全局搜索 ===== */
.header-search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  display: flex;
  align-items: center;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: 0 var(--sp-3);
  height: 36px;
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) var(--ease-out-quart);
}
.header-search:hover { border-color: var(--border-2); }
.header-search:focus-within {
  /* 聚焦时：组件边框 + 1px 蓝边 + 3px 外光晕，蓝框「占满」搜索框组件 */
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px oklch(from var(--brand) l c h / 0.18);
}
.search-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  margin-right: var(--sp-2);
  flex-shrink: 0;
}
.search-ico .mc-icon { width: var(--ico-md); height: var(--ico-md); }
.header-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--fs-sm);
  color: var(--text-1);
  padding: 0;
}
.header-search input::placeholder { color: var(--text-3); }
.search-kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px 6px;
  background: var(--surface-1);
  color: var(--text-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  margin-left: var(--sp-2);
}
.header-search:focus-within .search-kbd { opacity: 0; }

/* 搜索结果下拉：与搜索框组件左右对齐（占满 header-search 内容宽度） */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  max-height: 420px;
  overflow-y: auto;
  z-index: 60;
  animation: menu-in 180ms var(--ease-out-expo);
}
.search-results[hidden] { display: none; }
.search-section-title {
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.search-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart);
}
.search-item:hover,
.search-item.is-active { background: var(--surface-2); }
.search-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-2);
}
.search-item-body {
  flex: 1;
  min-width: 0;
}
.search-item-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-item-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ===== ③ 筛选器（chip 风格） ===== */
.header-filters {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.chip-select { position: relative; }
.chip-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  color: var(--text-1);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease-out-quart);
  white-space: nowrap;
}
.chip-trigger:hover {
  border-color: var(--border-2);
  background: var(--surface-2);
}
.chip-trigger[aria-expanded="true"] {
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.12);
}
.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}
.chip-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: transform var(--dur-fast) var(--ease-out-quart);
}
.chip-trigger[aria-expanded="true"] .chip-caret { transform: rotate(180deg); }

/* ===== Icon-only chip 触发器（用于会话列表顶部的状态筛选）=====
   - 只显示一个 Icon；展开后菜单与普通 chip 相同
   - 选中态时 Icon 着色 */
.chip-trigger-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  gap: 0;
}
.chip-select-icon.is-active .chip-trigger-icon {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-text);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.12);
}
.chip-select-icon.is-active .chip-icon { color: var(--brand-text); }
/* 隐藏原生 select（仅用于持久化选项值） */
.chip-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.chip-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  max-width: 280px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  padding: var(--sp-1);
  z-index: 60;
  list-style: none;
  margin: 0;
  animation: menu-in 180ms var(--ease-out-expo);
}
.chip-menu[hidden] { display: none; }
.chip-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart);
}
.chip-option:hover,
.chip-option.is-active { background: var(--surface-2); }
.chip-option-main { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.chip-option-ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-3); }
.chip-option-ico .mc-icon { width: 15px; height: 15px; }
/* 状态筛选项的圆点与头像右上角一致：琥珀=待回复，靛蓝=待客户，绿色=已关闭 */
.status-indicator { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.status-indicator-reply { background: #F59E0B; }
.status-indicator-waiting { background: #6366F1; }
.status-indicator-closed { width: 15px; height: 15px; background: #22C55E; color: #fff; font-size: 9px; font-weight: 700; line-height: 1; }
.chip-option.is-selected { color: var(--brand-text); font-weight: 500; }
.chip-option.is-selected::after {
  content: "✓";
  color: var(--brand);
  font-size: 12px;
}
.chip-option .opt-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ===== ④ 操作区 ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-shrink: 0;
}

/* 未读 pill（已迁移到侧栏「工作台」图标右上角的 .nav-unread，下方为兼容旧 DOM 留兜底） */
@keyframes badge-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* 全局 Icon 基线（[data-icon] 容器内渲染出来的 SVG） */
.mc-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
}
/* Inline icons share one baseline without inheriting the text line box. */
[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-primary .mc-icon, .btn-secondary .mc-icon { width: var(--ico-md); height: var(--ico-md); }

/* Agent 预设卡片上的图标（用户 emoji 或 bot icon） */
.agent-card-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-2);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: 22px;
  line-height: 1;
}
.agent-card-ico .mc-icon { width: 22px; height: 22px; }

/* 图标按钮 */
.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  cursor: pointer;
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-1);
  color: var(--text-1);
}
.icon-btn[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: var(--border-1);
  color: var(--text-1);
}
/* icon-btn 内的 svg 走中等尺寸 */
.icon-btn .mc-icon { width: var(--ico-lg); height: var(--ico-lg); }
.icon-btn-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  /* 同上：去掉与背景同色的描边（深色主题下就是黑边） */
  box-shadow: 0 0 8px oklch(from var(--danger) l c h / 0.5);
  animation: badge-pop 360ms var(--ease-out-expo);
}
.icon-btn-dot[hidden] { display: none; }

/* 下拉菜单（通用） */
.menu-anchor { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-elevated), var(--inner-highlight);
  padding: var(--sp-2);
  z-index: 60;
  transform-origin: top right;
  animation: menu-in 200ms var(--ease-spring);
}
.dropdown-menu[hidden] { display: none; }
@keyframes menu-in {
  from { transform: translateY(-6px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}
.dropdown-header {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-1);
  margin-bottom: var(--sp-2);
}
.dropdown-body { padding: 0 var(--sp-2) var(--sp-2); }
.dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dropdown-list li[role="menuitem"] {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart);
}
.dropdown-list li[role="menuitem"]:hover { background: var(--surface-2); }
.menu-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}
.menu-ico .mc-icon { width: var(--ico-sm); height: var(--ico-sm); }
.menu-hint {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 2px 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
}
.menu-sep {
  height: 1px;
  background: var(--border-1);
  margin: var(--sp-1) var(--sp-2);
  list-style: none;
}
.menu-danger { color: var(--danger-text) !important; }
.menu-danger:hover { background: oklch(from var(--danger) l c h / 0.08) !important; }

/* 用户触发器 + 下拉卡片 */
/* 触发器就是头像：不套外框、不放箭头。可点区域靠 aria/title 之外
   的 focus ring 表达，视觉上只是一个圆。 */
.user-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-1);
  transition: transform var(--dur-fast) var(--ease-out-quart);
}
.user-trigger:hover { transform: scale(1.04); }
.user-trigger:active { transform: scale(0.97); }
.user-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.user-trigger[aria-expanded="true"] { transform: scale(1.04); }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, oklch(100% 0 0 / 0.3), transparent 70%),
    linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 1px 2px oklch(0% 0 0 / 0.15);
}
/* 已上传头像：图片铺满整个圆，首字母那层渐变被盖住 */
.user-avatar.has-image { background: var(--surface-2); }
.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.user-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--sp-2);
  line-height: 1.15;
  min-width: 0;
}
.user-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.user-caret {
  display: none;
}
/* The conversation avatar is larger than the account menu avatar. */
.user-trigger .user-avatar { width: 32px; height: 32px; font-size: var(--fs-sm); }
.user-trigger .user-name { max-width: 120px; font-size: var(--fs-sm); }
.user-trigger .user-role { font-size: var(--fs-xs); }

/* 用户卡片（菜单头部） */
/* 悬停展开：菜单和头像之间留一段不可见的连续区域，
   否则鼠标从头像移到菜单的途中就离开了 hover，菜单会闪一下消失。 */
.user-menu-anchor::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  height: 12px;
}
.user-dropdown {
  min-width: 260px;
  top: calc(100% + 8px) !important;
}
.user-dropdown .dropdown-header {
  border-bottom: 1px solid var(--border-1);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-3);
}
.user-card-name {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.user-card-role {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--brand-text);
  margin-top: 2px;
}

/* 通知菜单内容（动态填充） */
.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--fs-sm);
  color: var(--text-1);
  border-bottom: 1px dashed var(--border-1);
}
.notify-row:last-child { border-bottom: none; }
.notify-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notify-row-title { font-size: var(--fs-sm); color: var(--text-1); font-weight: 500; }
.notify-row-desc { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
.notify-row .notify-status {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 2px var(--sp-2);
  border-radius: var(--r-1);
}
.notify-status.is-on  { background: oklch(from var(--success) l c h / 0.15); color: var(--success); }
.notify-status.is-off { background: var(--surface-sunken); color: var(--text-3); }
.notify-row-meta {
  display: flex;
  justify-content: space-between;
  padding-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
}
.notify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-1);
  margin-top: var(--sp-2);
}

/* 通用开关（Switch）：用作通知菜单桌面通知 + 提示音的开启/关闭 */
.mc-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  flex-shrink: 0;
}
.mc-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mc-switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  transition: background var(--dur-fast) var(--ease-out-quart), border-color var(--dur-fast) var(--ease-out-quart);
}
.mc-switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: var(--surface-1);
  border-radius: 50%;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.2);
  transition: transform var(--dur-fast) var(--ease-out-quart), background var(--dur-fast) var(--ease-out-quart);
}
.mc-switch input:checked + .mc-switch-track {
  background: var(--brand);
  border-color: var(--brand);
}
.mc-switch input:checked + .mc-switch-track .mc-switch-thumb {
  transform: translateX(16px);
  background: white;
}
.mc-switch input:focus-visible + .mc-switch-track {
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.25);
}
.mc-switch input:disabled + .mc-switch-track {
  opacity: 0.5;
  cursor: not-allowed;
}

.notify-toggle {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-1);
  padding: 4px var(--sp-3);
  border-radius: var(--r-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.notify-toggle:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

/* 旧 user-info / user-role / btn-text 兼容（被新样式覆盖，保留兜底） */
.user-info { display: none; }

/* 未读徽章 — 品牌情绪点（兼容历史 .unread-badge 类名） */
.unread-badge {
  background: var(--danger);
  color: white;
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  min-width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px oklch(from var(--danger) l c h / 0.35);
  letter-spacing: 0.02em;
  animation: badge-pop 360ms var(--ease-out-expo);
}
.unread-badge.show { display: inline-flex; }
@keyframes badge-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* 侧栏「工作台」未读红点（取代顶部 pill）
   展开态（hover/focus-within → 220px）：数字 badge，定位在 nav-item 最右侧
   折叠态（默认 48px 未 hover）：纯 12px 圆点，骑在 icon 右上角，数字隐藏 */

/* 展开态：数字 badge，右对齐到 item 最右
   注意尺寸：min-width 必须 == height（18×18），否则 1 位数时宽>高，
   border-radius:999px 会被压成圆角矩形而不是正圆；2 位及以上靠 padding 自然长宽 → pill */
.ocp-sidebar .nav-unread {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: white;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px oklch(from var(--danger) l c h / 0.4);
  line-height: 1;
  pointer-events: none;
  animation: badge-pop 360ms var(--ease-out-expo);
  z-index: 1;
}
.ocp-sidebar .nav-unread[hidden] { display: none; }
/* ≥ 10 时留出更宽的下限（padding 已在主规则给足，这里只兜 min-width） */
.ocp-sidebar .nav-unread[data-wide="1"] { min-width: 22px; }

/* 折叠态（48px 窄版未 hover/focus-within）：纯 12px 圆点，骑在 icon 右上角
   —— top/right 各留 4px，使红点既与 nav-item 边缘有边距、又能跨在 icon 角上，
   文字溢出裁掉（无需 JS 切换 data-dot）。
   50% 而非 999px：即使将来宽高被改得不一致，也退化成椭圆而不是圆角矩形 */
.ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .nav-unread {
  top: 4px;
  right: 4px;
  transform: none;
  min-width: 12px;
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  /* font-size:0 而非只靠 overflow:hidden —— 「14」正好居中在 12px 盒内，
     overflow 裁不掉，会挤成一团白；置 0 后折叠态为纯圆点，无数字笔画 */
  font-size: 0;
  animation: none;
  box-shadow: none;     /* 曾用 2px 描边与窄栏同色，但深色主题下看起来就是一圈黑边 */
}
.ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .nav-unread[data-wide="1"] {
  min-width: 12px;
  width: 12px;
}

/* 兼容别名：旧 .btn-icon 已全量迁移到 .icon-btn */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

/* 三栏布局 */
.app-body { flex: 1; display: flex; overflow: hidden; min-height: 0; position: relative; padding-left: 48px; }

/* ===== 主内容视图：workbench / overview / kb / config 整组替换 ===== */
.app-view-panel {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  min-height: 0;
  animation: view-panel-in 220ms var(--ease-out-expo) both;
}
.app-view-panel.is-entering,
.app-view-panel.is-view-entering,
.config-content.is-tab-entering,
#conversation-panel.is-session-entering {
  animation: view-panel-in 220ms var(--ease-out-expo) both;
}
@keyframes view-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.app-view-panel[hidden] { display: none; animation: none; }
/* 会话列表与消息区水平排列 */
.workbench-view { flex-direction: row; }
/* 其它视图 = 单页，垂直滚动 */
.overview-view,
.kb-view,
.settings-view {
  flex-direction: column;
  overflow-y: auto;
  background: var(--surface-0);
}

/* 通用单页布局（总览/知识库/设置） */
.page-view {
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  flex: 1 1 auto;
  min-height: 0;
}
.page-view-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}
.page-view-header .muted { margin: 0; }
.page-view-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}
.page-view-body .config-content { padding: 0; }
.page-view-body .config-content > h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

/* 设置页：顶部 tabs 与内容分隔 */
.settings-view .settings-tabs {
  display: flex;
  gap: 2px;
  margin-top: var(--sp-2);
  padding: 4px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}
.settings-view .settings-tabs .tab-btn {
  flex: none;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  border-bottom: none;
}
.settings-view .settings-tabs .tab-btn.active {
  background: var(--surface-1);
  color: var(--text-1);
  font-weight: 500;
  box-shadow: var(--shadow-1);
}

/* 总览页（单页布局） */
.overview-view .overview-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.overview-view .overview-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.overview-view .overview-header .overview-sub {
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}
.overview-view .project-overview-grid { padding: 0; }

/* ==========================================================
   运营洞察（总览页 · 租户级只读）
   ------------------------------------------------------------
   设计约束（.impeccable.md）：
   - 发丝分隔线分区，不套卡片（避免"卡片套卡片"）
   - 数字是「行的右值」而非英雄指标大数字
   - 数字一律 font-mono + tabular-nums，保证纵向对齐、可扫读
   - 诚实优先：不可用的指标显式标注原因，绝不用 0 顶替
   ========================================================== */
.insight-rail {
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-1);
}

.insight-rail-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.insight-rail-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
/* 作用域标签：明确区分上方项目级卡片 vs 本区块的租户级口径 */
.insight-scope {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 2px 6px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
}

.insight-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: auto;
  flex-wrap: wrap;
}
.insight-field {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.insight-field input {
  width: 56px;
  padding: 3px 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  text-align: right;
}
.insight-field input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.insight-btn {
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-body);
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-quart),
              border-color var(--dur-fast) var(--ease-out-quart);
}
.insight-btn:hover {
  color: var(--text-1);
  border-color: var(--border-2);
}

/* 三列等宽；窄屏降为单列 */
.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 var(--sp-6);
}
@media (max-width: 1100px) {
  .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .insight-grid { grid-template-columns: minmax(0, 1fr); }
  .insight-controls { margin-left: 0; }
}

.insight-col { min-width: 0; }
.insight-col + .insight-col {
  padding-left: var(--sp-6);
  border-left: 1px solid var(--border-1);
}
@media (max-width: 1100px) {
  .insight-col:nth-child(3) {
    grid-column: 1 / -1;
    padding-left: 0;
    border-left: none;
    margin-top: var(--sp-5);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-1);
  }
}
@media (max-width: 720px) {
  .insight-col + .insight-col,
  .insight-col:nth-child(3) {
    padding-left: 0;
    border-left: none;
    margin-top: var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border-1);
  }
}

.insight-col-title {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 var(--sp-2);
  letter-spacing: 0.01em;
}
.insight-col-title + .insight-body { margin-bottom: var(--sp-5); }

/* ---- 指标行：label 左 / tabular 数字右，发丝线分隔 ---- */
.insight-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 5px 0;
  border-bottom: 1px solid var(--border-1);
  font-size: var(--fs-sm);
}
.insight-row:last-child { border-bottom: none; }
.insight-row > .k {
  color: var(--text-3);
  white-space: nowrap;
}
.insight-row > .v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  text-align: right;
  white-space: nowrap;
}
/* 单位弱化，不与数值争视觉权重 */
.insight-row > .v .unit {
  color: var(--text-3);
  font-size: var(--fs-xs);
  margin-left: 2px;
}
/* 「不可用」：明确区别于 0 */
.insight-row > .v.is-na { color: var(--text-3); font-size: var(--fs-xs); }
/* 「出站死信」：非 0 = 有客户没收到消息，必须一眼可见，不能和普通计数同色 */
.insight-row > .v.is-danger { color: var(--danger-text); font-weight: 600; }

/* ---- 信号列表：紧凑两行，异常项用左侧色条而非整行高亮 ---- */
.insight-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 4px 0 4px var(--sp-2);
  border-bottom: 1px solid var(--border-1);
  border-left: 2px solid var(--border-1);
  font-size: var(--fs-sm);
}
.insight-item:last-child { border-bottom: none; }
.insight-item.is-alert { border-left-color: var(--danger); }
.insight-item .t {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
  min-width: 68px;
}
.insight-item.is-alert .t { color: var(--danger-text); }
.insight-item .q {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.insight-item .n {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* 空状态：给出「为什么空」，而不是光秃秃一句「无数据」 */
.insight-empty {
  font-size: var(--fs-sm);
  color: var(--text-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-1);
}
.insight-note {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin: var(--sp-2) 0 0;
  line-height: 1.5;
}

/* ============ 会话列表 ============ */
.session-list {
  width: 320px;
  background: var(--surface-1);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.session-list-header {
  /* 高度与左侧 ocp-sidebar-top 严格对齐；三栏共用 --wb-pane-head-h，避免 ① 视觉错位 ② hover 展开时跳动 */
  height: var(--wb-pane-head-h);
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.session-list-header .count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: 500;
  margin-left: var(--sp-1);
}

/* 会话列表顶部右侧的工具栏（状态筛选 chip 入口） */
.session-list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}
#session-list-items { flex: 1; overflow-y: auto; }

/* Keep selection and handling next to the list, including on touch screens. */
.session-selection-toggle,
.session-batch-actions button {
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: var(--surface-1);
  color: var(--text-2);
  padding: 6px 9px;
  min-height: 32px;
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
}
.session-selection-toggle[aria-pressed="true"] { color: var(--brand-text); background: var(--surface-2); }
.session-batch-toolbar { flex-shrink: 0; padding: 9px 12px; border-bottom: 1px solid var(--border-1); }
.session-trash-toolbar[hidden] { display: none; }
.session-trash-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: var(--surface-2);
}
.session-trash-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-trash-toolbar button {
  flex-shrink: 0;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: var(--surface-1);
  color: var(--text-2);
  padding: 6px 9px;
  min-height: 32px;
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
}
.session-trash-toolbar button.is-danger { color: var(--danger-text); }
.session-trash-toolbar button:disabled { opacity: 0.5; cursor: wait; }
.session-batch-selection { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--text-2); }
.session-batch-selection label { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; cursor: pointer; }
.session-batch-selection input, .session-select-input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
#session-selection-count { font-family: var(--font-mono); white-space: nowrap; }
.session-batch-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.session-batch-actions .is-danger { color: var(--danger-text); }
.session-action-feedback, .session-trash-notice {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-1);
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: background var(--dur-fast) var(--ease-out-expo), color var(--dur-fast) var(--ease-out-expo);
}
.session-action-feedback.is-busy { color: var(--brand-text); background: var(--brand-soft); }
.session-action-feedback.is-success { color: var(--success-fill); background: var(--mc-success-soft, rgba(21, 128, 61, 0.11)); }
.session-action-feedback.is-error { color: var(--danger-text); background: var(--danger-soft); }
.session-select-control { display: none; align-self: stretch; align-items: center; padding: 0 4px; cursor: pointer; }
.session-list.is-selecting .session-select-control { display: flex; }
.session-item-open { display: flex; align-items: flex-start; gap: var(--sp-2); flex: 1; min-width: 0; padding: 0; background: transparent; color: inherit; border: 0; text-align: start; font: inherit; cursor: pointer; }
.session-row-action { flex-shrink: 0; appearance: none; width: 32px; min-height: 36px; padding: 4px; border: 1px solid transparent; border-radius: var(--r-1); color: var(--text-2); background: transparent; text-align: center; font: inherit; font-size: 18px; cursor: pointer; }
.session-row-action:hover { background: var(--surface-2); border-color: var(--border-1); }
.session-row-action option { font-size: 14px; color: var(--text-1); background: var(--surface-1); text-align: start; }
.session-item.is-selected { background: oklch(from var(--brand) l c h / 0.08); }
.session-item-open:focus-visible, .session-row-action:focus-visible,
.session-selection-toggle:focus-visible, .session-batch-actions button:focus-visible,
.session-select-input:focus-visible, #session-select-all:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.session-selection-toggle:disabled, .session-batch-actions button:disabled, .session-row-action:disabled { opacity: 0.5; cursor: wait; }

/* ===== 会话项：紧凑两行布局 =====
   行 1: 头像(+状态点) | 项目名 + 时间
   行 2:            | 渠道图标 + 最后一条消息
*/
.session-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 10px 13px 14px;
  border-bottom: 1px solid var(--border-1);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) var(--ease-out-quart);
}
/* 左侧活跃指示条 */
.session-item::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: transparent;
  transform: scaleY(0.35);
  transition: background var(--dur-fast) var(--ease-out-quart),
              transform 220ms var(--ease-spring),
              box-shadow var(--dur-fast) var(--ease-out-quart);
}
.session-item:hover { background: var(--surface-2); }
.session-item:hover::before {
  background: oklch(from var(--text-3) l c h / 0.45);
  transform: scaleY(0.65);
}
.session-item:hover .session-avatar {
  transform: scale(1.04);
}
.session-item.active {
  background: oklch(from var(--brand) l c h / 0.09);
}
.session-item.active::before {
  background: var(--brand);
  transform: scaleY(1);
  box-shadow: 0 0 12px oklch(from var(--brand) l c h / 0.55);
}

/* ===== 发件人首字母头像 + 状态点叠加 ===== */
.session-item-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 36px; height: 36px;
}
.session-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  background: oklch(from var(--brand) l c h / 0.18);
  color: var(--brand-text);
  border: 1px solid oklch(from var(--brand) l c h / 0.25);
  transition: transform 200ms var(--ease-spring);
}
.avatar-tone-feishu  { background: oklch(from var(--ch-feishu)  l c h / 0.16); color: light-dark(oklch(38% 0.18 240), oklch(82% 0.14 240)); border-color: oklch(from var(--ch-feishu) l c h / 0.3); }
.avatar-tone-chat    { background: oklch(from var(--ch-chat)    l c h / 0.16); color: light-dark(oklch(38% 0.18 160), oklch(82% 0.14 160)); border-color: oklch(from var(--ch-chat) l c h / 0.3); }
.avatar-tone-wechat  { background: oklch(from var(--ch-wechat)  l c h / 0.16); color: light-dark(oklch(40% 0.16 245), oklch(82% 0.12 245)); border-color: oklch(from var(--ch-wechat) l c h / 0.3); }
.avatar-tone-dingtalk{ background: oklch(from var(--ch-dingtalk) l c h / 0.16); color: light-dark(oklch(40% 0.16 250), oklch(82% 0.12 250)); border-color: oklch(from var(--ch-dingtalk) l c h / 0.3); }
.avatar-tone-slack   { background: oklch(from var(--ch-slack)   l c h / 0.16); color: light-dark(oklch(40% 0.18 30),  oklch(82% 0.12 30));  border-color: oklch(from var(--ch-slack) l c h / 0.3); }
.avatar-tone-whatsapp{ background: oklch(from var(--ch-whatsapp) l c h / 0.16); color: light-dark(oklch(38% 0.18 145), oklch(82% 0.14 145)); border-color: oklch(from var(--ch-whatsapp) l c h / 0.3); }
.avatar-tone-line    { background: oklch(from var(--ch-line)    l c h / 0.16); color: light-dark(oklch(40% 0.16 180), oklch(82% 0.12 180)); border-color: oklch(from var(--ch-line) l c h / 0.3); }
.avatar-tone-telegram{ background: oklch(from var(--ch-telegram) l c h / 0.16); color: light-dark(oklch(40% 0.18 220), oklch(82% 0.12 220)); border-color: oklch(from var(--ch-telegram) l c h / 0.3); }
.avatar-tone-email   { background: oklch(from var(--ch-email)   l c h / 0.16); color: light-dark(oklch(42% 0.14 60), oklch(84% 0.12 60)); border-color: oklch(from var(--ch-email) l c h / 0.3); }
.avatar-tone-webhook { background: oklch(from var(--ch-webhook) l c h / 0.16); color: light-dark(oklch(45% 0.10 280), oklch(82% 0.08 280)); border-color: oklch(from var(--ch-webhook) l c h / 0.3); }
.avatar-tone-default { background: var(--surface-2); color: var(--text-2); border-color: var(--border-1); }

/* 状态指示：叠加在头像右上角 */
.status-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18);
  z-index: 1;
  font-variant-numeric: tabular-nums;
}
.dot-unread {
  background: #EF4444;
  color: white;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1);
  animation: badge-pop 360ms var(--ease-spring), unread-breathe 2.6s ease-in-out 400ms infinite;
}
@keyframes unread-breathe {
  0%, 100% { box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1), 0 0 0 0 rgba(239, 68, 68, 0.35); }
  50%      { box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1), 0 0 0 5px rgba(239, 68, 68, 0); }
}
.dot-ai-replied {
  background: #6366F1;
  width: 12px; min-width: 12px; height: 12px;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1);
}
.dot-pending-agent {
  background: #F59E0B;
  width: 12px; min-width: 12px; height: 12px;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1);
}
/* 已回复：绿色对勾，去红点 */
.status-check {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #22C55E;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.18), 0 0 0 2px var(--surface-1);
  z-index: 1;
}

/* ===== 右侧 body：两行 ===== */
.session-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  line-height: 1.4;
}
.session-item-row { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }

/* 行 1：项目名（title） + 时间 */
.session-item-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-1);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item.active .session-item-title { color: var(--brand-text); }
.session-item-time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.session-item.active .session-item-time { color: var(--brand-text); }

/* 渠道官方图标：显示在项目名称左侧（优先品牌 SVG，失败回退线条 icon） */
.session-item-channel-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  color: var(--text-3);
  opacity: 0.9;
  position: relative;
}
.session-item-channel-icon .mc-icon { width: var(--ico-sm); height: var(--ico-sm); }
/* 品牌 SVG 图标：固定 14×14，SVG 自带品牌色 */
.session-item-channel-logo {
  width: 14px; height: 14px;
  object-fit: contain;
}
.session-item-channel-logo.broken { display: none; }
/* 加载成功后藏起 fallback，避免 SVG 透明区露出线条 icon */
.session-item-channel-logo:not(.broken) ~ .session-item-channel-fallback { display: none; }
.ch-tone-feishu  { color: var(--ch-feishu); }
.ch-tone-chat    { color: var(--ch-chat); }
.ch-tone-wechat  { color: var(--ch-wechat); }
.ch-tone-dingtalk{ color: var(--ch-dingtalk); }
.ch-tone-slack   { color: var(--ch-slack); }
.ch-tone-whatsapp{ color: var(--ch-whatsapp); }
.ch-tone-line    { color: var(--ch-line); }
.ch-tone-telegram{ color: var(--ch-telegram); }
.ch-tone-email   { color: var(--ch-email); }
.ch-tone-webhook { color: var(--ch-webhook); }
.ch-tone-default { color: var(--text-3); }

.session-item-preview-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}
.session-item:hover .session-item-preview-text { color: var(--text-1); }

/* 行 2：渠道官方图标 + 项目名称胶囊标签 */
.session-item-project-pill {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item.active .session-item-project-pill {
  background: oklch(from var(--brand) l c h / 0.16);
  color: var(--brand-text);
}

/* ===== 空态 ===== */
.session-empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-2);
}
.session-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--sp-3);
  opacity: 0.4;
  color: var(--text-2);
  border-radius: var(--r-3);
  background: var(--surface-sunken);
}
.session-empty-icon .mc-icon { width: 28px; height: 28px; }
.session-empty-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}
.session-empty-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.55;
}

/* 会话列表底部加载更多 sentinel */
.session-list-sentinel {
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  min-height: 40px;
  line-height: 40px;
}

/* 渠道小色条（保留兼容，admin 配置页仍可能用） */
.ch-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

/* ============ 会话详情 ============ */
.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-0);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  text-align: center;
  padding: var(--sp-7);
  min-height: 0;
  overflow-y: auto;
}
.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  margin-bottom: var(--sp-5);
  opacity: 0.55;
  color: var(--text-3);
  border-radius: 50%;
  background: var(--surface-sunken);
}
.empty-icon .mc-icon { width: 40px; height: 40px; }
.empty-state h3 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-2);
  color: var(--text-2);
}
.empty-state p { font-size: var(--fs-sm); max-width: 380px; line-height: 1.6; }

#conversation-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.email-reply-address {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  text-align: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.email-reply-address:focus-visible, .email-session-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
.email-html-contacts, .email-reply-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: var(--fs-xs);
}
.email-html-contacts { padding: 8px 0; }
.email-html-contacts > span { color: var(--text-3); }
.email-reply-links { padding: 10px 20px; border-bottom: 1px solid var(--border-1); }
.email-reply-links[hidden] { display: none; }
.email-session-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  cursor: pointer;
  overflow-wrap: anywhere;
  text-align: left;
}

.conv-header {
  height: var(--wb-pane-head-h);
  min-height: var(--wb-pane-head-h);
  box-sizing: border-box;
  padding: 0 var(--sp-5);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-1);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; /* 左：头像  中：信息  右：操作 */
  align-items: center;
  column-gap: var(--sp-3);
  flex-shrink: 0;
}
.conv-user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; grid-column: 1; }
/* 窄屏主从视图的返回键：只在手机/折叠屏/平板竖屏出现 */
.conv-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--ctl-h-touch);
  height: var(--ctl-h-touch);
  padding: 0;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  cursor: pointer;
}
.conv-back-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.conv-back-btn .mc-icon { width: var(--ico-md); height: var(--ico-md); }
/* 关闭当前会话窗口：只收起详情，不归档/删除 */
.conv-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.conv-close-btn:hover {
  color: var(--text-1);
  background: var(--surface-sunken);
  border-color: var(--border-1);
}
.conv-close-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.conv-close-btn .mc-icon { width: var(--ico-md); height: var(--ico-md); }
.conv-header > .user-info { grid-column: 2; }   /* 中列：用户名 + 元信息 */
.conv-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); } /* 右列：状态贴右 */
.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), oklch(from var(--accent) l c h));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--fs-md);
  font-family: var(--font-display);
  box-shadow: 0 2px 8px oklch(from var(--brand) l c h / 0.3);
  flex-shrink: 0;
}
.user-info {
  display: flex; flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  overflow: hidden;
}
.user-name {
  font-weight: 600;
  font-size: var(--fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.user-meta {
  display: flex; align-items: center;
  flex-wrap: nowrap;
  gap: var(--sp-2);
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: left;
  min-width: 0;
  overflow: hidden;
}
.meta-line {
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-3);
}
.meta-line.is-project {
  padding: 1px 8px;
  background: var(--brand-soft);
  color: var(--brand-text);
  border-radius: 999px;
  font-weight: 500;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--sp-2);
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.badge.project { background: var(--brand-soft); color: var(--brand-text); }
.badge.channel {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-1);
}
.badge.channel .ch-dot { background: var(--brand); }

.status-text {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: 2px var(--sp-2);
  background: var(--surface-2);
  border-radius: var(--r-1);
}
.status-text.pending_agent { color: var(--accent-text); background: var(--accent-soft); }
.status-text.pending_user { color: var(--brand-text); background: var(--brand-soft); }

/* 次按钮 = 描边幽灵。
 * 与 .btn-primary 共享同一套尺寸（--ctl-h / --r-2 / --fs-sm）——
 * "次"只意味着视觉权重更低，不意味着更矮更小。 */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--ctl-h);
  background: transparent;
  border: 1px solid var(--border-2);
  padding: 0 var(--sp-4);
  border-radius: var(--r-2);
  font-family: inherit;
  font-weight: 500;
  font-size: var(--fs-sm);
  line-height: 1;
  white-space: nowrap;
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart),
              border-color var(--dur-fast) var(--ease-out-quart),
              color var(--dur-fast) var(--ease-out-quart);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: oklch(from var(--brand) l c h / 0.45);
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* 消息流 */
.message-stream {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  scroll-behavior: smooth;
  position: relative;   /* 拖拽上传覆盖层的定位上下文 */
}
.message {
  max-width: 72%;
  min-width: 0;
  flex: 0 0 auto;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-3);
  font-size: var(--fs-base);
  line-height: 1.58;
  position: relative;
  animation: msg-in 260ms var(--ease-out-expo) both;
}
@keyframes msg-in {
  0% { transform: translateY(8px) scale(0.985); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
/* 全局搜索 / Harness 会话引用跳到某条消息时的短暂高亮 */
.message-stream .message.is-search-target {
  box-shadow: 0 0 0 2px var(--brand), 0 0 0 8px color-mix(in oklab, var(--brand) 20%, transparent);
  animation: searchTargetPulse 1.8s var(--ease-out-expo);
}
@keyframes searchTargetPulse {
  0% { box-shadow: 0 0 0 2px var(--brand), 0 0 0 12px color-mix(in oklab, var(--brand) 30%, transparent); }
  100% { box-shadow: 0 0 0 2px var(--brand), 0 0 0 8px color-mix(in oklab, var(--brand) 20%, transparent); }
}
.message.inbound {
  align-self: flex-start;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  border-bottom-left-radius: var(--r-1);
}
.message.outbound { align-self: flex-end; border-bottom-right-radius: var(--r-1); }
.message.outbound.bot {
  background: var(--brand-fill);
  color: var(--text-inverse);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.18), 0 2px 10px -3px var(--brand-shadow);
}
/* 人工客服 / 其他渠道同步回复气泡（克制浅信号蓝表面 + 发丝边框，遵循 DESIGN.md，与 AI 实心信号蓝清晰区分） */
.message.outbound.staff {
  background: color-mix(in srgb, var(--mc-accent, #2563eb) 7%, var(--mc-bg-surface, #ffffff));
  color: var(--text-1);
  border: 1px solid color-mix(in srgb, var(--mc-accent, #2563eb) 22%, var(--border-1));
  box-shadow: var(--shadow-1), var(--inner-highlight);
}
:root[data-theme="dark"] .message.outbound.staff,
.dark-mode .message.outbound.staff {
  background: color-mix(in srgb, var(--mc-accent, #60a5fa) 13%, var(--mc-bg-surface, #0f141e));
  border-color: color-mix(in srgb, var(--mc-accent, #60a5fa) 28%, var(--border-1));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .message.outbound.staff {
    background: color-mix(in srgb, var(--mc-accent, #60a5fa) 13%, var(--mc-bg-surface, #0f141e));
    border-color: color-mix(in srgb, var(--mc-accent, #60a5fa) 28%, var(--border-1));
  }
}
.message.outbound.staff .message-meta,
.message.outbound.staff .message-footer,
.message.outbound.staff .message-delivery,
.message.outbound.staff .msg-translate-btn {
  color: var(--text-3);
}
.message.outbound.staff .msg-source-lang {
  background: var(--surface-2);
  border-color: var(--border-1);
  color: var(--text-2);
}
.message.outbound.staff .msg-translation {
  border-top-color: var(--border-1);
}
.message.outbound.staff .msg-translation-head { color: var(--text-3); }
.message.outbound.staff .msg-translation-lang,
.message.outbound.staff .msg-translation-text { color: var(--text-1); }
.message.outbound.staff .mc-attach-show { border-color: var(--border-1); }
.message.outbound.staff .mc-file-link {
  background: var(--surface-1);
  border-color: var(--border-1);
  color: var(--text-1);
}
.message.outbound.staff .mc-file-link:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}
.message.outbound.staff .email-info-trigger {
  color: var(--text-3);
  border-color: var(--border-1);
  background: var(--surface-1);
}
.message.outbound.staff .email-info-trigger:hover {
  color: var(--text-1);
  background: var(--surface-2);
}
.message.outbound.staff .msg-delivery-retry {
  color: var(--mc-accent, #2563eb);
  border-color: color-mix(in srgb, var(--mc-accent, #2563eb) 40%, var(--border-1));
}
.message-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: 4px;
  display: flex; gap: var(--sp-1);
}
.message.outbound .message-meta { color: oklch(from var(--text-inverse) l c h / 0.7); }

/* 消息底部一行：谁发的（含原文语言标签）在左，时间戳固定右下角。
   以前这些在可折叠的「消息详情」里，邮件气泡甚至没有时间 —— 客服要判断
   「隔了多久没回」得点开横幅看，所以改成常显的一行。 */
.message-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.4;
}
.message-footer .message-author { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-footer .message-time {
  margin-left: auto;      /* 时间戳永远贴右侧 */
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.message.outbound .message-footer { color: oklch(from var(--text-inverse) l c h / 0.72); }
.message-email .message-footer { margin-top: var(--sp-3); }
.msg-source-lang {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--text-3);
}
.message.outbound .msg-source-lang {
  background: oklch(from var(--text-inverse) l c h / 0.15);
  border-color: oklch(from var(--text-inverse) l c h / 0.25);
  color: oklch(from var(--text-inverse) l c h / 0.8);
}
.message-citations {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.message-citations .mc-cite-ico { width: 12px; height: 12px; flex-shrink: 0; }
.message.outbound .message-citations {
  color: oklch(from var(--text-inverse) l c h / 0.7);
  border-top-color: oklch(from var(--text-inverse) l c h / 0.2);
}

/* ---- 消息工具行（「翻译」按钮）----
 * 刻意做得不显眼：小字号 + 弱化色 + 半透明，hover 消息时才完全显现。
 * 它只是辅助阅读，不该和消息内容抢注意力。 */
.message-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  opacity: 1;
  flex-wrap: wrap;
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}
.message:hover .message-tools,
.message-tools:focus-within { opacity: 1; }

.msg-translate-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart),
              border-color var(--dur-fast) var(--ease-out-quart);
}
.msg-translate-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border-1);
}
.msg-translate-btn:focus-visible {
  outline: none;
  color: var(--text-1);
  border-color: var(--brand);
  box-shadow: 0 0 0 2px oklch(from var(--brand) l c h / 0.2);
}
.msg-translate-btn.is-loading { opacity: 0.6; cursor: progress; }
.message.outbound .msg-translate-btn { color: oklch(from var(--text-inverse) l c h / 0.75); }

/* ---- 译文块：原文下方并排追加，原文始终保留 ---- */
.msg-translation {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid oklch(from var(--brand) l c h / 0.55);
  background: oklch(from var(--brand) l c h / 0.07);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  animation: translationIn var(--dur-base) var(--ease-out-expo);
}
.msg-translation.is-hidden { display: none; }
@keyframes translationIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-translation-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.03em;
  color: var(--text-3);
}
.msg-translation-lang { font-weight: 600; color: var(--brand-text); }
.msg-translation-engine { opacity: 0.75; }
.msg-translation-text {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
}
/* 出站气泡（品牌/成功实色底）内的译文要反色，否则看不清 */
.message.outbound .msg-translation {
  border-left-color: oklch(from var(--text-inverse) l c h / 0.6);
  background: oklch(from var(--text-inverse) l c h / 0.12);
}
.message.outbound .msg-translation-head { color: oklch(from var(--text-inverse) l c h / 0.75); }
.message.outbound .msg-translation-lang { color: var(--text-inverse); }
.message.outbound .msg-translation-text { color: var(--text-inverse); }
.message-pending-badge {
  position: absolute;
  top: -8px; right: -8px;
  background: var(--accent);
  color: var(--text-inverse);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* ============================================================================
 * 输入区（方案 A · 一体输入栏）
 * 结构：附件存在时显示文件行；其余操作与文字区保持在同一行。
 *
 * .composer-dock 是输入区的定位锚点。AI 草稿不在这里：
 * 它作为一条「还没发出去的消息」渲染在 #message-stream 末尾（见 app.js）。
 * ========================================================================== */
.composer-dock {
  position: relative;
  flex-shrink: 0;
}

.composer {
  background: var(--surface-1);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--wb-pane-foot-h);
  padding: var(--sp-3) var(--sp-4);
  position: relative;
  z-index: 5;
}

/* ---- 附件区（工作台会话与 Agent Harness 共用；无附件时整体不占位） ---- */
.composer-attachments {
  display: none;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--sp-2);
  padding: 2px 2px var(--sp-2);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  animation: composerAttachIn var(--dur-base) var(--ease-out-expo);
}
.composer-attachments.active:not([hidden]) { display: flex; }
.composer-attachments[hidden] { display: none; }
@keyframes composerAttachIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.mc-attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface-sunken);
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) var(--ease-out-quart);
  animation: mcThumbIn var(--dur-base) var(--ease-out-expo) both;
}
.mc-attach-thumb:hover,
.mc-attach-thumb:focus-within {
  border-color: color-mix(in oklab, var(--brand) 55%, var(--border-2));
}
@keyframes mcThumbIn {
  from { opacity: 0; transform: scale(0.88); }
  to { opacity: 1; transform: scale(1); }
}
.mc-attach-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mc-attach-thumb img,
.mc-attach-thumb .mc-attach-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mc-attach-thumb .thumb-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 100%;
  padding: 6px 4px;
  color: var(--text-2);
  text-align: center;
}
.mc-attach-thumb .thumb-file .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mc-attach-thumb .thumb-file .ext {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  background: color-mix(in oklab, currentColor 12%, transparent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 按文件类型给轻色调，不刺眼、明暗主题都清晰 */
.mc-attach-thumb[data-file-tone="pdf"] .thumb-file { color: light-dark(oklch(52% 0.19 25), oklch(74% 0.16 25)); }
.mc-attach-thumb[data-file-tone="doc"] .thumb-file { color: light-dark(oklch(50% 0.17 255), oklch(73% 0.14 250)); }
.mc-attach-thumb[data-file-tone="sheet"] .thumb-file { color: light-dark(oklch(48% 0.15 152), oklch(73% 0.14 152)); }
.mc-attach-thumb[data-file-tone="slide"] .thumb-file { color: light-dark(oklch(56% 0.17 50), oklch(76% 0.15 55)); }
.mc-attach-thumb[data-file-tone="archive"] .thumb-file { color: light-dark(oklch(54% 0.15 78), oklch(78% 0.14 82)); }
.mc-attach-thumb[data-file-tone="code"] .thumb-file { color: light-dark(oklch(50% 0.17 295), oklch(76% 0.15 295)); }
.mc-attach-thumb[data-file-tone="text"] .thumb-file,
.mc-attach-thumb[data-file-tone="generic"] .thumb-file { color: var(--text-2); }

/* hover / focus 时在底部浮现文件名，常态保持干净方块 */
.mc-attach-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 5px;
  background: oklch(14% 0.012 260 / 0.84);
  color: oklch(98% 0 0);
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity var(--dur-fast) var(--ease-out-quart),
              transform var(--dur-fast) var(--ease-out-quart);
}
.mc-attach-thumb:hover .mc-attach-name,
.mc-attach-thumb:focus-within .mc-attach-name {
  opacity: 1;
  transform: translateY(0);
}

/* 右上角紧凑删除按钮（18px，与 64px 圆角方块成比例） */
.mc-attach-thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: oklch(16% 0.012 260 / 0.72);
  color: oklch(98% 0 0);
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity var(--dur-fast) var(--ease-out-quart),
              transform var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart);
}
.mc-attach-thumb:hover .remove,
.mc-attach-thumb:focus-within .remove,
.mc-attach-thumb.is-error .remove,
.mc-attach-thumb .remove:focus-visible {
  opacity: 1;
  transform: scale(1);
}
.mc-attach-thumb .remove:hover {
  background: var(--danger);
  transform: scale(1.08);
}
.mc-attach-thumb .remove:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* 上传中：虚线框 + 居中旋转进度图标（图片仍保留底层缩略图预览） */
.mc-attach-thumb.uploading {
  border-style: dashed;
  border-color: var(--brand);
}
.mc-attach-thumb.uploading .mc-attach-img,
.mc-attach-thumb.uploading .thumb-file {
  opacity: 0.48;
}
.mc-attach-spinner {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-text);
  pointer-events: none;
}
.mc-attach-spinner svg {
  animation: mcAttachSpin 900ms linear infinite;
}
@keyframes mcAttachSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 上传失败 */
.mc-attach-thumb.is-error {
  border-color: color-mix(in oklab, var(--danger) 65%, var(--border-2));
  background: color-mix(in oklab, var(--danger) 8%, var(--surface-sunken));
}
.mc-attach-err-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* 附件折叠标签（>4 个时） */
.mc-attach-more {
  flex: 0 0 auto;
  align-self: center;
  padding: 0 var(--sp-3);
  height: 32px;
  border-radius: var(--r-pill);
  border: 1px dashed var(--border-2);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.mc-attach-more:hover {
  border-color: var(--brand);
  color: var(--brand-text);
  background: oklch(from var(--brand) l c h / 0.06);
}

/* ---- 共用输入组件（工作台客户对话 / Agent Harness） ----
 * 设计原则见 DESIGN.md「输入组件一致性」：
 *   1. 焦点环画在 .composer-frame 上，覆盖整个输入组件，两处保持一致；
 *   2. 底部不常驻快捷键提示；只有状态/错误/字数告警时才显示 .composer-hint-row；
 *   3. 两个输入组件共用这里的表面、边框、圆角、字号与控件尺寸。
 * 新增输入区请复用这几个类，不要再复制一份外观。 */
.composer-frame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  background: var(--surface-1);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-base) var(--ease-out-expo),
              background var(--dur-base) var(--ease-out-expo),
              box-shadow var(--dur-base) var(--ease-out-expo);
}
.composer-frame:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px color-mix(in oklab, var(--brand) 13%, transparent), var(--shadow-2);
}
.composer-frame.is-dragover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 16%, transparent);
}
.composer-line {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  min-width: 0;
  padding: 6px 7px 6px 9px;
}
.composer-input {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.composer-textarea {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  height: 34px;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--r-1);
  resize: none;
  /* 高度由 autoGrowReplyInput()/autoResize() 按内容测量；这里只给下限。 */
  max-height: none;
  overflow-y: auto;
  outline: none;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
}
.composer-textarea::placeholder { color: var(--text-3); }
.composer-textarea:hover,
.composer-textarea:focus,
.composer-textarea:focus-visible {
  background: transparent;
  box-shadow: none;
  outline: none;
}
.composer-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.composer-attach:hover,
.composer-attach[aria-expanded="true"] {
  border-color: var(--border-2);
  background: var(--surface-sunken);
  color: var(--brand-text);
}
.composer-attach:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-attach:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.composer-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 84px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid color-mix(in oklab, var(--brand) 45%, var(--border-1));
  border-radius: var(--r-2);
  background: var(--brand-fill);
  color: var(--text-inverse);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px var(--brand-shadow);
  transition: filter var(--dur-fast), box-shadow var(--dur-base) var(--ease-out-expo),
              background var(--dur-base) var(--ease-out-expo), opacity var(--dur-base) var(--ease-out-expo);
}
.composer-submit:not(:disabled):hover { filter: brightness(1.06); }
.composer-submit:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.composer-submit:disabled { opacity: 0.4; cursor: default; filter: grayscale(0.35); }
/* 底部状态行：空闲时不占高度，只有状态/错误/字数告警时才出现。
 * 不再常驻快捷键提示 —— 快捷键已经足够通用，底部只保留真正需要看的信息。 */
.composer-hint-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 22px;
  padding: 4px 9px;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.4;
}
.composer-hint-row.is-visible { display: flex; }
.composer-status-message {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--danger-text);
}

.composer-tools {
  position: relative;
  flex: 0 0 auto;
}
.composer-tool-trigger {
  /* 尺寸由共用 .composer-attach 统一提供（桌面 34 / 触屏 44） */
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-2);
}
.composer-tool-trigger:hover,
.composer-tool-trigger[aria-expanded="true"] {
  border-color: var(--border-2);
  background: var(--surface-sunken);
  color: var(--brand-text);
}
.composer-tool-trigger:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-tool-trigger .ico,
.composer-tool-trigger .mc-icon {
  width: var(--ico-lg);
  height: var(--ico-lg);
}
.composer-tools-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--sp-2));
  z-index: 30;
  display: grid;
  gap: var(--sp-1);
  min-width: 200px;
  padding: var(--sp-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
}
.composer-tools-menu[hidden] { display: none; }
.composer-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--ctl-h-touch);
  padding: 0 var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
}
.composer-menu-item:hover,
.composer-menu-item:focus-visible {
  border-color: var(--border-1);
  background: var(--surface-sunken);
  outline: none;
}
.composer-menu-item .ico,
.composer-menu-item .mc-icon { width: var(--ico-md); height: var(--ico-md); }
.composer-menu-hint {
  padding: 0 var(--sp-3) var(--sp-1);
  color: var(--text-3);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

/* 超限态：边框与焦点环一起转成危险色，状态文案仍由底部 .composer-hint-row 承担 */
.composer-textarea.over-limit {
  border-color: transparent;
  box-shadow: none;
}
.composer-frame:has(textarea.over-limit) {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 12%, transparent);
}

/* 字符计数显示在按需反馈行，正文不为它预留宽度或高度。 */
.composer-counter {
  display: none;
  align-items: center;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  color: var(--text-3);
  background: var(--surface-sunken);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out-expo),
              color var(--dur-base) var(--ease-out-expo),
              background var(--dur-base) var(--ease-out-expo);
  font-variant-numeric: tabular-nums;
}
.composer-counter.show { display: inline-flex; opacity: 1; }
.composer-counter.warn { color: var(--accent-text); }
.composer-counter.over {
  color: var(--text-inverse);
  background: var(--danger);
  font-weight: 600;
}

/* 字数进度条：只在有内容时显示，不为初始空状态留下空白 */
.composer-meter {
  display: none;
  height: 2px;
  margin: 0 9px;
  background: var(--border-1);
  border-radius: var(--r-pill);
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out-expo);
}
.composer-meter.show { display: block; opacity: 1; }
.composer-meter-fill {
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: var(--r-pill);
  transition: width var(--dur-base) var(--ease-out-expo),
              background var(--dur-base) var(--ease-out-expo);
}
.composer-meter-fill.warn { background: var(--accent); }
.composer-meter-fill.over { background: var(--danger); }

/* 底部状态行的外观由共用输入组件统一提供（.composer-hint-row） */

/* 软键盘弹出时优先保证输入行可见：收紧外框与行内边距，
 * 底部提示仍留在框内，但不再为它保留最小高度。 */
.composer.is-short-viewport {
  min-height: 0;
  padding-block: 6px;
}
.composer.is-short-viewport .composer-line { padding-block: 4px; }
.composer.is-short-viewport .composer-hint-row { min-height: 0; padding-block: 2px; }

/* ---- 工具入口（菜单内的附件按钮） ---- */
.composer-tool:not(.composer-tool-trigger) {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 6px var(--sp-3);
  min-height: var(--ctl-h);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.composer-tool:not(.composer-tool-trigger):hover {
  border-color: var(--brand);
  color: var(--brand-text);
  background: oklch(from var(--brand) l c h / 0.06);
}
.composer-tool:not(.composer-tool-trigger):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.composer-tool:not(.composer-tool-trigger):active { transform: scale(0.97); }
.composer-tool .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}
.composer-tool .ico .mc-icon { width: var(--ico-sm); height: var(--ico-sm); }
.composer-tool.busy {
  pointer-events: none;
  opacity: 0.6;
}
/* 发送按钮（4 态）：基础外观来自共用 .composer-submit，这里只保留工作台特有状态 */
/* 超限态：文案换成「请缩减」 */
.composer-send.over-limit {
  background: var(--danger);
}
/* loading：旋转环 */
.composer-send.loading { pointer-events: none; }
.composer-send .spinner {
  width: 13px;
  height: 13px;
  border: 2px solid oklch(from var(--text-inverse) l c h / 0.35);
  border-top-color: var(--text-inverse);
  border-radius: var(--r-pill);
  animation: composerSpin 0.7s linear infinite;
}
@keyframes composerSpin { to { transform: rotate(360deg); } }
/* success：短暂 ✓ 反馈 */
.composer-send.success {
  background: var(--success-fill);
  color: var(--text-inverse);
}

/* AI 正在回复：等待态。
 * 刻意与「人工发送中」区分 —— 这不是自己在发，而是在等 AI 处理，
 * 所以用弱化的品牌色 + 缓慢呼吸，而不是进行中的实色。 */
.composer-send.ai-pending {
  background: oklch(from var(--brand) l c h / 0.5);
  color: oklch(from var(--text-inverse) l c h / 0.92);
  opacity: 1;                       /* 覆盖 :disabled 的 0.45，否则双重变淡 */
  box-shadow: none;
  animation: aiPendingBreathe 1.8s var(--ease-out-expo) infinite;
  /* 【关键】覆盖 .loading 的 pointer-events:none ——
     这个按钮此时刻意保持可点，点它就是「停止本次自动回复」 */
  pointer-events: auto;
  cursor: pointer;
}
.composer-send.ai-pending:hover {
  background: oklch(from var(--brand) l c h / 0.7);
  animation-play-state: paused;     /* hover 时停呼吸，明确「现在可以点」 */
}
@keyframes aiPendingBreathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.68; }
}

/* ---- ② AI 草稿气泡（对话流末尾，可改可发） ---- */
/*
 * 草稿就是「一条还没发出去的消息」，所以它长在消息流里：出站对齐、同一宽度约束，
 * 用虚线描边 + 淡品牌底区分「尚未发送」。早先是 composer 上方的悬浮胶囊条 ——
 * 草稿和对话被输入框隔开，客服得来回看两处才知道 AI 到底建议回什么，
 * 长草稿还会被单行截断成省略号。
 *
 * 交互：点正文进编辑；编辑态里可以用一句「想怎么改」让 AI 重新生成
 * （POST /sessions/:sid/draft/rewrite，只返回文本，不落库、不发送）；
 * 发送复用 /sessions/:sid/reply，投递与重试链路完全不变。
 */
.draft-bubble {
  align-self: flex-end;
  max-width: 72%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-3);
  border-bottom-right-radius: var(--r-1);
  border: 1px dashed oklch(from var(--brand) l c h / 0.56);
  background:
    linear-gradient(135deg, oklch(from var(--brand) l c h / 0.085) 0%, oklch(from var(--brand) l c h / 0.03) 100%),
    var(--surface-1);
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.2),
    0 6px 20px -8px oklch(from var(--brand) l c h / 0.22);
  color: var(--text-1);
  font-size: var(--fs-base);
  line-height: 1.58;
  animation: msg-in 280ms var(--ease-out-expo) both;
  transition: width 260ms var(--ease-out-expo),
              border-color 180ms var(--ease-out-expo),
              box-shadow 220ms var(--ease-out-expo),
              opacity 180ms var(--ease-out-expo);
}
.draft-bubble.is-regenerating {
  opacity: 0.78;
  border-style: dashed;
  border-color: var(--brand);
  animation: aiPendingBreathe 1.4s ease-in-out infinite;
}
/* 编辑态撑满可用宽度：view 态由正文决定宽度（短稿子不该占一整行），
 * 但编辑框是输入控件，窄到 300px 连一句话都看不全。 */
.draft-bubble.is-editing {
  width: 72%;
  border-style: dashed;
  border-color: var(--brand);
  box-shadow:
    0 12px 32px -10px oklch(from var(--brand) l c h / 0.28);
}

.draft-bubble-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.draft-bubble-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--brand-fill);
  color: var(--text-inverse);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.draft-bubble-flag {
  padding: 1px 7px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--danger-text);
  background: oklch(from var(--danger) l c h / 0.12);
  border: 1px solid oklch(from var(--danger) l c h / 0.3);
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.draft-bubble-conf {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-1);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.draft-bubble-why {
  min-width: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

/* 正文：可点即改。hover 给一点品牌底，明确「这块能编辑」 */
.draft-bubble-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: var(--r-2);
  cursor: text;
  transition: background var(--dur-fast) var(--ease-out-quart);
}
.draft-bubble-body:hover { background: oklch(from var(--brand) l c h / 0.08); }
.draft-bubble-body:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.draft-bubble-body.is-placeholder {
  color: var(--text-2);
  cursor: default;
}
.draft-bubble-body.is-placeholder:hover { background: transparent; }

/* 编辑态 / 操作行用 hidden 切换；这些元素自带 display:flex，
 * 必须显式压回 none —— 否则作者样式会盖掉浏览器默认的 [hidden]。 */
.draft-bubble-editor[hidden],
.draft-bubble-foot[hidden],
.draft-bubble-body[hidden],
.draft-bubble-error[hidden] { display: none; }

.draft-bubble-editor {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  animation: draft-editor-in 220ms var(--ease-out-expo) both;
}
@keyframes draft-editor-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.draft-bubble-text {
  width: 100%;
  min-height: 76px;
  max-height: 40vh;
  resize: vertical;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-1);
  font: inherit;
  line-height: 1.55;
}
.draft-bubble-text:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}

/* 「告诉 AI 怎么改」：一句话 + 重新生成。输入框在左，按钮在右，不换行 */
.draft-bubble-regen {
  display: flex;
  gap: var(--sp-2);
}
.draft-bubble-prompt {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--ctl-h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-sm);
}
.draft-bubble-prompt::placeholder { color: var(--text-3); }
.draft-bubble-prompt:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}
.draft-bubble-regen-btn {
  flex: 0 0 auto;
  height: var(--ctl-h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out-quart), background var(--dur-fast) var(--ease-out-quart);
}
.draft-bubble-regen-btn:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--surface-2);
}
.draft-bubble-regen-btn:disabled { opacity: 0.55; cursor: progress; }

.draft-bubble-error {
  color: var(--danger-text);
  font-size: var(--fs-xs);
}

.draft-bubble-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.draft-bubble-hint {
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.draft-bubble-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}
.draft-bubble-act {
  height: var(--ctl-h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart), border-color var(--dur-fast) var(--ease-out-quart);
}
.draft-bubble-act:hover:not(:disabled) { background: var(--surface-2); border-color: var(--brand); }
.draft-bubble-act:disabled { opacity: 0.5; cursor: not-allowed; }
.draft-bubble-act.is-primary {
  background: var(--brand);
  border-color: transparent;
  color: var(--text-inverse);
  font-weight: 600;
}
.draft-bubble-act.is-primary:hover:not(:disabled) {
  background: oklch(from var(--brand) calc(l - 0.05) c h);
}

/* 发送前的译文预览：客户语言 ≠ 客服工作语言时，先把草稿译成客户语言，
 * 译文摆在这块里给客服看一眼，确认后才真的发出去。交互都在气泡内完成，不弹窗。 */
.draft-bubble-preview {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-2);
  background: var(--surface-1);
}
.draft-bubble-preview-head {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.draft-bubble-preview-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-1);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.draft-bubble-preview-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  justify-content: flex-end;
}

/* ---- 拖拽上传态（整个消息区 + 输入区） ---- */
.composer.drop-active::after,
.message-stream.drop-active::after {
  content: "松开即可上传附件";
  position: absolute;
  inset: var(--sp-3);
  border: 2px dashed var(--brand);
  border-radius: var(--r-3);
  background: oklch(from var(--brand) l c h / 0.07);
  color: var(--brand-text);
  font-size: var(--fs-md);
  font-weight: 600;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 20;
  animation: dropPulse var(--dur-slow) var(--ease-out-expo);
}
@keyframes dropPulse {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- 消息气泡内的附件展示 ---- */
.message .mc-attachments-show {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.mc-image-attachment { max-width: min(420px, 100%); min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.message .mc-attach-show {
  display: block;
  width: fit-content;
  height: auto;
  max-width: 100%;
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  background: var(--surface-sunken);
  overflow: hidden;
  flex: 0 0 auto;
  transition: transform var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-base) var(--ease-out-expo);
}
.message .mc-attach-show:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.message .mc-attach-show img {
  width: auto;
  height: auto;
  max-width: 100%;
  display: block;
}
.message .mc-file-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  max-width: 100%;
  padding: 5px var(--sp-3);
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  background: var(--surface-sunken);
  color: var(--text-1);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart),
              transform var(--dur-fast) var(--ease-out-quart);
}
.message .mc-file-link .mc-file-link-ico { width: 13px; height: 13px; flex-shrink: 0; }
.message .mc-file-link:hover {
  border-color: var(--brand);
  color: var(--brand-text);
  background: oklch(from var(--brand) l c h / 0.07);
  transform: translateY(-1px);
}
/* 出站（深底气泡）内的附件反色处理 */
.message.outbound .mc-attach-show { border-color: oklch(from var(--text-inverse) l c h / 0.25); }
.message.outbound .mc-file-link {
  border-color: oklch(from var(--text-inverse) l c h / 0.25);
  background: oklch(from var(--text-inverse) l c h / 0.12);
  color: var(--text-inverse);
}
.message.outbound .mc-file-link:hover {
  border-color: oklch(from var(--text-inverse) l c h / 0.5);
  background: oklch(from var(--text-inverse) l c h / 0.2);
  color: var(--text-inverse);
}

/* 减动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .composer-attachments,
  .mc-attach-thumb,
  .composer-send,
  .composer-meter-fill,
  .composer-counter { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .message.is-search-target { animation: none !important; }
}


.tab-btn {
  flex: 1;
  padding: var(--sp-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.tab-btn:hover { color: var(--text-1); background: var(--surface-2); }
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 500;
}
.tab-content { flex: 1; overflow-y: auto; padding: var(--sp-5); display: none; }
.tab-content.active { display: block; }


.info-list { display: grid; grid-template-columns: 80px 1fr; gap: var(--sp-2); font-size: var(--fs-sm); }
.info-list dt { color: var(--text-3); }
.info-list dd {
  color: var(--text-1);
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* ============ AI 建议回复（侧栏 kb tab） ============ */
.suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.suggest-header h4 {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.suggest-refresh {
  padding: 2px 8px;
  line-height: 1;
}
.suggest-refresh .mc-icon { width: var(--ico-md); height: var(--ico-md); }
.ai-suggestion {
  background: var(--surface-2);
  border-radius: var(--r-2);
  padding: var(--sp-3);
  min-height: 84px;
  font-size: var(--fs-sm);
  color: var(--text-1);
  line-height: 1.55;
  border-left: 3px solid var(--brand);
}
.ai-suggestion.suggest-transfer {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.ai-suggestion.suggest-empty-state {
  border-left-color: var(--border-2);
  background: var(--surface-sunken);
}
.suggest-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.suggest-loading .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--brand);
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.suggest-error { color: var(--danger-text); font-size: var(--fs-xs); }
.suggest-empty { color: var(--text-3); font-size: var(--fs-xs); }
.suggest-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-xs);
}
.suggest-confidence {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.suggest-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.suggest-text.muted { color: var(--text-3); font-style: italic; }
.suggest-citations {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.suggest-decision-badge {
  display: inline-block;
  padding: 1px var(--sp-2);
  border-radius: var(--r-1);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--brand-soft);
  color: var(--brand-text);
  margin-bottom: var(--sp-2);
}
.suggest-decision-badge.decision.transfer { background: var(--danger-soft); color: var(--danger-text); }
.suggest-decision-badge.decision.ask { background: var(--accent-soft); color: var(--accent-text); }
.suggest-decision-badge.decision.close { background: var(--surface-sunken); color: var(--text-2); }
.suggest-transfer-reason {
  font-size: var(--fs-xs);
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.suggest-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.suggest-actions button { flex: 1; }
.suggest-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

#kb-query {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  margin-bottom: var(--sp-2);
  outline: none;
  font-size: var(--fs-sm);
}
#kb-results { display: flex; flex-direction: column; gap: var(--sp-2); }
.kb-entry {
  padding: var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  border-left: 2px solid var(--brand);
}
.kb-entry-title { font-weight: 500; margin-bottom: var(--sp-1); }
.kb-entry-content { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.5; }

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: var(--mc-bg-scrim, oklch(0% 0 0 / 0.52));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--sp-4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modal-in 200ms var(--ease-out-expo);
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  width: 100%;
  max-width: 880px;
  /* 固定高度：max-height + min-height + flex column + min-height:0 让 body 真的能滚 */
  max-height: calc(100dvh - var(--sp-7));
  min-height: min(480px, calc(100dvh - var(--sp-7)));
  height: min(820px, 85dvh);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-elevated), var(--inner-highlight);
  animation: modal-up 280ms var(--ease-spring);
}
@keyframes modal-up {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.modal-header {
  padding: var(--mc-space-4, 16px) var(--mc-space-6, 24px);
  border-bottom: 1px solid var(--mc-border-subtle, var(--border-1));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--mc-space-3, 12px);
  /* header 不滚动 */
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.modal-body {
  padding: var(--mc-space-5, 20px) var(--mc-space-6, 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-4, 16px);
  /* 关键：flex 子项必须 min-height: 0 才能让 overflow 在固定高度容器内生效 */
  flex: 1 1 auto;
  min-height: 0;
}
/* 内部 tab 内容也允许独立滚动 */
.modal-body .config-content.active {
  /* config-content 自身不滚动，让里面的 grid / 列表跟着 modal-body 一起滚 */
  display: block;
}

.config-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--sp-5);
  padding: 4px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}
.config-tabs .tab-btn {
  flex: none;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  border-bottom: none;
}
.config-tabs .tab-btn.active {
  background: var(--surface-1);
  color: var(--text-1);
  font-weight: 500;
  box-shadow: var(--shadow-1);
}
.config-content { display: none; }
.config-content.active { display: block; }
.config-content h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: var(--sp-4);
}
.muted { color: var(--text-3); font-size: var(--fs-sm); margin-bottom: var(--sp-3); }

/* ============ 项目卡片（重构：避免通用表格） ============ */
.project-card {
  /* 旧的 3 栏 grid（40px 1fr auto）是 DOM 改版前的遗留：现在 .project-card-head
   * 已经是一个 flex 容器包住 icon / body / actions，再套 grid 只会挤压内容。 */
  display: flex;
  flex-direction: column;
  padding: var(--sp-4);
  margin-bottom: var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  transition: all var(--dur-fast) var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}
.project-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.project-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
  opacity: 0.6;
  transition: opacity var(--dur-fast) var(--ease-out-expo);
}
.project-card:hover::before { opacity: 1; }

.project-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-2);
  background: linear-gradient(135deg, var(--brand), oklch(from var(--brand) l c h / 0.7));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-lg);
  box-shadow: 0 2px 8px oklch(from var(--brand) l c h / 0.25);
  flex-shrink: 0;
}
.project-body { min-width: 0; }
.project-name {
  font-weight: 500;
  font-size: var(--fs-md);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.project-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.badge.llm {
  background: oklch(70% 0.18 150 / 0.15);
  color: oklch(45% 0.18 150);
  border: 1px solid oklch(70% 0.18 150 / 0.3);
}
.badge.muted-badge {
  background: var(--surface-2);
  color: var(--text-3);
  font-style: italic;
}

.project-actions-inline {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-shrink: 0;
  width: 100%;              /* 另起一行：三个入口按钮不挤占项目名称的位置 */
  padding-top: var(--sp-1);
}
.project-actions-inline button {
  padding: var(--sp-1) var(--sp-3);
  background: transparent;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out-expo);
}
.project-actions-inline button:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--border-2);
}
.project-actions-inline button.llm-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-text);
  border-color: var(--brand);
}

/* ============ 渠道卡片（重构：避免通用表格） ============ */
.channel-actions {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.channel-card {
  display: grid;
  grid-template-columns: 4px auto 1fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  margin-bottom: var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  transition: all var(--dur-fast) var(--ease-out-quart);
  position: relative;
  overflow: hidden;
}
.channel-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.channel-card::before {
  /* 左侧色条 — 渠道类型识别 */
  content: "";
  width: 4px;
  height: 100%;
  align-self: stretch;
  background: var(--channel-color, var(--brand));
}
.channel-card[data-type="im_feishu"] { --channel-color: var(--ch-feishu); }
.channel-card[data-type="chat"] { --channel-color: var(--ch-chat); }
.channel-card[data-type="im_wechat"] { --channel-color: var(--ch-wechat); }
.channel-card[data-type="im_dingtalk"] { --channel-color: var(--ch-dingtalk); }
.channel-card[data-type="im_slack"] { --channel-color: var(--ch-slack); }
.channel-card[data-type="im_whatsapp"] { --channel-color: var(--ch-whatsapp); }
.channel-card[data-type="im_line"] { --channel-color: var(--ch-line); }
.channel-card[data-type="im_telegram"] { --channel-color: var(--ch-telegram); }
.channel-card[data-type="email"] { --channel-color: var(--ch-email); }
.channel-card[data-type="webhook"] { --channel-color: var(--ch-webhook); }

.channel-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-2);
  background: oklch(from var(--channel-color) l c h / 0.15);
  color: var(--channel-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: background var(--dur-fast) var(--ease-out-expo);
}
.channel-icon .mc-icon { width: var(--ico-md); height: var(--ico-md); }
/* 品牌 SVG 图标：占满容器，自带品牌色，不再叠加品牌色底 */
.channel-icon-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
  border-radius: inherit;
  background: transparent;      /* 覆盖全局 .brand-logo 的渐变背景 */
}
/* 加载完成时把品牌色底完全去掉，让 logo 自带颜色不被中和；
   同时藏起下面的 MCIcons fallback，避免"两层叠加" */
.channel-icon:has(.channel-icon-img:not(.broken)) {
  background: transparent;
}
.channel-icon .channel-icon-img:not(.broken) ~ .channel-icon-fallback { display: none; }
/* SVG 加载失败 → 隐藏 img，露出 fallback icon（保留品牌色底） */
.channel-icon-img.broken { display: none; }
.channel-icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-body { min-width: 0; }
.channel-name {
  font-weight: 500;
  font-size: var(--fs-md);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.channel-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  display: flex;
  gap: var(--sp-3);
  align-items: center;
}
.channel-status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.channel-status-dot.inactive { background: var(--text-3); }

.channel-actions-inline { display: flex; gap: var(--sp-2); align-items: center; }
.channel-actions-inline button {
  padding: var(--sp-1) var(--sp-2);
  background: transparent;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.channel-actions-inline button:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
.channel-actions-inline button.danger:hover { color: var(--danger-text); border-color: var(--danger); }

/* ============ 渠道设置 · 品牌方接入卡片（Logo + 品牌名 + 加号） ============
   - 每张卡片 = 品牌 Logo（不可达时回退品牌色线条 icon）+ 品牌名 + 加号按钮
   - 点击卡片 → 进入该品牌特有的配置方式选择（扫码 / OAuth / 表单 / 嵌入） */
.channel-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.channel-type-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-1);
  transition: all var(--dur-fast) var(--ease-out-expo);
}
.channel-type-card:hover {
  border-color: var(--brand-color, var(--brand));
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
/* 品牌 Logo 位（48×48 圆角块；图标是各平台官方 SVG，自带品牌色，
   容器只做占位 + fallback 兜底，背景透明不染色，避免盖掉 logo 自身颜色） */
.channel-type-logo {
  position: relative;
  width: 48px; height: 48px;
  border-radius: var(--r-2);
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.channel-type-logo .brand-logo {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;       /* 官方 logo 自带完整图形，不裁切 */
  padding: 6px;              /* 内缩一圈，避免贴边 */
  border-radius: inherit;
  background: transparent;   /* 覆盖全局 .brand-logo 的渐变背景，避免透出 SVG 透明区 */
}
/* 关键：品牌 SVG 加载成功（非 .broken）时，藏起下面的 MCIcons fallback，
   防止 SVG 透明区域露出兜底线条 icon，造成"两个 icon 叠加" */
.channel-type-logo .brand-logo:not(.broken) ~ .channel-type-icon-fallback { display: none; }
.channel-type-logo .channel-type-icon-fallback {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.channel-type-logo .channel-type-icon-fallback .mc-icon { width: var(--ico-md); height: var(--ico-md); }
.channel-type-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.channel-type-name { font-weight: 600; font-size: var(--fs-sm); font-family: var(--font-display); }
.channel-type-desc { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
/* 加号按钮：默认描边，hover 时填充品牌色 */
.channel-type-add {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-1);
  color: var(--text-2);
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.channel-type-card:hover .channel-type-add {
  background: var(--brand-color, var(--brand));
  color: white;
  border-color: transparent;
}
.channel-type-add .mc-icon { width: 14px; height: 14px; }

/* —— 弹窗内的品牌卡（与网格卡同构，稍紧凑）—— */
.cw-type-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface-1);
}
.cw-type-card:hover { border-color: var(--brand-color, var(--brand)); transform: translateY(-1px); }
.cw-type-logo {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--r-2);
  background: transparent;       /* 官方 logo 自带颜色，不染色 */
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cw-type-logo .brand-logo {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;          /* 官方 logo 自带完整图形，不裁切 */
  padding: 4px;
  border-radius: inherit;
  background: transparent;      /* 覆盖全局 .brand-logo 的渐变背景 */
}
.cw-type-logo .brand-logo.broken { display: none; }
/* 与 .channel-type-logo 同理：品牌 SVG 加载成功后藏起 fallback */
.cw-type-logo .brand-logo:not(.broken) ~ .channel-type-icon-fallback { display: none; }
.cw-type-logo .channel-type-icon-fallback { display: inline-flex; }
.cw-type-logo .channel-type-icon-fallback .mc-icon { width: 18px; height: 18px; }
.cw-type-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cw-type-name { font-weight: 600; font-size: var(--fs-sm); font-family: var(--font-display); }
.cw-type-desc { font-size: var(--fs-xs); color: var(--text-2); }
.cw-type-add {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-1);
  color: var(--text-3);
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out-quart);
}
.cw-type-card:hover .cw-type-add {
  background: var(--brand-color, var(--brand));
  color: white;
  border-color: transparent;
}
.cw-type-add .mc-icon { width: 12px; height: 12px; }

/* 未完成的渠道入口：保留品牌与说明，但置灰、不可点击，并在右侧标注开发中。 */
.cw-type-card.is-unavailable {
  cursor: not-allowed;
  opacity: .55;
  filter: grayscale(1);
}
.cw-type-card.is-unavailable:hover {
  border-color: var(--border-1);
  transform: none;
}
.cw-type-card.is-unavailable:hover .cw-type-add {
  background: transparent;
  color: var(--text-3);
  border-color: var(--border-1);
}
/* 还没配置开发者凭证：视觉置灰，但仍可点进去完成配置。 */
.cw-type-card.is-needs-credentials {
  opacity: .6;
  filter: grayscale(.55);
}
.cw-type-card.is-needs-credentials:hover {
  opacity: .85;
  filter: grayscale(.2);
}
.cw-type-badge {
  font-size: var(--fs-xs);
  line-height: 1;
  padding: 5px 8px;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface-2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* —— 品牌特有「配置方式」选择卡（扫码 / OAuth / 表单 / 嵌入）—— */
.setup-method-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.setup-method-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border-1);
  border-radius: 8px;
  background: var(--surface-1);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text-1);
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.setup-method-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.setup-method-label { font-weight: 600; font-size: var(--fs-sm); font-family: var(--font-display); }
.setup-method-desc { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.setup-method-desc { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }

/* ---------- server-described channel setup ---------- */
/* 品牌网格不再自己滚动：弹窗交给 .channel-config-body，引导交给整页滚动。 */
.channel-type-picker {
  padding: 2px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.channel-setup-guide-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr); gap: var(--sp-4); align-items: start; }
.channel-setup-instructions { margin: var(--sp-3) 0; padding-left: 22px; color: var(--text-2); line-height: 1.65; }
.channel-setup-instructions li + li { margin-top: 4px; }
.channel-setup-usage, .channel-usage-section { margin: var(--sp-4) 0; padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-1); }
.channel-setup-usage h5, .channel-usage-section h4 { margin: 0 0 var(--sp-2); color: var(--text-1); }
.channel-usage-summary p { margin: 0; color: var(--text-2); line-height: 1.55; }
.channel-usage-summary .channel-setup-instructions { margin-bottom: 0; }
.channel-setup-usage ol { margin: 0; padding-left: 22px; color: var(--text-2); line-height: 1.65; }
.channel-setup-usage li + li { margin-top: 4px; }
.channel-usage-entries { display: grid; gap: var(--sp-2); }
.channel-usage-entry { display: grid; grid-template-columns: minmax(130px, 0.6fr) minmax(0, 1.4fr); gap: var(--sp-3); align-items: baseline; padding: var(--sp-2) 0; border-top: 1px solid var(--border-1); }
.channel-usage-entry > div:first-child { display: grid; gap: 2px; }
.channel-usage-entry > div:first-child span { font-size: var(--fs-xs); }
.channel-usage-entry-value { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.channel-usage-entry-value a { color: var(--brand-text); overflow-wrap: anywhere; }
.channel-usage-notes { margin: 0; padding-left: 22px; color: var(--text-2); line-height: 1.6; }
.channel-usage-notes li + li { margin-top: 4px; }
.channel-setup-callback { display: grid; gap: 4px; margin: var(--sp-3) 0; padding: var(--sp-3); border-radius: var(--r-2); background: var(--surface-sunken); color: var(--text-2); font-size: var(--fs-xs); }
.channel-setup-callback code { overflow-wrap: anywhere; color: var(--text-1); }
.setup-guide-card { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.setup-guide-card .setup-link { font-size: var(--fs-xs); }
.setup-guide-note { margin: var(--sp-2) 0 0; font-size: var(--fs-xs); }
.channel-setup-field { display: grid; gap: 5px; margin: 0 0 var(--sp-3); }
.channel-setup-field label { font-size: var(--fs-sm); color: var(--text-2); }
.channel-setup-field input, .channel-setup-field select { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: var(--r-1); background: var(--surface-1); color: var(--text-1); font: inherit; }
.channel-setup-field input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.channel-setup-helper { font-size: var(--fs-xs); line-height: 1.45; }
.channel-setup-error { min-height: 1.35em; margin: var(--sp-2) 0; color: var(--danger-text); line-height: 1.45; }
.channel-setup-status { margin: var(--sp-3) 0; color: var(--text-2); }
.channel-setup-display-fields { margin: 0 0 var(--sp-4); }
.channel-setup-display-fields h5 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--text-1); }
.channel-setup-display-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-2); }
.channel-setup-display-field { min-width: 0; margin-top: 0; }
.channel-setup-display-field code { overflow-wrap: anywhere; word-break: break-word; }
.channel-setup-display-fields.completion { margin-top: var(--sp-4); }
.oauth-auth-card { display: grid; gap: var(--sp-3); margin: var(--sp-4) 0; }
.oauth-auth-card .btn-primary { justify-self: start; text-decoration: none; }
.oauth-auth-card .setup-link { justify-self: start; }
.oauth-qr-card { width: min(260px, 100%); }
.oauth-credentials-toggle { justify-self: start; margin-bottom: var(--sp-3); }
#oauth-credentials-fields { margin: 0 0 var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-2); }
#oauth-credentials-fields legend { padding: 0 var(--sp-1); color: var(--text-2); font-size: var(--fs-sm); }
.email-oauth-detail,
.email-oauth-edit-note { display: grid; gap: 6px; margin: var(--sp-3) 0; padding: var(--sp-3); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border-1)); border-radius: var(--r-2); background: color-mix(in srgb, var(--brand) 7%, var(--surface-1)); }
.email-oauth-detail p,
.email-oauth-edit-note p { margin: 0; line-height: 1.55; }
.email-oauth-edit-note strong { color: var(--text-1); }
#cd-oauth-account[readonly] { color: var(--text-2); cursor: not-allowed; }
.channel-row-recent { animation: channel-row-recent 2.2s ease-out; }
@keyframes channel-row-recent { 0%, 50% { background: color-mix(in srgb, var(--brand) 13%, transparent); } 100% { background: transparent; } }

@media (max-width: 680px) {
  .channel-setup-guide-grid { grid-template-columns: 1fr; }
  .channel-type-picker { grid-template-columns: 1fr !important; }
}

.section-sub {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin: var(--sp-5) 0 var(--sp-3);
}

/* 渠道类型徽章 */
.feishu-btn {
  background: oklch(from var(--ch-feishu) l c h / 0.12);
  color: var(--ch-feishu);
  border-color: oklch(from var(--ch-feishu) l c h / 0.3);
}
.feishu-btn:hover { background: oklch(from var(--ch-feishu) l c h / 0.2); }
.chat-btn {
  background: oklch(from var(--ch-chat) l c h / 0.12);
  color: var(--ch-chat);
  border-color: oklch(from var(--ch-chat) l c h / 0.3);
}
.chat-btn:hover { background: oklch(from var(--ch-chat) l c h / 0.2); }

/* Widget 嵌入片段 */
.widget-snippet {
  background: var(--surface-sunken);
  padding: var(--sp-3);
  border-radius: var(--r-2);
  border: 1px solid var(--border-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  word-break: break-all;
  margin: var(--sp-2) 0;
  position: relative;
  line-height: 1.6;
}
.widget-snippet .copy-btn {
  position: absolute;
  top: var(--sp-2); right: var(--sp-2);
  padding: 2px var(--sp-2);
  font-size: var(--fs-xs);
  background: var(--brand);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--r-1);
  cursor: pointer;
}
.channel-token {
  display: flex; gap: var(--sp-2); align-items: center;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border-radius: var(--r-2);
  margin: var(--sp-2) 0;
  font-size: var(--fs-xs);
  border: 1px solid var(--border-1);
}
.channel-token code {
  font-family: var(--font-mono);
  color: var(--text-2);
  flex: 1;
  word-break: break-all;
}

/* ============ LLM 设置面板 ============ */
.llm-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.llm-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.llm-form label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.llm-form label .hint {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  font-weight: 400;
}
.llm-form input,
.llm-form select {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  outline: none;
  font-size: var(--fs-base);
  transition: all var(--dur-fast) var(--ease-out-quart);
  font-family: var(--font-mono);
}
.llm-form input:focus,
.llm-form select:focus {
  border-color: var(--brand);
  background: var(--surface-1);
}
.llm-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.llm-status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--brand-soft);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  color: var(--brand-text);
}
.llm-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.llm-status.fallback .dot { background: var(--accent); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  padding: 11px var(--sp-4);
  background: var(--text-1);
  color: var(--surface-0);
  border: 1px solid oklch(100% 0 0 / 0.1);
  border-radius: var(--r-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  z-index: 200;
  display: none;
  box-shadow: var(--shadow-elevated);
  max-width: min(360px, calc(100vw - var(--sp-7)));
  overflow-wrap: anywhere;
}
.toast.show { display: block; animation: slideIn 260ms var(--ease-spring); }
.toast.error { background: var(--danger); color: white; border-color: oklch(100% 0 0 / 0.14); }
.toast.success { background: var(--success-fill); color: var(--text-inverse); border-color: oklch(100% 0 0 / 0.14); }
@keyframes slideIn {
  from { transform: translateY(-8px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

/* ============ 通知横幅 ============ */
.notify-banner {
  position: relative;
  align-self: center;
  flex-shrink: 0;
  margin: var(--sp-2) var(--sp-4);
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-3);
  border: 1px solid oklch(from var(--accent) l c h / 0.3);
  font-size: var(--fs-sm);
  z-index: 80; /* Below modal backdrops (100), above workspace navigation (60). */
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  box-shadow: var(--shadow-2);
  width: max-content;
  max-width: min(600px, calc(100vw - var(--sp-7)));
  line-height: 1.5;
  animation: banner-in 360ms var(--ease-out-expo);
}
.notify-banner-text { min-width: 0; overflow-wrap: anywhere; }
@keyframes banner-in { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.notify-banner button {
  padding: 4px var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--accent);
  background: var(--surface-1);
  color: var(--accent-text);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 500;
  flex-shrink: 0;
  min-height: 32px;
  white-space: nowrap;
}
.notify-banner button.close-btn {
  border: none;
  padding: 2px var(--sp-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--accent-text);
}
.notify-banner button.close-btn:hover { background: oklch(100% 0 0 / 0.4); }
.notify-banner button.close-btn .mc-icon { width: 14px; height: 14px; }
.notify-banner-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-text);
  flex-shrink: 0;
}

/* 通用 .close-btn（弹窗标题栏右侧的关闭按钮） */
.close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-1);
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart), color var(--dur-fast) var(--ease-out-quart);
}
.close-btn:hover { background: var(--surface-2); color: var(--text-1); }
.close-btn .mc-icon { width: 14px; height: 14px; }

/* Webhook 接入与在线测试：沿用表单密度，诊断结果局部更新。 */
.webhook-flow { min-width: 0; }
.webhook-config-body { display: flex; flex-direction: column; overflow: hidden; padding: 0; border-radius: 0 0 var(--r-3) var(--r-3); }
.webhook-config-body > form { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 0; }
.webhook-config-body .webhook-flow { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: var(--sp-5); }
.webhook-flow-status { padding-inline-start: var(--sp-3); border-inline-start: 2px solid var(--brand); margin-bottom: var(--sp-5); font-size: var(--fs-sm); line-height: 1.6; }
.webhook-flow-status p { margin: var(--sp-1) 0 var(--sp-2); color: var(--text-2); }
.webhook-flow-status > button[hidden] { display: none; }
.webhook-flow-order { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0; margin: 0 0 var(--sp-4); list-style: none; font-size: var(--fs-xs); line-height: 1.6; color: var(--text-2); }
.webhook-flow-order li { white-space: nowrap; }
.webhook-flow-order li:not(:last-child)::after { content: '→'; margin-inline-start: var(--sp-2); color: var(--text-3); }
.webhook-flow-section { min-width: 0; padding-block: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-1); }
.webhook-flow-heading { display: flex; gap: var(--sp-3); align-items: baseline; margin-bottom: var(--sp-4); }
.webhook-flow-heading > span { font: 500 var(--fs-sm)/1.6 var(--font-mono); color: var(--text-3); }
.webhook-flow-heading h3 { margin: 0; color: var(--text-1); font: 600 var(--fs-base)/1.5 var(--font-body); }
.webhook-flow-heading p { margin: var(--sp-1) 0 0; }
.webhook-flow-optional { font-size: var(--fs-sm); color: var(--text-3); font-weight: 400; margin-inline-start: var(--sp-2); }
.webhook-flow-project, .webhook-flow-secret-status, .webhook-flow-receive-only { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); line-height: 1.6; color: var(--text-2); }
.webhook-flow-values { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0; font-size: var(--fs-sm); line-height: 1.6; }
.webhook-flow-values dt { color: var(--text-2); }
.webhook-flow-values dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.webhook-flow-values code { font-family: var(--font-mono); }
.webhook-flow-advanced { margin-top: var(--sp-4); font-size: var(--fs-sm); }
.webhook-flow-advanced summary { cursor: pointer; color: var(--text-2); }
.webhook-flow-advanced[open] summary { margin-bottom: var(--sp-3); }
.webhook-flow-footer { flex-shrink: 0; margin: 0; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border-1); background: var(--surface-1); }
.webhook-flow .webhook-endpoint { margin-block: 0 var(--sp-4); padding-top: 0; border-top: 0; }
.webhook-flow .webhook-tests { margin-block: 0; border-top: 0; }
.webhook-flow .webhook-test-save-note { padding-top: 0; }
.webhook-endpoint-help { font-size: var(--fs-sm); color: var(--text-2); }
.webhook-endpoint-help summary { cursor: pointer; }
.webhook-endpoint-help[open] summary { margin-bottom: var(--sp-2); }
.webhook-endpoint-help code { display: block; min-width: 0; overflow-wrap: anywhere; font: var(--fs-sm)/1.6 var(--font-mono); color: var(--text-1); }
.webhook-endpoint { display: flex; flex-direction: column; gap: var(--sp-2); margin-block: var(--sp-3) var(--sp-5); padding-block: var(--sp-3); border-block: 1px solid var(--border-1); min-width: 0; }
.webhook-help-heading, .webhook-secret-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.webhook-endpoint > code { display: block; font-family: var(--font-mono); font-size: var(--fs-sm); overflow-wrap: anywhere; color: var(--text-1); }
.webhook-identity { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: var(--sp-2) var(--sp-3); margin: 0 0 var(--sp-2); font-size: var(--fs-sm); line-height: 1.6; }
.webhook-identity dt { color: var(--text-2); }
.webhook-identity dd { display: flex; align-items: flex-start; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; margin: 0; }
.webhook-identity code, #webhook-form-address-template { min-width: 0; overflow-wrap: anywhere; font-family: var(--font-mono); color: var(--text-1); }
.webhook-identity button { flex-shrink: 0; }
.webhook-endpoint p, .webhook-test p { margin: 0; line-height: 1.6; }
.webhook-address-pending { color: var(--text-2); }
.webhook-secret-input { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.webhook-secret-input input { flex: 1; min-width: 0; }
.webhook-secret-input button { flex-shrink: 0; }
.webhook-secret-actions { justify-content: flex-start; margin-top: var(--sp-2); }
.webhook-secret-status:empty { display: none; }
.webhook-tests { min-width: 0; margin-block: var(--sp-4); border-top: 1px solid var(--border-1); }
.webhook-test-save-note { padding-top: var(--sp-3); }
.webhook-test { min-width: 0; padding-block: var(--sp-3); border-bottom: 1px solid var(--border-1); }
.webhook-test summary { cursor: pointer; color: var(--text-1); font-size: var(--fs-sm); font-weight: 600; line-height: 1.6; }
.webhook-test[open] summary { margin-bottom: var(--sp-3); }
.webhook-test-fields { display: flex; flex-direction: column; gap: var(--sp-3); margin-block: var(--sp-3); }
.webhook-test-field { display: flex; align-items: end; gap: var(--sp-2); min-width: 0; }
.webhook-test-field > div { flex: 1; min-width: 0; }
.webhook-test-field label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); }
.webhook-test input, .webhook-test textarea { width: 100%; min-width: 0; box-sizing: border-box; padding: var(--sp-2) var(--sp-3); background: var(--surface-sunken); border: 1px solid var(--border-2); border-radius: var(--r-2); color: var(--text-1); font: var(--fs-base)/1.5 var(--font-body); }
.webhook-test input:focus, .webhook-test textarea:focus { border-color: var(--brand); background: var(--surface-1); }
.webhook-test input:disabled, .webhook-test textarea:disabled { opacity: 0.65; }
.webhook-test > .form-group label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); }
#webhook-test-outbound-note:empty { display: none; }
.webhook-test-field > button { flex-shrink: 0; }
.webhook-test .form-group { margin-top: var(--sp-3); }
.webhook-test-actions { display: flex; justify-content: flex-start; gap: var(--sp-2); flex-wrap: wrap; margin-block: var(--sp-3); }
.webhook-test-result { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); line-height: 1.6; overflow-wrap: anywhere; border-inline-start: 2px solid var(--success); padding-inline-start: var(--sp-3); }
.webhook-test-result:empty { display: none; }
.webhook-test-result.is-error { border-color: var(--danger); }
.webhook-test-parsed-fields { display: grid; grid-template-columns: minmax(80px, 1fr) minmax(0, 2fr); gap: var(--sp-1) var(--sp-3); margin-block: var(--sp-2); }
.webhook-test-parsed-fields dt { color: var(--text-2); overflow-wrap: anywhere; }
.webhook-test-parsed-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.webhook-test-result small { color: var(--text-3); }
@media (max-width: 480px) {
  .webhook-test-field { flex-wrap: wrap; align-items: center; }
  .webhook-test-field > div { flex-basis: calc(50% - var(--sp-2)); }
  .webhook-test-field > button { margin-inline-start: auto; }
}

/* ============ 空状态 + 实用类 ============ */
.muted { color: var(--text-3); font-size: var(--fs-sm); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--r-pill);
  border: 2px solid var(--surface-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* 焦点态（无障碍） */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============ 向后兼容别名（旧变量名） ============ */
:root {
  --bg-primary: var(--surface-0);
  --bg-secondary: var(--surface-1);
  --bg-tertiary: var(--surface-2);
  --bg-hover: var(--surface-2);
  --text-primary: var(--text-1);
  --text-secondary: var(--text-2);
  --text-tertiary: var(--text-3);
  --border-color: var(--border-1);
  --accent-color: var(--brand);
}

/* ============ Agent 预设面板 ============ */
.agent-preset-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.agent-preset-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.agent-preset-form label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.agent-preset-form label .hint {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  font-weight: 400;
}
.agent-preset-form input,
.agent-preset-form select,
.agent-preset-form textarea {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-sm);
}
.agent-preset-form textarea {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  resize: vertical;
}

.agent-preset-grid-card {
  transition: transform .15s ease, border-color .15s ease;
}
.agent-preset-grid-card:hover {
  border-color: var(--brand) !important;
  transform: translateY(-1px);
}
.agent-preset-grid-card .badge {
  flex-shrink: 0;
}

details summary {
  user-select: none;
}
details summary::-webkit-details-marker {
  display: none;
}
details[open] summary {
  margin-bottom: var(--sp-2);
}
/* ============ 顶部菜单 · 响应式（< 1100px / < 760px 折叠） ============ */
@media (max-width: 1280px) {
  .header-search { max-width: 280px; min-width: 180px; }
}
@media (max-width: 1080px) {
  /* 收紧各区分隔和间距 */
  .app-header { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .header-divider { display: none; }
  .header-search { max-width: 220px; }
  .brand-text { display: none; }   /* 只保留 logo */
}
@media (max-width: 820px) {
  /* 窄屏不再整块隐藏搜索：收成一个图标，点击/⌘K 后在本行内展开成满宽输入框。
     原先 display:none 会让触屏用户彻底没有搜索入口（也没有 ⌘K 键可按）。 */
  .header-search { width: 40px; padding: 0; justify-content: center; cursor: pointer; }
  .header-search .search-ico { margin-right: 0; }
  .header-search input { width: 0; padding: 0; opacity: 0; }
  .header-search .search-kbd { display: none; }
  .header-search:focus-within,
  .header-search.is-search-open {
    position: absolute;
    left: var(--sp-3);
    right: var(--sp-3);
    top: 8px;
    width: auto;
    z-index: 80;
    padding: 0 var(--sp-3);
  }
  .header-search:focus-within .search-ico,
  .header-search.is-search-open .search-ico { margin-right: var(--sp-2); }
  .header-search:focus-within input,
  .header-search.is-search-open input { width: auto; flex: 1; opacity: 1; }
  .header-search:focus-within .search-results,
  .header-search.is-search-open .search-results { max-height: 60vh; }
  .header-filters { gap: var(--sp-1); }
  .chip-trigger { padding: 0 var(--sp-2); }
  .user-trigger .user-meta { display: none; } /* 顶栏账户仅保留头像，会话资料仍可读 */
}
@media (max-width: 560px) {
  .brand-title { display: none; }
  .brand-logo { width: 32px; height: 32px; font-size: 16px; }
  .app-logo { width: 32px; height: 32px; }
  .header-filters { display: none; }  /* 极窄屏只保品牌+操作 */
}

/* ============ R9 常驻侧栏（.ocp-sidebar） ============ */
/* 默认窄版 48px；hover / focus-within 展开到 220px，展开时文字渐显 */
.ocp-sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 60;
  width: 48px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-right: 1px solid var(--border-1);
  transition: width 240ms var(--ease-out-expo), box-shadow 240ms var(--ease-out-expo);
}
.ocp-sidebar:hover, .ocp-sidebar:has(:focus-visible) {
  width: 220px;
  box-shadow: var(--shadow-elevated);
}
/* 收起状态：只保留图标，左右居中 */
.ocp-sidebar:not(:hover):not(:has(:focus-visible)) .nav-label { display: none; }
.ocp-sidebar:not(:hover):not(:has(:focus-visible)) .nav-item { justify-content: center; padding: 8px; gap: 0; }
.ocp-sidebar:not(:hover):not(:has(:focus-visible)) .ocp-sidebar-bottom { padding: var(--sp-2); }
.ocp-sidebar:not(:hover):not(:has(:focus-visible)) .ocp-nav { padding: var(--sp-3) var(--sp-1); }
/* 侧栏顶部：与 .session-list-header 同高（50px），内含 select + 折叠态项目首字母徽章 */
.ocp-sidebar-top {
  position: relative;
  height: 50px;
  box-sizing: border-box;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}
.ocp-project-badge {
  position: absolute;
  inset: 9px auto auto 9px;
  width: 30px;
  height: 30px;
  border-radius: var(--r-2);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}
.ocp-project-select {
  width: 100%;
  height: 100%;
  align-self: stretch;
  appearance: none;
  padding-left: 10px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--text-1);
  /* 箭头统一由 tokens.css 的全局 select 规则提供（含右侧留白），这里只管底色 */
  background-color: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) var(--ease-out-quart);
}
.ocp-project-select:hover { border-color: var(--border-2); }
.ocp-project-select:focus {
  outline: none;
  border-color: var(--brand);
  /* 聚焦：1px 实色边 + 3px 外光晕，蓝框「占满」select 组件 */
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px oklch(from var(--brand) l c h / 0.18);
}
.ocp-nav { flex: 1; display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3) var(--sp-2); }
.ocp-sidebar .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 10px;
  width: 100%;
  border: none;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out-quart),
              color var(--dur-fast) var(--ease-out-quart),
              transform var(--dur-fast) var(--ease-spring);
}
.ocp-sidebar .nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: var(--brand);
  opacity: 0;
  transform: scaleY(0.35);
  transition: opacity 160ms var(--ease-out-expo), transform 220ms var(--ease-spring);
}
.ocp-sidebar .nav-item:hover { background: var(--surface-2); color: var(--text-1); }
.ocp-sidebar .nav-item:hover .nav-ico { transform: scale(1.08); }
.ocp-sidebar .nav-item:active { transform: scale(0.98); }
/* 账户页内嵌视图：在侧边栏切换，不整页跳转 */
.ocp-embed-view { display: flex; flex: 1; min-width: 0; }
.ocp-embed-view[hidden] { display: none; }
.ocp-embed { flex: 1; width: 100%; height: 100%; border: 0; display: block; background: var(--surface-0); }
/* 账户类入口是链接，去掉下划线并保持与按钮一致的对齐 */
.ocp-sidebar a.nav-item { text-decoration: none; }
/* 登录卡片上的产品介绍入口：低调但可点 */
.auth-product-link { margin: 6px 0 0; font-size: 13.5px; }
.auth-product-link a { color: var(--text-3); text-decoration: none; }
.auth-product-link a:hover { color: var(--text-1); text-decoration: underline; }
.ocp-sidebar .nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}
.ocp-sidebar .nav-item.active::before {
  opacity: 1;
  transform: scaleY(1);
}
.ocp-sidebar .nav-ico {
  display: inline-flex;
  width: 20px;
  flex-shrink: 0;
  justify-content: center;
  transition: transform 200ms var(--ease-spring);
}
.ocp-sidebar .nav-ico .mc-icon { width: var(--ico-lg); height: var(--ico-lg); }
.ocp-sidebar .nav-label {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}
.ocp-sidebar:hover .nav-label,
.ocp-sidebar:has(:focus-visible, .ocp-project-select:focus) .nav-label,
.ocp-sidebar .nav-item.active .nav-label { opacity: 1; }
.ocp-sidebar-bottom { padding: var(--sp-3) var(--sp-2); border-top: 1px solid var(--border-1); }
/* 底部「设置」入口：外形与导航项一致，图标列与上方 nav-item 对齐 */
.ocp-sidebar .nav-item-settings { margin: 0; }
.ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .ocp-sidebar-bottom .nav-item {
  justify-content: center; padding: 8px; gap: 0;
}
.ocp-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--surface-sunken);
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out-quart), color var(--dur-fast) var(--ease-out-quart);
}
.ocp-avatar:hover { background: var(--brand-soft); color: var(--brand-text); }
.ocp-avatar .mc-icon { width: var(--ico-sm); height: var(--ico-sm); }

/* ============ R9 项目总览（中间区 #project-overview，4 卡片 2x2） ============ */
#project-overview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--surface-0);
}
#project-overview .overview-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
#project-overview .overview-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}
#project-overview .overview-header .overview-sub {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.project-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
.project-overview-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-base) var(--ease-out-expo);
}
.project-overview-card:hover { transform: translateY(-2px); }
.project-overview-card .ov-card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.project-overview-card .ov-card-head .mc-icon { width: var(--ico-sm); height: var(--ico-sm); color: var(--brand); }
.project-overview-card .ov-card-body {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: var(--sp-3) 0 var(--sp-2);
}
.project-overview-card .ov-big {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1;
}
.project-overview-card .ov-unit { font-size: var(--fs-sm); color: var(--text-3); }
.project-overview-card .ov-preset-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  word-break: break-all;
}
.project-overview-card .ov-card-foot { font-size: var(--fs-xs); color: var(--text-2); }
.project-overview-card .ov-muted { color: var(--text-3); }
.project-overview-card .ov-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.project-overview-card .ov-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  color: var(--text-2);
}
.project-overview-card .ov-chip .mc-icon { width: var(--ico-xs); height: var(--ico-xs); }
/* 概览页 chip 内的品牌 logo：固定 14×14，SVG 自带颜色 */
.project-overview-card .ov-chip-logo {
  width: 14px; height: 14px;
  object-fit: contain;
  flex-shrink: 0;
}
.project-overview-card .ov-chip-logo.broken { display: none; }
/* 加载成功后藏起 fallback */
.project-overview-card .ov-chip-logo:not(.broken) ~ .ov-chip-fallback { display: none; }
.project-overview-card .ov-recent-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.project-overview-card .ov-recent-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  min-width: 0;
}
.project-overview-card .ov-recent-item .ov-recent-title {
  font-weight: 600;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.project-overview-card .ov-recent-item .ov-recent-time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  flex-shrink: 0;
}
.project-overview-card .ov-recent-item .ov-recent-preview {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ============ R9 侧栏响应式 ============ */
/* < 720px：侧栏变顶部横条（图标横排；项目下拉保留，文字标签隐藏） */
@media (max-width: 720px) {
  .ocp-sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    border-right: none;
    border-bottom: 1px solid var(--border-1);
    padding: 0 var(--sp-2);
  }
  .ocp-sidebar:hover, .ocp-sidebar:has(:focus-visible, .ocp-project-select:focus) { width: 100%; box-shadow: none; }
  .ocp-sidebar-top { border-bottom: none; padding: var(--sp-1) var(--sp-1); }
  .ocp-project-select { width: auto; min-width: 120px; }
  .ocp-nav {
    flex: 1;
    flex-direction: row;
    justify-content: center;
    gap: var(--sp-1);
    padding: var(--sp-1);
  }
  .ocp-sidebar .nav-item { width: auto; padding: 6px 10px; }
  .ocp-sidebar .nav-label { display: none; }
  .ocp-sidebar-bottom { border-top: none; padding: var(--sp-1); }
  /* 移动端：导航变成顶部横条，工作台按主从视图显示（见下方 900px 规则）。 */
  .app-body { flex-direction: column; padding-left: 0; }
  .session-row-action { min-width: 36px; min-height: 44px; }
  /* 总览卡片：2 列 → 1 列 */
  .project-overview-grid { grid-template-columns: 1fr; }
}

/* ============ 工作台主从视图（手机 / 折叠屏 / 平板竖屏） ============
 *
 * 旧实现把会话列表压到「最高 30%」，实际只剩一条的高度，用户要在夹缝里
 * 翻列表、又只能看到半截对话。窄屏下改成主从两屏：
 *   · 没选会话：列表占满主内容高度；
 *   · 选了会话：对话占满主内容高度，左上角返回键回到列表。
 * 两屏各自完整使用可用高度，而不是互相挤成一条。
 */
@media (max-width: 900px) {
  .workbench-view { flex-direction: column; }
  .workbench-view .session-list {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-1);
  }
  .workbench-view .conversation {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
  }
  .workbench-view:not(.has-open-session) .conversation { display: none; }
  .workbench-view.has-open-session .session-list { display: none; }
  .conv-back-btn { display: inline-flex; }
}

/* ============ 用户下拉打开时 lock body 滚动（防止背景跟着滚动） ============ */
body.dropdown-open { overflow: hidden; }

/* =====================================================================
 * v1.3+ Impeccable 设计语言（替换旧 v1.3 样式）
 * 设计方向：杂志感邮件客户端 × 模块化控制台 × 玻璃拟态气泡
 * 字体：Playfair Display（标题衬线 + 邮件）+ Inter（UI body）+ JetBrains Mono（技术元数据）
 * 配色：oklch 深空蓝灰底 + 琥珀金（agent accent）+ 翠绿（active）+ 砖红（danger）
 * ===================================================================== */

/* ---------- 项目详情卡片 ---------- */
/* 设计思路：杂志感的网格化布局，每个 section 有自己独立的"卡片身份"—— */
/* 不同于"全部用同一种卡片样式"的 AI 审美 */

.project-detail-panel { margin-top: var(--sp-5); }

.project-card {
  cursor: pointer;
  position: relative;
  transition: background 220ms cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: var(--r-3);
}
.project-card:hover { background: oklch(from var(--surface-1) l c h / 0.6); }
.project-card.expanded {
  border: 1px solid oklch(from var(--brand) l c h / 0.4);
  box-shadow:
    0 0 0 1px oklch(from var(--brand) l c h / 0.3),
    0 8px 24px -12px oklch(from var(--brand) l c h / 0.3);
}

/* 项目卡片头部：水平排版 + chevron 旋转指示 */
.project-card-head {
  display: flex;
  flex-wrap: wrap;          /* 让配置入口按钮能另起一行，不挤压项目名称 */
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: linear-gradient(
    180deg,
    oklch(from var(--surface-1) calc(l + 0.02) c h / 0.6) 0%,
    var(--surface-1) 100%
  );
  transition: border-color 220ms cubic-bezier(0.16, 1, 0.3, 1),
              background 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.project-card.expanded .project-card-head {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: oklch(from var(--brand) l c h / 0.4);
}

/* 项目图标：杂志感的"色块字标"——首字母大字号 + 半透明色块 */
.project-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-2);
  background: oklch(from var(--brand) l c h / 0.15);
  color: oklch(from var(--brand) l c h / 0.95);
  font-family: var(--font-display, sans-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  border: 1px solid oklch(from var(--brand) l c h / 0.2);
}

.project-card-head .project-icon {
  /* hover 时轻微浮起 */
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.project-card:hover .project-icon {
  transform: translateY(-2px) rotate(-2deg);
}

.project-body { flex: 1; min-width: 0; min-height: 0; }
.project-name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display, sans-serif);
  font-weight: 600;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono, monospace);
}
.project-meta span + span::before {
  content: "·";
  margin: 0 6px;
  color: var(--text-3);
  opacity: 0.5;
}

/* 项目 Item 上的三个配置入口 —— 各自打开聚焦该主题的弹窗。
 * 基础观感复用 .project-actions-inline button，这里只补图标与不换行。 */
.project-section-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;      /* 窄卡片下不允许被挤成竖排 */
}
.project-section-btn .ico {
  width: 13px;
  height: 13px;
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease-out-quart);
}
.project-section-btn:hover .ico { color: var(--brand-text); }
.project-section-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}

/* ---- 项目配置弹窗（一块一个弹窗） ---- */
.app-dialog-card.project-config-card {
  width: 100%;
  max-width: 600px;         /* 单个主题，不需要大宽幅 */
}
.project-config-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.project-config-head h3 {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.project-config-head h3 .ico {
  width: 16px;
  height: 16px;
  color: var(--brand-text);
  flex-shrink: 0;
}
.project-config-subtitle {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-config-body { padding: var(--sp-5); }

/* 「当前：<图标> 预设名」摘要行里的图标（MCIcons 键名渲染成 SVG） */
.preset-current { display: flex; align-items: center; gap: 6px; }
.preset-current-ico {
  display: inline-flex;
  align-items: center;
  color: var(--brand-text);
}

/* 弹窗头已经承担了主题标题，块内不再重复标题、也不再套一层卡片
 * （避免"卡片套卡片"，让内容直接落在弹窗里） */
.project-detail-section {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-4, 16px);
}
.project-detail-section .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-2, 8px);
  margin: 0;
}

.pd-input {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  background: var(--surface-sunken);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-sm);
  box-sizing: border-box;
  color: var(--text-1);
  transition: border-color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.pd-input:focus {
  outline: none;
  border-color: oklch(from var(--brand) l c h / 0.6);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}
.pd-kb-list, .pd-channel-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--fs-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.pd-kb-list li, .pd-channel-list li {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border-radius: var(--r-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono, monospace);
}

/* 合并后的 system prompt 预览：等宽字体 + 折叠面板 */
.project-prompt-preview summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: var(--sp-2) 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.project-prompt-preview summary::-webkit-details-marker { display: none; }
.project-prompt-preview summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 180ms;
  display: inline-block;
}
.project-prompt-preview[open] summary::before { transform: rotate(90deg); }
.project-prompt-preview .pd-prompt-preview {
  margin: var(--sp-2) 0 0;
  max-height: 280px;
  overflow: auto;
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: oklch(from var(--surface-sunken) calc(l - 0.02) c h);
  padding: var(--sp-3);
  border-radius: var(--r-1);
  border: 1px solid var(--border-1);
}

/* ---------- LLM Provider 卡片 ---------- */
/* 设计思路：developer console 风格——每个 provider 一行紧凑卡片，含元数据 + 操作 */

/* 服务商优先级排序控件 —— 列表顺序就是故障转移的尝试顺序：
 * 首位首选，失败依次向下重试。数字是优先级，↑↓ 调整。 */
.llm-provider-order {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.llm-order-idx {
  min-width: 18px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
}
.llm-order-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart),
              border-color var(--dur-fast) var(--ease-out-quart),
              color var(--dur-fast) var(--ease-out-quart);
}
.llm-order-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--brand);
  color: var(--text-1);
}
.llm-order-btn:disabled { opacity: 0.28; cursor: not-allowed; }
.llm-order-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}

.llm-provider-card {
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--surface-0);
  transition: border-color 220ms, transform 220ms, box-shadow 220ms;
  position: relative;
  overflow: hidden;
}
.llm-provider-card::before {
  /* 左侧 3px 状态条 */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-2);
  transition: background 220ms;
}
.llm-provider-card:hover {
  border-color: oklch(from var(--brand) l c h / 0.3);
}
.llm-provider-card.active {
  border-color: oklch(from var(--brand) l c h / 0.4);
  background: oklch(from var(--brand) l c h / 0.04);
  box-shadow: 0 0 0 1px oklch(from var(--brand) l c h / 0.3),
              0 12px 24px -16px oklch(from var(--brand) l c h / 0.4);
}
.llm-provider-card.active::before {
  background: linear-gradient(180deg, oklch(from var(--brand) l c h / 0.9), oklch(from var(--brand) l c h / 0.6));
  width: 4px;
}

/* 卡片头部：左 = 服务商名字（最左），右 = 操作按钮 + 排序控件（最右） */
.llm-provider-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.llm-provider-main { flex: 1; min-width: 220px; }
.llm-provider-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.llm-primary-badge {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--brand-fill);
  color: var(--text-inverse);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.llm-provider-meta {
  margin-top: 2px;
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
  word-break: break-all;
}
.llm-provider-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  margin-left: auto;      /* 靠右贴边 */
}
.llm-provider-head .muted {
  font-size: var(--fs-xs);
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.01em;
}
.llm-provider-head code {
  background: oklch(from var(--surface-sunken) calc(l - 0.02) c h);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  border: 1px solid var(--border-1);
}

/* 模型 chip：胶囊标签样式 */
.llm-provider-models {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border-1);
}
.model-chip {
  background: var(--surface-sunken);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono, monospace);
  border: 1px solid var(--border-1);
  transition: all 160ms;
}
.model-chip:hover {
  background: oklch(from var(--brand) l c h / 0.15);
  border-color: oklch(from var(--brand) l c h / 0.4);
}

/* ============================================================ */
/* 邮件卡片 / 详情 — Magazine Email Client 风格 */
/* 灵感：Apple Mail / Superhuman 的卡片美学 —— 关键信息高对比， */
/* 次要信息层降为弱化色，避免"千篇一律的灰卡片"。 */
/* ============================================================ */

/* Subject and body carry the message. Transport information is disclosed below. */
.message.message-email { width: min(880px, 100%); max-width: 100%; }
.email-card { min-width: 0; }
.email-card-head { margin-bottom: var(--sp-3); }
.email-card-subject {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-1);
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.email-card-details {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.email-card-details > summary {
  width: fit-content;
  cursor: pointer;
  padding: var(--sp-1) 0;
  border-radius: var(--r-1);
}
.email-card-details > summary:hover { color: var(--text-1); }
.email-card-details > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.email-card-details[open] > summary { margin-bottom: var(--sp-2); }
.email-card-meta > div { display: flex; flex-wrap: wrap; gap: var(--sp-1); overflow-wrap: anywhere; }
.email-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.55;
  font-family: var(--font-mono, monospace);
  display: grid;
  gap: 2px;
}
.email-card-meta strong {
  color: var(--text-3);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
.email-card-meta code {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: transparent;
  padding: 0;
}
.email-card-time {
  color: var(--text-3);
  margin-top: 2px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono, monospace);
}

/* The conversation is the only scrolling reading surface. */
.email-card-body {
  font-size: var(--fs-sm);
  line-height: 1.65;
  word-break: break-word;
  color: var(--text-1);
}

.email-text-plain {
  font-family: var(--font-body);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--text-1);
}

/* 附件区 */
.email-card-attachments {
  padding: var(--sp-2) 0;
  font-size: var(--fs-xs);
}
.email-card-attachments strong {
  color: var(--text-2);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.email-att-list {
  list-style: none;
  padding: 0;
  margin: var(--sp-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.email-att-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--surface-0);
  border-radius: var(--r-1);
  font-family: var(--font-mono, monospace);
  border: 1px solid var(--border-1);
}
.email-att-list code {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: oklch(from var(--surface-sunken) calc(l - 0.04) c h);
  padding: 1px 6px;
  border-radius: 4px;
}

.email-card-actions {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border-1);
  text-align: right;
}
.email-detail-btn {
  padding: 4px 12px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  border-radius: 999px;
  font-size: var(--fs-xs);
  cursor: pointer;
  color: var(--text-2);
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.email-detail-btn:hover {
  border-color: oklch(from var(--brand) l c h / 0.5);
  color: var(--brand);
  background: oklch(from var(--brand) l c h / 0.06);
}

/* ============================================================ */
/* 邮件详情 Modal — 编辑感布局 */
/* ============================================================ */
.email-detail-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.email-detail-section {
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: var(--sp-4);
  background: var(--surface-0);
}
.email-detail-section h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display, sans-serif);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.email-header-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.email-header-table th {
  text-align: left;
  vertical-align: top;
  padding: 6px 12px 6px 0;
  width: 110px;
  color: var(--text-3);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono, monospace);
}
.email-header-table td {
  padding: 6px 0;
  word-break: break-word;
  color: var(--text-1);
  line-height: 1.55;
}
.email-header-table code {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  background: oklch(from var(--surface-sunken) calc(l - 0.02) c h);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-1);
}

/* Tab 切换：邮件纯文本 / HTML 切换 */
.email-detail-body-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-1);
}
.email-tab-btn {
  padding: var(--sp-2) var(--sp-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all 200ms;
  font-family: var(--font-display, sans-serif);
  font-weight: 500;
  margin-bottom: -1px;
}
.email-tab-btn:hover { color: var(--text-1); }
.email-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.email-tab-pane {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-sm);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
  background: oklch(from var(--surface-sunken) calc(l - 0.02) c h);
  padding: var(--sp-4);
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  color: var(--text-1);
}
.email-html-preview {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============ 消息正文多视图切换（富文本 / 纯文本 / HTML 源码） ============
   与弹窗里的 .email-detail-body-tabs 是两套：弹窗用下划线式 tab，
   消息流卡片空间小，用胶囊式，点起来不挤也不误触。 */
.email-body-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--border-1);
}
.email-body-tab {
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-display, sans-serif);
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms, border-color 160ms, background 160ms;
}
.email-body-tab:hover { color: var(--text-1); border-color: var(--border-2); }
.email-body-tab.is-active {
  color: var(--brand);
  border-color: var(--brand);
  background: oklch(from var(--brand) calc(l + 0.06) c h / 0.12);
}
/* 「加载远程图片」是动作不是视图，跟切换按钮同一排但要能一眼分出来 */
.email-body-tab-alt {
  margin-left: auto;
  color: var(--text-3);
  border-style: dashed;
}
.email-body-panes { min-height: 40px; }
/* 卡片内的正文视图比弹窗里的更紧凑：不再重复一层灰底和滚动条，
   滚动统一交给会话消息流。 */
.email-card-body .email-tab-pane {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  max-height: none;
  overflow: visible;
}
/* 沙箱 iframe 承载渲染后的 HTML 正文：透明底，继承卡片排版，不给固定高度硬撑 */
.email-html-frame {
  display: block;
  width: 100%;
  min-height: 40px;
  height: 40px;
  max-height: none;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color-scheme: light dark;
}
.email-html-frame[hidden], .email-tab-pane[hidden] { display: none !important; }
/* 详情弹窗里可视面积大得多，正文也通常更长 */
.email-detail-body-content .email-html-frame { min-height: 40px; max-height: none; }
.email-html-source {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--text-2);
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: oklch(from var(--surface-sunken) calc(l - 0.03) c h);
  padding: var(--sp-3);
  border-radius: var(--r-1);
  border: 1px solid var(--border-1);
}
.email-att-list li { flex-wrap: wrap; }
.email-att-disposition {
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: 4px;
  padding: 0 5px;
}

/* ============ Webhook 表单正文 ============
   表单提交不是一段文本，是一组字段：key 用等宽字体成列排，
   复杂值（对象/数组）缩进成 JSON，避免嵌套结构被压成一行。 */
.form-card {
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: var(--surface-0);
  overflow: hidden;
}
.form-card-head {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
  background: oklch(from var(--surface-sunken) calc(l - 0.01) c h / 0.5);
}
.form-card-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.form-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--r-1);
  background: var(--brand-soft);
  font-size: 12px;
  line-height: 1;
}
.form-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.form-card-count {
  margin-left: auto;
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-0);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.form-card-meta {
  margin: 0;
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.form-card-meta strong {
  font-weight: 500;
  margin-right: 6px;
}
.form-card-meta code {
  font-family: var(--font-mono, monospace);
  word-break: break-all;
}
.form-card-body { padding: var(--sp-1) var(--sp-4) var(--sp-3); }
.form-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  table-layout: fixed;
}
.form-field-table th,
.form-field-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-1);
}
.form-field-table tr:last-child th,
.form-field-table tr:last-child td { border-bottom: none; }
.form-field-table th {
  width: 32%;
  max-width: 32%;
  padding-right: var(--sp-3);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  word-break: break-all;
  user-select: text;
}
/* 结构化字段占满整行，标签压在结构上方 —— 挤在值列里嵌套第二层就没地方了 */
.form-field-table th.form-block {
  width: auto;
  max-width: none;
  padding-right: 0;
  font-weight: 400;
  font-size: var(--fs-base);
  color: var(--text-1);
}
.form-block-key {
  display: block;
  margin-bottom: var(--sp-1);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  word-break: break-all;
}
.form-value {
  color: var(--text-1);
  font-size: var(--fs-base);
  word-break: break-word;
  user-select: text;
}
/* 文本保留原样换行 —— 表单里的「留言」字段常常是多行段落。
   字号交给外层（顶层 form-value / 嵌套 form-nested-val）定，
   这里再写一次会把嵌套层级的字又顶回顶层大小。 */
.form-text {
  white-space: pre-wrap;
  color: var(--text-1);
}
.form-number {
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}
/* 空值不该跟「真的填了空字符串」长得一样 */
.form-null {
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--text-3);
}
/* 是非题一眼扫出哪些勾了 */
.form-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.form-flag.is-yes {
  color: var(--success);
  background: oklch(from var(--success) calc(l - 0.06) c h / 0.14);
  border-color: oklch(from var(--success) calc(l - 0.02) c h / 0.28);
}
.form-flag.is-no {
  color: var(--text-3);
  background: var(--surface-sunken);
  border-color: var(--border-1);
}
/* 嵌套对象：缩进 + 一条导轨，取代 JSON 的大括号与引号 */
.form-nested {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border-2);
}
.form-nested-row {
  display: grid;
  /* 键列写死宽度，不用百分比：每深一层只多缩进 14px，
     用百分比的话第二层起值就被一路挤到卡片最右边，读起来像掉队。 */
  grid-template-columns: 88px minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: baseline;
}
.form-nested-key {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  color: var(--text-2);
  word-break: break-all;
  user-select: text;
}
.form-nested-val {
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--text-1);
  word-break: break-word;
  user-select: text;
}
/* 标量数组铺成 chip：加急 / 开发票 / 需要样品 一眼扫完 */
.form-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.form-chip {
  max-width: 100%;
  padding: 1px 8px;
  border-radius: var(--r-1);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-1);
}
.form-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: 0;
  padding-left: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.form-list > li::marker { color: var(--text-3); font-variant-numeric: tabular-nums; }
.form-empty {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
/* 表单附件：只展示本站已转存的副本（/api/attachments/:id），
   未转存/历史消息只给文件名与原因，绝不出现提交方的公网地址。 */
.form-attachments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.form-attachment {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  min-width: 0;
}
.form-attachment.is-image { flex-direction: column; align-items: flex-start; }
.form-attachment-name { color: var(--text-1); word-break: break-all; }
.form-attachment-note { color: var(--text-3); font-size: var(--fs-xs); }
.form-attachment.is-failed .form-attachment-name { color: var(--warn, var(--text-2)); }
.form-image-link {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface-sunken);
}
.form-image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 420px);
  max-height: 320px;
  object-fit: contain;
}
.form-attachment-download {
  color: var(--brand);
  font-size: var(--fs-sm);
  word-break: break-all;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.form-file-link {
  color: var(--brand);
  word-break: break-all;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.email-detail-attachments {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.email-detail-attachments li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 10px;
  font-size: var(--fs-sm);
  background: oklch(from var(--surface-sunken) calc(l - 0.01) c h);
  border-radius: var(--r-1);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono, monospace);
}
.email-detail-attachments code {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  background: var(--surface-0);
  padding: 1px 6px;
  border-radius: 4px;
}

.email-detail-headers summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  padding: var(--sp-2) var(--sp-3);
  background: oklch(from var(--surface-sunken) calc(l - 0.02) c h);
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.email-detail-headers summary::-webkit-details-marker { display: none; }
.email-detail-headers summary::before {
  content: "▶";
  font-size: 10px;
  display: inline-block;
  transition: transform 180ms;
}
.email-detail-headers[open] summary::before { transform: rotate(90deg); }
.email-detail-headers[open] summary { margin-bottom: var(--sp-2); }

/* ============================================================ */
/* App Dialog — 替换浏览器原生 prompt/confirm/alert */
/* 设计思路：模块化 dialog，键盘可达，焦点陷阱 */
/* ============================================================ */
.app-dialog {
  position: fixed;
  inset: 0;
  /* 高于 .aw-backdrop(1000)：Agent 设置里点「管理知识库」时，Dialog/KB 卡片要在遮罩之上。 */
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  animation: dialogFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
/* 【关键】[hidden] 属性的 display: none 必须 override .app-dialog 的 flex */
/* 否则 dialog 永远关不掉 */
.app-dialog[hidden] {
  display: none !important;
  animation: none;
}
@keyframes dialogFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0% 0 0 / 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.app-dialog-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-elevated), var(--inner-highlight);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--sp-8));
  overflow: hidden;
  animation: dialogUp 280ms var(--ease-spring);
}
@keyframes dialogUp {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* 大尺寸 dialog 变体（KB 管理 / Provider 编辑 / Agent 预设等） */
.app-dialog-card.provider-editor-card,
.app-dialog-card.kb-manager-card {
  max-width: 720px;
}
.app-dialog-card.kb-manager-card {
  max-width: 880px;
  height: 80dvh;
  max-height: min(720px, calc(100dvh - var(--sp-8)));
}
.app-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--mc-border-subtle, var(--border-1));
  flex-shrink: 0;
}
.app-dialog-head h3 {
  margin: 0;
  font-family: var(--font-display, sans-serif);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--text-1);
}
.app-dialog-body {
  padding: var(--sp-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-4, 16px);
  flex: 1;
  min-height: 0;
}
.app-dialog-message {
  font-size: var(--fs-sm);
  color: var(--text-1);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.app-dialog-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.app-dialog-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.app-dialog-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.app-dialog-label .hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: var(--sp-2);
}
.app-dialog-input,
.app-dialog-textarea,
.app-dialog-select {
  width: 100%;
  padding: var(--sp-3) var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-sm);
  box-sizing: border-box;
  transition: border-color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1),
              background 180ms;
  resize: vertical;
}
.app-dialog-textarea {
  font-family: var(--font-body);
  line-height: 1.55;
  min-height: 80px;
}
.app-dialog-select {
  appearance: none;
  /* 箭头由 tokens.css 的全局规则提供（全局规则里已给出右侧内边距与图标位置），
     这里只把「基准位置」调成弹窗自己的节奏 */
  padding-right: var(--sp-7);
  cursor: pointer;
}
.app-dialog-input:hover,
.app-dialog-textarea:hover,
.app-dialog-select:hover {
  border-color: oklch(from var(--brand) l c h / 0.4);
}
.app-dialog-input:focus,
.app-dialog-textarea:focus,
.app-dialog-select:focus {
  outline: none;
  border-color: oklch(from var(--brand) l c h / 0.6);
  background: var(--surface-1);
  box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.18);
}
.app-dialog-input::placeholder,
.app-dialog-textarea::placeholder {
  color: var(--text-3);
  opacity: 0.6;
}
.app-dialog-error {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--danger-text);
  background: oklch(from var(--danger) l c h / 0.08);
  border: 1px solid oklch(from var(--danger) l c h / 0.2);
  border-radius: var(--r-1);
}
.app-dialog-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
  background: oklch(from var(--surface-sunken) l c h / 0.4);
  flex-shrink: 0;
}
.app-dialog-foot .spacer { flex: 1; }

/* ---- 弹窗 / 表单里的操作按钮行 ------------------------------ */
/* .btn-row 是所有操作按钮行的唯一容器，取代散落各处、
 * 间距各不相同的内联 style="display:flex; gap:8px; margin-top:12px"。 */
.btn-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

/* 按钮组的节奏：主次同高（--ctl-h）、同字号、同圆角，层级只由
 * 「实心 vs 描边」+ 字重 + 宽度（108 / 84）表达——绝不再出现
 * 主按钮撑满整行、次按钮被压成小方块的比例失衡。 */
.app-dialog-foot > .btn-primary,
.app-dialog-foot > .btn-secondary,
.btn-row > .btn-primary,
.btn-row > .btn-secondary {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  margin: 0;
  min-height: var(--ctl-h);
  padding: 0 var(--sp-4);
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.app-dialog-foot > .btn-secondary,
.btn-row > .btn-secondary { min-width: 84px; }
.app-dialog-foot > .btn-primary,
.btn-row > .btn-primary { min-width: 108px; }

/* ============================================================ */
/* Provider Editor Dialog 样式 */
/* ============================================================ */
.provider-editor-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.provider-editor-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.provider-editor-form .pe-hint {
  font-size: var(--fs-xs);
  margin-top: -2px;
}
.pe-models-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.pe-models-head .app-dialog-label { margin: 0; }
.pe-fetch-btn {
  /* 与 label 同行的小工具按钮：显式退出 --ctl-h 节奏，避免顶开标题行 */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: auto;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.pe-fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pe-fetch-btn .ico { font-size: 12px; }
.pe-fetch-status {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  border-radius: var(--r-1);
  font-family: var(--font-mono, monospace);
  line-height: 1.4;
  word-break: break-all;
  background: var(--surface-sunken);
  color: var(--text-2);
  min-height: 28px;
}
.pe-fetch-status.loading { color: var(--brand); }
.pe-fetch-status.success {
  color: oklch(from var(--success) l c h / 0.9);
  background: oklch(from var(--success) l c h / 0.08);
}
.pe-fetch-status.error {
  color: var(--danger-text);
  background: oklch(from var(--danger) l c h / 0.08);
}

/* ============================================================ */
/* KB 管理 Dialog 样式 */
/* ============================================================ */
.kb-manager-head h3 { font-size: var(--fs-md); }
.kb-manager-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
  font-family: var(--font-mono, monospace);
}
.kb-manager-loading {
  padding: var(--sp-6);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.kb-manager-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--border-1);
  margin-bottom: var(--sp-3);
}
/* 顶部数据库状态固定单行，超出用省略号，不换行挤压列表 */
.kb-manager-summary > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-xs);
}
.kb-manager-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.kb-manager-empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-2);
}
.kb-manager-empty-icon { font-size: 36px; margin-bottom: var(--sp-2); opacity: 0.6; }
.kb-manager-empty p { margin: 0; }
.kb-manager-card {
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-0);
  overflow: hidden;
}
.kb-manager-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: oklch(from var(--surface-sunken) l c h / 0.5);
  border-bottom: 1px solid var(--border-1);
}
.kb-manager-card-info { flex: 1; min-width: 0; }
.kb-manager-card-name {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.kb-manager-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
  font-family: var(--font-mono, monospace);
}
.kb-manager-card-meta code {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
}
.kb-manager-card-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.kb-manager-entries {
  display: flex;
  flex-direction: column;
}
.kb-manager-entries-empty {
  padding: var(--sp-4);
  font-size: var(--fs-xs);
  text-align: center;
}
.kb-entry-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-1);
}
.kb-entry-item:first-child { border-top: none; }
.kb-entry-item:hover { background: oklch(from var(--surface-sunken) l c h / 0.3); }
.kb-entry-main { flex: 1; min-width: 0; }
.kb-entry-title {
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--text-1);
  margin-bottom: 4px;
}
.kb-entry-preview {
  font-size: var(--fs-xs);
  line-height: 1.5;
  margin-bottom: 4px;
  word-break: break-word;
}
.kb-entry-meta {
  font-size: var(--fs-xs);
  font-family: var(--font-mono, monospace);
}
.kb-neg-count {
  color: var(--danger, #c0392b);
  font-weight: 600;
}
.kb-entry-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.kb-entry-actions .btn-secondary {
  /* 条目行内的微型按钮：显式退出 --ctl-h 节奏，保持列表密度 */
  min-height: auto;
  padding: 4px 10px;
  font-size: var(--fs-xs);
}
.kb-manager-foot {
  /* 继承 .app-dialog-foot 的 padding / 分组节奏，只额外保证左右分组对齐 */
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* ============================================================ */
/* 项目详情渠道列表（迁移到全局渠道 tab，但项目详情不再含渠道） */
/* 渠道列表项的视觉强化：让"项目下挂的渠道"在全局视图里更清晰 */
/* ============================================================ */
.pd-channel-list code {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ============================================================ */
/* Toast（已有，但用 impeccable 重新打磨） */
/* ============================================================ */
.toast {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: oklch(from var(--text-1) l c h / 0.95);
  color: var(--surface-0);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  z-index: 200;
  display: none;
  box-shadow:
    0 12px 24px -8px oklch(0% 0 0 / 0.5),
    0 0 0 1px oklch(100% 0 0 / 0.1) inset;
  max-width: 360px;
  backdrop-filter: blur(8px);
}
.toast.show {
  display: block;
  animation: toastIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) translateX(8px); }
  to { opacity: 1; transform: translateY(0) translateX(0); }
}
.toast.error { background: oklch(55% 0.18 25); color: white; }
.toast.success { background: oklch(65% 0.15 160); color: white; }

/* ============================================================ */
/* 知识库文件夹导入（§KB-Import）                                */
/*                                                              */
/* 视觉意图（对齐 .impeccable.md 的设计原则）：                    */
/*   ① 列表即进度条：每个文件的进度画在**行内背景**上              */
/*      （::before + transform: scaleX(var(--p))，纯合成层，      */
/*       不触发布局 → 几千行滚动时也不掉帧）                      */
/*   ② 工程仪表盘感：路径与数字用等宽字体 + tabular-nums，         */
/*      发丝分隔线替代卡片描边，颜色只表达状态                    */
/*   ③ 诚实：拿不到真实百分比时用不定态扫光，不编数字              */
/*   ④ 异常可见：左侧 2px 状态脊 + 原因直接占位，点行展开全文      */
/* ============================================================ */

.app-dialog-card.kb-import-card {
  --kbi-ease: var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
  --kbi-hair: color-mix(in oklch, var(--border-1) 65%, transparent);
  --kbi-up: var(--brand);
  --kbi-work: var(--accent);
  --kbi-ok: var(--success);
  --kbi-bad: var(--danger);
  --kbi-skip: var(--text-3);
  /* 必须同时覆盖 width 与 max-width：基础类 .app-dialog-card 带着 max-width: 520px，
     只写 width 会被它压回 520 —— 表现就是"表格挤成一条、路径列全被省略号吃掉"。 */
  width: min(1000px, 94vw);
  max-width: min(1000px, 94vw);
  /* 给一个确定高度：flex:1 的列表才有"填满中段"的依据，头/脚固定、只有列表滚 */
  height: min(720px, 88dvh);
  max-height: calc(100dvh - var(--sp-8));
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* 只让中间的列表滚动，头/脚固定 */
}
/* 作者样式里的 display 会压过 UA 的 [hidden]：这里统一兜底，否则"隐藏"的按钮还会露出来 */
.kb-import-card [hidden] { display: none !important; }
/* 引导第 4 步：导入面板直接内联在当前页面，不再浮在遮罩上 */
.app-dialog-card.kb-import-card.is-inline {
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  /* 内联时是页面里的一段，而不是叠在引导卡片里的第二张弹窗卡片 */
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.app-dialog-card.kb-import-card.is-inline .kbi-body { flex: 0 0 auto; }
.app-dialog-card.kb-import-card.is-inline .kbi-empty { min-height: 200px; flex: 0 0 auto; }
.app-dialog-card.kb-import-card.is-inline .kbi-list-body { max-height: 360px; overflow-y: auto; }
/* 内联时不用弹窗的关闭 X / 完成按钮：退出导入走引导卡片上的「收起导入」。 */
.app-dialog-card.kb-import-card.is-inline header .icon-btn,
.app-dialog-card.kb-import-card.is-inline [data-kbi-action="close"] { display: none; }
/* 拖拽区已经自带「选择文件夹/文件」和格式说明，顶部这一排是冗余的。 */
.app-dialog-card.kb-import-card.is-inline .kbi-toolbar-left { display: none; }
.app-dialog-card.kb-import-card.is-inline .kbi-toolbar { justify-content: flex-end; }
/* 内联时没有「完成」按钮，空闲状态下不要再留一条空 footer；
   导入进行中仍有取消 / 重跑 / 回滚时再显示。 */
.app-dialog-card.kb-import-card.is-inline .kbi-foot { display: none; }
.app-dialog-card.kb-import-card.is-inline .kbi-foot:has(button.btn-secondary:not([hidden])) { display: flex; }

.kbi-head-bar { flex: 0 0 auto; }
.kbi-title-wrap h3 { margin: 0; font-size: var(--fs-lg); }
.kbi-subtitle {
  font-size: var(--fs-xs);
  margin-top: 2px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52ch;
}

.kbi-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  overflow: hidden;              /* 列表自己滚，头部工具条不跟着滚 */
}

/* ---------- 工具栏 ---------- */

.kbi-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.kbi-toolbar-left { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.kbi-hint {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46ch;
}

.kbi-mode {
  margin-left: auto;
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  background: var(--surface-sunken);
}
.kbi-mode-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.kbi-mode-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kbi-mode-opt:has(input:checked) {
  background: var(--surface-1);
  color: var(--text-1);
  font-weight: 600;
  box-shadow: 0 1px 2px oklch(from var(--text-1) l c h / 0.12);
}
.kbi-mode-opt:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- 紧凑汇总条（不是"英雄指标卡"：一行数字，给盯进度的人扫异常） ---------- */

.kbi-sum {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 6px 0;
  border-top: 1px solid var(--kbi-hair);
  border-bottom: 1px solid var(--kbi-hair);
}
.kbi-sum-cell { display: inline-flex; align-items: baseline; gap: 5px; }
/* 发丝分隔线：等宽数字排在一起时，线比间距更能表达"这是不同的量" */
.kbi-sum-cell + .kbi-sum-cell {
  border-left: 1px solid var(--kbi-hair);
  padding-left: var(--sp-3);
}
.kbi-sum-cell b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.kbi-sum-cell i { font-style: normal; font-size: var(--fs-xs); color: var(--text-3); }
.kbi-sum-cell.is-warn b { color: var(--kbi-bad); }
.kbi-sum-spacer { flex: 1 1 auto; }

.kbi-agg {
  width: 160px;
  height: 3px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
  flex: 0 0 auto;
}
.kbi-agg > i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--kbi-up), var(--kbi-work));
  transition: transform 320ms var(--kbi-ease);
}
.kbi-agg-label {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.kbi-current {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-xs);
}
.kbi-current-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 4px;
  background: color-mix(in oklch, var(--kbi-work) 16%, transparent);
  color: var(--text-2);
}
.kbi-current-path {
  font-family: var(--font-mono);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 筛选器 ---------- */

.kbi-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kbi-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: border-color 120ms var(--kbi-ease), background 120ms var(--kbi-ease), color 120ms var(--kbi-ease);
}
.kbi-filter b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.kbi-filter:hover { border-color: var(--border-2); color: var(--text-1); }
.kbi-filter.is-on {
  background: color-mix(in oklch, var(--brand) 12%, transparent);
  border-color: color-mix(in oklch, var(--brand) 45%, transparent);
  color: var(--text-1);
  font-weight: 600;
}
.kbi-filter:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.kbi-list-note { font-size: var(--fs-xs); }

/* ---------- 空状态（仍是拖拽区，但收敛为一行提示 + 两个动作） ---------- */

.kbi-empty {
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  text-align: center;
  padding: var(--sp-6) var(--sp-5);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-3);
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface-2) 60%, transparent), transparent),
    var(--surface-sunken);
  transition: border-color 160ms var(--kbi-ease), background 160ms var(--kbi-ease);
}
.kbi-empty-ico { font-size: 32px; line-height: 1; color: var(--text-3); }
.kbi-empty-title { font-weight: 600; font-size: var(--fs-md); }
.kbi-empty-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.kbi-empty-note { font-size: var(--fs-xs); line-height: 1.7; }

/* ---------- 文件列表 ---------- */

.kbi-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--kbi-hair);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface-1);
}
.kbi-list-head,
.kbi-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px) 132px;
  gap: var(--sp-3);
  align-items: center;
  padding: 0 var(--sp-3);
}
.kbi-list-head {
  flex: 0 0 auto;
  height: 28px;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--kbi-hair);
}
.kbi-list-head > span:nth-child(2),
.kbi-list-head > span:nth-child(3) { text-align: right; }

.kbi-list-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;   /* 滚到边界不把整页带走 —— 列表内滚动更"跟手" */
}
.kbi-list-body::-webkit-scrollbar { width: 10px; }

.kbi-row {
  position: relative;
  height: 30px;
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--kbi-hair);
  border-left: 2px solid transparent;
  /* 几千行时让浏览器跳过屏外行的排版与绘制（比虚拟滚动简单得多，且不破坏 DOM 稳定性） */
  content-visibility: auto;
  contain-intrinsic-size: auto 30px;
  transition: background 120ms var(--kbi-ease);
}
.kbi-row:last-child { border-bottom: 0; }
.kbi-row:hover { background: color-mix(in oklch, var(--text-1) 5%, transparent); }

/* 进度填充层：背景化的进度表达，宽度用 scaleX 而非 width —— 不触发布局 */
.kbi-row::before {
  content: '';
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  background: color-mix(in oklch, var(--kbi-up) 18%, transparent);
  transition: transform 260ms var(--kbi-ease), background 260ms var(--kbi-ease);
  pointer-events: none;
}
.kbi-row > * { position: relative; z-index: 1; }

.kbi-row[data-tone='up'] { border-left-color: color-mix(in oklch, var(--kbi-up) 70%, transparent); }
.kbi-row[data-tone='work'] { border-left-color: color-mix(in oklch, var(--kbi-work) 80%, transparent); }
.kbi-row[data-tone='work']::before {
  background: color-mix(in oklch, var(--kbi-work) 16%, transparent);
  transform: none;
  width: 38%;
  animation: kbi-sweep 1.5s var(--ease-in-out, ease-in-out) infinite;
}
/* 已整理的行走"无填充"：进度已经结束，留白 + 绿色状态脊就够；
   整片绿色真成"绿墙"后，红色的失败行反而看不见了（异常优先） */
.kbi-row[data-tone='ok'] { border-left-color: color-mix(in oklch, var(--kbi-ok) 80%, transparent); }
.kbi-row[data-tone='ok']::before { background: transparent; }
.kbi-row[data-tone='skip'] { border-left-color: var(--border-2); }
.kbi-row[data-tone='skip']::before { background: transparent; }
.kbi-row[data-tone='bad'] { border-left-color: color-mix(in oklch, var(--kbi-bad) 85%, transparent); }
.kbi-row[data-tone='bad']::before { background: color-mix(in oklch, var(--kbi-bad) 14%, transparent); }

@keyframes kbi-sweep {
  0% { transform: translateX(-40%); }
  100% { transform: translateX(260%); }
}

.kbi-path {
  font-family: var(--font-mono);
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
}
.kbi-size,
.kbi-state {
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.kbi-size { font-family: var(--font-mono); }
.kbi-state { font-weight: 600; }
.kbi-row[data-tone='idle'] .kbi-state { color: var(--text-3); font-weight: 400; }
.kbi-row[data-tone='up'] .kbi-state { color: var(--text-1); }
.kbi-row[data-tone='work'] .kbi-state { color: var(--text-1); }
.kbi-row[data-tone='ok'] .kbi-state { color: var(--kbi-ok); }
.kbi-row[data-tone='skip'] .kbi-state { color: var(--text-3); }
.kbi-row[data-tone='bad'] .kbi-state { color: var(--kbi-bad); }

/* 异常行可展开：状态后面挂个小指示符，不额外增加 DOM 节点 */
.kbi-row[data-expandable='1'] { cursor: pointer; }
.kbi-row[data-expandable='1'] .kbi-state::after { content: ' ›'; color: var(--text-3); }
.kbi-row[data-expandable='1'].is-expanded .kbi-state::after { content: ' ⌄'; }
.kbi-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.kbi-row-detail {
  padding: 6px var(--sp-3) 8px calc(var(--sp-3) + 2px);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-2);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--kbi-hair);
  border-left: 2px solid var(--border-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 已整理的知识（默认折叠：主视图留给文件列表） ---------- */

.kbi-entries { flex: 0 0 auto; border: 1px solid var(--kbi-hair); border-radius: var(--r-2); }
.kbi-entries > summary {
  padding: 8px var(--sp-3);
  font-size: var(--fs-xs);
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kbi-entries > summary b { font-family: var(--font-mono); color: var(--text-1); }
.kbi-entries > summary:hover { color: var(--text-1); }
.kbi-entries-body {
  max-height: 200px;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kbi-entry {
  border-left: 2px solid color-mix(in oklch, var(--brand) 60%, transparent);
  padding: 2px 0 2px 10px;
}
.kbi-entry-title { font-size: var(--fs-sm); font-weight: 600; }
.kbi-entry-body { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.6; }
.kbi-entry-meta { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); }

/* ---------- 拖拽反馈 ---------- */

.kbi-drop-veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklch, var(--surface-0) 72%, transparent);
  backdrop-filter: blur(1px);
  border: 2px dashed color-mix(in oklch, var(--brand) 60%, transparent);
  border-radius: var(--r-3);
  font-weight: 600;
  color: var(--text-1);
  pointer-events: none;
}
.app-dialog-card.kb-import-card.is-dragover { border-color: color-mix(in oklch, var(--brand) 55%, var(--border-1)); }
.app-dialog-card.kb-import-card.is-dragover .kbi-empty {
  border-color: var(--brand);
  background: color-mix(in oklch, var(--brand) 10%, var(--surface-sunken));
}

/* 常驻的隐藏文件输入框：不用 display:none（部分浏览器会拒绝 click()），
   用 1px + opacity 0 保持"可被程序点击"的同时完全不占布局 */
.kbi-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.kbi-foot { flex: 0 0 auto; }
.kbi-foot > .btn-secondary[hidden],
.kbi-foot > .btn-primary[hidden] { display: none !important; }

/* ---------- 知识库面板里的「导入记录」---------- */

.kb-import-history { display: flex; flex-direction: column; gap: var(--sp-2); }
.kb-import-history-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  font-size: var(--fs-sm); font-weight: 600;
}
.kb-import-history-empty { font-size: var(--fs-xs); padding: var(--sp-2) 0; line-height: 1.7; }
.kb-import-history-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.kb-import-history-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-2);
  background: var(--surface-1);
}
.kb-import-history-main { flex: 1; min-width: 0; }
.kb-import-history-name { font-size: var(--fs-sm); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kb-import-history-meta { font-size: var(--fs-xs); margin-top: 3px; font-variant-numeric: tabular-nums; }
.kb-import-history-actions { display: flex; gap: 6px; flex-shrink: 0; }
.kb-import-mini-bar {
  height: 3px; border-radius: 999px; background: var(--surface-sunken);
  overflow: hidden; margin-top: 6px;
}
.kb-import-mini-bar > i {
  display: block; height: 100%; width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: transform 320ms var(--ease-out-quart);
}
.kb-import-mini-current {
  font-size: var(--fs-xs); margin-top: 3px;
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-import-live { color: var(--brand-text); }

.kb-import-badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.kb-import-badge.is-done { background: color-mix(in oklch, var(--success) 18%, transparent); color: var(--success); }
.kb-import-badge.is-running { background: color-mix(in oklch, var(--brand) 16%, transparent); color: var(--brand-text); }
.kb-import-badge.is-failed { background: color-mix(in oklch, var(--danger) 16%, transparent); color: var(--danger-text); }
.kb-import-badge.is-skip { background: var(--surface-sunken); color: var(--text-3); border-color: var(--border-1); }
.kb-import-badge.is-canceled { background: var(--surface-sunken); color: var(--text-3); }
.kb-import-hint-sm { font-size: var(--fs-xs); }

/* 知识库管理面板 / 配置页：拖入时整块高亮 */
.kb-manager-body.is-dragover,
#kb-body.is-dragover {
  outline: 2px dashed var(--brand);
  outline-offset: -6px;
  background: color-mix(in oklch, var(--brand) 8%, transparent);
  border-radius: var(--r-2);
}
.kb-manager-inline {
  margin-top: 14px;
  padding: 0;
  max-height: none;
  overflow: visible;
}
.role-kb-inline-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-1);
}
.role-own-kb-search {
  margin-bottom: 10px;
}
.role-own-kb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.role-own-kb-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2, 8px);
  background: var(--surface-1);
}
.role-own-kb-item-main {
  min-width: 0;
  flex: 1;
}
.role-own-kb-item-main > p {
  margin: 4px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
  word-break: break-word;
}
.role-own-kb-kws {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.mcp-verify-ok {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-1, 6px);
  background: color-mix(in oklch, var(--success) 12%, transparent);
  color: var(--success-fill, var(--success));
  font-size: var(--fs-sm);
  line-height: 1.45;
}
details.project-mcp-toolset > summary.project-mcp-toolset-head {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
details.project-mcp-toolset > summary.project-mcp-toolset-head::-webkit-details-marker {
  display: none;
}
details.project-mcp-toolset > summary.project-mcp-toolset-head::before {
  content: '▸';
  margin-right: 6px;
  color: var(--text-3);
  transition: transform 150ms var(--ease-out-quart, ease);
}
details.project-mcp-toolset[open] > summary.project-mcp-toolset-head::before {
  transform: rotate(90deg);
}
details.project-mcp-toolset > summary.project-mcp-toolset-head > strong {
  margin-right: auto;
}
.project-mcp-tool-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border-1);
}
.project-mcp-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.project-mcp-batch-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.project-mcp-batch-risk {
  width: auto;
  min-width: 96px;
  height: var(--ctl-h-sm, 30px);
  padding: 0 8px;
  font-size: var(--fs-sm);
}

/* ---------- 动效可关闭 ---------- */

@media (prefers-reduced-motion: reduce) {
  .kbi-row[data-tone='work']::before { animation: none; transform: none; width: 100%; opacity: 0.5; }
  .kbi-row::before,
  .kbi-agg > i,
  .kb-import-mini-bar > i { transition: none; }
}

/* ---------- 窄屏：收起次要列，保证路径可读 ---------- */

@media (max-width: 720px) {
  .kbi-list-head,
  .kbi-row { grid-template-columns: minmax(0, 1fr) 104px; }
  .kbi-list-head > span:nth-child(2),
  .kbi-row .kbi-size { display: none; }
  .kbi-agg { width: 96px; }
}

/* ============================================================================
 * 重建批次 1 · 基础容器与共享原子
 *
 * 说明：本段是事故后按 app.js / index.html 里**实际在用的 DOM**
 * 逐个重建的。重建原则：只用本文件已有的设计令牌，不引入新的色值与字号。
 * ========================================================================== */

/* ---------- card：一层壳，不嵌套 ---------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-4);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.card-body { font-size: var(--fs-sm); line-height: 1.65; color: var(--text-2); }

/* ---------- 表单原子 ---------- */

/* .ar-* 是「设置里的行内表单」这一族控件的统一外壳：
   行内使用，不进大表单，所以压到 fs-sm / 28px 高 */
.ar-input {
  height: 28px;
  padding: 0 var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  min-width: 0;
}
.ar-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}
.ar-input:disabled { opacity: 0.55; cursor: not-allowed; }
textarea.ar-input { height: auto; padding: var(--sp-2); line-height: 1.55; resize: vertical; }
select.ar-input { cursor: pointer; }

.ar-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--sp-1);
}
.ar-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.ar-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; }
.ar-wrap { display: flex; flex-direction: column; gap: var(--sp-3); }
.ar-sec { display: flex; flex-direction: column; gap: var(--sp-2); }

.ar-hint { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.6; }
.ar-muted { font-size: var(--fs-sm); color: var(--text-3); }

/* 三个反馈态共用一条左边框 + 一行文案，不做彩色标签 */
.ar-ok, .ar-err, .ar-warn, .ar-testout > div {
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--border-2);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-2);
  background: var(--surface-sunken);
}
.ar-ok { border-left-color: var(--success); }
.ar-err { border-left-color: var(--danger); }
.ar-warn { border-left-color: var(--warning); }

.ar-check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
}
.ar-check input { accent-color: var(--brand); }

.ar-reply {
  display: block;
  margin-top: var(--sp-1);
  padding: var(--sp-2);
  background: var(--surface-sunken);
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
}

/* 工具清单（模型 / MCP 侧的风险等级与说明） */
.ar-tools { display: flex; flex-direction: column; gap: var(--sp-1); }
.ar-tool {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-1);
  font-size: var(--fs-sm);
}
.ar-tool:last-child { border-bottom: none; }
.ar-tool-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-1);
}
.ar-tool-desc {
  flex: 1;
  color: var(--text-3);
  font-size: var(--fs-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ar-tool-risk {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  background: var(--surface-sunken);
}
/* 只读级（记录类工具）不需要用户决策，给中性色而不是警告色 */
.ar-tool-risk.risk-read { color: var(--text-3); }

/* 模型调用轨迹（对话里「AI 刚才做了什么」的折叠区） */
.ar-toolcall { font-size: var(--fs-xs); color: var(--text-3); }
.ar-toolcall-idx {
  font-family: var(--font-mono);
  color: var(--text-2);
  margin-right: var(--sp-2);
}
.ar-toolcall-sum { color: var(--text-2); }
.ar-toolcall-args {
  display: block;
  margin-top: var(--sp-1);
  padding: var(--sp-2);
  background: var(--surface-sunken);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-3);
}

/* ---------- 其他零散原子 ---------- */

.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.btn-row-tight { gap: var(--sp-1); }
.label { font-size: var(--fs-sm); color: var(--text-2); }
.form-grid { display: grid; gap: var(--sp-3); }
.field-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
}
.icon-btn-ico { display: inline-flex; align-items: center; justify-content: center; }
.icon-btn-ico .mc-icon { width: var(--ico-lg); height: var(--ico-lg); }

.message-content { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.email-detail-body-content { font-size: var(--fs-sm); line-height: 1.7; color: var(--text-1); }
.citation-item { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.7; }

/* 出站气泡（AI = 品牌蓝底 / 人工客服 = 成功绿底）里的引用必须用反色文字。
 *
 * 【为什么需要这条】`.message.outbound .message-citations` 已经把容器改成反色了，
 * 但 `.citation-item` 是**子元素且自己声明了 color: var(--text-3)** ——
 * 子元素自己的声明优先于继承，于是引用文字实际渲染成中性灰：
 * light 主题下是 oklch(58%)，压在 oklch(68%) 的品牌蓝上，对比度极低，几乎看不清。
 * （正文没受影响，因为它走的是气泡自身的 `color: var(--text-inverse)`。）
 *
 * 用 0.85 而不是容器那档 0.7：引用是 --fs-xs 小字号，
 * 小字需要更高对比度才够清晰；但也不宜到纯不透明，否则会和正文抢注意力。 */
.message.outbound .citation-item {
  color: oklch(from var(--text-inverse) l c h / 0.85);
}
.message.outbound .message-citations .mc-cite-ico {
  /* 图标随文字一起提亮，避免出现「图标亮、文字灰」的割裂感 */
  color: oklch(from var(--text-inverse) l c h / 0.85);
}
.chat-action, .copy-id-btn, .toggle-status-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  background: var(--surface-1);
  color: var(--text-2);
  cursor: pointer;
}
.chat-action:hover, .copy-id-btn:hover, .toggle-status-btn:hover {
  border-color: var(--border-2);
  color: var(--text-1);
}

.ocp-avatar-inner { display: inline-flex; align-items: center; justify-content: center; }
.ocp-avatar-inner .mc-icon { width: var(--ico-md); height: var(--ico-md); }

/* 会话项里的两行结构（标题行 / 预览行） */
.session-item-row { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.session-item-row-title { justify-content: space-between; }
.session-item-row-title .t { font-size: var(--fs-sm); font-weight: 500; color: var(--text-1); }
.session-item-row-preview { margin-top: 2px; }
.session-item-row-preview .p {
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes apSpin { to { transform: rotate(360deg); } }

/* ============================================================================
 * 重建批次 3 · 对话创建向导（aw-*）与审批记录（apv-*）
 *
 * 两个遮罩共用 .aw-backdrop / .aw-card / .aw-head / .aw-body / .aw-foot：
 * 向导是双栏（左聊右预览），审批是单栏（.aw-body-single）。
 * ========================================================================== */

.aw-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: oklch(0% 0 0 / 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: awFade 180ms var(--ease-out-expo);
}
@keyframes awFade { from { opacity: 0; } to { opacity: 1; } }

.aw-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  max-height: calc(100dvh - var(--sp-8));
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: 0 24px 64px -16px oklch(0% 0 0 / 0.55);
  overflow: hidden;
  animation: awUp 240ms var(--ease-out-expo);
}
/* 审批 / 小工具复用同一张卡，但不该占满宽度 */
.aw-card-narrow { max-width: 560px; }
@keyframes awUp {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.aw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--mc-space-3, 12px);
  padding: var(--mc-space-4, 16px) var(--mc-space-6, 24px);
  border-bottom: 1px solid var(--mc-border-subtle, var(--border-1));
  flex-shrink: 0;
}
.aw-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.aw-sub {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.6;
}
.aw-close { flex-shrink: 0; }

.aw-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.aw-body-single {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-4, 16px);
  padding: var(--mc-space-5, 20px) var(--mc-space-6, 24px);
  overflow-y: auto;
}
.aw-body-single:has(.aw-chat) {
  display: grid;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

/* 左：对话区 */
.aw-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border-1);
}
.aw-body-single .aw-chat { border-right: none; }
.aw-log {
  flex: 1;
  min-height: 160px;
  max-height: 46vh;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.aw-bubble {
  max-width: 84%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.aw-user {
  align-self: flex-end;
  background: var(--brand-soft);
  color: var(--text-1);
  border-bottom-right-radius: var(--r-1);
}
.aw-assistant {
  align-self: flex-start;
  background: var(--surface-sunken);
  color: var(--text-1);
  border-bottom-left-radius: var(--r-1);
}
.aw-error {
  align-self: flex-start;
  background: var(--danger-soft);
  color: var(--text-1);
  border-left: 2px solid var(--danger);
}
.aw-muted-note { color: var(--text-3); }

/* 快捷提示：点一下补全需求，降低「不知道该说什么」的门槛 */
.aw-tips { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-2); }
.aw-tip {
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: 3px 9px;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.aw-tip:hover { border-style: solid; color: var(--brand-text); border-color: var(--brand); }

.aw-input-row {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-1);
  flex-shrink: 0;
}
.aw-input {
  flex: 1;
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-1);
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  resize: none;
}
.aw-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}

/* 右：生成结果预览（只读，用来让人在提交前确认） */
.aw-preview {
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4);
  background: var(--surface-sunken);
}
.aw-preview-empty {
  height: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-5);
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-3);
}
.aw-pv-block + .aw-pv-block { margin-top: var(--sp-5); }
.aw-pv-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border-1);
}
.aw-pv-name {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.aw-pv-role { font-size: var(--fs-xs); font-weight: 400; color: var(--text-3); }
.aw-pv-desc { margin-top: var(--sp-1); font-size: var(--fs-xs); line-height: 1.7; color: var(--text-2); }
.aw-pv-model { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); }

.aw-pv-prompt {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}


.aw-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--mc-space-3, 12px);
  padding: var(--mc-space-4, 16px) var(--mc-space-6, 24px);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
  flex-shrink: 0;
}
.aw-status {
  margin-right: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
  min-height: 1em;
}

/* ---------- 审批记录（apv-*） ---------- */

.apv-row {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-1);
}
.apv-row:last-child { border-bottom: none; }
.apv-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.apv-tool {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-1);
  padding: 1px 7px;
  border-radius: var(--r-1);
  background: var(--surface-sunken);
}
.apv-status {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-2);
}
.apv-status.status-approved { color: var(--success); }
.apv-status.status-rejected { color: var(--danger-text); }
.apv-status.status-pending  { color: var(--warning); }
.apv-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.apv-args { margin-top: var(--sp-2); }
.apv-args pre {
  margin: 0;
  padding: var(--sp-2);
  background: var(--surface-sunken);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 140px;
  overflow-y: auto;
}
.apv-reason, .apv-result, .apv-note {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: 1.65;
  color: var(--text-2);
}
.apv-result { color: var(--text-3); }
.apv-ops { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); align-items: center; }
.apv-note-input { flex: 1; }

/* ---------- 外部工具 / 通知通道清单 ---------- */

.mcp-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-1);
}
.mcp-row:last-child { border-bottom: none; }
.mcp-main { flex: 1; min-width: 0; }
.mcp-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-1);
}
.mcp-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-3);
}
/* 风险等级：只读 / 可写 / 高危 三档，色差即语义 */
.mcp-tag.risk-read    { color: var(--text-3); }
.mcp-tag.risk-low     { color: var(--text-2); }
.mcp-tag.risk-medium  { color: var(--warning); }
.mcp-tag.risk-high    { color: var(--danger-text); }
.mcp-meta {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.6;
  word-break: break-all;
}
.mcp-ops { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.mcp-out { display: flex; flex-direction: column; gap: var(--sp-1); }
.mcp-tool {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.mcp-tool .mcp-tag { flex-shrink: 0; }
.mcp-main:empty { display: none; }

/* ============================================================================
 * 重建批次 5 · 项目配置弹窗（pd-*）、渠道接入向导（qr/wizard-*）、
 *                模型验证输出（llm-test-*）、知识库（kb-*）
 * ========================================================================== */

/* ---------- 项目配置弹窗（pd-*） ---------- */

.pd-input {
  width: 100%;
  min-width: 0;
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
}
textarea.pd-input { height: auto; padding: var(--sp-2); resize: vertical; line-height: 1.55; }
.pd-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}
.pd-preset-select { font-family: var(--font-mono); font-size: var(--fs-xs); }
.pd-prompt-preview {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3);
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface-sunken);
  border-radius: var(--r-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.pd-kb-list { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); font-size: var(--fs-sm); color: var(--text-2); }

/* 基本信息弹窗：邮件设置、项目状态各成一段，与上面的字段隔开 */
.pd-email-settings,
.pd-brand-settings,
.pd-project-members {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-3, 12px);
  padding-top: var(--mc-space-4, 16px);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
}
.pd-project-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mc-space-3, 12px);
  padding-top: var(--mc-space-4, 16px);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
}
.channel-email-settings h4 {
  margin: 0;
  font-size: var(--mc-text-base, 0.875rem);
  font-weight: 600;
  color: var(--mc-fg-primary, var(--text-1));
}
.channel-email-settings .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-2, 8px);
  margin: 0;
}

/* Agent 设置 → 知识库：每行「名称 + 条数」，和渠道列表同一种读法 */
.pd-kb-rows { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.pd-kb-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-1); background: var(--surface-sunken); font-size: var(--fs-sm); }
.pd-kb-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-kb-list li { margin-bottom: var(--sp-1); }

/* 弹窗内底部一排操作按钮：左「取消」右「保存」 */
.pd-save-basic, .pd-save-preset-btn, .pd-activate-btn, .pd-archive-btn,
.pd-manage-kb-btn, .pd-new-kb-btn, .pd-custom-preset-btn, .pd-delete-btn,
.pe-save-btn, .pe-cancel-btn { flex-shrink: 0; }
.pd-delete-btn { color: var(--danger-text); }

/* 角色分组标题（AI 角色库按 kind 分组） */
.agent-preset-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.agent-preset-group::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-1);
}

/* ---------- 模型服务商编辑器（pe-*） ---------- */

.pe-fetch-btn { display: inline-flex; align-items: center; gap: var(--sp-2); }
.pe-models-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.pe-fetch-status { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--sp-1); }

/* ---------- 渠道接入向导（qr-* / wizard-*） ---------- */

.wizard-steps {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-1);
}
.wizard-step {
  position: relative;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.wizard-step.active { color: var(--brand-text); font-weight: 500; }
.wizard-step.done { color: var(--text-2); }
.wizard-step.done::before { content: '✓ '; color: var(--success); }

/* 二维码：每种接入方式一张，不做成九宫格 */
.qr-grid { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.qr-card {
  flex: 1 1 220px;
  min-width: 0;
  padding: var(--sp-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  text-align: center;
}
.qr-card img, .qr-card svg {
  display: block;
  margin: 0 auto;
  width: 160px;
  height: 160px;
  background: white;
  border-radius: var(--r-1);
  padding: var(--sp-2);
}
.qr-card-label {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-1);
}
.field-box { margin-top: var(--sp-3); }

/* ---------- 模型验证输出（llm-test-*） ---------- */

.llm-provider-testout {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--border-2);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  background: var(--surface-sunken);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.llm-provider-testout[hidden] { display: none; }
.llm-test-ok { color: var(--success); }
.llm-test-err { color: var(--danger-text); }
.llm-test-reply {
  margin-top: var(--sp-1);
  color: var(--text-2);
  line-height: 1.6;
  max-height: 90px;
  overflow-y: auto;
}

/* ---------- 知识库（kb-*） ---------- */

.kb-search-widget { display: flex; flex-direction: column; gap: var(--sp-2); }
.kb-add-entry-btn, .kb-delete-btn, .kb-import-btn { flex-shrink: 0; }
.kb-search-widget { display: block; }
.kb-add-entry-btn { align-self: flex-start; }

/* ============================================================================
 * 产品化重构层（impeccable · distill + onboard + clarify）
 *
 * 这一层只服务三件事：把空状态写成有价值的引导、把设置按使用频次分层、
 * 让新用户第一次进来知道下一步去哪。其余一律不加装饰。
 * ========================================================================== */

/* ---------- 会话区空状态 ---------- */

.empty-state-tips {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-1);
  text-align: left;
  max-width: 380px;
}
.empty-tip {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-3);
}
.empty-tip-kbd {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 20px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
}
.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
  margin-top: var(--sp-5);
}

/* ---------- 通用空块（设置页里复用的是同一个） ---------- */

.empty-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-3);
}
.empty-block-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-3);
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--text-3);
}
.empty-block-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.empty-block-text {
  margin-top: var(--sp-1);
  font-size: var(--fs-sm);
  line-height: 1.65;
  color: var(--text-2);
}
.empty-block-hint {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: 1.65;
  color: var(--text-3);
}
.empty-block-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
  margin-top: var(--sp-4);
}

/* ---------- 设置：三层分组导航 ---------- */

.settings-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.settings-title-row h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}
.settings-onboard-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-1);
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
}
.settings-onboard-link:hover { border-color: var(--brand); color: var(--brand-text); }
.settings-onboard-link .mc-icon { width: var(--ico-sm); height: var(--ico-sm); color: var(--accent); }

/* tab 分三簇横排，不加分类标题。
   组内 tab 紧贴（它们常被连着看），组间留大空（跨组跳转频率低）。
   没有文字标签，层级只能靠间距说 —— 所以组间距必须明显大于组内间距。 */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 var(--sp-7);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-1);
}
.settings-group { display: flex; flex-direction: column; }
/* 簇与簇之间补一道竖发丝线，替代原来那行分类文字的位置 */
.settings-group + .settings-group {
  padding-left: var(--sp-7);
  border-left: 1px solid var(--border-1);
}
.settings-group-tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.settings-group-tabs .tab-btn {
  flex: 0 0 auto;
  border-radius: var(--r-2) var(--r-2) 0 0;
}
.settings-group-tabs .tab-btn.active {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--brand);
}

.auth-login-notice {
  padding: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--brand-soft);
  color: var(--text-1);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.auth-login-notice[hidden] { display: none; }
/* 账户安全：外壳由弹窗提供，卡片自己只负责内部排版（见文末 .account-security-card 版式）。 */
.account-password-dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  margin: auto;
  padding: var(--sp-5);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: var(--surface-1);
  color: var(--text-1);
  box-shadow: var(--shadow-2);
}
.account-password-dialog::backdrop { background: oklch(10% .02 265 / .55); }
.account-password-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.account-password-head h2 { margin: 0; font: 600 var(--fs-xl) var(--font-display); }
#account-password-description { margin: 0 0 var(--sp-5); line-height: 1.6; }
.account-password-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }
.account-password-dialog button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (max-width: 480px) {
  .account-password-actions button { flex: 1 1 auto; }
}

/* ============================================================================
 * 总览页重构：从「四张英雄指标卡」改成「一条横带 + 可点的最近会话 + 长尾洞察」
 *
 * 为什么不用英雄指标：一行超大数字是给汇报用的，而盯进度的人要的是
 * 「哪几条还没回」——所以数字降级成一条扫得过的横带，最近会话升为主位。
 * ========================================================================== */

.overview-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-1);
}

/* ---------- 今日一览：发丝分隔的横带，不是一排盒子 ---------- */
/* ---------- 主区：最近会话占位，右侧一句「这页干什么」 ---------- */

.ov-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: var(--sp-5);
  align-items: start;
  margin-bottom: var(--sp-7);
}
.ov-recent {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  overflow: hidden;
}
.ov-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
}
.ov-block-head h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.ov-block-more {
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: none;
  border: none;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-1);
  cursor: pointer;
}
.ov-block-more:hover { color: var(--brand-text); background: var(--surface-sunken); }

/* 会话行是一整条可点区域 —— 运营看到未读就该能直接钻进去 */
.ov-recent-list { display: flex; flex-direction: column; }
.ov-recent-item {
  /* 五列定宽：点 / 谁 / 哪个项目 / 最近说了什么 / 什么时候 —— 每列都稳定，
     扫一列就能找出「同一个项目里还没回的那几条」 */
  display: grid;
  grid-template-columns: 8px minmax(72px, 128px) minmax(0, 96px) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-1);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart);
}
.ov-recent-item:last-child { border-bottom: none; }
.ov-recent-item:hover { background: var(--surface-sunken); }
.ov-recent-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* 未读点：不用数字徽章，只用一个实心点 —— 这里要的是「有没有」，不是「几条」 */
.ov-recent-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
}
.ov-recent-item.is-unread .ov-recent-dot { background: var(--danger); }

.ov-recent-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-recent-item.is-unread .ov-recent-title { font-weight: 700; }

.ov-recent-proj {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-recent-preview {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ov-recent-time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.ov-note {
  padding: var(--sp-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  font-size: var(--fs-xs);
  line-height: 1.7;
  color: var(--text-2);
}
.ov-note h3 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}
.ov-note p + p { margin-top: var(--sp-2); }
.ov-note-foot { color: var(--text-3); }
.ov-inline-link {
  font: inherit;
  color: var(--brand-text);
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ============================================================
   总览 · 价值回执 / 置信度 / 知识库健康度
   ------------------------------------------------------------
   这一层只做「把数字摆正」：发丝线分区、等宽数字右对齐、
   颜色只在「好 / 待提升」两种状态间切换，其余一律中性墨色。
   图表用 --ov-series-* 两个色槽，明暗两套都经过 CVD 校验
   （浅色 #2563EB/#EB6834，深色 #3987E5/#D95926）。
   ============================================================ */
.overview-view {
  --ov-series-1: light-dark(#2563eb, #3987e5);
  --ov-series-2: light-dark(#eb6834, #d95926);
  --ov-track: light-dark(oklch(93% 0.01 255), oklch(26% 0.015 258));
  --ov-good: light-dark(#15803d, #4ade80);
}

/* hidden 属性必须压过下面这些 display:flex —— 否则「自动回复已开启」时，
   那条空的 CTA 仍会留一个按钮在页面上（作者样式胜过 UA 的 display:none）。 */
.overview-view [hidden] { display: none !important; }

/* 时间窗切换：分段按钮，选中的那个是唯一有底色的 */
.overview-view .ov-range {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
}
.overview-view .ov-range-btn {
  font: inherit;
  font-size: var(--fs-xs);
  padding: 3px 10px;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-quart), background var(--dur-fast) var(--ease-out-quart);
}
.overview-view .ov-range-btn:hover { color: var(--text-1); }
.overview-view .ov-range-btn.is-active {
  background: var(--surface-1);
  color: var(--text-1);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}

/* ---------- ① 价值回执 ---------- */
.ov-value {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.ov-value-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.ov-value-head h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.ov-value-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border-1);
}
.ov-value-hero, .ov-value-mini { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ov-value-hero + .ov-value-mini,
.ov-value-mini { padding-left: var(--sp-4); border-left: 1px solid var(--border-1); }
.ov-value-hero:first-child { padding-left: 0; border-left: none; }
.ov-value-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--text-3);
}
/* 英雄数字：48px 上限，比例数字（非等宽）—— 等宽会让 121 这类数看着发松 */
.ov-value-figure {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 2.6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-1);
}
.ov-value-figure i {
  font-style: normal;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-3);
}
.ov-value-sm {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-1);
}
.ov-value-note { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.ov-value-note b { font-variant-numeric: tabular-nums; color: var(--text-1); }

.ov-value-roi {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--brand-soft);
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.ov-roi-badge {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-text);
}
.ov-roi-text { line-height: 1.6; }

.ov-value-assume {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.6;
}

/* ---------- ② 置信度 ---------- */
.ov-conf {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.ov-conf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.ov-conf-head h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
}
.ov-conf-verdict {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--r-pill);
}
.ov-conf-verdict[data-tone="good"] { color: var(--ov-good); background: color-mix(in oklch, var(--ov-good) 12%, transparent); }
.ov-conf-verdict[data-tone="warn"] { color: var(--text-1); background: var(--accent-soft); }
.ov-conf-verdict[data-tone="muted"] { color: var(--text-3); background: var(--surface-sunken); }

/* 进度条：轨道是同一色相的浅一档，填充才是数据 */
.ov-conf-meter {
  position: relative;
  padding: 6px 0 var(--sp-6);
}
.ov-conf-track {
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--ov-track);
  overflow: hidden;
}
.ov-conf-fill {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--ov-series-1);
  transition: width var(--dur-slow) var(--ease-out-quart), background var(--dur-base) var(--ease-out-quart);
}
.ov-conf-fill[data-state="good"] { background: var(--ov-good); }
/* 90% 建议线：一条竖刻度，不是网格线 —— 它承载的是产品给的建议阈值 */
.ov-conf-gate {
  position: absolute;
  top: 0;
  bottom: var(--sp-4);
  width: 1px;
  background: var(--border-2);
}
.ov-conf-gate::before {
  content: "";
  position: absolute;
  top: -1px; left: -3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-2);
}
.ov-conf-gate-label {
  position: absolute;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  /* 这行是阈值说明，不是装饰：10.5px 下 --text-3 只有 3.9:1，达不到 4.5 */
  color: var(--text-2);
}
.ov-conf-foot {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.ov-conf-figure b {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.ov-conf-cta {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
}
.ov-conf-cta p { flex: 1 1 320px; margin: 0; font-size: var(--fs-sm); line-height: 1.6; color: var(--text-2); }

.ov-conf-byproject { margin-top: var(--sp-4); }
.ov-conf-list { display: flex; flex-direction: column; gap: 6px; }
.ov-conf-row {
  display: grid;
  grid-template-columns: minmax(72px, 140px) minmax(60px, 1fr) 48px auto;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
}
.ov-conf-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-conf-mini-track { height: 5px; border-radius: var(--r-pill); background: var(--ov-track); overflow: hidden; }
.ov-conf-mini-fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--ov-series-1); }
.ov-conf-mini-fill[data-state="good"] { background: var(--ov-good); }
.ov-conf-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-1); text-align: right; }
.ov-conf-tag { color: var(--text-3); white-space: nowrap; }

/* ---------- ③ 图表卡 ---------- */
.ov-charts {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.ov-chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  overflow: hidden;
  min-width: 0;
}
.ov-legend { display: inline-flex; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--text-2); }
.ov-key { display: inline-flex; align-items: center; gap: 5px; }
.ov-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
/* 容器高度含 x 轴文字带：图表卡不该出现自己的小滚动条 */
.ov-chart-plot { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.ov-svg { display: block; width: 100%; height: auto; }
.ov-grid { stroke: var(--border-1); stroke-width: 1; }
.ov-baseline { stroke: var(--border-2); stroke-width: 1; }
.ov-axis { fill: var(--text-3); font-family: var(--font-mono); font-size: 10px; font-variant-numeric: tabular-nums; }

.ov-table-view { border-top: 1px solid var(--border-1); }
.ov-table-view summary {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--text-3);
  cursor: pointer;
}
.ov-table-view summary:hover { color: var(--text-1); }
.ov-table-view[open] summary { border-bottom: 1px solid var(--border-1); }
.ov-table-view .ap-table-wrap { max-height: 260px; overflow: auto; }

/* 排行条：单色，比较的是长度不是颜色 */
.ov-ranked { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-1) var(--sp-4) var(--sp-4); }
.ov-ranked-row {
  display: grid;
  grid-template-columns: minmax(80px, 132px) minmax(40px, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
}
/* 英文分类名比中文长（Missing from knowledge base），单行会截成半句；
   允许折两行，行高收紧，排行条的高度才是齐的。 */
.ov-ranked-name {
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.ov-ranked-track { height: 7px; border-radius: var(--r-pill); background: var(--ov-track); overflow: hidden; }
.ov-ranked-fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--ov-series-1); }
.ov-ranked-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.ov-ranked-val em { font-style: normal; color: var(--text-3); }

/* ---------- ④ 知识库健康度 ---------- */
.ov-kb {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  overflow: hidden;
  margin-bottom: var(--sp-5);
}
.ov-kb-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.ov-kb-cell {
  padding: var(--sp-4);
  border-left: 1px solid var(--border-1);
  min-width: 0;
}
.ov-kb-cell:first-child { border-left: none; }
.ov-kb-cell h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}
.ov-dim { display: flex; flex-direction: column; gap: 7px; }
.ov-dim-row {
  display: grid;
  grid-template-columns: minmax(52px, 1fr) minmax(30px, 46%) auto;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
}
/* 维度名允许折成两行：知识库/项目名是中文长词，单行省略会把「医美咨询演示示例知识库」
   这类名字切掉一半，用户分不清是谁。两行封顶，再长才省略。 */
.ov-dim-name {
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.ov-dim-track { height: 5px; border-radius: var(--r-pill); background: var(--ov-track); overflow: hidden; }
.ov-dim-fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--ov-series-1); }
.ov-dim-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  text-align: right;
  min-width: 28px;
}
.ov-kb-notes {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.7;
}
.ov-kb-notes:empty { display: none; }

/* ---------- ⑤ 未覆盖问题 ---------- */
.ov-gaps {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
  overflow: hidden;
  margin-bottom: var(--sp-6);
}
.ov-gap-list { display: flex; flex-direction: column; }
.ov-gap-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) minmax(0, 96px) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-sm);
}
.ov-gap-row:first-child { border-top: none; }
.ov-gap-row:hover { background: var(--surface-sunken); }
.ov-gap-count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.ov-gap-q { color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-gap-proj {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-gap-list > .empty-block, .ov-gap-list > .ov-muted { padding: var(--sp-4); }
.ov-gap-split-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--mc-accent, #2563eb);
  background: var(--mc-accent-soft, rgba(37, 99, 235, 0.09));
  vertical-align: middle;
}

/* 新建 / 编辑知识库条目（问答表单） */
.kb-qa-card {
  width: min(640px, 94vw);
  max-height: 90vh;
}
.kb-qa-original {
  border: 1px solid var(--border-1);
  border-radius: var(--mc-radius-md, 8px);
  background: var(--surface-2);
  padding: 10px 14px;
}
.kb-qa-original > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  user-select: none;
  list-style: none;
}
.kb-qa-original > summary::-webkit-details-marker { display: none; }
.kb-qa-original > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 150ms var(--mc-ease-out, ease);
}
.kb-qa-original[open] > summary::before {
  transform: rotate(90deg);
}
.kb-qa-original-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-1);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
  user-select: text;
}
.kb-qa-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.kb-qa-label-row label {
  margin: 0;
}
.kb-qa-kw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.kb-qa-kw-wrap > input {
  width: 100%;
  padding-right: 38px;
}
.kb-qa-kw-icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-1, 6px);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart), color var(--dur-fast) var(--ease-out-quart);
}
.kb-qa-kw-icon-btn:hover:not(:disabled) {
  background: var(--brand-soft);
  color: var(--brand-text);
}
.kb-qa-kw-icon-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.kb-qa-kw-icon-btn.is-loading svg {
  animation: auth-loading-spin 900ms linear infinite;
}
.kb-cat-combo {
  position: relative;
}
.kb-cat-combo > input {
  width: 100%;
  padding-right: 36px;
}
.kb-cat-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-1, 6px);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart), color var(--dur-fast) var(--ease-out-quart);
}
.kb-cat-toggle:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
.kb-cat-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2, 8px);
  box-shadow: var(--shadow-2);
  padding: 4px;
}
.kb-cat-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  border-radius: var(--r-1, 6px);
  background: transparent;
  color: var(--text-1);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.kb-cat-option:hover,
.kb-cat-option.is-selected {
  background: var(--brand-soft);
  color: var(--brand-text);
}
.kb-cat-option.is-create {
  border-top: 1px solid var(--border-1);
  margin-top: 4px;
  padding-top: 8px;
  color: var(--brand-text);
}
.kb-cat-option-meta {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}
.kb-cat-empty {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-3);
}
.pd-project-kb {
  padding-top: 16px;
  border-top: 1px solid var(--border-1);
}

/* 项目设置独立页（Tabs 分区 + 默认 AI 角色卡片 + 知识库列表） */
.ps-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: var(--sp-5, 20px);
  overflow-x: auto;
}
.ps-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 150ms var(--mc-ease-out, ease), border-color 150ms var(--mc-ease-out, ease);
}
.ps-tab:hover { color: var(--text-1); }
.ps-tab.is-active {
  color: var(--mc-accent, #2563eb);
  font-weight: 600;
  border-bottom-color: var(--mc-accent, #2563eb);
}
.ps-body {
  max-width: 760px;
}
.ps-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ps-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ps-divider-block {
  padding-top: 18px;
  margin-top: 6px;
  border-top: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ps-default-role-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border-1);
  border-radius: var(--mc-radius-lg, 12px);
  background: var(--surface-1);
}
.ps-default-role-main {
  min-width: 0;
  flex: 1;
}
.ps-default-role-view {
  flex-shrink: 0;
}
.ps-kb-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-1);
  border-radius: var(--mc-radius-lg, 12px);
  background: var(--surface-1);
  overflow: hidden;
}
.ps-kb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-1);
}
.ps-kb-row:last-child { border-bottom: 0; }

/* 渠道列表统一品牌图标 + 更多操作菜单 */
.channel-icon .channel-brand-logo-img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: contain;
}
.channel-more-wrap {
  position: relative;
  display: inline-flex;
}
.channel-more-btn {
  min-width: 34px;
  padding-inline: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.channel-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 140px;
  padding: 4px;
  border-radius: var(--mc-radius-md, 8px);
  border: 1px solid var(--border-2, var(--border-1));
  background: var(--mc-bg-elevated, var(--surface-1));
  box-shadow: var(--mc-shadow-lg, 0 12px 32px rgba(15, 23, 42, 0.14));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.channel-more-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-1);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms var(--mc-ease-out, ease);
}
.channel-more-item:hover { background: var(--surface-2); }
.channel-more-item.is-danger { color: var(--danger); }
.channel-more-item.is-danger:hover { background: var(--mc-danger-soft, rgba(220, 38, 38, 0.1)); }

/* ---------- 未覆盖问题明细弹窗 ---------- */
.gap-detail { display: flex; flex-direction: column; gap: var(--sp-4); }
.gap-detail-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.gap-detail-block h4 {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
}
.gap-detail-original {
  margin: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}
.gap-detail-hint { margin: 0; font-size: var(--fs-xs); color: var(--text-3); }
.gap-detail-questions { display: flex; flex-direction: column; gap: var(--sp-2); }
.gap-detail-question {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.gap-detail-question:hover { border-color: var(--brand); background: var(--surface-sunken); }
.gap-detail-text { overflow: hidden; text-overflow: ellipsis; }
.gap-detail-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ---------- 今日一览（右侧窄栏） ---------- */
/* 渠道 chip：原来只挂在 .ov-glance 和项目卡片下，总览页换成窄栏后就没有样式兜底了 */
.overview-view .ov-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.overview-view .ov-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
}
.overview-view .ov-chip .mc-icon { width: var(--ico-xs); height: var(--ico-xs); }
.overview-view .ov-chip-logo { width: 13px; height: 13px; object-fit: contain; flex-shrink: 0; }
.overview-view .ov-chip-logo.broken { display: none; }
.overview-view .ov-chip-logo:not(.broken) ~ .ov-chip-fallback { display: none; }

.ov-note-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-3); }
.ov-note-stats > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}
.ov-note-stats span { color: var(--text-3); }
.ov-note-stats b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-weight: 600;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .ov-value-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-value-hero + .ov-value-mini, .ov-value-mini { padding-left: 0; border-left: none; }
  .ov-kb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-kb-cell:nth-child(3) { border-left: none; }
  .ov-kb-cell:nth-child(n + 3) { border-top: 1px solid var(--border-1); }
}
@media (max-width: 1080px) {
  .ov-charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .ov-value-grid, .ov-kb-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-kb-cell { border-left: none; }
  .ov-kb-cell + .ov-kb-cell { border-top: 1px solid var(--border-1); }
  .ov-gap-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .ov-gap-proj { display: none; }
  .overview-view .ov-range { margin-left: 0; }
}

/* ---------- 响应式收口 ---------- */

@media (max-width: 1080px) {
  .ov-main { grid-template-columns: minmax(0, 1fr); }
  .ov-note { display: none; }
  .aw-body { grid-template-columns: minmax(0, 1fr); }
  .aw-chat { border-right: none; border-bottom: 1px solid var(--border-1); }
}
@media (max-width: 900px) {
  .ov-recent-item { grid-template-columns: 8px minmax(0, 1fr) auto; }
  .ov-recent-proj, .ov-recent-preview { display: none; }
.mcp-row { flex-direction: column; gap: var(--sp-2); }
.mcp-ops { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  /* 窄屏下三簇各占一行，竖线失去「分隔同一行」的意义，去掉只留间距 */
  .settings-tabs { gap: var(--sp-2) 0; }
  .settings-group { width: 100%; }
  .settings-group + .settings-group {
    padding-left: 0;
    border-left: none;
    padding-top: var(--sp-2);
  }
}
@media (max-width: 720px) {
  .empty-state-tips { max-width: none; }

}

@media (prefers-reduced-motion: reduce) {

  .aw-backdrop, .aw-card { animation: none; }
.ov-recent-item, .settings-onboard-link { transition: none; }
}

/* 语义裸标签（如 .btn）不单独定义样式：组件样式交给 .btn-primary /
   .btn-secondary，避免同时挂两个类时打架 */

/* emptyBlock 的正文容器只负责排版 */
.empty-block-body { min-width: 0; }
.empty-block-calm { border-style: solid; border-color: var(--border-1); }

/* ============================================================
   项目弹窗内的「选一个 AI 角色」网格
   网格而不是下拉框：话术方案带角色定位和说明，
   光看名字选不出来，得能一眼比出来。
   每张卡只有一条主动作（「添加到项目」），其余是次级文字按钮 ——
   它们回答的是「加之前想先看看」，不该和主动作抢同一块视觉重量。
   ============================================================ */
.pd-agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.pd-agent-current { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }

.pd-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: var(--sp-3);
}

/* 分段小标题：内置 / 行业模板 / 我改过的。跨满整行 */
.pd-agent-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border-1);
}
.pd-agent-group:first-child { margin-top: 0; }
.pd-agent-group-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-1); }
.pd-agent-group-note  { font-size: var(--fs-xs); color: var(--text-3); }

.pd-agent-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
}
/* 正在用的那张：只描边，不加底色 —— 底色会和主按钮的实心块抢 */
.pd-agent-card.is-current {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.pd-agent-card-head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.pd-agent-card-ico {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-2);
}
.pd-agent-card-titles { min-width: 0; }
.pd-agent-card-titles h4 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pd-agent-card-role { font-size: var(--fs-xs); color: var(--text-3); }

/* 描述压到两行：卡片高度要齐，三行会让下面那排按钮参差不齐 */
.pd-agent-card-desc {
  margin: 0;
  flex: 1 1 auto;
  min-height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-2);
}

.pd-agent-card-primary .btn-primary { width: 100%; }
.pd-agent-card-primary .btn-secondary { width: 100%; }

/* 次级操作：纯文字，挤在一起。视觉重量必须明显低于上面的主按钮 */
.pd-agent-card-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--sp-1);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-1);
}
.pd-agent-card-ops button {
  padding: 2px 6px;
  border: 0;
  border-radius: var(--r-1);
  background: none;
  font: inherit;
  font-size: var(--fs-xs);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-expo), background var(--dur-fast) var(--ease-out-expo);
}
.pd-agent-card-ops button:hover { color: var(--text-1); background: var(--surface-sunken); }
.pd-agent-card-ops button:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; }
.pd-agent-card-ops button.is-danger:hover { color: var(--danger-text); background: var(--danger-soft); }

/* --- 项目级微调：默认折叠在网格下面 --- */
.pd-agent-tweaks-slot { margin-top: var(--sp-5); }

.pd-tweaks {
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
}
.pd-tweaks-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.pd-tweaks-toggle input { accent-color: var(--brand); width: 15px; height: 15px; }
.pd-tweaks-toggle-note { font-size: var(--fs-xs); color: var(--text-3); }

.pd-tweaks-more { margin-top: var(--sp-3); }
.pd-tweaks-more > summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  list-style: revert;
}
.pd-tweaks-more > summary:hover { color: var(--text-1); }

.pd-tweaks-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}
.pd-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.pd-field > span { font-size: var(--fs-xs); color: var(--text-2); }
.pd-field input, .pd-field textarea {
  padding: 7px 9px;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: var(--surface-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  resize: vertical;
}
.pd-field input:focus-visible, .pd-field textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}
.pd-tweaks-ops { display: flex; justify-content: flex-end; grid-column: 1 / -1; }

@media (max-width: 720px) {
  .pd-agent-grid { grid-template-columns: 1fr; }
  .pd-agent-head { align-items: stretch; }
}

/* 外部工具区块：和模型服务商同页，所以从服务商列表下面起一条分隔线 */
.mcp-section {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-1);
}
.mcp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.mcp-section-head h3 { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--text-1); }
.mcp-section-note {
  margin: 0 0 var(--sp-3);
  max-width: 68ch;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-3);
}

/* ============================================================
   AI 角色三个弹窗的重做
   ============================================================ */

/* ---------- ① 看话术：一篇可扫读的文档，不是代码倒模 ---------- */
.rd-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  max-height: calc(100dvh - var(--sp-8));
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: 0 24px 64px -16px oklch(0% 0 0 / 0.55);
  overflow: hidden;
  animation: awUp 240ms var(--ease-out-expo);
}
.rd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border-1);
}
.rd-ident { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.rd-ico {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: 0 0 auto;
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-2);
}
.rd-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: 600; color: var(--text-1); }
.rd-role { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-3); }

/* 一句话定位：这份话术是干什么的（数据来自后端 description，不是编的） */
.rd-summary {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-2);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border-1);
}

/* 章节跳转条：让人先看见「这份话术分几块」，再决定读不读 */
.rd-outline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
}
.rd-outline button {
  padding: 3px 8px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  background: none;
  font: inherit;
  font-size: var(--fs-xs);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-expo), border-color var(--dur-fast) var(--ease-out-expo);
}
.rd-outline button:hover { color: var(--text-1); border-color: var(--border-2); }
.rd-outline button.is-here { color: var(--brand); border-color: var(--brand); }

.rd-doc {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
  scroll-behavior: smooth;
}

.rd-sec + .rd-sec { margin-top: var(--sp-5); }
.rd-h {
  margin: 0 0 var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-1);
}
.rd-body { display: flex; flex-direction: column; }

.rd-p { margin: 0; font-size: var(--fs-sm); line-height: 1.7; color: var(--text-2); }
.rd-gap { height: var(--sp-2); }

.rd-li {
  display: flex;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-2);
}
/* 缩进用左侧发丝线表达层级，不靠数字或额外色块 */
.rd-li-d1 { padding-left: var(--sp-4); border-left: 1px solid var(--border-1); margin-top: 2px; }
.rd-li-d2 { padding-left: var(--sp-4); margin-top: 2px; opacity: 0.88; }
.rd-li-d3 { padding-left: var(--sp-4); opacity: 0.8; }
.rd-num {
  flex: 0 0 auto;
  min-width: 1.3em;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  text-align: right;
}
.rd-bullet {
  flex: 0 0 auto;
  width: 4px; height: 4px;
  margin-top: 0.62em;
  border-radius: 50%;
  background: var(--text-3);
}
.rd-li b, .rd-p b { color: var(--text-1); font-weight: 600; }
/* 话术里的 <kb>、<user_message> 这类标签是契约的一部分，值得被看见 */
.rd-mark { color: var(--brand); }
.rd-doc code {
  padding: 1px 4px;
  border-radius: var(--r-1);
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-1);
}

.rd-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-1);
  background: var(--surface-1);
}
.rd-stat {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

/* ---------- ② Agent 运行时设置 ---------- */
.rt-card { max-width: 760px; }
/* Agent 设置是一整页：模型 / 能力 / 自动回复 / 数据源 / 知识库 / 试运行都在里面，
   比原来的窄卡宽一倍，并固定高度让内容自己滚，切 tab 时页头页脚不动。 */
.rt-page { width: min(1120px, calc(100vw - 48px)); max-width: min(1120px, calc(100vw - 48px)); height: min(88dvh, 900px); max-height: calc(100dvh - 48px); }
.rt-loading { padding: var(--sp-2) 0; }
.project-basic-card { width: min(720px, calc(100vw - 48px)); max-width: min(720px, calc(100vw - 48px)); }
.channel-role-card { width: min(560px, calc(100vw - 48px)); }
.channel-role-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.channel-role-option { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; }
.channel-role-option:hover { border-color: var(--border-strong, var(--border)); }
.channel-role-option.is-selected { border-color: var(--brand); background: oklch(from var(--brand) l c h / 0.07); }
.channel-role-option input { margin-top: 3px; flex-shrink: 0; }
.channel-role-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.channel-role-main .muted { font-size: var(--fs-xs); }
.rt-tabs {
  display: flex;
  gap: 2px;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border-1);
}
.rt-tab {
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out-expo), border-color var(--dur-fast) var(--ease-out-expo);
}
.rt-tab:hover { color: var(--text-1); }
.rt-tab.is-active { color: var(--text-1); border-bottom-color: var(--brand); }
.rt-panes { overflow-y: auto; }
.rt-pane { display: none; padding: var(--sp-4); flex-direction: column; gap: var(--sp-5); }
.rt-pane.is-active { display: flex; }

/* 创建时留下的需求：低频，放最后并且默认收起 */
.rt-brief {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sunken);
  border-radius: var(--r-2);
  font-size: var(--fs-xs);
}
.rt-brief summary { cursor: pointer; color: var(--text-2); }
.rt-brief p {
  margin: var(--sp-2) 0 0;
  color: var(--text-3);
  line-height: 1.7;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .rd-doc { padding: var(--sp-3) var(--sp-4); }
  .rt-tabs { overflow-x: auto; }

}

/* Existing content remains visible during an authorized settings refresh. */
[data-config-content][aria-busy="true"]::before {
  content: '正在刷新…'; display: block; color: var(--text-3); font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}
.shortcuts-content { white-space: normal; }
.shortcuts-content section + section { margin-top: var(--sp-5); }
.shortcuts-content h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border-1); }
.shortcut-row > span:first-child { min-width: 0; }
.shortcut-keys { display: inline-flex; gap: 5px; flex-shrink: 0; }
.shortcut-keys kbd { font-family: var(--font-mono); font-size: var(--fs-xs); min-width: 28px; padding: 3px 7px; text-align: center; background: var(--surface-2); border: 1px solid var(--border-1); border-bottom-width: 2px; border-radius: var(--r-1); color: var(--text-1); }
@media (max-width: 480px) { .shortcut-row { gap: var(--sp-2); font-size: var(--fs-xs); } }

/* Project master-detail workspace; reuse the console's existing tokens. */
.project-workspace { display: grid; grid-template-columns: minmax(190px, 240px) minmax(0, 1fr); min-height: 560px; gap: var(--sp-6); }
.project-rail { border-right: 1px solid var(--border-1); padding-right: var(--sp-4); min-width: 0; }
.project-rail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding-bottom: var(--sp-4); }
.project-rail-items { display: flex; flex-direction: column; gap: var(--sp-1); }
.project-rail-item { display: flex; flex-direction: column; gap: var(--sp-1); width: 100%; padding: var(--sp-3); text-align: left; border: 0; border-radius: var(--r-1); background: transparent; color: var(--text-1); cursor: pointer; }
.project-rail-item:hover { background: var(--surface-1); }
.project-rail-item.is-active { background: oklch(from var(--brand) l c h / 0.10); box-shadow: inset 2px 0 var(--brand); }
.project-rail-name { font-weight: 600; overflow-wrap: anywhere; }
.project-rail-meta { color: var(--text-3); font-size: var(--fs-xs); }
.project-detail-panel { min-width: 0; margin: 0; }
.project-workspace-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.project-workspace-head h2 { margin: 0 0 var(--sp-2); font-family: var(--font-display); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.project-workspace-head-actions { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.pd-agent-note { margin: var(--sp-2) 0 0; max-width: 64ch; font-size: var(--fs-xs); }
.project-workspace-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-5); border-bottom: 1px solid var(--border-1); margin: var(--sp-3) 0 var(--sp-5); }
.project-workspace-tab { padding: var(--sp-3) 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.project-workspace-tab.is-active { color: var(--brand-text); border-bottom-color: var(--brand); font-weight: 600; }
.project-rail-item:focus-visible, .project-workspace-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.project-workspace-content { min-width: 0; }
.project-channel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.project-channel-head h3 { margin: 0 0 var(--sp-2); }
.project-channel-list { border-top: 1px solid var(--border-1); }
.project-channel-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border-1); }
.project-channel-summary { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: var(--sp-1); overflow-wrap: anywhere; }
.project-channel-summary span, .project-channel-summary small { color: var(--text-3); font-size: var(--fs-xs); }
.project-channel-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.project-channel-empty { padding: var(--sp-6) 0; }
@media (max-width: 900px) {
  .project-workspace { grid-template-columns: minmax(150px, 180px) minmax(0, 1fr); gap: var(--sp-4); }
  .project-workspace-tabs { gap: var(--sp-3); }
}
@media (max-width: 640px) {
  .project-workspace { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .project-rail { border-right: 0; border-bottom: 1px solid var(--border-1); padding: 0 0 var(--sp-3); }
  .project-rail-items { max-height: 180px; overflow-y: auto; }
  .project-channel-head { flex-wrap: wrap; }
}

.cw-type-card { font: inherit; text-align: left; color: var(--text-1); }

/* Project AI data sources, channel state links, and identity settings. */
.identity-settings,
.project-mcp-section { max-width: 920px; }
.identity-settings-head,
.project-mcp-heading,
.channel-external-state-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.identity-settings-head h3,
.project-mcp-heading h3,
.channel-external-state h4 { margin: 0 0 var(--sp-2); }
.identity-project-picker { display: grid; grid-template-columns: 110px minmax(0, 360px); align-items: center; gap: var(--sp-3); margin: var(--sp-5) 0; }
.identity-project-picker label,
.identity-checkbox { color: var(--text-2); font-size: var(--fs-sm); }
.identity-provider-list { border-top: 1px solid var(--border-1); }
.identity-provider { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border-1); }
.identity-provider-summary { min-width: 0; flex: 1; }
.identity-provider-title { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.identity-provider-summary p { margin: var(--sp-1) 0 0; }
.identity-provider-login { margin-top: var(--sp-3); font-size: var(--fs-xs); }
.identity-provider-login summary { width: fit-content; cursor: pointer; color: var(--text-2); }
.identity-login-row { display: flex; align-items: flex-start; gap: var(--sp-2); margin-top: var(--sp-2); }
.identity-login-row code { min-width: 0; flex: 1; padding: var(--sp-2); background: var(--surface-sunken); color: var(--text-1); overflow-wrap: anywhere; user-select: text; }
.identity-provider-form { display: grid; gap: var(--sp-4); margin-top: var(--sp-5); padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-1); }
.identity-provider-form h4 { margin: 0; font-size: var(--fs-md); }
.identity-provider-form fieldset { display: grid; gap: var(--sp-3); min-width: 0; padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); }
.identity-provider-form legend { padding: 0 var(--sp-2); color: var(--text-1); font-weight: 600; }
.identity-provider-form .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.identity-checkbox { display: flex; align-items: center; gap: var(--sp-2); }
.identity-user-mapping { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.identity-form-error,
.identity-error { color: var(--danger-text); margin: 0; }
.identity-empty { padding: var(--sp-6) 0; }
[data-identity-secret]:not([hidden]) { display: grid; gap: var(--sp-2); margin-top: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-1); }
.identity-secret-row { display: flex; align-items: center; gap: var(--sp-2); }
.identity-secret-row input { min-width: 0; flex: 1; font-family: var(--font-mono); }

.project-mcp-section { display: grid; gap: var(--sp-4); }
.project-mcp-heading { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border-1); }
.project-mcp-list { display: grid; gap: var(--sp-4); }
.project-mcp-empty { padding: var(--sp-5); border: 1px dashed var(--border-1); border-radius: var(--r-2); background: var(--surface-sunken); }
.project-mcp-source { display: grid; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-1); }
.project-mcp-source-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.project-mcp-source-title { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.project-mcp-source-meta { margin: var(--sp-1) 0 0; color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.project-mcp-source-meta code { color: var(--text-2); overflow-wrap: anywhere; }
.project-mcp-toolset { padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.project-mcp-toolset-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.project-mcp-toolset-head p { margin: var(--sp-1) 0 0; }
.project-mcp-count { flex-shrink: 0; color: var(--text-2); font-family: var(--font-mono); font-size: var(--fs-xs); }
.project-mcp-tools { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.project-mcp-tool-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 150px) auto; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.project-mcp-tool-check,
.project-mcp-edit-tool label { display: flex; align-items: flex-start; gap: var(--sp-2); min-width: 0; }
.project-mcp-tool-check span,
.project-mcp-edit-tool label span { display: grid; gap: 2px; min-width: 0; }
.project-mcp-tool-check small,
.project-mcp-edit-tool small { color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.project-mcp-tool-check code,
.project-mcp-edit-tool code { color: var(--text-2); }
.project-mcp-tool-risk { min-width: 0; }
.project-mcp-callout { grid-column: 1 / -1; min-width: 0; }
.project-mcp-context { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); font-size: var(--fs-sm); }
.project-mcp-context span { color: var(--text-2); overflow-wrap: anywhere; }
.project-mcp-private-note { margin: 0; color: var(--text-3); font-size: var(--fs-xs); }
.project-mcp-editor { padding-top: var(--sp-2); }
.project-mcp-editor h4 { margin: 0 0 var(--sp-2); }
.project-mcp-editor-form { display: grid; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-sunken); }
.project-mcp-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-3); }
.project-mcp-editor-grid .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.project-mcp-enabled { display: flex; align-items: center; gap: var(--sp-2); grid-column: 1 / -1; }
.project-mcp-edit-tools { display: grid; gap: var(--sp-2); }
.project-mcp-edit-tools-head { display: flex; justify-content: space-between; gap: var(--sp-2); }
.project-mcp-edit-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 150px); align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; border-top: 1px solid var(--border-1); }
.project-mcp-context-form { display: grid; gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.project-mcp-context-form .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.project-mcp-context-form textarea { resize: vertical; }
.project-mcp-legacy { display: grid; gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border-1); }
.project-mcp-legacy-head h4 { margin: 0; }
.project-mcp-legacy-list { display: grid; gap: var(--sp-2); }
.project-mcp-legacy-source { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-sunken); }
.project-mcp-legacy-source > div { min-width: 0; }
.project-mcp-legacy-source strong { margin-right: var(--sp-2); }
.project-mcp-legacy-source .project-mcp-source-meta { margin: var(--sp-1) 0 0; }
.project-mcp-legacy-editor { padding-top: var(--sp-3); }
.project-mcp-legacy-editor h4 { margin: 0 0 var(--sp-2); }
.project-mcp-form-error,
.project-mcp-call-error { margin: 0; color: var(--danger-text); }
.project-mcp-secret-row { display: flex; align-items: center; gap: var(--sp-2); }
.project-mcp-secret-row code { min-width: 0; flex: 1; padding: var(--sp-2); background: var(--surface-sunken); overflow-wrap: anywhere; user-select: text; }
.project-mcp-call-form { display: grid; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-sunken); }
.project-mcp-call-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.project-mcp-call-fields { display: grid; gap: var(--sp-3); }
.project-mcp-call-field { display: grid; gap: var(--sp-1); }
.project-mcp-call-field > label { display: grid; gap: var(--sp-1); }
.project-mcp-call-check { display: flex; align-items: center; gap: var(--sp-2); }
.project-mcp-call-check > label { display: flex; align-items: center; gap: var(--sp-2); }
.project-mcp-call-include { display: flex; align-items: center; gap: var(--sp-1); color: var(--text-3); font-size: var(--fs-xs); }
.project-mcp-call-object,
.project-mcp-call-array { display: grid; gap: var(--sp-2); min-width: 0; padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-1); }
.project-mcp-call-object legend,
.project-mcp-call-array legend { padding: 0 var(--sp-1); color: var(--text-1); font-weight: 600; }
.project-mcp-call-array-rows { display: grid; gap: var(--sp-2); }
.project-mcp-call-array-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); padding: var(--sp-2); border: 1px solid var(--border-1); border-radius: var(--r-1); background: var(--surface-1); }
.project-mcp-call-array-fields { display: grid; gap: var(--sp-2); min-width: 0; }
.project-mcp-call-array-empty { margin: 0; color: var(--text-3); font-size: var(--fs-xs); }
.project-mcp-call-help { color: var(--text-3); line-height: 1.5; }
.project-mcp-call-request { margin: 0; color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.project-mcp-call-result { min-width: 0; padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.project-mcp-call-result-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.project-mcp-call-result pre { max-height: 360px; margin: 0; padding: var(--sp-3); overflow: auto; border-radius: var(--r-1); background: var(--surface-1); color: var(--text-1); font: var(--fs-xs)/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.project-mcp-result-table-wrap { max-width: 100%; overflow-x: auto; }
.project-mcp-result-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.project-mcp-result-table th, .project-mcp-result-table td { padding: var(--sp-2); border: 1px solid var(--border-1); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.project-mcp-result-table th { color: var(--text-2); background: var(--surface-sunken); font-weight: 600; }
.project-mcp-result-list { display: grid; grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr); gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); }
.project-mcp-result-list dt { color: var(--text-2); }
.project-mcp-result-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.project-mcp-result-object { padding: var(--sp-2) 0; }
.project-mcp-result-array { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.project-mcp-result-array-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-2); min-width: 0; padding: var(--sp-2); border-left: 2px solid var(--border-1); background: var(--surface-sunken); }
.project-mcp-result-array-index { color: var(--text-3); font: var(--fs-xs)/1.5 var(--font-mono); white-space: nowrap; }
.project-mcp-result-array-item > .project-mcp-result-list,
.project-mcp-result-array-item > .project-mcp-result-array { grid-column: 1 / -1; }
.project-mcp-result-scalar { overflow-wrap: anywhere; }
.project-mcp-result-collapsed, .project-mcp-result-more { color: var(--text-3); font-size: var(--fs-xs); }
.project-mcp-result-more { margin: var(--sp-2) 0 0; }
.project-mcp-result-more-label { color: var(--text-3); }
.project-mcp-result-extra { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.project-mcp-result-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.project-mcp-result-raw { margin-top: var(--sp-3); font-size: var(--fs-xs); }
.project-mcp-result-raw summary { cursor: pointer; color: var(--text-3); }
.project-mcp-call-unknown { display: grid; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--warning, #d99a23); border-radius: var(--r-1); background: color-mix(in srgb, var(--warning, #d99a23) 10%, transparent); }
.project-mcp-call-unknown p { margin: 0; color: var(--text-2); font-size: var(--fs-sm); }
.project-mcp-call-unknown code { overflow-wrap: anywhere; }

.channel-external-state { display: grid; gap: var(--sp-3); margin-top: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2); background: var(--surface-sunken); }
.channel-external-state-head h4 { font-size: var(--fs-md); }
.channel-external-state-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--sp-2); }
.channel-external-state-controls .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.channel-external-state-status { margin: 0; color: var(--text-2); font-size: var(--fs-sm); }
.channel-external-connection { display: grid; gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.channel-external-connection summary { cursor: pointer; color: var(--text-1); font-weight: 600; }
.channel-external-connection-list { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); }
.channel-external-connection-list dt { color: var(--text-2); }
.channel-external-connection-list dd { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; margin: 0; }
.channel-external-connection-list code { min-width: 0; overflow-wrap: anywhere; color: var(--text-1); }
.channel-external-connection-list .btn-secondary { flex-shrink: 0; }
.channel-external-rotate-form { display: grid; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--r-1); background: var(--surface-1); }
.channel-external-rotate-form .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.channel-external-rotate-error { margin: 0; color: var(--danger-text); }
.channel-external-state-new { display: grid; gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.channel-external-state [hidden] { display: none !important; }
.channel-external-state-new .form-group { display: grid; gap: var(--sp-1); margin: 0; }
.channel-external-state-error { margin: 0; color: var(--danger-text); }
.channel-external-secret { display: grid; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--border-1); }
.channel-external-secret > div { display: flex; align-items: center; gap: var(--sp-2); }
.channel-external-secret input { min-width: 0; flex: 1; font-family: var(--font-mono); }

@media (max-width: 720px) {
  .identity-settings-head, .project-mcp-heading, .channel-external-state-head, .identity-provider, .project-mcp-source-head { align-items: stretch; flex-direction: column; }
  .identity-project-picker { grid-template-columns: 1fr; gap: var(--sp-1); }
  .identity-provider .btn-row, .project-mcp-source-head .btn-row { align-self: flex-start; }
  .identity-user-mapping { grid-template-columns: 1fr; align-items: stretch; }
  .identity-secret-row, .project-mcp-secret-row, .channel-external-secret > div { align-items: stretch; flex-wrap: wrap; }
  .identity-secret-row input, .channel-external-secret input { flex-basis: 100%; }
  .project-mcp-editor-grid { grid-template-columns: 1fr; }
  .project-mcp-legacy-source { align-items: stretch; flex-direction: column; }
  .project-mcp-legacy-source .btn-secondary { align-self: flex-start; }
  .project-mcp-tool-row { grid-template-columns: minmax(0, 1fr) auto; }
  .project-mcp-tool-row .project-mcp-tool-risk { grid-column: 1; }
  .project-mcp-tool-row [data-mcp-call] { grid-column: 2; grid-row: 2; }
  .project-mcp-context { grid-template-columns: 1fr; }
  .project-mcp-call-array-row { grid-template-columns: 1fr; }
  .project-mcp-result-list { grid-template-columns: 1fr; gap: var(--sp-1); }
  .channel-external-state-controls { grid-template-columns: 1fr; align-items: stretch; }
  .channel-external-connection-list { grid-template-columns: 1fr; gap: var(--sp-1); }
  .channel-external-connection-list dd { margin-bottom: var(--sp-2); }
}

/* 会话内联审批 + 出站消息的投递状态（顶栏「待审批」按钮已随弹窗一起下线） */
.inline-approvals { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
.inline-approvals-floating { display: flex; flex-direction: column; gap: var(--sp-2); margin: var(--sp-3) 0 0; }
.inline-approvals-floating[hidden] { display: none; }
.apv-row.inline-approval { max-width: 100%; }
.apv-inline-status { margin-top: var(--sp-2); }
.apv-row.inline-approval.is-highlighted { animation: inline-approval-pulse 2.4s ease-out; }
@keyframes inline-approval-pulse {
  0%, 55% { box-shadow: 0 0 0 2px var(--warning); }
  100% { box-shadow: none; }
}

.message-delivery {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3);
}
.message-delivery-label.delivery-failed_retry,
.message-delivery-label.delivery-failed_dead { color: var(--danger); }
.message-delivery-error {
  opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}
.msg-delivery-retry {
  border: 1px solid currentColor; border-radius: var(--sp-1);
  padding: 1px var(--sp-2); font-size: var(--fs-xs); cursor: pointer;
  background: transparent; color: inherit;
}
.msg-delivery-retry:disabled { opacity: 0.55; cursor: not-allowed; }
.msg-delivery-retry:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .apv-row.inline-approval.is-highlighted { animation: none; box-shadow: 0 0 0 2px var(--warning); }
}

/* 出站气泡是反色的，投递行也要跟着反色，否则会看不清 */
.message.outbound .message-delivery { color: oklch(from var(--text-inverse) l c h / 0.7); }
.message.outbound .message-delivery-label.delivery-failed_retry,
.message.outbound .message-delivery-label.delivery-failed_dead { color: oklch(from var(--danger) l c h / 0.9); }
.message.outbound .msg-delivery-retry { color: inherit; border-color: oklch(from var(--text-inverse) l c h / 0.5); }

.session-details { white-space: normal; overflow-wrap: anywhere; }
/* 会话 ID：等宽 + 一节复制按钮，方便直接拿去查日志 */
.session-details .session-id-value {
  margin-inline: var(--sp-1) var(--sp-2);
  padding: 1px 6px;
  border-radius: var(--r-1);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
  user-select: all;
}
.session-details p + p { margin-top: var(--sp-3); }

/* 侧栏展开只认「指针是否还在这条栏里」。
   旧写法把整条栏设成 pointer-events:none、只给子元素恢复，于是指针落在
   导航项之间的空隙、内边距或底部空白时 :hover 立刻失效 —— 栏就自己收起来了。
   现在整栏都接收指针事件：栏宽 48px 时正好落在 .app-body 的 padding-left 里，
   不遮挡内容；展开覆盖内容时指针本来就在栏上，遮挡是预期行为。 */
@media (min-width: 721px) {
  .ocp-sidebar { pointer-events: auto; }
}

/* Compact screens keep the same rhythm, with larger controls for touch. */
@media (max-width: 720px) {
  :root { --ctl-h: var(--ctl-h-touch); }
  .login-card input, .composer-textarea,
  .app-dialog-input, .app-dialog-select, .app-dialog-textarea,
  .channel-setup-field input, .channel-setup-field select { font-size: max(var(--fs-base), 1rem); }
  .login-view { padding: var(--sp-5) var(--sp-4); }
  .login-card { padding: var(--sp-7) var(--sp-5) var(--sp-5); }
  .login-header { margin-bottom: var(--sp-5); }
  .page-view, #project-overview { padding: var(--sp-4); }
  .app-header { height: 60px; padding-inline: var(--sp-3); gap: var(--sp-2); }
  .header-actions { gap: var(--sp-1); }
  .icon-btn, .close-btn, .chip-trigger-icon { width: var(--ctl-h-touch); height: var(--ctl-h-touch); }
  .user-trigger { min-height: var(--ctl-h-touch); padding-inline: var(--sp-1); }
  .ocp-sidebar-top { flex: 1 1 0; min-width: 0; height: 52px; }
  .ocp-sidebar .ocp-project-select,
  .ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .ocp-project-select { display: block; width: 100%; min-width: 0; opacity: 1; pointer-events: auto; }
  .ocp-sidebar .ocp-nav,
  .ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .ocp-nav { flex: 0 0 auto; padding: var(--sp-1); }
  .ocp-sidebar .nav-item,
  .ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .nav-item { width: var(--ctl-h-touch); min-height: var(--ctl-h-touch); padding: var(--sp-2); }
  .ocp-sidebar .ocp-avatar { width: var(--ctl-h-touch); height: var(--ctl-h-touch); }
  .ocp-sidebar .ocp-sidebar-bottom,
  .ocp-sidebar:not(:hover):not(:has(:focus-visible, .ocp-project-select:focus)) .ocp-sidebar-bottom { padding: var(--sp-1); }
  :root { --wb-pane-head-h: 56px; --wb-pane-foot-h: 88px; }
  .session-list-header { padding-inline: var(--sp-3); }
  .session-selection-toggle, .session-batch-actions button { min-height: var(--ctl-h-touch); }
  .session-row-action { width: var(--ctl-h-touch); min-width: var(--ctl-h-touch); }
  .conv-header { padding: 0 var(--sp-3); column-gap: var(--sp-2); height: auto; }
  .conv-header .user-name { max-width: 100%; }
  .conv-header .user-meta { flex-wrap: wrap; gap: var(--sp-1); }
  .conv-header .meta-line { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .conv-actions { max-width: 130px; }
  .conv-actions .btn-secondary { padding-inline: var(--sp-2); }
  .message-stream { padding: var(--sp-3); }
  .message { max-width: 92%; }
  .composer { padding: var(--sp-2) var(--sp-3); }
  .composer-line { padding-inline: 6px; }
  .composer-attachments { padding-inline: 0; }
  .composer-meter { margin-inline: 0; }
  /* 触屏上输入组件的左右控件保持 44px 命中区；桌面密度仍是 34px */
  .composer-submit, .msg-translate-btn, .chat-action, .copy-id-btn,
  .toggle-status-btn, .email-detail-btn { min-height: var(--ctl-h-touch); }
  .composer-attach { width: var(--ctl-h-touch); min-width: var(--ctl-h-touch); min-height: var(--ctl-h-touch); }
  .composer-tools-menu { left: calc(-1 * var(--sp-1)); }
  .draft-bubble { max-width: 88%; }
  .empty-state { padding: var(--sp-4); justify-content: safe center; }
  .empty-icon { width: 56px; height: 56px; margin-bottom: var(--sp-3); }
  .empty-icon .mc-icon { width: var(--ico-xl); height: var(--ico-xl); }
  .empty-state-tips { margin-top: var(--sp-3); padding-top: var(--sp-3); }
  .empty-state-actions { flex-wrap: wrap; }
  .modal, .app-dialog, .aw-backdrop { padding: var(--sp-3); }
  .modal-header, .app-dialog-head, .aw-head { padding: var(--sp-3) var(--sp-4); }
  .modal-body, .app-dialog-body { padding: var(--sp-4); }
  .app-dialog-foot { padding: var(--sp-3) var(--sp-4); gap: var(--sp-2); }
  .app-dialog-card, .aw-card, .rd-card,
  .app-dialog-card.kb-manager-card, .app-dialog-card.kb-import-card { max-height: calc(100dvh - var(--sp-6)); }
  .ar-input { height: auto; min-height: var(--ctl-h-touch); padding-block: var(--sp-2); }
  .pd-tweaks-fields { grid-template-columns: minmax(0, 1fr); }
  .channel-types, .channel-setup-display-grid { grid-template-columns: minmax(0, 1fr); }
  .project-workspace-head { flex-wrap: wrap; }
  .notify-banner {
    position: relative;
    inset: auto;
    transform: none;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-1) var(--sp-2);
    width: auto;
    max-width: none;
    margin: var(--sp-2) var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    animation: none;
    z-index: auto;
  }
  .notify-banner-ico { grid-column: 1; grid-row: 1; }
  .notify-banner-text { grid-column: 2; grid-row: 1; }
  .notify-banner > button:not(.close-btn) { grid-column: 2; grid-row: 2; justify-self: start; min-height: var(--ctl-h-touch); }
  .notify-banner > .close-btn { grid-column: 3; grid-row: 1 / 3; min-height: var(--ctl-h-touch); }
}

@media (max-width: 480px) {
  /* 极窄屏会话头改成两行，固定高度会裁掉第二行；这条是唯一例外。 */
  .conv-header { grid-template-columns: auto minmax(0, 1fr); height: auto; min-height: var(--wb-pane-head-h); padding-block: var(--sp-2); }
  .conv-actions { grid-column: 1 / -1; max-width: none; width: 100%; margin-top: var(--sp-2); justify-content: space-between; }
  .settings-view .settings-tabs .tab-btn { padding-inline: var(--sp-3); }
}

@media (hover: none) {
  .mc-attach-thumb .remove { opacity: 1; transform: scale(1); width: 20px; height: 20px; }
  .mc-attach-name { opacity: 0.92; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .app-logo, .brand-logo, .icon-btn, .btn-primary, .btn-secondary,
  .ocp-sidebar, .nav-label, .chip-trigger { transition: none; }
  .notify-banner, .ai-pulse, .message, .draft-bubble, .modal, .modal-content,
  .app-dialog, .app-dialog-card { animation: none; }
}

/* 语言切换（登录前后都可用的右下角小按钮） */
/* 语言切换：工作台里在顶栏、个人头像左边；登录页没有顶栏，用右下角浮层兜底 */
.app-lang-toggle{
  display:inline-flex;align-items:center;justify-content:center;height:30px;min-width:40px;padding:0 10px;
  border-radius:var(--r-pill);border:1px solid var(--border-1);background:var(--surface-sunken);
  color:var(--text-2);font-size:var(--fs-xs);font-family:var(--font-mono);letter-spacing:.06em;
  cursor:pointer;transition:background var(--dur-fast) var(--ease-out-quart),color var(--dur-fast) var(--ease-out-quart),border-color var(--dur-fast) var(--ease-out-quart);
}
.app-lang-toggle:hover{background:var(--surface-2);color:var(--text-1);border-color:var(--border-2)}
.app-lang-toggle:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.header-actions .app-lang-toggle{margin-right:var(--sp-1)}
.app-lang-toggle-float{
  position:fixed;right:16px;bottom:16px;z-index:9999;height:34px;background:var(--surface-1);
  box-shadow:var(--shadow-2);
}

/* 个人菜单触发器：只留头像，名字/角色/邮箱放进展开后的卡片 */
/* 触发器只留头像（规则见上方 .user-trigger 基础样式） */
.user-dropdown .dropdown-header{display:flex;align-items:center;gap:var(--sp-3);text-align:left}
.user-avatar-lg{width:38px;height:38px;font-size:15px;flex-shrink:0}
.user-card-text{min-width:0;display:flex;flex-direction:column;gap:2px}
.user-card-email{font-size:var(--fs-xs);color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:210px}

/* 搜索框聚焦只保留外圈一道环：input 自身的焦点环由组件外框代替 */
.header-search input:focus,
.header-search input:focus-visible{outline:none;box-shadow:none}

/* 数据与留存（设置内） */
.data-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--sp-4);margin-bottom:var(--sp-3)}
.data-card-head h2{margin:0}
.data-audit-table{width:100%;border-collapse:collapse;font-size:var(--fs-sm)}
.data-audit-table th{text-align:left;font-weight:600;color:var(--text-3);font-size:var(--fs-xs);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border-1);white-space:nowrap}
.data-audit-table td{padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border-1);vertical-align:top}
.data-audit-table tr:last-child td{border-bottom:none}
.data-danger-card{border-color:color-mix(in oklab, var(--danger) 35%, var(--border-1))}
.data-danger-card h2{color:var(--danger-text)}

/* 权限不足时的说明块：说清原因和找谁，而不是留一个点了会 403 的按钮 */
.no-permission{padding:var(--sp-6);max-width:560px}
.no-permission h3{margin:0 0 var(--sp-2)}
.no-permission p{margin:0;color:var(--text-2);line-height:1.6}

/* ============ 个人设置（头像菜单） ============ */
.user-trigger-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface-1);
  pointer-events: none;
}
.user-trigger { position: relative; }
.notify-settings { min-width: 300px; }
.notify-settings .notify-row:first-child { padding-top: 0; }

.settings-scope {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: var(--r-1);
  padding: 2px 8px;
  margin-left: var(--sp-2);
  vertical-align: middle;
}

.profile-card { min-width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--sp-5); }

/* ---------- 紧凑按钮：弹窗内联操作用，比常规按钮矮一档 ---------- */
.btn-compact { min-height: calc(var(--ctl-h) - 8px); padding: 0 var(--sp-3); font-size: var(--fs-xs); }
/* 幽灵按钮：视觉权重最低的一档，只做「移除」「重试」这类次要动作 */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: var(--ctl-h);
  padding: 0 var(--sp-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  font-family: inherit;
  font-weight: 500;
  font-size: var(--fs-sm);
  line-height: 1;
  white-space: nowrap;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-quart),
              color var(--dur-fast) var(--ease-out-quart);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text-1); }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 个人资料：头图区 ---------- */
.profile-hero {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
}
/* 头像块本身就是上传入口：整块可点，悬停浮出相机遮罩 */
.profile-avatar-block {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  cursor: pointer;
  isolation: isolate;
}
.profile-avatar.user-avatar {
  width: 72px;
  height: 72px;
  font-size: 26px;
  box-shadow: 0 0 0 1px var(--border-1), 0 2px 10px oklch(from var(--shadow-ink, black) l c h / 0.08);
}
.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: oklch(from black l c h / 0.52);
  color: #fff;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out-quart);
  pointer-events: none;
}
.profile-avatar-overlay .mc-icon { width: 22px; height: 22px; }
.profile-avatar-block:hover .profile-avatar-overlay,
.profile-avatar-block:focus-within .profile-avatar-overlay,
.profile-avatar-block[data-busy='true'] .profile-avatar-overlay { opacity: 1; }
.profile-avatar-block[data-busy='true'] { cursor: progress; }

.profile-hero-text { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.profile-hero-name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-1);
  overflow-wrap: anywhere;
}
.profile-role-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-1);
  background: oklch(from var(--brand) l c h / 0.12);
  color: var(--brand-text);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.profile-avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.profile-avatar-hint { font-size: var(--fs-xs); color: var(--text-3); }
.profile-avatar-status { font-size: var(--fs-xs); color: var(--text-2); min-height: 1.2em; }
.profile-avatar-status[data-tone='error'] { color: var(--danger-text); }
.profile-avatar-status[data-tone='ok'] { color: var(--success-text, var(--brand-text)); }

/* ---------- 个人资料：分节 ---------- */
.profile-section { display: flex; flex-direction: column; gap: var(--sp-2); }
.profile-section-title {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.profile-section-desc { margin: 0; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.55; }
.profile-name-field { display: flex; gap: var(--sp-2); }
.profile-name-field input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--ctl-h);
  padding: 0 var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-1);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out-quart);
}
.profile-name-field input:focus { border-color: var(--brand); background: var(--surface-1); }
.profile-name-field input[data-invalid='true'] { border-color: var(--danger); }
.profile-name-error { font-size: var(--fs-xs); color: var(--danger-text); min-height: 1.2em; }

.profile-facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.profile-facts dt { color: var(--text-3); font-size: var(--fs-xs); }
.profile-facts dd { margin: 0; font-size: var(--fs-sm); color: var(--text-1); overflow-wrap: anywhere; }
.profile-note { font-size: var(--fs-xs); margin: 0; }

/* ---------- 账户安全 ---------- */
.account-security-card { min-width: min(460px, 100%); display: flex; flex-direction: column; gap: var(--sp-4); }
.security-identity { display: flex; align-items: center; gap: var(--sp-3); }
.security-avatar.user-avatar { width: 44px; height: 44px; font-size: 17px; flex: 0 0 auto; }
/* 必须给 flex 子项宽度上限：只写 min-width:0 时它会按内容宽度收缩，
   邮箱被压成一行只有百来像素，换两三行把整块撑高。 */
.security-identity-text { flex: 1 1 auto; min-width: 0; }
/* 弹窗容器统一是 white-space: pre-wrap（给纯文本提示用的），
   放进来的结构化内容必须关掉它——否则模板字符串里的缩进换行会被当成真空行，
   把身份块撑成一倍高。 */
.account-security-card,
.profile-card { white-space: normal; }
.security-identity-name { font-size: var(--fs-md); font-weight: 600; color: var(--text-1); overflow-wrap: anywhere; }
.security-identity-email { font-size: var(--fs-sm); color: var(--text-2); overflow-wrap: anywhere; }
.security-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: var(--surface-sunken);
}
.security-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.security-item-text { min-width: 0; }
.security-item-text h4 { margin: 0 0 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-1); }
.security-item-desc { margin: 0; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.55; }
.security-item-foot { display: flex; align-items: center; gap: var(--sp-2); }
/* 空状态的脚注不占高度：否则「重新读取」藏起来后仍留一条空白带 */
.security-item-foot:not(:has(> :not([hidden]))) { display: none; }
/* 徽标跟在标题后面，和状态文案分开，不抢正文的位置 */
.security-item-text h4 .security-badge { margin-left: 6px; vertical-align: 1px; }
.security-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.security-badge[data-tone='ok'] { background: oklch(from var(--brand) l c h / 0.12); color: var(--brand-text); }
.security-badge[data-tone='error'] { background: var(--danger-soft); color: var(--danger-text); }
.security-badge[hidden] { display: none; }

.pd-agent-card-channels { margin: 6px 0 10px; font-size: var(--fs-xs); color: var(--text-3); }

.project-channel-role { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-3); }

/* 运行时：技能 / 记录 / 数据源 */
.ar-skills { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.ar-skill-row { display: grid; grid-template-columns: minmax(180px, 1fr) 130px minmax(0, 1.2fr); align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); opacity: .72; }
.ar-skill-row.is-on { opacity: 1; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.ar-skill-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ar-skill-mode { width: 100%; }
.ar-kind-groups { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.ar-kind-pack { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px 10px; background: var(--surface); }
.ar-kind-pack > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); padding: 4px 0; }
.ar-kind-pack .ar-tools { margin-top: 6px; }
.ar-recording-schema { align-items: center; }
.ar-custom-kind { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.ar-risk-custom { margin-top: 8px; }

/* 技能库 */
.skill-lib { width: min(880px, 92vw); max-height: 86vh; }
.skill-lib-actions { display: flex; align-items: center; gap: 12px; margin-bottom: var(--sp-3); }
.skill-lib-list { display: flex; flex-direction: column; gap: 8px; }
.skill-lib-row { display: flex; gap: var(--sp-3); justify-content: space-between; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.skill-lib-main { min-width: 0; }
.skill-lib-title { display: flex; align-items: center; gap: 8px; }
.skill-lib-desc { margin: 4px 0 0; color: var(--text-2); font-size: var(--fs-sm); }
.skill-lib-when { margin: 2px 0 0; color: var(--text-3); font-size: var(--fs-xs); }
.skill-lib-meta { margin: 4px 0 0; color: var(--text-3); font-size: var(--fs-xs); }
.skill-lib-ops { display: flex; gap: 6px; flex-shrink: 0; }
.badge.custom { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

@media (max-width: 760px) {
  .ar-skill-row { grid-template-columns: 1fr; }
  .ar-custom-kind { grid-template-columns: 1fr; }
  .skill-lib-row { flex-direction: column; }
}

.ar-kind-others { margin: 8px 0; border: 1px dashed var(--border); border-radius: var(--radius-md); padding: 8px 10px; }
.ar-kind-others > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.ar-kind-others .ar-kind-groups { margin-bottom: 0; }

/* ============ 项目 → 渠道 → AI 角色 三级页面 ============ */
/* 项目页与设置页共用单页布局，但项目页没有设置 tab，内容直接铺满。 */
.projects-view { flex-direction: column; overflow-y: auto; background: var(--surface-0); }

.role-page-head { align-items: center; }
.role-page-title { display: flex; align-items: flex-start; gap: var(--sp-3); min-width: 0; }
.role-page-title h2 { margin: 0 0 var(--sp-1); font-family: var(--font-display); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.role-page-title .muted { margin: 0; font-size: var(--fs-xs); }
.role-back { flex-shrink: 0; margin-top: 2px; }

.role-project-default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--mc-space-3, 12px) var(--mc-space-4, 16px);
  margin-top: var(--mc-space-4, 16px);
  padding: var(--mc-space-3, 12px) var(--mc-space-4, 16px);
  border: 1px solid var(--mc-border-subtle, var(--border-1));
  border-radius: var(--mc-radius-lg, 12px);
  background: var(--mc-bg-subtle, var(--surface-sunken));
}
.role-project-default-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 240px;
}
.role-project-default-copy strong {
  font-size: var(--mc-text-sm, 0.8125rem);
  font-weight: 600;
  color: var(--mc-fg-primary, var(--text-1));
}
.role-project-default-copy span {
  font-size: var(--mc-text-xs, 0.75rem);
  color: var(--mc-fg-muted, var(--text-3));
}
.role-default-select {
  width: auto;
  min-width: 220px;
  max-width: 100%;
  flex: 0 1 280px;
}
.role-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--mc-space-4, 16px);
  margin-top: var(--sp-4);
  align-items: stretch;
}
.role-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-3, 12px);
  height: 100%;
  padding: var(--mc-space-4, 16px);
  border: 1px solid var(--mc-border-subtle, var(--border-1));
  border-radius: var(--mc-radius-lg, 12px);
  background: var(--mc-bg-surface, var(--surface-1));
  box-shadow: var(--mc-shadow-xs), var(--mc-inner-shadow);
  cursor: pointer;
  transition:
    border-color var(--mc-dur-fast, 150ms) var(--mc-ease-out, ease-out),
    box-shadow var(--mc-dur-fast, 150ms) var(--mc-ease-out, ease-out),
    transform var(--mc-dur-fast, 150ms) var(--mc-ease-out, ease-out);
}
.role-choice:hover {
  border-color: var(--mc-border-default, var(--border-1));
  box-shadow: var(--mc-shadow-sm), var(--mc-inner-shadow);
  transform: translateY(-1px);
}
.role-choice-follow {
  background: var(--mc-bg-subtle, var(--surface-sunken));
}
.role-choice.is-current {
  border-color: var(--mc-accent, var(--brand));
  background: var(--mc-accent-soft, oklch(from var(--brand) l c h / 0.06));
  box-shadow: 0 0 0 1px var(--mc-accent-ring, transparent), var(--mc-shadow-sm);
}
.role-choice-check {
  position: absolute;
  top: var(--mc-space-3, 12px);
  right: var(--mc-space-3, 12px);
  width: 22px;
  height: 22px;
  border-radius: var(--mc-radius-full, 9999px);
  display: none;
  place-items: center;
  background: var(--mc-accent, var(--brand));
  color: var(--mc-fg-inverse, #fff);
  box-shadow: var(--mc-shadow-xs);
}
.role-choice.is-current .role-choice-check {
  display: grid;
}
.role-choice.is-current .role-choice-head {
  padding-right: 28px;
}
.role-editor-readonly-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--mc-space-3, 12px);
  padding: var(--mc-space-3, 12px) var(--mc-space-4, 16px);
  margin-bottom: var(--mc-space-4, 16px);
  border: 1px solid var(--mc-border-subtle, var(--border-1));
  border-radius: var(--mc-radius-md, 8px);
  background: var(--mc-bg-subtle, var(--surface-sunken));
  font-size: var(--mc-text-sm, 0.8125rem);
  color: var(--mc-fg-secondary, var(--text-2));
}
.role-choice-head {
  display: flex;
  align-items: flex-start;
  gap: var(--mc-space-3, 12px);
  min-width: 0;
}
.role-choice-ico {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: var(--mc-radius-md, 8px);
  background: var(--mc-bg-subtle, var(--surface-sunken));
  border: 1px solid var(--mc-border-subtle, var(--border-1));
  color: var(--mc-fg-secondary, var(--text-2));
}
.role-choice.is-current .role-choice-ico {
  background: var(--mc-bg-surface, var(--surface-1));
  border-color: var(--mc-accent-ring, var(--border-1));
  color: var(--mc-accent, var(--brand));
}
.role-choice-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-2, 8px);
}
.role-choice-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--mc-space-1, 4px) var(--mc-space-2, 8px);
  padding-top: 2px;
}
.role-choice-title strong {
  color: var(--mc-fg-primary, var(--text-1));
  font-size: var(--mc-text-base, 0.875rem);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.role-choice-role {
  color: var(--mc-fg-muted, var(--text-3));
  font-size: var(--mc-text-xs, 0.75rem);
  padding: 1px 7px;
  border-radius: var(--mc-radius-full, 9999px);
  background: var(--mc-bg-subtle, var(--surface-sunken));
  border: 1px solid var(--mc-border-subtle, var(--border-1));
}
.role-choice-desc {
  margin: 0;
  color: var(--mc-fg-secondary, var(--text-2));
  font-size: var(--mc-text-sm, 0.8125rem);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.role-choice-meta {
  margin-top: auto;
  color: var(--mc-fg-muted, var(--text-3));
  font-size: var(--mc-text-xs, 0.75rem);
  font-variant-numeric: tabular-nums;
}
.role-choice-actions {
  margin-top: auto;
  padding-top: var(--mc-space-3, 12px);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--mc-space-2, 8px);
}
.role-section {
  display: flex;
  flex-direction: column;
  gap: var(--mc-space-3, 12px);
  padding-top: var(--mc-space-4, 16px);
  border-top: 1px solid var(--mc-border-subtle, var(--border-1));
}
.role-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--mc-space-2, 8px);
}
.role-section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-md);
}
.role-section-details {
  padding: var(--mc-space-3, 12px) var(--mc-space-4, 16px);
  border: 1px solid var(--mc-border-subtle, var(--border-1));
  border-radius: var(--mc-radius-lg, 12px);
  background: var(--mc-bg-subtle, var(--surface-sunken));
}
.role-section-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--mc-text-sm, 0.8125rem);
  color: var(--mc-fg-primary, var(--text-1));
}
.role-section-details[open] > summary {
  margin-bottom: var(--mc-space-3, 12px);
}

.role-tabs { display: flex; gap: var(--sp-4); border-bottom: 1px solid var(--border-1); margin: var(--sp-4) 0 var(--sp-4); }
.role-tab {
  padding: var(--sp-2) 0; border: 0; border-bottom: 2px solid transparent;
  background: none; font: inherit; font-size: var(--fs-sm); color: var(--text-3); cursor: pointer;
}
.role-tab:hover { color: var(--text-1); }
.role-tab.is-active { color: var(--text-1); border-bottom-color: var(--brand); }
.role-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.role-editor { display: flex; flex-direction: column; min-width: 0; }
.role-editor-form { display: flex; flex-direction: column; min-width: 0; }
.role-pane { display: none; flex-direction: column; gap: var(--sp-4); }
.role-pane.is-active { display: flex; }
.role-pane-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3); }
.role-pane-head h3 { margin: 0; font-family: var(--font-display); font-size: var(--fs-md); }
.role-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.role-field > span { color: var(--text-2); font-size: var(--fs-xs); }
.role-field .pd-input { width: 100%; }
.role-field-hint { color: var(--text-3); font-size: var(--fs-xs); }
.role-prompt { min-height: 220px; resize: vertical; line-height: 1.7; }
.role-file { max-width: 360px; }

.role-skill-list, .role-mcp-list, .role-kb-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-1); }
.role-skill-row, .role-mcp-row, .role-kb-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--border-1);
}
.role-skill-main, .role-mcp-main, .role-kb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.role-skill-title { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.role-skill-desc, .role-mcp-url { color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.role-skill-mode { width: auto; flex-shrink: 0; }
.role-skill-row:not(.is-on) .role-skill-main { opacity: 0.72; }
.role-toggle { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-2); font-size: var(--fs-sm); }

.role-install {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-2);
  background: var(--surface-sunken);
}
.role-install[hidden] { display: none; }
.role-install-preview { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.role-install-preview span { color: var(--text-3); font-size: var(--fs-xs); }
.role-install-error { margin: 0; color: var(--danger); font-size: var(--fs-xs); }
.role-install-error[hidden] { display: none; }

.role-editor-error { margin: var(--sp-3) 0 0; color: var(--danger); font-size: var(--fs-sm); }
.role-editor-error[hidden] { display: none; }
.role-editor-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border-1);
}
.role-mcp-manage { margin-top: var(--sp-2); }
.role-mcp-manage > summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); }
.role-mcp-manage > .pd-mcp-data-sources-slot { margin-top: var(--sp-4); }

/* 渠道接入自检：把「如何使用」变成可点的检查项。 */
.channel-check-card { max-width: 560px; }
.channel-check-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-1); }
.channel-check {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--border-1);
}
.channel-check-ico {
  width: 22px; height: 22px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 50%; font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface-2); color: var(--text-3);
}
.channel-check.is-ok .channel-check-ico { background: oklch(from var(--success) l c h / 0.16); color: var(--success); }
.channel-check.is-warn .channel-check-ico { background: oklch(from var(--danger) l c h / 0.12); color: var(--danger); }
.channel-check-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.channel-check-main strong { font-size: var(--fs-sm); }
.channel-check-detail { color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.channel-check-result { color: var(--text-3); font-size: var(--fs-xs); }
.channel-check-endpoint { margin-top: var(--sp-3); }
.channel-check-endpoint > summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); }
.channel-check-entries { margin-top: var(--sp-3); }
.channel-check-entries h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.channel-check-entries[hidden] { display: none; }

@media (max-width: 640px) {
  .aw-backdrop, .modal, .app-dialog { padding: var(--mc-space-3, 12px); }
  .aw-head, .aw-foot, .modal-header, .app-dialog-head, .app-dialog-foot { padding: var(--mc-space-3, 12px) var(--mc-space-4, 16px); }
  .aw-body-single, .modal-body, .app-dialog-body { padding: var(--mc-space-4, 16px); }
  .role-choice-list { grid-template-columns: 1fr; }
  .role-default-select { width: 100%; flex-basis: 100%; }
  .role-tabs { overflow-x: auto; }
  .role-editor-foot { flex-wrap: wrap; }
  .channel-check { flex-wrap: wrap; }
}

/* 项目页里的 [hidden] 必须压过按钮自带的 display，否则坐席的只读隐藏会失效。 */
.project-workspace [hidden] { display: none !important; }

/* 权限隐藏：侧栏按钮自带 display:flex，会盖掉 UA 的 [hidden]。 */
.ocp-sidebar .nav-item[hidden] { display: none !important; }
.role-field-hint.is-warn { color: var(--danger); }
.role-field-hint:empty { display: none; }

/* 项目成员行：成员名 + 角色/邮箱 + 移出按钮 */
.pd-member-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 4px 0;
}
.pd-member-remove {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 12px;
}

/* 项目模型 / 项目语言 / A/B 分流：两列以上的紧凑表单网格 */
.pd-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.pd-settings-grid .pd-field select,
.pd-touchpoint-add .pd-field select {
  padding: 7px 9px;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: var(--surface-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
}
.pd-settings-grid .pd-field select:focus-visible,
.pd-touchpoint-add .pd-field select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-shadow);
}
.pd-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  align-self: end;
  padding-bottom: 8px;
}

/* 客服 IM 桥接：一行一条桥接 + 新增表单 */
.pd-touchpoint-rows { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.pd-touchpoint-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-1);
}
.pd-touchpoint-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-touchpoint-main .muted { font-size: var(--fs-xs); }
.pd-touchpoint-remove { margin-left: auto; padding: 2px 8px; font-size: 12px; }
.pd-touchpoint-add {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-2);
  align-items: end;
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--border-1);
}
.pd-touchpoint-add-ops {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
/* 项目设置弹窗里的区块分隔：低频配置堆在一起时靠发丝线保持可扫读 */
.pd-project-llm, .pd-project-translation {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-1);
}

/* 知识库管理：搜索/筛选行 */
.kb-manager-search {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* 项目设置里的内联操作行（项目模型 / 项目语言） */
.pd-inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============ API 凭证（设置 → API 接入） ============ */
/* 头部：标题在左、主操作在右，两者之间至少要有一道间距；列表另起一块，
   和头部拉开距离 —— 以前按钮直接贴着下面的卡片列表，看起来像是列表的第一行。 */
.cred-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.cred-panel-head-text { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.cred-panel-title { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--text-1); }
.cred-panel-note { margin: 0; font-size: var(--fs-xs); }
.cred-panel-head .btn-primary { flex: 0 0 auto; margin-inline-start: auto; }
#cred-token-reveal:not(:empty) { margin-bottom: var(--sp-4); }
/* 列表项本身是 .llm-provider-card，自带 margin-bottom，这里不再叠 gap。 */
#cred-list { display: block; }

/* ============ 登录设备 ============ */
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border-1);
}
.device-row:first-child { border-top: 0; }

/* ============ 项目业务记录（Agent 自动记录 + 人工维护） ============ */
.pe-toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.pe-filter { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-3); }
.pe-list { display: flex; flex-direction: column; }
.pe-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-top: 1px solid var(--border-1); flex-wrap: wrap;
}
.pe-row:first-child { border-top: 0; }
.pe-row-main { min-width: 0; flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; }
.pe-kind, .pe-stage {
  display: inline-block; margin-left: var(--sp-2); padding: 0 6px; border-radius: var(--r-1);
  font-size: var(--fs-xs); background: var(--surface-2); color: var(--text-3);
}
.pe-summary { font-size: var(--fs-xs); }
.pe-row-meta { font-size: var(--fs-xs); white-space: nowrap; }
.pe-row-actions { display: flex; gap: var(--sp-1); }
.pe-editor { display: flex; flex-direction: column; gap: var(--sp-3); }
.pe-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--text-3); }
.pe-field input, .pe-field select, .pe-field textarea {
  font: inherit; color: var(--text-1); background: var(--surface-1);
  border: 1px solid var(--border-2); border-radius: var(--r-2); padding: 8px var(--sp-3);
}
.pe-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-2); }

/* ============ 手动明暗主题覆盖（驱动 light-dark()） ============ */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ============ 顶栏当前项目可见上下文胶囊（解决侧栏折叠态项目隐身） ============ */
.header-project-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 196px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  background: var(--surface-sunken);
  box-shadow: var(--inner-highlight);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--dur-fast) var(--ease-out-expo),
              border-color var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.header-project-pill:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-1);
  transform: translateY(-0.5px);
}
.header-project-pill:active {
  transform: scale(0.97);
}
.header-project-pill.is-filtered {
  background: var(--brand-soft);
  border-color: oklch(from var(--brand) l c h / 0.32);
  color: var(--brand-text);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.2), 0 1px 4px oklch(from var(--brand) l c h / 0.14);
}
.header-project-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px oklch(from var(--brand) l c h / 0.22);
  flex-shrink: 0;
}
.header-project-pill:not(.is-filtered) .header-project-dot {
  background: var(--text-3);
  box-shadow: none;
}

/* ============ 新建项目卡片（全屏引导复用） ============ */
.epo-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  padding: var(--sp-7);
  box-shadow: var(--shadow-elevated), var(--inner-highlight);
  position: relative;
  overflow: hidden;
  animation: card-rise-in 380ms var(--ease-out-expo) both;
}
.epo-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, oklch(from var(--brand) l c h / 0.65) 20%, var(--brand) 50%, oklch(from var(--brand) l c h / 0.65) 80%, transparent 100%);
}
.epo-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  border: 1px solid oklch(from var(--brand) l c h / 0.22);
  color: var(--brand-text);
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-bottom: var(--sp-4);
}
.epo-card h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-1);
  margin: 0 0 var(--sp-2);
}
.epo-desc {
  color: var(--text-2);
  font-size: var(--fs-base);
  line-height: 1.6;
  margin: 0 0 var(--sp-5);
}
.epo-steps {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-xs);
  color: var(--text-3);
  flex-wrap: wrap;
}
.nuo-step-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.nuo-step-sep {
  color: var(--text-3);
  user-select: none;
}
.epo-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: background 220ms var(--ease-out-expo), color 220ms var(--ease-out-expo), border-color 220ms var(--ease-out-expo);
}
.epo-step.is-active {
  background: var(--brand-soft);
  border-color: oklch(from var(--brand) l c h / 0.26);
  color: var(--brand-text);
  font-weight: 600;
}
.epo-step.is-done {
  background: oklch(from var(--success) l c h / 0.14);
  color: var(--success-fill);
  font-weight: 600;
}
.epo-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.epo-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}
.epo-field input {
  width: 100%;
  height: 42px;
  padding: 0 var(--sp-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  color: var(--text-1);
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-base) var(--ease-out-expo);
}
.epo-field input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px oklch(from var(--brand) l c h / 0.14);
}
/* 快捷场景模板芯片 */
.epo-presets,
.epo-quick-chips,
.epo-template-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.epo-presets-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
}
.epo-preset-chip,
.epo-quick-chip,
.epo-template-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-2);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-expo),
              border-color var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-spring);
}
.epo-preset-chip:hover,
.epo-quick-chip:hover,
.epo-template-chip:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-text);
  transform: translateY(-1px);
}
.epo-preset-chip.is-selected,
.epo-quick-chip.is-selected,
.epo-template-chip.is-selected {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-text);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--brand);
}
.epo-preset-chip:active,
.epo-quick-chip:active,
.epo-template-chip:active {
  transform: scale(0.96);
}
.epo-error {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--danger-text);
}
.epo-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
/* ============ 新用户全屏引导（5 步） ============
 * 不是半透明遮罩：进入时直接隐藏顶栏与侧栏，引导本身就是 #app-view 的内容。
 * 卡片外观复用「新建项目」引导（.epo-card/.epo-eyebrow/.epo-steps），
 * 这样新项目与首次开通看到的是同一套视觉语言。
 */
#app-view.is-new-user-onboarding .app-header,
#app-view.is-new-user-onboarding .app-body,
/* 通知授权横幅插在 .app-body 之前，也要一起收掉，否则会压在引导顶部。 */
#app-view.is-new-user-onboarding #notify-banner { display: none; }

.new-user-onboarding {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* 底部多留 72px：隐藏顶栏时右下角会出现语言浮层按钮，别压住引导的主按钮。 */
  padding: var(--sp-7) var(--sp-5) 72px;
  background-color: var(--surface-0);
  background-image:
    radial-gradient(ellipse 65% 50% at 50% 0%, oklch(from var(--brand) l c h / 0.11), transparent 65%),
    linear-gradient(to right, light-dark(oklch(18% 0.02 258 / 0.03), oklch(96% 0.01 250 / 0.028)) 1px, transparent 1px),
    linear-gradient(to bottom, light-dark(oklch(18% 0.02 258 / 0.03), oklch(96% 0.01 250 / 0.028)) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
}
.new-user-onboarding[hidden] { display: none; }
.nuo-shell { width: 100%; max-width: 1080px; margin: auto; }
.nuo-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
  padding: 10px var(--sp-4);
  border-radius: var(--r-3);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  box-shadow: var(--shadow-1);
}
.nuo-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nuo-topbar-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}
.nuo-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}
.nuo-topbar-user {
  font-size: var(--fs-xs);
  color: var(--text-3);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nuo-card { max-width: none; }
.nuo-steps { margin-bottom: var(--sp-5); }
.nuo-step { white-space: nowrap; }
.nuo-body { min-height: 250px; }
.nuo-channel-surface { margin-top: var(--sp-3); }
/* 内联渠道复用 channel-config-body 的排版规则，但不做自身的滚动/内边距。 */
.nuo-channel-surface.channel-config-body {
  padding: 0;
  overflow: visible;
  max-height: none;
}
/* 引导里只保留自己的底部按钮：渠道核心的返回/创建等底部行由引导的
   上一步/下一步/稍后再说代理，避免两排按钮互相打架。
   保留 .qs-actions（下载二维码 / 新窗口预览），方便用户当场预览并试发消息。 */
.nuo-channel-surface .btn-row,
.nuo-channel-surface .setup-modal-foot,
.nuo-channel-surface .qc-actions {
  display: none !important;
}
/* 简化后的在线客服表单：引导里一个全宽名称输入框就够。 */
.nuo-channel-surface #chat-create-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
}
.nuo-channel-surface #chat-create-form .form-group label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}
.nuo-channel-surface #chat-create-form .form-group input {
  width: 100%;
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font: inherit;
}
.nuo-kb-import-surface { margin-top: var(--sp-3); }
/* 知识库顶部状态条：名称 + 条目数 + 操作同一行 */
.nuo-kb-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-2);
}
.nuo-kb-status-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.nuo-kb-status-main strong { font-size: var(--fs-sm); color: var(--text-1); }
.nuo-kb-status-main #nuo-kb-count { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.nuo-kb-status-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nuo-kb-status-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  white-space: nowrap;
}
.nuo-kb-status-btn:hover { border-color: var(--brand); color: var(--brand-text); }
@media (max-width: 720px) {
  .nuo-kb-statusbar { flex-wrap: wrap; }
}
/* 知识库顶部状态固定一行，不换行 */
#nuo-kb-count { white-space: nowrap; }
.nuo-actions { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border-1); }
.nuo-spacer { flex: 1; }
.nuo-hint {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-xs);
  line-height: 1.65;
  color: var(--text-3);
}
.nuo-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-3);
}
.nuo-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: var(--sp-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  background: var(--surface-sunken);
  color: var(--text-1);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              background var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.nuo-choice:hover { border-color: var(--brand); background: var(--surface-1); }
.nuo-choice.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand);
}
.nuo-choice-name { font-weight: 600; font-size: var(--fs-sm); }
.nuo-choice-desc { font-size: var(--fs-xs); line-height: 1.55; color: var(--text-2); }
.nuo-choice-check {
  margin-left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
}
.nuo-choice.is-selected .nuo-choice-check {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: inset 0 0 0 3px var(--surface-1);
}
.nuo-inline { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.nuo-result {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid oklch(from var(--success) l c h / 0.35);
  border-radius: var(--r-3);
  background: oklch(from var(--success) l c h / 0.08);
}
.nuo-result h4 { margin: 0 0 var(--sp-1); font-size: var(--fs-sm); }
.nuo-result p { margin: var(--sp-1) 0 0; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.6; }
.nuo-code {
  display: block;
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-2);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-1);
}
.nuo-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.nuo-toggle.is-disabled { opacity: 0.62; cursor: not-allowed; }
.nuo-toggle.is-disabled input { cursor: not-allowed; }
.nuo-answer {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-size: var(--fs-sm);
  line-height: 1.7;
}
.nuo-answer:empty { display: none; }
.nuo-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--sp-3);
}
.nuo-agent {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  background: var(--surface-sunken);
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              background var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.nuo-agent:hover { border-color: var(--brand); background: var(--surface-1); }
.nuo-agent.is-selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.nuo-agent-name { font-weight: 600; font-size: var(--fs-sm); }
.nuo-agent-role { font-size: var(--fs-xs); color: var(--brand-text); }
.nuo-agent-desc { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.nuo-textarea {
  width: 100%;
  min-height: 84px;
  padding: var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font: inherit;
  resize: vertical;
}
.nuo-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.14); }
.nuo-test-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.nuo-test-row input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
}
.nuo-test-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px oklch(from var(--brand) l c h / 0.14); }
.nuo-test-log { margin-top: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.nuo-test-hit {
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
}
.nuo-test-hit strong { display: block; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.nuo-test-hit p { margin: 4px 0 0; font-size: var(--fs-xs); line-height: 1.6; color: var(--text-2); overflow-wrap: anywhere; }
.nuo-test-hit .nuo-score { float: right; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.nuo-empty { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.nuo-entry-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nuo-entry-list li {
  display: flex;
  gap: var(--sp-2);
  align-items: baseline;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  font-size: var(--fs-xs);
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.nuo-entry-list strong { color: var(--text-1); font-weight: 600; overflow-wrap: anywhere; }
.nuo-agent-name, .nuo-agent-desc, .nuo-choice-name, .nuo-choice-desc { overflow-wrap: anywhere; }
.nuo-summary { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.nuo-summary li {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-2);
}
.nuo-summary-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: oklch(from var(--success) l c h / 0.16);
  color: var(--success-fill);
  font-size: 12px;
  font-weight: 700;
}
.nuo-summary-mark.is-pending { background: var(--surface-sunken); color: var(--text-3); }
.nuo-summary-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nuo-summary-text strong { font-size: var(--fs-sm); }
.nuo-summary-text small { font-size: var(--fs-xs); color: var(--text-3); }
.nuo-kb-test-box {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: var(--surface-2);
}
.nuo-kb-test-box h4 {
  margin: 0 0 4px;
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.nuo-verify-card {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid oklch(from var(--brand) l c h / 0.28);
  border-radius: var(--r-3);
  background: var(--brand-soft);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.nuo-verify-card h4 {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.nuo-verify-card p {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-2);
}
.nuo-verify-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: 4px;
}
.nuo-webhook-done {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.nuo-webhook-done h4 {
  margin: 0;
  font-size: var(--fs-md);
  color: var(--text-1);
}
.nuo-webhook-url-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.nuo-webhook-url-row code {
  flex: 1 1 280px;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--r-2);
  border: 1px solid var(--border-2);
  background: var(--surface-sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-xs);
  word-break: break-all;
  color: var(--text-1);
}

@media (max-width: 720px) {
  /* 隐藏顶栏后，右下角会补一个语言浮层按钮：底部留出空间，避免压住主按钮。 */
  .new-user-onboarding { padding: var(--sp-4) var(--sp-3) 72px; }
  .nuo-topbar { padding: 8px 12px; }
  .nuo-topbar-user { display: none; }
  .nuo-agent-grid { grid-template-columns: 1fr; }
  .nuo-card { padding: var(--sp-5); }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .epo-card,
  .app-view-panel,
  .dropdown-menu,
  .chip-menu,
  .search-results,
  .modal,
  .modal-content,
  .app-dialog,
  .app-dialog-card,
  .toast,
  .message,
  .draft-bubble,
  .draft-bubble-editor,
  .dot-unread {
    animation: none !important;
  }
}
@media (max-width: 720px) {
  .header-project-pill { display: none; }
  .epo-card { padding: var(--sp-5); }
}


/* ============================================================================
 * 工作台 17 项深度优化样式（#1/#4/#5/#6/#7/#9/#14/#15/#16/#17）
 * ========================================================================== */

/* #1 & #9：收件箱顶部项目筛选 + 紧凑工具栏 */
.session-list-header {
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
}
.session-list-title {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: var(--fs-sm);
}
.session-list-toolbar {
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.session-project-select {
  appearance: none;
  min-width: 78px;
  max-width: 118px;
  width: auto;
  height: 30px;
  /* 箭头统一由 tokens.css 的全局 select 规则提供，这里只管底色与文字；
     这一格宽度只有 118px，箭头与内边距都收紧一点 */
  --mc-select-arrow-inset: 7px;
  --mc-select-arrow-size: 10px;
  --mc-select-text-gap: 3px;
  padding-right: calc(var(--mc-select-arrow-inset) + var(--mc-select-arrow-size) + var(--mc-select-text-gap));
  padding-left: 9px;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background-color: var(--surface-sunken);
  color: var(--text-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              background-color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.session-project-select:hover {
  border-color: var(--border-2);
  background-color: var(--surface-2);
}
.session-project-select:focus-visible {
  outline: none;
  border-color: var(--brand);
  background-color: var(--surface-1);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 3px oklch(from var(--brand) l c h / 0.14);
}
.session-list-toolbar .session-selection-toggle {
  min-height: 30px;
  padding: 0 8px;
  border-radius: var(--r-2);
  flex-shrink: 0;
}
.session-list-toolbar .chip-trigger-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-2);
}

/* #9：全局总览卡片视觉层次 */
.ov-recent,
.ov-note,
.insight-rail {
  box-shadow: var(--shadow-1), var(--inner-highlight);
}

/* #4：项目页头操作按钮组并排、同高对齐 */
.project-workspace-head-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.project-workspace-head-actions > .btn-primary,
.project-workspace-head-actions > .btn-secondary {
  min-height: var(--ctl-h);
}

/* #5：渠道配置弹窗重设计（严控最小宽度与换行，杜绝横/纵向溢出） */
.channel-config-modal {
  padding: var(--sp-5);
}
.channel-config-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: 760px;
  height: auto;
  min-height: 0;
  max-height: min(86dvh, 840px);
  overflow: hidden;
}
.channel-config-body {
  padding: var(--sp-5);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.channel-config-body > *,
.channel-config-body form,
.channel-config-body section,
.channel-config-body div {
  min-width: 0;
  max-width: 100%;
}
.channel-config-body p,
.channel-config-body li,
.channel-config-body label,
.channel-config-body span,
.channel-config-body code,
.channel-config-body pre {
  overflow-wrap: anywhere;
}
.channel-config-body pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.channel-modal-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  background: var(--surface-sunken);
  min-width: 0;
}
.channel-modal-section h3,
.channel-modal-section h4,
.channel-modal-section h5 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text-1);
}
.setup-display-field-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}
.setup-display-code {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-2);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-1);
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.setup-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-top: var(--sp-4);
  margin-top: var(--sp-1);
  border-top: 1px solid var(--border-1);
}

/* #6：对话顶部客户头像与收件箱列表头像完全一致 */
.conv-header .session-avatar,
#conv-avatar.session-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
}

/* #7：邮件消息右上角圆形「！」按钮 */
.email-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.email-card-subject {
  flex: 1 1 auto;
  min-width: 0;
}
.email-info-trigger {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-expo),
              border-color var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-spring);
}
.email-info-trigger:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-text);
  transform: scale(1.06);
}
.email-info-trigger:active {
  transform: scale(0.94);
}
.email-info-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.message.outbound .email-info-trigger {
  background: oklch(from var(--text-inverse) l c h / 0.14);
  border-color: oklch(from var(--text-inverse) l c h / 0.34);
  color: var(--text-inverse);
}
.message.outbound .email-info-trigger:hover {
  background: oklch(from var(--text-inverse) l c h / 0.24);
  border-color: var(--text-inverse);
}

/* #14：个人头像下拉菜单内外观与语言分段控件 */
.user-dropdown {
  min-width: 278px;
}
.user-menu-prefs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-1);
}
.user-menu-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.user-menu-pref-label {
  font-size: var(--fs-xs);
  font-weight: 550;
  color: var(--text-2);
  white-space: nowrap;
}
.user-menu-segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
}
.user-menu-seg-btn {
  min-width: 44px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.user-menu-seg-btn:hover:not([aria-pressed="true"]) {
  color: var(--text-1);
  background: oklch(from var(--text-1) l c h / 0.05);
}
.user-menu-seg-btn[aria-pressed="true"] {
  background: var(--surface-1);
  color: var(--brand-text);
  font-weight: 600;
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--border-1);
}
.user-menu-seg-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* #11：引导卡片严格尊重 [hidden]，防止 flex/block 覆盖隐藏态 */
.epo-card [hidden],
.epo-error[hidden],
.epo-form[hidden] {
  display: none !important;
}

/* #15：自动翻译简化设置 */
.translation-simple-form {
  max-width: 560px;
}
.translation-toggle-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: fit-content;
  margin-bottom: var(--sp-2);
  cursor: pointer;
}
.translation-toggle-row input[type="checkbox"] {
  width: 16px !important;
  height: 16px;
  min-width: 16px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--brand);
}
.translation-help {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.6;
}

/* #16：数据与留存 UI 全面重设计（严禁任何组件间距为 0） */
.data-retention-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-width: 920px;
}
.data-card {
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1), var(--inner-highlight);
}
.data-card[hidden] { display: none !important; }
.data-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: 0;
}
.data-card-head-text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 auto;
}
.data-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text-1);
}
.data-card-desc {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 68ch;
}
.data-metrics-block,
.data-status-block {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.data-metrics-block p,
.data-status-block p {
  margin: 0;
}
.data-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.data-edit-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-1);
}
.data-edit-panel[hidden] { display: none !important; }
.data-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-4);
  align-items: end;
}
.data-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 550;
  color: var(--text-2);
  min-width: 0;
}
.data-form-field input {
  width: 100%;
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.data-form-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 3px oklch(from var(--brand) l c h / 0.14);
}
.data-checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--ctl-h);
  font-size: var(--fs-sm);
  color: var(--text-1);
  cursor: pointer;
}
.data-checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.data-error-note {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--danger-text);
}
.data-export-row {
  gap: var(--sp-3);
}
.data-inline-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
}
.data-inline-hint:empty { display: none; }
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-1);
}
.data-table-wrap .data-audit-table th,
.data-table-wrap .data-audit-table td {
  padding: 10px 14px;
}
.data-table-wrap .data-audit-table thead th {
  background: var(--surface-sunken);
}
.data-danger-card {
  border-color: color-mix(in oklab, var(--danger) 36%, var(--border-1));
  background: color-mix(in oklab, var(--danger) 3%, var(--surface-1));
}
.data-danger-card .data-card-title {
  color: var(--danger-text);
}
.data-danger-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.data-danger-input {
  flex: 1 1 240px;
  max-width: 340px;
  min-height: var(--ctl-h);
}
.data-danger-btn {
  color: var(--danger-text);
  border-color: color-mix(in oklab, var(--danger) 50%, transparent);
}
.data-danger-btn:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger-text);
}

@media (max-width: 640px) {
  .data-card { padding: var(--sp-4); }
  .channel-config-modal { padding: var(--sp-3); }
  .channel-config-body { padding: var(--sp-4); }
}


/* ============================================================================
 * 快捷生成临时对话 / 自助表单 & 链接与二维码分享弹窗
 * ========================================================================== */

.project-channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

/* 有效期选择器（在线客服 & 自助收集表单共用） */
.qc-expiry-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.qc-expiry-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}
.qc-expiry-select,
.qc-expiry-datetime {
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-size: var(--fs-sm);
  min-width: 0;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              background var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.qc-expiry-select {
  flex: 0 1 180px;
  cursor: pointer;
}
.qc-expiry-datetime {
  flex: 1 1 200px;
  font-variant-numeric: tabular-nums;
}
.qc-expiry-datetime[hidden] { display: none !important; }
.qc-expiry-select:focus,
.qc-expiry-datetime:focus {
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 3px oklch(from var(--brand) l c h / 0.14);
}

/* 分享结果有效期状态徽章 */
.qs-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.qs-expiry-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-1);
  background: var(--surface-2);
  color: var(--text-2);
}
.qs-expiry-badge.is-permanent {
  background: var(--mc-success-soft, rgba(21, 128, 61, 0.11));
  border-color: oklch(from var(--success) l c h / 0.3);
  color: var(--success-fill);
}
.qs-expiry-badge.is-active {
  background: var(--brand-soft);
  border-color: oklch(from var(--brand) l c h / 0.28);
  color: var(--brand-text);
}
.qs-expiry-badge.is-expired {
  background: var(--danger-soft);
  border-color: oklch(from var(--danger) l c h / 0.32);
  color: var(--danger-text);
}

/* 多类型自助表单字段构建器（严控 min-width: 0，不溢出） */
.fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.fb-add-btn {
  min-height: 30px;
  padding: 0 11px;
  font-size: var(--fs-xs);
}
.fb-builder {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.fb-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  min-width: 0;
  transition: border-color var(--dur-fast) var(--ease-out-expo), background var(--dur-fast) var(--ease-out-expo);
}
.fb-row:focus-within {
  border-color: oklch(from var(--brand) l c h / 0.45);
  background: var(--surface-1);
}
.fb-row-main {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(110px, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.fb-label-input,
.fb-type-select,
.fb-options-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: var(--fs-xs);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              box-shadow var(--dur-fast) var(--ease-out-expo);
}
.fb-label-input:focus,
.fb-type-select:focus,
.fb-options-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 3px oklch(from var(--brand) l c h / 0.14);
}
.fb-req-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.fb-req-toggle input[type="checkbox"] {
  width: 14px !important;
  height: 14px;
  min-width: 14px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.fb-remove-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out-expo), color var(--dur-fast) var(--ease-out-expo);
}
.fb-remove-btn:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.fb-options-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fb-options-row[hidden] { display: none !important; }
.fb-options-input {
  height: auto;
  min-height: 34px;
  padding: 6px 10px;
}

/* 自动翻译实时自动保存状态条 */
.translation-autosave-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  min-height: 24px;
}
.translation-autosave-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease-out-expo), opacity var(--dur-fast) var(--ease-out-expo);
}
.translation-autosave-status:empty { display: none; }
.translation-autosave-status.is-saving { color: var(--brand-text); }
.translation-autosave-status.is-saved { color: var(--success-fill); }
.translation-autosave-status.is-error { color: var(--danger-text); }

@media (max-width: 600px) {
  .fb-row-main {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .fb-label-input,
  .fb-type-select {
    grid-column: 1 / -1;
  }
}

/* 快捷生成 & 分享弹窗 */
.quick-share-modal {
  padding: var(--sp-5);
}
.quick-share-dialog {
  width: min(540px, calc(100vw - 32px));
  max-width: 540px;
  height: auto;
  min-height: 0;
  max-height: min(88dvh, 780px);
  overflow: hidden;
}
.quick-share-body {
  padding: var(--sp-5);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

/* 配置表单 */
.qc-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}
.qc-intro {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.6;
}
.qc-fields-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.qc-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              background var(--dur-fast) var(--ease-out-expo),
              color var(--dur-fast) var(--ease-out-expo);
}
.qc-field-chip:hover {
  border-color: oklch(from var(--brand) l c h / 0.55);
}
.qc-field-chip:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}
.qc-field-chip input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.qc-custom-field-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.qc-custom-field-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.qc-error {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-2);
  background: var(--danger-soft);
  border: 1px solid oklch(from var(--danger) l c h / 0.3);
  color: var(--danger-text);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.qc-error[hidden] { display: none !important; }
.qc-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-1);
}

/* 分享结果：高清二维码 + 只读链接复制栏 + 动作按钮 */
.qs-result {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
  animation: view-panel-in 240ms var(--ease-out-expo) both;
}
/* 引导内联：代码与二维码左右排，压缩整体高度，并保留预览与二维码下载动作 */
.qs-result.is-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  grid-template-areas:
    "meta meta"
    "desc desc"
    "embed qr"
    "link qr"
    "actions actions";
  gap: var(--sp-3) var(--sp-4);
  align-items: start;
}
.qs-result.is-inline .qs-meta-row { grid-area: meta; justify-content: flex-start; }
.qs-result.is-inline .qs-desc { grid-area: desc; }
.qs-result.is-inline .qs-embed-group { grid-area: embed; }
.qs-result.is-inline .qs-qr-card { grid-area: qr; align-self: start; gap: 6px; padding: 10px; }
.qs-result.is-inline .qs-qr-frame { padding: 8px; }
.qs-result.is-inline .qs-qr-img { width: 156px; height: 156px; }
.qs-result.is-inline .qs-qr-caption { font-size: var(--fs-xs); }
.qs-result.is-inline .qs-link-group { grid-area: link; }
.qs-result.is-inline .qs-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-start; }
.qs-result.is-inline .qs-embed-code { max-height: 110px; }
@media (max-width: 900px) {
  .qs-result.is-inline {
    grid-template-columns: 1fr;
    grid-template-areas: "meta" "desc" "embed" "qr" "link" "actions";
  }
}
.qs-desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.6;
}
.qs-qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-radius: var(--r-3);
  border: 1px solid var(--border-1);
  background: var(--surface-sunken);
  box-shadow: var(--inner-highlight);
}
/* 关键：浅色与深色模式下均必须保留纯白背景与充足静区，保证手机扫码 100% 识别 */
.qs-qr-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #ffffff;
  border-radius: var(--r-3);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 24px -8px rgba(15, 23, 42, 0.18);
}
.qs-qr-img {
  display: block;
  width: 212px;
  height: 212px;
  max-width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.qs-qr-caption {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
}
.qs-link-group,
.qs-embed-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.qs-embed-code {
  margin: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow: auto;
}
.qs-link-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}
.qs-link-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.qs-link-input {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  background: var(--surface-sunken);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qs-link-input:focus {
  border-color: var(--brand);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 3px oklch(from var(--brand) l c h / 0.14);
}
.qs-copy-btn {
  flex-shrink: 0;
  min-height: var(--ctl-h);
}
.qs-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-1);
}

@media (prefers-reduced-motion: reduce) {
  .qs-result { animation: none !important; }
}
@media (max-width: 560px) {
  .quick-share-modal { padding: var(--sp-3); }
  .quick-share-body { padding: var(--sp-4); }
  .qs-link-row { flex-wrap: wrap; }
  .qs-copy-btn { width: 100%; }
}
