:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2622;
  --muted: #6f655c;
  --border: #e6ddd2;
  --accent: #b5532a;
  --accent-text: #ffffff;
  --accent-soft: #f6e6dc;
  --ok: #2f7d4f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1917;
    --surface: #25221f;
    --text: #ece6df;
    --muted: #a99f95;
    --border: #3a3531;
    --accent: #e0835a;
    --accent-text: #1b1917;
    --accent-soft: #3a2a22;
    --ok: #6cc592;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--serif);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0.2em 0 0.5em; }
h2 { font: 600 1.15rem var(--sans); margin-top: 0; }
h3 { font: 600 1.05rem var(--sans); margin: 1.6em 0 0.3em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.site-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  max-width: 760px; margin: 0 auto; padding: 1rem 16px;
}
.brand { font: 700 1.1rem var(--sans); color: var(--text); text-decoration: none; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 3rem; }
.site-footer { max-width: 760px; margin: 0 auto; padding: 1.5rem 16px 2.5rem; border-top: 1px solid var(--border); font: 0.85rem var(--sans); color: var(--muted); }

button, select, input, textarea { font: inherit; color: inherit; }
button {
  font-family: var(--sans); font-size: 0.95rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.55em 1em; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.pill { border-radius: 999px; font-size: 0.85rem; padding: 0.4em 0.9em; }
.pill.ready { border-color: var(--ok); color: var(--ok); }

/* home */
.hero { padding: 1.5rem 0 1rem; }
.lede { font-size: 1.15rem; }
.lesson-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.6rem; }
.lesson-list a {
  display: grid; grid-template-columns: 2.2rem 1fr auto; align-items: center; gap: 0.8rem;
  padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.lesson-list a:hover { border-color: var(--accent); }
.lesson-list .num {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font: 700 0.95rem var(--sans);
}
.lesson-list a.done .num { background: var(--ok); color: var(--surface); }
.lesson-list .title { font-size: 1.1rem; }
.lesson-list .meta { font: 0.85rem var(--sans); color: var(--muted); white-space: nowrap; }

/* lesson */
.crumbs { font: 0.9rem var(--sans); padding-top: 0.5rem; }
.eyebrow { font: 600 0.8rem var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin: 1.5rem 0 0; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: 0.3em 0; }
.formula {
  margin: 1.2rem 0; padding: 0.9rem 1rem; text-align: center;
  background: var(--accent-soft); border-radius: 10px; font: 600 1.05rem var(--sans);
}
.spine { list-style: none; padding: 0 !important; counter-reset: s; }
.spine li { counter-increment: s; padding: 0.35em 0; border-bottom: 1px dashed var(--border); }
.spine li::before { content: counter(s) "."; color: var(--muted); font-family: var(--sans); margin-right: 0.5em; }
.spine span { color: var(--muted); font-size: 0.92rem; }
.shapes { width: 100%; border-collapse: collapse; font: 0.9rem/1.45 var(--sans); display: block; overflow-x: auto; }
.shapes th, .shapes td { text-align: left; vertical-align: top; padding: 0.55em 0.6em; border-bottom: 1px solid var(--border); }
.shapes th { color: var(--muted); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; margin: 2rem 0; }
.exercise { border-color: var(--accent); }
.field { margin: 0.9rem 0; }
.field label { display: block; font: 600 0.9rem var(--sans); margin-bottom: 0.3rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.6em 0.7em; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field :focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.ai-output { white-space: pre-wrap; margin-top: 1rem; }
.ai-output:not(:empty), .ai-output.busy { padding: 1rem; background: var(--bg); border-left: 3px solid var(--accent); border-radius: 6px; }
.ai-output.busy:empty::after { content: "Thinking…"; color: var(--muted); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.3em 0; }
.checklist input { accent-color: var(--ok); transform: scale(1.15); }

.pager { display: flex; justify-content: space-between; gap: 1rem; font: 0.95rem var(--sans); }

dialog {
  max-width: min(460px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); padding: 1.3rem;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.model-option {
  display: grid; gap: 0.15rem; width: 100%; text-align: left; margin: 0.6rem 0; padding: 0.8rem 1rem;
}
.model-option span { font-size: 0.85rem; }
.progress { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 1rem; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
