:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #1a1d29;
  --text-dim: #5b6072;
  --border: #e2e4ec;
  --accent: #4f46e5;
  --accent-2: #0ea5a4;
  --accent-soft: #eef0ff;
  --simple: #b45309;
  --intermediate: #0369a1;
  --structured: #15803d;
  --radius: 12px;
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #161925;
    --surface-2: #1f2333;
    --text: #eef0f6;
    --text-dim: #9aa0b4;
    --border: #2a2e40;
    --accent: #818cf8;
    --accent-2: #2dd4bf;
    --accent-soft: #23264a;
    --simple: #f2b477;
    --intermediate: #7dd3fc;
    --structured: #86efac;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Top bar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.progress-pill {
  font-size: 0.8rem; color: var(--text-dim);
  background: var(--surface-2); border-radius: 999px; padding: 6px 14px;
}

/* Hero */
.hero { padding: 56px 0 40px; }
.hero h1 { font-size: 2.1rem; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero p { color: var(--text-dim); max-width: 640px; font-size: 1.05rem; }
.hero .tags { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 0.78rem; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 5px 12px; font-weight: 600;
}

/* Module list on index */
.modules { display: flex; flex-direction: column; gap: 18px; margin: 32px 0 60px; }
.module-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.module-head {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; cursor: pointer;
}
.module-num {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.module-head h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.module-head .count { font-size: 0.8rem; color: var(--text-dim); }
.chevron { transition: transform 0.2s ease; color: var(--text-dim); }
.module-card.open .chevron { transform: rotate(90deg); }

.lesson-list { border-top: 1px solid var(--border); display: none; }
.module-card.open .lesson-list { display: block; }
.lesson-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 68px;
  border-top: 1px solid var(--border);
}
.lesson-row:first-child { border-top: none; }
.lesson-row .lnum { color: var(--text-dim); font-size: 0.85rem; width: 26px; flex-shrink: 0; }
.lesson-row a { color: var(--text); font-size: 0.92rem; flex: 1; }
.lesson-row a:hover { color: var(--accent); text-decoration: none; }
.check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border); flex-shrink: 0; }
.check.done { background: var(--structured); border-color: var(--structured); }

/* Lesson page */
.lesson-shell { display: grid; grid-template-columns: 260px 1fr; gap: 40px; padding: 32px 0 80px; }
@media (max-width: 860px) { .lesson-shell { grid-template-columns: 1fr; } .side { display: none; } }

.side { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.side .mod-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 18px 0 6px; }
.side a.slink { display: block; padding: 6px 10px; border-radius: 8px; font-size: 0.87rem; color: var(--text-dim); }
.side a.slink.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a.slink:hover { text-decoration: none; color: var(--text); }

.crumb { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 10px; }
.lesson-title { font-size: 1.7rem; margin: 0 0 6px; letter-spacing: -0.01em; }
.lesson-subtitles { list-style: none; padding: 0; margin: 14px 0 30px; display: flex; flex-direction: column; gap: 6px; }
.lesson-subtitles li { color: var(--text-dim); font-size: 0.95rem; padding-left: 18px; position: relative; }
.lesson-subtitles li::before { content: "•"; color: var(--accent); position: absolute; left: 0; }

.video-embed { aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin: 0 0 20px; background: var(--surface-2); }
.video-embed iframe { width: 100%; height: 100%; border: 0; }
.video-pending { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); font-size: 0.9rem; text-align: center; padding: 20px; }

.read-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 26px; }

.read-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  border-radius: 999px; padding: 9px 18px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
}
.read-btn:hover { border-color: var(--accent); }
.read-btn.active { background: var(--accent); color: #fff; }

.read-select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-size: 0.82rem; cursor: pointer;
  max-width: 190px;
}
.read-select:focus { outline: none; border-color: var(--accent); }

.tts-panel { display: none; background: #0f172a; border-radius: var(--radius); padding: 14px 16px; margin: -10px 0 26px; }
.tts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tts-c { background: #1e293b; border: 1px solid #334155; color: #e2e8f0; border-radius: 6px; width: 34px; height: 30px; font-size: 14px; cursor: pointer; }
.tts-c:hover { background: #334155; }
.tts-c.tts-x { color: #fca5a5; }
.tts-count { margin-left: auto; color: #94a3b8; font-size: 0.78rem; }
.tts-bar { height: 7px; background: #1e293b; border-radius: 4px; cursor: pointer; overflow: hidden; }
.tts-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }
.tts-now { margin-top: 10px; color: #cbd5e1; font-size: 0.88rem; line-height: 1.6; }

.section-block { margin-bottom: 30px; }
.section-block h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 10px; }
.prose p { margin: 0 0 16px; font-size: 1.02rem; }
.prose { color: var(--text); }

.recall-box {
  background: var(--surface-2); border-radius: var(--radius); padding: 18px 20px; margin-top: 8px;
}
.recall-box h4 { margin: 0 0 10px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.recall-box ul { margin: 0; padding-left: 18px; }
.recall-box li { margin-bottom: 6px; font-size: 0.95rem; }

.test-yourself {
  background: #1a1d29; color: #eef0f6; border-radius: var(--radius); padding: 20px 22px; margin-top: 10px;
}
@media (prefers-color-scheme: dark) { .test-yourself { background: #0a0c12; } }
.test-yourself h4 { margin: 0 0 12px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }
.test-yourself .qa { margin-bottom: 10px; font-size: 0.93rem; }
.test-yourself .qa b { color: var(--accent-2); }

/* 3-tier prompt practice */
.practice-task { font-size: 0.95rem; color: var(--text-dim); margin-bottom: 16px; }
.prompt-tiers { display: flex; flex-direction: column; gap: 14px; }
.prompt-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.prompt-card .tier-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface-2); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.prompt-card .dot { width: 9px; height: 9px; border-radius: 50%; }
.prompt-card.simple .dot { background: var(--simple); }
.prompt-card.intermediate .dot { background: var(--intermediate); }
.prompt-card.structured .dot { background: var(--structured); }
.prompt-card pre { margin: 0; padding: 16px; font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.87rem; white-space: pre-wrap; background: var(--surface); }

.nav-buttons { display: flex; justify-content: space-between; margin-top: 46px; gap: 14px; }
.nav-btn { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; font-size: 0.9rem; background: var(--surface); flex: 1; }
.nav-btn.next { text-align: right; }
.nav-btn .label { display: block; color: var(--text-dim); font-size: 0.75rem; margin-bottom: 3px; }
.nav-btn:hover { border-color: var(--accent); text-decoration: none; }

.mark-done-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 10px 20px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; margin-top: 30px;
}
.mark-done-btn.done { background: var(--structured); }

.empty-note { color: var(--text-dim); font-size: 0.9rem; font-style: italic; }

footer { border-top: 1px solid var(--border); padding: 30px 0; color: var(--text-dim); font-size: 0.85rem; text-align: center; }
