@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* =========================================================
   GEMEINSAMES DESIGN SYSTEM
   ========================================================= */

:root {
  /* SCHRIFTEN */
  --font-primary: 'Inter', Arial, sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* FARBEN */
  --color-cream: #FAF4E3;
  --color-sage: #9DAF99;
  --color-sage-light: #D8DFD6;
  --color-dark: #344238;
  --color-text-secondary: #586158;
  --color-accent: #C45C60;
  --color-accent-hover: #A9474B;

  /* HINTERGRÜNDE */
  --color-bg-base: var(--color-cream);
  --color-bg-panel: rgba(250, 244, 227, .96);
  --color-bg-toolbar: rgba(250, 244, 227, .96);
  --color-bg-toolbar-light: rgba(250, 244, 227, .85);
  --color-bg-hover: #EDF1E9;
  --color-bg-sources: var(--color-sage-light);
  --color-bg-dropdown: #FFFAF0;
  --color-bg-overlay: rgba(52, 66, 56, .85);

  /* TEXT */
  --color-text-main: var(--color-dark);
  --color-text-muted: var(--color-text-secondary);
  --color-text-dark: var(--color-dark);
  --color-meta: var(--color-accent);

  /* KARTE */
  --color-point: var(--color-sage);
  --color-point-active: var(--color-accent);

  /* RAHMEN */
  --border-light: rgba(52, 66, 56, .20);
  --border-strong: var(--color-sage);
  --focus-ring: rgba(196, 92, 96, .15);

  /* SCHRIFTGRÖSSEN */
  --font-size-title: 36px;
  --font-size-intro: 19px;
  --font-size-body: 17px;
  --font-size-small: 14px;
  --font-size-meta: 13px;
  --font-size-caption: 11px;

  /* STATUS-FARBEN */
  --color-badge-high: #3b6b49;
  --color-badge-high-bg: rgba(157, 175, 153, 0.35);
  --color-badge-med: #8a6a5d;
  --color-badge-med-bg: var(--color-sage-light);
  --color-badge-low: #a84b4b;
  --color-badge-low-bg: rgba(196, 92, 96, 0.18);

  /* SCHATTEN */
  --shadow-panel: 0 12px 30px rgba(0, 0, 0, 0.08);
  --shadow-title: 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-dropdown: 0 16px 36px rgba(52, 66, 56, .15), 0 3px 8px rgba(52, 66, 56, .05);
  --shadow-control: 0 2px 8px rgba(52, 66, 56, .06);
}


/* =========================================================
   ALLGEMEINE STRUKTUR
   ========================================================= */

body {
  margin: 0;
  font-family: var(--font-primary);
  background: var(--color-bg-base);
  color: var(--color-text-main);
  overflow: hidden;
}

#app,
#map {
  position: relative;
  height: 100vh;
  width: 100%;
}


/* =========================================================
   UI-LAYER: TITEL & TOOLBAR
   ========================================================= */

#map-title {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);

  padding: 12px 24px;
  background: var(--color-bg-toolbar-light);
  backdrop-filter: blur(8px);
  color: var(--color-text-main);
  box-shadow: var(--shadow-title);

  font-family: var(--font-primary);
  font-size: 18px;
  font-weight: 700;

  border-radius: 14px;
  z-index: 1000;
  transition: background 0.2s ease;
}

#map-title:hover {
  background: var(--color-bg-hover);
}

#map-toolbar {
  position: absolute;
  top: 20px;
  left: 8px;

  display: flex;
  flex-direction: column;

  background: var(--color-bg-toolbar);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 1000;
  transition: left 220ms ease;
}

#map-toolbar.detail {
  left: 300px;
}

.toolbar-button {
  width: 60px;
  height: 60px;
  border: none;

  background: transparent;
  color: var(--color-text-main);

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: all 0.2s ease;
}

.toolbar-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.toolbar-button:hover,
.toolbar-button.active {
  color: var(--color-cream);
  background: var(--color-accent);
}


/* =========================================================
   SIDE PANEL
   ========================================================= */

#map-panel {
  position: absolute;
  top: 20px;
  left: 8px;

  width: 280px;
  height: calc(100vh - 40px);

  display: flex;
  flex-direction: column;

  background: var(--color-bg-panel);
  color: var(--color-text-main);

  border-radius: 18px;
  padding: 20px;
  box-sizing: border-box;

  box-shadow: var(--shadow-panel);
  z-index: 1000;

  opacity: 1;
  transform: translateX(0);
  transition: opacity 220ms ease, transform 220ms ease;
}

#map-panel.hidden {
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
}

#panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#panel-title {
  margin: 0;

  font-family: var(--font-primary);
  font-size: var(--font-size-title);
  font-weight: 700;

  color: var(--color-text-main);
}

#panel-close {
  border: none;
  background: transparent;

  color: var(--color-text-main);

  font-size: 26px;
  line-height: 1;

  cursor: pointer;
}

.panel-view {
  min-height: 0;
  flex: 1;
}

.panel-view.hidden {
  display: none !important;
}

#panel-search-view,
#panel-filter-view {
  display: flex;
  flex-direction: column;
}

#panel-filter-view {
  overflow-y: auto;
}


/* =========================================================
   FORMULAR-ELEMENTE
   ========================================================= */

.panel-controls {
  margin-bottom: 16px;
}

.search-list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sort-control {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  font-size: 12px;
}

.search-list-controls select {
  max-width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--color-cream);
  color: var(--color-text-main);
  font-family: var(--font-primary);
  font-size: 14px;
}

.search-list-controls select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

#search-bar {
  width: 100%;
  box-sizing: border-box;

  padding: 12px 14px;
  margin-bottom: 12px;

  background-color: var(--color-cream);
  color: var(--color-text-main);

  border: 1px solid var(--border-light);
  border-radius: 10px;

  font-size: 16px;
  font-family: var(--font-primary);
}

#search-bar:focus {
  outline: none;

  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 10px;

  padding: 16px 0 8px;

  border: none;
  border-top: 1px solid var(--border-light);
  
}

.filter-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.filter-section h3 {
  margin: 0 0 6px;

  font-family: var(--font-mono);
  font-size: var(--font-size-meta);
  font-weight: 700;

  letter-spacing: 0.08em;
  text-transform: uppercase;

  color: var(--color-meta);
}

.filter-option {
  display: flex;
  align-items: center;

  gap: 10px;
  padding: 8px 10px;

  border-radius: 10px;

  font-size: 15px;
  color: var(--color-text-main);

  cursor: pointer;
  transition: background 160ms ease;
}

.filter-option:hover {
  background: var(--color-bg-hover);
}

.filter-option input[type="checkbox"] {
  accent-color: var(--color-accent);

  width: 16px;
  height: 16px;

  cursor: pointer;
  flex-shrink: 0;
}

.filter-reset-button {
  width: 100%;

  padding: 10px 14px;
  margin-bottom: 14px;

  border: 1px solid var(--color-accent);
  border-radius: 10px;

  background: transparent;
  color: var(--color-accent);

  font-size: 14px;
  font-weight: 600;

  cursor: pointer;

  transition: all 160ms ease;
}

.filter-reset-button:hover {
  color: var(--color-cream);
  background: var(--color-accent);
  border-color: var(--color-accent);
}


/* =========================================================
   LISTEN
   ========================================================= */

#place-list {
  margin-top: 10px;

  flex: 1;
  min-height: 0;

  overflow-y: auto;
  overscroll-behavior: contain;

  padding-right: 4px;
}

.place-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}

.place-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.place-year,
.place-item-story {
  display: inline-block;
  margin: 0;

  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;

  color: var(--color-accent);
}

.place-item-story {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-sage-light);
  color: var(--color-text-main);
  font-family: var(--font-primary);
}

.place-item strong {
  display: block;
  margin: 0;

  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
}

.place-item-subtitle {
  display: block;

  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;

  color: var(--color-text-muted);
}

.place-item:hover {
  background: var(--color-bg-hover);
}

.popup-place {
  text-align: center;
}

.place-marker-tooltip {
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;

    color: var(--color-text);
    background: var(--color-cream);

    border: none;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

    padding: 6px 9px;
}

.leaflet-tooltip.place-marker-tooltip::before {
    border-top-color: var(--color-cream);
}

/* =========================================================
   DETAIL-ANSICHT
   ========================================================= */

#default-button {
  position: absolute;
  top: 20px;
  left: 20px;

  display: none;

  padding: 10px 16px;

  border: none;
  border-radius: 10px;

  background: var(--color-bg-toolbar-light);
  color: var(--color-text-main);

  cursor: pointer;
  z-index: 1000;

  font-weight: 600;

  transition: background 0.2s ease;
}

#default-button:hover {
  background: var(--color-bg-hover);
}

#place-detail {
  box-sizing: border-box;

  margin: 0;
  padding: 0 24px;

  height: 0;

  overflow: hidden;

  opacity: 0;
  transform: translateY(24px);

  visibility: hidden;
  pointer-events: none;

  background: var(--color-cream);
  color: var(--color-text-main);

  transition:
    height 280ms ease,
    opacity 220ms ease,
    transform 280ms ease,
    padding 280ms ease,
    visibility 0s linear 280ms;
}

body.detail-view #place-detail {
  height: 67vh;

  padding: 24px;

  overflow-y: auto;

  opacity: 1;
  transform: translateY(0);

  visibility: visible;
  pointer-events: auto;

  transition:
    height 280ms ease,
    opacity 220ms ease,
    transform 280ms ease,
    padding 280ms ease,
    visibility 0s linear 0s;
}

body.detail-view #map-filters,
body.detail-view #map-title,
body.detail-view #map-toolbar,
body.detail-view #map-panel {
  display: none;
}

body.detail-view #app,
body.detail-view #map {
  height: 33vh;
}

.place-text-paragraph {
    margin: 0 0 1.25em;
}

.place-text-paragraph:last-child {
    margin-bottom: 0;
}


/* =========================================================
   DETAILANSICHT – MEDIEN
   ========================================================= */

.place-media {
  margin: 0;
  padding: 0;
}

.place-media-img {
  width: 100%;
  max-height: 350px;

  object-fit: cover;

  border-radius: 12px;
  border: 1px solid var(--border-light);

  box-shadow: 0 4px 12px rgba(0,0,0,0.05);

  cursor: zoom-in; 
  transition: transform 0.2s ease;
}

.place-media-img:hover {
  transform: scale(1.02);
}

.place-media-caption {
  margin-top: 10px;
  margin-bottom: 16px;

  font-family: var(--font-mono);
  font-size: var(--font-size-caption);
  font-weight: 400;

  color: var(--color-text-muted);

  line-height: 1.5;
  text-align: left;
}


/* =========================================================
   DETAILANSICHT – ARTIKEL
   ========================================================= */

.place-article {
  max-width: 1200px;
  margin: 0 auto;
}

.place-header {
  margin-bottom: 32px;
  padding-bottom: 20px;

  border-bottom: 1px solid var(--border-light);
}


/* Metadaten / Kategorie */

.place-eyebrow {
  margin: 0 0 8px;

  font-family: var(--font-mono);
  font-size: var(--font-size-meta);
  font-weight: 700;

  text-transform: uppercase;
  letter-spacing: 0.08em;

  color: var(--color-meta);
}


/* Ortsüberschrift */

.place-header-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; 
  gap: 28px;
  align-items: start;
}

.place-title {
  margin: 0 0 12px;

  font-family: var(--font-primary);
  font-size: var(--font-size-title);
  font-weight: 700;

  line-height: 1.15;

  color: var(--color-text-main);
}

.place-subtitle {
  margin: 0 0 14px;

  font-family: var(--font-primary);
  font-size: 18px;
  font-weight: 500;

  line-height: 1.4;

  color: var(--color-text-muted);
}


/* Weitere Metadaten */

.place-meta {
  display: flex;
  flex-wrap: wrap;

  gap: 10px 18px;

  margin: 0 0 16px;

  font-family: var(--font-mono);
  font-size: var(--font-size-meta);

  color: var(--color-meta);
}

.place-meta span::before {
  content: "• ";
  opacity: 0.5;
}

.place-meta span:first-child::before {
  content: "";
}


/* Kurzbeschreibung */

.place-lead {
  margin: 0;

  font-family: var(--font-primary);
  font-size: var(--font-size-intro);
  font-weight: 500;

  line-height: 1.5;

  color: var(--color-text-main);

  text-align: justify;
  hyphens: auto;
}

.place-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;

  gap: 28px;

  align-items: start;
}

.place-section {
  margin-bottom: 28px;
}

.place-section h3,
.place-card h3 {
  margin: 0 0 12px;

  font-family: var(--font-mono);
  font-size: var(--font-size-meta);
  font-weight: 700;

  letter-spacing: 0.08em;
  text-transform: uppercase;

  color: var(--color-meta);
}


/* Haupttext */

.place-section p {
    margin: 0 0 1.25em;

    font-family: var(--font-primary);
    font-size: var(--font-size-body);
    font-weight: 400;

    line-height: 1.65;

    color: var(--color-text-main);

    text-align: justify;
    hyphens: auto;
}

.place-section p:last-child {
    margin-bottom: 0;
}


/* =========================================================
   DETAIL-CARDS / QUELLEN
   ========================================================= */

.place-card {
  background: var(--color-bg-sources);

  border: 1px solid var(--border-light);
  border-radius: 16px;

  padding: 18px;
  margin-bottom: 16px;

  backdrop-filter: blur(6px);
}

.place-facts div {
  padding: 10px 0;

  border-bottom: 1px solid var(--border-light);
}

.place-facts div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.place-facts dt {
  margin-bottom: 4px;

  font-family: var(--font-mono);
  font-size: var(--font-size-meta);

  color: var(--color-meta);
}

.place-facts dd {
  margin: 0;

  font-size: var(--font-size-small);
  line-height: 1.5;

  color: var(--color-text-main);
}

.place-sources-list {
  margin: 0;
  padding-left: 18px;

  font-family: var(--font-primary);
  font-size: var(--font-size-small);

  color: var(--color-text-main);
}

.place-sources-list li {
  margin-bottom: 8px;
  line-height: 1.5;
}


/* =========================================================
   BADGES
   ========================================================= */

.place-badge {
  display: inline-block;

  padding: 4px 10px;

  border-radius: 999px;

  font-size: 0.8rem;
  font-weight: 600;

  background: var(--color-badge-med-bg);
  color: var(--color-badge-med);
}

.place-badge--high {
  background: var(--color-badge-high-bg);
  color: var(--color-badge-high);
}

.place-badge--medium {
  background: var(--color-badge-med-bg);
  color: var(--color-badge-med);
}

.place-badge--low {
  background: var(--color-badge-low-bg);
  color: var(--color-badge-low);
}


/* =========================================================
   LEAFLET – MARKER
   ========================================================= */

.map-marker {
  width: 16px;
  height: 16px;

  background-color: var(--color-point);

  border: 2px solid var(--color-cream);
  border-radius: 50%;

  box-sizing: border-box;

  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.4);

  cursor: pointer;
}

/* Aktiver / ausgewählter Ort */
.active-marker .map-marker {
  background-color: var(--color-point-active);
}


/* =========================================================
   LEAFLET CONTROLS
   ========================================================= */

.leaflet-control-zoom a {
  background: var(--color-bg-toolbar);

  color: var(--color-text-main);

  border: none;
}

.leaflet-control-zoom a:hover {
  background: var(--color-accent);

  color: var(--color-cream);
}


/* =========================================================
   LEAFLET POPUPS
   ========================================================= */

.place-popup .leaflet-popup-content-wrapper {
  background: var(--color-cream);

  color: var(--color-text-main);
}

.place-popup .leaflet-popup-tip {
  background: var(--color-cream);
}

.popup-place {
  display: flex;
  flex-direction: column;
}

.popup-place strong {
  font-family: var(--font-primary);
  font-size: var(--font-size-small);
  font-weight: 600;

  color: var(--color-text-main);
}

.popup-place span {
  margin-top: 4px;
}

.popup-place span:first-of-type {
  font-family: var(--font-primary);
  font-size: var(--font-size-small);
  font-weight: 400;

  line-height: 1.4;

  color: var(--color-text-muted);
}

.popup-place span:last-of-type {
  font-family: var(--font-mono);
  font-size: var(--font-size-meta);

  color: var(--color-meta);
}


/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */

@media (max-width: 900px) {
  .place-layout {
    grid-template-columns: 1fr;
  }

  .place-title {
    font-size: 1.8rem;
  }
}

@media (max-width: 700px) {

  #app,
  #map {
    height: 100dvh;
  }

  #map-title {
    top: 14px;

    max-width: 70vw;

    padding: 6px 12px;

    text-align: center;
    line-height: 1.2;

    font-size: 12px;
  }

  #map-toolbar {
    top: 20px;
    left: 8px;
  }

  .toolbar-button {
    width: 52px;
    height: 52px;
  }

  .toolbar-button svg {
    width: 21px;
    height: 21px;
  }

  #map-panel {
    top: 0px;
    left: 0px;
    right: 0px;

    width: auto;
    height: 100dvh;

    max-height: none;

    padding: 18px;
  }

  #panel-title {
    font-size: 28px;
  }

  #place-list {
    -webkit-overflow-scrolling: touch;
  }

  .filter-option {
    padding: 12px 10px;
    font-size: 20px;
  }

  .filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  .place-sources-list {
    font-size: 20px;
    padding: 12px 10px;
  }

  body.detail-view #app,
  body.detail-view #map {
    height: 38dvh;
  }

  body.detail-view #place-detail {
    height: 62dvh;
    padding: 18px;
  }

  .place-layout {
    gap: 18px;
  }

  .place-title {
    font-size: 1.7rem;
  }

  .place-lead {
    font-size: 1rem;
  }

  .place-card {
    padding: 8px;
  }

  .place-section {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin-bottom: 28px;
  }
}


/* =========================================================
   LIGHTBOX (BILD-VERGRÖSSERUNG)
   ========================================================= */
.lightbox-overlay {
  position: fixed;
  top: 0; 
  left: 0; 
  width: 100vw; 
  height: 100vh;
  z-index: 9999; /* Muss über der Karte und UI liegen! */
  
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* Dein dunkles Grün als schicker, halbtransparenter Hintergrund */
  background: var(--color-bg-overlay); 
  backdrop-filter: blur(8px); 
  
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: zoom-out;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 50px rgba(0,0,0,0.4);
}

.place-main {
  min-width: 0;
}

.place-gallery {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 24px 0;
  overflow: hidden;
}

.place-gallery .swiper-wrapper {
  align-items: flex-start;
}

.place-gallery .swiper-slide {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

.place-gallery-img {
  display: block;

  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 460px;

  object-fit: contain;
  background: var(--color-cream);
}

.place-gallery-caption {
  margin-top: 10px;

  font-family: var(--font-mono);
  font-size: var(--font-size-caption);

  color: var(--color-text-muted);
  line-height: 1.5;

  text-align: center;
}

.place-gallery .swiper-button-prev,
.place-gallery .swiper-button-next {
  color: var(--color-accent);
}

.place-gallery .swiper-pagination {
  position: relative;
  margin-top: 12px;
  bottom: auto;
}
/* Kompakte Filter-Dropdowns neben dem Kartentitel. */
#map-header {
  position: absolute;
  top: 20px;
  left: 8px;
  right: 8px;
  z-index: 1001;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

#map-header > * { pointer-events: auto; }

#map-header #map-title {
  position: static;
  transform: none;
  margin: 0;
}

#map-filters {
  display: flex;
  justify-self: end;
  gap: 8px;
}

.filter-dropdown { position: relative; }

.filter-dropdown summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--color-bg-panel);
  box-shadow: var(--shadow-title);
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
}

.filter-dropdown summary::-webkit-details-marker { display: none; }
.filter-dropdown summary::after { content: "⌄"; }
.filter-dropdown[open] summary::after { content: "⌃"; }
.filter-dropdown[open] summary,
.filter-dropdown:has(input:checked) summary { background: var(--color-sage-light); }
.filter-dropdown summary:focus-visible { outline: 2px solid var(--color-accent); }

.filter-dropdown-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 260px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 8px;
  background: var(--color-bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
}

#map-filters .filter-option {
  padding: 10px 8px;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
}

#map-filters .filter-option:hover { background: var(--color-sage-light); }
#map-filters input { accent-color: var(--color-accent); width: 16px; height: 16px; }
#map-filters .filter-reset-button { margin: 8px 0 0; font-size: 12px; padding: 8px; }

#map-toolbar, #map-panel { top: 20px; }
#map-panel { height: calc(100dvh - 40px); }
body.detail-view #map-header { display: none; }

@media (max-width: 700px) {
  #map-header { top: 14px; gap: 8px; }
  #map-header #map-title { padding: 8px; font-size: 12px; max-width: none; }
  .filter-dropdown summary { padding: 10px; gap: 6px; font-size: 12px; }
  #map-toolbar, #map-panel { top: 70px; }
  #map-panel { height: calc(100dvh - 70px); }
}

/* Auf großen Bildschirmen bleiben Karte und Station nebeneinander sichtbar. */
@media (min-width: 701px) {
  #place-detail {
    position: fixed;
    top: 0;
    right: 0;
    width: 40%;
    height: 100dvh;
    transform: translateX(100%);
    border-left: 1px solid var(--border-light);
  }

  body.detail-view #app {
    width: 60%;
    height: 100dvh;
  }

  body.detail-view #map {
    width: 100%;
    height: 100dvh;
  }

  body.detail-view #place-detail {
    height: 100dvh;
    transform: translateX(0);
    padding: 24px;
  }

  #place-detail .place-layout,
  #place-detail .place-header-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #place-detail .place-lead,
  #place-detail .place-text-paragraph {
    text-align: left;
  }

  #place-detail .place-title {
    font-size: clamp(24px, 2.2vw, 36px);
  }
}

@media (max-width: 480px) {
  /* Der Titel behält seine eigene Mitte; Filter stehen bei Platzmangel darunter. */
  #map-header { grid-template-columns: 1fr; }
  #map-header #map-title { grid-row: 1; justify-self: center; }
  #map-filters { grid-row: 2; justify-self: center; }
  #map-panel, #map-toolbar { top: 106px; }
  #map-panel { height: calc(100dvh - 106px); }
}

@media (min-width: 701px) {
  #map-filters {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  #map-header #map-title { grid-column: 2; }
  .filter-dropdown { max-width: 100%; }
  .filter-dropdown[open] { z-index: 2; }
  .filter-dropdown summary { padding: 10px; gap: 6px; font-size: 13px; }
  .filter-dropdown-options {
    left: 0;
    right: auto;
    width: 240px;
    max-width: var(--filter-menu-width, 240px);
  }
  #map-filters .filter-option span { min-width: 0; overflow-wrap: anywhere; }
  #map-filters .filter-option input { flex-shrink: 0; }
}

#story-menu { grid-column: 3; justify-self: start; }
#story-menu .filter-dropdown-options { left: auto; right: 0; width: 260px; max-width: calc(100vw - 24px); }
#story-menu a {
  display: block;
  padding: 12px 8px;
  color: var(--color-text-main);
  font-size: 14px;
  text-decoration: none;
  border-radius: 6px;
}
#story-menu a:hover, #story-menu a:focus-visible { background: var(--color-sage-light); }
.station-story-links { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.station-story-link {
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--color-text-main);
  background: var(--color-sage-light);
  text-decoration: none;
  font-size: 14px;
}
.station-story-link:hover { background: var(--color-sage); }
@media (max-width: 700px) {
  #story-menu .filter-dropdown-options { left: auto; right: 0; }
}
@media (max-width: 480px) {
  #map-header #map-title { grid-column: 1; }
  #story-menu { grid-column: 1; grid-row: 3; justify-self: center; }
  #map-panel, #map-toolbar { top: 148px; }
  #map-panel { height: calc(100dvh - 148px); }
}

/* Dropdowns: ruhige Flächen, klare Auswahl und kompakte Navigation. */
.filter-dropdown summary {
  position: relative;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--color-bg-toolbar);
  box-shadow: var(--shadow-control);
  transition: background .16s ease, border-color .16s ease;
}
.filter-dropdown summary:hover { background: var(--color-bg-dropdown); border-color: var(--color-sage); }
.filter-dropdown summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform .16s ease;
}
.filter-dropdown[open] summary::after { content: ""; transform: translateY(1px) rotate(225deg); }
.filter-dropdown[open] { z-index: 3; }
.filter-dropdown[open] summary { border-color: var(--color-sage); background: var(--color-sage-light); }
.filter-dropdown:has(input:checked) summary { color: var(--color-dark); border-color: var(--color-sage); }
.filter-dropdown:has(input:checked) summary::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
  flex-shrink: 0;
}
.filter-dropdown-options {
  top: calc(100% + 10px);
  padding: 8px;
  border-radius: 14px;
  background: var(--color-bg-dropdown);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-dropdown);
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
  animation: dropdown-appear .15s ease-out;
}
.dropdown-heading {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.dropdown-heading strong { font-size: 12px; font-weight: 600; }
.dropdown-heading > span { color: var(--color-text-muted); font-size: 11px; line-height: 1.4; }
#map-filters .filter-option {
  margin: 3px 0;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  line-height: 1.4;
  transition: background .15s ease;
}
#map-filters .filter-option:hover { background: var(--color-bg-hover); }
#map-filters .filter-option:has(input:checked) { background: var(--color-sage-light); border-color: var(--border-light); }
#map-filters .filter-option:focus-within { outline: 2px solid var(--color-accent); outline-offset: -2px; }
#map-filters .filter-reset-button {
  background: transparent;
  color: var(--color-text-muted);
  border: 0;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  padding: 12px 8px 6px;
  text-align: left;
}
#map-filters .filter-reset-button:hover { color: var(--color-accent); }
#story-menu .filter-dropdown-options { width: 300px; }
#story-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  margin: 4px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background .15s ease, border-color .15s ease;
}
#story-menu a:hover, #story-menu a:focus-visible { border-color: var(--border-light); background: var(--color-bg-hover); }
.story-link-text { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.story-link-text strong { font-size: 14px; font-weight: 600; }
.story-link-text > span { font-size: 12px; line-height: 1.5; color: var(--color-text-muted); }
.story-link-arrow { color: var(--color-accent); font-size: 20px; }
@keyframes dropdown-appear {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .filter-dropdown-options { animation: none; }
  .filter-dropdown summary, .filter-dropdown summary::after { transition: none; }
}

#map-panel a, #place-detail a { color: var(--color-text-main); }
#map .leaflet-bar a {
  background: var(--color-bg-toolbar);
  color: var(--color-text-main);
  border-color: var(--border-light);
}
#map .leaflet-bar a:hover { background: var(--color-bg-hover); }

/* Kompakte mobile Navigation und lesbare Stationsdetails. */
@media (max-width: 700px) {
  #map-header { top: max(10px, env(safe-area-inset-top)); grid-template-columns: 1fr; gap: 8px; }
  #map-header #map-title { grid-column: 1; grid-row: 1; justify-self: center; padding: 8px 12px; }
  #map-filters { grid-column: 1; grid-row: 2; justify-self: start; gap: 6px; }
  #story-menu { grid-column: 1; grid-row: 2; justify-self: end; }
  .filter-dropdown summary { min-height: 40px; box-sizing: border-box; padding: 10px 8px; font-size: 12px; gap: 4px; }
  #map-toolbar, #map-panel { top: 104px; }
  #map-panel { height: calc(100dvh - 104px); padding: 16px; }
  .filter-dropdown-options { max-height: calc(100dvh - 160px); width: min(260px, calc(100vw - 24px)); }
  #story-menu .filter-dropdown-options { width: min(300px, calc(100vw - 24px)); }
  #map-filters .filter-option { min-height: 44px; box-sizing: border-box; }
  #place-detail .place-header-grid { grid-template-columns: minmax(0, 1fr); }
  #place-detail .place-lead, #place-detail .place-text-paragraph { text-align: left; }
  #place-detail .place-sources-list { font-size: 14px; padding: 0; overflow-wrap: anywhere; }
  body.detail-view #place-detail { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  #default-button { top: 10px; left: 10px; }
}

@media (max-width: 700px) {
  #map-toolbar.detail { display: none; }
  #map .leaflet-control-zoom { display: none; }
  #map:has(#map-panel:not(.hidden)) .leaflet-control-zoom { display: none; }
}

/* Mobile Kartenwerkzeuge: Titel mittig, Filter rechts, Story-Einstieg unten. */
#story-start-link {
  position: absolute;
  top: 20px;
  right: 12px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 12px 16px;
  box-sizing: border-box;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-control);
  background: var(--color-bg-toolbar);
  color: var(--color-text-main);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
#story-start-link:hover { background: var(--color-bg-hover); }
#story-start-link:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
body.detail-view #story-start-link { display: none; }
@media (min-width: 701px) {
  #map-filters { display: contents; }
  #map-filters > .filter-dropdown {
    grid-row: 1;
    top: var(--filter-top, 0px);
  }
  #map-filters > .filter-dropdown:first-child { grid-column: 1; justify-self: end; }
  #map-filters > .filter-dropdown:last-child { grid-column: 3; justify-self: start; }
  #map-header #map-title { grid-row: 1; }
}
@media (max-width: 700px) {
  :root { --mobile-tools-top: calc(max(10px, env(safe-area-inset-top)) + 64px); }
  #map-header { display: block; height: 48px; }
  #map-header #map-title {
    width: fit-content;
    max-width: calc(100% - 24px);
    margin: 0 auto;
    padding: 10px 12px;
    box-sizing: border-box;
    font-size: clamp(18px, 5.2vw, 24px);
    line-height: 1.2;
    text-align: center;
  }
  #story-menu { display: none; }
  #map-filters {
    position: absolute;
    top: 64px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 116px;
  }
  #map-filters summary { min-height: 44px; font-size: 13px; padding: 12px; justify-content: space-between; }
  #map-filters .filter-dropdown-options { left: auto; right: 0; }
  #map-toolbar {
    top: var(--mobile-tools-top);
    left: 8px;
    gap: 8px;
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }
  #map-toolbar .toolbar-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--color-bg-toolbar);
    box-shadow: var(--shadow-control);
  }
  #map-toolbar .toolbar-button:hover,
  #map-toolbar .toolbar-button.active { background: var(--color-accent); }
  #map-panel { top: var(--mobile-tools-top); height: calc(100dvh - var(--mobile-tools-top)); }
  #story-start-link {
    top: auto;
    position: absolute;
    right: 12px;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 24px);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 16px;
    box-sizing: border-box;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-panel);
    background: var(--color-bg-toolbar);
    color: var(--color-text-main);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
  }
  #story-start-link:hover { background: var(--color-bg-hover); }
  #story-start-link:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
  body.detail-view #story-start-link,
  #map:has(#map-panel:not(.hidden)) #story-start-link,
  #map:has(#map-panel:not(.hidden)) #map-filters { display: none; }
}

/* Orientierung: Besuchsstatus und Erzählfolge sind voneinander unabhängig. */
.map-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background-color 160ms ease, width 160ms ease, height 160ms ease;
}
.marker-number { display: none; }
.story-marker .map-marker {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: var(--color-dark);
  color: var(--color-cream);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 700;
}
.story-marker .marker-number { display: inline; }
.visited-marker .map-marker {
  box-shadow: 0 0 0 2px var(--color-cream), 0 0 0 4px var(--color-dark), var(--shadow-control);
}
.visited-marker .map-marker::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border: 1px solid var(--color-cream);
  border-radius: 50%;
  background: var(--color-dark);
  color: var(--color-cream);
  font-family: var(--font-primary);
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
}
.active-marker .map-marker {
  background: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-cream), 0 0 0 5px var(--color-accent);
}
.leaflet-marker-icon:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 8px; border-radius: 50%; }
.place-item-state {
  display: inline-block;
  margin: 0;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-cream);
  font-size: 11px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--color-dark);
}
.place-item-state:empty { display: none; }
.place-item-visited { border-left: 3px solid var(--color-sage); }
.place-item-related { background: var(--color-sage-light); }
.place-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }

#map-context {
  position: absolute;
  z-index: 1001;
  left: 12px;
  bottom: 32px;
  width: min(280px, calc(100% - 80px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--color-text-main);
}
.map-context-overview {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--color-bg-toolbar);
  box-shadow: var(--shadow-control);
}
#map-context [hidden] { display: none; }
#map-context p { margin: 0; }
.map-visit-progress { font-size: 12px; color: var(--color-text-muted); }
#map-context .map-story-context { margin-top: 6px; font-size: 14px; font-weight: 700; }
.map-marker-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 11px; }
.map-marker-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.map-marker-legend i { display: inline-grid; place-items: center; width: 12px; height: 12px; border-radius: 50%; font-style: normal; }
.legend-visited { border: 1px solid var(--color-dark); font-size: 10px; }
.legend-active { background: var(--color-accent); }
#map-context .map-numbering-hint { margin-top: 8px; font-size: 11px; color: var(--color-text-muted); }
#map-context .map-clear-story {
  width: 100%;
  min-height: 46px;
  box-sizing: border-box;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--color-bg-toolbar);
  box-shadow: var(--shadow-control);
  color: var(--color-point-active);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
#map-context .map-clear-story:hover { background: var(--color-bg-hover); }
#map-context button:focus-visible, #map-context select:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.map-story-choice { display: grid; gap: 4px; margin-top: 8px; font-size: 12px; }
.map-story-choice select { width: 100%; padding: 6px; border: 1px solid var(--border-light); border-radius: 6px; background: var(--color-cream); color: inherit; font: inherit; }
@media (min-width: 701px) {
  body:not(.detail-view) #map:has(#map-panel:not(.hidden)) #map-context { left: 380px; width: min(280px, calc(100% - 460px)); }
}
@media (max-width: 700px) {
  #map-context { bottom: 100px; width: min(280px, calc(100% - 24px)); }
  body.detail-view #map-context { bottom: 12px; max-height: calc(100% - 76px); overflow-y: auto; }
  body:not(.detail-view) #map:has(#map-panel:not(.hidden)) #map-context { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .map-marker { transition: none; }
}
@media (max-width: 700px) {
  .map-context-overview { padding: 10px 12px; }
  body.detail-view #map-context { width: calc(100% - 24px); }
  body.detail-view #map-context .map-marker-legend,
  body.detail-view #map-context .map-numbering-hint { display: none; }
  body.detail-view #map-context .map-visit-progress::before { content: '✓ '; }
}
