:root {
  --kjf-op-accent: #f5d547;
  --kjf-op-accent-ink: #1a1a1a;
  --kjf-op-panel: rgba(247, 244, 239, 0.97);
  --kjf-op-ink: #243028;
  --kjf-op-muted: #5c6b63;
  --kjf-op-line: rgba(36, 48, 40, 0.12);
  --kjf-op-green: #6f9b56;
  --kjf-op-radius: 14px;
  --kjf-op-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.kjf-objektplan {
  color: var(--kjf-op-ink);
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.5rem 0 3rem;
}

.kjf-objektplan *,
.kjf-objektplan *::before,
.kjf-objektplan *::after {
  box-sizing: border-box;
}

.kjf-objektplan__header {
  position: relative;
  margin-bottom: 1.25rem;
}

.kjf-objektplan .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.kjf-objektplan__title {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}

.kjf-objektplan__lead {
  margin: 0;
  color: var(--kjf-op-muted);
  max-width: 42rem;
}

.kjf-objektplan__stage {
  position: relative;
  z-index: 1;
  width: 100%;
}

.kjf-objektplan.is-detail .kjf-objektplan__stage {
  z-index: 4;
}

.kjf-objektplan__viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--kjf-op-radius);
  background: #dfe8da;
  border: 1px solid var(--kjf-op-line);
  width: 100%;
  /* Höhe setzt JS anhand Fit-Scale */
  min-height: 280px;
  touch-action: manipulation;
  cursor: grab;
}

.kjf-objektplan__canvas {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 0;
  transform-origin: 0 0;
  will-change: transform;
  transition: transform 480ms var(--kjf-op-ease);
}

.kjf-objektplan__map,
.component-area .kjf-objektplan__map {
  display: block;
  /* Breite/Höhe setzt JS auf naturalWidth/Height → scharfer Zoom aus Full-Res */
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

.kjf-objektplan__markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  container-type: inline-size;
  container-name: kjf-map;
  z-index: 2;
}

.kjf-objektplan__floor-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.kjf-objektplan__floor-overlays[hidden] {
  display: none !important;
}

.kjf-objektplan__floor-overlay,
.component-area .kjf-objektplan__floor-overlay {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0 !important;
  width: auto;
  height: auto;
  max-width: none !important;
  max-height: none !important;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.kjf-objektplan__marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  /* % der Highres-Karte; skaliert mit Canvas mit → immer sinnvoll groß */
  width: 1.85%;
  aspect-ratio: 1;
  min-width: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--kjf-op-accent);
  color: var(--kjf-op-accent-ink);
  font-weight: 800;
  font-size: 0.55em;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 8px 18px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: box-shadow 180ms var(--kjf-op-ease), outline 180ms ease;
  z-index: 2;
  pointer-events: auto;
}

/* Mehr als 2 Zeichen → Pille, Breite wächst mit dem Text */
.kjf-objektplan__marker.is-pill {
  width: auto;
  min-width: 1.85cqw;
  height: 1.85cqw;
  min-height: 18px;
  aspect-ratio: auto;
  padding: 0 0.55em;
}

@supports not (height: 1cqw) {
  .kjf-objektplan__marker.is-pill {
    min-width: 1.85%;
    height: auto;
    padding: 0.35em 0.55em;
  }
}

.kjf-objektplan__marker:hover,
.kjf-objektplan__marker:focus-visible,
.kjf-objektplan__marker.is-active {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2), 0 12px 24px rgba(0, 0, 0, 0.18);
  z-index: 3;
}

.kjf-objektplan__marker:focus-visible {
  outline-color: var(--kjf-op-green);
}

/* Overlay sitzt auf der Stage und darf über die Legende rauswachsen */
.kjf-objektplan__panel {
  position: absolute;
  z-index: 6;
  right: 0.75rem;
  top: 0.75rem;
  width: min(400px, calc(100% - 1.5rem));
  max-height: none;
  overflow: visible;
  border-radius: var(--kjf-op-radius);
  background: var(--kjf-op-panel);
  border: 1px solid var(--kjf-op-line);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem 1.1rem 1.25rem;
  animation: kjf-op-panel-in 280ms var(--kjf-op-ease) both;
  text-align: left;
}

@media (max-width: 767px) {
  .kjf-objektplan__panel {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: -0.5rem;
    width: auto;
  }
}

.kjf-objektplan__mobile-info {
  display: none;
}

.kjf-objektplan__mobile-info[hidden] {
  display: none !important;
}

/* Kein display:contents — Safari/VoiceOver entfernt sonst Marker & Interaktion aus dem A11y-Tree */
.kjf-objektplan__mobile-top {
  display: block;
}

.kjf-objektplan__lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(12, 18, 14, 0.88);
  cursor: zoom-out;
}

.kjf-objektplan__lightbox[hidden] {
  display: none !important;
}

.kjf-objektplan__lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  cursor: zoom-out;
  pointer-events: auto;
}

.kjf-objektplan__lightbox-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.85rem, env(safe-area-inset-right));
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--kjf-op-ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.kjf-objektplan__panel[hidden] {
  display: none !important;
}

.kjf-objektplan__backdrop {
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(20, 28, 22, 0.14);
  cursor: pointer;
  animation: kjf-op-fade-in 200ms ease both;
  border-radius: var(--kjf-op-radius);
  /* Klicks sollen Marker/Karte erreichen → direkter Wechsel ohne erst rauszoomen */
  pointer-events: none;
}

.kjf-objektplan__backdrop[hidden] {
  display: none !important;
}

.kjf-objektplan__back {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--kjf-op-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  padding: 0;
  margin: 0 0 0.35rem;
  cursor: pointer;
  display: inline-block;
}

.kjf-objektplan__back:hover,
.kjf-objektplan__back:focus-visible {
  color: var(--kjf-op-ink);
}

.kjf-objektplan__panel-body {
  margin: 0;
  padding: 0;
}

.kjf-objektplan__panel .kjf-objektplan__building-title,
.kjf-objektplan__panel h2 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.45rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.kjf-objektplan__badge {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--kjf-op-accent);
  color: var(--kjf-op-accent-ink);
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.kjf-objektplan__badge.is-pill {
  width: auto;
  padding: 0 0.55rem;
}

.kjf-objektplan__intro {
  margin: 0 0 1rem;
  color: var(--kjf-op-muted);
}

.kjf-objektplan__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.kjf-objektplan__meta span {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(111, 155, 86, 0.16);
  color: var(--kjf-op-ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.kjf-objektplan__detail-media {
  margin: 0 0 1rem;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.kjf-objektplan__detail-media img {
  display: block;
  width: 100%;
  height: auto;
}

.kjf-objektplan__doc-images {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.kjf-objektplan__doc-image {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--kjf-op-line);
}

.kjf-objektplan__doc-image img {
  display: block;
  width: 100%;
  height: auto;
}

.kjf-objektplan__doc-image figcaption {
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  color: var(--kjf-op-muted);
}

.kjf-objektplan__floors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.kjf-objektplan__floor-tab {
  appearance: none;
  border: 1px solid var(--kjf-op-line);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--kjf-op-ink);
}

.kjf-objektplan__floor-tab.is-active {
  background: var(--kjf-op-ink);
  color: #fff;
  border-color: var(--kjf-op-ink);
}

.kjf-objektplan__floorplan {
  display: none;
}

.kjf-objektplan__downloads {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  list-style: none;
}

.kjf-objektplan__downloads > li,
.kjf-objektplan__downloads li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kjf-objektplan__downloads > li::before,
.kjf-objektplan__downloads li::before {
  content: none !important;
  display: none !important;
}

.kjf-objektplan__downloads a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--kjf-op-line);
  color: var(--kjf-op-ink);
  text-decoration: none;
  font-weight: 600;
}

.kjf-objektplan__downloads a:hover,
.kjf-objektplan__downloads a:focus-visible {
  border-color: var(--kjf-op-green);
}

.kjf-objektplan__legend,
.kjf-objektplan__legend-extra {
  display: block;
  margin-top: 1.5rem;
  text-align: left;
  position: relative;
  z-index: 0;
  width: 100%;
  max-width: none !important;
}

.kjf-objektplan.is-detail .kjf-objektplan__legend,
.kjf-objektplan.is-detail .kjf-objektplan__legend-extra {
  z-index: 0;
}

.kjf-objektplan__legend-title {
  font-size: 1.1rem;
  margin: 0 0 0.6rem;
}

/* div-Grid statt ul → Template-Listenstyles können die Breite nicht mehr kappen */
.kjf-objektplan__legend-list {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem 1.1rem;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
  float: none !important;
  columns: auto !important;
}

.kjf-objektplan__legend-list > * {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
  max-width: none;
  float: none;
}

.kjf-objektplan__legend-list > *::before,
.kjf-objektplan__legend-list > *::marker {
  content: none;
  display: none;
}

.kjf-objektplan__legend-list button {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: none;
  padding: 0.15rem 0;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.kjf-objektplan__legend-list button:hover,
.kjf-objektplan__legend-list button:focus-visible {
  color: var(--kjf-op-green);
}

.kjf-objektplan__legend-list .kjf-objektplan__badge {
  flex: 0 0 auto;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.3rem;
  font-size: 0.75rem;
  background: var(--kjf-op-accent);
  color: var(--kjf-op-accent-ink);
}

.kjf-objektplan__legend-list .kjf-objektplan__badge.is-pill {
  width: auto;
  padding: 0 0.5rem;
}

.kjf-objektplan__legend-list button > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 1200px) {
  .kjf-objektplan__legend-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .kjf-objektplan__legend-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .kjf-objektplan__legend-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .kjf-objektplan__legend-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .kjf-objektplan__legend-list {
    grid-template-columns: 1fr;
  }
}

/* —— Mobile: sticky Karte+Info, Legende scrollt mit der Seite —— */
@media (max-width: 767px) {
  .kjf-objektplan {
    --kjf-op-sticky-top: var(--header-h-mobile, 78px);
    display: block;
    height: auto;
    max-height: none;
    min-height: 0;
    padding: 0.5rem 0 1.5rem;
    overflow: visible;
  }

  .kjf-objektplan__header {
    margin-bottom: 0.45rem;
    padding: 0 0.15rem;
  }

  .kjf-objektplan__title {
    font-size: 1.2rem;
    margin: 0 0 0.15rem;
  }

  /* Visuell ausblenden, aber für Screenreader/„Seite anhören“ behalten */
  .kjf-objektplan__lead {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .kjf-objektplan__mobile-top {
    display: block;
    position: sticky;
    top: var(--kjf-op-sticky-top);
    z-index: 8;
    background: #fff;
    padding-bottom: 0.35rem;
    margin-bottom: 0.35rem;
  }

  .kjf-objektplan.is-detail .kjf-objektplan__mobile-top {
    /* Platz für Info-Karte, die leicht unter die Map hängt */
    padding-bottom: 0.85rem;
  }

  .kjf-objektplan__stage {
    position: relative;
    height: 32vh;
    min-height: 160px;
    max-height: 260px;
    z-index: 1;
    overflow: visible;
  }

  .kjf-objektplan.is-detail .kjf-objektplan__stage {
    z-index: 2;
  }

  .kjf-objektplan__viewport {
    height: 100% !important;
    min-height: 0;
    border-radius: 10px;
  }

  .kjf-objektplan__panel,
  .kjf-objektplan__backdrop {
    display: none !important;
  }

  .kjf-objektplan__markers {
    pointer-events: auto;
  }

  .kjf-objektplan__marker {
    pointer-events: auto;
  }

  /* Info-Overlay: nur leicht in die Karte, Rest darunter → Pin bleibt sichtbar */
  .kjf-objektplan__mobile-info {
    display: block;
    position: absolute;
    left: 50%;
    top: calc(100% - 10px);
    bottom: auto;
    transform: translateX(-50%);
    z-index: 6;
    width: min(78%, 260px);
    margin: 0;
    padding: 0.65rem 0.7rem 0.6rem;
    border-radius: 12px;
    background: var(--kjf-op-panel);
    border: 1px solid var(--kjf-op-line);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    text-align: left;
    max-height: none;
    overflow: visible;
    pointer-events: auto;
  }

  .kjf-objektplan__mobile-info-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0 12px 0 10px;
    background: transparent;
    color: var(--kjf-op-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
  }

  .kjf-objektplan__mobile-info-close:hover,
  .kjf-objektplan__mobile-info-close:focus-visible {
    color: var(--kjf-op-ink);
  }

  .kjf-objektplan__mobile-info[hidden] {
    display: none !important;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__building-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 1.5rem 0.35rem 0;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__building-title > span:last-child {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 700;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__badge {
    flex: 0 0 auto;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.35rem;
    font-size: 0.72rem;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__meta {
    margin: 0 0 0.25rem;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__meta span {
    font-size: 0.72rem;
    padding: 0.12rem 0.4rem;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__intro {
    margin: 0 0 0.3rem;
    font-size: 0.8rem;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__detail-media {
    margin: 0.3rem auto 0;
    width: min(100%, 132px);
    aspect-ratio: 4 / 3;
    max-height: none;
    border-radius: 8px;
    overflow: hidden;
    background: #e8efe4;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__detail-media button {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
    background: transparent;
  }

  .kjf-objektplan__mobile-info .kjf-objektplan__detail-media img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
  }

  .kjf-objektplan__legend {
    position: relative;
    z-index: 1;
    margin-top: 0.25rem;
    margin-bottom: 0;
    overflow: visible;
    padding: 0 0.1rem 1rem;
    /* Abstand, wenn Info-Karte nach unten hängt */
  }

  .kjf-objektplan.is-detail .kjf-objektplan__legend {
    margin-top: 7.5rem;
  }

  .kjf-objektplan__legend-title {
    position: static;
    margin: 0 0 0.4rem;
    padding: 0;
    background: transparent;
    font-size: 1rem;
  }

  .kjf-objektplan__legend-list {
    grid-template-columns: 1fr !important;
    gap: 0.15rem !important;
  }

  .kjf-objektplan__legend-list button {
    min-height: 48px;
    padding: 0.55rem 0.35rem;
    font-size: 1rem;
    gap: 0.65rem;
    border-radius: 10px;
  }

  .kjf-objektplan__legend-list button:hover,
  .kjf-objektplan__legend-list button:focus-visible {
    color: inherit;
    background: rgba(111, 155, 86, 0.1);
  }

  .kjf-objektplan__legend-list button.is-active {
    background: rgba(245, 213, 71, 0.35);
  }

  .kjf-objektplan__legend-list .kjf-objektplan__badge {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.85rem;
  }

  .kjf-objektplan__legend-extra {
    display: none;
  }

  .kjf-objektplan__empty {
    padding: 0.5rem 0;
  }
}

.kjf-objektplan__empty {
  padding: 1rem 0;
  color: var(--kjf-op-muted);
}

@keyframes kjf-op-panel-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes kjf-op-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

  .kjf-objektplan__panel,
  .kjf-objektplan__backdrop {
    animation: none !important;
  }
}
