:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #111815;
  color: #e9f0e8;
}
* { box-sizing: border-box; }
html, body, main { width: 100%; height: 100%; margin: 0; }
main { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: #111815; }
.terrain-base img { filter: grayscale(65%) contrast(0.5) brightness(0.85); }
.leaflet-container { font-family: system-ui, sans-serif; background: #111815; }
.toolbar { position: absolute; top: 16px; left: 16px; z-index: 500; display: flex; align-items: flex-start; gap: 7px; }
.years { display: flex; min-height: 38px; border: 1px solid #506459; border-radius: 5px; background: #16221be8; overflow: hidden; }
button, summary, select, input { font: 500 12px system-ui, sans-serif; color: #e5eee4; }
button, summary { min-height: 38px; border: 1px solid #506459; border-radius: 5px; background: #16221be8; padding: 0 12px; cursor: pointer; }
#places { min-height: 38px; max-width: 105px; border: 1px solid #506459; border-radius: 5px; background: #16221be8; padding: 0 9px; cursor: pointer; }
button:hover, summary:hover { background: #2a4031f2; }
.year-field, .range-field { display: flex; align-items: center; gap: 4px; padding: 0 7px; color: #b8cbbb; }
.range-field { border-left: 1px solid #506459; }
.years input { border: 0; background: transparent; color: #e5eee4; text-align: center; padding: 0; font-size: 13px; }
#target-year { width: 43px; }
#year-range { width: 27px; }
.years input::-webkit-inner-spin-button, .years input::-webkit-outer-spin-button { appearance: none; margin: 0; }
summary { min-height: 38px; border: 1px solid #506459; border-radius: 5px; background: #16221be8; padding: 0 12px; cursor: pointer; }
#places { min-height: 38px; max-width: 105px; border: 1px solid #506459; border-radius: 5px; background: #16221be8; padding: 0 9px; cursor: pointer; }
button:hover, summary:hover { background: #2a4031f2; }
.years button { border: 0; border-radius: 0; background: transparent; min-width: 57px; }
.years button[aria-pressed="true"] { background: #d1e4c9; color: #18271c; }
.years button + button { border-left: 1px solid #506459; }
summary { display: flex; align-items: center; list-style: none; }
summary::-webkit-details-marker { display: none; }
.layers { position: relative; }
.layers summary { gap: 6px; }
.layers summary::after { content: '▾'; color: #aabca9; font-size: 10px; }
.layers[open] summary::after { transform: rotate(180deg); }
.layer-menu { position: absolute; left: 0; top: calc(100% + 7px); width: min(250px, calc(100vw - 20px)); display: grid; gap: 11px; padding: 13px; border: 1px solid #506459; border-radius: 5px; background: #16221bf5; color: #cbd8c9; font-size: 12px; }
.layer-menu { max-height: calc(100vh - 75px); max-height: calc(100dvh - 75px); overflow-y: auto; }
.layer-section { display: grid; gap: 7px; }
.layer-section + .layer-section { border-top: 1px solid #425349; padding-top: 10px; }
.layer-heading { color: #aabca9; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.layer-menu select { width: 100%; min-height: 38px; padding: 7px; border: 1px solid #506459; border-radius: 4px; background: #25392a; }
.layer-menu p { margin: 0; color: #aabca9; font-size: 12px; line-height: 1.4; }
.layer-menu p:empty { display: none; }
.toggle { display: flex; gap: 8px; align-items: center; min-height: 28px; cursor: pointer; }
.toggle input { accent-color: #bbd8b5; }
#historic-places-controls:not([hidden]) { display: grid; gap: 7px; }
#historic-places-search { width: 100%; min-height: 32px; padding: 6px 7px; border: 1px solid #506459; border-radius: 4px; background: #25392a; }
#historic-places-results { list-style: none; padding: 0; margin: 0; max-height: min(27vh, 220px); overflow-y: auto; }
#historic-places-results button { display: block; width: 100%; min-height: 31px; padding: 6px 7px; border: 0; border-radius: 3px; background: transparent; text-align: left; }
#historic-places-results button:hover { background: #2a4031f2; }
.historic-place-marker { display: block; width: 12px; height: 12px; border: 2px solid #f4f1dd; border-radius: 50%; background: #425f49; box-shadow: 0 1px 4px #000b; }
.historic-place-popup p { margin: 5px 0; }
.historic-place-popup .historic-place-meta { color: #b6c9b7; font-size: 11px; }
a { color: #bcd9bd; }
.map-footer { position: absolute; bottom: 20px; left: 16px; z-index: 500; display: flex; align-items: flex-end; gap: 5px; max-width: min(calc(100% - 76px), 590px); }
.map-status { min-width: 0; padding: 7px 10px; border-radius: 3px; background: #16221bdc; color: #d2ded0; font-size: 12px; line-height: 1.45; }
.map-help summary { justify-content: center; min-height: 32px; width: 32px; padding: 0; border-color: #506459; background: #16221bdc; font-size: 12px; }
.map-help-text { position: fixed; left: 16px; bottom: 62px; width: min(290px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid #506459; border-radius: 5px; background: #16221bf7; box-shadow: 0 4px 18px #0005; color: #d2ded0; font-size: 12px; line-height: 1.5; }
.map-help-text p { margin: 0; }
.map-help-text p + p { margin-top: 8px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #17201b; color: #e3eee3; }
.leaflet-container .leaflet-popup-content a { color: #bcd9bd; }
.leaflet-popup-content { line-height: 1.6; }
.leaflet-control-attribution { font-size: 10px !important; }
.leaflet-control-attribution a { color: #425c48; }
button:focus-visible, summary:focus-visible, select:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #d1e4c9; outline-offset: 2px; }
@media (max-width: 600px) {
  .toolbar { top: 10px; left: 10px; right: 10px; gap: 5px; max-width: calc(100vw - 20px); flex-wrap: wrap; }
  .toolbar .layers { margin-left: auto; }
  button, summary, #places, .years { min-height: 44px; }
  .map-footer { left: 10px; bottom: 24px; max-width: calc(100% - 76px); }
  .map-help summary { min-height: 36px; width: 36px; }
  .map-help-text { left: 10px; bottom: 70px; width: min(290px, calc(100vw - 76px)); }
  .layer-menu { left: auto; right: 0; max-height: calc(100vh - 185px); max-height: calc(100dvh - 185px); }
  .layer-menu .toggle, #historic-places-results button { min-height: 40px; }
}
