* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; font-family: system-ui, sans-serif; }

body { display: flex; flex-direction: column; }

header {
  padding: 0.6rem 1rem;
  background: #2e5339;
  color: #fff;
}

header h1 {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.brand-logo { height: 1.6em; width: auto; flex-shrink: 0; }

.brand-sub { font-size: 0.85rem; font-weight: 400; opacity: 0.85; }

header p { font-size: 0.85rem; opacity: 0.85; }

#map { flex: 1; position: relative; }

.popup-title { font-weight: 600; font-size: 1.05em; margin-bottom: 0.3em; }

.popup-category { color: #555; font-size: 0.85em; margin-bottom: 0.5em; }

.popup-row { margin: 0.15em 0; }

.popup-row a { word-break: break-all; }

.popup-extlink { font-size: 0.8em; margin-top: 0.5em; }

.legend-about { font-size: 0.78rem; margin-top: 0.4rem; }

.legend-about a { color: #2e5339; }

#about-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
}

.about-card {
  position: relative;
  background: #fff;
  border-radius: 8px;
  max-width: 460px;
  width: calc(100% - 2rem);
  max-height: 85%;
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.about-card h2 { font-size: 1.1rem; margin-bottom: 0.6rem; }

.about-card p { margin: 0.5rem 0; }

.about-meta { color: #666; font-size: 0.8rem; }

.about-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #666;
}

.popup-warning { color: #b35900; font-size: 0.85em; }

.legend {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  background: #fff;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  font-size: 0.9rem;
  line-height: 1.7;
}

.legend label { display: flex; align-items: center; gap: 0.4em; cursor: pointer; }

#place-search {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

#search-results { max-height: 14rem; overflow-y: auto; }

.search-hit {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
}

.search-hit:hover { background: #f0f4f0; }

.search-empty { color: #888; font-size: 0.8rem; padding: 0.2rem 0.3rem; }

.legend-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.legend-tab {
  flex: 1;
  padding: 0.25rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  font-size: 0.85rem;
  cursor: pointer;
}

.legend-tab.active {
  background: #2e5339;
  border-color: #2e5339;
  color: #fff;
  font-weight: 600;
}

.maplibregl-popup-content { font-family: system-ui, sans-serif; }

.legend-sep { margin: 0.4rem 0; border: none; border-top: 1px solid #ddd; }

.legend-open { font-size: 0.85rem; flex-direction: column; align-items: flex-start; }

.legend-open select { margin-top: 0.2rem; max-width: 100%; }

.legend-open input[type="file"] { margin-top: 0.2rem; max-width: 180px; font-size: 0.75rem; }

.mode-switch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  padding: 3px;
  gap: 3px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 0.3rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

.mode-btn.active {
  background: #2e5339;
  color: #fff;
  font-weight: 600;
}

.route-panel-controls { font-size: 0.8rem; font-weight: 400; margin-top: 0.3rem; }

.route-panel-controls label { display: flex; align-items: center; gap: 0.4em; cursor: pointer; }

.corridor-range-label { flex-wrap: wrap; }

.corridor-range-label input[type="range"] { flex-basis: 100%; width: 100%; }

#corridor-km { font-weight: 600; color: #2e5339; }

.route-item-hint { color: #666; font-size: 0.8rem; padding: 0.3rem 0.2rem; }

#route-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  bottom: 10px;
  z-index: 10;
  width: 290px;
  max-width: 75%;
  overflow-y: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.route-panel-head {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #ddd;
  margin-bottom: 0.3rem;
}

.route-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35em;
  padding: 0.25rem 0.2rem;
  border-radius: 4px;
  cursor: pointer;
}

.route-item:hover { background: #f0f4f0; }

.route-km {
  font-variant-numeric: tabular-nums;
  color: #2e5339;
  font-weight: 600;
  min-width: 6.2em;
}

.route-item-name { flex: 1; }

.route-item-sub {
  flex-basis: 100%;
  padding-left: 6.9em;
  color: #666;
  font-size: 0.8rem;
}

.open-now { color: #2e7d32; font-weight: 600; }

.closed-now { color: #c62828; font-weight: 600; }

.route-remove { margin-top: 0.2rem; cursor: pointer; }

.legend .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.35);
}

/* Own-position marker: Schorle gold with brand-green ring, clearly
   distinct from the (smaller, flat, category-colored) POI dots. */
.maplibregl-user-location-dot,
.maplibregl-user-location-dot::before {
  background-color: #f0b429;
}

.maplibregl-user-location-dot,
.maplibregl-user-location-dot::before {
  width: 17px;
  height: 17px;
}

.maplibregl-user-location-dot::after {
  border: 3px solid #2e5339;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.9), 0 1px 4px rgba(0,0,0,0.4);
  width: 23px;
  height: 23px;
  left: -3px;
  top: -3px;
}

.maplibregl-user-location-accuracy-circle {
  background-color: #f0b429;
  opacity: 0.15;
}

#legend-toggle {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 11;
  padding: 0.45rem 0.8rem;
  border: none;
  border-radius: 6px;
  background: #2e5339;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  cursor: pointer;
}

/* Phones: legend collapses behind the button, route panel becomes a
   bottom sheet so the map stays usable. */
@media (max-width: 640px) {
  #legend-toggle { display: block; }

  .legend { display: none; }

  .legend.open {
    display: block;
    top: 54px;
    max-height: calc(100% - 64px);
    width: min(280px, calc(100% - 20px));
  }

  #route-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 45%;
    border-radius: 10px 10px 0 0;
  }

  header { padding: 0.4rem 0.8rem; }

  header h1 { font-size: 1.05rem; }

  header p { font-size: 0.75rem; }
}
