:root {
  color-scheme: light;
  --bg: #f3efe2;
  --panel: rgba(253, 250, 240, 0.88);
  --panel-border: rgba(78, 62, 36, 0.15);
  --ink: #2e2619;
  --muted: #64563f;
  --accent: #466b45;
  --accent-soft: #cedbbf;
  --shadow: 0 24px 80px rgba(60, 44, 22, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 30%),
    linear-gradient(135deg, #e7e0c7 0%, #f7f3e8 50%, #e4ead9 100%);
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
  gap: 1rem;
  padding: 1rem;
}

.panel {
  padding: 1.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1 {
  margin: 0.4rem 0 1rem;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  line-height: 0.95;
}

.intro,
.notes {
  color: var(--muted);
  line-height: 1.5;
}

.legend {
  display: grid;
  gap: 0.65rem;
  margin: 1.5rem 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.legend-swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.notes h2 {
  margin-bottom: 0.6rem;
  color: var(--ink);
  font-size: 1rem;
}

pre {
  margin: 0;
  padding: 0.9rem;
  overflow-x: auto;
  border-radius: 16px;
  background: rgba(70, 107, 69, 0.08);
}

code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.86rem;
}

main,
.map-frame {
  min-width: 0;
}

.map-frame {
  position: relative;
}

#map {
  min-height: calc(100vh - 2rem);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.maplibregl-popup-content {
  border-radius: 14px;
}

.maplibregl-popup-content {
  font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", serif;
}

.map-status {
  position: absolute;
  z-index: 2;
  top: 1rem;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: rgba(253, 250, 240, 0.94);
  box-shadow: 0 8px 24px rgba(60, 44, 22, 0.16);
}

.map-status[hidden] {
  display: none;
}

.timeline-control {
  display: grid;
  gap: 0.45rem;
  min-width: 12rem;
  padding: 0.7rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(253, 250, 240, 0.94);
  box-shadow: 0 12px 36px rgba(60, 44, 22, 0.16);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", serif;
}

.timeline-control-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.timeline-buttons {
  display: grid;
  gap: 0.35rem;
}

.timeline-buttons button {
  width: 100%;
  border: 1px solid rgba(70, 107, 69, 0.28);
  border-radius: 6px;
  padding: 0.42rem 0.55rem;
  background: #fffdf6;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.timeline-buttons button:hover,
.timeline-buttons button:focus-visible {
  border-color: rgba(70, 107, 69, 0.58);
  outline: none;
}

.timeline-buttons button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.error-overlay {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10000;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(28rem, calc(100vh - 2rem));
  overflow: auto;
  border: 1px solid rgba(111, 23, 23, 0.32);
  border-radius: 8px;
  background: #fff7f4;
  box-shadow: 0 18px 60px rgba(59, 20, 20, 0.22);
  color: #331514;
}

.error-overlay[hidden] {
  display: none;
}

.error-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(111, 23, 23, 0.18);
  background: #f6d5ce;
}

.error-overlay-actions {
  display: flex;
  gap: 0.45rem;
}

.error-overlay button {
  border: 1px solid rgba(111, 23, 23, 0.28);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  background: #fffaf8;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.error-overlay pre {
  margin: 0;
  border-radius: 0;
  background: transparent;
  white-space: pre-wrap;
}

.error-overlay-copy-buffer {
  position: fixed;
  top: -100vh;
  left: -100vw;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  #map {
    min-height: 65vh;
  }
}
