@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink: #1a1a2e;
  --ink-light: #4a4a6a;
  --ink-faint: #8888aa;
  --paper: #faf9f6;
  --paper-warm: #f5f2eb;
  --paper-card: #ffffff;
  --accent: #c0392b;
  --accent-light: #e74c3c;
  --accent-warm: #e67e22;
  --accent-green: #27ae60;
  --accent-blue: #2980b9;
  --border: #e8e4da;
  --border-strong: #c8c2b2;
  --shadow-soft: 0 2px 12px rgba(26,26,46,0.06);
  --shadow-mid: 0 4px 24px rgba(26,26,46,0.1);
  --shadow-lift: 0 8px 40px rgba(26,26,46,0.14);
  --radius: 4px;
  --radius-lg: 8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
}

/* ── NAVBAR ── */
nav {
  background: var(--ink);
  padding: 0 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 3px solid var(--accent);
}

.nav-brand {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  text-decoration: none;
  padding: 18px 0;
  margin-right: auto;
  letter-spacing: -0.02em;
}

.nav-brand span { color: var(--accent); }

nav a:not(.nav-brand) {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 20px 18px;
  transition: color 0.2s, background 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}

nav a:not(.nav-brand):hover,
nav a:not(.nav-brand).active {
  color: white;
  border-bottom-color: var(--accent);
}

/* ── LAYOUT ── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 60px 24px;
}

.container-wide {
  max-width: 1080px;
  margin: 0 auto;
  padding: 60px 24px;
}

/* ── TYPOGRAPHY ── */
h1 {
  font-family: 'Lora', serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 12px;
}

h2 {
  font-family: 'Lora', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

h3 {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  color: var(--accent);
}

p { color: var(--ink-light); margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: 1.1rem;
  color: var(--ink-light);
  margin-bottom: 0;
  line-height: 1.65;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  margin-bottom: 8px;
}

/* ── SECTIONS / CARDS ── */
section {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.2s;
}

section:hover { box-shadow: var(--shadow-mid); }

.section-accent {
  border-left: 4px solid var(--accent);
}

.section-green {
  border-left: 4px solid var(--accent-green);
  background: #f0faf4;
}

.section-blue {
  border-left: 4px solid var(--accent-blue);
  background: #f0f6ff;
}

.section-warn {
  border-left: 4px solid var(--accent-warm);
  background: #fffbf0;
}

/* ── MATH DISPLAY ── */
.math-block {
  background: var(--paper-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.8;
}

.math-block .step {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 3px 0;
}

.math-block .step-num {
  font-size: 0.7rem;
  color: var(--ink-faint);
  min-width: 18px;
  font-family: 'DM Sans', sans-serif;
}

.math-inline {
  font-family: 'JetBrains Mono', monospace;
  background: var(--paper-warm);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.95em;
  border: 1px solid var(--border);
}

/* ── LISTS ── */
ul, ol {
  padding-left: 24px;
  color: var(--ink-light);
}

li { margin-bottom: 6px; }

.check-list { list-style: none; padding-left: 0; }
.check-list li { padding-left: 24px; position: relative; }
.check-list li::before { position: absolute; left: 0; }
.check-list .ok::before { content: '✓'; color: var(--accent-green); font-weight: 700; }
.check-list .bad::before { content: '✗'; color: var(--accent); font-weight: 700; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--ink);
  color: white;
}
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-mid); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-light); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
}
.btn-outline:hover { border-color: var(--ink); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

/* ── PROGRESS ── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ── UNIT CARDS ── */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.unit-card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.unit-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}

.unit-card.u1::before { background: var(--accent); }
.unit-card.u2::before { background: var(--accent-blue); }
.unit-card.u3::before { background: var(--accent-green); }
.unit-card.u4::before { background: var(--accent-warm); }

.unit-card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-3px);
}

.unit-card .unit-num {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.unit-card h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.unit-card p { font-size: 0.9rem; margin: 0; }

.unit-card .lesson-count {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── LESSON LIST ── */
.lesson-list {
  list-style: none;
  padding: 0;
}

.lesson-list li {
  margin: 0;
}

.lesson-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
  border-radius: var(--radius);
  transition: background 0.15s;
  margin-bottom: 4px;
}

.lesson-list a:hover { background: var(--paper-warm); }

.lesson-list .lesson-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--paper-warm);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

.lesson-list .lesson-icon.done {
  background: #e8faf1;
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.lesson-list .lesson-title { font-size: 0.95rem; font-weight: 500; }
.lesson-list .lesson-meta { font-size: 0.78rem; color: var(--ink-faint); margin-top: 1px; }

/* ── PAGE HEADER BLOCK ── */
.page-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--ink-faint); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb span { color: var(--border-strong); }

/* ── LESSON NAV ── */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

/* ── INTERACTIVE PRACTICE ── */
.practice-question {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.practice-question h3 {
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 16px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--ink-light);
  transition: all 0.15s;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--paper-warm);
  color: var(--ink);
}

.choice-btn.correct {
  background: #e8faf1;
  border-color: var(--accent-green);
  color: var(--accent-green);
  font-weight: 600;
}

.choice-btn.wrong {
  background: #fdf0f0;
  border-color: var(--accent);
  color: var(--accent);
}

.feedback {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
}

.feedback.show { display: block; }
.feedback.correct { background: #e8faf1; color: #1a7a45; border: 1px solid #a8e6c1; }
.feedback.wrong { background: #fdf0f0; color: #8b1a1a; border: 1px solid #f0a0a0; }

/* ── QUIZ ── */
.quiz-score {
  text-align: center;
  padding: 40px;
  display: none;
}

.quiz-score.show { display: block; }
.quiz-score .big-num {
  font-family: 'Lora', serif;
  font-size: 5rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.quiz-score .big-num span { color: var(--accent); }

/* ── HERO ── */
.hero {
  background: var(--ink);
  color: white;
  padding: 80px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 40px,
    rgba(255,255,255,0.015) 40px,
    rgba(255,255,255,0.015) 41px
  );
}

.hero-inner { position: relative; max-width: 680px; margin: 0 auto; }

.hero h1 {
  color: white;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  margin-bottom: 20px;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero .lead { color: rgba(255,255,255,0.65); font-size: 1.1rem; margin-bottom: 32px; }

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── TAGS ── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag-red { background: #fdf0f0; color: var(--accent); border: 1px solid #f0a0a0; }
.tag-blue { background: #f0f6ff; color: var(--accent-blue); border: 1px solid #a0c8f0; }
.tag-green { background: #e8faf1; color: var(--accent-green); border: 1px solid #a0dfc0; }
.tag-warm { background: #fffbf0; color: var(--accent-warm); border: 1px solid #f0d0a0; }

/* ── SUMMARY BOX ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.summary-item {
  background: var(--paper-warm);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.summary-item .icon { font-size: 1.4rem; margin-bottom: 6px; }
.summary-item .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); font-weight: 500; }
.summary-item .value { font-weight: 600; color: var(--ink); }

/* ── DIVIDER ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  nav { padding: 0 16px; }
  .container, .container-wide { padding: 32px 16px; }
  section { padding: 20px; }
  .unit-grid { grid-template-columns: 1fr; }
  .lesson-nav { flex-direction: column; gap: 12px; }
}