/* ============================================================
   NSP project page + interactive demo
   Static, dependency-free CSS.
   ============================================================ */

:root {
  /* Default LIGHT palette. Always wins regardless of OS / browser color
     scheme; the dark palette is opt-in via [data-theme="dark"]. */
  color-scheme: light;
  --bg-0: #f3ece0;
  --bg-1: #ece4d3;
  --bg-2: #e3d8c2;
  --bg-3: #d6c8ae;
  --line: rgba(60, 48, 30, 0.18);
  --line-strong: rgba(60, 48, 30, 0.34);
  --text-0: #1c1610;
  --text-1: #463a26;
  --text-2: #6b5d44;
  --warn: #b07a1e;
  --ok: #4a7032;
  --eval: #8a3a6c;
  --shadow: 0 18px 50px rgba(40, 28, 12, 0.12);
  --radius: 2px;
  --radius-sm: 0;

  --paper-bg: #f3ece0;
  --paper-bg-soft: #ece4d3;
  --ink: #1c1610;
  --ink-soft: #463a26;
  --ink-dim: #75674e;
  --ink-faint: #b6a98b;
  --rule: rgba(60, 48, 30, 0.16);
  --rule-strong: rgba(60, 48, 30, 0.34);
  --plate: #fbf6ea;
  --plate-edge: rgba(60, 48, 30, 0.14);
  --plate-shadow: 0 18px 44px rgba(40, 28, 12, 0.10);

  --accent: #8a6a2a;
  --accent-soft: rgba(138, 106, 42, 0.16);
  --accent-line: rgba(138, 106, 42, 0.46);

  /* Fonts. */
  --serif: "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", Times, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Roboto, Arial,
    sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-0: #0e0f14;
  --bg-1: #161821;
  --bg-2: #1d2029;
  --bg-3: #262a36;
  --line: rgba(232, 226, 212, 0.13);
  --line-strong: rgba(232, 226, 212, 0.28);
  --text-0: #ece4d2;
  --text-1: #bab09a;
  --text-2: #807866;
  --warn: #d8a85a;
  --ok: #9ab48a;
  --eval: #c69cb6;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);

  --paper-bg: #0e0f14;
  --paper-bg-soft: #161821;
  --ink: #ece4d2;
  --ink-soft: #b6ad97;
  --ink-dim: #75705f;
  --ink-faint: #3a3830;
  --rule: rgba(232, 226, 212, 0.12);
  --rule-strong: rgba(232, 226, 212, 0.28);
  --plate: #f3eadb;
  --plate-edge: rgba(232, 226, 212, 0.22);
  --plate-shadow: 0 32px 80px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  --accent: #c8a96a;
  --accent-soft: rgba(200, 169, 106, 0.16);
  --accent-line: rgba(200, 169, 106, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--text-0);
  font: 15px/1.65 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Only the root carries the paper background; the body must remain
   transparent so the decorative WebGL canvas (z:-2) is visible underneath. */
html {
  background: var(--bg-0);
}

body {
  overflow-x: hidden;
}

img {
  max-width: 100%;
}

.muted {
  color: var(--text-2);
  font-size: 13.5px;
}

/* ============================================================
   Project page (journal-style, dark, serif)
   ============================================================ */

.page--project {
  /* Background is intentionally transparent; the paper colour is painted on
     <html> and the decorative WebGL canvas (z:-2) renders between them. */
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  letter-spacing: 0.005em;
  min-height: 100vh;
  position: relative;
}

.page--project a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color 160ms ease, border-color 160ms ease;
}

.page--project a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.page--project em {
  font-style: italic;
}

.page--project strong {
  font-weight: 600;
}

/* Decorative WebGL background (drifting latent-SDE ribbons).
   Sits behind every paint layer; can be removed without any visual breakage. */
.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
  display: block;
}

.page__bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* Transparent base so the WebGL canvas (z:-2) reads through; the body
     element provides the solid paper colour underneath both layers. */
  background:
    radial-gradient(1100px 600px at 50% -10%, rgba(80, 60, 30, 0.18), transparent 65%),
    radial-gradient(900px 700px at 50% 110%, rgba(40, 50, 70, 0.16), transparent 70%);
}

.page__bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 248, 230, 0.18), transparent 60%),
    radial-gradient(1px 1px at 78% 28%, rgba(255, 248, 230, 0.14), transparent 60%),
    radial-gradient(1px 1px at 32% 64%, rgba(255, 248, 230, 0.12), transparent 60%),
    radial-gradient(1px 1px at 88% 78%, rgba(255, 248, 230, 0.16), transparent 60%),
    radial-gradient(1.4px 1.4px at 56% 88%, rgba(255, 248, 230, 0.10), transparent 60%);
  background-repeat: no-repeat;
  opacity: 0.7;
}

.paper {
  max-width: 1080px;
  margin: 0 auto;
  padding: 96px 28px 120px;
}

.paper__head {
  text-align: center;
  max-width: 980px;
  margin: 0 auto 24px;
}

.paper__title {
  margin: 0 auto 30px;
  max-width: 920px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 4.4vw, 60px);
  line-height: 1.16;
  letter-spacing: -0.005em;
  color: var(--ink);
  text-wrap: balance;
}

.paper__status {
  margin: 0 0 22px;
  font-style: italic;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.paper__note {
  margin: 0 auto 30px;
  max-width: 76ch;
  color: var(--ink-soft);
  font-size: 16.5px;
  font-style: italic;
  line-height: 1.7;
  text-wrap: balance;
}

.paper__links {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 20px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.link:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.page--project .link {
  border-bottom: 1px solid var(--rule-strong);
}

.page--project .link:hover {
  border-color: var(--ink);
}

.link--locked {
  color: var(--ink-dim);
  border-style: dashed;
  cursor: default;
}

.link--locked:hover {
  border-color: var(--rule-strong);
  color: var(--ink-dim);
}

.link--demo {
  color: var(--accent);
  border-color: var(--accent-line);
}

.page--project .link--demo {
  border-bottom: 1px solid var(--accent-line);
}

.link--demo:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.link--inline {
  margin-top: 8px;
  font-size: 13.5px;
  padding: 8px 16px;
}

.link__icon {
  display: inline-block;
  width: 11px;
  height: 12px;
  flex: none;
}

/* Hero figure (eye-catch) sits in a "paper plate" card. */
.hero-figure,
.figure {
  margin: 56px auto;
  max-width: 920px;
}

.hero-figure {
  margin-top: 64px;
}

.hero-figure__plate,
.figure__plate {
  background: var(--plate);
  padding: 18px;
  border: 1px solid var(--plate-edge);
  box-shadow: var(--plate-shadow);
}

.hero-figure__plate img,
.figure__plate img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.hero-figure figcaption,
.figure figcaption {
  margin-top: 14px;
  text-align: center;
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* Sections. */
.section {
  max-width: 720px;
  margin: 80px auto 0;
  padding-top: 48px;
  border-top: 1px solid var(--rule);
}

.section__title {
  margin: 0 auto 32px;
  text-align: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.section__title::after {
  content: "";
  display: block;
  width: 36px;
  height: 1px;
  margin: 16px auto 0;
  background: var(--accent-line);
}

.prose p {
  margin: 0 0 18px;
  color: var(--ink);
}

.prose p:last-child {
  margin-bottom: 0;
}

.caption {
  margin: 24px 0 12px;
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
}

/* Numbered lists (Overview, Datasets). */
.numbered {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  counter-reset: numbered;
}

.numbered > li {
  display: grid;
  grid-template-columns: 56px 1fr;
  column-gap: 24px;
  row-gap: 6px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
  counter-increment: numbered;
}

.numbered > li:last-child {
  border-bottom: none;
}

.numbered > li::before {
  content: counter(numbered, decimal);
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 38px;
  line-height: 1;
  color: var(--accent);
}

.numbered__title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  padding-top: 4px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.numbered > li > p {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16.5px;
  line-height: 1.65;
}

/* Results table -- journal "ruled" style. */
.table-wrap {
  margin: 8px 0 0;
  overflow-x: auto;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}

.results {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--serif);
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

.results thead th {
  border-bottom: 1px solid var(--ink);
  padding: 10px 8px;
  text-align: right;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  white-space: nowrap;
}

.results thead th:first-child,
.results td:first-child {
  text-align: left;
}

.results td {
  padding: 8px;
  text-align: right;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.results tbody tr:last-child td {
  border-bottom: none;
}

.results__best td {
  color: var(--ink);
  background: var(--accent-soft);
}

.results__best em {
  font-style: italic;
}

.results__best strong {
  font-weight: 600;
}

/* BibTeX block. */
.bibtex {
  margin: 16px 0 0;
  padding: 18px 20px;
  background: var(--paper-bg-soft);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  letter-spacing: 0;
  overflow-x: auto;
}

.bibtex code {
  font-family: inherit;
}

/* Footer. */
.paper__foot {
  max-width: 720px;
  margin: 80px auto 0;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-dim);
}

/* ============================================================
   Theme dock (small fixed accent picker)
   ============================================================ */

.theme-toggle {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--paper-bg) 88%, transparent);
  border: 1px solid var(--rule-strong);
  backdrop-filter: blur(6px);
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper-bg-soft) 92%, transparent);
}

.theme-toggle__icon {
  display: inline-block;
  color: var(--accent);
}

/* Default (light theme): show the moon (click to go dark). */
.theme-toggle__icon--sun {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--sun {
  display: inline-block;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

/* ============================================================
   Lightbox
   ============================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
}

.lightbox[hidden] {
  display: none;
}

/* Lightbox uses fixed colours (light text on a near-black backdrop) so the
   caption and close button stay legible in both themes. */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.92);
  cursor: zoom-out;
}

.lightbox__panel {
  position: relative;
  max-width: min(94vw, 1500px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 20px 24px;
}

.lightbox__image {
  max-width: 100%;
  max-height: 78vh;
  background: #fbf6ea;
  padding: 12px;
  border: 1px solid rgba(255, 250, 235, 0.18);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.lightbox__caption {
  max-width: 80ch;
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15.5px;
  color: rgba(248, 240, 220, 0.94);
  line-height: 1.6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.lightbox__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 38px;
  height: 38px;
  background: rgba(20, 16, 10, 0.55);
  color: #fbf6ea;
  border: 1px solid rgba(248, 240, 220, 0.45);
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease,
    color 160ms ease;
}

.lightbox__close:hover {
  background: rgba(248, 240, 220, 0.18);
  border-color: #fbf6ea;
  color: #ffffff;
}

/* ============================================================
   Responsive (project page)
   ============================================================ */

@media (max-width: 720px) {
  .paper {
    padding: 64px 20px 80px;
  }
  .paper__title {
    font-size: clamp(28px, 8vw, 38px);
  }
  .section {
    margin-top: 56px;
    padding-top: 36px;
  }
  .section__title {
    font-size: 24px;
  }
  .numbered > li {
    grid-template-columns: 40px 1fr;
    gap: 16px;
  }
  .numbered > li::before {
    font-size: 28px;
  }
  .theme-toggle {
    right: 12px;
    top: 12px;
    padding: 6px 10px;
    font-size: 10.5px;
  }
}

/* ============================================================
   Demo page (preserved)
   ============================================================ */

.page--demo {
  /* Transparent gradient veil; body supplies the solid paper colour and the
     decorative WebGL canvas (z:-2) reads through. */
  background:
    radial-gradient(1100px 600px at 50% -10%, rgba(80, 60, 30, 0.18), transparent 65%),
    radial-gradient(900px 700px at 50% 110%, rgba(40, 50, 70, 0.16), transparent 70%);
  min-height: 100vh;
  font-family: var(--sans);
}

.page--demo .topbar {
  background: color-mix(in srgb, var(--bg-1) 86%, transparent);
  padding-right: 160px;
}

.page--demo a {
  color: var(--accent);
  text-decoration: none;
  transition: color 140ms ease;
}

.page--demo a:hover {
  color: var(--text-0);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  backdrop-filter: blur(6px);
}

.topbar__home {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-1);
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px;
}

.topbar__home:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.topbar__title {
  flex: 1;
}

.topbar__title h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.topbar__title p {
  margin: 2px 0 0;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-2);
  font-family: var(--serif);
}

.topbar__region {
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  padding: 5px 12px;
  border-radius: 0;
  background: transparent;
}

.demo {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  padding: 24px 28px;
  max-width: 1640px;
  margin: 0 auto;
}

@media (max-width: 920px) {
  .demo {
    grid-template-columns: 1fr;
  }
}

.demo__sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

.card--notice p {
  font-size: 12.5px;
  color: var(--text-1);
  margin: 0 0 8px;
  line-height: 1.55;
}

.card--notice strong {
  color: var(--accent);
  font-weight: 600;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar__head {
  font-size: 10.5px;
  text-align: center;
  color: var(--text-2);
  padding: 4px 0;
}

.calendar__cell {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-0);
  border-radius: 0;
  padding: 7px 0;
  font-family: var(--serif);
  font-size: 13px;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}

.calendar__cell:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--accent-line);
}

.calendar__cell--empty {
  background: transparent;
  border: none;
  cursor: default;
}

.calendar__cell--disabled {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
  cursor: not-allowed;
  opacity: 0.5;
}

.calendar__cell--active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.calendar__hint {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-2);
}

#hour {
  width: 100%;
  accent-color: var(--accent);
}

.hour-readout {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-1);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-1);
}

.legend__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend__swatch {
  width: 64px;
  height: 10px;
  border-radius: 0;
  border: 1px solid var(--line);
  display: inline-block;
}

.legend__swatch--precip {
  background: linear-gradient(
    90deg,
    #ffffff 0%,
    #e0e0e0 6%,
    #b3d3ed 16%,
    #4d8cc7 28%,
    #33a64d 44%,
    #9ed14d 60%,
    #ed8c2b 76%,
    #d8332e 90%,
    #8c1a1a 100%
  );
  border: 1px solid var(--paper-edge);
}

.legend__swatch--dem {
  background: linear-gradient(
    90deg,
    #5c94d1 0%,
    #cce6f3 14%,
    #f5eed1 22%,
    #d8d48c 38%,
    #c7a86b 58%,
    #8c6647 78%,
    #5e4836 90%,
    #f5f4f2 100%
  );
  border: 1px solid var(--paper-edge);
}

.demo__panels {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
}

.demo__row {
  display: grid;
  gap: 18px;
  align-items: start;
}

.demo__row--inputs,
.demo__row--outputs {
  grid-template-columns: repeat(2, 1fr);
}

.demo__row--outputs > .panel {
  max-width: none;
}

@media (max-width: 720px) {
  .demo__row--inputs,
  .demo__row--outputs {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.005em;
  color: var(--text-0);
}

.panel--highlight {
  border-color: var(--accent-line);
}

.panel--highlight header {
  background: var(--accent-soft);
  color: var(--ink);
  border-bottom-color: var(--accent-line);
}

.panel img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-2);
  image-rendering: auto;
}

.tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 0;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: transparent;
}

.tag--ok {
  color: var(--accent);
  border-color: var(--accent-line);
}

.tag--warn {
  color: var(--warn);
  border-color: var(--warn);
}

.tag--eval {
  color: var(--eval);
  border-color: var(--eval);
}

.panel--summary {
  background: var(--bg-1);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 24px;
  padding: 18px 22px;
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
}

.summary__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 1px solid var(--rule);
  padding-left: 14px;
}

.summary__item:first-child {
  border-left: none;
  padding-left: 0;
}

.summary__item--highlight dt {
  color: var(--accent);
  letter-spacing: 0.06em;
}

.summary__value--good {
  color: #2f7a3f;
  font-weight: 600;
}

[data-theme="dark"] .summary__value--good {
  color: #82c98a;
}

.summary__value--bad {
  color: #b04848;
  font-weight: 600;
}

@media (max-width: 720px) {
  .summary__item {
    border-left: none;
    padding-left: 0;
  }
}

.summary dt {
  margin: 0;
  color: var(--text-2);
  font-style: italic;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

.summary dd {
  margin: 0;
  color: var(--text-0);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.panel--summary .muted {
  padding: 0 22px 18px;
  margin: 0;
  font-style: italic;
  font-size: 12.5px;
  font-family: var(--serif);
}

.demo__footer {
  text-align: center;
  padding: 22px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--text-2);
  border-top: 1px solid var(--line);
  margin-top: 28px;
}

.calendar__hint,
.hour-readout,
.hour-note {
  font-family: var(--serif);
  font-style: italic;
}

.hour-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-2);
}

.error {
  margin: 24px;
  padding: 12px 16px;
  background: #2a1808;
  border: 1px solid #6f3f25;
  color: #f1c45b;
  border-radius: 0;
  font-size: 13px;
  font-family: var(--serif);
}

/* ============================================================
   Responsive refinements (tablet / phone)
   ------------------------------------------------------------
   The earlier blocks above cover the coarsest breakpoints
   (920 / 720 px). The rules below tighten secondary spacing
   and avoid cramped layouts on small viewports. Anything that
   only sharpens an existing rule lives here so the high-level
   sections above stay readable.
   ============================================================ */

/* Tablet portrait: ease up the demo gutters once the sidebar
   has dropped below the panels. The topbar still keeps its
   right-hand reservation for the floating theme toggle until the
   row collapses at the next breakpoint. */
@media (max-width: 920px) {
  .demo {
    padding: 22px 22px 28px;
    gap: 18px;
  }
  .demo__sidebar {
    /* When the sidebar stacks above the panels, sticky scrolling
       is more annoying than helpful. */
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Phone landscape and below: collapse the topbar to a wrapping
   stack and rein in the largest typographic blocks. */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 12px;
    padding: 14px 18px;
  }
  .page--demo .topbar {
    /* The row has wrapped, so the floating theme toggle no longer
       lands on top of the in-flow children -- drop the extra gutter
       reserved for it on desktop. */
    padding: 14px 18px;
  }
  .topbar__home {
    order: 1;
    flex: 0 0 auto;
  }
  .topbar__region {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
    /* Leave room so the floating theme toggle never lands on top
       of the region badge. */
    margin-right: 88px;
  }
  .topbar__title {
    order: 3;
    flex: 1 0 100%;
  }
  .topbar__title h1 {
    font-size: 18px;
  }
  .topbar__title p {
    font-size: 12px;
    line-height: 1.45;
  }

  .paper {
    padding: 56px 18px 72px;
  }
  .paper__status {
    font-size: 17px;
  }
  .paper__note {
    font-size: 15px;
    line-height: 1.6;
  }

  .hero-figure,
  .figure {
    margin: 40px auto;
  }
  .hero-figure {
    margin-top: 44px;
  }
  .hero-figure__plate,
  .figure__plate {
    padding: 10px;
  }
  .hero-figure figcaption,
  .figure figcaption {
    font-size: 13.5px;
  }

  .section__title {
    font-size: 22px;
  }
  .numbered__title {
    font-size: 18.5px;
  }
  .numbered > li > p {
    font-size: 15.5px;
  }

  .results {
    font-size: 13px;
  }
  .results thead th,
  .results td {
    padding: 7px 6px;
  }

  .bibtex {
    padding: 14px 14px;
    font-size: 12.5px;
  }

  .demo {
    padding: 16px 14px 24px;
    gap: 14px;
  }
  .demo__row--inputs,
  .demo__row--outputs {
    gap: 14px;
  }
  .panel header {
    padding: 9px 12px;
    font-size: 13px;
  }
  .card {
    padding: 14px 16px;
  }

  .calendar {
    gap: 3px;
  }
  .calendar__head {
    font-size: 10px;
  }
  .calendar__cell {
    padding: 6px 0;
    font-size: 12.5px;
  }

  .summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 18px;
    padding: 14px 16px;
  }
  .summary dd {
    font-size: 14.5px;
  }
  .panel--summary .muted {
    padding: 0 16px 14px;
  }
}

/* Very narrow phones (~iPhone SE width). */
@media (max-width: 420px) {
  .paper__title {
    font-size: clamp(24px, 7.4vw, 32px);
    line-height: 1.18;
  }
  .topbar__region {
    /* Drop the right-hand offset on the smallest screens; the
       theme toggle and badge can share the line because both are
       short. */
    margin-right: 76px;
    font-size: 11px;
    padding: 4px 9px;
    letter-spacing: 0.12em;
  }
  .topbar__home {
    font-size: 12px;
  }
  .summary {
    grid-template-columns: 1fr;
  }
  .results {
    font-size: 12px;
  }
  .results thead th,
  .results td {
    padding: 6px 4px;
  }
}
