/* 外部CSS文件 */
:root {
    --site-bg: #f8f9fa;
    --site-bg-accent: #f1f3f5;
    --surface: #ffffff;
    --surface-muted: #f8f9fa;
    --surface-soft: #f3f6fb;
    --text-main: #212529;
    --text-muted: #6c757d;
    --text-subtle: #495057;
    --border-color: #dee2e6;
    --border-strong: #ced4da;
    --primary: #04aa6d;
    --primary-strong: #038857;
    --primary-soft: rgba(4, 170, 109, 0.12);
    --info-soft: #eef2ff;
    --success-soft: #edf7f1;
    --shadow-sm: 0 0.5rem 1rem rgba(33, 37, 41, 0.08);
    --shadow-md: 0 1rem 3rem rgba(33, 37, 41, 0.09);
    --shadow-lg: 0 1.5rem 3rem rgba(33, 37, 41, 0.12);
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --container-max: 1200px;
    --content-max: 1200px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body { 
    font-family: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
    line-height: 1.65; 
    background: #ffffff;
    color: var(--text-main);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    width: min(var(--content-max), calc(100% - 2rem));
    margin: 0 auto 3rem;
}

body > main:first-of-type {
    padding-top: 2rem;
}

/* ==================== */
/* Navigation */
/* ==================== */

.nav-links {
  position: sticky;
  top: 0;
  z-index: 1100;
  margin-bottom: 0;
  background: #282a35;
  border-bottom: 1px solid #1f212a;
  overflow: visible;
}

.nav-wrapper {
  width: min(var(--container-max), calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  flex-wrap: wrap;
}

.nav-home {
  flex-shrink: 0;
  color: #ffffff;
  text-decoration: none;
  border: none;
  border-radius: 0;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  position: relative;
}

.nav-home:hover {
  background: #11131a;
}

.nav-home.active {
  background: var(--primary);
  color: #fff;
}

.nav-brand-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.1;
}

.nav-brand-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-brand-subtitle {
  display: none;
}

.nav-dropdowns {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.4rem;
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  background: transparent;
  border: none;
  color: #f1f1f1;
  padding: 0.95rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  border-radius: 0;
  position: relative;
}

.nav-dropdown-btn:hover {
  background: #11131a;
  color: #fff;
}

.nav-dropdown-btn.active,
.nav-dropdown.open .nav-dropdown-btn {
  background: var(--primary);
  color: #fff;
}

.dropdown-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
  opacity: 0.65;
}

.nav-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  min-width: 300px;
  border-radius: 0;
  border: 1px solid #d9d9d9;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  z-index: 1200;
  overflow: hidden;
  padding: 0;
}

.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a {
  display: block;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: var(--text-main);
  border-radius: 0;
  transition: all 0.18s ease;
}

.dropdown-menu a + a {
  border-top: 1px solid #efefef;
}

.dropdown-menu a:hover {
  background: #f1f1f1;
  color: #000;
}

.dropdown-menu a.active {
  background: #e7f7f1;
  color: #000;
  box-shadow: inset 4px 0 0 var(--primary);
}

.menu-item-title {
  font-weight: 700;
  margin-bottom: 0.22rem;
  font-size: 0.96rem;
}

.menu-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.mobile-menu-toggle {
  display: none;
  background: #282a35;
  border: 1px solid #1f212a;
  color: #ffffff;
  padding: 0.8rem 1rem;
  border-radius: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  margin: 0.75rem auto 0;
  width: min(var(--container-max), calc(100% - 2rem));
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
  border-color: var(--border-strong);
}

/* ==================== */
/* Footer */
/* ==================== */

.reference-links {
  background: transparent;
  color: var(--text-main);
  margin-top: auto;
}

.footer-wrapper {
  width: min(var(--content-max), calc(100% - 2rem));
  margin: 0 auto 2rem;
  padding: 2rem 0 0;
  border-top: 1px solid var(--border-color);
}

.footer-wrapper h3 {
  color: var(--text-main);
  text-align: left;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem;
  margin: 0;
}

.footer-links a {
  color: var(--text-subtle);
  text-decoration: none;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.82);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(222, 226, 230, 0.7);
}

.footer-links a:hover {
  background: white;
  color: var(--primary-strong);
  border-color: rgba(121, 82, 179, 0.18);
  transform: translateY(-1px);
}

.link-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.footer-info {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.92rem;
}

.footer-info p {
  margin: 0;
}

/* ==================== */
/* 响应式设计 */
/* ==================== */

@media (max-width: 1024px) {
  .nav-wrapper {
    flex-direction: column;
    align-items: stretch;
    padding: 0.9rem 0;
  }
  
  .nav-dropdowns {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }
  
  .nav-dropdown {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: block;
  }
  
  .nav-wrapper {
    display: none;
    width: min(var(--container-max), calc(100% - 2rem));
    padding: 0.25rem 0 1rem;
  }
  
  .nav-links.mobile-open .nav-wrapper {
    display: flex;
  }
  
  .nav-links.mobile-open .nav-wrapper > * {
    width: 100%;
    margin: 0.25rem 0;
  }
  
  .nav-dropdown-btn {
    width: 100%;
    justify-content: space-between;
    background: #282a35;
    color: #f1f1f1;
  }
  
  .dropdown-menu {
    position: static;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    margin-top: 0.35rem;
    border: none;
    padding: 0;
    min-width: 0;
  }
  
  .dropdown-menu a {
    color: #000;
    background: #fff;
    border: none;
  }
  
  .dropdown-menu a:hover {
    background: #f1f1f1;
  }
  
  .menu-item-desc {
    color: var(--text-muted);
  }
  
  .footer-links {
    grid-template-columns: 1fr;
  }
  
  .footer-wrapper {
    padding-top: 1.5rem;
  }
}

/* 首页卡片式导航（可选） */
.home-quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.home-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  border-left: 5px solid #667eea;
}

.home-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.home-card h3 {
  color: #333;
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-card p {
  color: #666;
  margin-bottom: 15px;
  line-height: 1.6;
}

.home-card-link {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.home-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* ==================== */
/* 通用组件样式 */
/* ==================== */

.step { 
    background: var(--surface); 
    padding: 1.5rem; 
    margin-bottom: 1.5rem; 
    border: 1px solid rgba(222, 226, 230, 0.8);
    border-left: 4px solid var(--primary); 
    box-shadow: var(--shadow-sm); 
    border-radius: var(--radius-md);
}

pre { 
    background: #272822; 
    color: #f8f8f2; 
    padding: 15px; 
    overflow-x: auto; 
    border-radius: 4px; 
}

.note { 
    background: #fff8d5; 
    padding: 10px; 
    border-left: 4px solid #ff9800; 
    margin-top: 10px; 
    border-radius: var(--radius-sm);
}

.example-box {
    border: 1px solid rgba(121, 82, 179, 0.24);
    padding: 12px;
    margin: 15px 0;
    background: #f8f7fc;
    border-radius: var(--radius-sm);
}

h1 {
    color: var(--text-main);
    text-align: left;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: -0.03em;
}



/* ==================== */
/* Exam-focused pages */
/* ==================== */

.page-lead {
    max-width: 900px;
    margin: 0 auto 25px;
    color: #444;
    font-size: 1.05rem;
}

.page-meta {
    max-width: 900px;
    margin: 0 auto 25px;
    padding: 14px 18px;
    background: #eef7ff;
    border-left: 4px solid #007bff;
    border-radius: 6px;
}

.checklist {
    margin: 0;
    padding-left: 20px;
}

.checklist li {
    margin-bottom: 10px;
}

.question-list {
    margin: 0;
    padding-left: 22px;
}

.question-list li {
    margin-bottom: 14px;
}

.question-card {
    background: #f8fbff;
    border: 1px solid #d6e6ff;
    border-radius: 8px;
    padding: 16px 18px;
    margin: 15px 0;
}

.question-card h3 {
    margin-top: 0;
    color: #1d4f91;
}

.resource-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.resource-links a {
    display: inline-block;
    text-decoration: none;
    background: #667eea;
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-weight: 600;
}

.resource-links a:hover {
    background: #5567c9;
}

.practice-warning {
    background: #fff4d8;
    border-left: 5px solid #f0a202;
    padding: 14px 16px;
    border-radius: 6px;
    margin: 20px 0;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.mini-tag {
    display: inline-block;
    background: #e8ecff;
    color: #3d4fb2;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.lesson-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.lesson-sidebar {
    position: sticky;
    top: 88px;
    display: grid;
    gap: 16px;
}

.lesson-sidebar-card {
    background: #f1f1f1;
    border: 1px solid #e3e3e3;
    border-radius: 0;
    padding: 14px 0;
    box-shadow: none;
}

.lesson-sidebar-card h2,
.lesson-sidebar-card h3 {
    margin: 0 14px 12px;
    padding: 0;
    border: 0;
    font-size: 1rem;
}

.lesson-menu {
    display: grid;
    gap: 8px;
}

.lesson-menu a {
    display: block;
    text-decoration: none;
    color: #000;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0;
    padding: 8px 14px;
    font-weight: 500;
    transition: all 0.18s ease;
}

.lesson-menu a:hover {
    color: #000;
    background: #dddddd;
    border-left-color: var(--primary);
    transform: none;
}

.lesson-menu a.active {
    color: #fff;
    background: var(--primary);
    border-left-color: var(--primary-strong);
    font-weight: 700;
}

.tag-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: Consolas, "Courier New", monospace;
    color: #045c3a;
    background: #e7f7f1;
    border: 1px solid #cfeee3;
}

.lesson-content {
    min-width: 0;
}

.lesson-shell.generated-sidebar {
    grid-template-columns: 260px minmax(0, 1fr);
}

.lesson-sidebar.generated-sidebar .lesson-sidebar-card {
    background: #f1f1f1;
}

.lesson-sidebar-card p.sidebar-note {
    margin: 0;
    padding: 0 14px;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.summary-card {
    background: #fff;
    border: 1px solid rgba(222, 226, 230, 0.92);
    border-left: 4px solid var(--primary);
    border-radius: 0;
    padding: 16px 18px;
    margin-bottom: 18px;
    box-shadow: none;
}

.summary-card p:last-child,
.summary-card ul:last-child {
    margin-bottom: 0;
}

.concept-box {
    background: #eef7ff;
    border-left: 4px solid #007bff;
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
  }
  
  .exercise-step {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border-left: 4px solid #28a745;
  }
  
  .exercise-step h3 {
    margin-top: 0;
    color: #28a745;
  }
  
  .code-example {
    background: #272822;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    margin: 15px 0;
    white-space: pre-wrap;
  }
  
  .important-note {
    background: #fff8d5;
    border-left: 4px solid #ff9800;
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 4px 4px 0;
  }
  
  .component-preview {
    border: 1px dashed #ccc;
    padding: 15px;
    margin: 15px 0;
    background: white;
  }

@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    .lesson-shell {
        grid-template-columns: 1fr;
    }

    .lesson-sidebar {
        position: static;
        order: -1;
    }
}
