:root {
  color-scheme: light;
  --paper: #faf8f2;
  --surface: #fffdfa;
  --surface-alt: #f1edf9;
  --ink: #292342;
  --muted: #554c6e;
  --line: #d9d2e5;
  --accent: #5434a8;
  --focus: #5c35c0;
  --structural-accent: #7554ce;
  --purple-soft: #f1e9ff;
  --purple-ink: #5427a1;
  --mint-soft: #e2f5e9;
  --mint-ink: #165b4b;
  --peach-soft: #fff0d7;
  --peach-ink: #81430e;
  --error-surface: #ffeae6;
  --error-text: #932e36;
  --hero-background: #302273;
  --ink-panel: #252047;
  --fixed-ink: #252047;
  --on-panel: #fcf8ff;
  --panel-muted: #dfd7fa;
  --panel-line: #8f83b5;
  --yellow: #ffe382;
  --button-hover: #594198;
  --plot-paper: #f4eefc;
  --page-width: 1320px;
  --gutter: clamp(16px, 4vw, 54px);
  --heading-font: system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161525;
  --surface: #1f1c31;
  --surface-alt: #2a2441;
  --ink: #f4efff;
  --muted: #c9bfde;
  --line: #463d60;
  --accent: #c9b3ff;
  --focus: #d3b8ff;
  --structural-accent: #a78aef;
  --purple-soft: #2b2247;
  --purple-ink: #d8bbff;
  --mint-soft: #192f31;
  --mint-ink: #a2e8c7;
  --peach-soft: #3a2a33;
  --peach-ink: #ffce9e;
  --error-surface: #432837;
  --error-text: #ffacbf;
  --hero-background: #2a2056;
  --ink-panel: #251e42;
  --button-hover: #6343a7;
}


:root {
  --green: var(--accent);
  --pale: var(--surface-alt);
  --lime: var(--yellow);
  --rust: var(--focus);
  --panel-surface: #37305d;
  --series-1: #5637a5;
  --series-2: #a24620;
  --series-3: #345fa3;
  --series-4: #846000;
  --series-5: #854398;
  --series-6: #176969;
  --series-7: #6d5146;
  --series-8: #9e376e;
}

:root[data-theme="dark"] {
  --series-1: #bba5ff;
  --series-2: #ffa87d;
  --series-3: #9bbdff;
  --series-4: #f5d575;
  --series-5: #e9a5ee;
  --series-6: #7ae2dc;
  --series-7: #d9b6a7;
  --series-8: #ff9eca;
}

.lab-header {
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
  border: 0;
  font: 1rem/1.4 var(--heading-font);
}
.lab-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px clamp(15px, 3vw, 42px);
  align-items: center;
  padding-block: 20px 15px;
}

.site-wordmark {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 9px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.55px;
  text-decoration: none;
  white-space: nowrap;
}

.site-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--yellow);
  border-radius: 10px;
  color: var(--fixed-ink);
  font-size: 21px;
  line-height: 1;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 8px;
  align-items: center;
}

.site-nav a,
.nav-more,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--purple-ink);
  background: var(--purple-soft);
}

.nav-more { display: none; }
.nav-more-links { display: contents; }

.theme-toggle {
  grid-column: 3;
  justify-self: end;
  padding-inline: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle:hover,
.theme-toggle[aria-pressed="true"] {
  border-color: var(--structural-accent);
  background: var(--purple-soft);
}

.theme-icon {
  display: inline-grid;
  place-items: center;
  width: 1em;
  color: var(--accent);
  font-size: 1.15em;
  line-height: 1;
}

.theme-icon::before { content: "☾"; }
.theme-toggle[aria-pressed="true"] .theme-icon::before { content: "☀"; }

.lab-header a { text-decoration: none; }

.lab-footer {
  max-width: var(--page-width);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  margin: 28px auto 0;
  padding: 22px var(--gutter) 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: .8rem/1.6 var(--heading-font);
}
.lab-footer a { color: var(--accent); }
.lab-footer strong { color: var(--ink); }

.allocation-shell,
.guide-page main {
  max-width: var(--page-width);
  padding-inline: var(--gutter);
}

.allocation-intro {
  margin-bottom: 24px;
  padding: clamp(22px, 4vw, 42px);
  border-radius: 14px;
  background: var(--hero-background);
  color: var(--on-panel);
}
.allocation-intro h1 em { color: var(--yellow); }
.allocation-intro :is(.eyebrow, .author, .intro-row > p) { color: var(--panel-muted); }
.allocation-intro .author a { color: var(--on-panel); }
.allocation-intro a:focus-visible { outline-color: var(--yellow); }
.allocation-intro .section-link { display: inline-block; color: var(--yellow); font-size: .8rem; }

.lab-hero, .guide-page .hero { background: var(--hero-background); }
.guide-page main { padding-top: 8px; }
.guide-page .hero, .lab-hero { border-radius: 14px; }
.guide-page .hero a:focus-visible, .lab-hero a:focus-visible { outline-color: var(--yellow); }

.guide-page .contents { min-width: 0; }
.guide-page .layout > div { min-width: 0; }
.guide-page .chapter { overflow-wrap: anywhere; }
.guide-page .chapter pre { overflow-x: auto; }

:focus-visible { outline-color: var(--focus); }
:is(.skip, .skip-link):focus { z-index: 20; background: var(--surface); color: var(--ink); }

@media (max-width: 1040px) {
  .lab-header { grid-template-columns: 1fr auto; }
  .theme-toggle { grid-column: 2; grid-row: 1; }
  .site-nav { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 700px) {
  .lab-header { padding-block: 12px 8px; gap: 5px 8px; }
  .site-nav {
    position: relative;
    margin-inline: -6px;
    gap: 0 4px;
  }
  .site-nav a, .nav-more { padding-inline: 8px; min-height: 44px; }
  .nav-more:not([hidden]) {
    display: inline-flex;
    margin-inline-start: auto;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
  }
  .nav-more[aria-expanded="true"],
  .site-nav:has(.nav-more-links [aria-current="page"]) .nav-more {
    background: var(--purple-soft);
    border-color: var(--structural-accent);
    color: var(--purple-ink);
  }
  .nav-caret {
    width: .42em;
    height: .42em;
    margin-block-start: -.22em;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
  }
  .nav-more[aria-expanded="true"] .nav-caret {
    margin-block-start: .22em;
    transform: rotate(225deg);
  }
  .nav-more:not([hidden]) + .nav-more-links {
    display: none;
    position: absolute;
    z-index: 30;
    inset-block-start: calc(100% + 6px);
    inset-inline-end: 0;
    inline-size: min(100%, 238px);
    box-sizing: border-box;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 8px 24px #0004;
  }
  .nav-more[aria-expanded="true"]:not([hidden]) + .nav-more-links { display: grid; }
  .nav-more-links a { padding-inline: 12px; }
  .allocation-intro { margin-bottom: 16px; }
  .allocation-shell { padding-top: 8px; }
  .lab-footer { margin-top: 20px; }
}

@media print {
  .lab-header, .theme-toggle { display: none; }
}

:root { --shadow: #e6dff1; }
:root[data-theme="dark"] { --shadow: #161326; }
.lab-hero .eyebrow, .guide-page .hero .eyebrow { color: var(--yellow); }
.controls :is(input, select), .presets button, .legend button { accent-color: var(--accent); }
.control output, .bank-selector button[aria-pressed="true"] {
  background: var(--ink-panel);
  color: var(--yellow);
}
:is(.metric-label, .metric-note, .metric-delta) { color: var(--panel-muted); }
.interactive-chart .plot-line { filter: none; }
.interactive-network .network-canvas { color: var(--ink); }
.lab-skip { position: absolute; top: -100px; left: 16px; padding: 8px 12px; }
.lab-skip:focus { top: 8px; }

.lab-missing {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--heading-font);
}
.lab-missing * { box-sizing: border-box; }
.lab-missing main {
  max-width: var(--page-width);
  margin-inline: auto;
  padding: 10vh var(--gutter);
}
.lab-missing main a { color: var(--accent); }
