:root {
  --paper: #f7f5f0;
  --ink: #211f1b;
  --muted: #6d675e;
  --line: #ddd7cb;
  --playground: #d9504a;
  --park: #2f7d4f;
  --shadow: 0 2px 10px rgba(40, 34, 24, 0.12);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--paper);
}

/* --- Kopfleiste ------------------------------------------------------- */

#bar {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

#bar > * { pointer-events: auto; }

.title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 2px 8px 6px;
  color: var(--ink);
  text-shadow: 0 1px 0 var(--paper);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(247, 245, 240, 0.72);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.chip[aria-pressed="false"] {
  opacity: 0.62;
}

.chip:hover { border-color: var(--line); }
.chip:focus-visible, #share:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.swatch.circle { border-radius: 50%; background: var(--playground); }
.swatch.square { border-radius: 1px; background: var(--park); }
.swatch.drop {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #2f7f9e;
}
.swatch.diamond {
  width: 9px;
  height: 9px;
  border-radius: 1px;
  transform: rotate(45deg);
  background: #7a5aa6;
}
.swatch.rect {
  width: 12px;
  height: 8px;
  border-radius: 1px;
  background: #b07a2a;
}
.swatch.ring {
  width: 11px;
  height: 11px;
  border: 3px solid #3f7d78;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}
.swatch.line {
  width: 14px;
  height: 0;
  border: 0;
  border-top: 2px dashed var(--playground);
  box-shadow: none;
}

#share {
  margin-left: auto;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

#filters-toggle {
  display: none;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

#share.copied { background: var(--ink); color: var(--paper); }

/* --- Status ----------------------------------------------------------- */

.status {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(33, 31, 27, 0.9);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
  transition: opacity 200ms ease;
}

.status[hidden] { display: none; }
.status.error { background: #7d2b26; max-width: min(420px, calc(100vw - 32px)); border-radius: 14px; }

/* --- Fußzeile --------------------------------------------------------- */

#footer {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 6px 18px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 8px 14px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(247, 245, 240, 0.97) 55%, rgba(247, 245, 240, 0.75));
  border-top: 1px solid rgba(221, 215, 203, 0.7);
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

#footer a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
#stand { white-space: nowrap; }
#stand.stale { color: #9a3b2f; font-weight: 600; }

/* --- Popup ------------------------------------------------------------ */

.maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: inherit;
  color: var(--ink);
  min-width: 180px;
}

.maplibregl-popup-close-button {
  font-size: 18px;
  padding: 2px 7px;
  color: var(--muted);
}

/* Karten-Bedienelemente über der Fußzeile halten */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  bottom: 38px;
}

@media (max-width: 720px) {
  .maplibregl-ctrl-bottom-right,
  .maplibregl-ctrl-bottom-left {
    bottom: 52px;
  }
}

.poi h2 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 650;
  padding-right: 14px;
}

.poi .kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.poi .kind::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--playground));
}

.poi .kind.square::before { border-radius: 1px; }

.poi .source {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.poi dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0;
  font-size: 12px;
}

.poi dt { color: var(--muted); }
.poi dd { margin: 0; font-variant-numeric: tabular-nums; }

/* --- Mobil ------------------------------------------------------------ */

@media (max-width: 720px) {
  #bar {
    gap: 6px;
    left: 8px;
    right: 8px;
    top: max(8px, env(safe-area-inset-top));
  }

  .title { display: none; }

  .chips {
    display: none;
    order: 2;
    width: 100%;
    flex-wrap: wrap;
    padding-bottom: 2px;
  }
  #bar.filters-open .chips { display: flex; }

  #filters-toggle { display: inline-flex; align-items: center; order: 1; height: 32px; }
  #share { order: 1; margin-left: auto; height: 32px; }
  .chip { height: 32px; }

  #footer { font-size: 10px; padding: 7px 10px max(7px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- Filter-Zusätze --------------------------------------------------- */

.chip.control { cursor: default; gap: 5px; }
.chip.control.hidden { display: none; }
.chip.control select {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 0 2px;
}
.swatch.star {
  width: auto;
  height: auto;
  border: 0;
  box-shadow: none;
  color: #b07a2a;
  font-size: 14px;
  line-height: 1;
}

/* --- Detailkarte / Bottom-Sheet --------------------------------------- */

.detail {
  position: absolute;
  z-index: 8;
  right: 16px;
  bottom: 92px;
  width: 330px;
  max-height: calc(100% - 150px);
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(40, 34, 24, 0.18);
  transform: translateY(calc(100% + 90px));
  transition: transform 220ms ease;
  pointer-events: none;
}

.detail.open { transform: none; pointer-events: auto; }
.detail-handle { display: none; }

.detail h2 {
  margin: 0 32px 4px 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 650;
}

.detail .kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail .kind::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--playground));
}
.detail .kind.square::before { border-radius: 1px; }

.detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  margin: 0;
  font-size: 13px;
}
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-variant-numeric: tabular-nums; }

.detail .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.detail button {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.detail button.favorite[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.detail button.close { margin-left: auto; border-color: transparent; color: var(--muted); }

.detail .source {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink);
  text-underline-offset: 2px;
}

@media (max-width: 720px) {
  .detail {
    left: 8px;
    right: 8px;
    bottom: 0;
    width: auto;
    max-height: 62vh;
    border-radius: 16px 16px 0 0;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(110%);
  }
  .detail.open { transform: none; }
  .detail-handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 2px;
    background: var(--line);
  }
  .detail h2 { font-size: 17px; }
}

/* --- Leerer Zustand --------------------------------------------------- */

.empty {
  position: absolute;
  z-index: 7;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(300px, calc(100vw - 32px));
  padding: 16px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(40, 34, 24, 0.16);
  text-align: center;
}
.empty p { margin: 0 0 10px; font-size: 14px; }
.empty button {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
