/* GeoHistory: a modern historical atlas. White bars and panels, black text in Source Sans 3 (self-hosted, SIL
   Open Font License; the same family as the map labels), blue buttons and links. The "modern finish" at the end wins. */
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/web/source-sans-3-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/web/source-sans-3-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/web/source-sans-3-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/web/source-sans-3-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/web/source-sans-3-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/web/source-sans-3-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  --paper: #f3eee3;
  --paper-2: #e9e2d2;
  --card: #fbf9f3;
  --ink: #231f19;
  --ink-2: #4b4337;
  --ink-3: #6a604f;
  --line: #d9cfbb;
  --line-2: #c4b79f;
  --accent: #7d2a1c;
  --accent-2: #9c3e2b;
  --accent-ink: #fffdf8;
  --focus: #1f5fa6;
  --ok: #3c7a4b;
  --shadow: 0 10px 30px rgba(52, 40, 22, .13), 0 1px 2px rgba(52, 40, 22, .10);
  --serif: "Alegreya", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --top-h: 58px;
  --time-h: 124px;
  --panel-w: 392px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #181613; --paper-2: #221f1a; --card: #1f1c18; --ink: #efe8da; --ink-2: #cdc3b1; --ink-3: #9d927f;
    --line: #37322a; --line-2: #4a4337; --accent: #e59a7a; --accent-2: #f0ac8f; --accent-ink: #1b1916; --focus: #8cc0ff; --ok: #7fbf8e;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #181613; --paper-2: #221f1a; --card: #1f1c18; --ink: #efe8da; --ink-2: #cdc3b1; --ink-3: #9d927f;
  --line: #37322a; --line-2: #4a4337; --accent: #e59a7a; --accent-2: #f0ac8f; --accent-ink: #1b1916; --focus: #8cc0ff; --ok: #7fbf8e;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans);
  overflow: hidden; -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--card); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.skip:focus { top: 8px; }
.muted { color: var(--ink-3); }
.noscript { position: fixed; inset: 40% 16px auto; text-align: center; }

/* ---------- top bar ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--paper) 94%, transparent); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font: 500 23px/1 var(--serif); letter-spacing: .005em; white-space: nowrap; }
.search { position: relative; flex: 1; max-width: 460px; min-width: 0; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2374695a' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 12px 50% no-repeat;
}
.results {
  position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; max-height: min(60vh, 440px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 30;
}
.search input:hover { border-color: var(--line-2); }
.results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.results li[aria-selected="true"], .results li:hover { background: var(--paper-2); }
.results .r-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.results .r-meta { color: var(--ink-3); font-size: 13px; margin-left: auto; white-space: nowrap; }
.results .r-empty { color: var(--ink-3); cursor: default; }
.tools { display: flex; gap: 6px; margin-left: auto; }
.chip {
  height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); white-space: nowrap;
  font-size: 14px; color: var(--ink-2); transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#projBtn[aria-pressed="true"] { background: var(--card); color: var(--ink); border-color: var(--line); }

/* ---------- map ---------- */
.stage { position: fixed; inset: var(--top-h) 0 var(--time-h) 0; }
.map { position: absolute; inset: 0; background: var(--paper-2); }
/* a faint vignette, like the edge of an atlas plate */
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4; box-shadow: inset 0 0 90px rgba(70, 52, 24, .13); }
@media (min-width: 900px) { .map .maplibregl-ctrl-top-right { right: calc(var(--panel-w) + 16px); top: 4px; } }
.map-status {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 5;
  background: var(--card); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
}
.map-status:empty { display: none; }
.map-status.error { border-left: 4px solid var(--accent); }
.badges { position: absolute; left: 12px; top: 12px; z-index: 6; max-width: min(360px, calc(100% - 24px)); }
.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(4px); box-shadow: 0 1px 2px rgba(52, 40, 22, .12);
  font: 500 15px/1.3 var(--serif); letter-spacing: .01em; color: var(--ink-2);
}
.badge:hover { border-color: var(--line-2); color: var(--ink); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.badge.exact::before { background: var(--ok); }
.badge-info { margin-top: 8px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.badge-info p { margin: 0 0 8px; } .badge-info p:last-child { margin: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-ctrl-group { background: var(--card); border-radius: 8px !important; box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgba(52, 40, 22, .15) !important; overflow: hidden; }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--card) 85%, transparent) !important; color: var(--ink-3); }
.maplibregl-ctrl-attrib a { color: var(--ink-2); }
.maplibregl-ctrl-attrib-inner { color: var(--ink-3); }
.maplibregl-ctrl-attrib-button { filter: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .maplibregl-ctrl-attrib-button { filter: invert(1); } }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); } }

/* ---------- panel ---------- */
.panel {
  position: fixed; z-index: 15; top: calc(var(--top-h) + 12px); right: 12px; bottom: calc(var(--time-h) + 12px); width: var(--panel-w);
  background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
/* the double rule of an atlas plate */
.panel::before { content: ""; position: absolute; inset: 4px; border: 1px solid var(--line); border-radius: 7px; pointer-events: none; z-index: 1; }
.sheet-bar { display: none; }
.panel-body { overflow: auto; padding: 20px 22px 26px; flex: 1; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.panel h1, .panel h2, .panel h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
.panel h1 { font-size: 31px; line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
.panel h2 { font-size: 12px; margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .11em; color: var(--ink-2); display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-weight: 600; }
.panel h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.panel h3 { font-size: 17px; margin: 16px 0 6px; }
.kicker { font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); margin: 0 0 5px; font-weight: 600; }
.back { border: 0; background: none; padding: 4px 0; color: var(--ink-3); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.back:hover { color: var(--accent); }
.lead { color: var(--ink-2); margin: 8px 0 0; line-height: 1.5; }
p.lead.century { font: 400 17.5px/1.5 var(--serif); color: var(--ink); text-wrap: pretty; }
.yearhead .yh-date { font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.yearhead .yh-d { display: block; color: var(--ink-2); font-size: 15.5px; }
.yearhead .link.yh-top { font: inherit; font-weight: 600; }
p.yearhead.none { font-style: italic; }
h2.context { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-top: 18px; }
.about { margin: 10px 0 4px; line-height: 1.5; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; }
.facts dt { color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
.facts dd { margin: 0; }
.note { font-size: 13px; line-height: 1.5; color: var(--ink-3); margin: 8px 0 0; }
.ext { font-weight: 600; }
.ext::after { content: " ↗"; }

.events { list-style: none; margin: 0; padding: 0; }
.events li + li { border-top: 1px solid var(--line); }
.ev { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 9px 4px; width: 100%; text-align: left; border: 0; background: none; border-radius: 8px; }
.ev:hover { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }
.ev .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px color-mix(in srgb, var(--ink) 22%, transparent); }
.ev .t { font: 500 16.5px/1.3 var(--serif); display: block; color: var(--ink); }
.ev .m { display: block; color: var(--ink-3); font-size: 13px; }
.ev .d { display: block; color: var(--ink-2); font-size: 13px; }
.ev.today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.more { margin-top: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 5px 12px; font-size: 13px; color: var(--ink-2); }
.more:hover { border-color: var(--line-2); color: var(--ink); }
.year-group { margin: 16px 0 4px; font: 500 18px var(--serif); color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.year-group button { border: 0; background: none; color: var(--accent); font-size: 13px; }
.year-group.current { color: var(--accent); }

.filter-box { margin: 0 0 6px; }
.filter-box summary { cursor: pointer; color: var(--ink-2); font-size: 14px; padding: 2px 0; width: max-content; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.filters button { font-size: 13px; height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; gap: 6px; }
.filters button .dot { width: 8px; height: 8px; border-radius: 50%; }
.filters button[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }

.legend { list-style: none; margin: 0; padding: 0; }
.legend li button { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 6px 4px; border: 0; background: none; text-align: left; border-radius: 8px; }
.legend li button:hover { background: var(--paper-2); }
.sw { width: 18px; height: 13px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(40, 28, 10, .28); }
.legend .a { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.changes { font-size: 14px; color: var(--ink-2); }
.changes b { color: var(--ink); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; padding: 0; list-style: none; }
.pill-list button { border: 1px solid var(--line); background: var(--paper); border-radius: 7px; padding: 2px 9px; font-size: 13px; color: var(--ink-2); }
.pill-list button:hover { border-color: var(--line-2); color: var(--ink); }
.empty { color: var(--ink-3); font-size: 14px; padding: 8px 0; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--paper-2), var(--paper), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- time bar ---------- */
.timebar {
  position: fixed; inset: auto 0 0 0; height: var(--time-h); z-index: 20; padding: 10px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line-2); box-shadow: 0 -1px 0 var(--card) inset;
}
.timebar-row { display: flex; align-items: center; gap: 12px; }
.year-form { display: flex; gap: 6px; }
.year-input {
  width: 168px; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--card);
  font: 500 24px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; letter-spacing: .01em; color: var(--ink);
}
.year-input[aria-invalid="true"] { border-color: var(--accent); }
.go { height: 40px; padding: 0 16px; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; letter-spacing: .02em; transition: background .15s; }
.go:hover { background: var(--accent-2); }
.transport { display: flex; align-items: center; gap: 6px; }
.tbtn { height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.tbtn:hover { border-color: var(--ink-3); color: var(--ink); }
.tbtn svg path, .play svg path, .key-toggle svg path { fill: currentColor; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(80, 30, 15, .25); }
.play:hover { background: var(--accent-2); }
.play .ico-pause { display: none; }
.play[aria-pressed="true"] .ico-play { display: none; }
.play[aria-pressed="true"] .ico-pause { display: inline; }
.speed { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; font-size: 13px; color: var(--ink-3); }
.speed select { height: 40px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: 500 14px var(--sans); padding: 0 8px; }
.year-hint { margin: 0; font-size: 13px; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.year-hint.err { color: var(--accent); }
/* the timeline: era bands on top, the track, then ticks with year labels */
.timeline { position: relative; margin-top: 10px; height: 50px; }
.eras { position: absolute; left: 8px; right: 8px; top: 0; height: 13px; pointer-events: none; }
.eras > span { position: absolute; top: 0; height: 13px; overflow: hidden; white-space: nowrap; text-align: center; font: 600 9.5px/13px var(--sans); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); border-radius: 3px; }
.eras > span:nth-child(odd) { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.eras > span:nth-child(even) { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.slider { position: absolute; left: 0; right: 0; top: 10px; width: 100%; margin: 0; height: 26px; background: transparent; -webkit-appearance: none; appearance: none; touch-action: none; }
.slider::-webkit-slider-runnable-track { height: 3px; background: var(--line-2); border-radius: 2px; }
.slider::-moz-range-track { height: 3px; background: var(--line-2); border-radius: 2px; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 24px; margin-top: -10.5px; border-radius: 4px; background: var(--accent); border: 2px solid var(--card); box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: grab; }
.slider::-moz-range-thumb { width: 12px; height: 20px; border-radius: 4px; background: var(--accent); border: 2px solid var(--card); box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: grab; }
.slider:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.1); }
.ticks { position: absolute; left: 8px; right: 8px; top: 27px; height: 22px; pointer-events: none; }
.ticks i { position: absolute; top: 0; width: 1px; height: 4px; background: var(--ink-3); opacity: .45; }
.ticks i.mj { height: 7px; opacity: .8; }
.ticks i b { position: absolute; top: 8px; left: 0; transform: translateX(-50%); font: 500 10.5px/1 var(--sans); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.thumb-year { position: absolute; top: -18px; transform: translateX(-50%); padding: 2px 7px; border-radius: 5px; background: var(--ink); color: var(--paper); font: 600 12px/1.3 var(--sans); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; }
.thumb-year.on { opacity: 1; }

/* ---------- dialogs ---------- */
.sheet { border: 1px solid var(--line-2); padding: 0; border-radius: 10px; max-width: 640px; width: calc(100% - 32px); max-height: calc(100% - 48px); background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(20, 15, 10, .45); }
.sheet-inner { padding: 18px 22px 24px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font: 500 26px var(--serif); margin: 0; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 20px; line-height: 1; }
.prose h3 { font: 500 19px var(--serif); margin: 20px 0 6px; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; }

/* ---------- phones ---------- */
@media (max-width: 899px) {
  /* phones: a compact time bar (one row of controls over the timeline) and the panel as a bottom sheet */
  :root { --top-h: 56px; --time-h: 96px; --safe-b: env(safe-area-inset-bottom, 0px); }
  html, body { overscroll-behavior: none; }
  .top { padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .tools .chip { padding: 0 10px; font-size: 13px; }
  #modernBtn { display: none; }
  .stage { bottom: calc(var(--time-h) + var(--safe-b)); }
  .panel {
    left: 0; right: 0; width: auto; top: auto; bottom: calc(var(--time-h) + var(--safe-b)); border-radius: 14px 14px 0 0; border-bottom: 0;
    height: 50px; transition: height .28s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -6px 24px rgba(52, 40, 22, .16);
  }
  .panel[data-size="half"] { height: min(46vh, calc(100% - var(--time-h) - var(--safe-b) - var(--top-h) - 8px)); }
  .panel[data-size="full"] { height: calc(100% - var(--time-h) - var(--safe-b) - var(--top-h) - 8px); }
  .panel.dragging { transition: none; }
  .sheet-bar { display: flex; align-items: stretch; flex: none; height: 50px; touch-action: none; user-select: none; -webkit-user-select: none; border-bottom: 1px solid transparent; }
  .panel:not([data-size="collapsed"]) .sheet-bar { height: 34px; }
  .panel:not([data-size="collapsed"]) .sheet-title { visibility: hidden; }   /* the panel's own heading shows below */
  .sheet-handle { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; padding: 10px 0 0 16px; border: 0; background: none; color: var(--ink); text-align: left; cursor: grab; touch-action: none; }
  .sheet-handle .grip { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: 2px; border-radius: 2px; background: var(--line-2); }
  .sheet-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 500 17px/1.2 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
  .sheet-chev { flex: none; width: 50px; display: flex; align-items: center; justify-content: center; padding-top: 6px; border: 0; background: none; color: var(--ink-2); touch-action: none; }
  .sheet-chev svg { fill: currentColor; transition: transform .2s; }
  .sheet-chev[data-dir="down"] svg { transform: rotate(180deg); }
  .panel[data-size="collapsed"] .panel-body { visibility: hidden; }
  .panel-body { padding-top: 6px; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .panel h1 { font-size: 24px; }
  .panel::before { display: none; }
  .panel-body { padding-left: 16px; padding-right: 16px; }
  .stage::after { box-shadow: none; }
  .timebar { height: calc(var(--time-h) + var(--safe-b)); padding: 7px 12px calc(4px + var(--safe-b)); }
  .timebar-row { flex-wrap: nowrap; gap: 8px; }
  .year-form { flex: 0 1 auto; gap: 4px; min-width: 0; }
  .year-input { width: 84px; min-width: 0; font-size: 18px; height: 36px; padding: 0 8px; }
  .go { height: 36px; padding: 0 9px; }
  .year-hint { display: none; }
  .year-hint.err { display: block; position: absolute; left: 12px; right: 12px; bottom: calc(100% + 4px); padding: 4px 8px; background: var(--card); border: 1px solid var(--line-2); border-radius: 4px; white-space: normal; }
  .transport { flex: 1 1 auto; justify-content: space-between; gap: 6px; min-width: 0; }
  .tbtn { height: 36px; padding: 0 10px; }
  .tbtn .tl { display: none; }
  .speed { margin-left: auto; min-width: 0; }
  .speed-lbl { display: none; }
  .speed select { max-width: 96px; padding: 0 4px; font-size: 16px; }   /* 16px: iOS does not zoom in on it */
  .timeline { margin-top: 6px; }
  .slider { height: 34px; top: 6px; }
  .slider::-webkit-slider-thumb { width: 22px; height: 30px; margin-top: -13.5px; }
}
@media (max-width: 599px) {
  /* small phones: no era names over the timeline, the track right under the controls */
  .eras { display: none; }
  .timeline { height: 40px; margin-top: 4px; }
  .slider { top: -2px; }
  .ticks { top: 17px; }
}
@media (max-width: 400px) {
  .tools .chip { padding: 0 8px; }
}

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

.unver { font: 600 10px/1.5 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; white-space: nowrap; vertical-align: 1px; }
.ruled-hist { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.ruled-hist summary { cursor: pointer; color: var(--ink-3); }
.ruled-hist ol { margin: 6px 0 0; padding-left: 18px; }
.strip { margin: 16px 0 0; padding: 10px 12px 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 4px 8px 8px 4px; background: color-mix(in srgb, var(--paper) 70%, transparent); }
.strip h2 { margin: 0 0 6px !important; }
.changes-list { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--ink-2); }
.changes-list li { padding: 3px 0; }
.ch-date { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; }
.link:hover { text-decoration-color: var(--accent); }
.link.people { font-style: italic; font-weight: 500; }
.parts { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.parts li { padding: 4px 0; border-top: 1px solid var(--line); }
.parts li:first-child { border-top: 0; }
.today { font-size: 14px; color: var(--ink-2); }
.today:empty { display: none; }
.occ { border-left: 3px solid var(--accent); padding-left: 10px; }

/* legend swatch of the occupation hatching: lines in the occupier's colour */
.hatchsw { display: inline-block; width: 1.5em; height: .85em; vertical-align: -1px; margin-right: .35em; border: 1px solid var(--hc); border-radius: 2px; background: repeating-linear-gradient(135deg, var(--hc) 0 2px, transparent 2px 5px); }

/* a jump between years is running: the panel still shows the year it started from */
#panelBody { transition: opacity 0.25s; }
.travelling #panelBody { opacity: 0.5; }


/* ---------- map key ---------- */
.key { position: absolute; left: 12px; bottom: 34px; z-index: 6; width: 248px; max-width: calc(100% - 24px); background: color-mix(in srgb, var(--card) 96%, transparent); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
.key-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: 0; background: none; font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--ink); }
.key-toggle .chev { margin-left: auto; transition: transform .15s; }
.key-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.key-body { padding: 0 12px 10px; max-height: min(50vh, 470px); overflow: auto; scrollbar-width: thin; }
.key-body h3 { display: flex; align-items: center; gap: 8px; margin: 10px 0 5px; font: 600 10.5px/1 var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.key-body h3:first-child { margin-top: 2px; }
.key-body ul { list-style: none; margin: 0; padding: 0; }
.key-body li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; padding: 2px 0; }
.key-body ul.koff { opacity: .45; }
.ki { display: flex; justify-content: center; }
.ksw { display: inline-block; width: 26px; height: 16px; border: 2px solid; border-radius: 2px; }
.ktrio { display: inline-flex; }
.kflag { display: inline-flex; width: 22px; height: 15px; border: 1px solid rgba(40, 34, 26, 0.8); border-radius: 1px; overflow: hidden; }
.kflag i { flex: 1; }
.kflag i:nth-child(1) { background: #fff; }
.kflag i:nth-child(2) { background: #2f5aa8; }
.kflag i:nth-child(3) { background: #c8312c; }
.kflag { flex-direction: column; }
/* the flag in a territory panel */
.flagbox { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 6px; }
.flagbig { width: auto; max-width: 132px; max-height: 88px; border: 1px solid var(--line, rgba(0, 0, 0, 0.25)); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); flex: none; }
.flagbig.emblem { border: none; box-shadow: none; max-height: 96px; }
.flagtext { min-width: 0; }
.flagtext p { margin: 0 0 4px; }
.flagname { font-weight: 600; }
.flagwarn { color: var(--warn, #8a5a00); }
.noflag { margin: 8px 0; }
.ktrio .ksw { width: 11px; border-width: 2px 1px; margin-left: -1px; }
.kemp { background: linear-gradient(90deg, var(--p1) 0 50%, var(--p2) 50%); position: relative; }
.kunder { display: inline-flex; align-items: center; justify-content: center; border: 1px dashed var(--line-2) !important; font: italic 11px/1 var(--serif); color: var(--ink-3); }
.khatch { border-color: var(--hc); background: repeating-linear-gradient(135deg, var(--hc) 0 2px, transparent 2px 5px); }
.kflash { width: 26px; height: 16px; border-radius: 2px; background: color-mix(in srgb, #fff 55%, var(--line-2)); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--ink-3); }
.kbattle, .kwarmk { display: inline-block; width: 15px; height: 15px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.4' fill='%23e0261b'/%3E%3Cg transform='rotate%2845 12 12%29' fill='%23141414'%3E%3Cpath d='M12 .6l1.7 2.6V15.1h-3.4V3.2z'/%3E%3Crect x='7.4' y='14.9' width='9.2' height='2.4' rx='1.2'/%3E%3Crect x='10.9' y='17' width='2.2' height='4.2'/%3E%3Ccircle cx='12' cy='22.3' r='1.45'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; }
.kwarmk { width: 18px; height: 18px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.4' fill='%23d9261c' stroke='%237a0f0a' stroke-width='1.4'/%3E%3Cg transform='rotate%2845 12 12%29' fill='%23141414'%3E%3Cpath d='M12 .6l1.7 2.6V15.1h-3.4V3.2z'/%3E%3Crect x='7.4' y='14.9' width='9.2' height='2.4' rx='1.2'/%3E%3Crect x='10.9' y='17' width='2.2' height='4.2'/%3E%3Ccircle cx='12' cy='22.3' r='1.45'/%3E%3C/g%3E%3C/svg%3E"); }
.kedge { width: 26px; height: 0; border-top: 3px dashed #d9261c; }
.kswitch { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.kswitch input { accent-color: var(--accent); margin: 0; }
.kwars { margin: 6px 0 0; }
.kwars .link { font-weight: 600; font-size: 12.5px; }
.kdots { display: grid !important; grid-template-columns: 1fr 1fr; gap: 1px 8px; }
.kdots li { display: flex !important; gap: 6px; align-items: center; }
.kdot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--card); box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.kcluster { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 10px; font-weight: 600; vertical-align: middle; }
.key-body p.kt { margin: 5px 0 0; }
@media (max-width: 899px) {
  .key { bottom: auto; top: 50px; left: 10px; width: auto; max-width: calc(100% - 64px); }
  .key-toggle { padding: 7px 10px; }
  .key-body { width: min(300px, calc(100vw - 84px)); max-height: 46vh; }
}

/* ---------- war markers: a red disc with one sword through it (wars filled, battles a red ring) ---------- */
.warwrap { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.warmk { position: relative; padding: 0; border: 0; background: none; cursor: pointer; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; animation: settle .4s ease-out both; }
.warmk svg { display: block; width: 18px; height: 18px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.warmk.battle { width: 15px; height: 15px; }
.warmk.battle svg { width: 15px; height: 15px; }
.warmk:hover { z-index: 3; transform: scale(1.15); }
.warmk:focus-visible { outline-offset: 1px; }
.map.zlow .warwrap.minor, .map.war-off .warwrap { display: none; }
@keyframes settle { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ---------- state context and event write-ups ---------- */
.ctx-wrap { margin-top: 18px; }
.ctx { border-top: 1px solid var(--line); }
.ctx:last-child { border-bottom: 1px solid var(--line); }
.ctx > summary {
  list-style: none; cursor: pointer; padding: 11px 0; display: flex; align-items: baseline; gap: 8px;
  font: 600 12px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .11em; color: var(--ink-2);
}
.ctx > summary::-webkit-details-marker { display: none; }
.ctx > summary::after { content: "+"; margin-left: auto; font: 400 16px/1 var(--sans); color: var(--ink-3); }
.ctx[open] > summary::after { content: "–"; }
.ctx > summary:focus-visible { outline-offset: 0; }
.ctx > summary .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ctx-body { padding: 0 0 12px; font-size: 14px; line-height: 1.5; }
.ctx-body p { margin: 0 0 6px; }
.ctx-glance .ctx-body > p:first-child { font: 400 16.5px/1.5 var(--serif); color: var(--ink); text-wrap: pretty; }
.ctx-big { font: 500 19px/1.35 var(--serif); color: var(--ink); }
.ctx-list, .ctx-src { margin: 4px 0 6px; padding-left: 18px; }
.ctx-list li, .ctx-src li { margin: 0 0 4px; }
.ctx-src { font-size: 13px; color: var(--ink-3); }
.wu { margin-top: 18px; }
.wu p { line-height: 1.55; margin: 0 0 10px; }
.wu h3 { font: 600 12px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .11em; color: var(--ink-2); margin: 14px 0 6px; }
.wu-src { font-size: 13px; padding-left: 20px; margin: 0; }
.wu-src li { margin-bottom: 4px; }
.kdot.kinv { box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--ring) 45%, transparent); }
/* ======================================================================================================
   Scholarly atlas finish (round 11): a quiet frame around the flag-filled map. Paper and charcoal, one muted
   ink-blue accent, Alegreya for headings, thin rules instead of boxes and shadows, small capitals for labels,
   tabular figures for years, no bouncy motion. Dark mode is an evening reading mode, not neon.
   ====================================================================================================== */
:root {
  --paper: #f6f4ee; --paper-2: #ece8de; --card: #fbfaf6; --ink: #1f1d1a; --ink-2: #423e37; --ink-3: #67625a;
  --line: #dedad0; --line-2: #c9c4b8; --accent: #2f4d6e; --accent-2: #3d5f84; --accent-ink: #fbfaf6;
  --focus: #2f6db5; --ok: #4d6b52; --warn: #7a5a1c;
  --shadow: 0 1px 2px rgba(30, 26, 20, .08);
  --radius: 3px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1a18; --paper-2: #23211e; --card: #201f1c; --ink: #e4dfd4; --ink-2: #c3bdb0; --ink-3: #969083;
    --line: #34312c; --line-2: #45413a; --accent: #a9bdd3; --accent-2: #bccbdd; --accent-ink: #1b1a18; --focus: #9cc0ea; --ok: #8fae93;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --paper: #1b1a18; --paper-2: #23211e; --card: #201f1c; --ink: #e4dfd4; --ink-2: #c3bdb0; --ink-3: #969083;
  --line: #34312c; --line-2: #45413a; --accent: #a9bdd3; --accent-2: #bccbdd; --accent-ink: #1b1a18; --focus: #9cc0ea; --ok: #8fae93;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
body { font-size: 15px; font-variant-numeric: lining-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }
.stage::after { display: none; }

/* top bar: a hairline under a paper strip */
.top { background: var(--paper); backdrop-filter: none; border-bottom-color: var(--line-2); }
.brand { font: 500 21px/1 var(--serif); letter-spacing: .01em; }
.search input { height: 34px; border-radius: var(--radius); background-color: var(--card); }
.results { border-radius: var(--radius); }
.results li { border-radius: 2px; }
.chip { height: 30px; border-radius: var(--radius); background: transparent; font-size: 13.5px; border-color: var(--line-2); transition: none; }
.chip[aria-pressed="true"] { background: var(--ink-2); border-color: var(--ink-2); }

/* map furniture */
.badge { border-radius: var(--radius); box-shadow: none; backdrop-filter: none; background: var(--card); font: 500 14.5px/1.3 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.badge::before { width: 6px; height: 6px; }
.badge-info, .map-status { border-radius: var(--radius); box-shadow: var(--shadow); }
.maplibregl-ctrl-group { border-radius: var(--radius) !important; box-shadow: 0 0 0 1px var(--line-2) !important; }

/* the panel: one hairline frame, no plate rule, no drop shadow */
.panel { border-radius: var(--radius); border-color: var(--line-2); box-shadow: var(--shadow); }
.panel::before { display: none; }
.panel h1 { font-size: 29px; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; }
.panel h2 { font: 500 16px/1.2 var(--serif); text-transform: none; letter-spacing: .06em; font-variant: small-caps; font-variant-caps: all-small-caps; color: var(--ink-2); margin: 24px 0 8px; }
.panel h2::after { background: var(--line-2); }
.kicker { font: 500 15px/1.2 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--ink-3); }
p.lead.century { font-size: 17px; }
.note, .facts, .changes-list, .legend .a, .ev .m { font-variant-numeric: lining-nums tabular-nums; }
.facts dt { font: 500 14.5px/1.3 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .06em; }
/* curated / map note / unverified: footnote-style annotations, not stickers */
.unver { border: 0; padding: 0; margin-left: 4px; font: 500 14px/1 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .05em; color: var(--ink-3); vertical-align: baseline; }
.unver::before { content: "["; } .unver::after { content: "]"; }
.link { font-weight: 500; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.strip { border: 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); border-radius: 0; background: none; padding: 8px 0 10px; }
.occ { border-left: 1px solid var(--line-2); }
.ev { border-radius: 2px; }
.ev .dot { box-shadow: none; width: 7px; height: 7px; margin-top: 8px; }
.ev .t { font-size: 16px; }
.ev.today { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.more, .filters button, .pill-list button, .icon-btn { border-radius: var(--radius); }
.filters button[aria-pressed="false"] { text-decoration: none; opacity: .5; }
.skeleton { border-radius: 2px; animation-duration: 2s; }
.sheet { border-radius: var(--radius); box-shadow: 0 8px 30px rgba(20, 16, 10, .18); }
.flagbig { box-shadow: none; }

/* the year opening the panel */
.yearhead .link.yh-top { font-weight: 600; color: var(--ink); text-decoration-color: var(--line-2); }
.yearhead .yh-date { font: 500 14px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; color: var(--ink-3); }
.yearhead .yh-d { font-size: 15px; margin-top: 2px; }
h2.context { margin-top: 22px; }
.yearhead .yh-also-h { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; }
.yh-also { list-style: none; margin: 2px 0 0; padding: 0; font-size: 14.5px; }
.yh-also li { padding: 2px 0; }
.yh-also .yh-date { font-size: 13px; margin-left: 4px; }

/* time bar: a ruled instrument */
.timebar { background: var(--paper); border-top-color: var(--line-2); box-shadow: none; }
.year-input { border-radius: var(--radius); font: 500 22px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; border-color: var(--line-2); }
.go { border-radius: var(--radius); background: transparent; color: var(--ink); border: 1px solid var(--line-2); font-weight: 500; transition: none; }
.go:hover { background: var(--paper-2); border-color: var(--ink-3); }
.tbtn { border-radius: var(--radius); background: transparent; height: 36px; font-weight: 400; }
.play { width: 38px; height: 38px; background: transparent; color: var(--ink); border: 1px solid var(--ink-3); box-shadow: none; }
.play:hover { background: var(--paper-2); }
.play[aria-pressed="true"] { background: var(--ink-2); color: var(--paper); border-color: var(--ink-2); }
.speed select { border-radius: var(--radius); background: transparent; height: 36px; font-weight: 400; }
.eras > span { font: 500 13px/13px var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .08em; border-radius: 0; background: none !important; border-left: 1px solid var(--line-2); }
.eras > span:first-child { border-left: 0; }
.slider::-webkit-slider-runnable-track { height: 1px; background: var(--ink-3); }
.slider::-moz-range-track { height: 1px; background: var(--ink-3); }
.slider::-webkit-slider-thumb { width: 3px; height: 22px; margin-top: -10.5px; border-radius: 0; background: var(--accent); border: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--paper) 85%, transparent); }
.slider::-moz-range-thumb { width: 3px; height: 22px; border-radius: 0; background: var(--accent); border: 0; box-shadow: 0 0 0 3px var(--paper); }
.slider:active::-webkit-slider-thumb { transform: none; }
.ticks i b { font: 500 11px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.thumb-year { border-radius: 2px; font: 500 12.5px/1.3 var(--serif); font-variant-numeric: lining-nums tabular-nums; background: var(--ink-2); }

/* the key: a legend card, ruled */
.key { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); border-color: var(--line-2); }
.key-toggle { font: 500 16px/1 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .08em; }
.key-body h3 { font: 500 14.5px/1 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .08em; border-top: 1px solid var(--line); padding-top: 8px; }
.key-body h3:first-child { border-top: 0; padding-top: 0; }
.kseg { display: inline-flex; margin: 2px 0 6px; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.kseg button { border: 0; background: none; padding: 3px 9px; font-size: 12px; color: var(--ink-2); }
.kseg button + button { border-left: 1px solid var(--line-2); }
.kseg button[aria-checked="true"] { background: var(--ink-2); color: var(--paper); }
.kffill { width: 26px; height: 16px; border: 1px solid #2a2219; background: linear-gradient(#fdfbf8 0 33%, #606d8c 33% 66%, #b56f66 66%); }
.kflash { background: color-mix(in srgb, var(--card) 45%, #7fa0c4); box-shadow: inset 0 0 0 1.5px #3d5f84; border-radius: 1px; }
.kcluster { background: var(--ink-2); }

/* the state context panel and write-ups (context round): the same small-capital labels, footnote sources */
.ctx > summary, .wu h3 { font: 500 16px/1.3 var(--serif); text-transform: none; font-variant-caps: all-small-caps; letter-spacing: .06em; }
.ctx > summary .muted { font-variant-caps: normal; font-size: 13px; }
.ctx-src, .wu-src { font-variant-numeric: lining-nums tabular-nums; }


@media (max-width: 899px) {
  .panel { border-radius: var(--radius) var(--radius) 0 0; }
  .panel h1 { font-size: 23px; }
  .year-input { font-size: 18px; }
  .tbtn { height: 36px; }
  .play { width: 36px; height: 36px; flex: none; }
}

/* ?debug=1: what the device does with the flag fill, for a screenshot */
.diag { position: fixed; z-index: 60; left: 8px; top: calc(var(--top-h) + 6px); max-width: calc(100% - 16px); margin: 0; padding: 6px 8px; font: 11px/1.35 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: #f6f1e6; background: rgba(20, 16, 10, .82); border-radius: 4px; pointer-events: none; }

/* ---------- "Suggest something we missed" (the form itself is built by js/suggest.js when opened) ---------- */
.suggest { margin: 28px 0 4px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.suggest > summary { list-style: none; cursor: pointer; padding: 11px 0; display: flex; align-items: baseline; gap: 8px; font: 500 16px/1.3 var(--serif); font-variant-caps: all-small-caps; letter-spacing: .06em; color: var(--ink-2); }
.suggest > summary::-webkit-details-marker { display: none; }
.suggest > summary::after { content: "+"; margin-left: auto; font: 400 16px/1 var(--sans); color: var(--ink-3); }
.suggest[open] > summary::after { content: "–"; }
.suggest > summary:hover { color: var(--accent); }
.sg-slot { padding: 0 0 14px; }
.sg-form { display: grid; gap: 12px; font-size: 14px; }
.sg-about { margin: 0; color: var(--ink-3); font-size: 13px; }
.sg-about b { color: var(--ink-2); font-weight: 600; }
.sg-field { display: grid; gap: 4px; min-width: 0; }
.sg-field label { font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.sg-opt, .sg-req { font-weight: 400; color: var(--ink-3); }
.sg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sg-form input, .sg-form textarea { width: 100%; min-width: 0; font: inherit; font-size: 15px; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 7px 9px; }
.sg-form textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
.sg-form input:focus, .sg-form textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.sg-form [aria-invalid] { border-color: #a33a2a; }
.sg-count { margin: 0; font-size: 12px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.sg-count.low { color: #a33a2a; }
.sg-hint { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.sg-err { margin: 0; font-size: 13px; color: #a33a2a; }
.sg-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.sg-privacy { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.sg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sg-send { border: 1px solid var(--ink-2); background: var(--ink-2); color: var(--paper); border-radius: var(--radius); padding: 7px 16px; font-weight: 600; font-size: 14px; }
.sg-send:hover { background: var(--ink); }
.sg-send:disabled { opacity: .6; }
.sg-status { margin: 0; font-size: 13px; color: var(--ink-3); }
.sg-status.err { color: #a33a2a; }
.sg-done:focus { outline: none; }
.sg-thanks { margin: 0; font: 500 17px/1.4 var(--serif); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sg-err, :root:not([data-theme="light"]) .sg-status.err, :root:not([data-theme="light"]) .sg-count.low { color: #f0a08e; } }
@media (max-width: 420px) { .sg-row { grid-template-columns: 1fr; } }

/* ======================================================================================================
   Modern finish (round 14): white bars and panels, black text in one clean sans (Source Sans 3), normal case
   instead of small capitals, blue buttons, tabs and links. Overrides the earlier atlas finish above.
   ====================================================================================================== */
:root {
  --paper: #ffffff; --paper-2: #f1f3f6; --card: #ffffff; --ink: #111111; --ink-2: #2e3238; --ink-3: #5d636b;
  --line: #e3e6eb; --line-2: #cdd2d9; --accent: #1d6fe0; --accent-2: #1659bd; --accent-ink: #ffffff; --accent-soft: #e8f0fc;
  --focus: #1d6fe0; --ok: #2f8a4c; --warn: #8a5a00;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: var(--sans);
  --shadow: 0 1px 3px rgba(15, 20, 30, .1), 0 4px 14px rgba(15, 20, 30, .06);
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16181c; --paper-2: #1f2228; --card: #1b1e23; --ink: #f2f4f7; --ink-2: #ccd1d8; --ink-3: #9aa2ad;
    --line: #2d3138; --line-2: #3c424b; --accent: #4d92f5; --accent-2: #6aa5f8; --accent-ink: #ffffff; --accent-soft: #1d2b40; --focus: #6aa5f8; --ok: #79c08f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --paper: #16181c; --paper-2: #1f2228; --card: #1b1e23; --ink: #f2f4f7; --ink-2: #ccd1d8; --ink-3: #9aa2ad;
  --line: #2d3138; --line-2: #3c424b; --accent: #4d92f5; --accent-2: #6aa5f8; --accent-ink: #ffffff; --accent-soft: #1d2b40; --focus: #6aa5f8; --ok: #79c08f;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
body { font: 15px/1.5 var(--sans); font-variant-numeric: lining-nums; color: var(--ink); background: var(--paper); }
a { color: var(--accent); }

/* normal case everywhere: no small capitals, no spaced-out capitals */
.panel h2, .kicker, h2.context, .facts dt, .unver, .eras > span, .key-toggle, .key-body h3, .ctx > summary, .wu h3, .suggest > summary {
  font-variant-caps: normal; text-transform: none; letter-spacing: 0;
}

/* buttons: blue. Primary (Go, play, a pressed toggle) filled blue with white text; secondary white with a blue outline */
.chip, .tbtn, .go, .play, .speed select, .more, .icon-btn, .filters button, .pill-list button, .kseg, .sg-send {
  font-family: var(--sans);
}
.chip, .tbtn, .speed select, .more, .pill-list button, .filters button {
  background: var(--card); color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius); font-weight: 600; transition: background .15s, color .15s;
}
.chip:hover, .tbtn:hover, .more:hover, .pill-list button:hover, .filters button:hover, .speed select:hover { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-2); }
.chip[aria-pressed="true"], #projBtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip { height: 32px; padding: 0 12px; font-size: 14px; }
.go { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: var(--radius); font-weight: 600; letter-spacing: 0; }
.go:hover { background: var(--accent-2); border-color: var(--accent-2); }
.play { background: var(--accent); color: var(--accent-ink); border: 0; box-shadow: none; }
.play:hover { background: var(--accent-2); }
.play[aria-pressed="true"] { background: var(--accent-2); color: var(--accent-ink); }
.speed select { color: var(--accent); }
.speed { color: var(--ink-3); }
.filters button[aria-pressed="true"] { background: var(--accent-soft); }
.filters button[aria-pressed="false"] { color: var(--ink-3); border-color: var(--line-2); opacity: 1; }
.icon-btn { background: var(--card); color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius); }
.sg-send { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sg-send:hover { background: var(--accent-2); border-color: var(--accent-2); }
/* tabs (the key's Flag fill / Plain colours): blue segmented control */
.kseg { border: 1px solid var(--accent); border-radius: var(--radius); }
.kseg button { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.kseg button + button { border-left: 1px solid var(--accent); }
.kseg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.kswitch input { accent-color: var(--accent); }

/* top bar: white, black text */
.top { background: var(--card); border-bottom: 1px solid var(--line); backdrop-filter: none; }
.brand { font: 700 21px/1 var(--sans); letter-spacing: -.01em; color: var(--ink); }
.search input { height: 36px; border-radius: var(--radius); border-color: var(--line-2); background-color: var(--card); color: var(--ink); }
.search input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 0; }
.results { border-radius: var(--radius); }
.results li[aria-selected="true"], .results li:hover { background: var(--accent-soft); }

/* map furniture */
.badge { background: var(--card); color: var(--ink); border-color: var(--line-2); border-radius: var(--radius); font: 600 14px/1.3 var(--sans); letter-spacing: 0; }
.badge:hover { color: var(--accent); border-color: var(--accent); }
.badge::before { background: var(--accent); }
.badge-info, .map-status { border-radius: var(--radius); }
.maplibregl-ctrl-group { border-radius: var(--radius) !important; }

/* time bar: white, black and grey ticks, a blue needle */
.timebar { background: var(--card); border-top: 1px solid var(--line); box-shadow: none; }
.year-input { font: 700 22px/1 var(--sans); font-variant-numeric: lining-nums tabular-nums; color: var(--ink); border-color: var(--line-2); border-radius: var(--radius); background: var(--card); letter-spacing: 0; }
.year-input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 0; }
.year-hint { color: var(--ink-3); }
.eras > span { font: 600 12px/13px var(--sans); color: var(--ink-2); background: none !important; border-left: 1px solid var(--line-2); border-radius: 0; }
.eras > span:first-child { border-left: 0; }
.slider::-webkit-slider-runnable-track { height: 2px; background: var(--ink-3); }
.slider::-moz-range-track { height: 2px; background: var(--ink-3); }
.slider::-webkit-slider-thumb { width: 6px; height: 24px; margin-top: -11px; border-radius: 3px; background: var(--accent); border: 0; box-shadow: 0 0 0 2px var(--card); }
.slider::-moz-range-thumb { width: 6px; height: 24px; border-radius: 3px; background: var(--accent); border: 0; box-shadow: 0 0 0 2px var(--card); }
.ticks i { background: var(--ink); opacity: .35; }
.ticks i.mj { opacity: .75; }
.ticks i b { font: 500 11.5px/1 var(--sans); font-variant-numeric: lining-nums tabular-nums; color: var(--ink-3); letter-spacing: 0; }
.thumb-year { background: var(--accent); color: var(--accent-ink); font: 700 12.5px/1.3 var(--sans); border-radius: 4px; }

/* the panel and the phone's bottom sheet: white, black text, tidy sans headings, blue links */
.panel { background: var(--card); color: var(--ink); border-color: var(--line); border-radius: 8px; }
.panel h1 { font: 700 28px/1.15 var(--sans); letter-spacing: -.01em; color: var(--ink); }
.panel h2 { font: 700 15px/1.3 var(--sans); color: var(--ink); margin: 24px 0 8px; }
.panel h2::after { background: var(--line); }
.panel h3 { font: 700 16px/1.3 var(--sans); }
.kicker { font: 600 13px/1.2 var(--sans); color: var(--accent); margin-bottom: 4px; }
h2.context { font-size: 14px; color: var(--ink-2); }
p.lead.century, .ctx-glance .ctx-body > p:first-child { font: 400 16.5px/1.5 var(--sans); color: var(--ink); }
.ctx-big { font: 600 18px/1.35 var(--sans); }
.facts dt { font: 600 13px/1.3 var(--sans); color: var(--ink-3); }
.unver { font: 600 11.5px/1.4 var(--sans); color: var(--ink-3); background: var(--paper-2); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.unver::before, .unver::after { content: none; }
.link { color: var(--accent); font-weight: 600; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.link:hover { text-decoration-color: var(--accent); }
.yearhead .link.yh-top { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.yearhead .yh-date, .yh-also .yh-date { font: 500 13px/1.3 var(--sans); color: var(--ink-3); }
.ev .t { font: 600 15.5px/1.3 var(--sans); color: var(--ink); }
.ev.today { background: var(--accent-soft); }
.year-group { font: 700 17px var(--sans); }
.year-group button { color: var(--accent); font-weight: 600; }
.strip { border-color: var(--line); }
.ctx > summary, .wu h3, .suggest > summary { font: 700 14.5px/1.3 var(--sans); color: var(--ink); }
.ctx > summary:hover, .suggest > summary:hover { color: var(--accent); }
.sg-thanks { font: 600 17px/1.4 var(--sans); }
.sheet { border-radius: 8px; background: var(--card); }
.sheet-head h2, .prose h3 { font-family: var(--sans); font-weight: 700; }
.sheet-head h2 { font-size: 23px; }
.prose h3 { font-size: 17px; }

/* the key: a white card, sans headings */
.key { background: var(--card); border-color: var(--line-2); border-radius: 8px; color: var(--ink-2); }
.key-toggle { font: 700 13.5px/1 var(--sans); color: var(--ink); }
.key-body h3 { font: 700 12.5px/1 var(--sans); color: var(--ink); border-top-color: var(--line); }
.kunder { font: italic 11px/1 var(--sans); }
.kcluster { background: var(--ink-2); color: var(--card); }

@media (max-width: 899px) {
  .panel { border-radius: 12px 12px 0 0; }
  .panel h1 { font-size: 23px; }
  .sheet-title { font: 700 16.5px/1.2 var(--sans); color: var(--ink); }
  .sheet-handle .grip { background: var(--line-2); }
  .year-input { font-size: 18px; }
  .chip { height: 32px; font-size: 13px; }
}
