:root {
  --bg: #efe6d3;
  --bg-strong: #ddc7a1;
  --panel: rgba(255, 251, 244, 0.86);
  --panel-border: rgba(100, 72, 37, 0.18);
  --ink: #1f1f1b;
  --muted: #655c4b;
  --accent: #934a24;
  --accent-2: #2f6f62;
  --shadow: 0 24px 60px rgba(71, 44, 8, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
  --history: #8d5032;
  --architecture: #4c6f82;
  --culture: #6d4e91;
  --road: #345b4c;
  --art: #ab6b2e;
  --transit: #8b3f5b;
  --other: #6f6a5b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 34%),
    radial-gradient(circle at bottom right, rgba(147, 74, 36, 0.18), transparent 28%),
    linear-gradient(135deg, #f4ead8 0%, #e7d0a8 50%, #e5c796 100%);
}

body {
  padding:
    max(12px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(102, 79, 49, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 79, 49, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at center, black 50%, transparent 90%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(100%, 1360px);
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.control-card,
.map-panel,
.list-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero-copy {
  padding: 24px;
}

.hero-copy::after,
.control-card::after {
  position: absolute;
  inset: auto -50px -50px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(147, 74, 36, 0.22), transparent 70%);
  content: "";
}

.eyebrow,
.panel-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.05;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.3rem, 10vw, 4.6rem);
}

.hero-text {
  max-width: 62ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.65;
}

.control-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.control-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.control-card input {
  border: 1px solid rgba(77, 57, 35, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  padding: 13px 14px;
  color: var(--ink);
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.button-row > * {
  flex: 1 1 180px;
}

.primary-btn,
.secondary-btn,
.card-focus {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.primary-btn,
.secondary-btn {
  padding: 12px 18px;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(135deg, #a65426, #7d3412);
  color: #fff7f0;
  box-shadow: 0 12px 24px rgba(147, 74, 36, 0.24);
}

.secondary-btn {
  background: rgba(46, 101, 90, 0.12);
  color: var(--accent-2);
}

.primary-btn:hover,
.secondary-btn:hover,
.card-focus:hover {
  transform: translateY(-1px);
}

.hint,
.status,
.empty-copy,
.loading-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.map-panel,
.list-panel {
  min-height: auto;
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.legend-chip,
.card-badge,
.card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-chip {
  border: 1px solid rgba(80, 56, 24, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

#map {
  width: 100%;
  height: min(56vh, 520px);
  min-height: 360px;
  border-radius: 22px;
  overflow: hidden;
}

.list-panel {
  display: flex;
  flex-direction: column;
}

.results {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
  max-height: 48vh;
  overscroll-behavior: contain;
}

.fact-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(89, 63, 34, 0.12);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
}

.card-focus {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(0, 0, 0, 0.045);
  color: var(--ink);
}

.card-focus {
  width: 100%;
  justify-content: space-between;
}

.card-title {
  font-size: 1.48rem;
}

.card-fact {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.62;
}

.card-detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.card-meta,
.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-meta-item {
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
}

.card-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.card-links a:hover {
  text-decoration: underline;
}

.empty-state,
.loading-state {
  padding: 26px;
  border: 1px dashed rgba(87, 62, 35, 0.22);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.38);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #fffaf2;
  color: var(--ink);
}

.popup-title {
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
}

.popup-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
}

@media (min-width: 960px) {
  .hero,
  .workspace {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .hero {
    grid-template-columns: 1.2fr 0.9fr;
  }

  #map {
    height: 610px;
    min-height: 610px;
  }

  .results {
    max-height: 610px;
  }

  .hero-copy {
    padding: 34px;
  }

  .control-card {
    padding: 26px;
  }

  .map-panel,
  .list-panel {
    padding: 20px;
  }
}

@media (max-width: 720px) {
  .hero-copy,
  .control-card,
  .map-panel,
  .list-panel {
    border-radius: 24px;
  }

  .hero-copy,
  .control-card,
  .map-panel,
  .list-panel {
    padding: 18px;
  }

  #map {
    height: 52vh;
    border-radius: 20px;
  }

  h1 {
    max-width: 100%;
  }

  .hero-text {
    font-size: 0.98rem;
  }

  .panel-head {
    flex-direction: column;
  }

  .results {
    max-height: none;
  }
}
