:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --surface: #fffdf8;
  --ink: #2b302c;
  --muted: #6b6d66;
  --line: #d8d2c3;
  --accent: #315b51;
  --accent-soft: #e1eee7;
  --reader-width: 42%;
}
* { box-sizing: border-box; }
html,body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; display: flex; flex-direction: column; overflow: hidden; }
a { color: var(--accent); }
button, input { font: inherit; }
button { border-radius: 6px; border: 1px solid var(--accent); cursor: pointer; padding: 8px 12px; background: var(--accent); color: #fff; }
button:hover { filter: brightness(.95); }
button:disabled { opacity: .47; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, [role="separator"]:focus-visible { outline: 3px solid #b67a37; outline-offset: 2px; }
button.secondary-button, button.icon-button { background: #fffdf8; color: var(--accent); border-color: #c4cfc5; }
button.icon-button { min-width: 32px; padding: 5px 8px; }
.site-header { padding: 11px 22px; background: #274239; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 78px; }
.eyebrow { color: #d1e0d3; text-transform: uppercase; font-size: 10px; letter-spacing: .17em; margin: 0 0 4px; }
.site-header h1 { font: normal clamp(21px,2vw,29px)/1.2 Georgia, serif; margin: 0; }
.site-actions { display: flex; gap: 5px; flex-wrap: nowrap; }
.layout-button { border: 1px solid #7a978c; background: transparent; color: #e8eee8; padding: 7px 11px; font-size: 13px; }
.layout-button[aria-pressed="true"] { color: #18362c; background: #f5f3e8; border-color: #f5f3e8; }
.workspace { width: 100%; min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(260px,var(--reader-width)) 9px minmax(290px,1fr); background: var(--line); }
.reader-panel,.map-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.reader-panel { background: var(--surface); }
.reader-toolbar { flex: 0 0 auto; min-height: 54px; padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 7px; align-items: center; background: #f6f2e8; }
.reader-toolbar .secondary-button { white-space: nowrap; }
.reader-location { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; text-align: right; }
.reading-scroll { min-height: 0; flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 23px clamp(18px,3vw,52px) 42px; scrollbar-gutter: stable; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 20px; color: var(--muted); }
.breadcrumbs button { padding: 0; border: 0; background: transparent; color: var(--accent); text-decoration: underline; }
.breadcrumbs .current-crumb { color: var(--muted); }
.toc-drawer { position: absolute; top: 54px; bottom: 0; left: 0; width: min(440px,100%); overflow: auto; background: #faf8f2; z-index: 1200; box-shadow: 5px 0 16px rgba(28,36,31,.18); border-right: 1px solid var(--line); padding: 16px 14px 24px; }
.toc-drawer[hidden] { display: none; }
.toc-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; font: 18px Georgia, serif; }
.toc-list { margin: 0; padding-left: 13px; list-style: none; }
.toc-list .toc-list { margin: 3px 0 6px 9px; padding-left: 11px; border-left: 1px solid #d8d2c3; }
.toc-item { display: flex; gap: 2px; align-items: flex-start; }
.toc-item .toc-expand { border: none; background: transparent; color: var(--muted); flex: 0 0 25px; padding: 6px 2px; font-size: 12px; }
.toc-item .toc-choose { background: transparent; border: none; text-align: left; color: var(--ink); flex: 1; padding: 6px; line-height: 1.34; }
.toc-item .toc-choose[aria-current="page"] { background: var(--accent-soft); color: #264d42; font-weight: 650; }
.toc-item .toc-choose:hover { text-decoration: underline; }
.article-navigation { display: flex; align-items: stretch; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); margin-top: 34px; padding-top: 16px; }
.article-navigation button { background: #edf3ee; color: #315b51; border-color: #c4d4c9; text-align: left; font-size: 13px; max-width: 100%; }
.loading-text { color: var(--muted); font-style: italic; }
.error-panel { padding: 16px; border: 1px solid #c58e78; border-radius: 5px; background: #fff1ea; }
.splitter { background: #d6d1c5; cursor: col-resize; display: flex; align-items: center; justify-content: center; touch-action: none; }
.splitter:hover,.splitter:focus-visible { background: #b2bcb4; }
.splitter-grip { display: block; width: 4px; height: 55px; border-left: 1px solid #888c83; border-right: 1px solid #888c83; }
body.resizing { cursor: col-resize !important; user-select: none; }
.map-panel { background: #f2f2ed; }
.map-toolbar { min-height: 62px; flex: 0 0 auto; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); background: #f1ede2; }
.map-heading { display: flex; flex-direction: column; min-width: 0; }
.toolbar-kicker { font-size: 9px; color: var(--muted); letter-spacing: .13em; }
.map-heading strong { font-size: 14px; }
.map-heading small { font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.map-toolbar button { white-space: nowrap; }
.map-wrap { min-height: 0; flex: 1; display: flex; flex-direction: column; border: 0; overflow: hidden; }
.map-caption { flex: 0 0 auto; background: #e9e5d9; padding: 5px 10px; font-size: 11px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; }
.map-caption .map-hint { color: var(--muted); }
#map { flex: 1; width: 100%; min-height: 0; background: #dce7e8; }
#map:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.map-message { margin: 0; padding: 10px 14px; background: #fff1d9; font-size: 13px; }
.map-message[hidden] { display: none; }
.map-bottom-bar { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 8px 12px; gap: 4px 14px; background: #f1ede2; border-top: 1px solid var(--line); }
.year-picker { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; }
.year-picker input { width: 88px; border: 1px solid #b5c1b7; background: white; color: var(--ink); border-radius: 5px; padding: 6px; }
.year-picker button { font-size: 12px; padding: 6px 10px; }
.year-label { color: var(--accent); font-weight: 650; min-width: 63px; }
.year-help { font-size: 10px; color: var(--muted); }
.site-footer { min-height: 32px; flex: 0 0 auto; display: flex; gap: 5px 20px; justify-content: space-between; flex-wrap: wrap; padding: 6px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.noscript { position: absolute; inset: 40% 10%; padding: 30px; background: white; z-index: 10000; }
.mode-reader { grid-template-columns: minmax(0,1fr) !important; }
.mode-reader .map-panel,.mode-reader .splitter { display: none !important; }
.mode-map { grid-template-columns: minmax(0,1fr) !important; }
.mode-map .reader-panel,.mode-map .splitter { display: none !important; }
/* Existing Leaflet customization preserved from the first atlas. */
.leaflet-container { font: 13px/1.4 system-ui,sans-serif; }
.leaflet-popup-content { margin: 15px 19px; }
.leaflet-popup-content h2 { font: 400 23px/1.2 Georgia,serif; margin: 0 0 6px; }
.leaflet-popup-content p { margin: 6px 0; }
.leaflet-control-attribution { font-size: 10px; max-width: min(460px,calc(100vw - 45px)); white-space: normal; }
.leaflet-control-layers { border-color: var(--line); }
.leaflet-control-layers label { padding: 3px 2px; }
.leaflet-control-layers input { accent-color: var(--accent); }
.leaflet-control-layers-expanded { max-height: calc(65svh - 70px); overflow-y: auto; }
.map-opacity { width: 190px; max-width: calc(100vw - 80px); margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--line); }
.map-opacity-heading,.map-opacity-ends { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.map-opacity-heading { font-weight: 600; }
.map-opacity-heading output { font-variant-numeric: tabular-nums; }
.map-opacity input[type="range"] { display: block; width: 100%; height: 28px; margin: 0; cursor: pointer; }
.map-opacity input:disabled { cursor: default; }
.map-opacity-ends,.map-opacity-help { font-size: 11px; color: var(--muted); }
.map-opacity-help { margin: 5px 2px 0; max-width: 190px; line-height: 1.4; }
.map-opacity .underlay-label { display: flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 12px; }
.map-opacity .underlay-label input { margin: 0; }
.relief-strength { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
#map path.leaflet-interactive:focus { outline: none; }
#map path.leaflet-interactive:focus-visible { stroke: #315b51; stroke-width: 3; }
.leaflet-tooltip.area-label,.leaflet-tooltip.map-label { background: transparent; border: none; box-shadow: none; color: #542d24; font-size: 13px; font-weight: bold; text-align: center; text-shadow: 0 0 3px white, 0 0 5px white; }
.leaflet-tooltip.map-label { visibility: hidden; pointer-events: none; padding: 2px 4px; line-height: 1.2; }
.leaflet-tooltip.map-label::before { display: none; }
.map-label-overview { font-family: Georgia,serif; letter-spacing: .04em; }
.leaflet-tooltip.map-label-regional { color: #292b27; }
@media (pointer:coarse) { .leaflet-control-layers label { padding: 7px 2px; } }
@media (max-width: 900px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  .site-header { padding: 12px 14px; min-height: auto; }
  .workspace { display: flex; flex-direction: column; flex: none; min-height: 0; }
  .reader-panel { height: 52dvh; min-height: 350px; flex: none; }
  .map-panel { height: 55dvh; min-height: 370px; flex: none; }
  .splitter { display: none; }
  .mode-reader .reader-panel { height: calc(100dvh - 140px); }
  .mode-map .map-panel { height: calc(100dvh - 140px); }
  .reading-scroll { padding: 18px 18px 30px; }
  .reader-location { display: none; }
  .map-hint,.year-help { display: none; }
  .leaflet-control-layers-expanded { max-height: 40svh; }
}
@media (max-width: 480px) {
  .site-header h1 { font-size: 19px; }
  .eyebrow { font-size: 9px; }
  .site-header { flex-wrap: wrap; }
  .site-actions { width: 100%; }
  .layout-button { flex: 1; }
  .map-heading small { display: none; }
  .map-toolbar { min-height: 48px; }
  .map-caption { font-size: 10px; }
  .site-footer { font-size: 10px; }
}
