:root {
  /* ---- Clinical Journal type system ---- */
  --font-display: "Source Serif 4", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;

  /* ---- Surfaces: warm chart-paper cream, not app-white ---- */
  --paper: #ffffff;
  --background: #f7f5ef;
  --background-body: #f7f5ef;
  --ivory: #fffef8;
  --pearl: #fbfaf4;
  --marble: #efece3;
  --off-white: #f2f0e8;
  --lavender: #eef2ed;
  --alice-blue: #eef2ee;
  --parachment: #f5e9d6;
  --egg-white: #fdfdfa;
  --primary: #1a1d1b;
  --blue: #2f6f4e;
  --dark-blue: #2f6f4e;
  --border: #e2dfd3;
  --border-light: #ede9dd;
  --muted: #5a5f5a;
  --surface: var(--paper);
  --master: var(--paper);
  --surface-subtle: color-mix(in srgb, var(--background) 30%, var(--paper));

  --text-primary: #1a1d1b;
  --text-secondary: #5a5f5a;
  --text-tertiary: #7a7f78;
  --text-quaternary: #9a9e97;
  --text-dark: #1a1d1b;
  --text-primary-strong: #1a1d1b;
  --text-secondary-strong: #3f433e;

  --text-on-dark: #ffffff;
  --text-on-dark-soft: rgba(255, 255, 255, 0.85);
  --text-on-dark-muted: rgba(255, 255, 255, 0.65);

  /* ---- Semantic accents ----
     accent-navy   -> "2nd Edition / current": neutral slate, reads as
                      the established baseline, not a highlight.
     accent-forest -> brand clinical green: used for the What If sandbox
                      and all interactive/focus states.
     accent-terracotta -> repurposed as the brand's vital-sign amber:
                      "3rd Edition / recalculated" and the revised-row
                      badge, since amber = "this changed, look here."
     accent-crimson -> muted clinical alert red: over-target / invalid
                      states only. */
  --accent-navy: #4a5568;
  --accent-forest: #2f6f4e;
  --accent-terracotta: #c9822e;
  --accent-crimson: #b23a3a;

  --fs-xs: clamp(0.75rem, 1.1vw, 0.875rem);
  --fs-sm: clamp(0.875rem, 1.3vw, 1rem);
  --fs-base: clamp(1rem, 1.5vw, 1.125rem);
  --fs-md: clamp(1.15rem, 1.9vw, 1.3rem);
  --fs-lg: clamp(1.3rem, 2.2vw, 1.5rem);
  --fs-xl: clamp(1.5rem, 2.8vw, 1.875rem);
  --fs-2xl: clamp(1.875rem, 3.6vw, 2.25rem);
  --fs-display: clamp(2.75rem, 5.5vw, 3.5rem);

  --ls-tightest: -0.04em;
  --ls-tighter: -0.02em;
  --ls-tight: -0.01em;
  --ls-normal: 0em;
  --ls-wide: 0.02em;
  --ls-wider: 0.05em;
  --ls-widest: 0.1em;
  --ls-huge: 0.2em;

  /* Flat, printed-document feel — no drop shadows in this brand. */
  --bs-thin: none;
  --bs-medium: none;
  --bs-heavy: none;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 2.5rem;
  --space-6: 3rem;

  /* Soft, considered corners — a well-bound printed report, not a data
     table (too sharp) and not a consumer app (too bubbly). */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-pill: 999px;
  --radius-xs: var(--r-xs);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-md);
  --radius-xl: var(--r-md);
  --radius-pill: var(--r-pill);

  --ed2-tint: var(--marble);
  --ed2-ink: var(--accent-navy);
  --ed3-tint: var(--parachment);
  --ed3-ink: var(--accent-terracotta);

  --dur: 0.15s;
  --ease: ease;

  /* Single source of truth for the comparison table's column proportions —
     the colgroup <col> widths and the summary strip's split both read
     these, so the divider below the table and the one in the summary
     strip can never drift apart from each other. */
  --cmp-activity-w: 24%;
  --cmp-num-w: 9.5%;
}

/* ---- Dark mode: manual toggle only, never OS-driven. Every color token
   above gets a counterpart here so the rest of the CSS never branches on
   theme — only the values change. ---- */
:root[data-theme="dark"] {
  --paper: #1c1f1c;
  --background: #141613;
  --background-body: #141613;
  --ivory: #1f221e;
  --pearl: #1e211c;
  --marble: #262a25;
  --off-white: #20231f;
  --lavender: #202520;
  --alice-blue: #1f2521;
  --parachment: #332a1c;
  --egg-white: #1c1f1a;
  --primary: #ece8dc;
  --blue: #4fa377;
  --dark-blue: #4fa377;
  --border: #34372f;
  --border-light: #292c26;
  --muted: #a9ad9f;
  --surface: var(--paper);
  --master: var(--paper);
  --surface-subtle: color-mix(in srgb, var(--background) 40%, var(--paper));

  --text-primary: #ece8dc;
  --text-secondary: #a9ad9f;
  --text-tertiary: #82867a;
  --text-quaternary: #63665c;
  --text-dark: #ece8dc;
  --text-primary-strong: #f5f2e8;
  --text-secondary-strong: #c2c6b8;

  --accent-navy: #93a0b4;
  --accent-forest: #4fa377;
  --accent-terracotta: #dda05a;
  --accent-crimson: #d97f7a;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-body);
  background: var(--background-body);
  color: var(--text-primary);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: var(--space-4) var(--space-3) var(--space-6);
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
}

/* ---------- ECG divider (brand signature, decorative only) ---------- */
.ecg-divider {
  width: 100%;
  height: 22px;
  display: block;
  margin: var(--space-3) 0;
}
.ecg-divider path {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

/* ---------- Masthead ---------- */
.masthead {
  border-bottom: 2px solid var(--text-primary);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
}
.masthead .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.masthead h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  letter-spacing: var(--ls-tight);
  font-weight: 550;
  margin: 0 0 6px 0;
  color: var(--text-primary-strong);
}
.masthead .subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  max-width: 70ch;
}

.masthead .subsubtitle {
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
  max-width: 70ch;
  color: var(--accent-crimson);
}
.masthead .source-note {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.source-note code {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- Controls: course lookup ---------- */
.lookup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  box-shadow: var(--bs-thin);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.field select,
.field input {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--text-primary);
  min-width: 160px;
}
.field select {
  min-width: 260px;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.field.invalid input {
  border-color: var(--accent-crimson);
  background: color-mix(in srgb, var(--accent-crimson) 6%, var(--paper));
}
.field .hint {
  font-size: 11px;
  color: var(--text-tertiary);
}
.field .hint.warn {
  color: var(--accent-crimson);
  font-weight: 600;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
.chip {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary-strong);
  white-space: nowrap;
}

/* ---------- Assumptions strip ---------- */
.assumptions {
  background: var(--lavender);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-end;
}
.assumptions .heading {
  flex-basis: 100%;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--dark-blue);
  margin-bottom: 2px;
}
.assumptions .field input {
  width: 110px;
  min-width: 0;
}
.reset-link {
  font-size: var(--fs-xs);
  color: var(--blue);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 8px 0;
  text-decoration: underline;
}

/* ---------- Edition comparison table ---------- */
.edition-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--bs-thin);
}

.comparison-card .section-label:first-child {
  padding-top: var(--space-3);
}

.table-scroll {
  overflow-x: auto;
}

/* The 2nd/3rd Edition group headers live inside the table itself (colspan
   cells over the real columns below them), so their color block and the
   column divider are always pixel-exact to the data — there's no separate
   banner above the table that could drift out of alignment with it. */
table.comparison-table th.group-head {
  text-align: center;
  padding: 8px var(--space-3) 6px;
}
table.comparison-table th.group-head .ed-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  opacity: 0.8;
  font-weight: 600;
}
table.comparison-table th.group-head .group-title {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 550;
  text-transform: none;
  letter-spacing: var(--ls-tight);
  margin-top: 2px;
}
table.comparison-table th.group-head.ed2 {
  background: var(--ed2-tint);
  color: var(--ed2-ink);
}
table.comparison-table th.group-head.ed3 {
  background: var(--ed3-tint);
  color: var(--ed3-ink);
}
table.comparison-table th.activity-col {
  vertical-align: bottom;
}
/* Divider between the two editions' column groups. Driven by the ed2/ed3
   classes rather than a fixed column index — a rowspan cell (2nd Edition's
   combined Seminar/BST value) removes cells from a row's DOM, which shifts
   nth-child positions per row, but every row still has an ed2-then-ed3
   class transition exactly once, so this stays correct everywhere. The
   border goes on the last .ed2 cell (border-right), not the first .ed3
   cell: in a split Seminar/BST row that .ed2 cell has rowspan="2", so its
   border spans the full Presenter+Attendee height instead of stopping
   after the Presenter row alone. */
table.comparison-table th.ed2:has(+ th.ed3),
table.comparison-table td.ed2:has(+ td.ed3) {
  border-right: 2px solid var(--border);
}

.section-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-3) 6px;
}

table.slt-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--fs-sm);
}
table.slt-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-tertiary);
  font-weight: 600;
  padding: 4px var(--space-3) 6px;
  border-bottom: 1px solid var(--border);
}
table.slt-table td {
  padding: 7px var(--space-3);
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
table.slt-table td.num,
table.slt-table th.num {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
table.slt-table tr.revised td {
  background: color-mix(in srgb, var(--accent-terracotta) 6%, transparent);
}
table.slt-table tr.revised {
  border-left: 3px solid var(--accent-terracotta);
}
table.slt-table tr.revised td:first-child {
  padding-left: calc(var(--space-3) - 3px);
}
.revised-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--accent-terracotta);
  border: 1px solid var(--accent-terracotta);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.subrow-label {
  padding-left: 14px;
  color: var(--text-secondary);
}
.subrow-note {
  font-size: 10.5px;
  color: var(--text-tertiary);
}
.empty-note {
  padding: 8px var(--space-3) var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-style: italic;
}

.summary-strip {
  border-top: 2px solid var(--text-primary);
  padding: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.summary-strip .totals {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary-strong);
}
.summary-strip .totals .grand {
  font-weight: 700;
  color: var(--text-primary);
}
.credit-block {
  text-align: right;
}
.credit-block .credit-number {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1;
}
.credit-block .credit-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-tertiary);
}

/* One label column + two value columns (2nd/3rd Ed), instead of two
   side-by-side blocks that each repeated "Teaching / Learning", "Grand
   Total SLT", etc. Column widths reuse the same variables as the table's
   colgroup above, so the ed2/ed3 value columns still land under the
   table's own ed2/ed3 columns. */
.comparison-summary {
  border-top: 2px solid var(--text-primary);
  padding: var(--space-3);
  display: grid;
  grid-template-columns:
    var(--cmp-activity-w) calc(4 * var(--cmp-num-w))
    calc(4 * var(--cmp-num-w));
  row-gap: 8px;
}
.comparison-summary .stat-row {
  display: contents;
}
.comparison-summary .stat-label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  align-self: baseline;
}
.comparison-summary .stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary-strong);
  text-align: right;
  align-self: baseline;
  padding-right: var(--space-3);
}
.comparison-summary .stat-value.ed3 {
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
  padding-right: 0;
}
.comparison-summary .stat-col-label {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  text-align: right;
  padding-right: var(--space-3);
}
.comparison-summary .stat-col-label.ed2 {
  color: var(--ed2-ink);
}
.comparison-summary .stat-col-label.ed3 {
  color: var(--ed3-ink);
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
  padding-right: 0;
}
.comparison-summary .stat-row.stat-grand .stat-label,
.comparison-summary .stat-row.stat-grand .stat-value {
  font-weight: 700;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.comparison-summary .stat-row.stat-credit .stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  align-self: center;
}
.comparison-summary .stat-row.stat-credit .stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  align-self: center;
}

/* ---------- Flags footer ---------- */
.footnote {
  margin-top: var(--space-4);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}
.footnote code {
  font-family: var(--font-mono);
  background: var(--surface-subtle);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- What-If section ---------- */
.whatif-card {
  margin-top: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--bs-thin);
}
.whatif-head {
  padding: var(--space-3);
  background: var(--off-white);
  border-bottom: 2px dashed var(--accent-forest);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.whatif-head .ed-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--accent-forest);
}
.whatif-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin: 2px 0 4px 0;
  font-weight: 550;
  color: var(--accent-forest);
}
.whatif-head .cite {
  font-size: 11px;
  color: var(--text-tertiary);
  max-width: 60ch;
}
.whatif-reset {
  font-size: var(--fs-xs);
  color: var(--accent-forest);
  cursor: pointer;
  background: none;
  border: 1px solid var(--accent-forest);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-body);
  white-space: nowrap;
}
.whatif-reset:hover {
  background: color-mix(in srgb, var(--accent-forest) 8%, transparent);
}

table.slt-table input.wi-input {
  width: 80px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-align: right;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--paper);
}
table.slt-table input.wi-input:focus {
  outline: 2px solid var(--accent-forest);
  outline-offset: 1px;
}
table.slt-table tr.wi-subrow td {
  color: var(--text-secondary);
}
table.slt-table tr.wi-subrow .subrow-label {
  padding-left: 20px;
}

.target-strip {
  border-top: 2px solid var(--text-primary);
  padding: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.target-strip .totals {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary-strong);
}
.target-strip .totals .grand {
  font-weight: 700;
  color: var(--text-primary);
}
.target-status {
  text-align: right;
}
.target-status .credit-number {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1;
}
.target-status .credit-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-tertiary);
}
.target-status .status-line {
  font-size: var(--fs-xs);
  margin-top: 4px;
  font-weight: 600;
}
.target-status.on-target .credit-number,
.target-status.on-target .status-line {
  color: var(--accent-forest);
}
.target-status.over-target .credit-number,
.target-status.over-target .status-line {
  color: var(--accent-crimson);
}
.target-status.under-target .credit-number,
.target-status.under-target .status-line {
  color: var(--accent-terracotta);
}
.target-status .hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  max-width: 34ch;
}

/* ---------- Footer: chart colophon pattern ---------- */
.site-footer {
  margin-top: var(--space-2);
  padding: var(--space-3) 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.footer-mark {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.footer-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.footer-title {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-primary);
}
.footer-meta {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  flex: 1;
  text-align: center;
}
.footer-stamp {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--accent-forest);
  border: 1.5px solid var(--accent-forest);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  transform: rotate(-2deg);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
  .footer-meta {
    text-align: left;
  }
  .footer-stamp {
    transform: none;
    align-self: flex-start;
  }
}

/* ---------- Theme toggle ---------- */
.masthead-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent-forest);
  color: var(--accent-forest);
}
.theme-toggle .fa-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .fa-sun {
  display: inline;
}
:root[data-theme="dark"] .theme-toggle .fa-moon {
  display: none;
}

@media (max-width: 640px) {
  .chips {
    margin-left: 0;
  }
  .credit-block {
    text-align: left;
  }
  .summary-strip {
    flex-direction: column;
    align-items: flex-start;
  }
  .target-status {
    text-align: left;
  }
  .target-strip {
    flex-direction: column;
    align-items: flex-start;
  }
}
