:root {
  --forest-deep: #080d06;
  --forest-dark: #111a0c;
  --forest-mid: #1c2d14;
  --moss-deep: #263a18;
  --moss: #344f22;
  --moss-light: #4e6e34;
  --fern: #6a8a52;
  --mist: #8fa87c;
  --leaf-gold: #a09050;
  --leaf-pale: #c8b878;
  --paper: #f4f0e8;
  --paper-dark: #e0dace;
  --ink: #1a1810;
  --ink-light: #6a6050;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --sidebar-w: 300px;
  --nav-h: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 10pt;
  line-height: 1.65;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.topnav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: linear-gradient(to right, var(--forest-mid), var(--moss-deep));
  border-bottom: 1px solid rgba(200, 184, 120, 0.12);
}

.topnav-brand {
  font-family: var(--font-serif);
  font-size: 14pt;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.5px;
}
.topnav-brand em { font-style: italic; color: var(--leaf-pale); }
.topnav-sub {
  font-size: 7.5pt;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}
.topnav-back {
  margin-left: auto;
  font-size: 7.5pt;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.15s;
}
.topnav-back:hover, .topnav-back:focus-visible { color: var(--leaf-pale); }

.page { display: flex; min-height: calc(100vh - var(--nav-h)); }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  background: linear-gradient(175deg, var(--moss) 0%, var(--moss-deep) 35%, var(--forest-dark) 70%, var(--forest-deep) 100%);
  color: rgba(255, 255, 255, 0.85);
}
.sidebar-inner { padding: 24px; display: flex; flex-direction: column; gap: 22px; }

.sidebar-label, .field-label {
  font-size: 7.5pt;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--leaf-pale);
  margin-bottom: 8px;
  display: block;
}

.search {
  width: 100%;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid rgba(200, 184, 120, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: inherit;
}
.search::placeholder { color: rgba(255, 255, 255, 0.4); }
.search:focus-visible, .chip:focus-visible, .legend-item:focus-visible {
  outline: 2px solid var(--leaf-pale);
  outline-offset: 2px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit;
  font-size: 8.5pt;
  padding: 3px 10px;
  border-radius: 2px;
  border: 1px solid rgba(200, 184, 120, 0.3);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}
.chip:hover { background: rgba(255, 255, 255, 0.06); }
.chip[aria-pressed="true"] { background: rgba(200, 184, 120, 0.2); color: #fff; border-color: var(--leaf-pale); }

.legend { display: flex; flex-direction: column; gap: 4px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 9pt;
  text-align: left;
  padding: 3px 0;
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}
.legend-item[aria-pressed="false"] { opacity: 0.4; }
.glyph { display: inline-flex; width: 15px; height: 15px; color: var(--leaf-pale); flex: none; }
.swatch { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.5); flex: none; }

.notice { font-size: 8.5pt; color: rgba(255, 255, 255, 0.55); border-top: 1px solid rgba(200, 184, 120, 0.18); padding-top: 14px; }

.legal-link { font-size: 8.5pt; color: var(--leaf-pale); }

.doc { max-width: 760px; margin: 0 auto; padding: 32px 24px 64px; }
.doc h1 { font-family: var(--font-serif); font-weight: 400; font-size: 26pt; color: var(--moss-deep); }
.doc h2 { font-family: var(--font-serif); font-weight: 400; font-size: 17pt; color: var(--moss-deep); margin-top: 28px; }
.doc ul { margin: 10px 0 0 20px; }
.doc li { margin-top: 6px; }
.doc a { color: var(--moss); }
.doc-meta { color: var(--ink-light); font-size: 9pt; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.map-wrap { position: relative; flex: 1; display: flex; min-height: 420px; }
#map { flex: 1; background: var(--paper-dark); }

.details { padding: 18px 28px 24px; border-top: 1px solid var(--paper-dark); background: var(--paper); }
.details-title { font-family: var(--font-serif); font-weight: 400; font-size: 17pt; color: var(--moss-deep); }
.details-empty, .details-meta, .details-link { font-size: 9pt; margin-top: 8px; border-left: 2px solid var(--leaf-gold); padding-left: 8px; }
.details-sources { color: var(--ink-light); }
.details-badge {
  display: inline-block;
  font-size: 7.5pt;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 1px 8px;
  border-radius: 2px;
  color: var(--ink);
  margin: 4px 8px 6px 0;
}
.warning {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 4px solid #a8503f;
  background: #f6e3de;
  color: var(--ink);
}
.warning-title { color: #8a3424; font-family: var(--font-serif); font-size: 13pt; }
.warning-text { margin-top: 4px; }
.popup-warning { margin-top: 4px; color: #8a3424; font-weight: 600; }
.details-phases { margin: 8px 0 0 18px; }
.details-phases .is-active { color: var(--moss); font-weight: 600; }
.popup-phase { margin: 4px 0 0; font-size: 9pt; }
.year { width: 100%; accent-color: var(--leaf-gold); }
.epoch-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 22px; }
.year-label { font-size: 9pt; color: rgba(255, 255, 255, 0.8); }
.epoch-reset { font: inherit; font-size: 8.5pt; background: none; border: 0; padding: 0; color: var(--leaf-pale); text-decoration: underline; cursor: pointer; }
.epoch-reset:focus-visible { outline: 2px solid var(--leaf-pale); outline-offset: 3px; }
.details-link { font-size: 9pt; margin-top: 8px; border-left: 2px solid var(--leaf-gold); padding-left: 8px; }
.details-sources { font-size: 9pt; margin-top: 8px; }
.opacity-control { background: var(--paper); padding: 6px 10px; width: 170px; }
.opacity-label { display: block; font-size: 8.5pt; color: var(--ink-light); margin-bottom: 2px; }
.opacity-slider { width: 100%; accent-color: var(--moss); }

.leaflet-container { font-family: var(--font-sans); }

/* Bounded by the map (absolute) or by the viewport (fixed on small screens), so the header never scrolls out of reach. */
.agent {
  position: absolute;
  right: 12px;
  bottom: 34px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 46px);
}
.agent-toggle {
  font: inherit;
  font-size: 9.5pt;
  padding: 10px 16px;
  border-radius: 2px;
  border: 1px solid var(--leaf-pale);
  background: var(--forest-deep);
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.agent-toggle:hover { background: var(--moss-deep); }
.agent-toggle:focus-visible, .agent-link:focus-visible, .agent-send:focus-visible, .agent-input:focus-visible {
  outline: 2px solid var(--leaf-pale);
  outline-offset: 2px;
}
.agent-panel {
  width: min(380px, calc(100vw - 24px));
  min-height: 0;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--leaf-gold);
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.agent-panel[hidden] { display: none; }
.agent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--forest-deep);
  color: var(--paper);
}
.agent-title { flex: 1; font-family: var(--font-serif); font-size: 13pt; font-weight: 400; }
.agent-link { font: inherit; font-size: 8.5pt; background: none; border: 0; color: var(--leaf-pale); cursor: pointer; text-decoration: underline; }
.agent-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.agent-msg { padding: 6px 10px; border-radius: 2px; max-width: 90%; white-space: pre-wrap; overflow-wrap: anywhere; }
.agent-msg-user { align-self: flex-end; background: var(--moss-deep); color: var(--paper); }
.agent-msg-assistant { align-self: flex-start; background: #fff; border: 1px solid var(--paper-dark); }
.agent-msg-pending { color: var(--ink-light); font-style: italic; }
.agent-msg-error { border-color: #8a3b2a; color: #7a2d1e; }
.agent-empty { color: var(--ink-light); font-size: 9pt; }
.agent-disclaimer { padding: 4px 12px; font-size: 8pt; color: var(--ink-light); border-top: 1px solid var(--paper-dark); }
.agent-form { display: flex; gap: 8px; padding: 8px 12px 12px; }
.agent-input { flex: 1; font: inherit; padding: 6px 8px; border: 1px solid var(--ink-light); border-radius: 2px; resize: none; background: #fff; }
.agent-send { font: inherit; padding: 0 14px; border: 0; border-radius: 2px; background: var(--moss); color: #fff; cursor: pointer; }
.agent-send:disabled, .agent-input:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 800px) {
  .page { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; position: static; height: auto; }
  .topnav-sub { display: none; }
  .agent { position: fixed; bottom: 12px; max-height: calc(100dvh - var(--nav-h) - 24px); }
  .agent-panel { max-height: 100%; }
}

.dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.leaflet-marker-icon:focus-visible { outline: 2px solid var(--leaf-pale); outline-offset: 3px; border-radius: 50%; }
