:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5f6670;
  --line: #e2ddd4;
  --accent: #b5832a;
  --cross: #e0a100;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }

.site-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
}
.site-header h1 { font-size: 1.6rem; letter-spacing: 0.01em; }
.lede { margin: 0; color: var(--muted); max-width: 70ch; }

.site-footer {
  padding: 6px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 0;
}

.sidebar {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.1rem; margin-bottom: 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; }

.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  margin-bottom: 8px;
}

ul, ol { list-style: none; margin: 0; padding: 0; }

.people-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }

.person-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
}
.person-btn:hover { background: var(--bg); }
.person-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.person-btn[aria-pressed="true"] { border-color: var(--line); border-left-color: var(--c); background: color-mix(in srgb, var(--c) 8%, white); }
.person-btn .name { font-weight: 600; }
.person-btn .years { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.person-btn .tagline { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; }

.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }

.btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn[aria-pressed="true"] { background: var(--ink); color: white; border-color: var(--ink); }
.btn.play { min-width: 84px; font-weight: 600; }

.crossover-list { display: flex; flex-direction: column; gap: 6px; }
.crossover {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: color-mix(in srgb, var(--cross) 10%, white);
  border: 1px solid color-mix(in srgb, var(--cross) 45%, white);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.crossover:hover { border-color: var(--cross); }
.crossover .who { font-weight: 600; }
.crossover .where { color: var(--muted); font-size: 0.85rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 4px; vertical-align: 1px; }

.journey { border-top: 4px solid var(--c); }
.journey-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.journey-head h2 { margin: 0; }
.journey-head .meta { color: var(--muted); font-size: 0.85rem; margin: 2px 0 10px; }
.remove { background: none; border: none; font-size: 1.2rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.remove:hover { color: var(--ink); }

.stops { display: flex; flex-direction: column; }
.stop {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 2px 10px;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
}
.stop:hover, .stop:focus-visible { background: var(--bg); outline: none; }
.stop.inactive { opacity: 0.4; }
.stop .num {
  grid-row: span 2;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--c);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.stop .place { font-weight: 600; }
.stop .place small { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.stop .note { color: #3b4148; font-size: 0.88rem; }
.badge { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); margin-left: 6px; vertical-align: 1px; font-weight: 600; }

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe7ea; }
.loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--surface); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); z-index: 500; margin: 0; }

.year-bar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  z-index: 500;
}
.year-row { display: flex; align-items: center; gap: 10px; }
#year-slider { flex: 1; accent-color: var(--ink); }
.year-label { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; min-width: 3.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.year-status { margin-top: 6px; font-size: 0.88rem; display: flex; flex-direction: column; gap: 2px; }
.year-status:empty { display: none; }
.year-status .away { color: var(--muted); }

/* Map markers */
.pin-icon { background: none; border: none; }
.pin {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 13px;
  background: var(--c);
  color: white;
  font: 700 12px/26px var(--font);
  text-align: center;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  position: absolute;
  left: var(--dx, 0);
  top: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.pin.birth::before { content: "★ "; }
.pin.death::after { content: " ✝"; }
.pin.past { opacity: 0.6; }
.pin.unborn { opacity: 0.45; background: white; color: var(--c); border-color: var(--c); }
.pin.arrive { animation: arrive 0.25s ease-out var(--draw, 0s) both; }
@keyframes arrive { from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); } }
.pin.active { transform: translate(-50%, -50%) scale(1.25); z-index: 2; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 1px 4px rgba(0, 0, 0, 0.35); }

.cross-ring { fill: var(--cross); stroke: var(--cross); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { stroke-opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .cross-ring, .pin.arrive { animation: none; } .pin { transition: none; } }

.leaflet-popup-content { font-family: var(--font); font-size: 14px; margin: 12px 14px; }
.popup h3 { font-size: 1rem; margin-bottom: 2px; }
.popup .who { font-size: 0.8rem; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: 0.04em; }
.popup .visit + .visit { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.popup .years { color: var(--muted); font-variant-numeric: tabular-nums; }
.popup p { margin: 4px 0 0; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .map-wrap { grid-row: 1; }
  .sidebar { grid-row: 2; overflow: visible; border-right: none; padding: 12px 16px; }
  .site-header, .site-footer { padding-left: 16px; padding-right: 16px; }
  html, body { height: auto; }
  .lede { font-size: 0.88rem; }
  .year-bar { bottom: 12px; }
}
