/* Redesign rules are scoped to the URL-selected modern interface. */
/* Shared compact credits also apply to the classic map. */
.gbai-attribution {
  display: flex;
  align-items: flex-end;
  max-width: min(1000px, calc(100vw - 20px));
  background: rgba(255, 255, 255, .92);
}
.gbai-attribution .leaflet-control-attribution {
  float: none;
  margin: 0;
  min-width: 0;
  font-size: 10px !important;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.gbai-attribution.is-expanded .leaflet-control-attribution {
  display: block;
  max-height: min(320px, 40vh);
  overflow-y: auto;
  -webkit-line-clamp: unset;
}
.gbai-attribution-toggle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #315357;
  font: inherit;
  font-size: 10px;
  line-height: 1.35;
  padding: 2px 5px;
  text-decoration: underline;
  cursor: pointer;
}
.map-modern #modern-detail-attribution .gbai-attribution {
  float: none;
  margin: 0;
  max-width: 100%;
}

#modern-map-navigation[hidden],
#modern-map-guide[hidden] {
  display: none !important;
}
#modern-map-guide,
.modern-brand-sub,
.modern-search-arrow {
  display: none;
}

#modern-detail-attribution {
  display: none;
}

.map-modern #modern-detail-attribution:not(:empty) {
  display: block;
  flex: 0 0 auto;
  border-top: 1px solid var(--hairline);
}

.map-modern #modern-detail-attribution .leaflet-control-attribution {
  float: none;
  margin: 0;
  padding: 3px 10px;
  line-height: 1.35;
  text-align: left;
}

:root.map-modern {
  color-scheme: light;
  --bg: rgba(255, 255, 255, .97);
  --bg-elev: #f8faf9;
  --fg: #182d31;
  --muted: #5c7378;
  --hairline: #dce7e3;
  --accent: #13818b;
  --accent-2: #09666f;
  /* Shared legacy controls inherit these only in the modern variant. */
  --brand-accent: var(--accent);
  --brand-accent-hover: var(--accent-2);
  --brand-accent-rgb: 19, 129, 139;
  --brand-accent-border: rgba(19, 129, 139, .47);
  --brand-accent-surface: #edf6f6;
  --brand-accent-line: #cfe5e7;
  --cta: var(--accent);
  --cta-hover: var(--accent-2);
  --cta-fg: #fff;
  --cta-shadow: none;
  --control-bg: #eef5f2;
  --gold: #80621e;
  --warn: #975a16;
  --danger: #b53e3e;
  --ok: #18774e;
  --shadow: 0 4px 22px rgba(25, 53, 44, .09), 0 1px 4px rgba(25, 53, 44, .04);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

.map-modern #map {
  background: #e6eee5;
}

.map-modern .leaflet-tooltip.building-hover-tooltip {
  min-width: 190px;
  max-width: min(300px, calc(100vw - 32px));
  white-space: normal;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: 0 8px 24px #0002;
  font: 13px/1.4 -apple-system, system-ui, sans-serif;
  pointer-events: none;
}

.map-modern .building-hover-tooltip::before { display: none; }
.map-modern .building-hover-type {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.map-modern .building-hover-area {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}
.map-modern .building-hover-area span { color: var(--muted); font-size: 11px; }
.map-modern .building-hover-area strong { font-size: 13px; white-space: nowrap; }

.map-modern #mk-map-badge {
  top: 34px !important;
  right: 24px !important;
}

.map-modern .top-left-rail {
  left: 24px;
  top: 24px;
  width: 292px;
  gap: 14px;
}

.map-modern .map-tools-stack {
  flex: 0 0 auto;
  width: 292px;
}

.brand-title a {
  color: inherit;
  text-decoration: none;
}

.brand-title a:hover {
  text-decoration: underline;
}

.map-modern .brand-card {
  min-height: 68px;
  padding: 14px 16px;
  gap: 12px;
  border-radius: 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.map-modern .brand-logo-dark {
  display: none;
}

.map-modern .brand-logo-light {
  display: inline-block;
}

.map-modern .brand-card .brand-logo {
  width: 36px;
  height: 36px;
}

.map-modern .brand-card .brand-sub {
  display: none;
}

.map-modern .modern-brand-sub {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
}

.map-modern .map-search,
.map-modern body:has(.detail.open) .map-search {
  left: var(--map-search-center, 50%);
  top: 24px;
  transform: translateX(-50%);
  min-width: 0;
  /* Keep the control's width stable while the detail panel is dragged.
     06_detail_panel.js centers it in the available gap and clamps it
     30px beyond the logo header. */
  width: min(560px, calc(100vw - 672px));
}

.map-modern .map-search-row {
  gap: 8px;
  align-items: center;
}

.map-modern .map-search input {
  min-height: 62px;
  padding: 16px 88px 16px 24px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 32px;
  background: var(--bg);
  font-size: 15px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: box-shadow .16s ease, border-color .16s ease;
}

.map-modern .map-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(19, 129, 139, .15), var(--shadow);
}

.map-modern .map-search input::placeholder {
  color: var(--muted);
}

.map-modern .search-go {
  right: 8px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
}

.map-modern .search-go:hover {
  background: var(--accent-2);
}

.map-modern .search-go img {
  display: none;
}

.map-modern .modern-search-arrow {
  display: block;
  width: 22px;
  height: 22px;
}

.map-modern #search-clear {
  right: 58px;
}

.map-modern .search-action-btn {
  min-height: 48px;
  padding: 0 13px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.map-modern .search-action-btn .star {
  color: var(--accent);
}

/* The anchored welcome card hangs below the search field, its arrow
   pointing at it. The field moves with the logo and the detail panel, so
   anchorWelcomeToSearch() (welcome-dialogs.js) publishes its left and
   bottom edges on the overlay. */
.map-modern #welcome-overlay.welcome-anchored .welcome-card {
  left: var(--welcome-anchor-left, 50vw);
  top: calc(var(--welcome-anchor-top, 86px) + 20px);
  width: min(360px, calc(100vw - var(--welcome-anchor-left, 50vw) - 16px));
}

.map-modern .search-results,
.map-modern .bookmarks-popover {
  margin-top: 10px;
  border-radius: 16px;
  background: white;
  border-color: var(--hairline);
  box-shadow: var(--shadow);
}

.map-modern .search-results .row {
  min-height: 52px;
  padding: 14px 18px;
}

.map-modern .kartenstil-card {
  padding: 6px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-height: calc(100svh - 195px);
}

.map-modern .kartenstil-head .seg-basemap button {
  min-height: 40px;
  border-radius: 8px;
  font-size: 12px;
}

.map-modern .kartenstil-chevron {
  width: 40px;
  min-height: 40px;
}

.map-modern .kartenstil-extra {
  padding: 12px 12px 8px;
}

#modern-map-navigation {
  position: fixed;
  z-index: 1110;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 24px);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 12px;
}

#modern-map-navigation > a,
.map-modern #modern-map-navigation summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
  list-style: none;
  white-space: nowrap;
}

.map-modern #modern-map-navigation summary::-webkit-details-marker {
  display: none;
}

.map-modern #modern-map-navigation > a:hover,
.map-modern #modern-map-navigation summary:hover,
.map-modern #modern-map-navigation details[open] > summary {
  color: var(--accent);
  background: #edf6f2;
}

.map-modern .modern-functions-menu {
  position: absolute;
  top: 76px;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(560px, calc(100vw - 104px));
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}

.map-modern .modern-functions-menu > div {
  padding: 0 12px;
}

.map-modern .modern-functions-menu > div + div {
  border-left: 1px solid var(--hairline);
}

.map-modern .modern-functions-menu h2 {
  margin: 0 0 12px;
  font-size: 13px;
}

.map-modern .modern-functions-menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-decoration: none;
}

.map-modern .modern-functions-menu a:hover {
  color: var(--accent);
}

.map-modern #modern-map-guide {
  position: relative;
  margin-top: 16px;
  flex-shrink: 0;
  z-index: 990;
  display: block;
  width: 292px;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.map-modern body:has(.detail.open) #modern-map-guide,
.map-modern body:has(#welcome-overlay:not([hidden])) #modern-map-guide,
.map-modern body:has(.kartenstil-chevron[aria-expanded="true"]) #modern-map-guide {
  display: none;
}

.modern-eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.map-modern #modern-map-guide h2 {
  margin: 14px 0;
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -.8px;
}

.map-modern #modern-map-guide p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.map-modern .detail {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 8px 32px rgba(25, 53, 44, .12);
}

/* Phones inherit the classic panel geometry, including its initial
   bottom sheet and expansion after starting the analysis. */
@media (min-width: 701px) {
  .map-modern .detail {
    top: 0;
    right: 0;
    bottom: 0;
    width: 560px;
    max-width: min(740px, calc(100vw - 24px));
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.map-modern .detail-head {
  padding: 24px 24px 20px;
  background: white;
}

.map-modern .det-shape[hidden],
.map-modern .fkz[hidden] {
  display: none;
}

.map-modern .detail-head .head-actions {
  top: 18px;
  right: 18px;
}

.map-modern body.is-makler-active .detail-head .head-actions {
  right: 18px;
}

/* Leave room for the small return link when a broker's full-height
   panel is open. Parcel actions remain separate, below the link. */
body.map-makler-return .detail-head {
  padding-top: 54px;
}

body.map-makler-return .detail-head .head-actions {
  top: 52px;
}

.map-modern .detail-body {
  padding: 20px;
  background: #f8faf8;
}

.map-modern .det-section,
.map-modern .preview-card {
  border-radius: 14px;
  background: white;
  border-color: var(--hairline);
}

.map-modern .detail button:focus-visible,
.map-modern #modern-map-navigation :focus-visible,
.map-modern #modern-map-guide button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.map-modern .research-btn,
.map-modern .start-analysis-btn:not(.pending) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: none;
}

.map-modern .det-section .stat .val.big {
  color: var(--accent-2);
}

.map-modern .pv-gate-btn:hover {
  background: var(--cta-hover);
}

.map-modern input,
.map-modern select {
  accent-color: var(--accent);
}

.map-modern .detail:has(.detail-body.stage-mode-full) .full-banner {
  background: linear-gradient(180deg, rgba(19, 129, 139, .12), rgba(19, 129, 139, .05));
  border-top-color: rgba(19, 129, 139, .28);
  color: var(--accent-2);
}

.map-modern .payment-card h2 strong,
.map-modern .tier--featured .tier-price-amount,
.map-modern .tier--featured .payment-price-amount {
  color: var(--accent);
}

.map-modern .legal-modal-body a:hover {
  color: var(--accent-2);
}

.map-modern .bottom-left-rail {
  left: 24px;
  bottom: 18px;
}

.map-modern .sources-card {
  border-radius: 10px;
  padding: 9px 12px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.map-modern .leaflet-control-attribution {
  color: #486164 !important;
  background: rgba(255, 255, 255, .92) !important;
}

.map-modern .leaflet-control-attribution a {
  color: #315357 !important;
}

.map-modern body.expose-workspace-active #modern-map-navigation,
.map-modern body.expose-workspace-active #modern-map-guide {
  display: none;
}

@media (max-width: 1279px) and (min-width: 1024px) {
  .map-modern .top-left-rail {
    width: 260px;
    left: 20px;
    top: 20px;
  }
  .map-modern .brand-card {
    padding: 12px;
  }
  .map-modern .brand-card .brand-title {
    font-size: 14px;
  }
  .map-modern .modern-brand-sub {
    font-size: 9px;
  }
  .map-modern .map-search,
  .map-modern body:has(.detail.open) .map-search {
    top: 20px;
    width: min(380px, calc(100vw - 600px));
  }
  .map-modern #modern-map-navigation .modern-overview-link {
    display: none;
  }
  .map-modern #modern-map-guide {
    width: 260px;
  }
  .map-modern .map-tools-stack { width: 260px; }
}

@media (max-width: 1023px) {
  .map-modern .top-left-rail {
    width: 248px;
    left: 20px;
    top: 20px;
  }
  .map-modern .brand-card {
    padding: 12px;
    gap: 9px;
  }
  .map-modern .brand-card .brand-title {
    font-size: 14px;
  }
  .map-modern .modern-brand-sub {
    font-size: 9px;
  }
  .map-modern .brand-card .brand-logo {
    width: 30px;
    height: 30px;
  }
  .map-modern .map-search,
  .map-modern body:has(.detail.open) .map-search {
    top: 20px;
    width: calc(100vw - 576px);
  }
  .map-modern .map-search input {
    padding-left: 16px;
  }
  .map-modern #modern-map-guide {
    width: 248px;
    padding: 22px;
  }
  .map-modern .map-tools-stack { width: 248px; }
  .map-modern #modern-map-guide h2 {
    font-size: 24px;
  }
}

@media (min-width: 701px) and (max-width: 1023px) {
  .map-modern .detail {
    width: min(520px, calc(100vw - 24px));
  }
}

@media (min-width: 701px) and (max-width: 767px) {
  .map-modern .detail {
    left: 8px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
}

@media (max-width: 767px) {
  .map-modern #mk-map-badge {
    top: calc(env(safe-area-inset-top, 0px) + 18px) !important;
    right: 16px !important;
  }
  .map-modern .top-left-rail {
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    left: 16px;
    width: calc(100vw - 84px);
  }
  .map-modern .brand-card {
    min-height: 48px;
    padding: 8px 10px;
    border-radius: 12px;
    gap: 8px;
  }
  .map-modern .brand-card > div {
    flex: 1;
    min-width: 0;
  }
  .map-modern .brand-card .brand-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .map-modern .modern-brand-sub {
    display: none;
  }
  .map-modern #modern-map-guide {
    display: none;
  }
  .map-modern .map-search,
  .map-modern body:has(.detail.open) .map-search {
    left: 16px;
    top: calc(env(safe-area-inset-top, 0px) + 80px);
    width: calc(100vw - 32px);
    transform: none;
  }
  .map-modern .map-search input {
    min-height: 58px;
    border-radius: 16px;
    padding-left: 16px;
    font-size: 16px;
  }
  .map-modern .map-search input::placeholder {
    font-size: 13px;
  }
  .map-modern #welcome-overlay.welcome-anchored .welcome-card {
    left: 16px;
    right: 16px;
    top: calc(var(--welcome-anchor-top, calc(env(safe-area-inset-top, 0px) + 138px)) + 20px);
    width: auto;
  }
  .map-modern #bookmarks-fab {
    min-width: 44px;
    width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    box-shadow: none;
  }
  .map-modern #bookmarks-fab .chevron {
    display: none;
  }
  .map-modern .map-layers-toggle {
    display: inline-flex !important;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
  .map-modern .map-tools-stack,
  .map-modern body.mobile-relocated .map-tools-stack {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 150px);
    left: 16px;
    width: min(320px, calc(100vw - 32px));
    z-index: 1090;
  }
  .map-modern .kartenstil-card {
    display: none;
    max-height: calc(100svh - 240px);
  }
  .map-modern body.layers-open .kartenstil-card {
    display: block;
  }
  .map-modern .detail-head {
    padding: 20px 16px 16px;
  }
  .map-modern body.map-makler-return .detail-head {
    padding-top: 54px;
  }
  .map-modern body.map-makler-return .top-left-rail {
    width: calc(100vw - 164px);
  }
  .map-modern .detail-body {
    padding: 14px;
  }
  .map-modern .bottom-left-rail {
    left: 12px;
    right: 12px;
    bottom: 76px;
    max-width: calc(100vw - 24px);
  }
  .map-modern body:has(.detail.open) .bottom-left-rail {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-modern .map-search input,
  .map-modern .detail {
    transition: none;
  }
}

/* Independent base-map preview controls also work with the classic UI. */
.map-modern #basemap-switch {grid-template-columns:repeat(3,minmax(0,1fr));}
.map-modern #basemap-switch button {
  display:flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
}
.map-modern .kartenstil-head #basemap-switch button {min-height:44px;}
#map .maplibregl-map {background:transparent;}

html:not(.map-modern) .modern-base-option, .modern-base-label {display:none!important;}
.map-modern .classic-base-label {display:none!important;}
.map-modern .modern-base-label {display:inline!important;}
