:root {
  --bg: #f5f2ea;
  --ink: #1f1e19;
  --accent: #c55d2d;
  --accent-2: #2f6f63;
  --line: #dfd6c8;
  --panel: rgba(255, 252, 246, 0.93);
  --shadow: 0 14px 40px rgba(47, 31, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #efe9dc 0%, #f6f1e5 38%, #e6edea 100%);
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 10%, rgba(197, 93, 45, 0.11), transparent 40%),
    radial-gradient(circle at 88% 20%, rgba(47, 111, 99, 0.1), transparent 36%),
    radial-gradient(circle at 60% 90%, rgba(197, 93, 45, 0.08), transparent 42%);
}

.shell {
  position: relative;
  width: min(1280px, 94vw);
  margin: 24px auto 28px;
  display: grid;
  gap: 18px;
}

.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 20px;
  padding: 26px 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent-2);
}

h1,
h2 {
  margin: 0;
  font-family: 'Newsreader', serif;
  font-weight: 700;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.hero p {
  margin: 12px 0 0;
  max-width: 80ch;
  line-height: 1.5;
}

.meta {
  margin-top: 14px;
  font-size: 0.92rem;
  color: #44423a;
}

.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.controls > label,
.controls .facet,
.controls button {
  margin: 0;
}

.controls label,
.controls fieldset {
  display: grid;
  gap: 4px;
  font-size: 0.83rem;
  color: #333126;
}

.controls input,
.controls select {
  width: 100%;
  border-radius: 9px;
  border: 1px solid #cfc3b2;
  background: #fffdf9;
  color: #1e1c15;
  padding: 7px 9px;
  font: inherit;
}

.controls input:focus,
.controls select:focus {
  outline: 2px solid rgba(47, 111, 99, 0.35);
  border-color: var(--accent-2);
}

.control-search {
  grid-column: span 1;
}

.control-compact {
  min-width: 0;
}

.distance-control {
  grid-column: span 2;
}

.distance-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 1px;
}

.distance-inline input {
  min-width: 0;
}

.distance-inline::before {
  content: 'Min / Max';
  grid-column: 1 / -1;
  margin-bottom: -1px;
  font-size: 0.72rem;
  display: flex;
  color: #4c483d;
}

.facet {
  border: 1px solid #d7cbba;
  border-radius: 12px;
  padding: 8px 9px 10px;
  min-height: 0;
}

.facet legend {
  padding: 0 6px;
  font-size: 0.83rem;
  color: #333126;
}

.facet-full {
  grid-column: span 6;
}

.facet-half {
  grid-column: span 3;
}

.facet-hint {
  margin: 1px 1px 6px;
  font-size: 0.76rem;
  color: #5a5548;
  line-height: 1.25;
}

.pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 7px;
  align-content: start;
}

.pill-grid-scroll {
  max-height: 128px;
  overflow: auto;
  padding-right: 2px;
}

.facet-pill {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #cdbda8;
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 10px;
  background: #fff;
  color: #2b291f;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.facet-pill:hover {
  border-color: #bca88d;
}

.facet-pill.is-active {
  background: color-mix(in srgb, var(--pill-tone, var(--accent-2)) 20%, #fff);
  border-color: color-mix(in srgb, var(--pill-tone, var(--accent-2)) 72%, #8f8374);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill-tone, var(--accent-2)) 58%, #8f8374);
}

.pill-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-count {
  font-size: 0.73rem;
  border-radius: 999px;
  border: 1px solid #cdbda8;
  padding: 0 7px;
  line-height: 1.35;
  background: #f7f1e7;
  flex: 0 0 auto;
}

.pill-empty {
  grid-column: 1 / -1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px dashed #ccbda8;
  background: #fffdf9;
  font-size: 0.84rem;
  color: #4b463b;
}

.facet.is-locked .pill-grid {
  display: none;
}

.facet:not(.is-locked) .facet-hint {
  display: none;
}

#clearFilters {
  align-self: end;
  grid-column: span 1;
  border-radius: 10px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), #d18447);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

#clearFilters:hover {
  filter: brightness(1.05);
}

.content {
  display: grid;
  grid-template-columns: minmax(280px, 1.3fr) minmax(290px, 1fr);
  gap: 18px;
}

.map-wrap,
.list-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.map-wrap {
  position: relative;
  padding: 10px;
}

.map-legend {
  position: absolute;
  z-index: 550;
  top: 18px;
  right: 18px;
  min-width: 160px;
  border-radius: 10px;
  border: 1px solid #d7cbba;
  background: rgba(255, 252, 246, 0.96);
  padding: 9px 10px;
  font-size: 0.82rem;
  color: #2f2b24;
  box-shadow: 0 4px 12px rgba(34, 29, 22, 0.12);
}

.map-legend p {
  margin: 0 0 6px;
  font-weight: 700;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.9);
}

#map {
  height: min(75vh, 720px);
  border-radius: 14px;
}

.list-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.results-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid #e2d8c8;
}

.results-header p {
  margin: 7px 0 0;
  color: #4b473c;
  font-size: 0.9rem;
}

#eventList {
  margin: 0;
  padding: 6px 10px 14px;
  list-style: none;
  overflow: auto;
  max-height: min(72vh, 690px);
}

.card {
  border: 1px solid #e2d8c8;
  border-radius: 12px;
  background: #fffefb;
  margin: 8px 0;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.card h3 {
  margin: 0;
  font-size: 1.03rem;
  line-height: 1.25;
}

.card h3 button {
  border: none;
  background: transparent;
  color: #133a35;
  text-align: left;
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.card h3 button:hover {
  text-decoration: underline;
}

.card .meta-line {
  font-size: 0.86rem;
  color: #3d3a31;
}

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

.tag {
  border-radius: 999px;
  background: #efe8da;
  color: #39362f;
  font-size: 0.74rem;
  padding: 3px 8px;
}

.card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #302f29;
}

.card a {
  color: var(--accent-2);
  font-size: 0.86rem;
  font-weight: 700;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
}

.popup-title {
  font-size: 0.96rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.popup-meta {
  font-size: 0.82rem;
  color: #403b33;
  margin-bottom: 8px;
}

@media (max-width: 1080px) {
  .controls {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .distance-control {
    grid-column: span 2;
  }

  .facet-full,
  .distance-control,
  .facet-half,
  #clearFilters {
    min-width: 0;
  }

  .facet-full {
    grid-column: span 4;
  }

  .facet-half,
  #clearFilters {
    grid-column: span 2;
  }

  .content {
    grid-template-columns: 1fr;
  }

  #map {
    height: 54vh;
  }

  #eventList {
    max-height: 50vh;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(96vw, 640px);
    margin-top: 12px;
  }

  .hero,
  .controls,
  .map-wrap,
  .list-wrap {
    border-radius: 14px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .controls > label,
  .facet-full,
  .facet-half,
  #clearFilters {
    grid-column: span 1;
  }

  .distance-control,
  .control-search {
    grid-column: span 1;
  }

  .pill-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  }

  .map-legend {
    position: static;
    margin: 0 0 10px;
  }
}
