/* ============================================================
   知识图谱 · 设计系统
   浅色 / 深色双主题 · 三栏布局 · 面向生产环境的界面规范
   ------------------------------------------------------------
   约定：
   - 颜色、圆角、阴影、字号全部走变量，主题切换只换变量
   - 所有可交互元素都有 hover / active / focus-visible / disabled 四态
   - 数字统一 tabular-nums，避免统计数值跳动
   ============================================================ */

/* ============================================================
   1. 设计令牌
   ============================================================ */
:root {
  color-scheme: light;

  /* 背景与表面 */
  --bg: #f5f6f8;
  --bg-subtle: #eef0f4;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --surface-hover: #f7f8fa;

  /* 描边 */
  --border: #e5e7ec;
  --border-2: #eef0f4;
  --border-strong: #d3d7de;

  /* 文字 */
  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --text-inverse: #ffffff;

  /* 主色 */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-active: #3730a3;
  --primary-soft: #eef2ff;
  --primary-soft-2: #e0e7ff;
  --primary-border: #c7d2fe;
  --primary-text: #3730a3;

  /* 语义色 */
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --info-border: #bae6fd;

  /* 阴影：分层、低对比，避免"发闷" */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px -1px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 26px -8px rgba(16, 24, 40, .12), 0 4px 10px -6px rgba(16, 24, 40, .06);
  --shadow-xl: 0 28px 56px -16px rgba(16, 24, 40, .22), 0 8px 20px -12px rgba(16, 24, 40, .1);
  --ring: 0 0 0 3px rgba(79, 70, 229, .16);

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 999px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* 导图配色：深色根节点 → 靛蓝一级 → 天蓝二级 → 白色叶子 */
  --mm-root: #101828;
  --mm-root-ring: #101828;
  --mm-l1: #4f46e5;
  --mm-l2: #0284c7;
  --mm-leaf: #ffffff;
  --mm-leaf-border: #dfe3ea;
  --mm-leaf-text: #1d2939;
  --mm-link: #d5dae3;
  --mm-hit: #f59e0b;
  --mm-selected: #4f46e5;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0c11;
  --bg-subtle: #0e1116;
  --surface: #12151c;
  --surface-2: #171b23;
  --surface-3: #1c212b;
  --surface-hover: #1a1f28;

  --border: #262c37;
  --border-2: #1f242e;
  --border-strong: #39414f;

  --text: #e9ecf1;
  --text-2: #98a2b3;
  --text-3: #667085;
  --text-inverse: #ffffff;

  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --primary-active: #818cf8;
  --primary-soft: rgba(99, 102, 241, .14);
  --primary-soft-2: rgba(99, 102, 241, .22);
  --primary-border: rgba(99, 102, 241, .42);
  --primary-text: #a5b4fc;

  --success: #34d399;
  --success-soft: rgba(16, 185, 129, .13);
  --success-border: rgba(16, 185, 129, .34);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, .13);
  --warning-border: rgba(245, 158, 11, .34);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: rgba(239, 68, 68, .13);
  --danger-border: rgba(239, 68, 68, .34);
  --info: #38bdf8;
  --info-soft: rgba(14, 165, 233, .13);
  --info-border: rgba(14, 165, 233, .34);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px -1px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, .5), 0 2px 4px -2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 26px -8px rgba(0, 0, 0, .6), 0 4px 10px -6px rgba(0, 0, 0, .4);
  --shadow-xl: 0 28px 56px -16px rgba(0, 0, 0, .8), 0 8px 20px -12px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(99, 102, 241, .28);

  --mm-root: #6366f1;
  --mm-root-ring: #6366f1;
  --mm-l1: #4f46e5;
  --mm-l2: #0284c7;
  --mm-leaf: #1b202a;
  --mm-leaf-border: #2f3643;
  --mm-leaf-text: #d7dce5;
  --mm-link: #333b48;
  --mm-hit: #fbbf24;
  --mm-selected: #818cf8;
}

/* ============================================================
   2. 基础
   ============================================================ */
* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }

/* ------------------------------------------------------------
   链接：默认不带下划线，悬停时才出现。
   之前这里没有任何 a 规则，于是正文里那几个行内链接
   （如「先到知识录入…」「可在设置里…」）带上了浏览器默认的
   蓝色下划线，跟整套配色对不上。
   按钮 / 导航 / 卡片这类「长得像按钮」的链接永远不下划线。
   ------------------------------------------------------------ */
a {
  color: var(--primary);
  text-decoration: none;
  text-underline-offset: 2px;
  transition: color .12s;
}
a:hover { color: var(--primary-hover); text-decoration: underline; }
.btn, .btn:hover,
.navitem, .navitem:hover,
.brand, .brand:hover,
.stat-card, .stat-card:hover,
.card, .card:hover,
.cat-row, .cat-row:hover,
.mm-node, .mm-node:hover,
.tab, .tab:hover { text-decoration: none; }

code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}
strong { font-weight: 650; }

/* 统一焦点样式，键盘可达性 */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* 图标容器 */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
.ico svg { display: block; }

/* ============================================================
   3. 顶栏与页面导航
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 58px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  flex: 0 0 auto;
}
.brand .logo-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.brand .logo-mark svg { width: 34px; height: 34px; display: block; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-txt b { font-size: 14px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-txt small { font-size: 10.5px; color: var(--text-3); white-space: nowrap; letter-spacing: .005em; }

/* 页面导航 */
.mainnav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }

.navitem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.navitem .ico svg { width: 15px; height: 15px; }
.navitem:hover { background: var(--surface-3); color: var(--text); }
.navitem.on {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 620;
}
.navitem.on .ico { color: var(--primary); }

.topactions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.topactions { display: flex; align-items: center; gap: 6px; }

/* 右侧栏开关：只在中等及以下宽度出现（宽屏三栏并排，不需要开关） */
#btnToggleRight { display: none; }
@media (max-width: 1280px) {
  #btnToggleRight { display: inline-flex; }
}

/* 图标按钮 */
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { background: var(--border-2); }
.icon-btn.on {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ico svg { width: 15px; height: 15px; }

/* 状态徽标 */
.ai-badge {  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: .02em;
  padding: 4px 9px 4px 8px;
  border-radius: var(--r-full);
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
  white-space: nowrap;
  cursor: default;
}
.ai-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.ai-badge.off {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

/* ============================================================
   4. 页面容器（多页面：每页一个主内容区，不再挤三栏）
   ============================================================ */
.page {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.page.wide { max-width: none; padding: 14px 18px 18px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -.02em;
  line-height: 1.3;
  margin: 0;
}
.page-head .desc {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.65;
}
.page-head .desc b { color: var(--text); font-weight: 620; font-variant-numeric: tabular-nums; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 概览卡片栅格 */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-card .sc-ico {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  flex: 0 0 auto;
}
.stat-card .sc-body { min-width: 0; }
.stat-card .sc-body b {
  display: block;
  font-size: 22px;
  font-weight: 660;
  line-height: 1.25;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .sc-body span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.stat-card.warn { border-color: var(--warning-border); background: var(--warning-soft); }
.stat-card.warn .sc-ico { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.stat-card.warn .sc-body b { color: var(--warning); }
.stat-card.danger { border-color: var(--danger-border); background: var(--danger-soft); }
.stat-card.danger .sc-ico { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.stat-card.danger .sc-body b { color: var(--danger); }

/* 通用卡片栅格 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 640;
  margin: 0;
}
.card h3 .ico { color: var(--text-3); }
.card h3 .ico svg { width: 16px; height: 16px; }
.card p { font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin: 0; }

/* 两栏 / 三栏表单行 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* 页面内的分栏（只用于知识库这类需要左右分栏的页面） */
.split {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* ============================================================
   5. 面板
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-2);
  background: linear-gradient(var(--surface), var(--surface-2));
}
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 640;
  letter-spacing: -.005em;
  color: var(--text);
}
.panel-head h2 .ico { color: var(--text-3); }
.panel-head h2 .ico svg { width: 15px; height: 15px; }

.panel-body {
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
}
.panel-body.scroll { overflow-y: auto; flex: 1 1 auto; }
.panel-body.scroll.short { max-height: 232px; }
.panel-body.tall { max-height: 62vh; overflow-y: auto; }

.hint {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   6. 表单控件
   ============================================================ */
textarea,
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
.search-input {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
  box-shadow: var(--shadow-xs);
}
textarea::placeholder,
input::placeholder { color: var(--text-3); }

textarea:hover,
input[type="text"]:hover,
input[type="password"]:hover,
input[type="date"]:hover,
input[type="number"]:hover,
select:hover,
.search-input:hover { border-color: var(--text-3); }

textarea:focus,
input:focus,
select:focus,
.search-input:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

textarea {
  resize: vertical;
  line-height: 1.7;
  min-height: 104px;
  background: var(--surface-2);
}
textarea:focus { background: var(--surface); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.6 9.6L12 15l5.4-5.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 30px;
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.6 9.6L12 15l5.4-5.4'/%3E%3C/svg%3E");
}

.search-input { padding: 6px 10px; font-size: 12px; }
.search-input.full { width: 100%; }

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .5;
  transition: opacity .15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: .9; }

.input-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.input-meta .dot { opacity: .45; }

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.inline-field > span { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.inline-field > span .ico svg { width: 14px; height: 14px; }
.inline-field input { flex: 1 1 auto; }

.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ============================================================
   7. 按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 580;
  padding: 0 13px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: translateY(.5px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-xs); }
.btn .ico svg { width: 15px; height: 15px; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active { background: var(--primary-active); border-color: var(--primary-active); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}
.btn.ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }

.btn.ok {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}
.btn.ok:hover { background: color-mix(in srgb, var(--success) 14%, var(--surface)); }

.btn.danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--r-xs); gap: 5px; }
.btn.sm .ico svg { width: 14px; height: 14px; }

.btn.link {
  height: auto;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 560;
}
.btn.link:hover { text-decoration: underline; background: none; }

/* ============================================================
   8. 分段控件（标签页）
   ============================================================ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 2px;
  border-radius: var(--r-sm);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 560;
  padding: 3px 9px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--text); }
.tab b {
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  opacity: .8;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.tab.active b { opacity: 1; color: var(--primary); }

/* ============================================================
   9. 复习清单
   ============================================================ */
.review-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 660;
  letter-spacing: .06em;
  color: var(--text-3);
  margin: 6px 0 1px;
}
.review-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-2);
}
.review-group-title .ico svg { width: 13px; height: 13px; }

.review-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 11px 10px 13px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .16s, border-color .16s;
}
.review-card::before {
  content: '';
  position: absolute;
  left: -1px; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--warning);
}
.review-card.overdue::before { background: var(--danger); }
.review-card.done::before { background: var(--success); }

.review-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.review-card.done { background: var(--surface-2); }

.rc-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.rc-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 620;
  font-size: 12.5px;
  line-height: 1.45;
  letter-spacing: -.005em;
}
.rc-body {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.62;
  margin: 0 0 8px;
}
.rc-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.rc-actions { display: flex; gap: 6px; margin-top: 9px; }

/* 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 580;
  padding: 1.5px 7px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.badge.cat {
  background: var(--primary-soft);
  color: var(--primary-text);
  border-color: var(--primary-border);
}
.badge.seq {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info-border);
}
.badge.over {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
  font-weight: 640;
}
.badge.done {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}
.badge.mastery {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}

/* ============================================================
   10. 思维导图
   ============================================================ */
.map-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

/* 工具栏 + 画布的舞台：全屏时整块一起进全屏，工具栏跟着进去，
   所以全屏下依然能缩放 / 搜索 / 导出 / 退出 */
.map-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}
.tb-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}
.tb-group.plain { background: transparent; padding: 0; gap: 5px; }
.tb-group:last-child { margin-left: auto; }
.tb-group .btn.ghost { height: 26px; padding: 0 9px; font-size: 11.5px; }
.tb-group .btn.ghost:hover { background: var(--surface); box-shadow: var(--shadow-xs); }
.tb-group .icon-btn.sm { width: 26px; height: 26px; }
.tb-group .icon-btn.sm:hover { background: var(--surface); box-shadow: var(--shadow-xs); }
.tb-group .search-input {
  width: 152px; height: 26px; padding: 0 9px;
  border-color: transparent; background: transparent; box-shadow: none;
}
.tb-group .search-input:hover { border-color: var(--border-strong); }
.tb-group .search-input:focus { border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); }

.zoom-label {
  font-size: 11.5px;
  color: var(--text-2);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}

.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
  height: calc(100vh - 220px);
  background-color: var(--surface);
  background-image: radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0);
  background-size: 22px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

#mindmap { width: 100%; height: 100%; display: block; cursor: grab; }
#mindmap.dragging { cursor: grabbing; }
#mindmap.hidden { display: none; }

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
  text-align: center;
  pointer-events: none;
  padding: 24px;
}
.map-empty.hidden { display: none; }
.map-empty .me-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: var(--r-xl);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-3);
  margin-bottom: 6px;
}
.map-empty .me-icon svg { width: 26px; height: 26px; }
.map-empty p { font-size: 14px; font-weight: 620; color: var(--text-2); }
.map-empty span { font-size: 12px; line-height: 1.75; max-width: 340px; }

.map-tip {
  position: absolute;
  left: 10px;
  bottom: 9px;
  font-size: 10.5px;
  color: var(--text-3);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border-2);
  padding: 3px 9px;
  border-radius: var(--r-full);
  pointer-events: none;
}
.map-tip b { color: var(--text-2); font-weight: 650; }

/* ------------------------------------------------------------
   全屏
   ------------------------------------------------------------
   两条路：
   ① 浏览器支持 Fullscreen API → 真全屏，工具栏一起进去
   ② 不支持 / 被策略拦住 → 加 .is-fullscreen，用固定定位铺满视口兜底
   两种状态下 .map-wrap 都要放开原来按视口算的高度，改成撑满剩余空间。
   ------------------------------------------------------------ */
.map-stage:fullscreen { padding: 12px; background: var(--bg); }
.map-stage.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 900;
  padding: 12px;
  background: var(--bg);
}
.map-stage:fullscreen .map-wrap,
.map-stage.is-fullscreen .map-wrap {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--r-md);
}
/* 兜底全屏时锁住页面滚动，避免背景跟着动 */
body.map-locked { overflow: hidden; }

/* --- SVG 节点 --- */
.mm-link {
  fill: none;
  stroke: var(--mm-link);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.mm-node { cursor: pointer; }
.mm-node rect { transition: filter .15s, stroke-width .15s; }
.mm-node:hover rect { filter: brightness(.97); }
[data-theme="dark"] .mm-node:hover rect { filter: brightness(1.3); }

.mm-node text {
  font-family: var(--font);
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
  /* 字号必须与 app.js 的 MM.FS 保持一致，否则节点宽度计算会失准 */
}
.mm-node.knowledge text { font-size: 12.5px; font-weight: 400; fill: var(--mm-leaf-text); }
.mm-node.category text { font-size: 13px; font-weight: 600; fill: #fff; }
.mm-node.root text { font-size: 15px; font-weight: 700; fill: #fff; }

.mm-node.knowledge rect {
  fill: var(--mm-leaf);
  stroke: var(--mm-leaf-border);
  stroke-width: 1;
  rx: 7; ry: 7;
}
.mm-node.category.l1 rect { fill: var(--mm-l1); stroke: none; rx: 8; ry: 8; }
.mm-node.category.l2 rect { fill: var(--mm-l2); stroke: none; rx: 8; ry: 8; }
.mm-node.root rect { fill: var(--mm-root); stroke: none; rx: 10; ry: 10; }

.mm-count { font-size: 10px !important; fill: #fff !important; opacity: .8; font-weight: 500; }
.mm-collapse-dot { fill: rgba(255, 255, 255, .92); }

.mm-node.selected rect { stroke: var(--mm-selected); stroke-width: 2.5; }
.mm-node.hit rect { stroke: var(--mm-hit); stroke-width: 2.5; }
.mm-node.dim { opacity: .26; }

/* ============================================================
   11. 分类树
   ============================================================ */
.cat-node { user-select: none; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  transition: background .12s, color .12s;
}
.cat-row:hover { background: var(--surface-3); color: var(--text); }
.cat-row.active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}
.cat-row .caret {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-3);
  transition: transform .15s;
  flex: 0 0 auto;
}
.cat-row.collapsed .caret { transform: rotate(-90deg); }
.cat-row .caret .ico svg { width: 12px; height: 12px; }
.cat-row .cat-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-row .cat-count {
  font-size: 10.5px;
  color: var(--text-3);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  padding: 0 3px;
}
.cat-row.active .cat-count { color: var(--primary); }
.cat-row .cat-acts { display: none; gap: 1px; flex: 0 0 auto; }
.cat-row:hover .cat-acts { display: flex; }
.cat-acts button {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-3);
  border-radius: var(--r-xs);
  transition: background .12s, color .12s;
}
.cat-acts button:hover { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.cat-acts button .ico svg { width: 13px; height: 13px; }
.cat-acts button[data-cat-del]:hover { color: var(--danger); }

.cat-children {
  margin-left: 13px;
  border-left: 1px solid var(--border);
  padding-left: 5px;
}

/* ============================================================
   12. 知识列表
   ============================================================ */
.kb-list {
  max-height: 268px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}
.kb-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  background: var(--surface);
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.kb-item:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
  background: var(--surface-2);
}
.kb-item .kb-t {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.45;
  letter-spacing: -.005em;
}
.kb-item .kb-c {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-item .kb-m {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 5px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   13. 历史记录
   ============================================================ */
.hist-item {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.hist-item:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
  background: var(--surface-2);
}
.hist-item .h-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.hist-item .h-date {
  font-size: 11.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.hist-item .h-sum {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.hist-item .h-prev {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   14. 空状态 / 骨架屏
   ============================================================ */
.empty {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  padding: 22px 8px;
  line-height: 1.9;
}
.empty b { display: block; color: var(--text-2); font-weight: 600; font-size: 12.5px; }

.skeleton {
  height: 54px;
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============================================================
   15. 弹窗
   ============================================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, .55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-mask.show { display: flex; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: min(760px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.05);
}
@keyframes pop {
  from { transform: translateY(8px) scale(.985); opacity: .5; }
  to { transform: none; opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-2);
}
.modal-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 640;
  letter-spacing: -.01em;
}
.modal-head h3 .ico { color: var(--primary); }
.modal-head h3 .ico svg { width: 17px; height: 17px; }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.modal-foot {
  padding: 11px 16px;
  border-top: 1px solid var(--border-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}
.modal-foot:empty { display: none; }

/* 表单域 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 620;
  color: var(--text-2);
  letter-spacing: .005em;
}
.field .desc {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.7;
}
.field .desc code { font-size: 10.5px; }

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 7px 12px;
  font-size: 12.5px;
}
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.orig-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 复习时间线 */
.review-timeline { display: flex; flex-direction: column; gap: 5px; }
.tl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
}
.tl-item.done { border-left-color: var(--success); }
.tl-item.pending { border-left-color: var(--warning); }
.tl-item .tl-seq { font-weight: 620; min-width: 52px; }
.tl-item .tl-date { color: var(--text-2); min-width: 92px; }
.tl-item .tl-st { margin-left: auto; font-size: 11px; color: var(--text-3); }

/* 整理结果 */
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.result-cell {
  text-align: center;
  padding: 12px 6px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.result-cell b {
  display: block;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 660;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.result-cell span { font-size: 11px; color: var(--text-3); }
.result-cell.ok b { color: var(--success); }
.result-cell.dup b { color: var(--warning); }
.result-cell.cat b { color: var(--primary); }

.item-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 13px;
  background: var(--surface-2);
}
.item-card .ic-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.item-card .ic-title {
  font-weight: 620;
  font-size: 12.5px;
  letter-spacing: -.005em;
}
.item-card .ic-content { font-size: 12.5px; line-height: 1.7; }
.item-card .ic-orig {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  line-height: 1.65;
}
.item-card.merged { background: var(--surface-3); }

/* 统计看板图表（概览数字卡在 .stat-cards，见第 4 节） */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
  padding: 8px 0 0;
  border-bottom: 1px solid var(--border);
}
.bar-chart .bar {
  flex: 1 1 0;
  background: linear-gradient(var(--primary), color-mix(in srgb, var(--primary) 62%, var(--surface)));
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  opacity: .82;
  transition: opacity .15s;
}
.bar-chart .bar:hover { opacity: 1; }
.chart-labels {
  display: flex;
  gap: 3px;
  font-size: 9.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.chart-labels span {
  flex: 1 1 0;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

/* ============================================================
   16. 提示条
   ============================================================ */
.toast-wrap {
  position: fixed;
  top: 68px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 11px 15px 11px 17px;
  font-size: 12.5px;
  max-width: 350px;
  line-height: 1.6;
  pointer-events: auto;
  animation: slideIn .2s cubic-bezier(.2, .9, .3, 1.05);
}
.toast::before {
  content: '';
  position: absolute;
  left: -1px; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.toast.ok::before { background: var(--success); }
.toast.err::before { background: var(--danger); }
.toast.warn::before { background: var(--warning); }
.toast b { display: block; margin-bottom: 2px; font-weight: 640; font-size: 12.5px; }
@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============================================================
   17. 加载遮罩
   ============================================================ */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 20, .42);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.loading-mask.show { display: flex; }
.loading-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px 36px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  text-align: center;
  min-width: 272px;
}
.loading-box p { margin: 15px 0 3px; font-size: 13.5px; font-weight: 620; }
.loading-box span { font-size: 11.5px; color: var(--text-3); }
.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   18. 滚动条
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ============================================================
   19. 响应式
   ============================================================ */
@media (max-width: 1180px) {
  .split { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .brand-txt small { display: none; }
  .navitem span { display: none; }
  .navitem { padding: 8px 10px; }
  .page { padding: 16px 14px 48px; }
  .split { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .map-wrap { height: 68vh; }
  .page-head { align-items: flex-start; }
}
@media (max-width: 620px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand .logo-mark, .brand .logo-mark svg { width: 30px; height: 30px; }
  .ai-badge { display: none; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
