/* CCMA Study Site — shared theme + components.
 * Single source of truth for color tokens, typography, layout, and callouts.
 * Loaded by every page via <link rel="stylesheet" href="/assets/site.css">.
 *
 * Design grammar (ported from stats 13, translated to clinical voice):
 *   - Body: serif (Crimson Pro), generous line-height 1.7, 17px
 *   - Headings: serif display (Libre Baskerville)
 *   - UI chrome: sans (Inter system stack) for nav/buttons/forms
 *   - Eyebrow labels: mono (JetBrains Mono), uppercase, color-coded
 *   - Callouts: 4px vertical accent bar + tinted bg + mono eyebrow label + serif body
 *   - Cool clinical (EMR) palette: cobalt #1e40af + accent #3b82f6 + amber #f59e0b + slate-50 #f8fafc
 */

/* ── Theme tokens ─────────────────────────────────────────────────────────── */
/* Palette tokens kept under their original names (--teal, --cream, etc.) so
   the rest of site.css doesn't have to change. The active hue family is
   Cobalt: cool clinical / hospital-EMR feel. */
:root,
:root[data-theme="light"] {
  --teal:        #1e40af;
  --teal-light:  #3b82f6;
  --teal-glow:   #93c5fd;
  --teal-muted:  #dbeafe;
  --teal-soft:   #eff6ff;
  --coral:       #f59e0b;
  --coral-soft:  #fef3c7;
  --cream:       #f8fafc;
  --cream-2:     #f1f5f9;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #e2e8f0;
  --border:      #cbd5e1;
  --border-soft: #e2e8f0;
  --text:        #0f172a;
  --text-dim:    #334155;
  --muted:       #64748b;
  --green:       #16a34a;
  --green-soft:  #dcfce7;
  --green-tint:  #ecfdf5;
  --gold:        #ca8a04;
  --gold-soft:   #fef3c7;
  --gold-tint:   #fffbeb;
  --purple:      #7c3aed;
  --purple-soft: #ede9fe;
  --taupe:       #8b6f47;
  --taupe-soft:  #f0e6d6;
  --shadow-sm:   0 1px 2px rgba(15,23,42,.06);
  --shadow-md:   0 4px 14px rgba(15,23,42,.08);
  --shadow-lg:   0 12px 32px rgba(15,23,42,.12);
  --hero-grad:   linear-gradient(135deg, #eff6ff 0%, #ffffff 60%, #fef3c7 100%);
}

:root[data-theme="dark"] {
  --teal:        #60a5fa;
  --teal-light:  #93c5fd;
  --teal-glow:   #bfdbfe;
  --teal-muted:  #1e3a8a;
  --teal-soft:   #172554;
  --coral:       #fbbf24;
  --coral-soft:  #2a1f0a;
  --cream:       #0f172a;
  --cream-2:     #0a101e;
  --surface:     #1e293b;
  --surface-2:   #172033;
  --surface-3:   #2a3548;
  --border:      #334155;
  --border-soft: #2a3548;
  --text:        #e2e8f0;
  --text-dim:    #cbd5e1;
  --muted:       #94a3b8;
  --green:       #4ade80;
  --green-soft:  #0a2018;
  --green-tint:  #0f2c1c;
  --gold:        #facc15;
  --gold-soft:   #2a1f0a;
  --gold-tint:   #2a200d;
  --purple:      #a78bfa;
  --purple-soft: #1e1933;
  --taupe:       #c2a373;
  --taupe-soft:  #2a2218;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow-md:   0 4px 14px rgba(0,0,0,.45);
  --shadow-lg:   0 12px 32px rgba(0,0,0,.55);
  --hero-grad:   linear-gradient(135deg, #172554 0%, #1e293b 60%, #2a1f0a 100%);
}

/* ── Reset + base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--teal-light); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal-light);
  outline-offset: 2px;
}
code {
  background: var(--surface-2);
  padding: .08em .35em;
  border-radius: 3px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .85em;
  border: 1px solid var(--border);
  color: var(--teal);
}
hr { border: 0; border-top: 1px solid var(--border); margin: 1.8rem 0; }
p { margin: 0 0 .8rem; }
em { font-style: italic; }
strong { font-weight: 700; }

/* Skip link — accessibility */
.skip-link {
  position: absolute; left: -9999px; top: 0; padding: .55rem 1rem;
  background: var(--teal); color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .8rem; z-index: 9999; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Libre Baskerville', Georgia, serif;
  color: var(--teal);
  line-height: 1.25;
  margin: 0 0 .5rem;
  font-weight: 700;
}
h1 { font-size: 2rem; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; margin-top: 1.6rem; }
h3 { font-size: 1.12rem; margin-top: 1.2rem; }

/* Eyebrow — small mono uppercase label, color-coded */
.eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--teal);
  font-weight: 600;
  margin-bottom: .35rem;
}
.eyebrow-coral  { color: var(--coral); }
.eyebrow-gold   { color: var(--gold); }
.eyebrow-green  { color: var(--green); }
.eyebrow-muted  { color: var(--muted); }

.muted { color: var(--muted); }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.sans  { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
.serif { font-family: 'Crimson Pro', Georgia, serif; }

/* Inline term highlights (used in lesson body content) */
.term {
  color: var(--teal);
  font-weight: 700;
  font-style: normal;
}
.warn-inline {
  color: var(--coral);
  font-style: italic;
  font-weight: 600;
}
.high-yield {
  color: var(--gold);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 1px;
  font-weight: 600;
}
.lat {
  font-style: italic;
  color: var(--text-dim);
}

/* ── Layout shell ─────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.4rem 5rem;
}
.main-wide { max-width: 1100px; }

/* ── Site header ──────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--teal);
  padding: .65rem 1.4rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-row {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-logo {
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal);
  text-decoration: none;
  flex-shrink: 0;
}
.site-logo span {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .58rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-tabs {
  display: flex;
  gap: .25rem;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}
.nav-tab {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  color: var(--text-dim);
  text-decoration: none;
  padding: .42rem .8rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all .14s;
  letter-spacing: .04em;
}
.nav-tab:hover { background: var(--teal-muted); color: var(--teal); border-color: var(--border); }
.nav-tab.active { background: var(--teal-muted); color: var(--teal); border-color: var(--teal); font-weight: 600; }
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px; height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .14s;
  margin-left: .25rem;
}
.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }

/* Lessons drawer — left side */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity .18s;
}
.drawer-overlay.open { display: block; opacity: 1; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 2px solid var(--teal);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .7rem;
}
.drawer-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.15rem;
  color: var(--teal);
  margin: 0;
}
.drawer-close {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}
.drawer-close:hover { color: var(--coral); border-color: var(--coral); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: .8rem 1.2rem 1.5rem;
}
.drawer-section { margin-top: 1rem; }
.drawer-section:first-child { margin-top: 0; }
.drawer-section-head {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
}
.lesson-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .65rem;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  font-size: .92rem;
  color: var(--text);
  margin-bottom: .15rem;
  transition: all .12s;
  font-family: 'Inter', system-ui, sans-serif;
}
.lesson-link:hover { background: var(--teal-muted); border-color: var(--border); }
.lesson-link.active { background: var(--teal-muted); border-color: var(--teal); }
.lesson-link-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .7rem;
  color: var(--teal);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .15rem .4rem;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 36px;
  text-align: center;
}
.lesson-link-title { flex: 1; }
.lesson-link-meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .58rem;
  color: var(--muted);
}

/* ── Reference side tab + drawer (right edge) ────────────────────────────── */
.ref-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 150;
  background: var(--teal-muted);
  color: var(--teal);
  writing-mode: vertical-rl;
  padding: 1rem .42rem;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  border: 1px solid var(--teal);
  border-right: none;
  box-shadow: var(--shadow-md);
  transition: all .15s;
  font-weight: 600;
}
.ref-tab:hover {
  background: var(--teal);
  color: #fff;
  padding-right: .6rem;
}
.ref-drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 2px solid var(--teal);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .24s ease;
}
.ref-drawer.open { transform: translateX(0); }

/* ── Lesson hero banner ─────────────────────────────────────────────────── */
.lesson-hero {
  background: var(--hero-grad);
  border: 1px solid var(--border);
  border-top: 4px solid var(--teal);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.6rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.lesson-hero-icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1.5px solid var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  box-shadow: 0 2px 8px rgba(15,118,110,.18);
}
.lesson-hero-icon svg { width: 32px; height: 32px; }
.lesson-hero-text { flex: 1; min-width: 0; }
.lesson-hero-text h1 {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.65rem;
  margin: 0 0 .25rem;
  color: var(--teal);
  line-height: 1.2;
}
.lesson-hero-text .meta-line {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  color: var(--text-dim);
  letter-spacing: .03em;
  margin: 0;
}
.lesson-hero-text .meta-line .sep { color: var(--muted); margin: 0 .35rem; }
@media (max-width: 600px) {
  .lesson-hero { flex-direction: column; align-items: flex-start; padding: 1.1rem 1.15rem; }
  .lesson-hero-icon { width: 48px; height: 48px; }
  .lesson-hero-icon svg { width: 26px; height: 26px; }
  .lesson-hero-text h1 { font-size: 1.35rem; }
}

/* Module hero — smaller version for module sections within a lesson */
.module-hero {
  margin: 2.2rem 0 1rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
.module-hero .eyebrow { margin-bottom: .15rem; }
.module-hero h2 { margin: .1rem 0 .2rem; }
.module-hero .module-goal {
  color: var(--text-dim);
  font-style: italic;
  font-size: .98rem;
  margin: .25rem 0 .35rem;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.card-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--teal);
  margin-bottom: .8rem;
  font-weight: 600;
}
.card h3 { margin-top: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.1rem;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  letter-spacing: .01em;
}
.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-primary:hover:not(:disabled) {
  background: var(--teal-light);
  border-color: var(--teal-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-secondary:hover { color: var(--teal); border-color: var(--teal); }
.btn-coral {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}
.btn-coral:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none !important; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--teal); border-color: var(--teal); }

/* ── Floating utility pills ──────────────────────────────────────────────── */
/* Used inline near content sections — "Explain Why", "Visualize", "Quiz Me" */
.util-row {
  display: flex; gap: .45rem; flex-wrap: wrap;
  margin: .5rem 0 1rem;
}
.util-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .32rem .8rem;
  border-radius: 24px;
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .04em;
  transition: all .15s;
  text-decoration: none;
  background: var(--surface);
}
.util-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.util-pill .icon { font-size: .85rem; line-height: 1; }
.util-pill.explain {
  border: 1px solid var(--purple);
  color: var(--purple);
  background: var(--purple-soft);
}
.util-pill.explain:hover { background: var(--purple); color: #fff; }
.util-pill.visualize {
  border: 1px solid var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.util-pill.visualize:hover { background: var(--gold); color: #fff; }
.util-pill.quiz {
  border: 1px solid var(--teal);
  color: var(--teal);
  background: var(--teal-muted);
}
.util-pill.quiz:hover { background: var(--teal); color: #fff; }

/* Util panel — expands inline below pill row when clicked */
.util-panel {
  display: none;
  margin: .5rem 0 1rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.util-panel.open { display: block; }
.util-panel-head {
  padding: .55rem .95rem;
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.util-panel-lbl {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--teal);
  font-weight: 700;
  flex: 1;
}
.util-panel-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: .1rem .3rem;
}
.util-panel-close:hover { color: var(--coral); }
.util-panel-body {
  padding: .95rem 1.1rem;
  font-size: .95rem;
  color: var(--text-dim);
  line-height: 1.7;
  background: var(--surface);
}
.util-panel-body strong { color: var(--teal); }

/* Loading dots */
.thinking {
  display: inline-flex; gap: .3rem; align-items: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  color: var(--muted);
}
.thinking-dots { display: inline-flex; gap: .25rem; }
.thinking-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: blink .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .18s; }
.thinking-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 100% { opacity: .25; transform: scale(.7); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: .15rem .5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}
.badge-teal   { background: var(--teal-muted); color: var(--teal); border-color: var(--teal); }
.badge-coral  { background: var(--coral-soft); color: var(--coral); border-color: var(--coral); }
.badge-gold   { background: var(--gold-soft); color: var(--gold); border-color: var(--gold); }
.badge-green  { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: var(--purple); }

/* ── Callout boxes ────────────────────────────────────────────────────────── */
/* Vertical accent bar (4px) + tinted bg + mono uppercase eyebrow + serif body */
.box {
  border-left: 4px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.2rem 1rem 1.15rem;
  margin: 1.1rem 0;
  font-size: 1rem;
  line-height: 1.65;
}
.box > :first-child { margin-top: 0; }
.box > :last-child  { margin-bottom: 0; }
.box-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: .45rem;
  font-weight: 700;
  display: block;
}
.box p { margin: 0 0 .6rem; }
.box p:last-child { margin-bottom: 0; }
.box ul, .box ol { margin: .35rem 0; padding-left: 1.4rem; }
.box li { margin-bottom: .25rem; }
.box li:last-child { margin-bottom: 0; }

.box-def        { border-color: var(--purple); background: var(--purple-soft); }
.box-def        .box-label { color: var(--purple); }

.box-procedure  { border-color: var(--teal-light); background: var(--teal-soft); }
.box-procedure  .box-label { color: var(--teal); }

.box-purpose    { border-color: var(--green); background: var(--green-tint); }
.box-purpose    .box-label { color: var(--green); }

.box-warning    { border-color: var(--coral); background: var(--coral-soft); }
.box-warning    .box-label { color: var(--coral); }

.box-key        { border-color: var(--gold); background: var(--gold-tint); }
.box-key        .box-label { color: var(--gold); }

.box-rationale  { border-color: var(--teal); background: var(--teal-soft); }
.box-rationale  .box-label { color: var(--teal); }
.box-rationale  blockquote {
  margin: .35rem 0 .6rem;
  padding: .15rem 0 .15rem .85rem;
  border-left: 3px solid var(--teal);
  font-style: italic;
  color: var(--text-dim);
  font-size: .96em;
}

.box-equipment  { border-color: var(--taupe); background: var(--taupe-soft); }
.box-equipment  .box-label { color: var(--taupe); }
.box-equipment  ul { padding-left: 1.2rem; columns: 1; column-gap: 1.4rem; }
@media (min-width: 720px) { .box-equipment ul { columns: 2; } }

.box-source     { border-color: var(--muted); background: var(--surface-2); }
.box-source     .box-label { color: var(--muted); }
.box-source     { font-size: .92rem; color: var(--text-dim); }
.box-source strong { color: var(--teal); }

/* tip — light teal callout for analogies/mnemonics */
.tip {
  display: flex;
  gap: .8rem;
  background: var(--teal-muted);
  border: 1px solid var(--teal);
  border-radius: 10px;
  padding: .85rem 1rem;
  margin: 1rem 0;
  font-size: .98em;
  line-height: 1.65;
}
.tip-icon { flex-shrink: 0; font-size: 1.1rem; }
.tip-body strong { color: var(--teal); }
.tip-body > :first-child { margin-top: 0; }
.tip-body > :last-child  { margin-bottom: 0; }

/* ── Numbered procedural steps ───────────────────────────────────────────── */
.steps {
  list-style: none;
  margin: 1.1rem 0;
  padding: 0;
  counter-reset: step;
}
.step {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: .8rem;
}
.step-num {
  counter-increment: step;
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--teal);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .85rem;
  font-weight: 700;
}
.step-num::before { content: counter(step); }
.step-content { flex: 1; min-width: 0; }
.step-content > .action { font-weight: 500; line-height: 1.65; }
.step-content > .box { margin-top: .65rem; }

/* ── Interactive quiz items (embedded in lesson pages) ───────────────────── */
/* Pattern: 4 clickable options → lock on click → green/coral feedback →
   reveal rationale callout below. Reset button restores the question. */
.quiz-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.quiz-item-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: .35rem;
}
.quiz-item-stem {
  font-weight: 500;
  margin-bottom: .8rem;
  line-height: 1.55;
}
.quiz-item-options {
  display: flex; flex-direction: column; gap: .45rem;
  margin: .55rem 0;
  list-style: none;
  padding: 0;
}
.quiz-item-option {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .65rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: 'Crimson Pro', Georgia, serif;
  color: var(--text);
  font-size: .98rem;
  line-height: 1.5;
  transition: all .12s;
  width: 100%;
}
.quiz-item-option:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--teal-muted);
  transform: translateX(2px);
}
.quiz-item-option:disabled { cursor: default; transform: none; }
.quiz-item-option-letter {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .76rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: all .12s;
}
.quiz-item-option:hover:not(:disabled) .quiz-item-option-letter {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.quiz-item-option-text { flex: 1; padding-top: .1rem; }

/* Locked states — set by JS on click */
.quiz-item-option.is-correct {
  border-color: var(--green);
  background: var(--green-tint);
}
.quiz-item-option.is-correct .quiz-item-option-letter {
  background: var(--green); color: #fff; border-color: var(--green);
}
.quiz-item-option.is-wrong {
  border-color: var(--coral);
  background: var(--coral-soft);
}
.quiz-item-option.is-wrong .quiz-item-option-letter {
  background: var(--coral); color: #fff; border-color: var(--coral);
}
.quiz-item-option.is-correct.is-revealed-as-correct::after {
  content: '✓'; margin-left: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--green); font-weight: 700; font-size: 1rem;
}

.quiz-item-rationale {
  display: none;
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px dashed var(--border);
  animation: rationaleFade .3s ease both;
}
.quiz-item-rationale.show { display: block; }
@keyframes rationaleFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.quiz-item-actions {
  display: flex; gap: .5rem; align-items: center;
  margin-top: .85rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .7rem;
}
.quiz-item-result {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}
.quiz-item-result.correct { color: var(--green); }
.quiz-item-result.wrong   { color: var(--coral); }
.quiz-item-reset {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s;
}
.quiz-item-reset:hover { border-color: var(--teal); color: var(--teal); }
.quiz-item-source {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .62rem;
  color: var(--muted);
  margin-top: .55rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ── SVG diagram container ───────────────────────────────────────────────── */
.diagram {
  margin: 1.4rem 0;
  text-align: center;
}
.diagram svg {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  height: auto;
}
.diagram-caption {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-top: .6rem;
}

/* ── Status rows (used in admin / smoke tests) ───────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .45rem 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot.ok   { background: var(--green); }
.status-dot.fail { background: var(--coral); }
.status-dot.run  { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.field {
  display: block;
  margin-bottom: .9rem;
}
.field-label {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .35rem;
  font-weight: 600;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .58rem .85rem;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1rem;
  transition: border-color .14s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal); }
.textarea { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .9rem; min-height: 100px; resize: vertical; }

/* ── Reduced-motion + print ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}
@media print {
  .site-header, .theme-toggle, .nav-tabs, .drawer, .drawer-overlay,
  .ref-tab, .ref-drawer, .util-row, .util-panel { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .box { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  a { color: #000; }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .main { padding: 1.25rem 1rem 4rem; }
  h1 { font-size: 1.55rem; }
  h2 { font-size: 1.22rem; }
  .nav-tabs { gap: .15rem; }
  .nav-tab { font-size: .68rem; padding: .35rem .55rem; }
  .site-logo span { display: none; }
  .ref-tab { font-size: .6rem; padding: .8rem .35rem; letter-spacing: .14em; }
  .step { padding: .8rem .9rem; gap: .8rem; }
  .step-num { width: 28px; height: 28px; font-size: .78rem; }
  .lesson-hero { padding: 1rem 1.1rem; }
}
