:root {
  color-scheme: light;
  --paper: #f5f0e5;
  --paper-alt: #e9e0ce;
  --ink: #1d2927;
  --muted: #3f4a45;
  --line: #c9c0af;
  --accent: #842b1d;
  --gold: #6b470e;
  --other: #46514b;
  --link: #7a2c20;
  --measure: 68rem;
  --reading: 43rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161d1b;
  --paper-alt: #222b28;
  --ink: #f3eddf;
  --muted: #b7c1ba;
  --line: #4a5750;
  --accent: #ff8b72;
  --gold: #f0c05e;
  --other: #b7c1ba;
  --link: #ffc0ae;
}

* { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.65;
}
a { color: var(--link); text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .14em; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.skip-link {
  position: absolute;
  z-index: 20;
  top: .5rem;
  left: .5rem;
  padding: .6rem .9rem;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 4.5rem;
  padding: calc(.5rem + var(--browser-safe-top, env(safe-area-inset-top))) clamp(1rem, 3vw, 2.8rem) .5rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: var(--ink);
  font-size: .94rem;
  font-weight: 680;
  letter-spacing: .01em;
  text-decoration: none;
}
.brand-mark {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: .66rem;
  letter-spacing: -.08em;
}
.topnav {
  display: flex;
  align-items: center;
  gap: clamp(.8rem, 1.8vw, 1.5rem);
  min-width: 0;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: .35rem 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 580;
  text-decoration: none;
}
.topnav a[aria-current="location"] { border-color: var(--accent); color: var(--ink); }
.edition-tools, .language-switch { display: flex; align-items: center; gap: .55rem; }
.language-switch { padding: .18rem; border: 1px solid var(--line); border-radius: 99px; }
.language-switch a {
  min-width: 2.55rem;
  padding: .28rem .55rem;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 720;
  text-align: center;
  text-decoration: none;
  border-radius: 99px;
}
.language-switch a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.theme-toggle {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle svg { width: 1.12rem; height: 1.12rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
main { width: min(100% - 2rem, var(--measure)); margin: 0 auto; }
article { padding-bottom: 4rem; }
.story-head {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) 0 3.2rem;
  border-bottom: 1px solid var(--line);
}
.kicker, .section-number, .chart-kicker, .dateline, .boundary-label {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .09em;
  line-height: 1.45;
  text-transform: uppercase;
}
.kicker { margin: 0 0 1.05rem; }
.kicker span { padding: 0 .45rem; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 {
  max-width: 15ch;
  margin: 0 0 1.2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.55rem, 5.9vw, 5.5rem);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: .99;
}
.standfirst {
  max-width: 51rem;
  margin: 0 0 1.2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
  line-height: 1.42;
}
.dateline { margin: 0; font-size: .68rem; letter-spacing: .06em; }
.story-section {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(24rem, 1.15fr);
  column-gap: clamp(2rem, 5vw, 5.5rem);
  row-gap: 1.5rem;
  padding: clamp(3.2rem, 7vw, 6rem) 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 5.25rem;
}
.first-section { padding-top: clamp(3rem, 5vw, 4.8rem); }
.section-intro { max-width: var(--reading); }
.section-number { margin: 0 0 .8rem; font-size: .7rem; }
.section-number span { color: var(--accent); }
h2 {
  margin-bottom: 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.1;
}
.section-intro p:last-child { margin-bottom: 0; }
.chart-figure {
  align-self: start;
  margin: 0;
  padding: clamp(1rem, 2.5vw, 1.8rem);
  background: var(--paper-alt);
  border-top: 3px solid var(--ink);
}
.chart-heading { margin: 0 0 .9rem; }
.chart-kicker { margin: 0 0 .45rem; color: var(--accent); font-size: .67rem; }
.chart-heading h3 { margin: 0 0 .4rem; font-family: Georgia, serif; font-size: clamp(1.25rem, 2vw, 1.7rem); font-weight: 500; line-height: 1.15; }
.chart-heading p { max-width: 38rem; margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-svg.chart-mobile { display: none; }
.chart-svg text { fill: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.chart-svg .chart-row-label { font-size: 13px; font-weight: 750; letter-spacing: .06em; }
.chart-svg .chart-count, .chart-svg .axis-label { fill: var(--muted); font-size: 12px; }
.chart-svg .chart-rate { fill: var(--accent); font-size: 19px; font-weight: 750; }
.chart-svg .axis-line { stroke: var(--line); stroke-width: 1; }
.chart-svg .bar-rural { fill: var(--accent); }
.chart-svg .bar-urban { fill: var(--gold); }
.chart-svg .bar-other { fill: var(--other); }
.chart-svg .bar-focus { fill: var(--accent); }
.chart-svg .bar-neighbor { fill: var(--gold); }
.chart-svg .bar-rest { fill: var(--other); }
.chart-svg .inside-label { fill: #fffaf0; font-size: 13px; font-weight: 700; }
:root[data-theme="dark"] .chart-svg .inside-label { fill: #171d1a; }
.chart-svg .stack-total { fill: var(--muted); font-size: 12px; font-weight: 700; }
figcaption, .chart-source { color: var(--muted); font-size: .8rem; line-height: 1.45; }
figcaption { margin-top: .75rem; }
.chart-source { margin-top: .7rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.reading-note {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 55rem);
  gap: .9rem;
  align-items: start;
  margin-top: .3rem;
  padding: 1.3rem 0 0;
  border-top: 1px solid var(--line);
}
.reading-note p { margin: 0; max-width: 58rem; font-family: Georgia, serif; font-size: 1.2rem; line-height: 1.5; }
.note-mark { color: var(--accent); font-family: Georgia, serif; font-size: 2.2rem; line-height: 1; }
.iasi-section .section-intro, .family-section .section-intro { grid-column: 1; }
.iasi-figure { grid-column: 2; grid-row: 1 / span 2; }
.chart-legend { display: grid; gap: .6rem; margin-top: .6rem; }
.chart-legend > div { display: grid; grid-template-columns: .8rem 1fr; gap: .6rem; align-items: start; font-size: .88rem; line-height: 1.35; }
.legend-dot { width: .72rem; height: .72rem; display: inline-block; margin-top: .2rem; border-radius: 50%; }
.dot-miroslava { background: var(--accent); }
.dot-ciurea { background: var(--gold); }
.dot-other { background: var(--other); }
.chart-legend b { font-weight: 720; }
.chart-legend small { display: block; color: var(--muted); font-size: .79rem; }
.analysis-paragraph { grid-column: 1; margin: 0; }
.family-section { grid-template-columns: minmax(0, .9fr) minmax(20rem, 1.1fr); align-items: start; }
.family-section > p { grid-column: 1; }
.boundary-line {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  grid-template-columns: 8rem 1fr;
  align-items: baseline;
  gap: .8rem 1rem;
  padding: 1.2rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.boundary-label { font-size: .66rem; color: var(--accent); }
.boundary-line p { margin: 0; }
.method-section {
  max-width: 58rem;
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5.5rem) 0;
  scroll-margin-top: 5.25rem;
}
.method-section > p, .method-section > h2 { max-width: var(--reading); }
.method-section h2 { margin-bottom: 1.3rem; }
.sources-list { padding-left: 1.2rem; }
.sources-list li { padding-left: .35rem; margin-bottom: .75rem; }
.attribution { color: var(--muted); font-size: .84rem; }
.related-story {
  max-width: 58rem;
  margin: 0 auto;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.related-story .section-number { margin-bottom: .4rem; }
.related-story p:last-child { margin-bottom: 0; }
.share-row { max-width: 58rem; margin: 2rem auto 0; }
.share-row .share-label { color: var(--muted); font-family: ui-monospace, monospace; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
.share-row .share-btn { border-color: var(--line); color: var(--ink); }
.share-row [role="status"] { color: var(--muted); }
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 3vw, 2.8rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}
.site-footer a { color: var(--ink); }

@media (max-width: 760px) {
  body { font-size: 1rem; }
  .masthead { min-height: 3.9rem; gap: .65rem; }
  .brand > span:not(.brand-mark) { display: none; }
  .brand-mark { width: 1.8rem; height: 1.8rem; }
  .topnav { flex: 1; gap: .9rem; }
  .topnav a { font-size: .73rem; }
  .edition-tools, .language-switch { gap: .35rem; }
  .language-switch a { min-width: 2.2rem; padding-inline: .35rem; }
  .theme-toggle { width: 2.35rem; height: 2.35rem; }
  .story-head { padding-top: 3.3rem; }
  h1 { max-width: 17ch; font-size: clamp(2.35rem, 12vw, 3.6rem); }
  .story-section, .family-section { grid-template-columns: 1fr; row-gap: 1.4rem; }
  .chart-figure, .iasi-figure, .reading-note, .analysis-paragraph, .boundary-line, .family-section > p { grid-column: 1; grid-row: auto; }
  .reading-note { grid-template-columns: 1.7rem 1fr; }
  .note-mark { font-size: 1.8rem; }
  .boundary-line { grid-template-columns: 6.6rem 1fr; }
  .chart-figure { padding: 1rem .75rem; }
  .chart-svg.chart-desktop { display: none; }
  .chart-svg.chart-mobile { display: block; }
  .chart-svg .chart-row-label { font-size: 12px; }
  .chart-svg .chart-count, .chart-svg .axis-label { font-size: 11px; }
  .chart-svg .chart-rate { font-size: 16px; }
  .chart-svg .inside-label { font-size: 11px; }
  .site-footer { flex-wrap: wrap; }
  .site-footer span { order: 3; width: 100%; }
}

@media (max-width: 420px) {
  main { width: min(100% - 1.25rem, var(--measure)); }
  .masthead { padding-inline: .7rem; }
  .brand { gap: .45rem; font-size: .83rem; }
  .topnav { gap: .72rem; }
  .topnav a { font-size: .68rem; }
  .story-head { padding-bottom: 2.4rem; }
  .chart-svg .chart-count { font-size: 10px; }
  .chart-svg .chart-rate { font-size: 15px; }
  .chart-svg .inside-label { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .chart-figure, .reading-note, .boundary-line { border: 1px solid CanvasText; }
  .chart-svg rect { stroke: CanvasText; stroke-width: 1; }
}
