:root {
  --bg: #f0ede2;
  --surface: #fbf9f1;
  --fg: #172321;
  --mut: #3f4d47;
  --line: #c9cfc3;
  --line-soft: #d9ddd2;
  --accent: #06565a;
  --accent-ink: #f4f3e9;
  --water: #168e91;
  --water-deep: #07535a;
  --water-light: #9bd2c7;
  --land: #c6b27d;
  --land-deep: #847449;
  --floodplain: #e0d2ac;
  --mud: #9a5c30;
  --town: #f6e9c9;
  --nav: #142421;
  --nav-ink: #f5f1e7;
  --hero-shade: rgba(5, 17, 17, .74);
  --hero-caption: rgba(8, 23, 23, .82);
  --plate: #f2ead8;
  --plate-grid: #aaa282;
  --deep-ink: #0b2021;
  --map-label: #172321;
  --shadow: 0 24px 72px rgba(17, 32, 29, .12);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --content: 84rem;
  --nav-height: 3.5rem;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #101a19;
  --surface: #172321;
  --fg: #f1eee4;
  --mut: #c0cbc4;
  --line: #344440;
  --line-soft: #2b3b37;
  --accent: #9cddd2;
  --accent-ink: #102320;
  --water: #58c2b8;
  --water-deep: #0a3c44;
  --water-light: #5ba69d;
  --land: #5a4d31;
  --land-deep: #483c29;
  --floodplain: #4a4433;
  --mud: #d2955a;
  --town: #ead8b5;
  --nav: #0b1312;
  --nav-ink: #f1eee4;
  --hero-shade: rgba(4, 12, 12, .76);
  --hero-caption: rgba(4, 12, 12, .84);
  --plate: #15211f;
  --plate-grid: #7d806e;
  --deep-ink: #f1eee4;
  --map-label: #f1eee4;
  --shadow: 0 28px 72px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-height) + 1rem); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.12rem/1.6 var(--serif);
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden], svg[hidden] { display: none !important; }
.progress {
  position: fixed; inset: 0 0 auto; height: 3px; z-index: 80;
  background: var(--line); pointer-events: none;
}
.progress span { display: block; width: 100%; height: 100%; background: var(--water); transform: scaleX(0); transform-origin: left; }
.skip-link {
  position: fixed; left: 1rem; top: -5rem; z-index: 100;
  padding: .6rem 1rem; background: var(--nav-ink); color: var(--nav); font: 700 .9rem var(--sans);
}
.skip-link:focus { top: .6rem; }
.site-nav {
  min-height: var(--nav-height); padding: .35rem clamp(1rem, 3vw, 3rem);
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 60; background: var(--nav); color: var(--nav-ink);
  border-bottom: 1px solid color-mix(in srgb, var(--nav-ink) 18%, transparent);
}
.brand { color: inherit; text-decoration: none; font: 700 .88rem var(--sans); letter-spacing: .02em; }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: clamp(.65rem, 1.5vw, 1.5rem); }
.nav-links a, .theme-btn { color: inherit; font: 600 .78rem var(--sans); text-decoration: none; }
.nav-links a:hover { color: var(--water-light); }
.theme-btn {
  width: 2.55rem; height: 2.55rem; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--nav-ink) 45%, transparent);
  background: transparent; cursor: pointer;
}
.banner {
  width: min(var(--content), calc(100% - 2rem)); margin: .7rem auto 0; padding: .5rem .8rem;
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  border: 1px solid var(--line); background: var(--surface); font: .86rem var(--sans);
}
.banner[hidden] { display: none !important; }
.banner button { min-height: 2.75rem; border: 0; background: none; color: var(--fg); cursor: pointer; }
main { overflow: clip; }
.hero {
  min-height: min(54rem, calc(100svh - var(--nav-height)));
  position: relative; isolation: isolate; display: flex; align-items: flex-end;
  color: #fffaf0; background: var(--deep-ink);
}
.archive-photo::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(90deg, var(--hero-shade) 0%, color-mix(in srgb, var(--hero-shade) 78%, transparent) 42%, transparent 83%),
              linear-gradient(0deg, var(--hero-shade) 0%, transparent 65%);
}
.archive-photo { position: absolute; inset: 0; z-index: -2; margin: 0; overflow: hidden; }
.archive-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 52%; filter: grayscale(1) contrast(1.08); }
.archive-photo figcaption {
  position: absolute; z-index: 1; right: clamp(1rem, 3vw, 3rem); bottom: 1.1rem; width: min(34rem, 42%);
  padding: .55rem .8rem; background: var(--hero-caption); color: #f2eee4;
  font: .69rem/1.45 var(--sans); backdrop-filter: blur(10px);
}
.archive-photo figcaption a { color: #d9eee6; }
.intro { width: min(var(--content), 100%); margin: 0 auto; padding: clamp(2rem, 6vw, 6rem) clamp(1.3rem, 7vw, 7rem) clamp(7.5rem, 12vh, 9rem); }
.kicker, .chapter-index {
  color: var(--accent); font: 500 .76rem/1.35 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.hero .kicker { color: #d0e9df; margin: 0 0 .9rem; }
h1 { max-width: 12ch; margin: 0; font: 500 clamp(3.3rem, 8.5vw, 8rem)/.9 var(--serif); letter-spacing: -.045em; text-wrap: balance; }
.deck { max-width: 39rem; margin: 1.2rem 0 0; font: 500 clamp(1rem, 1.55vw, 1.32rem)/1.48 var(--sans); color: #f4f0e6; text-wrap: pretty; }
.hero-promise { margin: .8rem 0 0; font: 600 .82rem var(--mono); letter-spacing: .03em; color: #d0e9df; }
.measurement-journey {
  width: min(var(--content), calc(100% - 3rem)); margin: 0 auto; padding: clamp(3rem, 8vw, 7rem) 0;
  display: grid; grid-template-columns: minmax(20rem, .83fr) minmax(34rem, 1.17fr); gap: clamp(2rem, 6vw, 7rem); align-items: start;
}
.instrument { position: sticky; top: calc(var(--nav-height) + 1rem); grid-column: 2; grid-row: 1; min-width: 0; max-height: calc(100svh - var(--nav-height) - 2rem); overflow: auto; scrollbar-width: thin; }
.instrument-heading { margin: 0 0 .75rem; }
.instrument-heading .kicker { margin: 0 0 .4rem; }
.instrument-heading h2 { margin: 0; font: 500 clamp(1.4rem, 2vw, 2rem)/1.12 var(--serif); letter-spacing: -.025em; }
.stage {
  position: relative; margin: 0; padding: .6rem; background: var(--plate); border: 1px solid var(--line);
  box-shadow: var(--shadow); overflow: hidden;
}
.measure-plate { display: block; width: 100%; height: auto; max-height: 49svh; }
.stage figcaption { margin: .45rem .25rem .1rem; color: var(--mut); font: .68rem/1.38 var(--sans); }
.readout { margin: .75rem 0 .15rem; max-width: 36rem; font: 500 clamp(1.1rem, 1.7vw, 1.6rem)/1.14 var(--serif); letter-spacing: -.015em; }
.extra { margin: .2rem 0 .45rem; min-height: 1.4em; color: var(--mut); font: .76rem/1.45 var(--sans); }
.instrument-link { margin: .35rem 0; font: 600 .78rem var(--sans); }
.more { color: var(--accent); }
.controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.measure, .reset {
  min-height: 2.7rem; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 2px;
  background: var(--surface); color: var(--fg); cursor: pointer; font: 700 .7rem/1.15 var(--sans); text-align: center;
}
.measure:hover, .reset:hover { border-color: var(--accent); }
.measure[aria-pressed="true"], .reset:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.reset[hidden] { display: none !important; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; }
.share-label { margin-right: .2rem; color: var(--mut); font: .7rem var(--sans); }
.icon-btn {
  display: grid; place-items: center; width: 2.3rem; height: 2.3rem; padding: 0;
  border: 1px solid var(--line-soft); border-radius: 50%; background: transparent; color: var(--fg); cursor: pointer;
}
.icon-btn svg { width: 1rem; height: 1rem; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.status { min-height: 1.1em; margin: .35rem 0 0; color: var(--mut); font: .72rem var(--sans); }
.chapter-copy { grid-column: 1; grid-row: 1; min-width: 0; }
.block { min-height: 64svh; padding: clamp(1rem, 4vh, 3.5rem) 0 clamp(3rem, 8vh, 7rem); scroll-margin-top: calc(var(--nav-height) + 1rem); border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; }
.block h2 { max-width: 13ch; margin: .3rem 0 1rem; font: 500 clamp(2.1rem, 4.3vw, 4.2rem)/.98 var(--serif); letter-spacing: -.035em; text-wrap: balance; }
.block p, .block li { max-width: 39rem; }
.block p { margin: 0 0 1rem; }
.block .chapter-index { margin: 0 0 .7rem; }
.block ul, .block ol { max-width: 44rem; padding-left: 1.2rem; }
.block li { padding-left: .3rem; margin: 0 0 .85rem; }
.arith {
  width: fit-content; padding: .3rem .65rem; border-left: 3px solid var(--mud); background: var(--surface);
  font: 500 1.15rem var(--mono); letter-spacing: .02em;
}
.article-copy { width: min(58rem, calc(100% - 3rem)); margin: 0 auto; }
.article-copy .block { min-height: auto; padding: clamp(3rem, 7vw, 6rem) 0; }
.article-copy .block h2 { max-width: 18ch; font-size: clamp(2rem, 4vw, 3.3rem); }
footer {
  margin-top: 3rem; padding: 1.5rem max(1.5rem, calc((100% - var(--content)) / 2));
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; background: var(--nav); color: #d4ded7;
  font: .75rem/1.5 var(--sans);
}
footer a { color: #d4ded7; }
.rail { display: none; }
/* The illustration separates the new town's high terrace from the buried confluence. */
.measure-plate text { fill: var(--fg); font-family: var(--sans); }
.measure-plate .context-gulf:not(.map-main) { display: none; }
.measure-plate .plate-ground, .measure-plate .map-ground { fill: var(--plate); }
.measure-plate .plate-eyebrow, .measure-plate .inset-title { fill: var(--mut); font: 500 15px var(--mono); letter-spacing: 1.2px; }
.measure-plate .diagram-label { fill: var(--fg); font: 700 23px var(--sans); }
.measure-plate .diagram-small { fill: var(--mut); font: 500 18px var(--sans); }
.measure-plate .measure-value { fill: var(--accent); font: 700 28px var(--mono); }
.measure-plate .plate-foot { fill: var(--mut); font: 500 14px var(--mono); }
.measure-plate .map-west-hill { fill: var(--land); }
.measure-plate .map-east-hill { fill: var(--land-deep); }
.measure-plate .map-floodplain { fill: var(--floodplain); }
.measure-plate .flood-dot { fill: var(--mud); opacity: .56; }
.measure-plate .map-contour { fill: none; stroke: var(--land-deep); stroke-width: 1.5; opacity: .64; }
.measure-plate .river-thread { fill: none; stroke: var(--water-deep); stroke-linecap: round; stroke-linejoin: round; stroke-width: 7; }
.measure-plate .river-braid { stroke-width: 3; opacity: .78; }
.measure-plate .old-stream-glow { fill: none; stroke: var(--water); stroke-width: 20; stroke-linecap: round; opacity: .2; }
.measure-plate .old-danube-bank { fill: none; stroke: var(--water-deep); stroke-width: 4; stroke-dasharray: 7 6; }
.measure-plate .danube-river { fill: var(--water-deep); }
.measure-plate .danube-shore { fill: none; stroke: var(--water-light); stroke-width: 3; }
.measure-plate .river-label, .measure-plate .north-arrow { fill: var(--map-label); font: 600 17px var(--mono); }
.measure-plate .map-main .diagram-small { fill: var(--map-label); }
.measure-plate .danube-label { fill: var(--nav-ink); }
.measure-plate .old-town-zone { fill: var(--town); stroke: var(--mud); stroke-width: 2; stroke-dasharray: 5 4; }
.measure-plate .old-town-hatch { fill: url(#sediment-hatch); stroke: none; opacity: .62; }
.measure-plate .settlement-point { fill: var(--mud); stroke: var(--plate); stroke-width: 3; }
.measure-plate .new-point { fill: var(--accent); }
.measure-plate .locality-point { fill: var(--land-deep); }
.measure-plate .town-callout { fill: none; stroke: var(--mud); stroke-width: 2; }
.measure-plate .north-link { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 6; opacity: .75; }
.measure-plate .lake-fill { fill: url(#gulf-water); stroke: var(--water-light); stroke-width: 3; transition: opacity .7s ease; opacity: 0; }
.measure-plate .lake-edge { fill: none; stroke: var(--water-light); stroke-width: 3; stroke-dasharray: 10 8; opacity: .8; }
.measure-plate .water-level-marker { fill: none; stroke: var(--water-light); stroke-width: 2; stroke-dasharray: 5 6; }
.measure-plate .buried-label-bg { fill: var(--water-deep); stroke: var(--water-light); stroke-width: 1; }
.measure-plate .buried-label { fill: var(--nav-ink); font: 700 19px var(--sans); }
.measure-plate .scene-tag-bg { fill: var(--nav); stroke: var(--water-light); stroke-width: 1; }
.measure-plate .scene-tag { fill: var(--nav-ink); font: 500 18px var(--mono); }
.measure-plate .measure-note-bg { fill: var(--surface); stroke: var(--water-light); stroke-width: 2; }
.measure-plate .map-note { opacity: 1; }
.stage[data-measure="gulf"] .map-gulf-note .measure-note-bg,
.stage[data-measure="mud"] .map-mud-note .measure-note-bg { stroke: var(--accent); stroke-width: 4; }
.measure-plate .era-label, .measure-plate .buried-label-bg, .measure-plate .buried-label { opacity: 0; transition: opacity .35s ease; }
.stage[data-water="before"] .era-before,
.stage[data-water="filling"] .era-filling,
.stage[data-water="full"] .era-full { opacity: 1; }
.stage[data-water="filling"] .lake-filling,
.stage[data-water="full"] .lake-full { opacity: .9; }
.stage[data-water="before"] .old-stream-glow { opacity: .3; }
.stage[data-water="filling"] .old-stream-glow,
.stage[data-water="full"] .old-stream-glow { opacity: .08; }
.stage[data-water="full"] .buried-label-bg,
.stage[data-water="full"] .buried-label { opacity: 1; }
.stage[data-water="filling"] .buried-label-bg,
.stage[data-water="filling"] .buried-label { opacity: .7; }
.stage[data-water="filling"] .old-label,
.stage[data-water="full"] .old-label { opacity: .16; }
.measure-plate .inset-frame { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.measure-plate .dam-ground, .measure-plate .pit-cut { fill: var(--land-deep); }
.measure-plate .dam-water-before { fill: var(--water-deep); opacity: .52; }
.measure-plate .dam-water-after { fill: var(--water); opacity: .7; }
.measure-plate .waterline { fill: none; stroke: var(--water-light); stroke-width: 3; }
.measure-plate .water-label-bg { fill: var(--nav); stroke: var(--water-light); stroke-width: 1.5; }
.measure-plate .water-label { fill: var(--nav-ink); font-weight: 700; }
.measure-plate .inset-water-label { fill: var(--nav-ink); paint-order: stroke; stroke: var(--water-deep); stroke-width: 2px; stroke-linejoin: round; }
.measure-plate .rise-gauge, .measure-plate .pit-gauge, .measure-plate .gulf-gauge { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.measure-plate .gauge-arrow { fill: none; stroke: var(--accent); stroke-width: 2; }
.measure-plate .pit-water { fill: var(--water-deep); }
.measure-plate .mud-gauge { fill: none; stroke: var(--mud); stroke-width: 2.5; }
.measure-plate .sediment-line { fill: none; stroke: var(--mud); stroke-width: 2; opacity: .7; }
.measure-plate .water-light { stop-color: var(--water-light); }
.measure-plate .water-deep { stop-color: var(--water-deep); }
.stage[data-measure="rise"] .context-rise .inset-frame,
.stage[data-measure="pit"] .context-pit .inset-frame { stroke: var(--accent); stroke-width: 4; }
@media (min-width: 1500px) {
  .rail {
    position: fixed; top: 50%; left: calc(50% + var(--content) / 2 + .5rem); transform: translateY(-50%);
    display: flex; flex-direction: column; z-index: 25; max-height: calc(100svh - 8rem); overflow: auto;
  }
  .rail-dot { display: flex; align-items: center; gap: .6rem; min-height: 2rem; text-decoration: none; }
  .rail-dot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 3px var(--bg); }
  .rail-label { color: var(--mut); font: 500 .64rem var(--mono); opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s ease; white-space: nowrap; }
  .rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label, .rail-dot[aria-current="true"] .rail-label { opacity: 1; transform: none; }
  .rail-dot[aria-current="true"] .dot { background: var(--accent); }
}
@media (max-width: 900px) {
  .hero { min-height: 82svh; }
  .intro { padding: 2rem 1.4rem 8.2rem; }
  h1 { max-width: 10ch; font-size: clamp(3rem, 13vw, 5.4rem); }
  .archive-photo figcaption { right: 1rem; left: 1rem; bottom: .8rem; width: auto; font-size: .64rem; }
  .measurement-journey { display: flex; flex-direction: column; gap: 1rem; width: min(100% - 1.5rem, 48rem); padding: 2.5rem 0 3.5rem; }
  .instrument { order: 0; position: sticky; top: calc(var(--nav-height) - .15rem); z-index: 35; width: calc(100% + 1.5rem); max-height: calc(50svh - var(--nav-height) + .15rem); margin: 0 -.75rem; padding: .45rem .75rem .55rem; overflow: auto; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px color-mix(in srgb, var(--bg) 75%, transparent); }
  .instrument-heading { margin: 0 0 .35rem; }
  .instrument-heading .kicker { display: none; }
  .instrument-heading h2 { font: 600 .9rem/1.2 var(--sans); }
  .stage { padding: .3rem; }
  .measure-plate { width: auto; height: 26svh; max-height: none; max-width: 100%; margin: 0 auto; }
  .stage figcaption { margin: .25rem .25rem 0; max-width: 70ch; font-size: .64rem; line-height: 1.28; }
  .readout { margin: .35rem 0 .3rem; font: 600 .82rem/1.25 var(--sans); }
  .extra, .instrument-link, .share-row, .status { display: none; }
  .controls { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; }
  .measure, .reset { min-height: 2.35rem; padding: .25rem .2rem; font-size: .58rem; }
  .chapter-copy { order: 1; }
  .block { min-height: 62svh; padding: 2.2rem .1rem 4rem; }
  .article-copy { width: min(100% - 2rem, 48rem); }
  .nav-links { gap: .65rem; }
  .nav-links a:not(.lang) { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 1rem; }
  .hero { min-height: 84svh; }
  .intro { padding: 1.5rem 1.1rem 8rem; }
  .hero .kicker { font-size: .68rem; margin-bottom: .7rem; }
  h1 { font-size: clamp(2.8rem, 14.2vw, 4rem); }
  .deck { margin-top: .85rem; font-size: .97rem; line-height: 1.43; }
  .hero-promise { font-size: .7rem; }
  .archive-photo img { object-position: 52% center; }
  .nav-links { gap: .4rem; }
  .brand { font-size: .76rem; }
  .theme-btn { width: 2.3rem; height: 2.3rem; }
  .measurement-journey { width: calc(100% - 1rem); }
  .instrument { width: calc(100% + 1rem); margin-inline: -.5rem; }
  .measure-plate { width: 100%; height: 25svh; max-height: none; max-width: 100%; margin: 0 auto; }
  .stage figcaption { display: none; }
  .measure-plate .diagram-label { font-size: 26px; }
  .measure-plate .diagram-small { font-size: 21px; }
  .measure-plate .river-label, .measure-plate .north-arrow { font-size: 21px; }
  .measure-plate .measure-value { font-size: 24px; }
  .measure-plate .buried-label { font-size: 21px; }
  .measure-plate .map-main .north-arrow, .measure-plate .map-main .stream-label,
  .measure-plate .map-main .water-label, .measure-plate .map-main .water-label-bg { display: none; }
  .stage[data-water="filling"] .measure-plate .map-main .old-label,
  .stage[data-water="full"] .measure-plate .map-main .old-label { opacity: 0; }
  .measure-plate .map-note { display: none; }
  .block h2 { font-size: clamp(2rem, 10vw, 3.2rem); }
  .article-copy .block { padding: 3rem 0; }
  footer { padding: 1.25rem 1rem; }
}
@media (pointer: coarse) {
  .theme-btn { min-width: 2.75rem; min-height: 2.75rem; }
  .measure, .reset { min-height: 2.75rem; }
}
@media print {
  .site-nav, .rail, .progress, .controls, .share-row, .banner, .theme-btn { display: none !important; }
  .hero { min-height: 55vh; }
  .instrument { position: static; max-height: none; overflow: visible; }
  .measurement-journey { display: block; }
  .block { min-height: auto; }
}
