/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* === CSS 变量 === */
:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-dark: #3730A3;
  --primary-bg: #EEF2FF;
  --success: #22C55E;
  --success-light: #DCFCE7;
  --success-dark: #15803d;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --danger-border: #FCA5A5;
  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --text: #1E293B;
  --text-light: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.05), 0 4px 6px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;

  /* 主视图区"书本顶风"配色（SVG） */
  --svg-bg: #FDFCF8;
  --svg-line: #1A1A1A;
  --svg-accent-blue: #2563EB;   /* τ_load */
  --svg-accent-red: #DC2626;    /* τ_spring */
  --svg-accent-green: #16A34A;  /* τ_net */
}

/* === 全局重置 === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

::selection {
  background: var(--primary-light);
  color: white;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary);
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

code, pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* === 导航栏 === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.navbar-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.3px;
  transition: color var(--transition);
}

.navbar-brand:hover {
  color: var(--primary-dark);
}

.navbar-title {
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  border-left: 1px solid var(--border);
  padding-left: 16px;
  margin-left: 4px;
}

/* === 主内容区 === */
.main {
  max-width: 920px;
  margin: 0 auto;
  padding: 84px 24px 60px;
}

.has-sidebar .main {
  margin-left: 260px;
  max-width: none;
  padding-right: 24px;
}

.has-sidebar .main > * {
  max-width: 920px;
}

/* === 首页 Hero === */
.hero {
  text-align: center;
  padding: 60px 24px 48px;
  background: linear-gradient(180deg, var(--primary-bg) 0%, var(--bg) 100%);
  border-radius: var(--radius-xl);
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 40px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero p {
  font-size: 18px;
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

/* === 主题区块 === */
.topic-section {
  margin: 40px 0;
}

.topic-section h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-section .topic-icon {
  font-size: 22px;
}

.topic-section.planned h2 {
  color: var(--text-muted);
}

.topic-section.planned .planned-tag {
  font-size: 11px;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: 0.4px;
  margin-left: 4px;
}

/* === Lesson 卡片 === */
.lesson-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-sm);
}

.lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.lesson-card.disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.lesson-card .lesson-bullet {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.lesson-card.disabled .lesson-bullet {
  background: var(--text-muted);
}

.lesson-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.4;
}

.lesson-card p {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.5;
}

.lesson-card .planned-tag {
  margin-left: auto;
  font-size: 11px;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: 0.4px;
}

/* === 全局课程侧边栏 === */
.book-sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 260px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 0 60px;
  z-index: 50;
  font-size: 14px;
}

.book-sidebar::-webkit-scrollbar {
  width: 4px;
}

.book-sidebar::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

.book-sidebar::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

.sidebar-title {
  display: block;
  padding: 12px 16px 14px;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color var(--transition);
}

.sidebar-title:hover {
  color: var(--primary-dark);
}

.sidebar-topic {
  padding: 14px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.sidebar-topic:first-of-type {
  border-top: none;
  margin-top: 0;
}

.sidebar-topic.planned {
  color: var(--text-muted);
}

.sidebar-topic .topic-icon {
  font-size: 14px;
}

.sidebar-lesson {
  display: block;
  padding: 9px 18px 9px 28px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar-lesson:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.sidebar-lesson.active {
  color: var(--primary);
  background: var(--primary-bg);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-lesson.disabled {
  color: var(--text-muted);
  cursor: default;
  pointer-events: none;
}

.sidebar-empty {
  padding: 6px 18px 12px 28px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* === 移动端侧边栏按钮 === */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 90;
  box-shadow: var(--shadow-lg);
  transition: background var(--transition), transform var(--transition);
  align-items: center;
  justify-content: center;
}

.sidebar-mobile-toggle:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 89;
}

.sidebar-overlay.show {
  display: block;
}

/* === 页脚 === */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* === 响应式 === */
@media (max-width: 800px) {
  .book-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .book-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  .has-sidebar .main {
    margin-left: 0;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero p {
    font-size: 16px;
  }
}
