:root {
  --paper: #f5efe0;
  --card: #efe6d2;
  --stage: #e9dfc8;
  --line: #d8cbaa;
  --ink: #1f1a12;
  --ink-soft: #4a4234;
  --brass: #755c14;
  --brick: #9e3b26;
  --river: #2e6e5e;
  --serif: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Segoe UI", sans-serif;
}
[data-theme="dark"] {
  --paper: #171310;
  --card: #211b14;
  --stage: #241d15;
  --line: #4a4136;
  --ink: #ece2cc;
  --ink-soft: #c9bda3;
  --brass: #d9b44a;
  --brick: #d4694f;
  --river: #5fa88f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.125rem; line-height: 1.65;
}
.wrap { max-width: 60rem; margin: 0 auto; padding: 0 1.25rem; }
a { color: var(--brick); }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; }
h2 { font-size: 1.75rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.25rem; margin: 0 0 0.5rem; }
.anchor { color: inherit; text-decoration: none; }
.anchor:hover { text-decoration: underline; text-decoration-color: var(--brass); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30; background: var(--paper);
  font-family: var(--sans); font-size: 0.95rem;
}
.topbar .home { color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.topbar .home:hover { color: var(--brick); }
.topnav { display: flex; gap: 0.85rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.topnav a:hover { color: var(--brick); }
.mobile-nav { display: none; position: relative; }
.mobile-nav summary { color: var(--ink); cursor: pointer; list-style: none; padding: .6rem .4rem; white-space: nowrap; }
.mobile-nav summary::-webkit-details-marker { display: none; }
.mobile-nav summary::after { content: " ▾"; }
.mobile-nav[open] summary::after { content: " ▴"; }
.mobile-nav summary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.mobile-nav nav { position: absolute; top: calc(100% + .25rem); left: 0; width: max-content; max-width: calc(100vw - 1.2rem); padding: .35rem; display: grid; background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.25); z-index: 60; }
.mobile-nav nav a { display: block; padding: .7rem .85rem; color: var(--ink); text-decoration: none; line-height: 1.25; white-space: nowrap; }
.mobile-nav nav a:hover { color: var(--brick); }
@media (max-width: 59.99rem) {
  .topnav { display: none; }
  .mobile-nav { display: block; }
  .topbar { gap: .5rem; padding: .5rem .75rem; }
  .topbar .home { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
}
[id] { scroll-margin-top: 4.5rem; }
.topbar .spacer { flex: 1; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.7rem;
  color: var(--ink); text-decoration: none; min-height: 44px;
  display: inline-flex; align-items: center;
}
.chip:hover { border-color: var(--brass); }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--brass); }
.icon-btn svg circle { fill: none; stroke: currentColor; stroke-width: 2; }
[data-theme="dark"] .icon-btn svg circle { fill: currentColor; }

/* ---------- rail ---------- */
.rail {
  display: none; position: fixed; left: 0; top: 0; bottom: 0; width: 3rem; z-index: 20;
}
@media (min-width: 80rem) {
  .rail { display: block; }
  .rail a {
    position: absolute; left: 1rem; width: 0.9rem; height: 0.9rem; border-radius: 50%;
    background: var(--line); overflow: hidden; text-indent: -99px;
  }
  .rail a.on { background: var(--brass); }
  .rail .mark {
    position: absolute; left: 0.82rem; width: 1.3rem; height: 1.3rem;
    background: var(--brick);
    clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%);
  }
}

/* ---------- hero ---------- */
.hero { padding: 2.5rem 0 1rem; }
.kicker {
  font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft); margin: 0 0 0.5rem;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.75rem; }
.deck { font-size: 1.25rem; color: var(--ink-soft); max-width: 44rem; margin: 0 0 0.75rem; }
.figure-line {
  font-family: var(--sans); font-weight: 700; letter-spacing: 0.04em;
  color: var(--brass); margin: 0 0 1.5rem;
}
figure { margin: 0 0 1.5rem; }
figure img { width: 100%; height: auto; display: block; border: 1px solid var(--line); }
figcaption {
  font-family: var(--sans); font-size: 0.92rem; color: var(--ink-soft);
  margin-top: 0.5rem; max-width: 60rem;
}
.hero-fig img { max-height: 70vh; object-fit: cover; }

/* ---------- sections ---------- */
.block { padding: 2.5rem 0; }
.block + .block { border-top: 1px solid var(--line); }
.lede { color: var(--ink-soft); font-size: 1.2rem; max-width: 44rem; }
.group-h {
  font-family: var(--sans); font-size: 1rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--brass); margin: 2.5rem 0 1rem; padding-top: 1rem; border-top: 2px solid var(--line);
}
.group-h:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* ---------- story grid + stage ---------- */
.story-grid { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; }
.stage {
  position: sticky; top: 3.4rem; height: 42vh; min-height: 20rem;
  background: var(--stage); border: 1px solid var(--line); overflow: hidden; z-index: 5;
}
.stage canvas { width: 100%; height: 100%; display: block; }
.stage .labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stage .lbl {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.1rem 0.45rem; color: var(--ink); white-space: nowrap;
}
.stage .hud {
  position: absolute; left: 0.75rem; bottom: 0.6rem;
  font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.15rem 0.6rem;
}
.stage .schem {
  position: absolute; right: 0.75rem; bottom: 0.6rem;
  font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft);
}
.stage .skip {
  position: absolute; right: 0.75rem; top: 0.6rem;
  font-family: var(--sans); font-size: 0.85rem;
}
.no-webgl .stage canvas, .no-webgl .stage .labels, .no-webgl .stage .hud { display: none; }
.stage .fallback { display: none; padding: 1rem; font-family: var(--sans); }
.no-webgl .stage .fallback { display: block; }
.steps { margin-top: 1.5rem; }
.step {
  padding: 1.25rem 1.25rem 1.25rem 1.5rem; margin: 0 0 1rem;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  scroll-margin-top: 8rem;
}
.step.on { background: var(--card); border-color: var(--line); }
.step h4 .n {
  font-family: var(--sans); color: var(--brass); font-weight: 700; margin-right: 0.4rem;
}
.step p { margin: 0.5rem 0 0; }
.step figure { margin: 1rem 0 0; }
@media (min-width: 60rem) {
  .story-grid { display: grid; grid-template-columns: minmax(24rem, 30rem) 1fr; gap: 2rem; align-items: start; }
  .stage { order: 2; top: 4rem; height: calc(100vh - 5rem); min-height: 30rem; }
  .steps { order: 1; margin-top: 0; }
}
@media (max-height: 740px) and (max-width: 60rem) {
  .stage { height: 34vh; min-height: 15rem; }
}

/* ---------- overlay (steaua) ---------- */
.ov-ui { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 1rem 0; font-family: var(--sans); }
.ov-ui label { font-weight: 700; }
.ov-ui select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.75rem;
  min-height: 44px; max-width: 100%;
}
.ov-guess { font-size: 0.9rem; color: var(--ink-soft); }
.ov-answer { font-size: 1.15rem; margin: 0.5rem 0 1rem; max-width: 50rem; }
.ov-answer b { color: var(--brick); }
.ov-fig { border: 1px solid var(--line); background: var(--stage); }
.ov-fig svg { width: 100%; height: auto; display: block; }
.ov-grid { stroke: var(--line); stroke-width: 1; }
.ov-star { fill: var(--brick); fill-opacity: 0.08; stroke: var(--brick); stroke-width: 3; stroke-linejoin: round; }
.ov-pitch { fill: none; stroke: var(--river); stroke-width: 2.5; }
.ov-dot { fill: var(--brick); }
.ov-town { font-family: var(--sans); font-weight: 700; font-size: 22px; fill: var(--ink); text-anchor: middle; }
.ov-coords { font-family: var(--sans); font-size: 14px; fill: var(--ink-soft); text-anchor: middle; }
.ov-starlab { font-family: var(--sans); font-weight: 600; font-size: 13px; fill: var(--brick); text-anchor: middle; letter-spacing: 0.08em; }
.ov-compass { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.ov-needle { stroke: var(--brick); stroke-width: 3; }
.ov-head { fill: var(--brick); }
.ov-kmlab { font-family: var(--sans); font-weight: 600; font-size: 13px; fill: var(--ink-soft); text-anchor: end; }
.ov-scale { stroke: var(--ink); stroke-width: 2; }
.ov-dim { font-family: var(--sans); font-size: 13px; fill: var(--ink-soft); text-anchor: middle; }
.ov-note { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.5rem; }
.reset {
  font: inherit; min-height: 44px; padding: 0.5rem 1rem; border-radius: 6px;
  border: 1px solid var(--brass); background: none; color: var(--ink); cursor: pointer;
}
.reset:hover { background: var(--card); }
.ov-table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.95rem; }
.ov-table th, .ov-table td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; }
.ov-table th { background: var(--card); }

/* ---------- date strip ---------- */
.strip { margin: 1rem 0 0; font-family: var(--sans); }
.strip-ui { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.play {
  font: inherit; min-height: 44px; padding: 0.5rem 1.1rem; border-radius: 6px;
  border: 1px solid var(--brass); background: none; color: var(--ink); cursor: pointer;
}
.play:hover { background: var(--card); }
.strip-count { font-size: 1rem; }
.strip-count b { color: var(--brass); font-size: 1.3rem; }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr)); gap: 2px; }
.cell {
  font: inherit; font-size: 0.72rem; min-height: 44px; padding: 0.2rem;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  cursor: pointer; border-radius: 3px; line-height: 1.2;
}
.cell small { display: block; font-size: 0.62rem; }
.cell.done { background: var(--card); color: var(--ink); }
.cell.now { background: var(--brick); border-color: var(--brick); color: #fff; }
.cell.kopeczi { outline: 2px solid var(--brass); outline-offset: -2px; }
.cell.city { box-shadow: inset 0 -4px 0 var(--river); }
.strip-legend { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.5rem; }
.strip-legend i { font-style: normal; border-bottom: 3px solid var(--river); }
.strip-legend b { font-weight: 700; color: var(--brass); }

/* ---------- ledger / visit / sources ---------- */
.ledger { list-style: none; margin: 1rem 0; padding: 0; font-size: 1.05rem; }
.ledger li { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.ledger li:last-child { border-bottom: 1px solid var(--line); }
.ledger .hold { font-weight: 700; }
.ledger .dates { color: var(--brass); font-family: var(--sans); font-size: 0.95rem; }
.ledger .src { display: block; font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); }
.visit p { max-width: 50rem; }
.src-h { font-family: var(--sans); font-size: 1rem; margin: 1.75rem 0 0.5rem; color: var(--brass); }
.srcs { margin: 0; padding-left: 1.25rem; }
.srcs li { margin: 0.5rem 0; font-size: 1rem; }
.srcs li::marker { color: var(--brass); }

/* ---------- share / footer / to-top ---------- */
.share-block { border-top: 1px solid var(--line); }
footer.site {
  border-top: 1px solid var(--line); padding: 1.5rem 1.25rem 3rem;
  font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); text-align: center;
}
.to-top {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40;
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1.3rem; cursor: pointer; display: none;
}
.to-top.show { display: block; }
.to-top:hover { border-color: var(--brass); }

/* ---------- js gating ---------- */
.cells { display: none; }
.js .cells { display: grid; }
.strip-static { font-family: var(--sans); }
.js .strip-static { display: none; }
.ov-fallback-note { display: none; }

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


/* share row (standards/v2/tools/share_row.py) */
.share-row{display:flex;flex-wrap:wrap;gap:.35rem;align-items:center}
.share-row .lab{font-size:.95rem;margin-inline-end:.3rem}
.share-row a,.share-row button{display:inline-grid;place-items:center;flex:none;width:2.5rem;height:2.5rem;padding:0;border-radius:50%;border:1px solid var(--sr-line,color-mix(in srgb,currentColor 28%,transparent));background:transparent;color:var(--sr-ink,inherit);text-decoration:none;cursor:pointer;font:inherit;transition:color .15s,border-color .15s}
.share-row a:hover,.share-row button:hover,.share-row a:focus-visible,.share-row button:focus-visible{color:var(--sr-acc,inherit);border-color:var(--sr-acc,currentColor)}
.share-row [hidden]{display:none}
@media (pointer:coarse){.share-row a,.share-row button{width:2.75rem;height:2.75rem}}
@media (max-width:30rem){.share-row .lab{flex-basis:100%;margin:0 0 .15rem}}
.share-status{font-size:.92rem;color:var(--sr-ok,inherit);min-height:1.2em;margin:.4rem 0 0}
.share-status:empty{display:none}
.share-field{display:block;width:100%;max-width:36rem;margin-top:.4rem;font:inherit;font-size:.9rem}
