#plannen {
  background: var(--warm);
  padding: 6rem 2rem;
}
#plannen .section-intro {
  max-width: 720px;
}
.plans-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 0;
}
.plans-modes,
.plans-levels {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
#plannen button,
#plannen select {
  font: 500 0.875rem var(--font-sans);
  color: var(--dark);
  border: 1px solid #d2cec3;
  background: transparent;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  min-height: 44px;
}
#plannen button:hover {
  background: #e3dfd3;
}
#plannen button[aria-pressed="true"] {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
}
#plannen button:disabled {
  opacity: 0.4;
  cursor: default;
}
.plans-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  background: #faf9f5;
  border: 1px solid #d7d2c7;
}
.plans-workspace {
  min-width: 0;
  border-right: 1px solid #d7d2c7;
}
.plans-levels {
  padding: 1rem;
  border-bottom: 1px solid #ded8cc;
}
.plans-levels button {
  flex: 1;
  font-size: 0.8rem !important;
  padding: 0.7rem 0.3rem !important;
}
.plans-viewport {
  height: 660px;
  position: relative;
  overflow: hidden;
  background: #f1efe9;
}
.plans-model,
.plans-flat {
  position: absolute;
  inset: 0;
}
.plans-model canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.plans-flat {
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.plans-surface {
  height: 100%;
  width: 100%;
  transform-origin: center;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.plans-surface svg,
.plans-surface img {
  height: 96%;
  width: 96%;
  object-fit: contain;
  max-width: none;
}
.plans-tools {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.3rem;
  z-index: 2;
  max-width: calc(100% - 2rem);
}
#plannen .plans-tools button {
  background: #faf9f5ed;
  padding: 0.55rem 0.75rem;
}
.plans-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #6b645b;
  font-size: 0.9rem;
}
.plans-model-tools,
.plans-documents {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #ded8cc;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
}
.plans-documents select {
  max-width: 100%;
}
.plans-documents a {
  color: var(--sage);
  font-size: 0.8rem;
}
.plans-side {
  padding: 1.5rem;
  min-width: 0;
}
.plans-level-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sage);
  margin-bottom: 0.5rem;
}
.plans-side h3 {
  font: 400 2.2rem/1.15 var(--font-serif);
  margin-bottom: 1rem;
}
.plans-description {
  font-size: 1rem;
  line-height: 1.7;
  color: #5a564e;
}
.plans-photo {
  margin: 1.5rem 0;
}
.plans-photo img {
  width: 100%;
  height: 185px;
  object-fit: cover;
  display: block;
}
.plans-photo figcaption {
  font-size: 0.75rem;
  color: #777165;
  margin-top: 0.6rem;
}
.plans-room-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  margin: 1.5rem 0 0.7rem;
  text-transform: uppercase;
  color: #777165;
}
.plans-rooms {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
#plannen .plans-rooms button {
  font-size: 0.8rem;
  padding: 0.55rem 0.7rem;
}
.plans-help {
  font-size: 0.75rem;
  color: #736d60;
  padding: 0.7rem 1rem;
  border-top: 1px solid #ded8cc;
}
.plans-status {
  font-size: 0.8rem;
  color: var(--sage);
  padding-top: 0.6rem;
  min-height: 1.7em;
}
.plans-static {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.plans-static img {
  width: 100%;
  height: 380px;
  object-fit: contain;
}
.plans-static a {
  color: var(--sage);
}
.plans-static-links {
  grid-column: 1/-1;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
/* Mode switcher as tabs attached to the viewer, so the whole block reads as one unit. */
.plans-modes {
  gap: 0;
}
#plannen .plans-modes button {
  border-bottom: 0;
  margin-right: -1px;
  background: #e8e5dc;
  color: #5a564e;
}
#plannen .plans-modes button:hover {
  background: #efece5;
}
#plannen .plans-modes button[aria-pressed="true"] {
  position: relative;
  z-index: 1;
  margin-bottom: -1px;
  padding-bottom: calc(0.7rem + 1px);
  background: #faf9f5;
  border-color: #d7d2c7;
  color: var(--dark);
  box-shadow: inset 0 3px 0 var(--sage);
}
.plans-layout {
  box-shadow: 0 1px 2px #292e2810, 0 8px 24px #292e280d;
}
@media (max-width: 1100px) {
  .plans-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
  #navbar .nav-left {
    gap: 0.75rem;
  }
  #navbar .nav-left a {
    font-size: 0.62rem;
  }
}
@media (max-width: 850px) {
  .plans-layout {
    grid-template-columns: 1fr;
  }
  .plans-workspace {
    border-right: 0;
  }
  .plans-side {
    border-top: 1px solid #d7d2c7;
  }
  .plans-viewport {
    height: 560px;
  }
  .plans-photo img {
    height: 240px;
  }
  .plans-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
  }
  .plans-level-label,
  .plans-side h3,
  .plans-room-label,
  .plans-rooms {
    grid-column: 1/-1;
  }
  .plans-photo {
    margin: 0;
  }
  .plans-static {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  #plannen {
    padding: 3.5rem 1rem;
  }
  .plans-top {
    margin-top: 1.5rem;
  }
  .plans-modes {
    width: 100%;
    gap: 0.2rem;
  }
  #plannen .plans-modes button {
    font-size: 0.75rem;
    padding: 0.65rem 0.45rem;
    flex: 1;
  }
  .plans-levels {
    padding: 0.65rem;
    gap: 0.25rem;
  }
  #plannen .plans-levels button {
    font-size: 0.7rem !important;
  }
  .plans-viewport {
    height: 490px;
  }
  .plans-side {
    display: block;
    padding: 1.2rem;
  }
  .plans-photo {
    margin-top: 1rem;
  }
  .plans-viewport .plans-tools {
    left: 0.6rem;
    bottom: 0.6rem;
    gap: 0.2rem;
  }
  #plannen .plans-tools button {
    padding: 0.45rem 0.55rem;
  }
  .plans-model-tools {
    padding: 0.6rem;
    font-size: 0.8rem;
  }
  .plans-model-tools select {
    font-size: 0.8rem !important;
    max-width: 100%;
  }
}

/* Keep the existing viewer and its selection alive in the modal top layer. */
#plannen .plans-fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  border: 0;
  background: var(--warm);
  color: var(--dark);
  overflow: auto;
  overscroll-behavior: contain;
}
.plans-fullscreen::backdrop { background: #292e28; }
.plans-fullscreen .plans-top { margin: 0; }
.plans-fullscreen .plans-viewport { height: max(340px, calc(100dvh - 250px)); }
.plans-fullscreen .plans-side { max-height: calc(100dvh - 120px); overflow: auto; }
#plannen #planFullscreen, #plannen #planReset { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; }
#planFullscreen .plan-collapse-icon { display: none; }
.plans-fullscreen #planFullscreen .plan-expand-icon { display: none; }
.plans-fullscreen #planFullscreen .plan-collapse-icon { display: block; }
#plannen button:focus-visible { outline: 3px solid var(--sage); outline-offset: 3px; }
@media (max-width: 850px) {
  .plans-fullscreen .plans-side { max-height: none; overflow: visible; }
  .plans-fullscreen .plans-top { position: sticky; top: -1rem; z-index: 5; background: var(--warm); padding: .5rem 0; }
}
@media (max-width: 520px) {
  #plannen .plans-fullscreen { padding: .5rem; }
  .plans-fullscreen .plans-top { top: -.5rem; gap: .5rem; }
  .plans-fullscreen .plans-viewport { height: max(320px, calc(100dvh - 270px)); }
}

#plannen .plans-model-tools { gap: .3rem; }
#plannen .plans-model-tools button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .5rem .8rem; font-size: .8rem; white-space: nowrap; }
@media (max-width: 600px) {
  #plannen .plans-model-tools button { flex: 1 1 0; flex-direction: column; gap: .2rem; padding: .4rem .3rem; font-size: .7rem; }
}

/* Compact numbered segments, shown only when choosing a floor applies. */
#plannen .plans-levels {
  gap: .25rem;
  padding: .6rem .8rem;
  background: #eeece5;
}
#plannen .plans-levels button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border: 0;
  border-radius: 4px;
  padding: .55rem .7rem !important;
  min-height: 44px;
}
.plan-floor-number { font-size: .7rem; opacity: .65; font-variant-numeric: tabular-nums; }
#plannen .plans-levels button[aria-pressed="true"] { box-shadow: 0 1px 3px #292e2820; }
@media (max-width: 520px) {
  #plannen .plans-levels { padding: .5rem; }
  #plannen .plans-levels button { flex-direction: column; gap: .2rem; padding: .45rem .25rem !important; }
}

/* Room panel: a plain column on wide screens, a compact bar with a pop-up panel on small ones. */
.plans-thumb, #plannen .plans-sheet-toggle { display: none; }
@media (max-width: 850px) {
  .plans-viewport { height: clamp(300px, calc(100svh - 430px), 560px); }
  .plans-fullscreen .plans-viewport { height: max(280px, calc(100dvh - 360px)); }
  .plans-help { display: none; }
  .plans-side { display: flex; flex-direction: column; gap: 0; padding: 0; position: relative; background: #faf9f5; }
  .plans-side-head { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; cursor: pointer; min-height: 64px; }
  .plans-thumb:not([hidden]) { display: block; width: 52px; height: 52px; object-fit: cover; flex: none; }
  .plans-side-titles { flex: 1; min-width: 0; }
  .plans-side .plans-level-label { margin: 0 0 .1rem; font-size: .68rem; }
  .plans-side h3 { font-size: 1.45rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #plannen .plans-sheet-toggle { display: inline-flex; align-items: center; gap: .35rem; flex: none; padding: .45rem .7rem; font-size: .78rem; }
  .plans-sheet-toggle svg { transition: transform .25s; }
  .is-open .plans-sheet-toggle svg { transform: rotate(180deg); }
  .plans-room-label { display: none; }
  .plans-rooms { position: relative; flex-wrap: nowrap; overflow-x: auto; padding: 0 .8rem .7rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .plans-rooms::-webkit-scrollbar { display: none; }
  #plannen .plans-rooms button { flex: none; white-space: nowrap; }
  .plans-side-body { position: absolute; left: 0; right: 0; bottom: 100%; z-index: 4; max-height: min(430px, 62svh); overflow: auto; padding: 1rem; background: #faf9f5; border-top: 1px solid #d7d2c7; box-shadow: 0 -10px 24px #292e2822; opacity: 0; visibility: hidden; transform: translateY(14px); transition: opacity .22s, transform .22s, visibility 0s .22s; }
  .is-open .plans-side-body { opacity: 1; visibility: visible; transform: none; transition: opacity .22s, transform .22s; }
  .plans-side-body .plans-photo { margin: 0 0 .8rem; }
  .plans-side-body .plans-photo img { height: auto; aspect-ratio: 4/3; max-height: 46svh; }
  .plans-side-body { display: flex; flex-direction: column-reverse; }
  .plans-description { font-size: .92rem; line-height: 1.6; }
}
@media (prefers-reduced-motion: reduce) { .plans-side-body, .plans-sheet-toggle svg { transition: none !important; } }
