/* ============================================================
   view-knowledge.css · 知识库（LLM Wiki + 知识网）
   ============================================================ */

/* ---------------- 二级栏：提问入口 ---------------- */
.kg-ask__box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.kg-ask__box:focus-within { border-color: var(--brand-400); box-shadow: var(--ring); }
.kg-ask__box > svg { color: var(--violet); flex: none; }
.kg-ask__box input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none;
  font-size: var(--fs-12); color: var(--text);
}
.kg-ask__box input::placeholder { color: var(--text-4); }

.kg-health {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: linear-gradient(150deg, #f4fbf7 0%, #f2f8ff 100%);
  border: 1px solid var(--success-bd);
}

/* ---------------- 知识网 ---------------- */
.kg-graph { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.kg-legend { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.kg-legend__item {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-11); color: var(--text-2);
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
  transition: all .15s var(--ease);
}
.kg-legend__item:hover { border-color: var(--brand-300); background: var(--brand-50); }
.kg-legend__item i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kg-legend__item span { color: var(--text-4); font-variant-numeric: tabular-nums; }

.kg-stage {
  position: relative;
  flex: 1; min-height: 0;
  background:
    radial-gradient(120% 90% at 50% 42%, #ffffff 0%, #f7f9fc 62%, #f1f5fa 100%);
  overflow: hidden;
}
.kg-canvas, .kg-stage > .tw-graph-host { position: absolute; inset: 0; }

.kg-legend-card {
  position: absolute; left: 18px; top: 16px;
  max-width: 250px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  pointer-events: none;
  z-index: 2;
}
.kg-legend-card__t {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-12); font-weight: 600; color: var(--text-2);
}
.kg-legend-card__d {
  font-size: var(--fs-11); color: var(--text-4);
  line-height: 1.7; margin-top: 5px;
}

.kg-hint {
  position: absolute; left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 13px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  font-size: var(--fs-12); color: var(--text-3);
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
}
.kg-hint > svg { color: var(--brand-500); }

/* ---------------- 条目列表 ---------------- */
.kg-list, .kg-source, .kg-gaps {
  height: 100%; overflow: auto;
  padding: 22px 24px 40px;
}

.wiki-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  transition: all .18s var(--ease);
}
.wiki-card:hover {
  border-color: var(--brand-300);
  box-shadow: var(--sh-3);
  transform: translateY(-2px);
}
.wiki-card__title { font-size: var(--fs-15); font-weight: 600; color: var(--text); }
.wiki-card__summary {
  font-size: var(--fs-12); color: var(--text-3);
  line-height: var(--lh-base); min-height: 4.95em;
}
.wiki-card__foot {
  display: flex; align-items: center; gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: var(--fs-11); color: var(--text-4);
}

/* ---------------- 条目阅读 ---------------- */
.kg-reading { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kg-reading__body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  overflow: hidden;
}
.kg-reading__aside {
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: auto;
  padding: 18px 16px 28px;
}
.kg-reading__article {
  overflow: auto;
  background: var(--bg-alt);
  border: 0; border-radius: 0; box-shadow: none;
  max-width: none; margin: 0;
  padding: 36px 56px 64px;
  font-size: var(--fs-14);
}

.wiki-outline { display: flex; flex-direction: column; gap: 1px; }
.wiki-outline__item {
  padding: 6px 9px;
  border-radius: var(--r-sm);
  font-size: var(--fs-12); color: var(--text-2);
  cursor: pointer;
  transition: background .14s var(--ease);
}
.wiki-outline__item:hover { background: var(--surface-3); color: var(--brand-700); }

.kg-reading__meta {
  display: flex; align-items: center; gap: 5px;
  justify-content: center;
  font-size: var(--fs-12); color: var(--text-4);
  margin-bottom: 22px;
}
.kg-reading__meta > svg { color: var(--violet); }
.kg-reading__lead {
  padding: 14px 16px;
  background: var(--ai-grad-soft);
  border: 1px solid #e4dcfd;
  border-radius: var(--r-md);
  color: #463a80;
  font-size: var(--fs-14);
  line-height: 1.85;
  margin-bottom: 24px;
}
.kg-reading__related {
  margin-top: 34px; padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ---------------- 来源资料 ---------------- */
.kg-drop {
  padding: 30px 24px;
  text-align: center;
  border: 1.5px dashed var(--line-dark);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #fbfcfe 0%, #f7f9fc 100%);
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.kg-drop:hover { border-color: var(--brand-400); background: var(--brand-50); }
.kg-drop__ico {
  width: 48px; height: 48px; margin: 0 auto 12px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--surface); color: var(--brand-600);
  box-shadow: var(--sh-2);
}
.kg-drop__t { font-size: var(--fs-15); font-weight: 600; }
.kg-drop__d {
  font-size: var(--fs-12); color: var(--text-3);
  line-height: 1.8; margin-top: 6px;
}

.src-row2 {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  transition: background .14s var(--ease);
}
.src-row2:last-child { border-bottom: 0; }
.src-row2:hover { background: var(--surface-2); }
.src-row2__main { flex: 1; min-width: 0; }
.src-row2__title { font-size: var(--fs-13); font-weight: 600; color: var(--text); }
.src-row2__meta { font-size: var(--fs-11); color: var(--text-4); margin-top: 3px; }
.src-row2__wiki {
  display: flex; flex-direction: column; align-items: flex-end;
  flex: none; line-height: 1.25;
}
/* 这里标的是「这份资料有没有被消化」，不是编出来的条目数 */
.src-row2__wiki b {
  font-size: var(--fs-12); font-weight: 700; color: var(--brand-600);
  white-space: nowrap;
}
.src-row2__wiki span { font-size: var(--fs-12); color: var(--text-4); white-space: nowrap; }

/* ---------------- 知识缺口 ---------------- */
.gap-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.gap-row:last-child { border-bottom: 0; }
.gap-row__ico {
  width: 32px; height: 32px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--warn-bg); color: var(--warn);
}

/* ---------------- 面板小件 ---------------- */
.kg-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.kg-neighbor {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: var(--fs-12); color: var(--text-2);
  cursor: pointer;
  transition: background .14s var(--ease);
}
.kg-neighbor:hover { background: var(--surface-3); color: var(--brand-700); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1280px) {
  .kg-toolbar__legend { display: none; }
  .kg-reading__body { grid-template-columns: 216px minmax(0, 1fr); }
  .kg-reading__article { padding: 28px 32px 48px; }
}

/* ============================================================
   知识库三级结构：总览 → 详情（知识网/条目/文件）→ 条目阅读
   ============================================================ */

.kbv-overview { height: 100%; overflow: auto; padding: 22px 24px 40px; }
.kbv-detail { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kbv-detail > .kg-stage { flex: 1; min-height: 0; }
.kbv-pane { flex: 1; min-height: 0; overflow: auto; padding: 22px 24px 40px; }

/* 知识库卡 */
.kbv-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  transition: all .18s var(--ease);
}
.kbv-card:hover { border-color: var(--brand-300); box-shadow: var(--sh-3); transform: translateY(-2px); }
.kbv-card__head { display: flex; align-items: flex-start; gap: 12px; }
.kbv-card__ico {
  width: 42px; height: 42px; flex: none;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  border: 1px solid transparent;
}
.kbv-card__name { font-size: var(--fs-15); font-weight: 600; color: var(--text); }
.kbv-card__desc {
  font-size: var(--fs-12); color: var(--text-3);
  line-height: var(--lh-base); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 3.3em;
}
.kbv-card__stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.kbv-card__stats > div { display: flex; flex-direction: column; gap: 1px; }
.kbv-card__stats b {
  font-size: var(--fs-15); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.kbv-card__stats span { font-size: var(--fs-11); color: var(--text-4); }
.kbv-card__foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
  font-size: var(--fs-11); color: var(--text-4);
  min-height: 40px;
}
.kbv-card__go {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-12); font-weight: 600; color: var(--brand-600);
  opacity: .55; transition: opacity .18s var(--ease);
}
.kbv-card:hover .kbv-card__go { opacity: 1; }

.kbv-item { align-items: flex-start; }
.kbv-dot {
  width: 24px; height: 24px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  border: 1px solid transparent;
}

/* 侧栏第一个元素：模块主操作。去掉搜索框后由它开场，
   和下面的分组标题保持与 .nav-group 一致的 14px 间距 */
.kbv-newbtn { margin-bottom: 14px; }

/* 图谱浮层工具条 */
.kg-toolbar {
  position: absolute; right: 16px; top: 16px;
  z-index: 3;
  display: flex; align-items: center; gap: 8px;
}
.kg-toolbar__legend {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 9px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}

/* 新建知识库向导 */
.kbn-ico {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
  border: 1.5px solid transparent;
  transition: all .15s var(--ease);
}
.kbn-ico:hover { background: var(--surface); border-color: var(--line-dark); color: var(--text); }
.kbn-ico.is-active { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-600); }
.kbn-tone {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all .15s var(--ease);
}
.kbn-tone.is-active { border-color: var(--text); transform: scale(1.1); }

/* 添加资料弹窗 */
.up-type {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 11px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--text-2);
}
/* 真正负责选文件的 input：视觉隐藏但仍可被脚本/键盘触发 */
.kg-file-input {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.up-type > svg { color: var(--brand-500); }
.up-pool {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 240px; overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.up-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all .14s var(--ease);
}
.up-item:hover { border-color: var(--brand-300); }
.up-item.is-on { border-color: var(--success-bd); background: #f7fdf9; }
.up-item__t { display: block; font-size: var(--fs-12); font-weight: 400; color: var(--text); }
.up-item__d { display: block; font-size: var(--fs-11); color: var(--text-4); margin-top: 1px; }

/* ============================================================
   文件页空态
   ============================================================ */
.kg-file-empty { margin-top: 18px; }

/* ============================================================
   知识库「文件」视图：搜索框 + 4 组筛选（类型 / 知识库 / 时间 / 多模态）
   浏览式检索是控件，不是页面，所以整块控制在文件视图顶部
   ============================================================ */
.kgf-bar {
  padding: 12px 14px 6px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.kgf-searchrow { align-items: center; margin-bottom: 10px; }
.kgf-searchrow .searchbox { height: 34px; }
.kgf-count {
  flex: none;
  font-size: var(--fs-12); color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.kgf-filters {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.kgf-fgroup { display: flex; align-items: flex-start; gap: 10px; }
.kgf-fgroup__label {
  flex: none; width: 56px; padding-top: 5px;
  font-size: var(--fs-12); font-weight: 600; color: var(--text-4);
}
.kgf-fgroup__body { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.kgf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: var(--fs-12); line-height: 1;
  cursor: pointer;
  transition: all .14s var(--ease);
}
.kgf-chip:hover { border-color: var(--brand-300); color: var(--text); }
.kgf-chip.is-active {
  background: var(--brand-50); border-color: var(--brand-400);
  color: var(--brand-700); font-weight: 600;
}
.kgf-chip--sw { padding-left: 8px; }
.kgf-chip--sw > svg { color: var(--text-4); }
.kgf-chip--sw.is-active > svg { color: var(--brand-600); }

/* 命中片段：摊在文件条目下面，带上出处（页码 / 时间戳） */
.kgf-row { align-items: flex-start; }
.kgf-hits {
  margin-top: 7px;
  display: flex; flex-direction: column; gap: 4px;
}
.kgf-hit {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
}
.kgf-hit__at {
  flex: none; padding-top: 1px;
  font-size: var(--fs-12); font-weight: 600; color: var(--brand-700);
  font-variant-numeric: tabular-nums;
}
.kgf-hit__text {
  font-size: var(--fs-12); line-height: 1.6; color: var(--text-2);
  word-break: break-word;
}
.kgf-hit--more { background: none; border-color: transparent; color: var(--text-4); padding: 0 9px; }
.kgf-hit--more { font-size: var(--fs-12); }

/* 没有检索词时：一行内容摘要，说明这份资料里写了什么 */
.kgf-summary {
  margin-top: 6px;
  font-size: var(--fs-12); line-height: 1.6; color: var(--text-3);
}

/* 命中高亮：浅黄底 + 字重 600，只标命中的那几个字 */
.kgf-hit mark, .kgf-summary mark, .kgf-row mark {
  background: #fef3c7; color: var(--text);
  font-weight: 600; padding: 0 1px; border-radius: 2px;
}

/* 数字口径说明：列出的是建模样例，真实库规模另说 */
.kgf-note {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: var(--fs-12); line-height: 1.6; color: var(--text-4);
}
.kgf-note > svg { flex: none; margin-top: 2px; }
.kgf-note b { color: var(--text-2); }
.kgf-note--page {
  margin: -6px 0 22px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.kgf-fgroup__hint { align-self: center; font-size: var(--fs-12); color: var(--text-4); }

/* 拖拽条收敛成一条，不再占据文件视图的大块版面 */
.kgf-drop--slim {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 16px;
}
.kgf-drop--slim .kg-drop__ico { margin: 0; }
.kgf-drop--slim .kg-drop__t { font-size: var(--fs-13); }
.kgf-drop--slim .kg-drop__d { font-size: var(--fs-12); margin-top: 2px; }

@media (max-width: 1280px) {
  .kgf-fgroup__label { width: 48px; }
}

/* ============================================================
   条目出处：卡片可点回原件 + 正文上标可跳到对应出处
   ============================================================ */

/* 出处卡片（.ref-card 的基础样式在 views.css，这里是它作为 <button> 的补充：
   左对齐、撑满侧栏、点击区域不小于 24px，并容纳 文件名 / 出处位置 / 原文片段 三行） */
.kg-reading__aside .ref-card {
  width: 100%;
  text-align: left;
  align-items: flex-start;
  font: inherit;
  color: inherit;
  min-height: 44px;
}
.kg-reading__aside .ref-card__main {
  display: flex; flex-direction: column;
  flex: 1; min-width: 0;
}
.kg-reading__aside .ref-card__quote {
  margin-top: 5px;
  font-size: var(--fs-12); font-weight: 400;
  line-height: 1.6; color: var(--text-3);
  word-break: break-word;
}
.kg-reading__aside .ref-card__go { flex: none; margin-top: 1px; color: var(--text-4); }
.kg-reading__aside .ref-card:hover .ref-card__go { color: var(--brand-600); }

/* 从正文上标跳过来的那条：短暂高亮（1.5s 后由 JS 摘掉这个类） */
.kg-reading__aside .ref-card.is-flash {
  border-color: var(--brand-400);
  background: var(--brand-50);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

/* 正文里的上标引用：点了跳到下方对应出处。
   在 .cite 的基础上把点击区域做到 24×24，并保证可聚焦、有 hover 反馈。 */
.wiki-cite {
  border: 0;
  min-width: 24px; height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: inherit;
  font-size: var(--fs-12); font-weight: 600;
  background: var(--brand-50); color: var(--brand-700);
  vertical-align: super;
  cursor: pointer;
}
.wiki-cite:hover { background: var(--brand-600); color: #fff; }
.wiki-cite:focus-visible {
  outline: 2px solid var(--brand-500); outline-offset: 1px;
}
