:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --green: #4ade80;
  --red: #f87171;
  --orange: #fb923c;
  --purple: #a78bfa;
  --border: #334155;
  --code-bg: #0d1117;
  --sidebar-w: 280px;
  --radius: 12px;
}
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  letter-spacing: -0.01em;
}
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-hover); }

/* Smooth page transitions */
.content > * { animation: slideUp .35s cubic-bezier(.22,1,.36,1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Layout */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-header .logo { font-size: 1.5rem; }
.sidebar-header h2 { font-size: 1rem; font-weight: 700; line-height: 1.3; display: flex; align-items: center; gap: .4rem; }
.sidebar-header h2 .brand-bio { font-family: 'Caveat', cursive; font-size: 1.5rem; font-weight: 700; color: var(--green); line-height: 1; }
.sidebar-header h2 .brand-rest { }
.sidebar-nav { padding: .5rem 0; }
.sidebar-nav .nav-section {
  padding: .75rem 1.5rem .25rem;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  font-weight: 600;
}
.sidebar-nav .nav-section[data-part="1"] { color: var(--accent); }
.sidebar-nav .nav-section[data-part="2"] { color: var(--purple); }
.sidebar-nav .nav-section[data-part="3"] { color: var(--green); }
.sidebar-nav .nav-section[data-part="4"] { color: var(--orange); }
.sidebar-nav .nav-section[data-part="extras"] { color: var(--red); }

/* Part-colored icons in sidebar */
.sidebar-nav a[data-part="1"] svg { color: var(--accent); }
.sidebar-nav a[data-part="2"] svg { color: var(--purple); }
.sidebar-nav a[data-part="3"] svg { color: var(--green); }
.sidebar-nav a[data-part="4"] svg { color: var(--orange); }
.sidebar-nav a[data-part="extras"] svg { color: var(--red); }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  transition: all .2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a svg, .sidebar-nav a i { width: 18px; height: 18px; flex-shrink: 0; }
.menu-btn svg { width: 20px; height: 20px; }
.theme-toggle svg { width: 18px; height: 18px; }
.module-card .icon svg { width: 32px; height: 32px; }
.module-card[data-part="Foundations"] .icon svg { color: var(--accent); }
.module-card[data-part="Programming"] .icon svg { color: var(--purple); }
.module-card[data-part="Data & Formats"] .icon svg { color: var(--green); }
.module-card[data-part="Analysis"] .icon svg { color: var(--orange); }

.module-card[data-part="Foundations"] { border-left: 3px solid var(--accent); }
.module-card[data-part="Programming"] { border-left: 3px solid var(--purple); }
.module-card[data-part="Data & Formats"] { border-left: 3px solid var(--green); }
.module-card[data-part="Analysis"] { border-left: 3px solid var(--orange); }
.module-card[data-part="Foundations"]:hover { border-color: var(--accent); box-shadow: 0 8px 30px rgba(56,189,248,.15); }
.module-card[data-part="Programming"]:hover { border-color: var(--purple); box-shadow: 0 8px 30px rgba(167,139,250,.15); }
.module-card[data-part="Data & Formats"]:hover { border-color: var(--green); box-shadow: 0 8px 30px rgba(74,222,128,.15); }
.module-card[data-part="Analysis"]:hover { border-color: var(--orange); box-shadow: 0 8px 30px rgba(251,146,60,.15); }
.sidebar-nav a:hover, .sidebar-nav a.active {
  color: var(--text);
  background: var(--bg-card-hover);
  border-left-color: var(--accent);
}
.sidebar-nav a .badge {
  margin-left: auto;
  background: var(--green);
  color: #000;
  font-size: .6rem;
  padding: .1rem .4rem;
  border-radius: 99px;
  font-weight: 700;
}

/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
  padding: .75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}
.breadcrumb { font-size: .85rem; color: var(--text-muted); }
.breadcrumb span { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.theme-toggle, .progress-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .4rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  transition: all .2s;
}
.theme-toggle:hover, .progress-btn:hover { background: var(--bg-card-hover); }
.progress-ring {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.progress-ring .bar {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-ring .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  transition: width .5s;
}

/* Content */
.content { padding: 2rem; max-width: 900px; margin: 0 auto; }

/* Hero */
.hero {
  text-align: center;
  padding: 4rem 2rem;
  background: transparent;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  border: none;
}
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; }
.hero h1 .brand-bio { font-family: 'Caveat', cursive; font-size: 5.25rem; font-weight: 700; background: linear-gradient(135deg, var(--green), #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 0.02em; line-height: 1; display: inline; }
.hero h1 .brand-rest { }

/* Decorative double helix accent above hero title */
.hero-deco {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}
.hero-deco .deco-icon {
  width: 48px;
  height: 48px;
  display: inline-block;
  animation: spinY 10s linear infinite;
  filter: drop-shadow(0 0 8px rgba(56,189,248,.3));
}
@keyframes spinY {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 2rem; }
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--accent);
  color: #0f172a;
  padding: .75rem 2rem;
  border-radius: 99px;
  font-weight: 700;
  font-size: 1rem;
  transition: all .3s;
  border: none;
  cursor: pointer;
}
.hero-btn:hover { background: var(--accent-hover); transform: translateY(-3px); box-shadow: 0 12px 40px rgba(56,189,248,.35); color: #0f172a; }
.hero-btn:active { transform: translateY(0); box-shadow: 0 4px 12px rgba(56,189,248,.2); transition-duration: .1s; }

/* Module cards */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s ease, border-color .3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.module-card:hover { transform: translateY(-6px); border-color: var(--accent); box-shadow: 0 12px 40px rgba(56,189,248,.12), 0 4px 12px rgba(0,0,0,.08); }
.module-card:active { transform: translateY(-2px); transition-duration: .1s; }
.module-card .icon { margin-bottom: .75rem; line-height: 1; }
.module-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.module-card p { font-size: .8rem; color: var(--text-muted); margin-bottom: 1rem; }
.module-card .tag {
  display: inline-block;
  font-size: .65rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-weight: 600;
  margin-right: .25rem;
  margin-bottom: .25rem;
}
.module-card[data-part="Foundations"] .tag { background: rgba(56,189,248,.12); color: var(--accent); }
.module-card[data-part="Programming"] .tag { background: rgba(167,139,250,.12); color: var(--purple); }
.module-card[data-part="Data & Formats"] .tag { background: rgba(74,222,128,.12); color: var(--green); }
.module-card[data-part="Analysis"] .tag { background: rgba(251,146,60,.12); color: var(--orange); }
.module-card .progress-mini {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
}
.module-card .progress-mini-fill {
  height: 100%;
  background: var(--green);
  transition: width .5s;
}

/* Module page */
.module-page { animation: fadeIn .3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.module-header {
  padding: 2rem;
  background: linear-gradient(135deg, rgba(56,189,248,.08), rgba(167,139,250,.08));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}
.module-header h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: .5rem; }
.module-header .meta { display: flex; gap: 1.5rem; color: var(--text-muted); font-size: .85rem; flex-wrap: wrap; }

/* Tabs */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .75rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; animation: fadeIn .3s; }
.tab-content.active { display: block; }

/* Lesson content */
.lesson h2 { font-size: 1.4rem; font-weight: 700; margin: 2rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.lesson h2:first-child { border-top: none; padding-top: 0; }
.lesson h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 .75rem; color: var(--accent); }
.lesson p { margin-bottom: 1rem; }
.lesson ul, .lesson ol { margin: 0 0 1rem 1.5rem; }
.lesson li { margin-bottom: .4rem; }
.lesson pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: .85rem;
  line-height: 1.6;
}
.lesson code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .85em;
}
.lesson p code, .lesson li code {
  background: var(--code-bg);
  padding: .15rem .4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.lesson .callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border-left: 4px solid var(--accent);
  background: rgba(56,189,248,.08);
}
.lesson .callout.warning { border-left-color: var(--orange); background: rgba(251,146,60,.08); }
.lesson .callout.tip { border-left-color: var(--green); background: rgba(74,222,128,.08); }
.lesson .callout strong { display: block; margin-bottom: .25rem; }

/* Terminal simulator */
.terminal {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.terminal-bar {
  background: #161b22;
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  border-bottom: 1px solid #30363d;
}
.terminal-bar .dot { width: 10px; height: 10px; border-radius: 50%; }
.terminal-bar .dot.r { background: #f87171; }
.terminal-bar .dot.y { background: #fbbf24; }
.terminal-bar .dot.g { background: #4ade80; }
.terminal-bar .title { margin-left: .5rem; font-size: .75rem; color: #8b949e; }
.terminal-body {
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}
.terminal-body .line { margin-bottom: .25rem; white-space: pre-wrap; word-break: break-all; }
.terminal-body .prompt { color: var(--green); }
.terminal-body .output { color: #c9d1d9; }
.terminal-body .error { color: var(--red); }
.terminal-input-line { display: flex; align-items: center; }
.terminal-input-line .prompt { color: var(--green); margin-right: .5rem; }
.terminal-input {
  background: none;
  border: none;
  color: #c9d1d9;
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
  flex: 1;
  outline: none;
  caret-color: var(--green);
}

/* Quiz */
.quiz-container { margin-top: 1rem; }
.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.quiz-question h4 { font-size: .95rem; margin-bottom: 1rem; display: flex; gap: .5rem; }
.quiz-question h4 .q-num {
  background: var(--accent);
  color: #0f172a;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: .75rem 1rem;
  margin-bottom: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  transition: all .2s;
}
.quiz-option:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.quiz-option.correct { border-color: var(--green); background: rgba(74,222,128,.1); }
.quiz-option.wrong { border-color: var(--red); background: rgba(248,113,113,.1); }
.quiz-option.disabled { pointer-events: none; }
.quiz-explanation {
  margin-top: .5rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .8rem;
  display: none;
}
.quiz-explanation.show { display: block; }
.quiz-explanation.correct-exp { background: rgba(74,222,128,.1); color: var(--green); }
.quiz-explanation.wrong-exp { background: rgba(248,113,113,.1); color: var(--red); }
.quiz-score {
  text-align: center;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.quiz-score h3 { font-size: 1.5rem; margin-bottom: .5rem; }
.quiz-score .score-num { font-size: 3rem; font-weight: 800; color: var(--accent); }
.quiz-reset {
  margin-top: 1rem;
  padding: .5rem 1.5rem;
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

/* Forum */
.forum-container { margin-top: 1rem; }
.comment-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.comment-form h4 { margin-bottom: 1rem; }
.comment-form input, .comment-form textarea {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  margin-bottom: .75rem;
  resize: vertical;
}
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--accent); }
.comment-form textarea { min-height: 100px; }
.comment-submit {
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: .6rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.comment-submit:hover { background: var(--accent-hover); }
.comment {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.comment-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.comment-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
}
.comment-meta .name { font-weight: 600; font-size: .9rem; }
.comment-meta .time { font-size: .75rem; color: var(--text-muted); }
.comment-body { font-size: .9rem; line-height: 1.6; }
.comment-actions { margin-top: .75rem; display: flex; gap: 1rem; }
.comment-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.comment-actions button:hover { color: var(--accent); }
.no-comments { text-align: center; color: var(--text-muted); padding: 2rem; }

/* Nav buttons */
.module-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  transition: all .2s;
}
.nav-btn:hover { border-color: var(--accent); background: var(--bg-card-hover); }

/* Card description */
.card-desc { font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; flex: 1; }

/* Focus styles */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Selection */
::selection { background: rgba(56,189,248,.25); color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.3); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content { padding: 1rem; }
  .hero { padding: 2rem 1rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero h1 .brand-bio { font-size: 3.5rem; }
  .modules-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: .95rem; }
  .module-header h1 { font-size: 1.4rem; }
  .tabs { gap: 0; }
  .tab-btn { padding: .6rem .75rem; font-size: .8rem; }
}
