:root {
  --panel-bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e2e2e2;
  --accent: #2563eb;
  --tabbar-height: calc(56px + env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }
button { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

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

/* Keep Leaflet's bottom-corner controls above the tab bar */
.leaflet-bottom {
  bottom: var(--tabbar-height) !important;
}

.leaflet-marker-icon.user-location-icon {
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.5));
}

/* Selected-route highlight: pulses a few times to draw the eye, then settles solid */
@keyframes route-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.route-highlight-pulse {
  animation: route-pulse 0.8s ease-in-out 3;
}

/* Controls */
#controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#locate-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--panel-bg);
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
  font-size: 20px;
  cursor: pointer;
}
#locate-btn:active { transform: scale(0.95); }
#locate-btn.active { background: var(--accent); }

/* Bottom tab bar */
#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabbar-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 1500;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.1);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0 0;
}
.tab-btn .tab-icon { font-size: 21px; line-height: 1; }
.tab-btn.active { color: var(--accent); font-weight: 700; }

/* Strecken / POIs: a bottom sheet over the always-visible map (not a
   full-screen swap) - so picking a route/POI still leaves the map, with its
   highlight and lift markers, visible above the sheet at the same time. */
.tab-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--tabbar-height);
  height: min(42vh, 420px);
  background: var(--panel-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 14px rgba(0,0,0,0.18);
  z-index: 1200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.tab-content.active { display: flex; }

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #ddd;
  margin: 8px auto 0;
  flex-shrink: 0;
}

/* Keep Leaflet's bottom-corner controls above whichever sheet is open */
body.sheet-open .leaflet-bottom {
  bottom: calc(min(42vh, 420px) + var(--tabbar-height)) !important;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chip {
  --chip-color: #666;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 2px solid var(--chip-color);
  background: #fff;
  color: var(--chip-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chip.active {
  background: var(--chip-color);
  color: #fff;
}
.chip:active { transform: scale(0.97); }

.list {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.list-item:active { background: #f5f5f5; }
.list-item.selected { background: #eff6ff; }
.list-item .swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.list-item .icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .title {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .info .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.list-item .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.list-item .chevron { color: #ccc; font-size: 20px; flex-shrink: 0; }

/* Side panel (route/lift/POI detail) */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 380px;
  max-width: 92vw;
  background: var(--panel-bg);
  box-shadow: -2px 0 12px rgba(0,0,0,0.2);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 2000;
  overflow-y: auto;
}
#panel.open { transform: translateX(0); }

#panel-header {
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
#panel-header h1 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 600; }
#panel-close { border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }

#panel-body { padding: 16px; padding-bottom: calc(16px + var(--tabbar-height)); }
#panel-body h2 { margin: 0 0 6px; font-size: 20px; }
#panel-body .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-right: 6px;
  margin-bottom: 8px;
}
#panel-body .stats {
  display: flex;
  gap: 16px;
  margin: 12px 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
#panel-body .stat { text-align: center; flex: 1; }
#panel-body .stat b { display: block; font-size: 16px; }
#panel-body .stat span { font-size: 11px; color: var(--muted); }
#panel-body p { line-height: 1.5; color: #333; font-size: 14px; }
#panel-body .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
#panel-body .tag { background: #f0f0f0; border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--muted); }
#panel-body .gallery { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0; }
#panel-body .gallery img { height: 90px; border-radius: 8px; flex-shrink: 0; }
#panel-body .hours { font-size: 13px; color: var(--muted); margin-top: 8px; }
#panel-body .status-line { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

@media (max-width: 600px) {
  #panel { width: 100%; }
}
