/* ===== 豆包使用从入门到精通 - 主样式表 ===== */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-code: #f4f4f5;
  --bg-tip: #f0f7ff;
  --bg-warning: #fff7ed;
  --bg-exercise: #f0fdf4;
  --bg-template: #faf5ff;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #8888a0;
  --border-color: #e2e8f0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --heading-color: #1e1b4b;
  --link-color: #4f46e5;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 900px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* ===== 暗色主题 ===== */
[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #1a1a2e;
  --bg-code: #252540;
  --bg-tip: #1a1a3e;
  --bg-warning: #2a1f0e;
  --bg-exercise: #0f2a1a;
  --bg-template: #1f1a2e;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0c0;
  --text-muted: #6b6b8a;
  --border-color: #2a2a4a;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-light: #1e1b4b;
  --heading-color: #e0e0f0;
  --link-color: #818cf8;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.8;
  transition: background 0.3s, color 0.3s;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== 顶部导航栏 ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 700; font-size: 1.1rem;
  color: var(--heading-color);
}
.navbar-brand .brand-icon { font-size: 1.4rem; }
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.2rem;
  color: var(--text-primary);
  transition: all 0.3s;
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: rotate(15deg);
}
.nav-chapter-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}
.nav-chapter-title.show { display: block; }

/* ===== 侧边栏 ===== */
.sidebar-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.2rem;
  color: var(--text-primary);
  transition: all 0.3s;
}
.sidebar-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 998;
  background: rgba(0,0,0,0.4);
  opacity: 0; visibility: hidden;
  transition: all 0.3s;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }
.sidebar {
  position: fixed; top: 60px; left: 0; bottom: 0; z-index: 999;
  width: 300px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s, background 0.3s, border-color 0.3s;
  padding: 16px 0;
}
.sidebar.active { transform: translateX(0); }
.sidebar-section { padding: 0 16px; margin-bottom: 12px; }
.sidebar-section-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 1px;
  padding: 8px 12px 4px;
}
.sidebar-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
  line-height: 1.4;
}
.sidebar-link:hover { background: var(--accent-light); color: var(--accent); }
.sidebar-link.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ===== 主内容区 ===== */
.main-content {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
  transition: margin-left 0.3s;
}
.main-content.shifted { margin-left: 300px; }

/* ===== 章节页面 ===== */
.chapter-page { display: none; }
.chapter-page.active { display: block; }

.chapter-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ===== 首页 ===== */
.home-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px 24px;
}
.home-container {
  max-width: 800px;
  width: 100%;
  text-align: center;
}
.home-icon { font-size: 4rem; margin-bottom: 20px; }
.home-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--heading-color);
  margin-bottom: 12px;
  line-height: 1.2;
}
.home-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.6;
}
.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.home-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px 16px;
  transition: all 0.3s;
}
.home-feature-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent);
}
.home-feature-card .icon { font-size: 2rem; margin-bottom: 8px; }
.home-feature-card h3 { font-size: 1rem; margin-bottom: 4px; color: var(--heading-color); }
.home-feature-card p { font-size: 0.85rem; color: var(--text-muted); }
.home-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 40px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(79,70,229,0.3);
}
.home-start-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.4);
}

/* ===== 文章排版 ===== */
.article h1, .chapter-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--heading-color);
  margin-bottom: 8px;
  line-height: 1.3;
}
.article .chapter-number {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.article .chapter-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}
.article h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading-color);
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.article h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--heading-color);
  margin-top: 28px;
  margin-bottom: 12px;
}
.article h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading-color);
  margin-top: 20px;
  margin-bottom: 8px;
}
.article p {
  margin-bottom: 16px;
  color: var(--text-primary);
}
.article ul, .article ol {
  margin-bottom: 16px;
  padding-left: 24px;
  color: var(--text-primary);
}
.article li { margin-bottom: 6px; }
.article strong {
  font-weight: 700;
  color: var(--heading-color);
}
.article a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.article a:hover { border-bottom-color: var(--link-color); }

/* ===== 代码块 ===== */
.article pre {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  color: var(--text-primary);
}
.article code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}
.article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}
.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  opacity: 0;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== 提示框 ===== */
.tip, .warning, .exercise, .template-box {
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  position: relative;
}
.tip {
  background: var(--bg-tip);
  border-left: 4px solid var(--accent);
}
.tip::before { content: "💡 小贴士"; display: block; font-weight: 700; margin-bottom: 6px; color: var(--accent); }
.warning {
  background: var(--bg-warning);
  border-left: 4px solid #f59e0b;
}
.warning::before { content: "⚠️ 避坑提醒"; display: block; font-weight: 700; margin-bottom: 6px; color: #d97706; }
.exercise {
  background: var(--bg-exercise);
  border-left: 4px solid #10b981;
}
.exercise::before { content: "✍️ 实操练习"; display: block; font-weight: 700; margin-bottom: 6px; color: #059669; }
.template-box {
  background: var(--bg-template);
  border-left: 4px solid #8b5cf6;
  border-radius: var(--radius);
}
.template-box::before { content: "📋 可复制提示词模板"; display: block; font-weight: 700; margin-bottom: 6px; color: #7c3aed; }

/* ===== 步骤列表 ===== */
.steps {
  counter-reset: step-counter;
  list-style: none;
  padding: 0;
  margin-bottom: 20px;
}
.steps li {
  counter-increment: step-counter;
  padding: 14px 16px 14px 52px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  line-height: 1.6;
}
.steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps li strong { color: var(--heading-color); }

/* ===== 表格 ===== */
.article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.article th, .article td {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  text-align: left;
}
.article th {
  background: var(--accent-light);
  font-weight: 700;
  color: var(--heading-color);
}
.article tr:nth-child(even) { background: var(--bg-secondary); }
.article tr:hover { background: var(--accent-light); }

/* ===== 首页目录 ===== */
.toc { margin-top: 40px; }
.toc h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--heading-color);
  margin-bottom: 16px;
  border: none;
  padding: 0;
}
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.toc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toc-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.toc-card .toc-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}
.toc-card .toc-text {
  flex: 1;
  text-align: left;
}
.toc-card .toc-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}
.toc-card .toc-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

/* ===== 底部导航 ===== */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}
.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.chapter-nav .prev {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.chapter-nav .prev:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.chapter-nav .next {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.chapter-nav .next:hover { background: var(--accent-hover); }

/* ===== 回到顶部 ===== */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-3px);
}

/* ===== 进度条 ===== */
.reading-progress {
  position: fixed;
  top: 60px; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  z-index: 1000;
  transition: width 0.1s;
}

/* ===== 底部版权 ===== */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .home-title { font-size: 1.8rem; }
  .article h1, .chapter-title { font-size: 1.5rem; }
  .article h2 { font-size: 1.3rem; }
  .home-features { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 280px; }
  .main-content.shifted { margin-left: 0; }
  .chapter-container { padding: 24px 16px 60px; }
  .navbar { padding: 0 16px; }
  .nav-chapter-title { display: none !important; }
  .toc-grid { grid-template-columns: 1fr; }
  .chapter-nav { flex-direction: column; gap: 12px; }
  .chapter-nav a { width: 100%; justify-content: center; }
  pre { font-size: 0.8rem; padding: 12px 14px; }
  .back-to-top { bottom: 20px; right: 20px; width: 40px; height: 40px; font-size: 1rem; }
}
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .main-content { margin-left: 300px; }
  .chapter-container { max-width: 850px; }
}

/* ===== 打印样式 ===== */
@media print {
  .navbar, .sidebar, .sidebar-overlay, .back-to-top, .reading-progress, .copy-btn, .chapter-nav { display: none !important; }
  .main-content { margin-left: 0 !important; margin-top: 0 !important; }
  .chapter-page { display: block !important; }
  .page-break { page-break-before: always; }
  body { background: #fff; color: #000; font-size: 12pt; }
  pre { background: #f5f5f5; border: 1px solid #ddd; }
  a { color: #000; text-decoration: underline; }
}
