:root {
  --header-height: 74px;
  --footer-height: 48px;
  --panel-bg: rgba(255, 255, 255, .94);
  --shadow: 0 4px 18px rgba(0, 0, 0, .14);
  --color-kita: #006eb8;
  --color-krippe: #008c95;
  --color-kindergarten: #218739;
  --color-hort: #e97600;
  --color-familienzentrum: #c90019;
  --color-ganztagsschule: #7652a2;
  --color-kinder-jugendhilfe: #b12b70;
  --color-sonstiges: #5f6368;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #f5f5f3;
  font-family: "Fira Sans", Arial, "Helvetica Neue", sans-serif;
  line-height: 1.4;
}

.skip-link {
  position: fixed;
  top: .5rem;
  left: 1rem;
  z-index: 2000;
  padding: .45rem .7rem;
  color: #fff;
  background: var(--hawk-red);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

#map {
  position: fixed;
  inset: var(--header-height) 0 var(--footer-height);
  z-index: 1;
}

.leaflet-container { font-family: inherit; }
.leaflet-popup-content { color: var(--ink); font-size: 13px; }
.leaflet-popup-content { max-height: min(340px, calc(100vh - var(--header-height) - var(--footer-height) - 80px)); overflow-y: auto; }
.leaflet-popup-content a { color: var(--hawk-red); text-decoration: none; }
.leaflet-popup-content a:hover { text-decoration: underline; }
.leaflet-popup-content strong { display: block; margin: 6px 0 2px; }
.leaflet-popup-content strong:first-child { margin-top: 0; font-size: 14px; }
.popup-title { display: block; margin-bottom: 6px !important; }
.popup-description { margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee; font-size: 12px; }
.facility-popup.popup-below {
  margin-bottom: 0;
  transform: translateY(calc(100% + 20px));
}
.facility-popup.popup-below .leaflet-popup-tip-container {
  top: -20px;
  margin-top: 0;
  transform: rotate(180deg);
}

.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--dark-grey);
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
  font-size: 14px;
  font-weight: 700;
}
.cluster-small { width: 30px; height: 30px; }
.cluster-medium { width: 40px; height: 40px; }
.cluster-large { width: 50px; height: 50px; }

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  height: var(--header-height);
  background: #fff;
  border-top: 5px solid var(--dark-grey);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 1500px;
  height: 100%;
  margin: 0 auto;
  padding: 8px 20px 9px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 285px;
  color: var(--header-text);
  text-decoration: none;
}

.brand-logo { display: block; width: 76px; height: auto; }
.brand-text { display: grid; gap: 1px; min-width: 0; }
.brand-text strong { font-size: 15px; line-height: 1.15; }
.brand-text span { color: var(--muted); font-size: 13px; }

.map-search {
  position: absolute;
  top: calc(var(--header-height) + 12px);
  left: 50%;
  z-index: 910;
  width: min(420px, calc(100% - 640px));
  min-width: 280px;
  padding: 6px;
  background: var(--panel-bg);
  border: 1px solid rgba(56, 60, 63, .22);
  border-radius: 4px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.map-search input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 0;
}
.map-search input:focus { border-color: var(--hawk-red); outline: 2px solid rgba(201, 0, 25, .2); }

.header-filters { display: flex; gap: 5px; }
.state-filter select {
  min-height: 36px;
  max-width: 160px;
  padding: 6px 24px 6px 8px;
  color: var(--header-text);
  background: #fff;
  border: 1px solid #b8b8b8;
  border-radius: 0;
  font-size: 12px;
}
.map-state-filter {
  position: absolute;
  top: calc(var(--header-height) + 12px);
  right: 12px;
  z-index: 900;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 280px;
  min-height: 40px;
  padding: 5px 8px;
  color: var(--header-text);
  background: var(--panel-bg);
  border: 1px solid rgba(56, 60, 63, .18);
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 700;
}
.map-state-filter { transition: opacity .15s ease, transform .15s ease; }
.map-state-filter select { width: 100%; max-width: none; min-height: 30px; }
.map-state-filter.is-collapsed {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.header-filters button,
.info-button {
  min-height: 36px;
  padding: 6px 9px;
  color: var(--header-text);
  background: #fff;
  border: 1px solid #b8b8b8;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.header-filters button:hover,
.header-filters button.is-active,
.info-button:hover { color: #fff; background: var(--dark-grey); border-color: var(--dark-grey); }
.header-filters .search-toggle {
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}
.header-filters .search-toggle[aria-expanded="true"] {
  color: #fff;
  background: var(--hawk-red);
  border-color: var(--hawk-red);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}
.header-actions nav { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; }
.header-actions nav a { color: var(--header-text); font-size: 13px; font-weight: 700; text-decoration: none; }
.header-actions nav a:hover { color: var(--hawk-red); }

.site-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 1000;
  height: var(--footer-height);
  color: #fff;
  background: var(--dark-grey);
}
.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 1500px;
  height: 100%;
  margin: 0 auto;
  padding: 5px 20px;
  font-size: 11px;
}
.footer-inner p { margin: 0; }
.footer-brand { display: grid; }
.footer-brand span { color: #c7c9ca; }
.footer-links { display: flex; justify-self: end; gap: 16px; text-align: right; }
.footer-links a { color: #fff; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.data-status { justify-self: center; color: #c7c9ca; white-space: nowrap; }
.data-status strong { color: #fff; }

.glass-card {
  padding: 12px;
  background: var(--panel-bg);
  border: 1px solid rgba(56, 60, 63, .18);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

#resultList {
  position: absolute;
  top: calc(var(--header-height) + 60px);
  right: 12px;
  z-index: 900;
  width: 280px;
  max-height: min(420px, calc(100vh - var(--header-height) - var(--footer-height) - 72px));
  overflow-y: auto;
  font-size: 13px;
  transition: opacity .15s ease, transform .15s ease;
}
#resultList.is-collapsed {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}
.map-control-button {
  position: absolute;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 2px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .2);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.map-control-button:hover { color: #fff; background: var(--dark-grey); border-color: var(--dark-grey); }
.map-control-button { top: calc(var(--header-height) + 82px); left: 10px; }
.legend-control-button { top: calc(var(--header-height) + 122px); color: var(--hawk-red); font-size: 17px; }
.legend-control-button[aria-expanded="true"] { color: #fff; background: var(--dark-grey); border-color: var(--dark-grey); }
.facility-panel-control-button { top: calc(var(--header-height) + 162px); font-size: 20px; }
.facility-panel-control-button[aria-expanded="false"] { color: #fff; background: var(--dark-grey); border-color: var(--dark-grey); }
.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -12px -12px 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, .02);
  border-bottom: 1px solid #eee;
  font-size: 12px;
  font-weight: 600;
}
.result-direct-link { margin-left: auto; color: var(--hawk-red); font-size: 11px; }
.result-summary button,
.result-error button {
  padding: 2px 0;
  color: var(--hawk-red);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 600;
  text-decoration: underline;
}
.active-filters { display: grid; gap: 3px; margin: 0 0 8px; color: var(--muted); font-size: 11px; }
.active-filters span { overflow-wrap: anywhere; }
.result-item { padding: 8px 6px; border-bottom: 1px solid #e2e2e2; cursor: pointer; }
.result-item:hover { background: #eeeeec; }
.result-row { display: flex; align-items: flex-start; gap: 8px; }
.result-dot {
  display: block;
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  margin-top: 3px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  aspect-ratio: 1;
}
.result-dot.kita { background: var(--color-kita); }
.result-dot.krippe { background: var(--color-krippe); }
.result-dot.kindergarten { background: var(--color-kindergarten); }
.result-dot.hort { background: var(--color-hort); }
.result-dot.familienzentrum { background: var(--color-familienzentrum); }
.result-dot.ganztagsschule { background: var(--color-ganztagsschule); }
.result-dot.kinder-jugendhilfe { background: var(--color-kinder-jugendhilfe); }
.result-dot.sonstiges { background: var(--color-sonstiges); }
.result-copy { flex: 1 1 auto; min-width: 0; }
.result-copy strong { display: block; margin-bottom: 2px; color: var(--ink); }
.result-copy small { display: block; color: var(--muted); font-size: 12px; }
.result-state { padding: 12px; color: var(--muted); text-align: center; font-size: 12px; }
.result-empty,
.result-error { display: grid; gap: 5px; padding: 12px 4px; color: var(--muted); text-align: center; font-size: 12px; }
.result-empty strong,
.result-error strong { color: var(--ink); }
.result-error button { justify-self: center; margin-top: 4px; }
#resultList::-webkit-scrollbar { width: 6px; }
#resultList::-webkit-scrollbar-thumb { background: #aaa; }

#legend {
  position: absolute;
  bottom: calc(var(--footer-height) + 12px);
  left: 12px;
  z-index: 900;
  padding: 14px !important;
  font-size: 13px;
}
#legend h4 { margin: 0 0 10px; font-size: 14px; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.legend-item:last-child { margin-bottom: 0; }
.legend-color { width: 13px; height: 13px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.kita { background: var(--color-kita); }
.krippe { background: var(--color-krippe); }
.kindergarten { background: var(--color-kindergarten); }
.hort { background: var(--color-hort); }
.familienzentrum { background: var(--color-familienzentrum); }
.ganztagsschule { background: var(--color-ganztagsschule); }
.kinder-jugendhilfe { background: var(--color-kinder-jugendhilfe); }
.sonstiges { background: var(--color-sonstiges); }
.hidden { display: none !important; }

@media (max-width: 1200px) {
  :root { --header-height: 116px; }
  .header-inner { display: flex; align-content: center; flex-wrap: wrap; gap: 7px 12px; }
  .brand { min-width: 280px; }
  .header-actions { order: 3; width: 100%; }
  .header-filters { min-width: 0; overflow-x: auto; }
}

@media (max-width: 720px) {
  :root { --header-height: 136px; --footer-height: 62px; }
  .header-inner { padding: 7px 10px; }
  .brand { min-width: 0; flex: 1 1 240px; }
  .brand-logo { width: 68px; }
  .brand-text strong { font-size: 13px; }
  .brand-text span { font-size: 12px; }
  .header-actions { order: 4; gap: 12px; }
  .header-filters { flex: 1 1 auto; }
  .header-filters button { min-height: 30px; padding: 4px 7px; font-size: 11px; }
  .header-actions nav a { font-size: 12px; }
  .info-button { display: none; }
  .footer-inner { grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 2px; padding: 4px 10px; }
  .footer-brand, .footer-links a:first-child { display: none; }
  .data-status { grid-row: 1; }
  .footer-links { grid-row: 2; justify-self: end; gap: 10px; }
  .map-state-filter { top: calc(var(--header-height) + 12px); right: 48px; width: 180px; min-height: 34px; }
  .map-state-filter span { display: none; }
  .map-search { width: calc(100% - 24px); min-width: 0; }
  body.search-open .map-state-filter { display: none; }
  body.search-open #resultList { top: calc(var(--header-height) + 72px); }
  #resultList { top: calc(var(--header-height) + 54px); width: 180px; right: 8px; font-size: 12px; }
  .map-control-button { top: calc(var(--header-height) + 52px); }
  .legend-control-button { top: calc(var(--header-height) + 92px); }
  .facility-panel-control-button { top: calc(var(--header-height) + 132px); }
  #legend { left: 8px; font-size: 12px; }
}

@media (max-width: 460px) {
  .brand-text strong { max-width: 175px; }
  .header-actions nav { display: none; }
  .footer-brand { display: none; }
  .footer-links { gap: 12px; }
  .map-state-filter { width: 145px; }
  #resultList { width: 145px; }
}
