/* AI Fluency 学习系统 — 以可读性和学习体验为核心的设计 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

/* ========== 设计令牌 ========== */
:root {
  --font: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  --bg: #111318;
  --bg-raised: #1a1d26;
  --bg-card: #1e2230;
  --bg-inset: #161923;
  --bg-hover: #252a3a;
  --border: #2a2f42;
  --border-hover: #3d4460;
  --text: #dce0e8;
  --text-dim: #8b92a8;
  --text-faint: #5c6278;
  --accent: #7c8af8;
  --accent-bg: rgba(124,138,248,.1);
  --green: #4ade80;
  --green-bg: rgba(74,222,128,.08);
  --cyan: #22d3ee;
  --cyan-bg: rgba(34,211,238,.08);
  --amber: #fbbf24;
  --amber-bg: rgba(251,191,36,.08);
  --red: #f87171;
  --red-bg: rgba(248,113,113,.08);
  --purple: #a78bfa;
  --purple-bg: rgba(167,139,250,.08);
  /* 4D 颜色 */
  --d1: #818cf8; --d1-bg: rgba(129,140,248,.1);
  --d2: #22d3ee; --d2-bg: rgba(34,211,238,.1);
  --d3: #4ade80; --d3-bg: rgba(74,222,128,.1);
  --d4: #f87171; --d4-bg: rgba(248,113,113,.1);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.35);
  --transition: .2s ease;
  /* 间距和排版 — 按 spec 要求"大号正文、明显行距" */
  --body-size: 1rem;    /* 16px */
  --body-lh: 1.85;
  --h1-size: 1.65rem;
  --h2-size: 1.2rem;
  --h3-size: 1.05rem;
  --content-max: 860px;
}

/* ========== 重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: var(--body-lh);
  font-size: var(--body-size);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ========== 顶部导航 ========== */
.topnav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 24px;
  background: rgba(17,19,24,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topnav-brand {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; white-space: nowrap;
}
.brand-icon { font-size: 1.2rem; }
.brand-text { font-weight: 700; font-size: .88rem; color: var(--accent); }
.topnav-links {
  display: flex; gap: 4px; margin-left: 24px;
}
.nav-link {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 500;
  color: var(--text-dim); cursor: pointer;
  transition: var(--transition);
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-bg); }
.topnav-right {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
}
.mode-switch {
  display: flex; background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 2px; border: 1px solid var(--border);
}
.mode-btn {
  padding: 4px 14px; border: none; border-radius: 4px;
  font-size: .78rem; font-weight: 600;
  background: transparent; color: var(--text-dim);
  transition: var(--transition);
}
.mode-btn.active { background: var(--accent); color: #fff; }
.mode-btn:hover:not(.active) { color: var(--text); }
.search-wrap { position: relative; }
.search-input {
  width: 200px; padding: 6px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: .82rem; font-family: var(--font);
  outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); width: 280px; }
.search-input::placeholder { color: var(--text-faint); }
.search-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); right: 0;
  width: 360px; max-height: 400px; overflow-y: auto;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 200;
}
.search-dropdown.show { display: block; }
.search-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: var(--transition);
}
.search-item:hover { background: var(--bg-hover); }
.search-item:last-child { border-bottom: none; }
.search-item-title { font-weight: 600; font-size: .88rem; }
.search-item-ctx { font-size: .78rem; color: var(--text-dim); margin-top: 2px; }

/* ========== 主区域 ========== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 80px;
  min-height: calc(100vh - 52px);
}

/* ========== 课程地图 (XMind 风格) ========== */
.course-map {
  margin-bottom: 40px;
}
.map-title {
  font-size: var(--h1-size); font-weight: 700;
  margin-bottom: 8px;
}
.map-subtitle {
  font-size: .92rem; color: var(--text-dim);
  margin-bottom: 28px; max-width: 640px;
}
/* 树状地图 */
.map-tree {
  display: flex; gap: 24px; overflow-x: auto;
  padding: 20px 0;
}
.map-branch {
  min-width: 200px; flex-shrink: 0;
}
.map-branch-title {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 0 0 8px;
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.map-node {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; margin-bottom: 4px;
  border-radius: var(--radius-sm); cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.map-node:hover { background: var(--bg-hover); }
.map-node.active { background: var(--accent-bg); border-left-color: var(--accent); }
.map-node-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.map-node-body { flex: 1; min-width: 0; }
.map-node-label {
  font-size: .85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-node-hint {
  font-size: .75rem; color: var(--text-dim); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.map-node-tag {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: .65rem; font-weight: 600; margin-top: 4px;
}

/* ========== 课程概览网格 ========== */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}
.lesson-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.lesson-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.lesson-card-accent {
  position: absolute; top: 0; left: 0; width: 100%; height: 3px;
}
.lesson-card-num {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 6px;
}
.lesson-card-title {
  font-size: .95rem; font-weight: 600; margin-bottom: 6px;
}
.lesson-card-liner {
  font-size: .82rem; color: var(--text-dim); line-height: 1.55;
}
.lesson-card-meta {
  font-size: .72rem; color: var(--text-faint); margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
}

/* ========== 入口卡片组 ========== */
.entry-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin-bottom: 40px;
}
.entry-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  cursor: pointer; transition: var(--transition);
}
.entry-card:hover {
  border-color: var(--border-hover); box-shadow: var(--shadow);
}
.entry-card-icon { font-size: 1.6rem; margin-bottom: 10px; }
.entry-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.entry-card-desc { font-size: .85rem; color: var(--text-dim); line-height: 1.6; }

/* ========== 课程详情页 ========== */
.lesson-page { max-width: var(--content-max); margin: 0 auto; }
.lesson-header { margin-bottom: 28px; }
.lesson-header-num {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 6px;
}
.lesson-header-title {
  font-size: var(--h1-size); font-weight: 700;
  margin-bottom: 6px; letter-spacing: -.01em;
}
.lesson-header-sub {
  font-size: .88rem; color: var(--text-dim);
}
.lesson-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.lesson-nav-btn {
  flex: 1; padding: 14px 18px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: var(--transition);
}
.lesson-nav-btn:hover { border-color: var(--border-hover); }
.lesson-nav-btn-label { font-size: .72rem; color: var(--text-faint); }
.lesson-nav-btn-title { font-size: .88rem; font-weight: 600; margin-top: 2px; }

/* ===== 层级区块 ===== */
.layer {
  margin-bottom: 24px;
}
.layer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); transition: var(--transition);
  user-select: none;
}
.layer-head:hover { border-color: var(--border-hover); }
.layer-num {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.layer-head-title { font-size: var(--h3-size); font-weight: 600; flex: 1; }
.layer-chevron {
  font-size: .75rem; color: var(--text-faint);
  transition: transform .2s;
}
.layer.open .layer-chevron { transform: rotate(180deg); }
.layer-body {
  overflow: hidden; max-height: 0;
  transition: max-height .35s ease;
}
.layer.open .layer-body { max-height: 8000px; }
.layer-content {
  padding: 18px 20px 2px;
}
/* 层级颜色 */
.layer-1 .layer-num { background: var(--d1-bg); color: var(--d1); }
.layer-2 .layer-num { background: var(--d2-bg); color: var(--d2); }
.layer-3 .layer-num { background: var(--d3-bg); color: var(--d3); }
.layer-4 .layer-num { background: var(--amber-bg); color: var(--amber); }
.layer-5 .layer-num { background: var(--purple-bg); color: var(--purple); }
.layer-6 .layer-num { background: var(--red-bg); color: var(--red); }

/* ===== 浏览模式摘要卡 ===== */
.scan-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
  margin-bottom: 20px;
}
.scan-card-label {
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); margin-bottom: 8px;
}
.scan-card-text {
  font-size: 1.02rem; line-height: 1.8; color: var(--text);
}
.scan-terms {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.term-tag {
  padding: 3px 10px; border-radius: 14px;
  font-size: .75rem; font-weight: 500;
  background: var(--accent-bg); color: var(--accent);
}

/* ===== 知识卡片 ===== */
.knowledge-cards {
  display: flex; flex-direction: column; gap: 14px;
}
.k-card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.k-card-title {
  font-size: .92rem; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.k-card-title::before {
  content: ''; width: 4px; height: 18px;
  background: var(--accent); border-radius: 2px; flex-shrink: 0;
}
.k-point {
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .92rem; line-height: 1.8;
  color: var(--text);
}
.k-point:last-child { border-bottom: none; }
.k-highlight {
  color: var(--accent); font-weight: 600;
}

/* ===== 课程内结构地图 ===== */
.local-map {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 20px;
}
.local-map-title {
  font-size: .82rem; font-weight: 600; color: var(--text-dim); margin-bottom: 12px;
}
.local-map-nodes {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.lm-node {
  padding: 6px 14px; border-radius: 20px;
  font-size: .8rem; font-weight: 500;
  background: var(--bg-hover); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
}
.lm-node:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 误区对比 ===== */
.misconception {
  background: var(--bg-raised); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 10px;
}
.misc-wrong {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .88rem; color: var(--red); font-weight: 500; margin-bottom: 6px;
}
.misc-correct {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .88rem; color: var(--green);
}
.misc-icon { flex-shrink: 0; }

/* ===== 延伸标记 ===== */
.ext-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  font-size: .68rem; font-weight: 600;
  background: var(--purple-bg); color: var(--purple);
  margin-bottom: 10px;
}

/* ===== 自测题 ===== */
.quiz-block { max-width: 680px; }
.q-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
}
.q-type-tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: .68rem; font-weight: 600; margin-bottom: 8px;
}
.q-text { font-size: 1rem; font-weight: 600; line-height: 1.7; margin-bottom: 14px; }
.q-options { display: flex; flex-direction: column; gap: 6px; }
.q-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-raised); border: 1px solid var(--border);
  cursor: pointer; font-size: .9rem; transition: var(--transition);
}
.q-opt:hover { border-color: var(--accent); }
.q-opt.selected { border-color: var(--accent); background: var(--accent-bg); }
.q-opt.correct { border-color: var(--green); background: var(--green-bg); }
.q-opt.wrong { border-color: var(--red); background: var(--red-bg); }
.q-radio {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text-faint); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.q-opt.selected .q-radio { border-color: var(--accent); }
.q-opt.selected .q-radio::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.q-check-btn {
  margin-top: 8px; padding: 8px 20px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); font-weight: 600;
  font-size: .85rem; transition: var(--transition);
}
.q-check-btn:hover { opacity: .9; }
.q-feedback {
  margin-top: 10px; padding: 12px 16px;
  border-radius: var(--radius-sm); font-size: .88rem;
  line-height: 1.7; display: none;
}
.q-feedback.show { display: block; }
.q-feedback.ok { background: var(--green-bg); border: 1px solid rgba(74,222,128,.2); }
.q-feedback.no { background: var(--red-bg); border: 1px solid rgba(248,113,113,.2); }

/* ===== 4Ds 页 ===== */
.d-section {
  margin-bottom: 36px;
}
.d-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}
.d-icon { font-size: 1.6rem; }
.d-name { font-size: var(--h2-size); font-weight: 700; }
.d-name-zh { font-size: .88rem; color: var(--text-dim); margin-left: 4px; }
.d-def {
  font-size: .95rem; color: var(--text); line-height: 1.8;
  padding-left: 16px; border-left: 3px solid;
  margin-bottom: 16px;
}
.d-comp {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 10px;
}
.d-comp-name { font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.d-comp-desc { font-size: .88rem; color: var(--text-dim); line-height: 1.7; }

/* ===== 四重目标页 ===== */
.goal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  border-top: 3px solid;
}
.goal-icon { font-size: 1.4rem; margin-bottom: 8px; }
.goal-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.goal-name-zh { font-size: .82rem; color: var(--text-dim); margin-bottom: 8px; }
.goal-desc { font-size: .9rem; color: var(--text); line-height: 1.7; margin-bottom: 8px; }
.goal-rel { font-size: .78rem; color: var(--text-faint); }

/* ===== 流程箭头 ===== */
.flow-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 16px 0;
}
.flow-step {
  padding: 8px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 500;
}
.flow-arrow { color: var(--accent); font-weight: 700; }

/* ===== 通用工具类 ===== */
.section-title {
  font-size: var(--h2-size); font-weight: 700;
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.section-subtitle {
  font-size: .88rem; color: var(--text-dim); margin-bottom: 16px;
  max-width: 640px; line-height: 1.7;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-16 { margin-top: 16px; }

/* 面包屑 */
.breadcrumb {
  font-size: .78rem; color: var(--text-faint); margin-bottom: 16px;
}
.breadcrumb a { cursor: pointer; }
.breadcrumb a:hover { color: var(--accent); }

/* 空白分割 */
.spacer { height: 32px; }

/* 动画 */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.animate { animation: fadeIn .25s ease forwards; }

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .topnav { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .topnav-links { order: 3; width: 100%; justify-content: center; }
  .main { padding: 20px 16px 60px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .map-tree { flex-direction: column; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .lesson-nav { flex-direction: column; }
}

/* 打印 */
@media print {
  .topnav { display: none; }
  .layer-body { max-height: none !important; }
}

/* ========== Language Switch ========== */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px 6px 3px 10px;
  border: 1px solid rgba(74,222,128,.3);
  box-shadow: 0 0 8px rgba(74,222,128,.08);
}
.lang-globe {
  font-size: 1rem;
  margin-right: 2px;
}
.lang-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  font-size: .82rem;
  font-weight: 700;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: .02em;
}
.lang-btn.active {
  background: var(--green);
  color: #111;
  box-shadow: 0 1px 4px rgba(74,222,128,.25);
}
.lang-btn:hover:not(.active) {
  color: var(--text);
  background: var(--bg-hover);
}

/* ========== Source Attribution Banner ========== */
.source-banner {
  margin-bottom: 28px;
  padding: 18px 24px;
  background: linear-gradient(135deg, rgba(124,138,248,.08), rgba(74,222,128,.04));
  border: 1px solid rgba(124,138,248,.18);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fadeIn .4s ease forwards;
}
.source-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}
.source-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.source-text {
  font-size: .92rem;
  color: var(--text);
  line-height: 1.6;
}
.source-text strong {
  color: var(--accent);
  font-weight: 700;
}

/* Responsive adjustments for lang switch */
@media (max-width: 900px) {
  .lang-switch {
    order: -1;
  }
}

