:root {
  --brand: #013D78;
  --gold: #B0832E;
  --ink: #23242a;
  --muted: #6b6f76;
  --line: #e7e4dd;
  --bg: #faf8f4;
  --card: #ffffff;
  --radius: 14px;
  --maxw: 760px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.appbar__brand {
  color: #fff;
  font-weight: 800;
  letter-spacing: .04em;
  text-decoration: none;
  font-size: .95rem;
}
.appbar__back {
  background: rgba(255,255,255,.15);
  border: 0;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 9px;
  font-size: 1.1rem;
  cursor: pointer;
}
.appbar__spacer { flex: 1; }
.modeswitch {
  display: inline-flex;
  background: rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 3px;
}
.modeswitch button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.85);
  font-size: .78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.modeswitch button.is-active { background: #fff; color: var(--brand); }

/* ---------- Layout ---------- */
.app { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 64px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.appfoot {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Home ---------- */
.hero { text-align: center; padding: 14px 6px 26px; }
.hero__mark { width: 124px; height: 124px; border-radius: 50%; margin: 0 auto 12px; display: block; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.hero h1 { font-size: 1.7rem; margin: 0 0 6px; letter-spacing: -.01em; }
.hero p { color: var(--muted); margin: 0; }
.hero__tag { font-weight: 600; color: var(--ink); }

/* About / intro */
.about { margin: 4px 2px 20px; }
.about > p { color: var(--muted); margin: 0 0 4px; }
.section-title { font-size: 1.25rem; margin: 20px 0 4px; text-align: center; }
.section-sub { color: var(--muted); font-size: .92rem; margin: 0 auto; max-width: 52ch; text-align: center; }
.about-foot { color: var(--muted); font-size: .85rem; text-align: center; margin: 18px 4px 0; }
.track-card .tagline { font-weight: 700; color: var(--c, var(--brand)); font-size: .9rem; margin: 1px 0 5px; }

.track-grid { display: grid; gap: 14px; }
.track-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--c, var(--brand));
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.track-card:active { transform: scale(.99); }
.track-card__icon { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 50%; }
.track-card__body { min-width: 0; }
.track-card h2 { margin: 0; font-size: 1.2rem; color: var(--c, var(--brand)); letter-spacing: .02em; }
.track-card .sub { font-weight: 600; color: var(--ink); margin: 2px 0 6px; }
.track-card .blurb { color: var(--muted); font-size: .9rem; margin: 0; }
.track-card .count { color: var(--c, var(--brand)); font-size: .8rem; font-weight: 700; margin-top: 8px; }

/* ---------- Track page ---------- */
.page-head { margin: 4px 0 18px; }
.page-head--track { display: flex; align-items: center; gap: 14px; }
.page-head__icon { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 50%; box-shadow: var(--shadow); }
.page-head .eyebrow { color: var(--brand); font-weight: 800; letter-spacing: .08em; font-size: .72rem; text-transform: uppercase; }
.page-head h1 { margin: 4px 0 4px; font-size: 1.6rem; }
.page-head p { margin: 0; color: var(--muted); }

.lesson-list { display: grid; gap: 10px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.lesson-item .num {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 12%, #fff);
  color: var(--brand);
  border-radius: 9px;
  font-weight: 800;
  font-size: .9rem;
}
.lesson-item .meta { min-width: 0; display: flex; flex-direction: column; }
.lesson-item .meta .t { font-weight: 700; line-height: 1.3; }
.lesson-item .meta .r { color: var(--muted); font-size: .82rem; }
.lesson-item .chev { margin-left: auto; color: var(--muted); }

/* ---------- Lesson page ---------- */
.lesson-head {
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
}
.lesson-head .eyebrow { opacity: .85; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lesson-head h1 { margin: 4px 0 2px; font-size: 1.5rem; }
.lesson-head .ref { opacity: .9; font-style: italic; }

.variant-bar {
  position: sticky;
  top: 49px;
  z-index: 20;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px;
  margin: 0 -2px 6px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.variant-bar::-webkit-scrollbar { display: none; }
.variant-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.variant-chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.variant-chip .lock { font-size: .7rem; opacity: .7; margin-left: 4px; }

/* ---------- Print / download PDF button ---------- */
.pdf-row { margin: 2px 0 12px; }
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-radius: 999px;
  padding: 8px 15px;
  font-size: .85rem;
  font-weight: 700;
}
.pdf-btn:active { transform: scale(.99); }
.pdf-btn svg { flex: 0 0 auto; }

/* ---------- Converted lesson content ---------- */
.lesson-content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 18px 22px;
  box-shadow: var(--shadow);
  overflow-wrap: break-word;
}
.lesson-content p { margin: .7em 0; }
.lesson-content h1, .lesson-content h2, .lesson-content h3 {
  line-height: 1.25;
  margin: 1.3em 0 .4em;
  color: var(--brand);
}
.lesson-content h1 { font-size: 1.3rem; }
.lesson-content h2 { font-size: 1.15rem; }
.lesson-content h3 { font-size: 1rem; letter-spacing: .02em; }
.lesson-content strong { color: var(--ink); }
.lesson-content ul, .lesson-content ol { padding-left: 1.3em; }
.lesson-content li { margin: .35em 0; }
.lesson-content img { max-width: 100%; height: auto; vertical-align: middle; }
.lesson-content a { word-break: break-word; }

/* Tables in the docs are callout boxes / structured blocks */
.lesson-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  background: color-mix(in srgb, var(--brand) 5%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: 12px;
  overflow: hidden;
}
.lesson-content td, .lesson-content th {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
  vertical-align: top;
}
.lesson-content table p:first-child { margin-top: 0; }
.lesson-content table p:last-child { margin-bottom: 0; }

/* Wide tables scroll horizontally on small screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

@media (min-width: 720px) {
  :root { font-size: 18px; }
  .track-grid { grid-template-columns: 1fr; }
}
