:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #fffdf8;
  --ink: #1f1a14;
  --muted: #5c5348;
  --line: #e2d8c8;
  --accent: #9a3412;
  --shadow: 0 12px 40px rgba(31, 26, 20, 0.08);
  font-family: "Source Sans 3", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  overflow: hidden;
}

h1,
h2,
h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  line-height: 1.15;
}

a {
  color: var(--accent);
}

#app {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 1rem clamp(1rem, 3vw, 2.5rem) 0.85rem;
  border-bottom: none;
  background: linear-gradient(180deg, #fffdf8 0%, var(--bg) 100%);
}

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

.topbar h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
}

.lede {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 0.65rem clamp(1rem, 3vw, 2.5rem) 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.filter-bar .search {
  flex: 1 1 10rem;
  max-width: 16rem;
}

.filter-bar .search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.filter-bar .toggle {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}

.filter-bar .era-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  flex: 1 1 100%;
}

@media (min-width: 901px) {
  .filter-bar .era-filters {
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}

.filter-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.15rem;
}

.filter-bar .chip {
  display: inline-flex;
  margin: 0;
  font-size: 0.82rem;
}

.sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.sidebar-count {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
  color: var(--accent);
  white-space: nowrap;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0.75rem 1rem 0.5rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.search input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  font: inherit;
  background: #fff;
}

.toggle {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.92rem;
  color: var(--muted);
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chip span::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--chip);
}

.sidebar-note,
.footer {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.site-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.65rem 0 0.5rem;
}

.site-card {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.site-card:hover,
.site-card.is-active {
  border-color: #c4a574;
  box-shadow: var(--shadow);
}

.site-card header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.site-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.meta {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.site-card p {
  margin: 0.35rem 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.visit {
  font-size: 0.88rem;
}

.sources {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.wiki {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.focus-map {
  margin-top: 0.65rem;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.focus-map:hover {
  border-color: var(--accent);
}

.era-badge {
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.map-panel {
  position: relative;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
}

.map-reset {
  position: absolute;
  z-index: 500;
  top: 0.75rem;
  right: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow);
}

.map-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.map-legend {
  position: absolute;
  z-index: 500;
  left: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  padding: 0.55rem 0.75rem;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  max-width: calc(100% - 1.5rem);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.map-legend i {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  font-style: normal;
}

.footer {
  padding: 0.85rem clamp(1rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line);
}

.heritage-marker-wrap {
  background: transparent;
  border: none;
}

.heritage-marker {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--marker);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.heritage-marker.is-selected {
  width: 22px;
  height: 22px;
  border-width: 3px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  #app {
    height: 100dvh;
  }

  .topbar,
  .filter-bar,
  .sidebar,
  .footer {
    display: none;
  }

  .layout {
    display: flex;
    flex: 1;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
    min-height: 0;
  }

  .map-panel {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .map-legend {
    font-size: 0.65rem;
    left: 0.5rem;
    bottom: max(0.5rem, env(safe-area-inset-bottom));
    max-width: calc(100% - 1rem);
  }

  .map-reset {
    top: max(0.5rem, env(safe-area-inset-top));
    right: 0.5rem;
  }
}

.mobile-site-panel {
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.mobile-site-panel:not([hidden]) {
  pointer-events: auto;
}

.mobile-site-panel[hidden] {
  display: none;
}

.mobile-site-panel__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(31, 26, 20, 0.45);
  cursor: pointer;
}

.mobile-site-panel__sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(72vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-radius: 1rem 1rem 0 0;
  padding: 0.75rem 1rem max(1.25rem, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(31, 26, 20, 0.15);
}

.mobile-site-panel__close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 2;
  margin: 0 0 0.25rem 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.mobile-site-panel__close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mobile-site-panel .site-card {
  border: none;
  padding: 0.25rem 0 0;
  box-shadow: none;
  cursor: default;
}

@media (min-width: 901px) {
  .mobile-site-panel {
    display: none !important;
  }
}
