:root {
  --color-primary: #2f7d4f;
  --color-primary-dark: #235f3c;
  --color-accent: #d97706;
  --color-bg: #f7f7f5;
  --color-surface: #ffffff;
  --color-text: #1f2521;
  --color-muted: #6b7269;
  --color-border: #e2e4df;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0,0,0,0.12);
  --topbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* Topbar */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 12px;
  padding-right: 12px;
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.brand-icon { font-size: 1.3rem; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

@media (max-width: 420px) {
  .brand-name { display: none; }
  .topbar-actions { gap: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .auth-area .btn { padding: 8px 10px; font-size: 0.82rem; }
}

.icon-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--color-bg); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover { background: var(--color-bg); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger { background: #b3261e; color: #fff; }

.auth-area { display: flex; align-items: center; gap: 8px; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; font-size: 0.9rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Filter panel */
.filter-panel {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top));
  left: 0; right: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 12px;
  z-index: 999;
  box-shadow: var(--shadow);
}
.filter-row { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-row:last-child { margin-bottom: 0; }
.filter-label { font-size: 0.85rem; color: var(--color-muted); font-weight: 600; }

#searchInput {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.chip-mine.active { background: var(--color-accent); border-color: var(--color-accent); }

/* Map */
#map {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
}

.leaflet-marker-icon.spot-marker-picknick { filter: hue-rotate(0deg); }

.map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--color-primary);
  box-shadow: var(--shadow);
  border: 2px solid #fff;
}
.map-pin span { transform: rotate(45deg); font-size: 1rem; }
.map-pin.cat-pinkelpause { background: #2563eb; }
.map-pin.cat-sonstiges { background: var(--color-accent); }

.locate-pulse {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37,99,235,0.25);
}

/* FAB */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(24px + var(--safe-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 900;
}
.fab:active { transform: scale(0.95); }

/* List toggle (mobile) */
.list-toggle {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 900;
}

/* Sidebar / bottom sheet */
.sidebar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 70vh;
  background: var(--color-surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 950;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
.sidebar.open { transform: translateY(0); }

.sidebar-handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 10px auto 4px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-header h2 { font-size: 1.05rem; margin: 0; }
.spot-count { color: var(--color-muted); font-weight: 400; font-size: 0.85rem; }

.spot-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}
.spot-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.spot-list-item:hover { background: var(--color-bg); }
.spot-list-icon { font-size: 1.4rem; flex-shrink: 0; }
.spot-list-main { flex: 1; min-width: 0; }
.spot-list-title { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-list-meta { font-size: 0.78rem; color: var(--color-muted); }
.spot-list-empty { padding: 24px; text-align: center; color: var(--color-muted); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  padding: 0;
}
.modal {
  background: var(--color-surface);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  position: relative;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal-large { max-width: 640px; }

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--color-bg);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 1rem;
}

.modal h2 { margin-top: 0; margin-bottom: 12px; font-size: 1.2rem; padding-right: 30px; }

.modal label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 12px;
}
.modal input[type=text], .modal input[type=email], .modal input[type=password], .modal input[type=search], .modal select, .modal textarea, .modal input[type=file] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
}
.modal textarea { resize: vertical; }

.category-fieldset { border: 1px solid var(--color-border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.category-fieldset legend { font-size: 0.85rem; font-weight: 600; color: var(--color-muted); padding: 0 4px; }
.radio-label { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; color: var(--color-text); margin-right: 14px; }
.radio-label input { width: auto; margin: 0; }

.coords-hint { font-size: 0.85rem; color: var(--color-muted); margin-top: -8px; margin-bottom: 12px; }

.form-error {
  color: #b3261e;
  font-size: 0.85rem;
  margin: 0 0 10px;
  min-height: 0;
}
.form-error:empty { display: none; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--color-primary); border-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.field-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--color-muted); margin-bottom: 8px; }

.photo-picker { display: flex; gap: 10px; margin-bottom: 16px; }
.photo-tile {
  position: relative;
  width: 84px; height: 84px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.photo-tile-add {
  border: 2px dashed var(--color-border);
  background: var(--color-bg);
  color: var(--color-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 0;
}
.photo-tile-add:hover { background: var(--color-border); }
.photo-tile-add-icon { font-size: 1.6rem; line-height: 1; }
.photo-tile-add-label { font-size: 0.68rem; font-weight: 600; }
.photo-picker-hint { font-size: 0.78rem; color: var(--color-muted); margin: -10px 0 16px; }

/* Spot detail */
.spot-detail-photos { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; scroll-snap-type: x mandatory; }
.spot-detail-photos img { width: 100%; max-width: 100%; flex: 0 0 100%; scroll-snap-align: start; border-radius: 10px; object-fit: cover; max-height: 320px; }
.spot-detail-photos.single img { flex-basis: 100%; }

.spot-detail-badges { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.badge { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; }

.spot-detail-desc { white-space: pre-wrap; margin-bottom: 14px; line-height: 1.45; }
.spot-detail-meta { font-size: 0.82rem; color: var(--color-muted); margin-bottom: 16px; }
.spot-detail-owner-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.spot-detail-owner-actions .btn { flex: 1; }

.comments-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 10px; }
.comment-item { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.comment-author { font-weight: 600; font-size: 0.85rem; }
.comment-date { font-size: 0.75rem; color: var(--color-muted); margin-left: 6px; }
.comment-body { font-size: 0.9rem; margin-top: 2px; white-space: pre-wrap; }
.comment-empty { color: var(--color-muted); font-size: 0.88rem; padding: 8px 0; }

.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form textarea { flex: 1; min-height: 40px; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 8px; font-family: inherit; resize: vertical; }
.comment-login-hint { font-size: 0.85rem; color: var(--color-muted); margin-top: 12px; }

.loading { text-align: center; color: var(--color-muted); padding: 30px 0; }

/* Hilfe */
.help-content h3 { font-size: 0.98rem; margin: 18px 0 6px; }
.help-content h3:first-child { margin-top: 0; }
.help-content p { margin: 0 0 4px; font-size: 0.9rem; line-height: 1.5; color: var(--color-text); }

/* Landing page */
.landing {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top));
  left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--color-bg), var(--color-surface));
  padding: 36px 20px calc(48px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 40px;
  z-index: 500;
}
.landing-hero { max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.landing-icon { font-size: 2.8rem; }
.landing-hero h1 { margin: 0; font-size: 2rem; }
.landing-tagline { color: var(--color-muted); font-size: 1.02rem; margin: 0; line-height: 1.5; }
.landing-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.btn-lg { padding: 13px 24px; font-size: 1rem; border-radius: 10px; }
.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.88rem;
  margin-top: 2px;
  padding: 4px;
}

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  width: 100%;
}
.feature {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
}
.feature > span { font-size: 1.5rem; flex-shrink: 0; }
.feature strong { display: block; margin-bottom: 2px; font-size: 0.95rem; }
.feature p { margin: 0; font-size: 0.84rem; color: var(--color-muted); }

@media (min-width: 700px) {
  .landing-features { flex-direction: row; }
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2521;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 3000;
  box-shadow: var(--shadow);
}

/* Desktop layout */
@media (min-width: 900px) {
  .list-toggle { display: none; }

  .sidebar {
    top: calc(var(--topbar-h) + var(--safe-top) + 12px);
    left: 12px;
    right: auto;
    bottom: 12px;
    width: 340px;
    max-height: none;
    transform: translateX(-120%);
    border-radius: 16px;
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-handle { display: none; }

  .filter-panel {
    left: 12px;
    right: auto;
    width: 340px;
    border-radius: 12px;
    margin-top: 8px;
    border: 1px solid var(--color-border);
  }

  .modal-backdrop { align-items: center; }
  .modal { border-radius: 16px; }

  .fab { right: 24px; bottom: 24px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #141815;
    --color-surface: #1c211d;
    --color-text: #eef0ec;
    --color-muted: #9aa39a;
    --color-border: #2c332c;
  }
  .modal-close { background: #262c26; }
}
