@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f4f7f6;
  --bg-card: #ffffff;
  --bg-sidebar: rgba(255,255,255,.92);
  --accent: #0d9668;
  --accent-light: #d1fae5;
  --accent2: #3b82f6;
  --gradient: linear-gradient(135deg, #0d9668 0%, #10b981 50%, #34d399 100%);
  --gradient-btn: linear-gradient(135deg, #0d9668, #10b981);
  --text: #1a2332;
  --text2: #5a6a7e;
  --text3: #94a3b8;
  --border: #e8ecf0;
  --border-light: #f1f4f7;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-glow: 0 0 0 3px rgba(13,150,104,.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 50px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-bounce: cubic-bezier(.34,1.56,.64,1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── 登录页 ─────────────────────── */

#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.login-card p { color: var(--text2); margin-bottom: 32px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: border .2s;
  margin-bottom: 16px;
  font-family: inherit;
}

.login-card input:focus { border-color: var(--accent); }

.login-card .login-error {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

/* ── 按钮 ───────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .25s var(--ease);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(.96); }

.btn-primary {
  background: var(--gradient-btn);
  color: #fff;
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(13,150,104,.25), inset 0 1px 0 rgba(255,255,255,.15);
}

.btn-primary:hover { box-shadow: 0 4px 16px rgba(13,150,104,.35), inset 0 1px 0 rgba(255,255,255,.15); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.btn-ghost {
  background: none;
  color: var(--text2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover { color: var(--accent); background: rgba(13,150,104,.06); }

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 18px;
  transition: all .25s var(--ease);
}

.btn-icon:hover { background: rgba(13,150,104,.08); color: var(--accent); }

/* ── 主布局 ─────────────────────── */

#app-page { display: none; }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s var(--ease);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header .subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 12px 4px;
  letter-spacing: .5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  transition: all .2s var(--ease);
  user-select: none;
  position: relative;
}

.nav-item:hover { background: rgba(13,150,104,.05); color: var(--text); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--text3);
  font-weight: 500;
}

.sidebar-stats {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
}

.sidebar-stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

/* ── 主内容区 ───────────────────── */

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  background: var(--bg);
  outline: none;
  transition: all .25s var(--ease);
  font-family: inherit;
}

.search-box input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: var(--shadow-glow);
}

.search-box .search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 15px;
}

.search-box .search-shortcut {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 500;
}

.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

.content { padding: 24px; flex: 1; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.content-header h3 { font-size: 18px; font-weight: 600; }

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-bar select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

/* ── 知识卡片网格 ───────────────── */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 22px;
  transition: all .3s var(--ease);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(13,150,104,.15);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.card-icon {
  font-size: 24px;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg);
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-star {
  position: absolute;
  top: 16px; right: 16px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text3);
  transition: .2s;
  z-index: 2;
}

.card-star.starred { color: #f59e0b; }
.card-star:hover { transform: scale(1.2); }

.card-summary {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(16,185,129,.08);
  color: var(--accent);
  font-weight: 500;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text3);
}

.card-category {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.card-images {
  display: flex;
  gap: 4px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.card-images img {
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
}

.save-mode-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59,130,246,.1);
  color: var(--accent2);
}

/* ── 详情弹窗 ───────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,.15);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-header .card-icon { font-size: 28px; width: 48px; height: 48px; }

.modal-header-info { flex: 1; }
.modal-header-info h2 { font-size: 20px; font-weight: 700; line-height: 1.3; }

.modal-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text2);
  flex-wrap: wrap;
}

.modal-close {
  width: 32px; height: 32px;
  border: none; background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: .2s;
}

.modal-close:hover { background: #fee2e2; color: #ef4444; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  margin-top: 16px;
}

.modal-tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: .2s;
}

.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--accent); border-color: var(--accent); }

.modal-body { padding: 20px 24px 24px; }

.modal-body .content-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

.modal-body .content-text h1,
.modal-body .content-text h2,
.modal-body .content-text h3 { margin: 16px 0 8px; }

.modal-body .content-text pre {
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
}

.modal-body .content-text code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.modal-body .content-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text2);
}

.modal-body .source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent2);
  text-decoration: none;
  font-size: 14px;
  margin-top: 12px;
}

.modal-body .source-link:hover { text-decoration: underline; }

.modal-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.modal-images img {
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: .2s;
}

.modal-images img:hover { transform: scale(1.02); box-shadow: var(--shadow-lg); }

.chunk-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chunk-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.chunk-item summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #f8fafc;
}

.chunk-content {
  padding: 12px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text2);
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.modal-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── 添加知识弹窗 ───────────────── */

.add-form textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}

.add-form textarea:focus { border-color: var(--accent); }

.add-form .form-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.add-form input, .add-form select {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.add-form input:focus { border-color: var(--accent); }

.add-form label { font-size: 14px; font-weight: 500; display: block; margin-bottom: 6px; }

.add-form .save-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text2);
}

.toggle-switch {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: .2s;
}

.toggle-switch.on { background: var(--accent); }

.toggle-switch::after {
  content: '';
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-switch.on::after { left: 20px; }

/* ── 拖拽上传区 ─────────────────── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text3);
  cursor: pointer;
  transition: .2s;
  margin-top: 12px;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(16,185,129,.04);
  color: var(--accent);
}

.drop-zone .drop-icon { font-size: 32px; margin-bottom: 8px; }
.drop-zone p { font-size: 14px; }
.drop-zone .hint { font-size: 12px; margin-top: 4px; }

/* ── AI 对话面板 ────────────────── */

.chat-panel {
  position: fixed;
  top: 0; right: -420px; bottom: 0;
  width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0,0,0,.08);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: right .3s ease;
}

.chat-panel.open { right: 0; }

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-msg.user .chat-avatar { background: var(--gradient); color: #fff; }
.chat-msg.assistant .chat-avatar { background: var(--bg); }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.chat-msg.user .chat-bubble { background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--bg); border-bottom-left-radius: 4px; }

.chat-refs {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text3);
}

.chat-refs a {
  color: var(--accent2);
  text-decoration: none;
  cursor: pointer;
}

.chat-refs a:hover { text-decoration: underline; }

.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.chat-input-area input:focus { border-color: var(--accent); }

/* ── 空状态 ─────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; color: var(--text2); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ── 分页 ───────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: .2s;
  font-family: inherit;
}

.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--gradient); color: #fff; border-color: transparent; }
.pagination button:disabled { opacity: .4; cursor: default; }

/* ── 加载中 ─────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

.toast {
  position: fixed;
  top: 20px; right: 20px;
  padding: 12px 20px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 999;
  animation: fadeInUp .3s;
  box-shadow: var(--shadow-lg);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* ── 下拉菜单 ─────────────────── */

.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 60;
  padding: 6px;
  animation: modalIn .2s var(--ease);
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border-radius: 6px;
  transition: all .15s;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}
.dropdown-item:hover { background: rgba(13,150,104,.06); color: var(--accent); }

/* ── 知识图谱 ─────────────────── */

#graph-container {
  display: none;
  width: 100%;
  height: calc(100vh - var(--topbar-h) - 80px);
  position: relative;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
}
#graph-container.active { display: block; }
#graph-container svg { width: 100%; height: 100%; }

.graph-controls {
  position: absolute;
  top: 16px; right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.graph-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  pointer-events: none;
  z-index: 20;
  max-width: 240px;
  display: none;
}
.graph-tooltip.show { display: block; }
.graph-tooltip .tooltip-title { font-weight: 600; margin-bottom: 4px; }
.graph-tooltip .tooltip-cat { font-size: 11px; color: var(--text3); }

.graph-legend {
  position: absolute;
  bottom: 16px; left: 16px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.graph-legend-item {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.graph-legend-item:last-child { margin-bottom: 0; }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
}

/* ── 交流日志 ─────────────────── */

#logs-container { display: none; }
#logs-container.active { display: block; }

.logs-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.logs-header h3 { font-size: 18px; font-weight: 600; }

.user-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.user-chip {
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text2);
  transition: all .2s var(--ease);
}
.user-chip:hover { border-color: var(--accent); color: var(--accent); }
.user-chip.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.log-list { display: flex; flex-direction: column; gap: 8px; }

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: all .2s var(--ease);
}
.log-item:hover { box-shadow: var(--shadow); }

.log-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.log-body { flex: 1; min-width: 0; }
.log-user { font-size: 13px; font-weight: 600; color: var(--text); }
.log-content {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
  line-height: 1.5;
  word-break: break-all;
}
.log-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text3);
}
.log-badge {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
}
.log-badge.knowledge { background: var(--accent-light); color: var(--accent); }
.log-badge.chat { background: #fef3c7; color: #d97706; }

/* ── 响应式 ─────────────────────── */

.menu-toggle { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .cards-grid { grid-template-columns: 1fr; }
  .chat-panel { width: 100%; right: -100%; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 90vh; }
  .search-box .search-shortcut { display: none; }
  .topbar-actions .btn-ghost span.hide-mobile { display: none; }
  #graph-container { height: calc(100vh - var(--topbar-h) - 120px); }
}

/* ── 聊天视图 ─────────────────────── */
#chat-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, rgba(102, 126, 234, 0.05), transparent),
              radial-gradient(circle at bottom left, rgba(240, 147, 251, 0.05), transparent);
}

.chat-container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
}

#main-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  mask-image: linear-gradient(to bottom, transparent, black 5%, black 95%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 5%, black 95%, transparent);
}

/* 隐藏滚动条但保留功能 */
#main-chat-messages::-webkit-scrollbar { width: 0; background: transparent; }

.chat-input-wrapper {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  margin-top: 10px;
  transition: all 0.3s ease;
}

.chat-input-wrapper:focus-within {
  box-shadow: 0 15px 40px rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
}

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#main-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  outline: none;
  color: var(--text);
}

.chat-input-actions {
  display: flex;
  gap: 4px;
  padding-bottom: 4px;
  padding-right: 4px;
}

.btn-icon.btn-primary-icon {
  background: var(--primary);
  color: white !important;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.btn-icon.btn-primary-icon:hover {
  transform: scale(1.05);
  background: var(--accent);
}

.file-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--primary);
  animation: chatSlideUp 0.3s ease;
}

@keyframes chatSlideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 气泡美化 */
.chat-container .chat-msg .chat-bubble {
  max-width: 85%;
  line-height: 1.6;
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.chat-container .chat-msg.assistant .chat-bubble {
  background: white;
  border-bottom-left-radius: 4px;
}

.chat-container .chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-bottom-right-radius: 4px;
}

/* 拖拽态 */
.chat-container.dragging .chat-input-wrapper {
  background: rgba(102, 126, 234, 0.1);
  border: 2px dashed var(--primary);
  transform: scale(1.01);
}

@media (max-width: 768px) {
  .chat-container { padding: 10px; }
  .chat-container .chat-bubble { max-width: 90%; }
}
