:root {
  --ink: #0E1013;
  --panel: #14171C;
  --surface: #181C22;
  --bone: #F2EFE9;
  --muted: #A8A59C;
  --line: #262B33;
  --amber: #FFB224;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, svg, pre, table { max-width: 100%; }
.lesson-section svg { width: 100%; height: auto; display: block; }

h1, h2, h3, .brand-name, .stat-value, .phase-number {
  font-family: "Space Grotesk", system-ui, sans-serif;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

a { color: var(--bone); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--amber); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

#chooser, #lessonView, #curriculum { scroll-margin-top: 90px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--amber);
  color: var(--ink);
  padding: 0.6rem 1rem;
  font-weight: 600;
}
.skip-link:focus { left: 0.75rem; top: 0.75rem; z-index: 50; }

/* Topbar: order control is a distinct pill, not a footnote */
.topbar {
  background: var(--ink);
  color: var(--bone);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  background: var(--surface); color: var(--bone);
  border: 1px solid var(--line);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700; font-size: 1.35rem;
  border-radius: 3px;
  position: relative;
}
.brand-mark::after {
  content: "";
  width: 7px; height: 7px;
  background: var(--amber);
  border-radius: 50%;
  position: absolute;
  right: 6px; bottom: 6px;
}
.brand-name { margin: 0; font-weight: 700; font-size: 1.08rem; }
.brand-sub { margin: 0; color: var(--muted); font-size: 0.85rem; }
.topbar-controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.order-pill {
  display: flex; gap: 0.55rem; align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.5rem 0.75rem;
}
.order-dot { width: 8px; height: 8px; background: var(--amber); border-radius: 50%; flex: none; }
.order-label { margin: 0; font-size: 0.88rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bone); }

main { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem 2rem; }

.button {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.65rem 1.05rem;
  font: inherit; font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--bone);
}
.button-primary { background: var(--bone); border-color: var(--bone); color: var(--ink); }
.button-secondary { background: transparent; color: var(--bone); }
.button-ghost { border-color: transparent; text-decoration: underline; padding-left: 0.25rem; padding-right: 0.25rem; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.topbar .button-secondary { border-color: var(--bone); }

/* Hero: one idea, real numbers, generous air */
.hero { padding: 4rem 0 2.5rem; max-width: 820px; }
.eyebrow {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 1rem;
}
.hero h1 { font-size: clamp(2.4rem, 6.5vw, 4rem); margin: 0 0 1.25rem; font-weight: 700; }
.hero-text { font-size: 1.2rem; color: var(--bone); margin: 0 0 2rem; max-width: 68ch; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 2.5rem; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 0 2rem;
}
.stat { padding: 1.25rem 1.25rem 1.25rem 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.stat-value { order: 1; }
.stat-label { order: 2; }
.stat:last-child { border-right: 0; padding-right: 0; }
.stat + .stat { padding-left: 1.25rem; }
.stat-value { display: block; font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 700; }
.stat-label { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.88rem; line-height: 1.4; }

.order-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.25rem 1.5rem;
}
.order-strip p { margin: 0 0 0.9rem; color: var(--muted); font-size: 0.95rem; }
.order-steps { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.order-steps li { display: flex; gap: 0.6rem; align-items: baseline; }
.order-steps .step-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--amber); font-weight: 700; }
.order-steps strong { font-family: "Space Grotesk", sans-serif; }

/* Chooser */
.chooser {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--amber);
  border-radius: 3px;
  padding: 1.5rem;
  margin: 0 0 2.5rem;
}
.chooser-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.chooser h2, .lesson-picker h2, .curriculum h2 { margin-top: 0; font-size: clamp(1.5rem, 3.5vw, 2rem); }
.chooser-note, .content-note { color: var(--muted); }
.style-list { list-style: none; margin: 1.25rem 0; padding: 0; display: grid; gap: 0.75rem; }
.style-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.9rem 1rem;
  background: var(--surface);
}
.style-row.is-off { opacity: 0.55; }
.style-row strong { display: block; font-family: "Space Grotesk", sans-serif; }
.style-row p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.93rem; }
.rank-badge {
  display: inline-block;
  background: var(--amber); color: var(--ink);
  border-radius: 2px;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem; font-weight: 700;
  margin-right: 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.style-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.style-actions button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--bone);
  border-radius: 3px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font: inherit; font-size: 0.9rem;
}
.chooser-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.saved-note { color: var(--muted); margin: 0; }

/* Pilot lessons and lesson view as editorial sections */
.lesson-picker { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 1.5rem; margin-bottom: 2.5rem; }
.lesson-picker > p { color: var(--muted); max-width: 68ch; }
.lesson-buttons { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.lesson-view { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 1.5rem; margin-bottom: 2.5rem; }
.lesson-view h2 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); margin: 0.2rem 0 0.5rem; }
.lesson-order { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.lesson-section { border-top: 1px solid var(--line); padding: 2rem 0; }
.lesson-section:first-of-type { border-top: 0; }
.lesson-section h3 { margin-top: 0; font-size: 1.5rem; }
.lesson-section h3 span { color: var(--amber); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.1rem; }
.lesson-section > p { max-width: 68ch; }
pre {
  background: var(--ink); color: var(--bone);
  border: 1px solid var(--line);
  padding: 1.1rem; border-radius: 3px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { margin: 0.6rem 0; }
.diagram {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.1rem;
  background: var(--surface);
}
.diagram-steps { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.diagram-step { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 0.6rem 0.8rem; font-weight: 600; }
.diagram-arrow { font-weight: 700; color: var(--muted); }
.listen-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* Curriculum */
.curriculum { padding-bottom: 2.5rem; }
.curriculum > p { color: var(--muted); max-width: 68ch; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.section-count { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 0.9rem; }
.phase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.phase-card { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 1.25rem; }
.phase-card.is-pilot { border-left: 3px solid var(--amber); }
.phase-number { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.phase-card h3 { margin: 0.4rem 0 0.5rem; font-size: 1.25rem; }
.phase-card p { margin: 0 0 1rem; color: var(--muted); }
.pilot-badge { display: inline-block; color: var(--amber); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; font-weight: 700; }
.phase-links { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.footer p { margin: 0.35rem 0; max-width: 72ch; }
.footer strong { color: var(--bone); }
.footer a { color: var(--bone); }

@media (max-width: 720px) {
  body { font-size: 16px; }
  main { padding-left: 1rem; padding-right: 1rem; }
  .topbar { position: static; }
  .topbar-inner { align-items: stretch; padding: 0.75rem 1rem; flex-direction: column; gap: 0.6rem; }
  .topbar-controls { width: 100%; flex-direction: column; align-items: stretch; }
  .order-pill { flex: none; width: 100%; min-width: 0; }
  .order-label { font-size: 0.82rem; line-height: 1.5; overflow-wrap: anywhere; }
  .topbar-controls .button { width: 100%; min-height: 48px; text-align: center; }
  #topbarStatus { overflow-wrap: anywhere; font-size: 0.88rem; }
  .hero { padding-top: 2.25rem; }
  .hero h1 { font-size: clamp(2rem, 11vw, 2.4rem); overflow-wrap: break-word; }
  .hero-text { font-size: 1.08rem; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .button { width: 100%; min-height: 48px; text-align: center; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 1rem 1rem 1rem 0; min-width: 0; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3) { border-top: 1px solid var(--line); }
  .stat:nth-child(4) { border-top: 1px solid var(--line); }
  .stat + .stat { padding-left: 0; }
  .stat:nth-child(2n) { padding-left: 1rem; }
  .stat-label { overflow-wrap: break-word; }
  .style-row { grid-template-columns: auto minmax(0, 1fr); }
  .style-row input[type="checkbox"] { width: 24px; height: 24px; flex: none; }
  .style-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .style-actions button { width: 100%; min-height: 48px; font-size: 0.95rem; }
  .chooser-head { flex-direction: column; }
  .chooser-actions { flex-direction: column; align-items: stretch; }
  .chooser-actions .button { width: 100%; min-height: 48px; text-align: center; }
  .lesson-buttons { flex-direction: column; align-items: stretch; }
  .lesson-buttons .button { width: 100%; min-height: 48px; text-align: left; }
  .lesson-view, .lesson-picker, .chooser, .order-strip { padding: 1.1rem; min-width: 0; }
  .lesson-view h2, .lesson-picker h2, .curriculum h2, .chooser h2 { overflow-wrap: break-word; }
  .order-steps { flex-direction: column; gap: 0.5rem; }
  .phase-grid { grid-template-columns: 1fr; }
  .phase-card { min-width: 0; }
  .phase-links { flex-direction: column; align-items: stretch; }
  .phase-links .button { width: 100%; min-height: 48px; text-align: center; }
  .phase-links a { min-height: 48px; display: flex; align-items: center; }
  .listen-row { flex-direction: column; align-items: stretch; }
  .listen-row .button { width: 100%; min-height: 48px; }
  .checklist input[type="checkbox"] { width: 22px; height: 22px; }
  .checklist li { display: flex; gap: 0.6rem; align-items: flex-start; }
  pre { padding: 0.9rem; font-size: 0.88rem; overflow-x: auto; overflow-wrap: anywhere; }
  code { overflow-wrap: anywhere; word-break: break-word; }
  .footer { padding-left: 1rem; padding-right: 1rem; }
  .footer a { overflow-wrap: anywhere; word-break: break-word; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  main { padding-left: 0.9rem; padding-right: 0.9rem; }
  .brand-mark { width: 2.25rem; height: 2.25rem; font-size: 1.2rem; }
  .hero { padding-top: 1.75rem; padding-bottom: 1.75rem; }
  .hero h1 { font-size: 2rem; }
  .hero-stats { grid-template-columns: 1fr; }
  .stat { padding: 1rem 0; border-right: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .stat:nth-child(2n) { padding-left: 0; }
  .stat:nth-child(3), .stat:nth-child(4) { border-top: 1px solid var(--line); }
  .stat-value { font-size: 1.9rem; }
  .style-row { grid-template-columns: auto minmax(0, 1fr); padding: 0.9rem; }
  .style-row p { overflow-wrap: break-word; }
  .lesson-view, .lesson-picker, .chooser, .order-strip { padding: 1rem; }
  .lesson-section { padding: 1.5rem 0; }
  .lesson-section h3 { font-size: 1.3rem; overflow-wrap: break-word; }
  .lesson-order { overflow-wrap: anywhere; font-size: 0.82rem; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .button { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
