/* === 全局样式 === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #f5a623;
  --primary-dark: #e09000;
  --bg: #fafafa;
  --text: #333;
  --text-light: #666;
  --card-bg: #fff;
  --border: #e0e0e0;
  --code-bg: #f4f4f4;
  --accent-blue: #1a73e8;
  --success: #34a853;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  font-size: 16px;
}

/* === 导航栏 === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

/* 汉堡按钮 */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  margin-left: auto;
  padding: 4px 8px;
  color: var(--text);
}

/* 导航菜单 */
.navbar-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  list-style: none;
  align-items: center;
}

/* 课程分组（下拉） */
.navbar-nav > li {
  position: relative;
}

.navbar-nav > li > a,
.navbar-nav > li > .dropdown-label {
  color: var(--text-light);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  display: inline-block;
  border: none;
  background: none;
  font-family: inherit;
}

.navbar-nav > li > a:hover,
.navbar-nav > li > a.active,
.navbar-nav > li:hover > .dropdown-label {
  background: var(--primary);
  color: #fff;
}

/* 下拉菜单 */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 6px 0;
  min-width: 180px;
  z-index: 200;
  list-style: none;
}

.navbar-nav > li:hover .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.dropdown-menu a:hover {
  background: #f5f5f5;
}

.dropdown-menu a.active {
  color: var(--primary-dark);
  font-weight: 600;
  background: #fff8eb;
}

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

/* === 首页 === */
.hero {
  text-align: center;
  padding: 60px 0 40px;
}

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

.hero p {
  font-size: 18px;
  color: var(--text-light);
  max-width: 540px;
  margin: 0 auto 40px;
}

.chapter-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.chapter-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.chapter-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(245, 166, 35, 0.15);
}

.chapter-num {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-card h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.chapter-card p {
  font-size: 14px;
  color: var(--text-light);
}

/* === 章节页面 === */
.chapter-header {
  padding: 40px 0 32px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 32px;
}

.chapter-header .label {
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chapter-header h1 {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
}

/* 段落 */
.content-section {
  margin-bottom: 40px;
}

.content-section h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.content-section h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

.content-section p {
  margin-bottom: 16px;
}

.content-section ul,
.content-section ol {
  margin: 0 0 16px 24px;
}

.content-section li {
  margin-bottom: 8px;
}

/* 高亮卡片 */
.highlight-box {
  background: #fff8eb;
  border-left: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin: 20px 0;
}

.highlight-box strong {
  color: var(--primary-dark);
}

/* 信息卡片 */
.info-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 20px 0;
}

/* 统计数字 */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.stat-card .number {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .label {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 可展开列表 */
.accordion {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 20px 0;
}

.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-btn {
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  background: var(--card-bg);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}

.accordion-btn:hover {
  background: #f9f9f9;
}

.accordion-btn::before {
  content: "▸";
  font-size: 14px;
  color: var(--primary);
  transition: transform 0.2s;
}

.accordion-item.open .accordion-btn::before {
  transform: rotate(90deg);
}

.accordion-content {
  display: none;
  padding: 0 20px 16px 48px;
  color: var(--text-light);
  line-height: 1.7;
}

.accordion-item.open .accordion-content {
  display: block;
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
  margin: 20px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* 步骤 */
.step {
  display: flex;
  gap: 20px;
  margin: 32px 0;
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.step-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-content h3 {
  margin-bottom: 8px;
}

/* 图片 */
.img-wrap {
  margin: 20px 0;
  text-align: center;
}

.img-wrap img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.img-wrap .caption {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

/* 视频占位 */
.video-placeholder {
  background: #000;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  color: #fff;
  margin: 20px 0;
}

.video-placeholder a {
  color: var(--primary);
}

/* 测验 */
.quiz-box {
  background: #f0f7ff;
  border: 1px solid #c4ddf6;
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
}

.quiz-box h3 {
  color: var(--accent-blue);
  margin-bottom: 12px;
}

.quiz-box input[type="text"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 16px;
  width: 200px;
}

.quiz-box button {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 12px;
}

.quiz-box .result {
  margin-top: 12px;
  font-weight: 600;
}

.quiz-box .result.correct {
  color: var(--success);
}

.quiz-box .result.wrong {
  color: #ea4335;
}

/* 导航按钮 */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.2s;
}

.chapter-nav a:hover {
  background: var(--primary-dark);
}

.chapter-nav .spacer {
  flex: 1;
}

/* 进度条 */
.progress-bar {
  background: #eee;
  border-radius: 20px;
  height: 8px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 20px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.progress-info .reset-link {
  color: var(--text-light);
  text-decoration: underline;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 12px;
}

/* 章节时间标注 */
.chapter-meta {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-light);
  margin-top: 8px;
}

.chapter-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 排错折叠区 */
.troubleshoot {
  background: #fff8f0;
  border: 1px solid #f5d0a9;
  border-radius: 10px;
  margin: 12px 0 20px;
  overflow: hidden;
}

.troubleshoot-btn {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #e09000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.troubleshoot-btn::before {
  content: "❓";
}

.troubleshoot-content {
  display: none;
  padding: 0 16px 12px;
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.7;
}

.troubleshoot.open .troubleshoot-content {
  display: block;
}

/* 对比图 */
.compare-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

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

.compare-item img {
  width: 100%;
  border-radius: 8px;
  border: 2px solid var(--border);
}

.compare-item.before img {
  border-color: #ea4335;
}

.compare-item.after img {
  border-color: #34a853;
}

.compare-label {
  font-size: 14px;
  font-weight: 700;
  margin-top: 8px;
}

.compare-item.before .compare-label {
  color: #ea4335;
}

.compare-item.after .compare-label {
  color: #34a853;
}

/* 打开 Onshape 练习按钮 */
.practice-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(26, 115, 232, 0.3);
  margin: 16px 0;
}

.practice-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
}

.practice-btn::before {
  content: "🔧";
  font-size: 20px;
}

.practice-wrap {
  text-align: center;
  margin: 24px 0;
  padding: 20px;
  background: #f0f7ff;
  border-radius: 12px;
  border: 1px dashed #c4ddf6;
}

.practice-wrap p {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

/* 检查点 */
.checkpoint {
  background: #f0faf0;
  border: 1px solid #a8d5a8;
  border-radius: 10px;
  padding: 16px 20px;
  margin: 20px 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.checkpoint-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.checkpoint-body {
  flex: 1;
}

.checkpoint-body strong {
  display: block;
  color: #2e7d32;
  margin-bottom: 4px;
}

.checkpoint-body p {
  font-size: 14px;
  color: var(--text-light);
  margin: 0;
}

.checkpoint-btn {
  background: #34a853;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

.checkpoint-btn:hover {
  background: #2e7d32;
}

.checkpoint.done {
  background: #e8f5e9;
  border-color: #66bb6a;
  opacity: 0.7;
}

.checkpoint.done .checkpoint-btn {
  display: none;
}

.checkpoint.done::after {
  content: "✅ 已完成";
  font-size: 14px;
  font-weight: 600;
  color: #2e7d32;
  align-self: center;
}

/* 分屏模式 */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 24px 60px;
}

.split-layout .tutorial-side {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 16px;
}

.split-layout .onshape-side {
  position: sticky;
  top: 72px;
  height: calc(100vh - 100px);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--primary);
  background: #f5f5f5;
}

.split-layout .onshape-side iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.split-layout .onshape-side .fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
  color: var(--text-light);
}

.split-layout .onshape-side .fallback a {
  margin-top: 12px;
}

/* 分屏切换按钮 */
.split-toggle {
  text-align: center;
  margin: 16px 0;
}

.split-toggle button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.split-toggle button:hover {
  background: var(--primary-dark);
}

/* 术语搜索 */
.glossary-search {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.glossary-search:focus {
  outline: none;
  border-color: var(--primary);
}
.glossary-count {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 16px;
}

/* 键盘按键样式 */
kbd {
  display: inline-block;
  padding: 3px 8px;
  font-size: 13px;
  font-family: monospace;
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 1px 0 #bbb;
  min-width: 24px;
  text-align: center;
}

/* === 响应式 === */
@media (max-width: 800px) {
  .navbar-toggle {
    display: block;
  }

  .navbar-nav {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    flex-direction: column;
    padding: 16px;
    gap: 0;
    overflow-y: auto;
    border-top: 1px solid var(--border);
  }

  .navbar-nav.open {
    display: flex;
  }

  .navbar-nav > li {
    border-bottom: 1px solid #f0f0f0;
  }

  .navbar-nav > li > a,
  .navbar-nav > li > .dropdown-label {
    padding: 12px 8px;
    font-size: 15px;
    width: 100%;
    text-align: left;
  }

  .dropdown-menu {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 16px;
  }

  .dropdown-menu a {
    padding: 10px 8px;
    font-size: 14px;
  }
}

@media (max-width: 640px) {
  .navbar {
    padding: 0 16px;
  }

  .main {
    padding: 72px 16px 40px;
  }

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

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

  .stats-row {
    grid-template-columns: 1fr;
  }

  .step {
    flex-direction: column;
    gap: 12px;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .split-layout .onshape-side {
    position: static;
    height: 400px;
  }
}
