:root {
  --model-canvas: var(--cream);
  --model-ink: var(--dark-text);
  --model-text: var(--body-text);
  --model-teal: var(--deep-teal);
  --model-berry: var(--berry);
  --model-rose: var(--dusty-rose);
  --model-sage: var(--sage-green);
  --model-line: rgba(47, 105, 117, 0.2);
}

html {
  scroll-behavior: smooth;
}

body:has(.model-page) {
  overflow-x: hidden;
  background: var(--model-canvas);
  color: var(--model-ink);
}

body:has(.model-page) > header.bg-hero {
  display: none;
}

body > .container:has(> .model-page) {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.model-page {
  width: 100%;
  overflow-x: clip;
  background: var(--model-canvas);
}

/* Transparent so the hero's ring flows into the content instead of being painted over.
   minmax(0, 1fr) lets the reading column shrink with the viewport so nothing overflows. */
.model-layout {
  width: min(calc(100% - 2.5rem), 84rem);
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  align-items: start;
  gap: clamp(2rem, 4vw, 4.5rem);
  margin: 0 auto;
  padding: clamp(3.5rem, 7vw, 6rem) 0 clamp(6rem, 10vw, 9rem);
}

.model-story {
  position: relative;
  min-width: 0;
  max-width: 68rem;
}

/* Engineering cycle rail ----------------------------------------------- */
.model-rail {
  --model-progress: 0;
  position: sticky;
  top: calc(var(--nav-height) + 2rem);
  align-self: start;
}

.model-rail ol {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The track runs between the first and last marker centres. */
.model-rail-track {
  position: absolute;
  top: 1rem;
  bottom: 1rem;
  left: calc(1rem - 1px);
  width: 2px;
  border-radius: 1px;
  background: var(--model-line);
}

.model-rail-progress {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(var(--model-teal), var(--model-berry));
  transform: scaleY(var(--model-progress));
  transform-origin: top;
}

.model-rail a {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  color: rgba(31, 36, 33, 0.5);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: color 180ms ease;
}

.model-rail-marker {
  width: 2rem;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(47, 105, 117, 0.35);
  border-radius: 50%;
  background: var(--model-canvas);
  color: var(--model-teal);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

.model-rail li.is-complete .model-rail-marker {
  border-color: var(--model-teal);
  background: var(--model-teal);
  color: var(--white);
}

.model-rail a:hover,
.model-rail a:focus-visible,
.model-rail a[aria-current="location"] {
  color: var(--model-berry);
}

.model-rail a:focus-visible {
  border-radius: 0.35rem;
  outline: 2px solid var(--model-berry);
  outline-offset: 0.2rem;
}

.model-rail a:hover .model-rail-marker,
.model-rail a[aria-current="location"] .model-rail-marker {
  border-color: var(--model-berry);
  background: var(--model-berry);
  color: var(--white);
  box-shadow: 0 0 0 0.2rem rgba(170, 43, 98, 0.16);
  transform: scale(1.08);
}

.model-chapter {
  padding: clamp(2.5rem, 5vw, 4rem) 0;
  border-bottom: 1px solid var(--model-line);
  scroll-margin-top: calc(var(--nav-height) + 2rem);
}

.model-chapter:first-child {
  padding-top: 0;
}

.model-chapter:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.model-chapter h2 {
  margin: 0 0 clamp(1.5rem, 3vw, 2.25rem);
  color: var(--model-teal);
  font: 400 clamp(2rem, 4vw, 3.4rem)/1.08 var(--font-display);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.model-chapter-body {
  min-width: 0;
}

.model-prose p {
  margin: 0 0 1.45rem;
  color: var(--model-text);
  font-size: clamp(1rem, 1.3vw, 1.13rem);
  line-height: 1.82;
}

.model-chapter--introduction .model-prose p:first-child {
  color: var(--model-ink);
  font: clamp(1.18rem, 1.8vw, 1.5rem)/1.65 var(--font-display);
}

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

/* Lists read as body copy: same size, rhythm and colour as the paragraphs around them. */
.model-prose ol,
.model-prose ul {
  margin: 0 0 1.45rem;
  padding-left: 1.4rem;
  color: var(--model-text);
  font-size: clamp(1rem, 1.3vw, 1.13rem);
  line-height: 1.82;
}

.model-prose li + li {
  margin-top: 0.7rem;
}

.model-prose li::marker {
  color: var(--model-teal);
  font-weight: 700;
}

.model-prose ol:last-child,
.model-prose ul:last-child {
  margin-bottom: 0;
}

.model-prose h3 {
  margin: clamp(2.5rem, 5vw, 4rem) 0 1rem;
  color: var(--model-teal);
  font: 400 clamp(1.7rem, 3vw, 2.5rem)/1.05 var(--font-display);
  letter-spacing: -0.03em;
}

.model-prose h3.model-section-heading {
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
  line-height: 1.12;
}

.model-prose h4 {
  margin: 2rem 0 1rem;
  color: var(--model-teal);
  font: 400 clamp(1.3rem, 2vw, 1.7rem)/1.2 var(--font-display);
}

.model-figure {
  margin: clamp(2.5rem, 5vw, 3.75rem) 0;
}

.model-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(47, 105, 117, 0.22);
  border-radius: 0.65rem;
  background: rgba(255, 250, 241, 0.7);
  box-shadow: 0 1rem 2.5rem rgba(31, 36, 33, 0.08);
}

.model-figure figcaption {
  margin-top: 0.9rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--model-rose);
  color: var(--model-text);
  font-size: 0.92rem;
  line-height: 1.6;
}

.model-figure figcaption strong {
  color: var(--model-teal);
  font-weight: 700;
}

/* Narrow screens: the rail becomes a compact sticky strip above the text. */
@media (max-width: 900px) {
  .model-layout {
    display: block;
    padding-top: 0;
  }

  .model-rail {
    z-index: 10;
    top: var(--nav-height);
    margin: 0 -1.25rem clamp(2.5rem, 7vw, 4rem);
    padding: 0.55rem 1.25rem;
    overflow-x: auto;
    border-block: 1px solid rgba(47, 105, 117, 0.16);
    background: rgba(241, 230, 208, 0.9);
    box-shadow: 0 0.45rem 1.2rem rgba(31, 36, 33, 0.07);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .model-rail::-webkit-scrollbar {
    display: none;
  }

  .model-rail ol {
    width: max-content;
    display: flex;
    gap: 1rem;
  }

  .model-rail-track {
    display: none;
  }

  .model-rail a {
    display: flex;
    gap: 0.45rem;
    white-space: nowrap;
  }

  .model-rail-marker {
    flex: 0 0 2rem;
  }

  .model-chapter {
    scroll-margin-top: calc(var(--nav-height) + 4.5rem);
  }
}

@media (max-width: 760px) {
  .model-layout {
    width: calc(100% - 2rem);
  }

  .model-rail {
    margin-inline: -1rem;
    padding-inline: 1rem;
  }

  .model-figure {
    margin: 2rem 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .model-rail a,
  .model-rail-marker {
    transition: none;
  }
}

@media print {
  .model-rail {
    display: none;
  }

  .model-layout {
    display: block;
  }

  .model-figure {
    break-inside: avoid;
  }
}

/* Inline citation markers and reference accordions ------------------------ */
.model-cite {
  font-size: 0.62em;
  line-height: 0;
}

.model-cite a {
  padding: 0.05rem 0.25rem;
  border-radius: 0.2rem;
  background: rgba(170, 43, 98, 0.1);
  color: var(--model-berry);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.model-cite a:hover,
.model-cite a:focus-visible {
  background: var(--model-berry);
  color: var(--white);
}

.model-cite + .model-cite {
  margin-left: 0.15rem;
}

.model-ref-note {
  color: rgba(31, 36, 33, 0.6);
  font-size: 0.92rem;
}

.model-ref-list {
  margin-bottom: 1.5rem;
  border-top: 1px solid var(--model-line);
}

.model-ref {
  border-bottom: 1px solid var(--model-line);
  scroll-margin-top: calc(var(--nav-height) + 2rem);
}

.model-ref summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.9rem 0.5rem 0.9rem 0;
  color: var(--dark-text);
  cursor: pointer;
  font-size: 0.95rem;
  list-style: none;
}

.model-ref summary::-webkit-details-marker {
  display: none;
}

.model-ref summary::after {
  margin-left: auto;
  color: var(--model-teal);
  content: "+";
  font-size: 1.1rem;
  line-height: 1;
}

.model-ref[open] > summary::after {
  content: "–";
}

.model-ref summary:hover,
.model-ref[open] > summary {
  color: var(--model-berry);
}

.model-ref-tag {
  padding: 0.15rem 0.4rem;
  border-radius: 0.2rem;
  background: rgba(170, 43, 98, 0.1);
  color: var(--model-berry);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.model-ref-title {
  font-weight: 700;
}

.model-ref-hint {
  color: rgba(31, 36, 33, 0.52);
  font-size: 0.82rem;
}

.model-ref > p {
  margin: 0;
  padding: 0 0 1.1rem;
  color: var(--model-text);
  font-size: 0.92rem;
  line-height: 1.7;
}

.model-ref:target {
  background: rgba(221, 175, 204, 0.18);
}

/* Modeling-specific media and references. */
.model-table-line { padding:.65rem 1rem; border-left:2px solid var(--model-line); background:rgba(255,255,255,.45); font-family:monospace; tab-size:4; }
.model-cite { color:var(--model-berry); text-decoration:underline; text-underline-offset:.2em; }
.model-ref { border-block-end:1px solid var(--model-line); scroll-margin-top:calc(var(--nav-height) + 2rem); }
.model-ref summary { display:flex; align-items:baseline; gap:1rem; padding:1rem 0; cursor:pointer; list-style:none; font-weight:600; color:var(--model-teal); }
.model-ref summary::-webkit-details-marker { display:none; }
.model-ref summary::after { content:"+"; margin-left:auto; }
.model-ref[open] summary::after { content:"−"; }
.model-ref[open] summary { color:var(--model-berry); }
.model-ref > p { padding-bottom:1rem; font-size:.92rem; }
.model-equation-slot { min-height:6rem; display:grid; place-items:center; border:1px dashed var(--model-line); margin-bottom:2rem; color:var(--model-teal); }

.model-figure-images { display:grid; gap:1rem; }
.model-figure-images--pair {
  grid-template-columns:repeat(2,minmax(0,1fr));
  align-items:center;
  width:min(100%,40rem);
  margin-inline:auto;
}
.model-figure-images--pair img { max-height:22rem; }
.model-figure img { max-height:38rem; object-fit:contain; }
.model-table-line { font-size:.95rem; line-height:1.65; overflow-wrap:anywhere; white-space:pre-wrap; }
@media(max-width:640px) {
  .model-figure-images--pair { gap:.5rem; }
}

#model-notes { padding:0 0 2rem; margin-bottom:2rem; font-size:.9rem; }
#model-notes h3 { font-size:1.3rem; margin-block:1rem .75rem; }
#model-notes p { font-size:.9rem; line-height:1.65; }

/* Compact labeled panels: keep a/b adjacent at every screen width. */
.model-figure .model-figure-images--pair {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:.4rem;
  width:min(100%,32rem);
  margin-inline:auto;
  align-items:start;
}
.model-figure-panel { min-width:0; }
.model-panel-label {
  display:block;
  margin-bottom:.4rem;
  color:var(--model-teal);
  font-size:.8rem;
  font-weight:700;
}
.model-figure .model-figure-images--pair img {
  width:100%;
  height:auto;
  max-height:16rem;
  object-fit:contain;
  box-shadow:none;
}
.model-table-wrap {
  max-width:100%;
  overflow-x:auto;
  margin:1.5rem 0 2rem;
  border:1px solid var(--model-line);
  border-radius:.5rem;
}
.model-table { width:100%; border-collapse:collapse; font-size:.94rem; line-height:1.55; }
.model-table th,.model-table td {
  padding:.8rem 1rem;
  text-align:left;
  vertical-align:top;
  border-bottom:1px solid var(--model-line);
  min-width:8rem;
  overflow-wrap:anywhere;
}
.model-table thead th { color:var(--model-teal); background:rgba(47,105,117,.1); font-weight:700; }
.model-table tbody th { font-weight:600; color:var(--model-ink); }
.model-table tbody tr:nth-child(even) { background:rgba(255,250,241,.5); }
.model-table tbody tr:last-child > * { border-bottom:0; }

/* Match Engineering's body rhythm with clear, aligned list markers. */
.model-prose .model-bullets {
  margin:0 0 1.45rem;
  padding-left:1.4rem;
  list-style:disc;
}
.model-prose .model-bullets > li {
  padding-left:.3rem;
  overflow-wrap:anywhere;
}
.model-prose .model-bullets > li + li { margin-top:.85rem; }
.model-prose .model-bullets > li::marker { color:var(--model-teal); font-size:.85em; }

/* Give each major section a clear break after the preceding divider. */
.model-story > .model-chapter + .model-chapter {
  margin-top:clamp(2rem,4vw,3.5rem);
}
@media print {
  .model-story > .model-chapter + .model-chapter { margin-top:2rem; }
}

/* Separate only the main modeling sections with visible rules. */
.model-story > .model-chapter + .model-chapter {
  border-top:1px solid var(--model-line);
  padding-top:clamp(3rem,6vw,5rem);
}
.model-story > .model-chapter { border-bottom:0; }

.model-equation {
  margin:1rem 0;
  border:1px solid var(--model-line);
  border-radius:.5rem;
  background:rgba(255,250,241,.5);
}
.model-equation summary {
  display:flex;
  align-items:center;
  gap:1rem;
  padding:1rem 1.2rem;
  list-style:none;
  cursor:pointer;
  color:var(--model-teal);
  font-weight:600;
}
.model-equation summary::-webkit-details-marker { display:none; }
.model-equation summary::after { content:"Show equation +"; margin-left:auto; flex-shrink:0; font-size:.85rem; }
.model-equation[open] summary::after { content:"Hide equation −"; }
.model-equation summary:focus-visible { outline:2px solid var(--model-teal); outline-offset:3px; }
.model-equation-body { padding:0 1.2rem 1.2rem; overflow-x:auto; }
.model-equation .model-equation-slot { margin:0; border:0; min-height:3rem; }

/* Native math renders locally; the LaTeX transcription is retained in each annotation. */
.model-equation-math { padding:1rem 0; min-width:0; }
.model-equation-math math { font-size:1.2rem; margin:0; }
.model-equation-body { overscroll-behavior-x:contain; }
.model-table caption { caption-side:top; padding:1rem; color:var(--model-teal); font-weight:600; text-align:left; }
.model-source-link { font-size:.85rem; color:var(--model-teal); }

.model-video {
  aspect-ratio: 16 / 9;
  width: 100%;
}

.model-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0.65rem;
}
/* DEHP concentrations dropdown table: scrolls inside the open dropdown, header stays visible. */
.model-table-wrap--scroll {
  max-height:34rem;
  margin:0;
  overflow:auto;
  overscroll-behavior:contain;
}
.model-table--dehp { font-size:.85rem; line-height:1.5; }
.model-table--dehp th,
.model-table--dehp td { min-width:9rem; overflow-wrap:break-word; }
.model-table--dehp thead th {
  position:sticky;
  top:0;
  z-index:2;
  background:color-mix(in srgb, var(--model-teal) 14%, var(--model-canvas));
}
.model-table--dehp td:nth-child(6),
.model-table--dehp td:nth-child(7) { min-width:18rem; }
.model-table--dehp a { color:var(--model-berry); overflow-wrap:anywhere; }
.model-data-dropdown .model-equation-body { padding-top:.2rem; }

/* Parameter table dropdown (needs the earlier .model-table-wrap--scroll rule from the DEHP additions). */
.model-table--params { font-size:.85rem; line-height:1.5; }
.model-table--params th,
.model-table--params td { min-width:7rem; overflow-wrap:break-word; }
.model-table--params thead th {
  position:sticky;
  top:0;
  z-index:2;
  background:color-mix(in srgb, var(--model-teal) 14%, var(--model-canvas));
}
.model-table--params td:nth-child(2),
.model-table--params td:nth-child(3) { min-width:12rem; }
.model-table--params td:nth-child(8),
.model-table--params td:nth-child(9) { min-width:18rem; }
.model-table--params a { color:var(--model-berry); overflow-wrap:anywhere; }

/* WT / D119A binding tables dropdown (needs the .model-data-dropdown rule from the DEHP additions). */
.model-table-wrap--stack { margin:0 0 1.25rem; }
.model-table-wrap--stack:last-child { margin-bottom:0; }
.model-table--d119a th,
.model-table--d119a td { min-width:9rem; }
.model-table--d119a tbody tr.model-table-section td {
  background:rgba(47,105,117,.1);
  color:var(--model-teal);
  font-weight:700;
}


.model-data-dropdown summary::after { content:"Show more +"; }
.model-data-dropdown[open] summary::after { content:"Show less −"; }