
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --bg-code: #0d1117;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --border: #30363d;
  --border-light: #21262d;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --info: #58a6ff;
  --math-bg: rgba(88, 166, 255, 0.05);
}

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

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.8;
  overflow-x: hidden;
}

/* 顶部导航 */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(15, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.nav-brand .logo { font-size: 1.4rem; }

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--accent);
  background: var(--accent-glow);
}

/* 主布局 */
.main-layout {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}

/* 侧边栏 */
.sidebar {
  width: 280px;
  height: calc(100vh - 56px);
  position: fixed;
  left: 0; top: 56px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  z-index: 100;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-title {
  padding: 0 20px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-list { list-style: none; padding: 0; }
.toc-list li { margin: 0; }

.toc-list a {
  display: block;
  padding: 6px 20px 6px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
}

.toc-list a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

.toc-list .toc-h2 { padding-left: 24px; font-weight: 500; }
.toc-list .toc-h3 { padding-left: 40px; font-size: 0.8rem; }
.toc-list .toc-h4 { padding-left: 56px; font-size: 0.78rem; color: var(--text-muted); }

/* 内容区 */
.content {
  margin-left: 280px;
  flex: 1;
  max-width: 900px;
  padding: 40px 48px 80px;
}

/* 标题 */
h1 { font-size: 2.4rem; font-weight: 800; margin: 0 0 24px; color: var(--text-primary); border-bottom: 2px solid var(--accent); padding-bottom: 12px; }
h2 { font-size: 1.7rem; font-weight: 700; margin: 48px 0 20px; color: var(--text-primary); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.3rem; font-weight: 600; margin: 32px 0 16px; color: var(--accent); }
h4 { font-size: 1.1rem; font-weight: 600; margin: 24px 0 12px; color: var(--text-secondary); }
h5 { font-size: 1rem; font-weight: 600; margin: 16px 0 8px; color: var(--text-muted); }

h1 a.anchor, h2 a.anchor, h3 a.anchor, h4 a.anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor { opacity: 1; }

/* 段落和文本 */
p { margin: 12px 0; }

strong { color: var(--accent-hover); font-weight: 600; }

em { color: var(--warning); font-style: italic; }

/* 引用块 */
blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}

blockquote p { margin: 6px 0; }
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

/* 特殊引用块 */
blockquote.alert-warning { border-left-color: var(--warning); background: rgba(210, 153, 34, 0.08); }
blockquote.alert-danger { border-left-color: var(--danger); background: rgba(248, 81, 73, 0.08); }
blockquote.alert-success { border-left-color: var(--success); background: rgba(63, 185, 80, 0.08); }
blockquote.alert-info { border-left-color: var(--info); background: var(--accent-glow); }

/* 代码块 */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

code {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--accent-hover);
  border: 1px solid var(--border-light);
}

pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: var(--text-primary);
}

/* 代码高亮 */
.code-keyword { color: #ff7b72; }
.code-string { color: #a5d6ff; }
.code-comment { color: #8b949e; font-style: italic; }
.code-number { color: #79c0ff; }
.code-function { color: #d2a8ff; }
.code-type { color: #ffa657; }

/* 表格 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9rem;
  border-radius: 8px;
  overflow: hidden;
}

th {
  background: var(--bg-tertiary);
  color: var(--accent);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--accent);
}

td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
}

tr:hover td { background: var(--bg-tertiary); }

/* 列表 */
ul, ol { margin: 12px 0 12px 24px; }
li { margin: 6px 0; }

/* 水平线 */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* 数学公式 */
.katex-display {
  background: var(--math-bg);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  overflow-x: auto;
}
.katex { font-size: 1.05em; }

/* 链接 */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 标签/徽章 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 6px;
}
.badge-frequency { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.badge-difficulty { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.badge-score { background: rgba(88, 166, 255, 0.2); color: var(--accent); }

/* 主页样式 */
.hero {
  text-align: center;
  padding: 80px 40px 60px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  border: none;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #a371f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 40px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 卡片 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.3s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(88, 166, 255, 0.12);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-meta {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 搜索 */
.search-box {
  position: relative;
  width: 240px;
}

.search-box input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.search-box input:focus { border-color: var(--accent); }

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
}

/* 回到顶部 */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: all 0.2s;
}

.back-to-top:hover {
  background: var(--accent);
  color: white;
}

/* 响应式 */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 24px; }
  .card-grid { grid-template-columns: 1fr; padding: 24px; }
  .hero h1 { font-size: 2rem; }
}

@media (max-width: 768px) {
  .top-nav { padding: 0 12px; }
  .nav-links { display: none; }
  .hero-stats { flex-direction: column; gap: 24px; }
  .content { padding: 16px; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
}

/* 打印 */
@media print {
  .top-nav, .sidebar, .back-to-top { display: none !important; }
  .content { margin-left: 0; max-width: none; }
  body { background: white; color: black; }
}

/* ================= 首页门户（浅色主题） ================= */
body.portal-page {
  --line: #e6e8f0;
  --blue: #3f63f2;
  --muted: #6b7280;
  background: #f6f7fb;
  color: #1b2133;
  line-height: 1.7;
  padding-top: 0;
  font-size: 15px;
}
.portal-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 26px;
  padding: 12px 28px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.portal-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #1b2133; font-weight: 800; font-size: 17px; }
.portal-brand small { color: var(--muted); font-weight: 500; font-size: 12px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #3f63f2, #7a4de8);
  color: #fff; font-weight: 800; font-size: 16px;
}
.portal-links { display: flex; gap: 20px; }
.portal-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.portal-links a:hover, .portal-links a.active { color: var(--blue); }
.portal-actions { margin-left: auto; display: flex; gap: 10px; }
.icon-button, .theme-button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 15px; color: #4b5563;
}
.theme-button:hover, .icon-button:hover { border-color: var(--blue); color: var(--blue); }

.portal-shell { display: flex; max-width: 1280px; margin: 0 auto; gap: 26px; padding: 26px 22px 40px; }
.portal-sidebar { width: 235px; flex-shrink: 0; }
.sidebar-kicker { font-size: 12px; font-weight: 800; color: var(--blue); letter-spacing: .04em; margin-bottom: 14px; }
.side-section { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; margin-bottom: 16px; }
.side-label { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .06em; margin: 2px 6px 10px; }
.side-link { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; color: #374151; text-decoration: none; font-size: 13.5px; }
.side-link:hover { background: #f0f3ff; color: var(--blue); }
.side-link.selected { background: #e9edff; color: var(--blue); font-weight: 700; }
.side-link b { margin-left: auto; font-size: 10px; color: #b7931f; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.math { background: #d17637; } .dot.english { background: #7251c6; } .dot.cs { background: #377bc0; } .dot.plan { background: #2fa26b; }
.side-footer { font-size: 12px; color: var(--muted); padding: 0 6px; }
.side-footer strong { margin-left: 6px; color: #374151; }

.portal-main { flex: 1; min-width: 0; }
.welcome-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; background: linear-gradient(120deg, #eef1ff, #f7f4ff); border: 1px solid var(--line); border-radius: 18px; padding: 30px 32px; }
.eyebrow { font-size: 12px; font-weight: 800; color: var(--blue); letter-spacing: .08em; }
.welcome-row h1 { font-size: 30px; margin: 8px 0 10px; line-height: 1.35; }
.welcome-row h1 em { font-style: normal; background: linear-gradient(90deg, #3f63f2, #8a4de8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome-row p { color: var(--muted); font-size: 14px; margin: 0; }
.target-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; min-width: 210px; }
.target-card span { font-size: 11px; color: var(--muted); font-weight: 700; }
.target-card strong { display: block; font-size: 20px; margin: 4px 0 2px; }
.target-card small { color: var(--muted); font-size: 12px; }

.quick-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0 6px; }
.quick-stats div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.quick-stats strong { font-size: 22px; color: var(--blue); display: block; }
.quick-stats span { font-size: 12px; color: var(--muted); }

.content-section { margin-top: 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.section-heading h2 { font-size: 21px; margin-top: 4px; }
.section-heading a { color: var(--blue); font-size: 13px; text-decoration: none; font-weight: 600; }
.sync-status { font-size: 12px; color: var(--muted); }
.course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.course-card { display: flex; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; text-decoration: none; color: inherit; transition: .2s; }
.course-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(46,57,96,.10); border-color: #cbd3ff; }
.course-card.featured { border-color: #b9c6ff; background: linear-gradient(160deg, #ffffff, #f3f6ff); }
.course-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: #fff; flex-shrink: 0; }
.math-icon { background: linear-gradient(135deg, #d17637, #eda45f); }
.english-icon { background: linear-gradient(135deg, #7251c6, #9a7ce8); }
.cs-icon { background: linear-gradient(135deg, #377bc0, #5fa2e8); }
.course-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 700; }
.course-copy h3 { font-size: 17px; margin: 6px 0 6px; }
.course-copy p { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 0 0 10px; }
.course-foot { font-size: 11.5px; color: var(--blue); font-weight: 700; }

.plan-section .timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.timeline-item.current { border-color: #b9c6ff; background: #f5f7ff; }
.timeline-number { font-size: 20px; font-weight: 800; color: #c3cbf0; }
.timeline-item.current .timeline-number { color: var(--blue); }
.timeline-item b { font-size: 15px; }
.timeline-item small { color: var(--blue); font-size: 12px; margin-left: 10px; font-weight: 700; }
.timeline-item p { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

.updates-section .update-list { display: flex; flex-direction: column; gap: 10px; }
.update-list a { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; text-decoration: none; color: inherit; }
.update-list a:hover { border-color: #cbd3ff; }
.update-tag { flex-shrink: 0; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 20px; }
.tag-blue { background: #e3ecff; color: #377bc0; }
.tag-orange { background: #fdeede; color: #d17637; }
.tag-purple { background: #efe7ff; color: #7251c6; }
.update-list b { font-size: 14px; }
.update-list p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.update-list time { margin-left: auto; font-size: 12px; color: var(--muted); flex-shrink: 0; }

.portal-footer { display: flex; justify-content: space-between; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* 首页暗夜模式（切换按钮在 <html> 上加 .dark-mode） */
.dark-mode body.portal-page, .dark-mode .portal-page {
  --line: #2a3040; --muted: #8b93a7;
  background: #10131c; color: #dde3f0;
}
.dark-mode .portal-nav { background: rgba(20,24,38,.92); border-color: var(--line); }
.dark-mode .portal-brand { color: #dde3f0; }
.dark-mode .portal-links a { color: #8b93a7; }
.dark-mode .portal-links a:hover, .dark-mode .portal-links a.active { color: #7d9bff; }
.dark-mode .icon-button, .dark-mode .theme-button { background: #171c2b; border-color: var(--line); color: #aab2c8; }
.dark-mode .side-section, .dark-mode .quick-stats div, .dark-mode .course-card,
.dark-mode .timeline-item, .dark-mode .update-list a, .dark-mode .target-card,
.dark-mode .highlight-card { background: #171c2b; border-color: var(--line); }
.dark-mode .side-link { color: #c4cbde; }
.dark-mode .side-link:hover { background: #1e2436; }
.dark-mode .side-link.selected { background: #222a45; color: #7d9bff; }
.dark-mode .welcome-row { background: linear-gradient(120deg, #1a2036, #221d38); border-color: var(--line); }
.dark-mode .welcome-row p, .dark-mode .course-copy p, .dark-mode .timeline-item p,
.dark-mode .update-list p, .dark-mode .welcome-row small { color: #8b93a7; }
.dark-mode .course-card.featured { background: linear-gradient(160deg, #171c2b, #1d2440); border-color: #34406e; }
.dark-mode .timeline-item.current { background: #1d2440; border-color: #34406e; }
.dark-mode .portal-footer { border-color: var(--line); }
.dark-mode .eyebrow, .dark-mode .sidebar-kicker { color: #7d9bff; }
.dark-mode .quick-stats strong { color: #7d9bff; }

@media (max-width: 1000px) {
  .portal-shell { flex-direction: column; }
  .portal-sidebar { width: 100%; }
  .course-grid, .quick-stats { grid-template-columns: repeat(2, 1fr); }
  .welcome-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 620px) {
  .course-grid, .quick-stats { grid-template-columns: 1fr; }
  .portal-links { display: none; }
}
