:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #24211c;
  --muted: #6b645a;
  --border: #e3ded4;
  --accent: #6b4e2e;
  --accent-text: #ffffff;
  --accent-soft: #f1ebe2;
  --error-bg: #fbeaea;
  --error-text: #8a1f1f;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191714;
    --surface: #23201c;
    --text: #ece7df;
    --muted: #a69e92;
    --border: #3a352e;
    --accent: #d2ab7c;
    --accent-text: #1b1712;
    --accent-soft: #2e2820;
    --error-bg: #3a1f1f;
    --error-text: #f2b8b8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--sans);
}

a { color: var(--accent); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 0.5rem;
}
.brand { font: 600 1.25rem var(--serif); color: var(--text); text-decoration: none; }
.site-header nav { display: flex; gap: 1rem; font-size: 0.95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }

main { max-width: 46rem; margin: 0 auto; padding: 0.5rem 1rem 4rem; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.25; }
h1 { font-size: 1.85rem; margin: 1rem 0 0.5rem; }
.lede { color: var(--muted); margin-top: 0; }

.field { margin: 1.25rem 0; border: 0; padding: 0; min-width: 0; }
.field-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
label, legend { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.optional { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.35rem 0 0; }

input[type=text], input[type=url], input[type=password], select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.segmented label {
  font-weight: 500;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}
.segmented label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.segmented input { margin: 0 0.35rem 0 0; accent-color: var(--accent); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
#generate { width: 100%; padding: 0.85rem; font-size: 1.05rem; margin-top: 0.5rem; }

.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.loading { text-align: center; padding: 5rem 1rem; }
.spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.lesson-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 1rem 0; }
.meta { color: var(--muted); font-size: 0.9rem; margin: 0; }
.lesson-title h1 { margin-top: 0.25rem; }
.big-idea { font-family: var(--serif); font-size: 1.15rem; background: var(--accent-soft); border-radius: var(--radius); padding: 0.85rem 1rem; }

.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; }
.section > summary { cursor: pointer; padding: 0.75rem 1rem; list-style-position: inside; }
.section > summary h2 { display: inline; font-size: 1.25rem; margin: 0; }
.section-body { padding: 0 1rem 1rem; }
.passage h3, .activity h3 { font-size: 1.05rem; margin: 1rem 0 0.25rem; }
.duration { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 0.9rem; }
.questions > li { margin-bottom: 1.25rem; }
.question { font-weight: 600; margin-bottom: 0.25rem; }
.questions p { margin: 0.25rem 0; }
.facilitator { color: var(--muted); font-size: 0.95rem; }
.activity + .activity { border-top: 1px solid var(--border); margin-top: 1rem; }

.blocked { border: 1px solid var(--error-text); background: var(--error-bg); border-radius: var(--radius); padding: 0.5rem 1.25rem 1rem; }

.assistant { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.assistant h2 { margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.chip { border-radius: 999px; font-size: 0.9rem; padding: 0.4rem 0.85rem; }
.chip:hover { border-color: var(--accent); }
#assistant-form { display: flex; gap: 0.5rem; }
#assistant-form input { flex: 1; min-width: 0; }

.history { list-style: none; padding: 0; }
.history li { display: flex; gap: 0.5rem; align-items: stretch; margin-bottom: 0.5rem; }
.history-open { flex: 1; text-align: left; display: flex; flex-direction: column; min-width: 0; }
.history-title { font-weight: 600; }
.history-delete { color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.prose { max-width: 40rem; }
.prose h2 { font-size: 1.25rem; margin-top: 2rem; }
