:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #f7f4ef;
  --card: #fffdf9;
  --line: #e4ddd2;
  --sidebar: #1e1a16;
  --sidebar-2: #2a241e;
  --sidebar-text: #f4efe8;
  --sidebar-dim: #b7aa9c;
  --accent: #9a3412;
  --accent-2: #c2410c;
  --good: #3f6212;
  --good-bg: #ecfccb;
  --bad: #9f1239;
  --bad-bg: #ffe4e6;
  --say: #fff7ed;
  --say-line: #c2410c;
  --shadow: none;
  --sans: "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

#app { min-height: 100%; }

.landing { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.brand { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 28px;
  align-items: start;
}
h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 42px;
  line-height: 1.1;
  margin: 0 0 12px;
}
.lede { font-size: 18px; line-height: 1.5; color: var(--muted); margin: 0 0 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--sidebar-text); border-color: #4a4036; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.meta { color: var(--muted); font-size: 14px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}
.panel h2, .block h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  margin: 28px 0 10px;
}
.learn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.learn-grid li { padding-left: 18px; position: relative; line-height: 1.4; }
.learn-grid li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }

.progress-card .bar, .player-progress .bar {
  height: 8px;
  background: #efe8de;
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
}
.player-progress .bar { background: #3a322b; }
.bar > span { display: block; height: 100%; background: var(--accent-2); }
.statline { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

.curriculum { margin-top: 28px; }
.section-block { border-top: 1px solid var(--line); }
.section-head {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.section-head strong { display: block; }
.section-head span { color: var(--muted); font-size: 13px; }
.lecture-row {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 0 8px 8px;
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--ink);
}
.lecture-row .min { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.check {
  width: 16px;
  height: 16px;
  border: 1.5px solid #a8a095;
  border-radius: 50%;
  flex: 0 0 16px;
  margin-top: 2px;
}
.check.on { background: var(--good); border-color: var(--good); }

.player { display: grid; grid-template-columns: 320px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-head { padding: 16px 16px 10px; border-bottom: 1px solid #3a322b; }
.side-head a { color: var(--sidebar-text); text-decoration: none; font-family: var(--serif); font-size: 18px; }
.player-progress { padding: 0; }
.side-search {
  margin: 10px 16px;
  width: calc(100% - 32px);
  background: var(--sidebar-2);
  color: var(--sidebar-text);
  border: 1px solid #4a4036;
  border-radius: 4px;
  padding: 8px 10px;
}
.side-scroll { overflow: auto; padding: 0 8px 24px; }
.side-section { margin-top: 8px; }
.side-label {
  padding: 10px 8px 4px;
  font-weight: 650;
  color: var(--sidebar-text);
}
.side-section .count { float: right; color: var(--sidebar-dim); font-weight: 500; font-size: 12px; }
.side-lecture {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--sidebar-dim);
  border: 0;
  padding: 8px 8px 8px 28px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-radius: 4px;
}
.side-lecture.active { background: var(--sidebar-2); color: white; }
.side-lecture .min { margin-left: auto; font-size: 12px; }
.side-lecture .check { border-color: #8a7d70; }
.stage { display: flex; flex-direction: column; min-width: 0; }
.stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 2;
}
.lesson {
  padding: 28px 28px 40px;
  max-width: 820px;
}
.kicker { color: var(--accent); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 8px; }
.lesson h1 { font-size: 34px; }
.objective { color: var(--muted); margin-top: 0; }
.prose p, .prose li { line-height: 1.55; font-size: 17px; }
.prose h2 { font-size: 24px; }
.say, .note {
  border: 1px solid var(--line);
  border-left: 4px solid var(--say-line);
  background: var(--say);
  padding: 12px 14px;
  margin: 16px 0;
  border-radius: 4px;
}
.say strong, .note strong { display: block; margin-bottom: 4px; }
.note { background: #f4f1ea; border-left-color: #57534e; }
table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 15px; }
th, td { border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; padding: 8px 10px 8px 0; }
th { font-size: 13px; color: var(--muted); font-weight: 650; }
.diagram {
  margin: 16px 0 8px;
  overflow: auto;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.diagram .mermaid { background: transparent; }
pre {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 12px 14px;
  overflow: auto;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.stage-nav {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  bottom: 0;
}
.quiz-q { margin: 18px 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.choice {
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--card);
}
.choice.picked { border-color: var(--accent); }
.choice.right { background: var(--good-bg); border-color: var(--good); }
.choice.wrong { background: var(--bad-bg); border-color: var(--bad); }
.why { color: var(--muted); font-size: 15px; }
.menu-btn { display: none; }
.timer { font-variant-numeric: tabular-nums; font-size: 28px; font-family: var(--serif); }

@media (max-width: 860px) {
  .hero, .learn-grid { grid-template-columns: 1fr; }
  h1 { font-size: 32px; }
  .player { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(340px, 92vw);
    z-index: 5;
    transform: translateX(-105%);
    transition: transform 0.15s ease;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .lesson { padding: 20px 16px 32px; }
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 4;
  }
}
