/* ---------------------------------------------------------------------------
 * AI-Assisted Data Analysis for Pharmaceutical Sciences — ULLA Summer School
 *
 * A calm, coffee-warm visual system. Cream paper, espresso ink, one rich
 * brown accent and a sage secondary. Blocks share a single base style; they
 * are distinguished only by their section number, not by color or topic.
 * ------------------------------------------------------------------------- */

:root {
  /* paper + ink */
  --paper:        #f7f1e6;   /* page bg — soft cream */
  --paper-2:      #efe7d7;   /* secondary surface */
  --paper-3:      #e6dcc7;   /* hairline / hover */
  --card:         #fdfaf3;   /* raised card */
  --ink:          #2a1d14;   /* espresso ink */
  --ink-2:        #5a4a3c;   /* muted ink */
  --ink-3:        #8c7a68;   /* quiet ink, captions */
  --rule:         #d9cdb4;

  /* accents */
  --accent:       #7a4a2b;   /* rich brown — primary */
  --accent-2:     #a7693f;   /* lighter brown for hover */
  --accent-tint:  #efe1cf;   /* tinted brown bg */
  --sage:         #5a6b4e;   /* calm secondary */
  --sage-tint:    #dde2cf;

  /* --g-foundations doubles as the warning / incorrect-answer tone (enhancements.css);
     the rest are retained color tokens */
  --g-foundations: #b07a3f;
  --g-part1:       #9e6336;
  --g-part2:       #77793e;
  --g-part3:       #4e6b54;
  --g-part4:       #4a6b6b;
  --g-capstone:    #6a3a2a;

  --shadow-sm: 0 1px 0 rgba(58, 36, 20, 0.06), 0 1px 2px rgba(58, 36, 20, 0.04);
  --shadow-md: 0 1px 0 rgba(58, 36, 20, 0.06), 0 4px 16px -8px rgba(58, 36, 20, 0.18);

  /* code blocks (override per-theme) */
  --code-bg: #2a1d14;
  --code-fg: #e8dcc7;

  /* swatch sample (mini palette preview for theme picker) */
  --swatch-a: var(--paper);
  --swatch-b: var(--accent);
  --swatch-c: var(--ink);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --measure: 78ch;

  --font-serif: "Newsreader", Georgia, "Iowan Old Style", serif;
  --font-sans:  "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---------------------------------------------------------------------
 * Themes — override the core color tokens. Three themes:
 *   paper     (default, warm cream + coffee)
 *   obsidian  (deep slate, warm tan accent)
 *   linen     (cool off-white, plum accent)
 * ------------------------------------------------------------------- */

[data-theme="obsidian"] {
  /* Mimics the Obsidian note app's default dark theme:
     charcoal surfaces, signature purple accent, cool grey ink. */
  --paper:        #1e1e1e;
  --paper-2:      #262626;
  --paper-3:      #2f2f2f;
  --card:         #242424;
  --ink:          #dcddde;
  --ink-2:        #b3b3b3;
  --ink-3:        #888888;
  --rule:         #363636;

  --accent:       #7f6df2;   /* Obsidian purple */
  --accent-2:     #9b8df5;
  --accent-tint:  #2a2540;
  --sage:         #6da3dc;   /* secondary blue */
  --sage-tint:    #1f2a3a;

  --g-foundations: #7f6df2;
  --g-part1:       #5dade2;
  --g-part2:       #48c9b0;
  --g-part3:       #f4b860;
  --g-part4:       #ec7c64;
  --g-capstone:    #c674c4;

  --code-bg: #161616;
  --code-fg: #d4d4d4;

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 1px 0 rgba(0,0,0,0.5), 0 8px 24px -10px rgba(0,0,0,0.7);

  --swatch-a: #1e1e1e;
  --swatch-b: #7f6df2;
  --swatch-c: #dcddde;
}

[data-theme="linen"] {
  --paper:        #f3f1ec;
  --paper-2:      #e8e6df;
  --paper-3:      #dad7cd;
  --card:         #fbfaf6;
  --ink:          #1c2230;
  --ink-2:        #4a5260;
  --ink-3:        #8990a0;
  --rule:         #cfcdc4;

  --accent:       #6b3a5e;   /* plum */
  --accent-2:     #87527a;
  --accent-tint:  #ece4e8;
  --sage:         #4f6c7a;
  --sage-tint:    #dde5e9;

  --g-foundations: #6b3a5e;
  --g-part1:       #7a4262;
  --g-part2:       #4f6c7a;
  --g-part3:       #5d7a6a;
  --g-part4:       #7a6b46;
  --g-capstone:    #4a3d6b;

  --code-bg: #1c2230;
  --code-fg: #e2e4ea;

  --swatch-a: #f3f1ec;
  --swatch-b: #6b3a5e;
  --swatch-c: #1c2230;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "onum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* very subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(122, 74, 43, 0.025) 0, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(90, 107, 78, 0.02) 0, transparent 55%);
  z-index: 0;
}
[data-theme="obsidian"] body::before {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212, 165, 116, 0.04) 0, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(138, 160, 122, 0.03) 0, transparent 55%);
}
[data-theme="linen"] body::before {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(107, 58, 94, 0.03) 0, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(79, 108, 122, 0.025) 0, transparent 55%);
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(122,74,43,0.25); transition: color .15s, border-color .15s; }
a:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: 8px 12px; border-radius: 4px;
}
.skip-link:focus { left: 12px; top: 12px; z-index: 1000; }

/* --- Header ---------------------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.nav-toggle {
  display: none;
  background: transparent; border: 1px solid var(--rule); color: var(--ink);
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  cursor: pointer; align-items: center; justify-content: center;
}
.nav-toggle:hover { background: var(--paper-2); }

.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink); border-bottom: 0;
  margin-right: auto;
}
.brand:hover { color: var(--ink); }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-family: var(--font-serif); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { font-family: var(--font-sans); font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.02em; text-transform: uppercase; }

.header-meta { display: flex; align-items: center; gap: 8px; }
.pill {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 100px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: var(--paper);
}
.pill-quiet { background: transparent; }

/* --- Theme switch -------------------------------------------------- */

.theme-switch { position: relative; }
.theme-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 6px 12px 6px 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 100px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-btn:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-3); }
.theme-btn .theme-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule);
  display: inline-block;
  flex-shrink: 0;
}

.theme-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 10px;
  z-index: 80;
  display: flex; flex-direction: column; gap: 2px;
}
.theme-pop[hidden] { display: none; }
.theme-pop-title {
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 4px 8px 8px;
}
.theme-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: var(--font-sans);
}
.theme-opt:hover { background: var(--paper-2); }
.theme-opt[aria-checked="true"] { background: var(--paper-2); }
.theme-opt[aria-checked="true"] .theme-opt-name::after {
  content: "✓";
  margin-left: 6px;
  color: var(--accent);
  font-weight: 600;
}
.theme-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.theme-swatch[data-theme="paper"]    { background: linear-gradient(135deg, #f7f1e6 0% 55%, #7a4a2b 55% 80%, #2a1d14 80%); }
.theme-swatch[data-theme="obsidian"] { background: linear-gradient(135deg, #1c1f23 0% 55%, #d4a574 55% 80%, #e8e3d8 80%); }
.theme-swatch[data-theme="linen"]    { background: linear-gradient(135deg, #f3f1ec 0% 55%, #6b3a5e 55% 80%, #1c2230 80%); }
.theme-opt-text { display: flex; flex-direction: column; line-height: 1.25; }
.theme-opt-name { font-size: 13.5px; font-weight: 500; }
.theme-opt-desc { font-size: 11.5px; color: var(--ink-3); }

@media (max-width: 720px) {
  .theme-btn-label { display: none; }
  .theme-btn { padding: 6px 8px; }
}

/* --- Layout ---------------------------------------------------------- */

.layout {
  position: relative;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 71px);
}

.nav-rail {
  position: sticky;
  top: 71px;
  align-self: start;
  height: calc(100vh - 71px);
  overflow-y: auto;
  padding: 28px 18px 28px 28px;
  border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-group-head {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 16px 10px 6px;
  display: flex; align-items: center; gap: 8px;
}
.nav-group-head:first-child { padding-top: 0; }
.nav-group-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-3);
}

.nav-item a, .nav-item .locked-link {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  border-bottom: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}
.nav-item a:hover { background: var(--paper-3); color: var(--ink); }
.nav-item a.active {
  background: var(--card);
  box-shadow: var(--shadow-sm);
  outline: 1px solid var(--rule);
}
.nav-item .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  text-align: right;
  padding-right: 4px;
  border-right: 2px solid var(--rule);
}

.nav-item .title { font-weight: 500; color: var(--ink); }
.nav-item .type {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 400;
  margin-top: 1px;
  letter-spacing: 0.01em;
}
.nav-item .home-icon { grid-column: 1; opacity: 0.7; }
.nav-item.home a { grid-template-columns: 24px 1fr; }

.nav-item.locked .locked-link {
  color: var(--ink-3);
  cursor: default;
}
.nav-item.locked .title { color: var(--ink-3); font-style: italic; }
.nav-item.locked .type { color: var(--ink-3); opacity: 0.7; }
.nav-item.locked .num  { color: var(--ink-3); opacity: 0.5; }
.nav-item.locked .lock {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.55;
}

/* "Before the class" CTA in the nav — promoted to the top of the rail
   (after Home, before Foundations) so it can't be missed. */
.nav-prep {
  margin: 6px 0 10px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--rule);
}
.nav-prep a,
.nav-prep .locked-link {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid color-mix(in oklab, var(--accent) 25%, var(--rule));
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 25%, var(--rule));
  line-height: 1.3;
}
.nav-prep a:hover {
  background: color-mix(in oklab, var(--accent-tint) 70%, var(--accent) 15%);
  color: var(--accent-2);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--rule));
}
.nav-prep .nav-prep-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  color: var(--accent);
  flex-shrink: 0;
}
.nav-prep .nav-prep-title { display: block; }
.nav-prep .nav-prep-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

/* locked "Before the class" — dimmed to match the locked block rows
   (no accent chip, grey italic title, muted icon, lock glyph). */
.nav-prep.locked .locked-link {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
  cursor: default;
}
.nav-prep.locked .nav-prep-title { font-style: italic; color: var(--ink-3); }
.nav-prep.locked .nav-prep-sub { color: var(--ink-3); opacity: 0.7; }
.nav-prep.locked .nav-prep-icon {
  background: color-mix(in oklab, var(--ink) 8%, transparent);
  color: var(--ink-3);
}
.nav-prep.locked .lock {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.55;
}

/* --- Main ------------------------------------------------------------ */

.main { position: relative; min-width: 0; }
.main:focus { outline: none; }

.view { padding: 48px 56px 96px; max-width: 980px; margin: 0 auto; position: relative; z-index: 1; }

/* --- Home ------------------------------------------------------------ */

.eyebrow {
  font-family: var(--font-sans);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 18px;
}
.eyebrow a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, currentColor 35%, transparent);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.eyebrow a:hover {
  color: var(--ink-2);
  border-bottom-color: currentColor;
}

.hero-byline {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-3);
  margin: -8px 0 22px;
}
.hero-byline strong { color: var(--ink-2); font-weight: 600; }
.hero-byline a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, currentColor 35%, transparent);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.hero-byline a:hover { color: var(--ink-2); border-bottom-color: currentColor; }

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 22px;
  text-wrap: balance;
}

.hero .lede {
  font-size: 19px;
  max-width: 58ch;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 28px;
  text-wrap: pretty;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 56px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.btn-primary { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); color: var(--paper); border-color: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-3); }

.callout {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 18px;
  align-items: start;
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  background: var(--sage-tint);
  border: 1px solid color-mix(in oklab, var(--sage) 30%, var(--rule));
  margin: 0 0 48px;
}
.callout-prep .callout-icon {
  color: var(--sage);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklab, var(--card) 70%, transparent);
  border-radius: 50%;
}
.callout h3 { font-family: var(--font-serif); font-weight: 600; font-size: 18px; margin: 0 0 6px; }
.callout p  { margin: 0; color: var(--ink-2); font-size: 16px; }

.home-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 48px;
  align-items: start;
}
.home-grid h2 {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
.schedule-table th {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--rule);
}
.schedule-table td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--paper-3);
  vertical-align: baseline;
}
.schedule-table tr.break td {
  color: var(--ink-3);
  font-style: italic;
}
.schedule-table tr.break td:first-child {
  font-style: normal;
}
.schedule-table td:first-child {
  font-family: var(--font-mono);
  font-size: 13.5px;
  white-space: nowrap;
  padding-right: 24px;
  color: var(--ink-2);
}

/* Schedule rows in the home grid. Locked rows fade their label. */
.sched-row a {
  color: var(--ink);
  border-bottom: 1px solid transparent;
}
.sched-row a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.sched-row.locked .sched-label { color: var(--ink-3); }
.sched-row .lock-hint {
  display: inline-flex; align-items: center;
  margin-left: 6px;
  color: var(--ink-3);
  opacity: 0.7;
  vertical-align: middle;
}

.legend-intro { font-size: 14px; color: var(--ink-3); margin: 0 0 14px; }
.legend-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; font-size: 15px; }
.legend-list li { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 14px; }
.legend-list strong { font-weight: 600; }

/* --- Coffee cups icon ----------------------------------------------- */

.cups {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  vertical-align: middle;
}
.cups::before, .cups::after, .cups .cup {
  /* unused — we generate cups in JS */
}
.cup-svg {
  width: 18px; height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

/* --- Block view ------------------------------------------------------ */

.block-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.block-header::before {
  content: "";
  position: absolute;
  left: -56px; top: 6px; bottom: 24px;
  width: 4px;
  border-radius: 4px;
  background: var(--accent);
}
.block-eyebrow {
  font-family: var(--font-sans);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.block-eyebrow .block-num {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.block-eyebrow .sep {
  width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); opacity: 0.5;
}
.block-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

/* --- Markdown content styling --------------------------------------- */

.markdown {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
  max-width: var(--measure);
}
.markdown > *:first-child { margin-top: 0; }

.markdown p { margin: 0 0 1.05em; text-wrap: pretty; }
.markdown em { color: var(--ink-2); }

.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-top: 2em;
  margin-bottom: 0.6em;
  text-wrap: balance;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

/* In-page anchor links (heading slug ids) should land just below the sticky
 * .site-header (≈71px tall — the nav-rail uses top:71px), not underneath it. */
.markdown :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: calc(71px + 1rem); }

.markdown h1 { font-size: 28px; }
.markdown h2 {
  font-size: 24px;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--rule);
}
.markdown h3 { font-size: 20px; color: var(--ink); }
.markdown h4 { font-size: 17px; font-weight: 600; color: var(--ink-2); }

.markdown ul, .markdown ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.markdown li { margin-bottom: 0.4em; }
.markdown li > p { margin: 0 0 0.4em; }

/* GFM task-list checkboxes: drop the bullet, align flush with body text, make tappable.
 * Tagged .task-item by app.js enableChecklists; plain bullet lists keep their markers. */
.markdown li.task-item { list-style: none; margin-left: -1.4em; }   /* cancels the ul padding-left */
.markdown li.task-item input[type="checkbox"] {
  margin-right: 0.55em;
  cursor: pointer;
  width: 15px; height: 15px;
  vertical-align: -2px;
  accent-color: var(--accent);
}
.markdown li.task-item.checked { color: var(--ink-3); }   /* subtle "done" cue */

.markdown hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4em 0;
}

.markdown blockquote {
  margin: 1.4em 0;
  padding: 14px 22px;
  background: var(--card);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-2);
  font-style: normal;
  box-shadow: var(--shadow-sm);
}
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown blockquote strong { color: var(--ink); }

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--paper-3);
  color: var(--ink);
}
.markdown pre {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.4em 0;
}
.markdown pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Copy-to-clipboard button on code blocks (wrapper + button added by
 * app.js addCopyButtons; pinned to the wrapper so it doesn't scroll away). */
.code-wrap { position: relative; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  padding: 5px 9px;
  color: var(--code-fg);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover,
.copy-btn:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}
.copy-btn.copied {
  opacity: 1;
  color: #fff;
  background: rgba(120, 190, 120, 0.30);
  border-color: rgba(120, 190, 120, 0.55);
}

/* Copy button on a collapsible prompt box (added by addPromptCopyButtons).
 * Lives in the summary flex row, pinned right, light accent pill; revealed
 * only when the box is open so collapsed headers stay clean. */
.prompt-copy {
  position: static;
  margin-left: auto;
  display: none;
  opacity: 1;
  color: var(--accent);
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--accent) 45%, var(--rule));
}
.markdown details.prompt[open] > summary .prompt-copy {
  display: inline-flex;
  align-items: center;
}
.prompt-copy:hover,
.prompt-copy:focus-visible {
  opacity: 1;
  background: color-mix(in oklab, var(--accent) 12%, var(--card));
  border-color: var(--accent);
}
.prompt-copy.copied {
  color: var(--sage, #5f7d49);
  background: color-mix(in oklab, var(--sage, #8bb174) 18%, var(--card));
  border-color: color-mix(in oklab, var(--sage, #8bb174) 55%, var(--rule));
}

.markdown table {
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 15.5px;
  width: 100%;
  table-layout: fixed;   /* equal-width columns by default */
}
/* Opt-out: key/description tables (e.g. block 3's Column | Meaning) read
   better with a narrow code column and a wide description, so let their
   columns size to content. body[data-route] is set per block by app.js. */
body[data-route="block3"] .markdown table { table-layout: auto; }
.markdown th, .markdown td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--paper-3);
  vertical-align: top;
}
.markdown th {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.markdown td:first-child code,
.markdown th:first-child { white-space: nowrap; }

/* coffee marker on headings */
.markdown h2 .cups,
.markdown h3 .cups,
.markdown h4 .cups {
  margin-left: 4px;
  background: var(--accent-tint);
  padding: 3px 8px 3px 6px;
  border-radius: 100px;
  font-size: 0;
  line-height: 1;
}
.markdown h2 .cups .cup-svg,
.markdown h3 .cups .cup-svg,
.markdown h4 .cups .cup-svg { width: 15px; height: 15px; }

/* additional-resources <details> */
.markdown details {
  margin: 1.4em 0;
  background: color-mix(in oklab, var(--accent-tint) 60%, var(--card));
  border: 1px solid color-mix(in oklab, var(--accent) 25%, var(--rule));
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  transition: box-shadow .2s;
}
.markdown details[open] { box-shadow: var(--shadow-md); }
.markdown details summary {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.markdown details summary::-webkit-details-marker { display: none; }
.markdown details summary::before {
  content: "+";
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.55);
  border-radius: 50%;
  transition: transform .2s;
  font-size: 16px;
}
.markdown details[open] summary::before { content: "−"; }
.markdown details summary:hover { color: var(--accent-2); }
.markdown details > *:not(summary) {
  padding: 0 20px;
}
.markdown details[open] > *:not(summary):first-of-type { padding-top: 14px; }
.markdown details[open] > *:last-child { padding-bottom: 18px; }

/* solution <details> — a distinct sage identity, set apart from the brown
   "Additional resources" toggles (authored as <details class="solution">) */
.markdown details.solution {
  background: color-mix(in oklab, var(--sage-tint) 60%, var(--card));
  border-color: color-mix(in oklab, var(--sage) 30%, var(--rule));
}
.markdown details.solution summary {
  color: var(--sage);
  background: var(--sage-tint);
}
.markdown details.solution summary::before { color: var(--sage); }
.markdown details.solution summary:hover {
  color: color-mix(in oklab, var(--sage) 70%, var(--ink));
}

/* "You should now be able to" — the per-block self-check that closes each
   block's core. An always-open competency card, set apart from the collapsible
   resource/solution toggles: a calm sage panel with check-mark bullets. */
.markdown .objectives {
  margin: 1.8em 0;
  padding: 16px 22px 18px;
  background: color-mix(in oklab, var(--sage-tint) 55%, var(--card));
  border: 1px solid color-mix(in oklab, var(--sage) 30%, var(--rule));
  border-left: 4px solid var(--sage);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-sm);
}
.markdown .objectives > p:first-child {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sage);
  margin: 0 0 0.75em;
}
.markdown .objectives ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}
.markdown .objectives li {
  position: relative;
  padding-left: 1.8em;
  margin-bottom: 0.5em;
}
.markdown .objectives li:last-child { margin-bottom: 0; }
.markdown .objectives li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0.05em;
  color: var(--sage);
  font-weight: 700;
}

/* references — the trailing "## References" section renders smaller + quieter;
   the .block-refs class is applied at runtime by postprocessReferences() */
.markdown h2.block-refs {
  font-size: 18px;
  color: var(--ink-2);
}
.markdown .block-refs {
  font-size: 14px;
  color: var(--ink-2);
}

/* KaTeX tweaks */
.markdown .katex { font-size: 1.02em; }

/* --- Locked view ----------------------------------------------------- */

.locked-view { display: flex; align-items: center; justify-content: center; min-height: 60vh; padding-top: 40px; }
.locked-card {
  text-align: center;
  max-width: 460px;
  padding: 40px 32px;
  background: var(--card);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-lg);
}
.locked-icon {
  width: 56px; height: 56px;
  background: var(--paper-2);
  color: var(--ink-3);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.locked-card h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.locked-card p { color: var(--ink-2); margin: 0 0 22px; font-size: 16px; }

/* --- Doc (preliminaries / checklist) -------------------------------- */

.doc { max-width: var(--measure); margin: 0 auto; }
.doc-backlink {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 18px;
}
.doc-backlink a { border-bottom: 0; color: var(--ink-3); }
.doc-backlink a:hover { color: var(--accent); }

/* --- Responsive ------------------------------------------------------ */

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .layout { grid-template-columns: 1fr; }
  .nav-rail {
    position: fixed;
    inset: 71px 0 0 0;
    width: 100%;
    height: calc(100vh - 71px);
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 40;
  }
  .nav-rail.open { transform: translateX(0); }
  .view { padding: 32px 22px 80px; }
  .block-header::before { left: -22px; }
  .home-grid { grid-template-columns: 1fr; gap: 36px; }
  .brand-sub { display: none; }
  .header-meta { display: none; }
  .markdown { font-size: 17px; }
}

@media (max-width: 520px) {
  .hero h1 { font-size: 34px; }
  .hero .lede { font-size: 17px; }
  .view { padding: 24px 18px 72px; }
}
