/* =====================================================
   PYPATH — MAIN STYLESHEET
   Layout, Typography, Components
===================================================== */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

body {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ── Typography ── */
h1, h2, h3, h4, h5, h6,
.navbar, .sidebar, .toc-sidebar,
button, input, label, .breadcrumb,
.lesson-meta, .module-card-meta {
  font-family: 'DM Sans', system-ui, sans-serif;
}

h1 { font-size: 2.2rem; font-weight: 700; line-height: 1.25; color: var(--text-primary); }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.35; color: var(--text-primary); margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.2rem; font-weight: 600; line-height: 1.4;  color: var(--text-primary); margin: 2rem 0 0.5rem; }
h4 { font-size: 1rem;   font-weight: 600; line-height: 1.5;  color: var(--text-primary); margin: 1.5rem 0 0.4rem; }

p { margin-bottom: 1.1rem; color: var(--text-secondary); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-emerald); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; color: var(--text-secondary); }
li { margin-bottom: 0.35rem; }
li:last-child { margin-bottom: 0; }

strong { font-weight: 600; color: var(--text-primary); }
em { font-style: italic; }

code:not([class]) {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875em;
  background: var(--bg-code);
  color: var(--accent-emerald);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

hr { border: none; border-top: 1px solid var(--border-default); margin: 2rem 0; }

/* ── Layout Grid ── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  background: var(--bg-navbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr 220px;
  grid-template-rows: 1fr;
  min-height: 100vh;
  padding-top: 60px;
}

.sidebar {
  grid-column: 1;
  position: fixed;
  top: 60px;
  left: 0;
  width: 260px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  z-index: 100;
}

.main-content {
  grid-column: 2;
  min-width: 0;
  padding: 2rem 3rem;
  max-width: 860px;
}

.toc-sidebar {
  grid-column: 3;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0.5rem;
  align-self: start;
}

/* ── Navbar Components ── */
.navbar-left { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.navbar-center { flex: 1; max-width: 480px; margin: 0 auto; }
.navbar-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; margin-left: auto; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition-med);
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}
.brand-icon { font-size: 1.5rem; }
.brand-name { letter-spacing: -0.02em; }

/* ── Search ── */
.search-wrapper {
  position: relative;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 1rem 0 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(78, 204, 163, 0.15);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 360px;
  overflow-y: auto;
}
.search-dropdown .search-item {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition-fast);
}
.search-dropdown .search-item:last-child { border-bottom: none; }
.search-dropdown .search-item:hover,
.search-dropdown .search-item.active { background: var(--bg-card); color: var(--text-primary); }
.search-item .search-module { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.search-item mark { background: none; color: var(--accent-amber); font-weight: 600; }
.search-empty { padding: 1.25rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; }

/* ── Progress Pill ── */
.progress-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: default;
}
.progress-ring { width: 32px; height: 32px; transform: rotate(-90deg); }
.progress-ring-bg {
  fill: none;
  stroke: var(--border-default);
  stroke-width: 3;
}
.progress-ring-fill {
  fill: none;
  stroke: var(--accent-emerald);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}
.progress-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-emerald);
  min-width: 2.5rem;
}

/* ── Theme Toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition-fast);
}
.theme-toggle:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.theme-toggle svg { width: 16px; height: 16px; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Sidebar ── */
.sidebar-inner { padding: 1rem 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.5rem;
}
.sidebar-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  line-height: 1;
}

.module-group { margin-bottom: 0.25rem; }

.module-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-radius: 0;
  transition: var(--transition-fast);
  user-select: none;
}
.module-header:hover { background: var(--bg-card); }
.module-header.active { background: var(--bg-card); }
.module-icon { font-size: 1rem; flex-shrink: 0; }
.module-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.3;
}
.module-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.module-group.open .module-chevron { transform: rotate(90deg); }

.lesson-list {
  display: none;
  padding: 0.25rem 0 0.25rem 0;
}
.module-group.open .lesson-list { display: block; }

.lesson-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem 0.45rem 2.75rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  border-left: 2px solid transparent;
  line-height: 1.35;
}
.lesson-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.lesson-link.active {
  color: var(--accent-emerald);
  border-left-color: var(--accent-emerald);
  background: rgba(78, 204, 163, 0.06);
  font-weight: 500;
}
.lesson-link.completed .lesson-check { color: var(--accent-emerald); }
.lesson-check {
  font-size: 0.8rem;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: var(--transition-fast);
}
.lesson-link.completed .lesson-check::before { content: '✓'; }
.lesson-link:not(.completed) .lesson-check::before { content: '○'; font-size: 0.65rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ── Skeleton loader ── */
.skeleton-line {
  height: 14px;
  background: var(--bg-card);
  border-radius: 4px;
  margin: 0.75rem 1rem;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

/* ── Breadcrumb ── */
.breadcrumb {
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.breadcrumb-list li:not(:last-child)::after {
  content: '›';
  margin-left: 0.3rem;
  color: var(--text-faint);
}
.breadcrumb-list a { color: var(--text-muted); }
.breadcrumb-list a:hover { color: var(--accent-emerald); text-decoration: none; }
.breadcrumb-list li:last-child { color: var(--text-secondary); font-weight: 500; }

/* ── TOC ── */
.toc-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
#toc { display: flex; flex-direction: column; gap: 0; }
.toc-link {
  display: block;
  padding: 0.35rem 0.75rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-left: 2px solid var(--border-subtle);
  text-decoration: none;
  transition: var(--transition-fast);
  line-height: 1.4;
}
.toc-link:hover { color: var(--text-primary); text-decoration: none; }
.toc-link.active {
  color: var(--accent-teal);
  border-left-color: var(--accent-teal);
  font-weight: 500;
}
.toc-link.toc-h3 { padding-left: 1.5rem; font-size: 0.75rem; }

/* ── Loading ── */
.content-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scroll to Top ── */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 42px;
  height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition-med), transform var(--transition-med);
  z-index: 200;
}
.scroll-top.visible { opacity: 1; transform: translateY(0); }
.scroll-top:hover { background: var(--bg-card-hover); box-shadow: var(--shadow-md); }
.scroll-top svg { width: 18px; height: 18px; }

/* ═══════════════════════════════════════
   LESSON CONTENT STYLES
═══════════════════════════════════════ */

.lesson { max-width: 800px; }

.lesson-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-default);
}
.lesson-header h1 {
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-emerald) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lesson-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.lesson-meta .time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-card);
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.lesson-intro {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 2rem;
  padding-left: 1rem;
  border-left: 3px solid var(--accent-emerald);
}

/* ── Colab Button ── */
.colab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: linear-gradient(135deg, #f9ab00, #ff6d00);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: var(--transition-fast);
  box-shadow: 0 2px 8px rgba(249, 171, 0, 0.3);
}
.colab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(249, 171, 0, 0.4);
  text-decoration: none;
  color: #fff;
}
.colab-btn svg { width: 16px; height: 16px; }

/* ── Callout Boxes ── */
.callout {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  border-left: 4px solid;
}
.callout h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.callout p:last-child { margin-bottom: 0; }

.callout.pitfall {
  background: var(--callout-pitfall-bg);
  border-color: var(--callout-pitfall-border);
}
.callout.pitfall h4 { color: var(--callout-pitfall-border); }

.callout.tip {
  background: var(--callout-tip-bg);
  border-color: var(--callout-tip-border);
}
.callout.tip h4 { color: var(--callout-tip-border); }

.callout.note {
  background: var(--callout-note-bg);
  border-color: var(--callout-note-border);
}
.callout.note h4 { color: var(--callout-note-border); }

/* ── Try It Section ── */
.try-it {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2.5rem 0;
}
.try-it h3 {
  margin-top: 0;
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.try-it h3::before { content: '⚡'; }
.try-it ol, .try-it ul { margin-bottom: 1rem; }
.try-it .colab-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* ── Inline Mini-Challenge ── */
.mini-challenge {
  background: var(--bg-surface);
  border: 1px dashed var(--accent-amber);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
}
.mini-challenge h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--accent-amber);
}
.mini-challenge p:last-of-type { margin-bottom: 0.75rem; }

/* ── Key Takeaways ── */
.takeaways {
  background: var(--callout-takeaway-bg);
  border: 1px solid var(--callout-takeaway-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2.5rem 0;
}
.takeaways h3 {
  margin-top: 0;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.takeaways h3::before { content: '🔑'; }
.takeaways ul { margin-bottom: 0; }
.takeaways li { margin-bottom: 0.5rem; }

/* ── Further Reading ── */
.further-reading {
  margin: 2rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-default);
}
.further-reading h3 { margin-top: 0; }
.further-reading ul { list-style: none; padding: 0; }
.further-reading li { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.5rem; }
.further-reading li::before { content: '→'; color: var(--accent-emerald); flex-shrink: 0; }
.further-reading a { color: var(--accent-teal); }

/* ── Lesson Navigation ── */
.lesson-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-default);
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}
.btn-nav:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  text-decoration: none;
}
.btn-nav:disabled, .btn-nav.hidden { visibility: hidden; }

.mark-complete-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.mark-complete-label input[type="checkbox"] {
  accent-color: var(--accent-emerald);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.mark-complete-label.completed { color: var(--accent-emerald); font-weight: 500; }

/* ── Tabbed Code Examples ── */
.tab-container { margin: 1.5rem 0; }
.tab-buttons {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 0;
}
.tab-btn {
  padding: 0.5rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-emerald); border-bottom-color: var(--accent-emerald); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ═══════════════════════════════════════
   HOME PAGE
═══════════════════════════════════════ */

.home-page { max-width: 100%; }

.hero {
  text-align: center;
  padding: 3rem 1rem 4rem;
  position: relative;
  overflow: hidden;
}

.hero-logo {
  font-size: 5rem;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 30px rgba(78, 204, 163, 0.3));
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-emerald) 60%, var(--accent-teal) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-tagline {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-family: 'DM Sans', sans-serif;
}
.hero-tagline code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-amber);
  font-size: 0.95em;
  background: none;
  border: none;
  padding: 0;
  -webkit-text-fill-color: var(--accent-amber);
}

.hero-cta-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 2rem;
  background: var(--accent-emerald);
  color: var(--text-inverse);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
  box-shadow: 0 4px 20px rgba(78, 204, 163, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(78, 204, 163, 0.5);
  text-decoration: none;
  color: var(--text-inverse);
}
[data-theme="light"] .btn-primary { color: #0d1a0d; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 2rem;
  background: transparent;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid var(--border-default);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
}
.btn-secondary:hover {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  text-decoration: none;
}

.home-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin: 2.5rem 0;
  flex-wrap: wrap;
}
.stat-item {
  text-align: center;
}
.stat-number {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-emerald);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modules-section { margin-top: 1rem; }
.section-heading {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.module-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition-med);
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--accent-emerald));
}
.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}
.module-card-icon { font-size: 2rem; margin-bottom: 0.75rem; display: block; }
.module-card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.module-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 1rem;
  font-family: 'DM Sans', sans-serif;
}
.module-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text-faint);
}
.module-card-progress {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  margin-top: 1rem;
  overflow: hidden;
}
.module-card-progress-fill {
  height: 100%;
  background: var(--card-color, var(--accent-emerald));
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

/* ── Features Section ── */
.features-section {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.feature-card {
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  transition: var(--transition-med);
}
.feature-card:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.feature-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}
.feature-title {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}
.feature-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  line-height: 1.55;
}
.feature-desc kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78em;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--accent-emerald);
}

/* ── Site Footer ── */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.footer-brand {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.footer-links {
  display: flex;
  gap: 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
}
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent-emerald); text-decoration: none; }
.footer-copy {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* ── Quick Reference Card ── */
.quick-ref {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 2rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}
.quick-ref h4 {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--accent-amber);
  margin-top: 0;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.quick-ref table { width: 100%; border-collapse: collapse; }
.quick-ref td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.quick-ref td:first-child { color: var(--accent-teal); white-space: nowrap; min-width: 160px; }
.quick-ref td:last-child { color: var(--text-secondary); }
.quick-ref tr:last-child td { border-bottom: none; }

/* Hint/Solution toggles */
.hint-toggle, .solution-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 0.5rem;
  user-select: none;
}
.hint-toggle:hover, .solution-toggle:hover { border-color: var(--accent-amber); color: var(--accent-amber); }
.hint-content, .solution-content {
  display: none;
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid var(--border-subtle);
}
