* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: #243029;
  background: #f4f1e8;
}
body { display: flex; flex-direction: column; }

header {
  height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 34px;
  background: #f4f1e8;
  border-bottom: 1px solid #d8d1c0;
  z-index: 1300;
}
h1 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 38px;
  font-weight: 500;
}
h1 a,
h1 a:visited,
h1 a:hover,
h1 a:focus {
  color: inherit;
  text-decoration: none;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #7b6848;
}
header p { margin: 4px 0; color: #667068; }
button { font: inherit; }

.header-actions { display: flex; gap: 10px; }
.menu-btn { display: none; }
header button {
  background: #2f5c4c;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
}

main {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 390px 1fr;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  height: calc(100vh - 116px);
}

.map-wrap {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-width: 0;
  height: calc(100vh - 116px);
}
#map {
  height: calc(100vh - 116px);
  width: 100%;
}

.mobile-jump-to-filters {
  display: none;
}

.control-panel {
  grid-column: 1;
  grid-row: 1;
  overflow: auto;
  padding: 20px;
  background: #fbfaf6;
  border-right: 1px solid #d8d1c0;
  height: 100%;
}
.panel-grip { display: none; }

.search { position: relative; }
.search input {
  width: 100%;
  padding: 13px 44px 13px 14px;
  border: 1px solid #cec6b3;
  border-radius: 9px;
  background: #fff;
  font-size: 15px;
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #ebe7dc;
  color: #55605a;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.search-clear:hover { background: #ddd7c8; color: #243029; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 15px 0;
}
.filters button,
.route-controls button {
  border: 1px solid #cfc7b5;
  background: #fff;
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  cursor: pointer;
}
.filters button {
  border-color: var(--filter-color, #cfc7b5);
  color: var(--filter-color, #2f5c4c);
}
.filters button.active {
  background: var(--filter-color, #2f5c4c);
  color: #fff;
  border-color: var(--filter-color, #2f5c4c);
}

.route-controls h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 20px;
  margin: 19px 0 9px;
}
.route-controls > div {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.route-controls button {
  border-color: var(--route-color, #cfc7b5);
  color: var(--route-color, #2f5c4c);
}
.route-controls button.active {
  background: var(--route-color, #2f5c4c);
  color: #fff;
  border-color: var(--route-color, #2f5c4c);
}
.route-controls .route-reset {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  font-size: 26px;
  line-height: 1;
  background: #fff;
  color: #2f5c4c;
  border: 1px solid #cfc7b5;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}
.route-controls .route-reset:hover { background: #f4f1e8; }

.list { display: grid; gap: 8px; }
.place-card {
  background: #fff;
  border: 1px solid #e1dbcd;
  border-radius: 9px;
  cursor: pointer;
  overflow: hidden;
}
.place-card.active {
  border-color: #2f5c4c;
  box-shadow: 0 0 0 2px rgba(47,92,76,.15);
}
.place-head {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 11px;
  padding: 8px;
}
.place-card.no-image .place-head {
  grid-template-columns: 1fr;
  padding: 12px;
}
.place-card img {
  width: 72px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: #e6e1d5;
}
.place-main h3 { font-size: 14px; margin: 5px 0 3px; }
.place-main span {
  font-size: 11px;
  color: #7b6848;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.place-accordion {
  border-top: 1px solid #eee6d4;
  padding: 0 12px 12px;
}
.place-accordion p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #4e5851;
}
.place-accordion .meta {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #876d3f;
}
.place-accordion .go-link {
  display: inline-block;
  margin-top: 10px;
  background: #2f5c4c;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.detail {
  position: absolute;
  z-index: 1000;
  right: 24px;
  top: 24px;
  width: min(390px, calc(100% - 48px));
  max-height: calc(100% - 48px);
  overflow: auto;
  background: #fbfaf6;
  border-radius: 14px;
  box-shadow: 0 15px 50px rgba(30,40,34,.25);
}
.hidden { display: none !important; }
.detail > button,
.modal-card > button {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  font-size: 24px;
  cursor: pointer;
}
.detail img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #ded8c9;
}
.detail.no-image img { display: none; }
.detail.no-image .detail-body { padding-top: 20px; }
.detail-body { padding: 20px; }
.detail-body span {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #876d3f;
}
.detail-body h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  margin: 8px 0 12px;
}
.detail-body p {
  line-height: 1.6;
  color: #4e5851;
  white-space: pre-line;
}
.detail a {
  display: inline-block;
  margin-top: 14px;
  background: #2f5c4c;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 15px;
}

.mobile-menu {
  position: fixed;
  right: 14px;
  top: 78px;
  z-index: 1400;
  display: grid;
  gap: 8px;
  background: #fbfaf6;
  border: 1px solid #ddd4c0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.16);
}
.mobile-menu button {
  border: 1px solid #cfc7b5;
  background: #fff;
  border-radius: 8px;
  color: #2f5c4c;
  padding: 8px 10px;
  text-align: left;
}

.modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  background: rgba(25,33,28,.55);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  position: relative;
  max-width: 760px;
  background: #fbfaf6;
  border-radius: 14px;
  padding: 32px;
  line-height: 1.6;
}
.modal-content p { margin: 0 0 14px; }

.trail-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin: 6px 0 16px;
}
.trail-item {
  background: #f3eee0;
  border: 1px solid #ddd4c0;
  border-radius: 10px;
  padding: 12px;
}
.trail-item h3 { margin: 0 0 6px; font-size: 17px; font-family: Georgia, serif; }
.trail-item p { margin: 0 0 6px; font-size: 14px; line-height: 1.45; }

.trail-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.trail-link-chip {
  border: 2px solid var(--trail, #2f5c4c);
  background: #fff;
  color: var(--trail, #2f5c4c);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.trail-link-chip:hover,
.trail-link-chip:focus-visible {
  background: var(--trail, #2f5c4c);
  color: #fff;
}
.trail-link-chip:focus-visible {
  outline: 3px solid rgba(47,92,76,.25);
  outline-offset: 2px;
}
.trail-origin-text {
  font-size: 14px;
  line-height: 1.65;
  color: #425047;
  margin: 6px 0 0;
}

.trail-origin-columns {
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 28px;
  font-size: 15px;
  line-height: 1.65;
  color: #425047;
}

.trail-origin-columns p {
  margin: 0;
}

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

.leaflet-popup-content {
  margin: 12px 28px 10px 12px;
  min-width: 0;
  max-width: 230px;
}

.popup {
  padding-top: 2px;
}

.popup-cat {
  display: block;
  margin: 0 0 3px;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #876d3f;
}

.popup h3 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 16px;
  line-height: 1.25;
  font-weight: normal;
}

.leaflet-control-attribution {
  display: none !important;
}

@media (max-width: 900px) {
  .trail-links,
  .trail-list { grid-template-columns: 1fr; }

  .trail-origin-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  header {
    position: fixed;
    top: 8px;
    left: 10px;
    right: 10px;
    height: auto;
    padding: 8px 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }

  h1 {
    display: block;
    font-size: 24px;
  }

h1 a{
    color: #412e0c;
    text-decoration: none;
}

  .eyebrow { font-size: 10px; }
  header p { display: none; }

  .route-controls h2 { display: none; }

  .filters button,
  .route-controls button {
    font-size: 11px;
    padding: 6px 9px;
  }

  .route-controls .route-reset {
    width: 32px;
    height: 32px;
    font-size: 22px;
  }

  .menu-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 22px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #2f5c4c;
    box-shadow: none;
  }

  #aboutBtn,
  #aboutTrsteniceBtn,
  #trailsBtn { display: none; }

  main { display: block; }

  .map-wrap,
  #map {
    height: 62vh;
    min-height: 380px;
  }

  .control-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 42vh;
    border-right: 0;
    border-top: 1px solid #d8d1c0;
    border-radius: 16px 16px 0 0;
    padding: 10px 14px 14px;
    box-shadow: 0 -8px 28px rgba(0,0,0,.14);
    z-index: 1200;
    background: rgba(251,250,246,.97);
    backdrop-filter: blur(3px);
  }

  .list {
    padding-top: 6px;
  }

  .panel-grip {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #ccc3af;
    margin: 2px auto 10px;
  }

  .detail { display: none !important; }

  .mobile-menu {
    right: 12px;
    top: 52px;
    background: rgba(255,255,255,.95);
    border: 1px solid #ddd4c0;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0,0,0,.12);
    padding: 6px;
    gap: 4px;
  }

  .mobile-menu button {
    border: 0;
    background: transparent;
    border-radius: 6px;
    color: #2f5c4c;
    text-align: right;
    padding: 6px 10px;
    font-size: 14px;
  }

  .leaflet-top.leaflet-left,
  .leaflet-top.leaflet-right {
    top: 66px;
  }

  .leaflet-touch .leaflet-control-zoom a {
    width: 24px !important;
    height: 24px !important;
    line-height: 22px !important;
    font-size: 18px !important;
  }

  .leaflet-bottom {
    bottom: 56px;
  }

  .leaflet-control-layers .leaflet-control-layers-toggle {
    width: 30px !important;
    height: 30px !important;
    background-size: 14px 14px !important;
  }

  .leaflet-control-layers {
    border-radius: 8px;
  }

  .mobile-jump-to-filters {
    display: grid;
    place-items: center;
    position: absolute;
    right: 10px;
    bottom: 56px;
    z-index: 1250;
    width: 30px;
    height: 30px;
    border: 1px solid #cfc7b5;
    border-radius: 8px;
    background: rgba(255,255,255,.95);
    color: #2b2b2b;
    line-height: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.14);
    padding: 0;
  }

  .mobile-jump-to-filters svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: #2b2b2b;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-jump-to-filters:active {
    transform: translateY(1px);
  }

  .modal {
    align-items: start;
    padding: 10px 12px 12px;
    overflow: auto;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 22px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 18px 16px;
  }
}
