/* ============================================================
   全局样式 — 严格遵循 Design.md
   ============================================================ */

:root {
  /* 色彩 Token */
  --color-primary:        #2D7DD2;
  --color-primary-dark:    #1B5FA8;
  --color-primary-light:  #E8F4FD;
  --color-secondary:      #38B2AC;
  --color-accent:         #6C5CE7;
  --color-bg:             #F0F7FF;
  --color-surface:        rgba(255, 255, 255, 0.85);
  --color-surface-solid:  #FFFFFF;
  --color-text-primary:   #1A202C;
  --color-text-secondary: #64748B;
  --color-text-muted:     #94A3B8;
  --color-border:         #E2E8F0;
  --color-danger:         #E53E3E;
  --color-success:        #38A169;
  --color-warning:        #D69E2E;
  --color-node-chapter:   #553C9A;
  --color-node-kp:        #2B6CB0;
  --color-node-formula:   #276749;
  --color-node-concept:   #C05621;

  /* 渐变 */
  --grad-primary:  linear-gradient(135deg, #2D7DD2 0%, #5B9FE3 100%);
  --grad-brand:    linear-gradient(135deg, #2D7DD2 0%, #6C5CE7 100%);
  --grad-tutor:    linear-gradient(135deg, #2D7DD2 0%, #38B2AC 100%);
  --grad-quiz:     linear-gradient(135deg, #F59E0B 0%, #EF7C3C 100%);
  --grad-reading:  linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);

  /* 圆角 */
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* 阴影 —— 轻量弥散，扩散范围更大、更通透 */
  --shadow-xs:         0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-card:       0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 0 16px 40px rgba(45, 125, 210, 0.12);
  --shadow-pop:        0 16px 48px rgba(15, 23, 42, 0.10);

  /* 统一过渡曲线 */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--color-text-primary);
  background:
    radial-gradient(1100px 520px at 8% 2%, rgba(108, 92, 231, 0.30), transparent 55%),
    radial-gradient(1100px 560px at 100% 6%, rgba(56, 178, 172, 0.32), transparent 52%),
    radial-gradient(900px 600px at 88% 78%, rgba(45, 125, 210, 0.28), transparent 60%),
    radial-gradient(1000px 640px at 14% 95%, rgba(107, 114, 207, 0.28), transparent 62%),
    linear-gradient(180deg, #D9E8F8 0%, #DCEAF6 40%, #E4E2F6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(45, 125, 210, 0.18); }
/* 细滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.28); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.45); background-clip: content-box; }

h1, h2, h3, h4 { line-height: 1.3; }
code, pre { font-family: "JetBrains Mono", monospace; }

/* ── 顶部导航 ─────────────────────────────────── */
.navbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 6px 24px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--color-text-primary);
}
.navbar .brand svg { width: 26px; height: 26px; color: var(--color-primary); }
.navbar .brand span {
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.navbar .nav-actions { display: flex; align-items: center; gap: 6px; }
.navbar .nav-link {
  position: relative;
  font-size: 0.92rem; font-weight: 600;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 7px 14px; border-radius: var(--radius-sm);
  transition: color .2s var(--ease-out), background .2s var(--ease-out);
}
.navbar .nav-link::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 4px;
  height: 2px; border-radius: 2px;
  background: var(--grad-brand);
  transform: scaleX(0); transform-origin: left;
  transition: transform .25s var(--ease-out);
}
.navbar .nav-link:hover {
  color: var(--color-primary);
  background: rgba(45, 125, 210, 0.07);
}
.navbar .nav-link:hover::after { transform: scaleX(1); }
@media (max-width: 767px) {
  .navbar .nav-link { display: none; }
}

/* 返回主页：半透明玻璃质感胶囊按钮（右上角）*/
.back-home-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.9rem; font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.45));
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 4px 16px rgba(31,45,80,0.10), inset 0 1px 0 rgba(255,255,255,0.7);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), background .2s var(--ease-out);
}
.back-home-btn svg { width: 16px; height: 16px; }
.back-home-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.7));
  box-shadow: 0 8px 22px rgba(45,125,210,0.18), inset 0 1px 0 rgba(255,255,255,0.85);
}
.back-home-btn:active { transform: translateY(0); }

/* ── 按钮 ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s ease, transform .15s ease;
}
.btn:hover  { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(0.95); }
.btn:disabled, .btn.disabled {
  opacity: 0.4; cursor: not-allowed;
  filter: none; transform: none;
}
.btn-primary   {
  background: var(--grad-primary); color: #fff;
  box-shadow: 0 6px 18px rgba(45, 125, 210, 0.32);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(45, 125, 210, 0.42); }
.btn-secondary {
  background: rgba(255,255,255,0.8); color: var(--color-primary);
  border: 1px solid var(--color-border); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-ghost     { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: rgba(100,116,139,0.1); color: var(--color-text-primary); }
.btn-sm        { padding: 5px 14px; font-size: 0.875rem; }
.btn svg { width: 20px; height: 20px; }

/* ── 输入框 ───────────────────────────────────── */
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid #CBD5E0;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text-primary);
  transition: box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  border-color: var(--color-primary);
}

/* ── 卡片 ─────────────────────────────────────── */
.card {
  background: linear-gradient(155deg, rgba(255,255,255,0.78), rgba(255,255,255,0.58));
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: box-shadow .25s var(--ease-out), transform .25s var(--ease-out);
}
.card:hover { box-shadow: var(--shadow-card-hover), inset 0 1px 0 rgba(255,255,255,0.6); }

/* ── 首页 ─────────────────────────────────────── */
.home {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 36px;
}

/* 青绿渐变 Hero Banner */
.home-hero {
  position: relative;
  border-radius: 28px;
  min-height: 440px;
  padding: 40px;
  background: linear-gradient(135deg, #46C7B0 0%, #34C2C9 45%, #2BB6DA 100%);
  box-shadow: 0 20px 50px rgba(45, 180, 190, 0.18);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.home-logo, .home-hero-center { position: relative; z-index: 1; }
.home-hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(700px 360px at 85% 120%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
/* 车辆系统动力学线框暗纹 */
.hero-pattern {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}
.home-logo {
  position: absolute; top: 32px; left: 36px;
  display: flex; align-items: center; gap: 12px;
}
.logo-emblem {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.9); color: #15418A;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.logo-emblem svg { width: 28px; height: 28px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; color: #123E86; }
.logo-text b { font-size: 1.3rem; font-weight: 800; letter-spacing: 2px; }
.logo-text i { font-size: 0.66rem; font-style: normal; letter-spacing: 1.5px; opacity: 0.9; }
.home-hero-center { text-align: center; position: relative; z-index: 1; }
.home-hero-center h1 {
  font-size: 4rem; font-weight: 800; color: #fff;
  letter-spacing: 4px;
  text-shadow: 0 4px 16px rgba(0,0,0,0.14);
}
.home-hero-center .subtitle {
  font-size: 1.3rem; color: rgba(255,255,255,0.96);
  margin-top: 14px; letter-spacing: 3px;
}

/* 功能卡片容器 */
.home-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  margin-top: 26px;
  padding: 26px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255,255,255,0.28), rgba(255,255,255,0.12));
  border: 1px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.home-card {
  --accent: var(--color-primary);
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 14px;
  padding: 32px 22px 28px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,0.72), rgba(255,255,255,0.48));
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  border: 1px solid rgba(255,255,255,0.75);
  box-shadow: 0 10px 30px rgba(31,45,80,0.08), inset 0 1px 0 rgba(255,255,255,0.65);
  text-decoration: none; color: var(--color-text-primary);
  transition: transform .28s var(--ease-out), box-shadow .28s var(--ease-out), border-color .28s var(--ease-out);
}
/* 顶部按强调色透出一抹光晕，弱化纯白感 */
.home-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
  opacity: 0.7; pointer-events: none;
}
.home-card > * { position: relative; z-index: 1; }
.home-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 46px color-mix(in srgb, var(--accent) 16%, rgba(15,23,42,0.10)),
              inset 0 1px 0 rgba(255,255,255,0.75);
  border-color: color-mix(in srgb, var(--accent) 40%, white);
}
.hc-icon {
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, white);
  color: var(--accent);
  transition: transform .28s var(--ease-out), background .28s var(--ease-out);
}
.home-card:hover .hc-icon { transform: scale(1.08) translateY(-2px); }
.hc-icon svg { width: 34px; height: 34px; stroke-width: 2; }
.home-card h3 { font-size: 1.25rem; font-weight: 700; }
.home-card p {
  font-size: 0.9rem; color: var(--color-text-secondary);
  line-height: 1.7; flex: 1; min-height: 48px;
}
/* 幽灵按钮：默认彩色边框 + 文字，Hover 填充实心 */
.hc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 26px; border-radius: 999px;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid color-mix(in srgb, var(--accent) 55%, white);
  font-size: 0.92rem; font-weight: 600;
  transition: background .25s var(--ease-out), color .25s var(--ease-out),
              border-color .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.home-card:hover .hc-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 32%, transparent);
}

/* 四色强调 —— 仅以 --accent 区分，图标/按钮风格统一 */
.home-card.accent-graph   { --accent: #6C5CE7; }
.home-card.accent-tutor   { --accent: #16A34A; }
.home-card.accent-quiz    { --accent: #2D7DD2; }
.home-card.accent-reading { --accent: #F59E0B; }

.home-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  padding: 28px 0 8px;
}
.home-admin-link { color: var(--color-text-muted); text-decoration: none; }
.home-admin-link:hover { color: var(--color-primary); text-decoration: underline; }

/* ── 登录 / 注册 ─────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 24px;
}
.auth-card {
  width: 400px;
  max-width: 100%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card h2 { font-size: 1.5rem; text-align: center; }
.auth-card label {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: 4px;
}
.auth-card input { width: 100%; }
.auth-card .form-error {
  color: var(--color-danger);
  font-size: 0.875rem;
  min-height: 1.4em;
}
.auth-card .switch-link {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}
.auth-card .switch-link a { color: var(--color-primary); }

/* ── 知识图谱页 ───────────────────────────────── */
.graph-page { position: relative; height: calc(100vh - 64px); overflow: hidden; }
#graph-canvas { width: 100%; height: 100%; }

.graph-controls {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}
.graph-controls select {
  padding: 7px 10px; font-size: 0.875rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: #fff; color: var(--color-text-primary); cursor: pointer;
}
.gc-divider { width: 1px; height: 22px; background: var(--color-border); margin: 0 2px; }
.gc-stats { font-size: 0.8rem; color: var(--color-text-secondary); padding: 0 6px; white-space: nowrap; }
.gc-back {
  padding: 7px 12px; font-size: 0.875rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  background: var(--color-primary, #4C6FFF); color: #fff; cursor: pointer;
  transition: filter .15s ease;
}
.gc-back:hover { filter: brightness(1.08); }

/* 模式切换：知识图谱 / 能力图谱（顶部居中分段控件）*/
.graph-toggle {
  position: absolute;
  top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 12;
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}
.graph-toggle button {
  padding: 7px 18px;
  font-size: 0.875rem; font-weight: 600;
  border: none; border-radius: 999px;
  background: transparent; color: var(--color-text-secondary);
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.graph-toggle button:hover { color: var(--color-text-primary); }
.graph-toggle button.active {
  background: var(--color-primary, #4C6FFF); color: #fff;
}

/* 总览引导提示（底部居中，避开搜索框）*/
.graph-hint {
  position: absolute;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9;
  padding: 8px 16px;
  font-size: 0.85rem; color: var(--color-text-secondary);
  background: var(--color-surface);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  pointer-events: none;
}

/* 图例 / 类型筛选面板（左下）*/
.graph-legend {
  position: absolute;
  left: 16px; bottom: 16px;
  z-index: 10;
  width: 198px; max-height: 46vh;
  display: flex; flex-direction: column;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.legend-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  font-size: 0.76rem; font-weight: 700; color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}
.legend-reset {
  border: none; background: none; cursor: pointer;
  font-size: 0.74rem; font-weight: 600; color: var(--color-primary);
  padding: 2px 6px; border-radius: 6px;
}
.legend-reset:hover { background: var(--color-primary-light); }
.legend-items { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border: none; border-radius: 7px;
  background: none; cursor: pointer; font-family: inherit;
  transition: background .15s var(--ease-out), opacity .15s var(--ease-out);
}
.legend-item:hover { background: rgba(45, 125, 210, 0.07); }
.legend-item.off { opacity: 0.4; }
.legend-item.off .legend-dot { filter: grayscale(1); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid; flex: 0 0 12px; }
.legend-label { flex: 1; text-align: left; font-size: 0.82rem; color: var(--color-text-primary); }
.legend-count { font-size: 0.72rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* 抽屉底部双按钮 */
.panel-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.panel-actions .ask-ai-btn { margin-top: 0; width: 100%; }

.graph-search {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
.graph-search input { width: 220px; font-size: 0.875rem; padding: 8px 12px; }
.graph-search-results {
  position: absolute;
  top: 52px; right: 0;
  width: 300px;
  max-height: 320px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  display: none;
}
.graph-search-results.open { display: block; }
.graph-search-results .item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.graph-search-results .item:hover { background: var(--color-primary-light); }
.graph-search-results .item .name { font-weight: 600; font-size: 0.9rem; }
.graph-search-results .item .def {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.graph-zoom {
  position: absolute;
  right: 16px; bottom: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.graph-zoom button {
  width: 40px; height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-text-primary);
}
.graph-zoom button:hover { background: var(--color-primary-light); }

/* 节点详情侧边面板 */
.node-panel {
  position: absolute;
  top: 0; right: 0;
  width: 340px;
  height: 100%;
  z-index: 20;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}
.node-panel.open { transform: translateX(0); }
.node-panel .panel-close {
  align-self: flex-end;
  background: none; border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-secondary);
}
.node-panel h3 { font-size: 1.125rem; margin-bottom: 8px; }
.node-panel .stars { color: var(--color-warning); margin-bottom: 12px; }
.node-panel .section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 16px 0 6px;
}
.node-panel .definition, .node-panel .content-text {
  font-size: 0.9rem;
  line-height: 1.75;
}
.node-panel .neighbor-list { list-style: none; }
.node-panel .neighbor-list li {
  padding: 6px 10px;
  margin-bottom: 6px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}
.node-panel .neighbor-list li:hover { filter: brightness(0.97); }
.node-panel .neighbor-list .rel {
  color: var(--color-secondary);
  font-size: 0.75rem;
  margin-right: 6px;
}
.node-panel .ask-ai-btn { margin-top: 20px; width: 100%; }

/* 知识点卡片：支撑能力 chips */
.node-panel .ability-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.node-panel .ability-chips li.muted {
  color: var(--color-text-secondary); font-size: 0.8rem; background: none; padding: 2px 0;
}
.ability-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--color-primary-light);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.82rem; cursor: pointer;
  transition: filter .15s ease;
}
.ability-chip:hover { filter: brightness(0.96); }
.ability-chip .code {
  font-weight: 700; color: var(--color-primary, #4C6FFF);
}

/* 能力指标详情面板 */
.ability-panel .ab-domain {
  font-size: 0.85rem; color: var(--color-secondary);
  margin-bottom: 4px;
}
.ability-panel .ab-chapter-list { list-style: none; }
.ability-panel .ab-chapter-list li {
  padding: 7px 10px;
  margin-bottom: 6px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  font-size: 0.85rem; cursor: pointer;
  transition: filter .15s ease;
}
.ability-panel .ab-chapter-list li:hover { filter: brightness(0.97); }
.ability-panel .ab-chapter-list li.muted {
  color: var(--color-text-secondary); background: none; cursor: default;
}

/* Skeleton 骨架屏 */
.graph-skeleton {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--color-text-secondary);
}
.skeleton-pulse {
  width: 240px; height: 240px;
  border-radius: 50%;
  background: linear-gradient(90deg, #E2E8F0 25%, #F0F7FF 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 智能导师页 ───────────────────────────────── */
.tutor-layout {
  display: flex;
  height: calc(100vh - 64px);
}

/* 历史会话侧栏 */
.tutor-sidebar {
  width: 268px;
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(45, 125, 210, 0.1);
  padding: 16px 12px;
  gap: 12px;
}
.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px;
  border: none; border-radius: var(--radius-md);
  background: var(--grad-tutor); color: #fff;
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  cursor: pointer; box-shadow: 0 6px 16px rgba(56,178,172,0.3);
  transition: filter .15s ease, transform .15s ease;
}
.new-chat-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.new-chat-btn svg { width: 18px; height: 18px; }
.session-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.session-empty { color: var(--color-text-muted); font-size: 0.85rem; text-align: center; padding: 24px 0; }
.session-item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s var(--ease-out);
}
.session-item:hover { background: rgba(45,125,210,0.07); }
.session-item.active { background: var(--color-primary-light); }
/* 选中会话：左侧主色指示条 */
.session-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--grad-tutor);
}
.session-item.active .session-title { color: var(--color-primary-dark); }
.session-meta { flex: 1; min-width: 0; }
.session-title {
  font-size: 0.9rem; font-weight: 600; color: var(--color-text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-time { font-size: 0.74rem; color: var(--color-text-secondary); margin-top: 2px; }
.session-del {
  border: none; background: none; color: var(--color-text-muted);
  cursor: pointer; padding: 4px; border-radius: 6px;
  opacity: 0; transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.session-item:hover .session-del { opacity: 1; }
.session-del:hover { color: var(--color-danger); background: rgba(229,62,62,0.1); }
.session-del svg { width: 15px; height: 15px; display: block; }
.sidebar-foot { font-size: 0.72rem; color: var(--color-text-muted); text-align: center; padding-top: 4px; }
.icon-btn-sm { width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--radius-sm); }
.icon-btn-sm svg { width: 18px; height: 18px; }
#sidebar-toggle { display: none; }   /* 桌面端侧栏常驻，隐藏开关 */

.tutor-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-width: 0;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.tutor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(45, 125, 210, 0.12);
}
.tutor-topbar h2 { font-size: 1.5rem; flex: 0 0 auto; }
.node-tag {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.875rem;
  padding: 4px 12px;
  border-radius: 999px;
}
.node-tag.show { display: inline-flex; }
.node-tag .tag-close { cursor: pointer; font-weight: 700; }
.tutor-topbar .spacer { flex: 1; }

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 欢迎空状态：在空对话区垂直居中 */
.welcome-card {
  margin: auto;
  max-width: 520px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 24px;
  color: var(--color-text-secondary);
}
.welcome-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(45, 125, 210, 0.3);
}
.welcome-icon svg { width: 38px; height: 38px; }
.welcome-card h3 { font-size: 1.25rem; color: var(--color-text-primary); }
.welcome-card p { font-size: 0.95rem; line-height: 1.9; }

.msg-row { display: flex; gap: 10px; align-items: flex-start; }
.msg-row.user { justify-content: flex-end; }
.msg-avatar {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* AI 头像：浅蓝；用户头像：主色实心 */
.msg-row.ai .msg-avatar {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.msg-row.user .msg-avatar {
  background: linear-gradient(135deg, var(--color-primary) 0%, #4A9BE0 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(45, 125, 210, 0.25);
}
.msg-avatar svg { width: 20px; height: 20px; }
.msg-bubble {
  max-width: 70%;     /* 限制长文本铺展，贴合阅读习惯 */
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  overflow-wrap: break-word;
  word-break: break-word;
}
/* AI 气泡：极浅灰，弱化视觉重量 */
.msg-row.ai .msg-bubble {
  background: #F1F5F9;
  border: 1px solid #E7EDF4;
  box-shadow: none;
  border-top-left-radius: 4px;
}
/* 用户气泡：主色调蓝 */
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--color-primary) 0%, #4A9BE0 100%);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(45, 125, 210, 0.22);
}
/* 用户气泡内的图片 */
.msg-image {
  display: block;
  max-width: 240px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.msg-text:empty { display: none; }
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble pre {
  background: #1A202C;
  color: #E2E8F0;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.875rem;
  margin: 8px 0;
}
.msg-bubble code { font-size: 0.9em; }
.msg-bubble :not(pre) > code {
  background: rgba(45, 125, 210, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg-bubble .katex-display { overflow-x: auto; overflow-y: hidden; }
.msg-bubble.error { color: var(--color-danger); }

/* AI 打字光标 */
.msg-bubble.streaming::after {
  content: "▍";
  color: var(--color-primary);
  animation: blink 0.9s steps(1) infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.msg-tools { margin-top: 6px; display: flex; gap: 8px; }
.msg-tools button {
  border: none; background: none;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.msg-tools button:hover { color: var(--color-primary); }
.msg-tools svg { width: 16px; height: 16px; }

/* 快捷问句 */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 16px 8px;
}
.quick-questions button {
  border: 1px solid var(--color-primary);
  background: var(--color-surface);
  color: var(--color-primary);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease;
}
.quick-questions button:hover { background: var(--color-primary-light); }
.quick-questions.hidden { display: none; }

/* 图片预览条 */
.image-preview-bar {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 16px 8px;
  padding: 8px 12px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}
.image-preview-bar.show { display: flex; }
.image-preview-bar img { height: 40px; border-radius: 4px; }
.image-preview-bar .remove { cursor: pointer; color: var(--color-danger); margin-left: auto; }

/* 底部输入区 */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 20px;
}
.input-bar textarea {
  flex: 1;
  resize: none;
  overflow-y: hidden;                  /* autoGrow 超过 5 行时由 JS 切换为 auto */
  max-height: calc(1.6em * 5 + 22px);  /* 最大约 5 行 */
  min-height: 46px;
  line-height: 1.6;
  padding: 12px 18px;
  border-radius: 23px;
  border: 1px solid #D6E2F0;
  background: #fff;
  box-shadow: var(--shadow-card);
}
.input-bar textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.icon-btn {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border: none;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter .15s ease, transform .15s ease;
}
.icon-btn:hover  { filter: brightness(1.05); transform: translateY(-1px); color: var(--color-primary); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.recording { background: var(--color-danger); color: #fff; animation: blink 1.2s infinite; }
#send-btn { background: var(--color-primary); color: #fff; }
#send-btn.stop-mode { background: var(--color-danger); }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  z-index: 999;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ============================================================
   功能页通用布局（智能测评 / 智能导读）
   ============================================================ */
.feature-page {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  padding: 0 20px 64px;
}
.feature-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 0 18px;
}
.feature-title { display: flex; align-items: center; gap: 12px; }
.feature-title h2 { font-size: 1.5rem; font-weight: 700; }
.ft-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--grad-primary);
}
.ft-icon svg { width: 22px; height: 22px; }
.ft-icon.accent-quiz    { background: var(--grad-quiz); }
.ft-icon.accent-reading { background: var(--grad-reading); }
.feature-topbar .spacer { flex: 1; }
.feature-body { display: flex; flex-direction: column; gap: 22px; }

/* 配置面板 */
.setup-card { padding: 26px 28px; }
.setup-card h3 { font-size: 1.2rem; font-weight: 700; }
.setup-hint { color: var(--color-text-secondary); font-size: 0.92rem; margin: 6px 0 18px; }
.setup-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.setup-row label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.82rem; color: var(--color-text-secondary); font-weight: 600;
}
.setup-row select {
  min-width: 120px; padding: 9px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: #fff; font-size: 0.95rem; color: var(--color-text-primary);
}
.setup-row select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }

/* 加载态 + 三点动画 */
.feature-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 40px; color: var(--color-text-secondary);
}
.dot-spinner { display: inline-flex; gap: 6px; }
.dot-spinner i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-primary); display: inline-block;
  animation: dot-bounce 1.2s infinite ease-in-out both;
}
.dot-spinner i:nth-child(1) { animation-delay: -0.24s; }
.dot-spinner i:nth-child(2) { animation-delay: -0.12s; }
@keyframes dot-bounce { 0%, 80%, 100% { transform: scale(0.4); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ── 测验题卡 ───────────────────────────────────── */
.quiz-card { padding: 24px 26px; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-num {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--color-primary-light); color: var(--color-primary);
  font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}
.q-tag { font-size: 0.74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.tag-single   { background: rgba(45,125,210,0.12);  color: var(--color-primary); }
.tag-multiple { background: rgba(108,92,231,0.12);  color: var(--color-accent); }
.tag-short    { background: rgba(56,178,172,0.14);  color: #0E8074; }
.q-stem { font-size: 1.02rem; font-weight: 600; line-height: 1.7; margin-bottom: 14px; }
.q-options { display: flex; flex-direction: column; gap: 10px; }
.q-option {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.q-option:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.q-option input { accent-color: var(--color-primary); width: 16px; height: 16px; }
.opt-letter {
  width: 24px; height: 24px; border-radius: 6px; flex: 0 0 24px;
  background: #EEF2F7; color: var(--color-text-secondary);
  font-weight: 700; font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
}
.opt-text { flex: 1; }
.q-option.opt-correct { border-color: var(--color-success); background: rgba(56,161,105,0.08); }
.q-option.opt-correct .opt-letter { background: var(--color-success); color: #fff; }
.q-option.opt-wrong { border-color: var(--color-danger); background: rgba(229,62,62,0.07); }
.q-option.opt-wrong .opt-letter { background: var(--color-danger); color: #fff; }
.q-answer {
  width: 100%; resize: vertical; min-height: 84px;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  padding: 12px 14px; font-size: 0.95rem; line-height: 1.7;
}
.q-answer:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.q-feedback {
  margin-top: 14px; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 0.9rem; line-height: 1.7;
}
.q-feedback.fb-right { background: rgba(56,161,105,0.08); border: 1px solid rgba(56,161,105,0.3); }
.q-feedback.fb-wrong { background: rgba(229,62,62,0.06); border: 1px solid rgba(229,62,62,0.25); }
.fb-line { font-weight: 700; margin-bottom: 6px; }
.fb-exp { color: var(--color-text-secondary); margin-top: 4px; }
.quiz-actions { display: flex; justify-content: center; padding: 8px 0 4px; }

/* ── 成绩卡 ─────────────────────────────────────── */
.score-card {
  display: flex; align-items: center; gap: 28px;
  padding: 28px 32px;
  background: var(--grad-quiz); color: #fff; border: none;
}
.score-ring {
  --p: 0;
  width: 110px; height: 110px; flex: 0 0 110px; border-radius: 50%;
  background:
    radial-gradient(closest-side, #fff 78%, transparent 79% 100%),
    conic-gradient(rgba(255,255,255,0.95) calc(var(--p) * 1%), rgba(255,255,255,0.3) 0);
  display: flex; align-items: center; justify-content: center;
}
.score-num { font-size: 2rem; font-weight: 800; color: #EF7C3C; }
.score-num small { font-size: 0.9rem; font-weight: 600; }
.score-info h3 { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.score-info p { opacity: 0.95; margin-bottom: 14px; }
.score-info .btn-secondary { background: rgba(255,255,255,0.95); border: none; color: #C2410C; }

/* ── 导读 Markdown 渲染 ─────────────────────────── */
.reading-card { padding: 32px 36px; }
.markdown-body { font-size: 1rem; line-height: 1.85; color: var(--color-text-primary); }
.markdown-body h2 {
  font-size: 1.3rem; font-weight: 700; margin: 26px 0 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--color-primary-light);
}
.markdown-body h2:first-child { margin-top: 0; }
.markdown-body h3 { font-size: 1.1rem; font-weight: 700; margin: 18px 0 8px; }
.markdown-body p { margin: 10px 0; }
.markdown-body ul, .markdown-body ol { margin: 10px 0 10px 22px; }
.markdown-body li { margin: 6px 0; }
.markdown-body strong { color: var(--color-primary-dark); }
.markdown-body code {
  background: rgba(45,125,210,0.08); padding: 1px 6px; border-radius: 4px;
  font-size: 0.9em; color: var(--color-primary-dark);
}
.markdown-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--color-primary); padding: 4px 14px;
  margin: 12px 0; color: var(--color-text-secondary); background: var(--color-primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── 响应式断点（Design.md 第 6 节）─────────────── */
@media (max-width: 1279px) {
  .home-cards { grid-template-columns: repeat(2, 1fr); }
  .home-hero-center h1 { font-size: 3.2rem; }
  .node-panel {
    top: auto; bottom: 0;
    width: 100%; height: 55%;
    transform: translateY(100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .node-panel.open { transform: translateY(0); }
}
@media (max-width: 900px) {
  #sidebar-toggle { display: flex; }
  .tutor-sidebar {
    position: fixed; left: 0; top: 64px; bottom: 0;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 50; box-shadow: var(--shadow-pop);
    background: var(--color-surface-solid);
  }
  .tutor-sidebar.open { transform: translateX(0); }
}
@media (max-width: 767px) {
  .home-cards { grid-template-columns: 1fr; }
  .home-hero { min-height: 320px; padding: 28px; }
  .home-hero-center h1 { font-size: 2.6rem; }
  .home-logo { position: static; margin-bottom: 20px; }
  .graph-controls { display: none; }
  .graph-legend { display: none; }
  .graph-search input { width: 140px; }
  .msg-bubble { max-width: 90%; }
  .feature-page { padding: 0 14px 48px; }
  .setup-row { gap: 12px; }
  .score-card { flex-direction: column; text-align: center; gap: 16px; }
}
