body:has(#loft-dialog[open]) { overflow: hidden; }
#loft-dialog {
  width: min(1120px, 96vw); max-width: none; max-height: 96dvh; padding: 0; overflow: auto;
  border: 0; border-radius: 10px; background: var(--paper); color: var(--ink);
}
#loft-dialog[open] { display: flex; flex-direction: column; }
#loft-dialog::backdrop { background: rgb(21 29 23 / 76%); }
.loft-bar, .loft-foot, #loft-furniture { display: flex; align-items: center; gap: 12px; padding: 9px 16px; }
.loft-bar, .loft-foot { justify-content: space-between; }
.loft-bar h2 { font-size: 1.15rem; letter-spacing: -.03em; }
#loft-dialog button, #loft-dialog select {
  border-radius: 5px; border: 1px solid #bbc2b7; background: var(--white); color: var(--ink);
  font-size: .91rem; font-weight: 580; line-height: 1.2; padding: 7px 12px; min-height: 40px; touch-action: manipulation;
}
#loft-dialog button:hover { background: #e4e8df; }
#loft-dialog #loft-close, #loft-dialog #loft-reset { padding-inline: 6px; background: transparent; border-color: transparent; }
#loft-close span { font-size: 1.22rem; margin-left: 5px; }
#loft-stage { position: relative; flex: 1 1 auto; min-height: 140px; height: min(66dvh, 620px); background: #dcd4c4; overflow: hidden; isolation: isolate; }
#loft-canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; outline-offset: -3px; cursor: grab; }
#loft-canvas:active { cursor: grabbing; }
#loft-message { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; background: #f1eee7; }
#loft-stage.unavailable { background: center/cover url('/assets/eksempelloft.webp'); }
.unavailable #loft-message { inset: auto 14px 14px; padding: 12px; border-radius: 6px; }
.loft-modes, .loft-pad { position: absolute; }
.loft-modes { inset: 12px auto auto 12px; display: flex; gap: 3px; padding: 3px; background: var(--paper); border-radius: 7px; box-shadow: 0 1px 8px #20282030; }
#loft-dialog .loft-modes button { border: 0; background: transparent; }
#loft-dialog .loft-modes button[aria-pressed="true"] { background: var(--green); color: white; }
.loft-pad { right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(3, 42px); gap: 3px; user-select: none; -webkit-user-select: none; }
#loft-dialog .loft-pad button { height: 42px; border: 1px solid #adb7a9; background: rgb(253 252 248 / 95%); font-size: 1.12rem; padding: 4px; touch-action: none; }
.loft-pad [data-dir=up] { grid-column: 2; }
.loft-pad [data-dir=left] { grid-column: 1; }
#loft-furniture { justify-content: center; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rotation { display: flex; gap: 4px; }
.loft-foot p { font-size: .86rem; color: var(--muted); }
#loft-dialog #loft-reset { font-size: .8rem; white-space: nowrap; text-decoration: underline; }
@media (max-width: 650px), (max-height: 500px) {
  #loft-dialog { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  #loft-stage { height: auto; }
  .loft-bar, .loft-foot, #loft-furniture { padding: 5px 12px; }
  .loft-foot { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
}

.loft-exit { display: flex; gap: clamp(10px, 2vw, 26px); align-items: center; }
.loft-exit a { color: var(--green); font-size: .86rem; font-weight: 600; }

#loft-level {
  position: absolute; top: 13px; right: 12px; background: var(--paper); color: var(--green);
  border-radius: 5px; padding: 7px 10px; font-size: .78rem; pointer-events: none;
}
