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

:root {
  --sidebar-width: 300px;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1e40af;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #0f172a;
  --code-bg: #f1f5f9;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--accent);
  color: #e2e8f0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 0.78rem;
  color: #94a3b8;
}

.sidebar-nav {
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-nav a .milestone-num {
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  min-width: 22px;
  text-align: center;
}

.sidebar-nav a.active .milestone-num {
  background: var(--primary);
  color: #fff;
}

/* ===== Mobile Toggle ===== */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

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

.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ===== Milestone Section ===== */
.milestone-section {
  display: none;
}

.milestone-section.active {
  display: block;
}

.milestone-hero {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.milestone-hero .tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.milestone-hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 8px;
}

.milestone-hero .subtitle {
  font-size: 1rem;
  color: var(--text-muted);
}

/* ===== Learning Objectives ===== */
.objectives-box {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}

.objectives-box h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.objectives-box ul {
  list-style: none;
  padding: 0;
}

.objectives-box li {
  position: relative;
  padding: 4px 0 4px 22px;
  font-size: 0.9rem;
  color: #1e3a5f;
}

.objectives-box li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ===== Topic Groups (Collapsible) ===== */
.topic-group {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.topic-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
}

.topic-toggle:hover {
  background: var(--bg);
}

.topic-toggle .icon {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.topic-group.open .topic-toggle .icon {
  transform: rotate(45deg);
}

.topic-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.topic-group.open .topic-body {
  display: block;
}

/* ===== Content Typography ===== */
.topic-body h1,
.topic-body h2,
.topic-body h3 {
  color: var(--accent);
  margin: 28px 0 12px;
  line-height: 1.3;
}

.topic-body h1 { font-size: 1.4rem; }
.topic-body h2 { font-size: 1.15rem; }
.topic-body h3 { font-size: 1rem; }

.topic-body p {
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.topic-body ul, .topic-body ol {
  margin: 10px 0 14px 20px;
  font-size: 0.92rem;
}

.topic-body li {
  margin-bottom: 6px;
}

.topic-body strong {
  color: var(--accent);
}

.topic-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.topic-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.topic-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 14px 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.topic-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.topic-body blockquote {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  padding: 12px 16px;
  margin: 14px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  color: #1e3a5f;
}

.topic-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.85rem;
}

.topic-body th, .topic-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.topic-body th {
  background: var(--bg);
  font-weight: 600;
}

.topic-body .math {
  display: block;
  text-align: center;
  padding: 12px 0;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 1rem;
}

/* ===== Summary Box ===== */
.summary-box {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 36px;
}

.summary-box h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #166534;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-box p {
  font-size: 0.9rem;
  color: #14532d;
  margin-bottom: 10px;
}

.summary-box ul {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.summary-box li {
  padding: 4px 0 4px 20px;
  position: relative;
  font-size: 0.88rem;
  color: #14532d;
}

.summary-box li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .content {
    padding: 60px 16px 60px;
  }

  .milestone-hero h1 {
    font-size: 1.4rem;
  }
}
