/* BioAI 共享 CSS 框架
   基于原型 bioai-*.html 提取
   Plus Jakarta Sans 字体（已禁用 Google Fonts，使用系统默认字体）
*/

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e2e2de;
  --text: #1a1a18;
  --text-2: #4a4a47;
  --text-3: #8a8a86;
  --accent: #0a0a0a;
  --radius: 10px;
  --sidebar-w: 228px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --c-gf: #2a3f5f;  /* 合规 */
  --c-nf: #c9636f;  /* 内容 */
  --c-yf: #4a8c7a;  /* 运营 */
  --c-cf: #b88c3e;  /* 财务 */
  --c-pf: #5a7ab5;  /* 品牌洞察 */
  --c-kb: #1a1a18;  /* 知识基座 */
  --c-hf: #8b5cf6;  /* HR */
}

html, body { height: 100%; background: var(--surface); font-family: var(--font); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── TOPBAR ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; z-index: 100; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; width: var(--sidebar-w); flex-shrink: 0; }
.brand-logo { width: 28px; height: 28px; flex-shrink: 0; }
.brand-logo svg { width: 28px; height: 28px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.3px; }
.topbar-center { flex: 1; display: flex; align-items: center; padding-left: 4px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--text-2); font-weight: 500; }
.user-pill { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 10px; border-radius: 20px; transition: background .15s; }
.user-pill:hover { background: var(--bg); }
.ua { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: white; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text-2); }

/* ── LAYOUT ── */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 8px 0 40px;
  transition: width 0.2s;
}
.sidebar.collapsed { width: 0; overflow: hidden; padding: 0; border: none; }

/* 挂件 — 固定在侧边栏右边缘，position:fixed 突破 overflow:hidden */
.sidebar-toggle {
  position: fixed;
  left: var(--sidebar-w);
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 48px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  z-index: 99;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  padding: 0;
  font-family: inherit;
  transition: left 0.2s, width 0.15s;
}
.sidebar-toggle:hover { background: rgba(0,0,0,0.04); color: var(--text); width: 20px; }

/* 收起 — 贴到屏幕最左边 */
.sidebar.collapsed .sidebar-toggle { left: 0; border-left: 1px solid var(--border); }

.main-area { transition: margin-left 0.2s; }
.sidebar.collapsed ~ .main-area { margin-left: 0; }

.sidebar-section { padding: 0 12px 8px; }
.sidebar-label { font-size: 10px; font-weight: 700; letter-spacing: .8px; color: var(--text-3); text-transform: uppercase; padding: 4px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 7px; cursor: pointer; text-decoration: none;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .12s; position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--bg); color: var(--text); font-weight: 600; }
.inst-mark {
  width: 20px !important; height: 20px !important;
  min-width: 20px !important; min-height: 20px !important;
  max-width: 20px !important; max-height: 20px !important;
  border-radius: 5px; display: inline-flex !important;
  align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: white;
  flex-shrink: 0; padding: 0 !important;
}
.inst-mark.gf { background: var(--c-gf); }
.inst-mark.nf { background: var(--c-nf); }
.inst-mark.yf { background: var(--c-yf); }
.inst-mark.cf { background: var(--c-cf); }
.inst-mark.pf { background: var(--c-pf); }
.inst-mark.kb { background: var(--c-kb); }
.inst-mark.hf { background: var(--c-hf); }
.sub-nav-badge { font-size: 10px; color: var(--text-3); margin-left: auto; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }

/* ── MAIN AREA ── */
.main-area { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); background: var(--surface); }

/* ── HERO ── */
.hero { padding: 32px 40px 20px; }
.hero-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.hero-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.hero-greet { font-size: 14px; color: var(--text-2); max-width: 640px; line-height: 1.6; }
.hero-stats { display: flex; gap: 28px; margin-top: 20px; flex-wrap: wrap; }
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 500; }

/* ── CONTENT ── */
.content { padding: 0 40px 80px; max-width: 1040px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; margin-top: 28px; }
.section-head:first-child { margin-top: 0; }
.section-title { font-size: 13px; font-weight: 700; }
.section-count { font-size: 12px; color: var(--text-3); }

/* ── PILLS ── */
.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill-green { background: #e6f4ef; color: #2d7a5f; }
.pill-yellow { background: #fef4e2; color: #9b6f1a; }
.pill-red { background: #fde8ea; color: #a53038; }
.pill-blue { background: #e6edf9; color: #2a5fb5; }
.pill-gray { background: var(--bg); color: var(--text-3); }

/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }

/* ── KB ROWS ── */
.kb-row { padding: 14px 18px; border-bottom: 1px solid var(--border); transition: background .1s; }
.kb-row:last-child { border-bottom: none; }
.kb-row:hover { background: #fafaf8; }
.kb-row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.kb-id { font-family: 'SF Mono', Menlo, monospace; font-size: 11px; color: var(--text-3); background: var(--bg); padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.kb-title { font-size: 13.5px; font-weight: 700; }
.kb-row-desc { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; line-height: 1.55; }
.kb-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); align-items: center; }
.kb-meta-block { display: flex; align-items: center; gap: 6px; }
.kb-meta-label { font-weight: 700; letter-spacing: .3px; text-transform: uppercase; font-size: 10px; color: var(--text-3); }

/* ── AGENT CHIPS ── */
.agent-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 4px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-2); font-weight: 500;
}
.agent-chip .agent-dot {
  width: 14px; height: 14px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8px; color: white; font-weight: 800;
}
.agent-chip.owner { background: #fff8e6; border-color: #e8d997; }
.agent-chip.owner .agent-name { font-weight: 700; }
.agent-chip-count { color: var(--text-3); font-size: 10px; margin-left: 2px; }
.dot-gf { background: var(--c-gf); }
.dot-nf { background: var(--c-nf); }
.dot-yf { background: var(--c-yf); }
.dot-cf { background: var(--c-cf); }
.dot-pf { background: var(--c-pf); }
.kb-callers { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* ── KB CATS ── */
.kb-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.kb-cat {
  padding: 6px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-decoration: none; cursor: pointer; transition: all .12s;
}
.kb-cat:hover { background: var(--bg); color: var(--text); }
.kb-cat .kb-cat-count { margin-left: 5px; color: var(--text-3); font-weight: 500; font-size: 11px; }
.kb-cat.active { background: var(--text); color: white; border-color: var(--text); }
.kb-cat.active .kb-cat-count { color: rgba(255,255,255,0.7); }

/* ── KB SECTION ── */
.kb-section-title { display: flex; align-items: baseline; gap: 10px; }
.kb-section-emoji { font-size: 14px; line-height: 1; }

/* ── KB TIP ── */
.kb-tip { background: #fff8e6; border: 1px solid #e8d997; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #6e5a2e; line-height: 1.55; margin: 16px 0 4px; }
.kb-tip strong { font-weight: 700; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafaf8; }

/* ── CHAT ── */
.chat-wrapper {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 50px);
  background: transparent;
  border-radius: 12px 0 0 0;
  margin: 0;
}
.chat-history { flex: 1; overflow-y: auto; padding: 20px 40px; background: transparent; }

/* ── SESSION PANEL (v2 会话侧栏) ── */
#tab-chat.active { display: flex; }
#tab-chat .chat-wrapper { flex: 1; min-width: 0; }
.session-panel {
  width: 264px; flex: none; display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 50px);
  background: #f6f6f2; border-right: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.session-panel.collapsed { width: 36px; }
.session-panel.collapsed .sp-head, .session-panel.collapsed .sp-list { display: none; }
.sp-expand { display: none; position: absolute; top: 10px; left: 4px; border: none; background: transparent; font-size: 16px; color: var(--text-2); cursor: pointer; padding: 4px 6px; }
.session-panel.collapsed .sp-expand { display: block; }
.sp-head { padding: 12px 12px 8px; }
.sp-head-row { display: flex; align-items: center; gap: 6px; }
.sp-collapse { border: none; background: transparent; font-size: 15px; color: var(--text-3); cursor: pointer; padding: 2px 4px; }
.sp-collapse:hover { color: var(--text); }
.sp-search {
  flex: 1; min-width: 0; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; background: #fff; color: var(--text);
}
.sp-search:focus { outline: none; border-color: var(--c-agent, #4a8c7a); }
.sp-new {
  margin-top: 8px; width: 100%; box-sizing: border-box;
  border: none; border-radius: 8px; padding: 8px 0;
  background: var(--c-agent, #4a8c7a); color: #fff; font-size: 13px; cursor: pointer;
}
.sp-new:hover { background: var(--c-agent, #4a8c7a); filter: brightness(.9); }
.sp-list { flex: 1; overflow-y: auto; padding: 2px 6px 12px; }
.sp-group { font-size: 11px; color: var(--text-3); padding: 10px 8px 4px; }
.sp-item {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.sp-item:hover { background: #e9e9e4; }
.sp-item.active { background: color-mix(in srgb, var(--c-agent, #4a8c7a) 12%, #fff); color: color-mix(in srgb, var(--c-agent, #4a8c7a) 55%, #111); font-weight: 600; }
.sp-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-date { font-size: 10px; color: var(--text-3); flex: none; }
.sp-pin-flag { color: #b8860b; font-size: 11px; flex: none; }
.sp-acts { display: none; position: absolute; right: 4px; gap: 2px; background: inherit; }
.sp-item:hover .sp-acts { display: flex; }
.sp-item:hover .sp-date { display: none; }
.sp-acts button { border: none; background: transparent; cursor: pointer; font-size: 12px; padding: 2px 3px; color: var(--text-2); }
.sp-acts button:hover { color: var(--text); }
.sp-item .sp-acts button:last-child:hover { color: #b3442f; }
.sp-input { width: 100%; box-sizing: border-box; border: 1px solid var(--c-agent, #4a8c7a); border-radius: 6px; padding: 3px 6px; font-size: 13px; }
.sp-empty { padding: 18px 10px; color: var(--text-3); font-size: 12px; text-align: center; }
.sp-more { padding: 10px 0 4px; text-align: center; font-size: 12px; color: var(--text-3); cursor: pointer; }
.sp-more:hover { color: var(--c-agent, #4a8c7a); }
.sp-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #2a3f5f; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; display: flex; gap: 14px; align-items: center;
  z-index: 999; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.sp-toast button { background: none; border: none; color: #ffd28a; cursor: pointer; font-size: 13px; }

/* ── INPUT AREA (sticky 底部 + 气泡容器) ── */
.chat-input-area {
  position: sticky; bottom: 0;
  background: transparent;
  border-top: none;
  padding: 0 40px 16px;
}

/* 气泡容器 */
.chat-input-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* contenteditable div — 替代 textarea */
.chat-input {
  border: none; outline: none;
  background: transparent;
  width: 100%; padding: 6px 0;
  font-size: 14px; line-height: 1.6;
  min-height: 44px; max-height: 120px;
  overflow-y: auto;
  font-family: var(--font);
  color: var(--text);
}

/* 底部操作栏 */
.chat-input-actions {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 2px 0 6px;
}

/* ── BUTTONS ── */

/* 加号 — 左下角 24px 空心圈 */
.skill-plus-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: all 0.15s;
}
.skill-plus-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* 发送 — 右下角 32px 实心圈 */
.chat-send {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  transition: opacity 0.15s;
}
.chat-send:hover { opacity: 0.8; }
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; }
.chat-send svg { width: 16px; height: 16px; }

.msg { display: flex; gap: 12px; margin-bottom: 24px; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: white; }
.msg.user .msg-avatar { background: var(--text-3); }
.msg-agent { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.msg-body { max-width: 75%; }
.msg.user .msg-body { align-items: flex-end; }
.msg-bubble { background: #f5f5f2; border: none; border-radius: 16px; padding: 14px 18px; font-size: 14px; line-height: 1.7; }
.msg.user .msg-bubble { background: var(--text); color: white; }
.msg-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.msg.user .msg-time { text-align: right; }

.msg-citations { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.msg-citation { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.msg-citation .mc-label { font-weight: 700; min-width: 40px; }
.msg-citation a { color: var(--text-3); text-decoration: underline; }
.msg-citation a:hover { color: var(--text-2); }

/* ── HISTORY STRIP ── */
.history-strip { display: flex; gap: 6px; overflow-x: auto; padding: 0 40px 12px; scrollbar-width: none; }
.history-strip::-webkit-scrollbar { display: none; }
.hs-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); font-size: 12px; color: var(--text-2); background: var(--surface); white-space: nowrap; cursor: pointer; transition: all .12s; }
.hs-chip:hover { border-color: var(--text-3); color: var(--text); }
.hs-chip.active { background: var(--text); color: white; border-color: var(--text); }
.hs-chip .hs-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.hs-chip.active .hs-dot { background: rgba(255,255,255,0.6); }
.hs-preview { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.hs-del { margin-left: 2px; padding: 0 4px; font-size: 14px; color: var(--text-3); border-radius: 50%; transition: all .12s; }
.hs-del:hover { color: #e74c3c; background: rgba(231,76,60,0.1); }
.hs-chip.active .hs-del { color: rgba(255,255,255,0.5); }
.hs-chip.active .hs-del:hover { color: #ff6b6b; background: rgba(255,255,255,0.15); }

/* ── SUB TABS ── */
.sub-tabs { display: flex; gap: 4px; padding: 0 40px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: var(--topbar-h); z-index: 90; }
.sub-tab { padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--text-3); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .12s; }
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* ── DETAIL TABLE ── */
.detail-table { width: 100%; }
.detail-table .col-name { font-size: 12px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 6px 0; }

/* ── SKILL META ── */
.skill-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.skill-desc { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.skill-trigger { font-size: 11px; color: var(--text-3); }
.skill-trigger span { font-weight: 600; color: var(--text-2); }

/* ── MISC ── */
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.text-agent { font-size: 12px; font-weight: 600; }
a { color: inherit; text-decoration: none; }
.mono { font-family: 'SF Mono', Menlo, monospace; }

/* ── PAGE-SPECIFIC ── */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; flex: 1; min-width: 160px; }
.stat-card-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.stat-card-label { font-size: 11px; color: var(--text-3); font-weight: 500; margin-top: 4px; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }

.event-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.event-item:last-child { border-bottom: none; }
.event-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: white; flex-shrink: 0; }
.event-body { flex: 1; }
.event-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.event-tags { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.event-desc { font-size: 12px; color: var(--text-2); line-height: 1.5; }

.instance-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; cursor: pointer; transition: all .12s; text-decoration: none; color: inherit; display: block; }
.instance-card:hover { border-color: var(--text-3); transform: translateY(-1px); }
.instance-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.instance-card-name { font-size: 14px; font-weight: 700; }
.instance-card-stats { font-size: 12px; color: var(--text-2); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2d7a5f; flex-shrink: 0; }

/* ── LOGIN PAGE ── */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 380px; text-align: center; }
.login-logo { width: 48px; height: 48px; margin: 0 auto 16px; }
.login-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }
.login-form { text-align: left; }
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
.form-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: var(--font); font-size: 13.5px; outline: none; transition: border-color .15s; box-sizing: border-box; }
.form-input:focus { border-color: var(--text); }
.login-btn { width: 100%; background: var(--text); color: white; border: none; border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; transition: opacity .15s; }
.login-btn:hover { opacity: 0.85; }
.login-footer { margin-top: 24px; font-size: 11px; color: var(--text-3); }
.login-error { background: #fde8ea; color: #a53038; border-radius: 6px; padding: 8px 12px; font-size: 12px; margin-bottom: 12px; display: none; }

/* ── CHARTS (CSS only) ── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-item { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--text-2); width: 120px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-value { font-size: 11px; color: var(--text-3); width: 36px; text-align: right; flex-shrink: 0; }

/* ── TABS ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--text-3); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .12s; font-family: var(--font); }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* span.inst-mark fix */
span.inst-mark, div.inst-mark { padding: 0 !important; width: 20px !important; height: 20px !important; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 520px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.modal-box .form-group { margin-bottom: 14px; }
.modal-box .form-input, .modal-box .form-textarea { width: 100%; box-sizing: border-box; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-error { color: #a53038; font-size: 12px; margin-top: 6px; min-height: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.btn-cancel { padding: 8px 18px; border-radius: 6px; border: 1px solid var(--border); background: none; cursor: pointer; font-size: 13px; }
.btn-submit { padding: 8px 18px; border-radius: 6px; border: none; background: var(--accent); color: white; cursor: pointer; font-size: 13px; font-weight: 600; }

/* ── Skill Panel (v7 卡片布局 + 搜索) ── */
.skill-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 8px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.10);
}
.skill-panel.hidden { display: none; }

.skill-panel-search {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.skill-panel-search input {
  width: 100%; box-sizing: border-box;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--bg);
  outline: none;
}
.skill-panel-search input:focus { border-color: var(--accent); }

.skill-card-list { padding: 6px 8px; }

.skill-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background 0.12s;
}
.skill-card:hover { background: var(--bg); }
.skill-card.selected { background: rgba(99,102,241,0.08); }

.skill-card-header { display: flex; align-items: center; gap: 6px; }
.skill-card-icon { color: var(--accent); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.skill-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.skill-card-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; padding-left: 19px; }

.skill-panel-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 12px; }
.skill-panel-empty a { color: var(--accent); font-weight: 600; }

/* ── Inline Skill Chip（输入框 contenteditable 内）── */
.skill-inline {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 4px 1px 7px; margin: 0 2px;
  border-radius: 10px;
  background: rgba(99,102,241,0.10);
  border: 1px solid rgba(99,102,241,0.25);
  color: var(--accent);
  font-size: 12.5px; font-weight: 500;
  vertical-align: middle; cursor: default;
  user-select: none; white-space: nowrap;
}
.skill-inline .si-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 12px; cursor: pointer; opacity: 0.5;
}
.skill-inline .si-remove:hover { opacity: 1; background: rgba(0,0,0,0.08); }
/* 用户消息深色气泡适配 */
.msg.user .skill-inline {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.85);
}

/* contenteditable placeholder */
.chat-input:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }

/* KB Skills Tab */
.kb-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.kb-tab { padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer; font-family: inherit; transition: all .1s; }
.kb-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.kb-tab-content.hidden { display: none; }

.skill-section { margin-bottom: 24px; }
.skill-section h3 { font-size: 14px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.skill-section .count { font-size: 11px; color: var(--text-3); font-weight: 400; }
.skill-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.skill-row:last-child { border-bottom: none; }
.skill-row .skill-id { font-weight: 700; color: var(--accent); min-width: 32px; }
.skill-row .skill-name { font-weight: 600; min-width: 120px; }
.skill-row .skill-desc { color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-row .skill-actions { display: flex; gap: 4px; flex-shrink: 0; }
.skill-row .skill-actions button { font-size: 11px; padding: 4px 8px; }
.skill-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.skill-add-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: white; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }
.skill-add-btn:hover { opacity: .85; }
.skill-empty { padding: 16px; text-align: center; color: var(--text-3); font-size: 12px; }

/* Form textarea for skills */
.form-textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; font-family: inherit; background: var(--surface); color: var(--text-1); box-sizing: border-box; outline: none; transition: border-color .15s; resize: vertical; min-height: 80px; line-height: 1.5; }
.form-textarea:focus { border-color: var(--accent); }
.form-error.hidden { display: none; }