/* ---------- Reset / zmienne ---------- */
:root {
  --accent: #D97706;
  --accent-dark: #B45309;
  --surface: #ffffff;
  --surface-alt: #F5F5F4;
  --text: #1A1A1A;
  --text-dim: #6B6B6B;
  --border: #E2E2E0;
  --danger: #D64545;
  --radius: 14px;
  --sheet-handle-h: 54px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  color: var(--text);
  background: var(--surface-alt);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }

/* ---------- Mapa na całym ekranie ---------- */
#map {
  position: fixed; inset: 0;
  z-index: 0;
}

/* ---------- Górny pas: szukaj + chipy ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 500;
  padding: max(10px, env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.97), rgba(255,255,255,0.88) 70%, rgba(255,255,255,0));
  pointer-events: none; /* dzieci włączają z powrotem */
}
#topbar > * { pointer-events: auto; }

.search-wrap { margin-bottom: 8px; }
#search {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 23px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
#search:focus { outline: 2px solid var(--accent); }

.chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chips-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border-radius: 19px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}
.chip-more {
  background: var(--surface-alt);
  color: var(--text-dim);
}

/* ---------- Przełącznik warstw ---------- */
.layer-toggle {
  position: fixed;
  right: 10px;
  top: 118px;
  z-index: 490;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.layer-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.layer-btn.active {
  background: var(--surface-alt);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 510;
  height: 92vh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  touch-action: none;
}
.sheet.state-collapsed { transform: translateY(calc(92vh - var(--sheet-handle-h) - env(safe-area-inset-bottom, 0px))); }
.sheet.state-half      { transform: translateY(46vh); }
.sheet.state-full       { transform: translateY(0); }
.sheet.dragging { transition: none; }

.sheet-handle-wrap {
  flex: 0 0 auto;
  padding: 10px 16px 12px;
  cursor: grab;
}
.sheet-handle {
  width: 42px; height: 5px;
  margin: 0 auto 10px;
  border-radius: 3px;
  background: var(--border);
}
.sheet-summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}
.sheet-content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
  touch-action: pan-y;
}

/* ---------- Lista miejsc ---------- */
.place-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.place-list-item .dot { flex: 0 0 auto; }
.place-list-item .info { flex: 1 1 auto; min-width: 0; }
.place-list-item .name { font-weight: 600; font-size: 15px; }
.place-list-item .meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.place-list-item .chevron { color: var(--text-dim); }

.empty-state {
  padding: 32px 8px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ---------- Kolorowe znaczniki (kropki) ---------- */
.dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}

/* ---------- Chipy informacyjne (w kartach) ---------- */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: var(--surface-alt);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.tag .dot { width: 9px; height: 9px; }
.tag.muted { color: var(--text-dim); font-weight: 500; }
.tag.unverified {
  background: #FFF4E5;
  color: #92400E;
}

/* ---------- Karta miejsca (w panelu) ---------- */
.place-card-header { padding: 6px 0 4px; }
.place-card-header h2 { margin: 0 0 2px; font-size: 19px; }
.place-card-header .sub { font-size: 13px; color: var(--text-dim); }

.action-row { display: flex; gap: 10px; margin: 14px 0; }
.btn-primary, .btn-secondary, .btn-ghost {
  min-height: 44px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  padding: 0 18px;
  flex: 1 1 auto;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-icon {
  width: 40px; height: 40px;
  border: none; background: var(--surface-alt);
  border-radius: 10px; font-size: 16px;
}

.description { font-size: 14.5px; line-height: 1.5; color: var(--text); margin: 10px 0 18px; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 18px 0 8px;
}

/* ---------- Karta trasy ---------- */
.trail-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.trail-card.dimmed { opacity: 0.4; }
.trail-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.trail-card-head .name { font-weight: 600; font-size: 15px; flex: 1 1 auto; }
.trail-stats { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.trail-gpx-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.trail-gpx-btn.ready { background: var(--accent); color: #fff; }
.trail-gpx-btn.missing {
  background: var(--surface-alt);
  color: var(--text-dim);
  pointer-events: none;
}

/* ---------- Przycisk powrotu w panelu szczegółu ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  background: none; border: none;
  padding: 6px 2px;
  margin-bottom: 4px;
}

/* ---------- Panel filtrów (overlay pełnoekranowy) ---------- */
.overlay {
  position: fixed; inset: 0;
  z-index: 600;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.overlay.hidden { display: none; }
.overlay-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--border);
}
.overlay-header h2 { margin: 0; font-size: 20px; }
.overlay-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 16px; }
.overlay-footer {
  display: flex; gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

.filter-group { margin-bottom: 22px; }
.filter-group .section-title { margin-top: 0; }
.filter-options { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-option {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-option.active { background: var(--accent); color: #fff; border-color: var(--accent-dark); }

.range-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.range-row input[type=number] {
  width: 72px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
}

/* ---------- Leaflet drobne poprawki ---------- */
.leaflet-control-attribution { font-size: 10px; }
.place-marker-icon {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.plan-marker-icon {
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.marker-cluster-custom {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.is-unverified { filter: saturate(0.75); }

@media (min-width: 720px) {
  #topbar { padding-left: 24px; padding-right: 24px; max-width: 480px; }
  .sheet { left: 16px; max-width: 420px; border-radius: 18px; bottom: 16px; height: 80vh; box-shadow: 0 4px 24px rgba(0,0,0,0.22); }
  .sheet.state-collapsed { transform: translateY(calc(80vh - var(--sheet-handle-h))); }
  .sheet.state-half { transform: translateY(40vh); }
  .sheet.state-full { transform: translateY(0); }
  .layer-toggle { top: 130px; }
}
