@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(fonts/cormorant-garamond-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+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(fonts/cormorant-garamond-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(fonts/cormorant-garamond-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url(fonts/cormorant-garamond-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url(fonts/cormorant-garamond-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url(fonts/cormorant-garamond-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin-ext.woff2) format('woff2'); unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url(fonts/inter-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url(fonts/inter-cyrillic-ext.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }

:root {
  --parch: #efe4c8; --parch-2: #e6d6b0; --paper: #f8f1de; --ink: #3b2a1a; --ink-2: #6b5238;
  --cinnabar: #b0302a; --cinnabar-d: #7d1d17; --verd: #6f8f5a; --ochre: #d9b45a; --rose: #d79a93;
  --shadow: 0 10px 30px rgba(59, 42, 26, .25), 0 2px 6px rgba(59, 42, 26, .2);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --panel-w: 440px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d9c9a3; color: var(--ink); font-family: var(--sans); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--cinnabar-d); }

#map { position: fixed; inset: 0; background: #d9c9a3; }
.leaflet-container { background: #d9c9a3; font-family: var(--sans); }
.leaflet-tile { filter: saturate(1.05) contrast(1.02); }
.leaflet-control-zoom a { background: var(--paper); color: var(--ink); border-color: var(--parch-2) !important; }
.leaflet-control-attribution { background: rgba(248, 241, 222, .8) !important; color: var(--ink-2); font-size: 11px; }
.leaflet-control-attribution a { color: var(--cinnabar-d); }

/* top bar */
.topbar { position: fixed; z-index: 1000; top: 12px; left: 12px; right: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 16px 6px 6px; border: 1px solid rgba(59, 42, 26, .18); border-radius: 999px; background: rgba(248, 241, 222, .9); backdrop-filter: blur(8px); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.brand img { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); }
.brand-text strong { display: block; font-family: var(--serif); font-size: 22px; line-height: 1; letter-spacing: .01em; }
.brand-text small { display: block; font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.chip, #lang { border: 1px solid rgba(59, 42, 26, .2); background: rgba(248, 241, 222, .92); backdrop-filter: blur(8px); border-radius: 999px; padding: 8px 14px; cursor: pointer; box-shadow: 0 2px 8px rgba(59, 42, 26, .15); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--cinnabar); color: #fff4ec; border-color: var(--cinnabar-d); }
#lang { padding-right: 10px; }
.search { position: relative; }
.search input { width: 200px; border: 1px solid rgba(59, 42, 26, .2); background: rgba(248, 241, 222, .92); border-radius: 999px; padding: 8px 14px; box-shadow: 0 2px 8px rgba(59, 42, 26, .15); outline: none; }
.search input:focus { border-color: var(--cinnabar); }
.search ul { position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.search li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search li:hover, .search li.on { background: var(--parch); }
.search li small { color: var(--ink-2); }

/* kind chips */
.kinds { position: fixed; z-index: 999; top: 76px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100vw - 24px); }
.kinds button { border: 1px solid rgba(59, 42, 26, .18); background: rgba(248, 241, 222, .9); border-radius: 999px; padding: 5px 11px 5px 7px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.kinds button .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .3); }
.kinds button[aria-pressed="false"] { opacity: .45; }

.layers { position: fixed; z-index: 999; left: 12px; bottom: 112px; background: rgba(248, 241, 222, .9); border-radius: 14px; padding: 8px 12px; font-size: 13px; box-shadow: 0 2px 8px rgba(59, 42, 26, .15); display: flex; flex-direction: column; gap: 4px; }
.layers input { accent-color: var(--cinnabar); }

/* base-map switcher */
.mapsw { position: fixed; z-index: 999; top: 112px; left: 12px; display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; border-radius: 14px; background: rgba(248, 241, 222, .9); box-shadow: 0 2px 8px rgba(59, 42, 26, .15); max-width: calc(100vw - 24px); }
.mapsw button { border: 0; background: transparent; border-radius: 10px; padding: 5px 9px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.mapsw button b { font-family: var(--serif); font-size: 15px; color: var(--ink); }
.mapsw button.on { background: var(--ink); color: var(--paper); }
.mapsw button.on b { color: var(--paper); }
.base-fade { animation: basefade .6s ease both; }
@keyframes basefade { from { opacity: 0; } }

/* timeline */
.timebar { position: fixed; z-index: 1000; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 18px; background: rgba(248, 241, 222, .93); backdrop-filter: blur(8px); box-shadow: var(--shadow); border: 1px solid rgba(59, 42, 26, .16); }
.play { width: 46px; height: 46px; flex: none; border-radius: 50%; border: none; cursor: pointer; color: #fff4ec; font-size: 18px; background: radial-gradient(circle at 35% 30%, #d4503f, #a92a22 55%, #6e1712); box-shadow: 0 3px 8px rgba(110, 23, 18, .45); }
.range { flex: 1; min-width: 0; }
.range-labels { display: flex; justify-content: space-between; font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1; }
.range-title { font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--ink-2); letter-spacing: .08em; text-transform: uppercase; align-self: center; }
.range-track { position: relative; height: 34px; margin-top: 4px; }
.hist { position: absolute; inset: 0 0 12px; display: flex; align-items: flex-end; gap: 1px; }
.hist i { flex: 1; background: var(--ink-2); opacity: .28; border-radius: 1px 1px 0 0; min-height: 1px; }
.hist i.on { background: var(--cinnabar); opacity: .8; }
.sel { position: absolute; bottom: 10px; height: 4px; background: var(--cinnabar); border-radius: 2px; }
.range-track::after { content: ''; position: absolute; left: 0; right: 0; bottom: 10px; height: 4px; background: rgba(59, 42, 26, .15); border-radius: 2px; z-index: -1; }
.range-track input { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; margin: 0; height: 24px; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.range-track input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d4503f, #a92a22 60%, #6e1712); border: 2px solid #fff4ec; box-shadow: 0 2px 5px rgba(0, 0, 0, .35); cursor: grab; }
.range-track input::-moz-range-thumb { pointer-events: auto; width: 20px; height: 20px; border-radius: 50%; background: #a92a22; border: 2px solid #fff4ec; cursor: grab; }
.range-track input::-webkit-slider-runnable-track { background: none; }
.ticks { position: relative; height: 14px; font-size: 11px; color: var(--ink-2); }
.ticks span { position: absolute; transform: translateX(-50%); }
.count { flex: none; text-align: right; font-size: 13px; color: var(--ink-2); min-width: 90px; }
.count b { display: block; font-family: var(--serif); font-size: 26px; color: var(--ink); line-height: 1; }

/* town markers: wax seals */
.seal { position: relative; display: grid; place-items: center; border-radius: 50%; color: #fff4ec; font-weight: 700; font-size: 13px; font-family: var(--sans);
  background: radial-gradient(circle at 35% 30%, #d9584a, #a92a22 55%, #6e1712); box-shadow: 0 3px 6px rgba(60, 10, 6, .45), inset 0 -3px 5px rgba(0, 0, 0, .25), inset 0 2px 3px rgba(255, 220, 200, .35);
  transition: transform .25s ease, opacity .3s ease; cursor: pointer; }
.seal::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1px dashed rgba(255, 230, 215, .55); }
.seal:hover { transform: scale(1.15); }
.seal.empty { background: radial-gradient(circle at 35% 30%, #a9927a, #7c6650 60%, #54412f); opacity: .55; }
.seal.pulse::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(176, 48, 42, .7); animation: pulse 1.6s ease-out infinite; }
.seal.active { outline: 3px solid var(--ochre); outline-offset: 2px; }
@keyframes pulse { from { transform: scale(.8); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.town-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; white-space: nowrap; font-family: var(--serif); font-weight: 700; font-size: 16px; color: var(--ink); text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper), 0 0 10px var(--paper); pointer-events: none; }
.leaflet-marker-icon.town { background: none; border: none; }

.inscr { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(248, 241, 222, .92); border: 2px solid var(--ochre); box-shadow: 0 2px 6px rgba(59, 42, 26, .35); font-size: 17px; cursor: pointer; animation: glow 3s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(217, 180, 90, .25), 0 2px 6px rgba(59, 42, 26, .35); } }
.leaflet-popup-content-wrapper { background: var(--paper); color: var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--paper); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.5; max-width: 320px; }
.ipop h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 19px; }
.ipop .la { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-2); border-left: 3px solid var(--ochre); padding-left: 10px; margin: 8px 0; }

/* side panel */
.panel { position: fixed; z-index: 1100; top: 0; right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw; background: var(--paper);
  background-image: radial-gradient(ellipse at top, rgba(217, 180, 90, .12), transparent 60%), radial-gradient(ellipse at bottom right, rgba(176, 48, 42, .06), transparent 50%);
  box-shadow: -10px 0 40px rgba(59, 42, 26, .3); transform: translateX(105%); transition: transform .35s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; }
.panel.open { transform: none; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; border-bottom: 1px solid var(--parch-2); }
.panel-head h2 { margin: 0; font-family: var(--serif); font-size: 38px; line-height: 1; }
.p-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.x { border: none; background: var(--parch); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; flex: none; }
.panel-body { overflow: auto; padding: 14px 18px 120px; flex: 1; }
.empty-note { color: var(--ink-2); font-style: italic; padding: 12px 4px; }

.card { position: relative; margin: 0 0 16px; padding: 16px 16px 14px 58px; background: #fffaf0; border: 1px solid var(--parch-2); border-radius: 14px; box-shadow: 0 2px 10px rgba(59, 42, 26, .08); animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card .k { position: absolute; left: 12px; top: 14px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; color: #fff4ec; box-shadow: 0 2px 4px rgba(0, 0, 0, .3), inset 0 -2px 4px rgba(0, 0, 0, .25); }
.card .yr { font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--cinnabar-d); line-height: 1; }
.card h3 { margin: 4px 0 8px; font-family: var(--serif); font-size: 21px; line-height: 1.15; }
.card p { margin: 0 0 8px; font-size: 15px; line-height: 1.55; }
.card .kid { background: #eef3e8; border-radius: 10px; padding: 8px 10px; font-size: 14px; display: none; }
body.kids .card .kid { display: block; }
body.kids .card .sum { display: none; }
.card .kid b { color: var(--verd); }
.card blockquote { margin: 8px 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--ochre); font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink-2); }
.card blockquote small { display: block; font-family: var(--sans); font-style: normal; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.card .meta { font-size: 12px; color: var(--ink-2); line-height: 1.5; border-top: 1px dashed var(--parch-2); padding-top: 8px; margin-top: 8px; }
.card .meta b { color: var(--ink); font-weight: 600; }
.card .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card .acts a, .card .acts button { font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--parch-2); background: var(--paper); text-decoration: none; color: var(--ink); cursor: pointer; }
.card .acts a:hover, .card .acts button:hover { border-color: var(--cinnabar); }
.card.hl { box-shadow: 0 0 0 3px var(--ochre), 0 2px 10px rgba(59, 42, 26, .08); }

/* modals */
.modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(40, 26, 14, .55); backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.sheet { position: relative; max-width: 620px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 22px; padding: 30px 30px 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); border: 1px solid var(--parch-2); }
.sheet h1, .sheet h2 { font-family: var(--serif); margin: 0 0 12px; font-size: 42px; line-height: 1; }
.sheet h2 { font-size: 32px; }
.sheet p { font-size: 16px; line-height: 1.6; }
.sheet .x { position: absolute; right: 14px; top: 14px; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--cinnabar-d); margin: 6px 0 8px; }
.intro-sheet { text-align: center; }
.intro-seal { animation: stamp .9s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 6px 8px rgba(80, 10, 5, .4)); }
@keyframes stamp { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } }
.intro-langs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 18px; }
.intro-langs button { border: 1px solid var(--parch-2); background: #fffaf0; border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.intro-langs button.on { background: var(--ink); color: var(--paper); }
.intro-langs hr { flex-basis: 100%; height: 0; border: 0; margin: 0; }
.cta { border: none; border-radius: 999px; padding: 14px 30px; font-size: 18px; font-weight: 600; color: #fff4ec; cursor: pointer; background: radial-gradient(circle at 35% 30%, #d4503f, #a92a22 55%, #6e1712); box-shadow: 0 6px 16px rgba(110, 23, 18, .45); }
.made { font-size: 14px; border-top: 1px solid var(--parch-2); padding-top: 12px; }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 14px; }

/* phones */
@media (max-width: 760px) {
  :root { --panel-w: 100vw; }
  .topbar { top: 8px; left: 8px; right: 8px; flex-wrap: wrap; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 18px; }
  .search input { width: 104px; }
  .chip .lbl { display: none; }
  #lang { max-width: 92px; }
  .topbar { flex-wrap: nowrap; }
  .brand { padding-right: 10px; }
  .brand-text strong { font-size: 15px; max-width: 110px; }
  .chip, #lang { padding: 7px 10px; font-size: 13px; }
  .kinds { top: auto; bottom: 104px; left: 8px; right: 8px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .layers { bottom: 148px; left: 8px; }
  .mapsw { top: 64px; left: 8px; right: 8px; flex-wrap: nowrap; overflow-x: auto; }
  .mapsw button { white-space: nowrap; }
  .timebar { left: 8px; right: 8px; bottom: 8px; padding: 8px 10px; gap: 8px; }
  .count { min-width: 56px; font-size: 11px; }
  .count b { font-size: 20px; }
  .play { width: 40px; height: 40px; }
  .panel { top: auto; height: 78vh; border-radius: 22px 22px 0 0; transform: translateY(105%); }
  .panel.open { transform: none; }
  .panel-head h2 { font-size: 30px; }
  .sheet { padding: 24px 20px; }
  .sheet h1 { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
