/* House tour — inspection interface.
   Palette is inherited from the accepted render: warm white paper, dark ink,
   one architectural blue for interaction. No separate brand. */

:root {
  --paper: #f6f3ed;
  --paper-sunk: #efeae0;
  --paper-raised: #fbf9f5;
  --ink: #17140f;
  --ink-soft: #4a4437;
  --ink-mute: #6b6455;
  --rule: #ddd6c8;
  --rule-soft: #e8e2d6;
  --accent: #1b4d8f;
  --accent-soft: #dce5f0;
  --stage: #100e0b;

  --rail-w: 19rem;
  --sheet-h: 62vh;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --shadow-panel: 0 1px 2px rgba(23, 20, 15, .06),
                  0 10px 30px -12px rgba(23, 20, 15, .22);
  --shadow-lift: 0 2px 8px rgba(23, 20, 15, .18);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--stage);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Browser surfaces belong to this design, not to the platform. */
::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: .5rem; top: -3rem;
  z-index: 90;
  padding: .55rem .9rem;
  background: var(--paper-raised);
  color: var(--ink);
  font: 600 13px/1 var(--sans);
  text-decoration: none;
  border-radius: 8px;
  box-shadow: var(--shadow-panel);
  transition: top .18s var(--ease);
}
.skip-link:focus { top: .5rem; }

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  /* An explicit row keeps the stage at viewport height; without it the rail's
     content stretches the row and the panorama canvas overflows. */
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

/* ── Rail ─────────────────────────────────────────────────────────── */

.rail {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--rule);
  min-width: 0;
  min-height: 0;
}

.rail__scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c8c0af transparent;
  padding: 1.6rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.rail__scroll::-webkit-scrollbar { width: 10px; }
.rail__scroll::-webkit-scrollbar-thumb {
  background: #cbc3b2;
  border: 3px solid var(--paper);
  border-radius: 99px;
}

.rail__head { display: flex; flex-direction: column; gap: .3rem; }

.rail__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.15;
  text-wrap: balance;
}

.rail__status {
  margin: 0;
  font-size: .75rem;
  line-height: 1.45;
  color: var(--ink-mute);
  letter-spacing: .01em;
}

.section-heading {
  margin: 0 0 .6rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Room list */
.rooms__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.room {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  width: 100%;
  padding: .48rem .6rem .48rem .55rem;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background-color .14s var(--ease);
}
.room:hover { background: var(--paper-sunk); }

.room__id {
  flex: none;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  letter-spacing: .02em;
}
.room__name {
  flex: 1;
  min-width: 0;
  font-size: .9rem;
}
.room__kind {
  flex: none;
  font-size: .68rem;
  color: var(--ink-mute);
  letter-spacing: .04em;
}

.room[aria-current="true"] {
  background: var(--ink);
  color: var(--paper);
}
.room[aria-current="true"] .room__id,
.room[aria-current="true"] .room__kind { color: #cfc7b6; }

/* Plan */
.plan__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}
.plan__note {
  margin: 0 0 .6rem;
  font-size: .68rem;
  color: var(--ink-mute);
  letter-spacing: .02em;
}

.plan__frame {
  background: var(--paper-raised);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: .5rem;
}

.plan__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.plan__room {
  fill: #fffdf9;
  stroke: #b8b0a0;
  stroke-width: .35;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill .14s var(--ease);
}
.plan__room:hover { fill: #f1ece1; }
.plan__room--adjacent { fill: #e9e3d5; }
.plan__room--active { fill: var(--ink); stroke: var(--ink); }
.plan__room--sunroom { stroke-dasharray: 1.6 1.1; }
.plan__room--outdoor { fill: #f0f2ec; }

.plan__label {
  font-family: var(--sans);
  /* font-size is set per label by app.js, which measures the polygon width. */
  font-weight: 600;
  fill: var(--ink-soft);
  text-anchor: middle;
  pointer-events: none;
  letter-spacing: -.01em;
}
.plan__label--active { fill: var(--paper); }
.plan__label--hidden { display: none; }

.plan__door { stroke: var(--ink); stroke-width: .12; stroke-linecap: round; }
.plan__marker { fill: var(--accent); stroke: #fff; stroke-width: .35; }
.plan__view { fill: var(--accent); opacity: .26; }

.plan__room:focus-visible { outline: 2px solid var(--accent); outline-offset: .6px; }

.rail__foot { margin-top: auto; padding-top: .25rem; }
.rail__foot-note {
  margin: 0;
  font-size: .7rem;
  line-height: 1.5;
  color: var(--ink-mute);
  border-top: 1px solid var(--rule-soft);
  padding-top: .7rem;
}

/* ── Stage ────────────────────────────────────────────────────────── */

.stage {
  position: relative;
  overflow: hidden;
  background: var(--stage);
  min-width: 0;
  min-height: 0;
}

.stage:focus { outline: none; }

.stage__viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
.stage__viewport.is-dragging { cursor: grabbing; }

.stage__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Non-WebGL: show the flat equirect strip so the room is still legible. */
.stage__fallback-image {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stage);
  padding: 1rem;
}
.stage__fallback-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow-lift);
}

/* States */
.state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  padding: 1.5rem;
  background: rgba(16, 14, 11, .62);
  backdrop-filter: blur(2px);
  text-align: center;
}

.state[hidden] { display: none; }

.state__spinner {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 2px solid rgba(246, 243, 237, .28);
  border-top-color: var(--paper);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.state__text {
  margin: 0;
  font-size: .85rem;
  letter-spacing: .02em;
  color: var(--paper);
}

.state--error { background: rgba(16, 14, 11, .82); z-index: 3; }

.state__card {
  color: var(--ink);
  max-width: 32rem;
  background: var(--paper-raised);
  border-radius: 14px;
  padding: 1.6rem 1.75rem;
  box-shadow: var(--shadow-lift);
  text-align: left;
}
.state__title {
  margin: 0 0 .5rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.state__body {
  margin: 0 0 1.1rem;
  font-size: .9rem;
  color: var(--ink-soft);
  max-width: 62ch;
}
.state__actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.state__meta {
  margin: .9rem 0 0;
  font-size: .74rem;
  color: var(--ink-mute);
  overflow-wrap: anywhere;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9rem;
  font: 600 .84rem/1 var(--sans);
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 9px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .14s var(--ease), border-color .14s var(--ease);
}
.btn:hover { background: #e6e0d3; }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: #2b2519; }

/* Reading head */
.hud {
  color: var(--ink);
  position: absolute;
  left: 1.15rem;
  top: 1.05rem;
  max-width: min(20rem, 60vw);
  padding: .6rem .85rem .65rem;
  background: var(--paper);
  border-radius: 10px;
  box-shadow: var(--shadow-panel);
  pointer-events: none;
}
.hud__room {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.hud__meta {
  margin: .1rem 0 0;
  font-size: .72rem;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}


.ctl {
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 9px;
  cursor: pointer;
  transition: background-color .14s var(--ease);
}
.ctl:hover { background: var(--paper-raised); }
.ctl:disabled { opacity: .45; cursor: default; }
.ctl svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hotspots */
.hotspots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .34rem .6rem .34rem .4rem;
  background: rgba(246, 243, 237, .95);
  color: var(--ink);
  border: 1px solid rgba(23, 20, 15, .18);
  border-radius: 99px;
  font: 600 .76rem/1 var(--sans);
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(23, 20, 15, .2), 0 8px 20px -8px rgba(23, 20, 15, .4);
  transition: background-color .14s var(--ease), transform .14s var(--ease);
}
.hotspot:hover { background: #fff; transform: translate(-50%, -50%) scale(1.04); }

.hotspot__dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.hotspot__arrow { color: var(--ink-mute); font-size: .7rem; }

/* Hint */
.stage__hint {
  position: absolute;
  left: 50%;
  bottom: 1.05rem;
  transform: translateX(-50%);
  margin: 0;
  padding: .3rem .7rem;
  font-size: .72rem;
  letter-spacing: .03em;
  color: #cfc7b6;
  background: rgba(16, 14, 11, .55);
  border-radius: 99px;
  pointer-events: none;
  transition: opacity .4s var(--ease);
}
.stage__hint[data-hidden="true"] { opacity: 0; }

/* Mobile sheet handle — desktop hidden */
.sheet-handle {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(.6rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  align-items: center;
  gap: .5rem;
  padding: .45rem .9rem .5rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 99px;
  font: 600 .78rem/1 var(--sans);
  cursor: pointer;
  box-shadow: var(--shadow-lift);
}
.sheet-handle__bar {
  width: 1.1rem;
  height: 2px;
  border-radius: 2px;
  background: #b0a894;
}

/* ── Modal ────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal[hidden] { display: none; }

.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 14, 11, .5);
}

.modal__panel {
  color: var(--ink);
  position: relative;
  width: min(30rem, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper-raised);
  border-radius: 14px;
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-lift);
  animation: rise .18s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.modal__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.ctl--ghost { border-color: transparent; background: var(--paper-sunk); }

.keys { margin: 0; display: flex; flex-direction: column; gap: .1rem; }
.keys__row {
  display: flex;
  align-items: baseline;
  gap: .9rem;
  padding: .42rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.keys__row:last-child { border-bottom: 0; }
.keys dt { flex: none; width: 6.2rem; display: flex; gap: .2rem; }
.keys dd { margin: 0; font-size: .88rem; color: var(--ink-soft); }

kbd {
  display: inline-block;
  min-width: 1.35rem;
  padding: .16rem .35rem;
  font: 600 .76rem/1.3 var(--sans);
  text-align: center;
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.modal__foot {
  margin: 1rem 0 0;
  font-size: .82rem;
  color: var(--ink-mute);
  max-width: 62ch;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 60rem) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }

  .stage { grid-row: 1; }

  .rail {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    border-right: 0;
    border-top: 1px solid var(--rule);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-lift);
    height: var(--sheet-h);
    transform: translateY(calc(100% - 0px));
    visibility: hidden;
    transition: transform .26s var(--ease), visibility 0s linear .26s;
  }
  .rail[data-open="true"] {
    transform: translateY(0);
    visibility: visible;
    transition: transform .26s var(--ease);
  }
  .rail__scroll { padding-top: 1.15rem; }

  .sheet-handle { display: inline-flex; }

  .hud { top: .8rem; bottom: auto; }
  .stage__hint { bottom: calc(3.6rem + env(safe-area-inset-bottom, 0px)); }
  .hud { left: .8rem; }
}

@media (max-width: 60rem) {
  /* Hint duplicates the help sheet on small screens. */
  .stage__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (forced-colors: active) {
  .plan__room { fill: Canvas; stroke: CanvasText; }
  .plan__room--active { fill: Highlight; }
  .room[aria-current="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
@media (max-width: 60rem) {
  .ctl { min-width: 44px; min-height: 44px; }
  .hotspot, .sheet-handle { min-height: 44px; }
}

/* Always-available doorway actions, including doors behind the visitor. */
.connections {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .75rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  width: fit-content;
  max-width: calc(100% - 2rem);
}
.connections__label { flex: none; font-size: .75rem; color: var(--ink-soft); }
.connections__list { display: flex; gap: .35rem; overflow-x: auto; min-width: 0; padding: 3px; }
.connection {
  flex: none;
  min-height: 44px;
  padding: .5rem .8rem;
  background: var(--paper-sunk);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font: 600 .8rem/1.2 var(--sans);
  cursor: pointer;
}
.connection:hover { background: var(--accent-soft); }
.stage__hint { bottom: 5.5rem; }
.walk-controls, .live-help { display: none; }
.is-live .live-help { display: flex; }
.is-live .walk-controls {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: .3rem;
  position: absolute;
  right: 1rem;
  bottom: 1rem;
}
.walk-controls .ctl { width: 44px; height: 44px; touch-action: none; }
.walk-controls [data-walk="w"] { grid-column: 2; }
.walk-controls [data-walk="a"] { grid-column: 1; }
.is-live .connections { max-width: calc(100% - 12rem); }
.is-live.is-embed .walk-controls { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }

/* Embeds use the same compact navigation sheet at every size. */
.is-embed .shell { grid-template-columns: 1fr; }
.is-embed .stage { grid-row: 1; }
.is-embed .rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  border-right: 0;
  border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0;
  height: 75%;
  transform: translateY(100%);
  visibility: hidden;
}
.is-embed .rail[data-open="true"] { transform: translateY(0); visibility: visible; }
.is-embed .sheet-handle { display: inline-flex; min-height: 44px; }
.is-embed .ctl { min-width: 44px; min-height: 44px; }
.is-embed .stage__hint { display: none; }
.is-embed .connections { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 60rem) {
  .connections { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }
  .is-live .walk-controls { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }
  .is-live .connections { flex-direction: column; align-items: start; gap: 0; }
  .is-live .connections__list { max-width: 100%; }
}
@media (max-height: 420px) {
  .hud__meta { display: none; }
  .connections { padding: .25rem .5rem; }
}

/* Phone exploration: unobstructed view, thumb movement, one room strip. */
.joystick, .rail__close, .look-hint, .nearby-toggle { display: none; }
.rail__close { align-self: flex-end; min-height: 44px; }
.rail[data-open="true"] .rail__close { display: inline-flex; }
.room { min-height: 44px; }
@media (max-width: 640px), (max-height: 500px) and (max-width: 1000px) {
  .hud { left: max(.75rem, env(safe-area-inset-left)); top: .75rem; max-width: calc(100% - 1.5rem); }
  .hud__meta { display: none; }
  .is-live .walk-controls { display: none; }
  .sheet-handle, .is-embed .sheet-handle {
    left: max(.75rem, env(safe-area-inset-left));
    bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
    transform: none;
    min-height: 48px;
    font-size: .85rem;
    z-index: 45;
  }
  .connections, .is-embed .connections, .is-live .connections {
    left: max(.75rem, env(safe-area-inset-left));
    right: max(.75rem, env(safe-area-inset-right));
    width: auto;
    max-width: none;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
    padding: .5rem;
  }
  .is-live .connections, .is-live.is-embed .connections { bottom: calc(12.5rem + env(safe-area-inset-bottom, 0px)); }
  .connections__label { padding-left: .25rem; }
  .connections__list { max-width: 100%; scrollbar-width: thin; scrollbar-color: var(--ink-mute) var(--paper); }
  .connection { min-height: 48px; font-size: .85rem; }
  .is-live .joystick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    position: absolute;
    bottom: calc(4.4rem + env(safe-area-inset-bottom, 0px));
    left: max(.9rem, env(safe-area-inset-left));
  }
  .joystick__pad {
    display: grid;
    place-items: center;
    position: relative;
    width: 96px;
    height: 96px;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink);
    padding: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .joystick__arrows { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
  .joystick__thumb { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); pointer-events: none; }
  .joystick__label { color: var(--ink); background: var(--paper); font: 600 .75rem/1.4 var(--sans); padding: .1rem .4rem; border-radius: 4px; }
  .is-live .look-hint {
    display: block;
    position: absolute;
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: calc(6.3rem + env(safe-area-inset-bottom, 0px));
    margin: 0;
    padding: .4rem .65rem;
    background: var(--paper);
    color: var(--ink-soft);
    border-radius: 8px;
    font-size: .8rem;
    text-align: center;
    pointer-events: none;
  }
  .joystick__pad[data-active="true"] { background: var(--accent-soft); }
  .rail, .is-embed .rail { height: 85%; border-radius: 12px 12px 0 0; }
  .rail__scroll { padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }
  .stage[data-navigation-open="true"] .joystick,
  .stage[data-navigation-open="true"] .connections { visibility: hidden; }
  .stage[data-navigation-open="true"] .nearby-toggle { visibility: hidden; }
  .stage[data-navigation-open="true"] .look-hint { visibility: hidden; }
  .hotspot { font-size: .85rem; }
}
@media (max-width: 640px) and (orientation: portrait) {
  .is-live .connections, .is-live.is-embed .connections { display: none; }
  .is-live .stage[data-nearby-open="true"] .connections { display: flex; }
  .is-live .nearby-toggle {
    display: inline-flex;
    position: absolute;
    right: max(.75rem, env(safe-area-inset-right));
    bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    padding: .6rem .65rem;
    font-size: .8rem;
  }
}
@media (max-height: 500px) and (max-width: 1000px) {
  .connections, .is-embed .connections, .is-live .connections, .is-live.is-embed .connections {
    left: 11rem;
    right: .75rem;
    bottom: .75rem;
    flex-direction: row;
    align-items: center;
  }
  .is-live .joystick { bottom: 4.2rem; }
  .connections__label { display: none; }
  .joystick__pad { width: 80px; height: 80px; }
  .joystick__label { display: none; }
  .is-live .look-hint { display: none; }
  .sheet-handle, .is-embed .sheet-handle { font-size: .75rem; padding-inline: .65rem; }
}

/* House explorer: one immersive surface with spatial view controls. */
.showcase-only { display: none; }
.is-showcase .explorer-nav {
  display: flex;
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  gap: .25rem;
  padding: .3rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  z-index: 46;
  box-shadow: var(--shadow-lift);
}
.explorer-view {
  display: flex; align-items: center; gap: .45rem;
  min-height: 48px; padding: .6rem .75rem;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ink);
  font: 600 .8rem/1.2 var(--sans); cursor: pointer;
}
.explorer-view:hover { background: var(--paper-sunk); }
.explorer-view[aria-pressed="true"], .explorer-view[aria-expanded="true"] { background: var(--ink); color: var(--paper-raised); }
.explorer-view svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.is-showcase .sheet-handle, .is-showcase .connections, .is-showcase .nearby-toggle,
.is-showcase .joystick, .is-showcase .look-hint, .is-showcase .walk-controls { display: none; }
.is-showcase .hud__meta { display: none; }
.is-showcase .explorer-hint { display: block; position: absolute; bottom: 1.4rem; right: 1rem; max-width: 24rem; padding: .4rem .75rem; margin: 0; background: var(--paper); color: var(--ink-soft); font-size: .8rem; border-radius: 8px; pointer-events: none; }
.is-showcase .stage:not([data-presentation="floorplan"]) .overview-labels { display: none; }
.is-showcase .stage[data-presentation="dollhouse"] .hotspots,
.is-showcase .stage[data-presentation="floorplan"] .hotspots { display: none; }
.is-showcase .overview-labels { display: block; position: absolute; inset: 0; pointer-events: none; }
/* Room names on the plan drawing: small white type with a shadow, nothing boxed, so the plan stays the picture. */
.overview-room {
  position: absolute; transform: translate(-50%, -50%); max-width: 6.2rem; padding: .1rem .2rem; border: 0; background: none;
  color: #fff; font: 600 .72rem/1.15 var(--sans); letter-spacing: .01em; text-align: center; text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85), 0 0 5px rgba(0, 0, 0, .6);
  pointer-events: auto; cursor: pointer;
}
.overview-room:hover, .overview-room:focus-visible { text-decoration: underline; }
.is-showcase .level-switch:not([hidden]) {
  display: flex; flex-direction: column; gap: .2rem;
  position: absolute; right: max(1rem, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  padding: .3rem; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-lift); z-index: 46;
}
.level-switch__floor {
  min-height: 44px; min-width: 44px; padding: .45rem .7rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font: 600 .78rem/1.15 var(--sans); cursor: pointer; text-align: left;
}
.level-switch__floor:hover { background: var(--paper-sunk); }
.level-switch__floor[aria-pressed="true"] { background: var(--ink); color: var(--paper-raised); }
.room-level { padding: .9rem .25rem .3rem; color: var(--ink-mute); font: 600 .72rem/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; list-style: none; }
.is-showcase .room { grid-template-columns: 84px 2.5rem minmax(0, 1fr); gap: .65rem; }
.is-showcase .room__preview { width: 84px; height: 56px; grid-row: 1 / 3; object-fit: cover; border-radius: 4px; background: var(--paper-sunk); }
.is-showcase .room__id { grid-column: 2; }
.is-showcase .room__name { grid-column: 3; }
.is-showcase .room__kind { grid-column: 3; }
.is-showcase .rail { max-width: 32rem; left: 1rem; bottom: 5rem; height: min(75%, 650px); border-radius: 12px; }
.is-showcase .rail__scroll { padding-bottom: 1rem; }
.is-showcase .stage[data-navigation-open="true"] .explorer-hint { visibility: hidden; }
.is-showcase .stage__canvas { transition: opacity .13s var(--ease); }
.is-showcase .stage[data-transitioning="true"] .stage__canvas { opacity: .25; }
@media (max-width: 640px) {
  .is-showcase .explorer-nav { left: max(.75rem, env(safe-area-inset-left)); bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); right: max(.75rem, env(safe-area-inset-right)); gap: .15rem; justify-content: space-between; }
  .explorer-view { flex-direction: column; gap: .3rem; padding: .35rem .55rem; min-width: 58px; font-size: .72rem; min-height: 54px; }
  .is-showcase .explorer-hint { bottom: calc(5.3rem + env(safe-area-inset-bottom, 0px)); left: .75rem; right: .75rem; max-width: none; text-align: center; font-size: .75rem; }
  .is-showcase .rail { left: 0; bottom: 5.3rem; right: 0; max-width: none; height: 78%; border-radius: 12px 12px 0 0; }
  .is-showcase .room { grid-template-columns: 72px 2.2rem minmax(0, 1fr); gap: .5rem; }
  .is-showcase .room__preview { width: 72px; height: 52px; }
}
@media (max-height: 500px) and (max-width: 1000px) {
  .is-showcase .explorer-hint { display: none; }
  .is-showcase .explorer-nav { bottom: .6rem; left: .6rem; }
  .explorer-view { flex-direction: row; min-height: 44px; padding: .4rem .65rem; }
  .is-showcase .rail { bottom: 4.3rem; height: calc(100% - 4.8rem); }
}
@media (prefers-reduced-motion: reduce) { .is-showcase .stage__canvas { transition: none; } }

/* Panorama doorway controls stay legible without covering the doorway. */
html:not(.is-live) .hotspot {
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  background: var(--paper);
}
html:not(.is-live) .hotspot__dot {
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  transform: translateY(3px) rotate(-45deg);
}
html:not(.is-live) .hotspot__name {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  padding: .45rem .65rem;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  visibility: hidden;
  pointer-events: none;
}
html:not(.is-live) .hotspot:hover .hotspot__name,
html:not(.is-live) .hotspot:focus-visible .hotspot__name { visibility: visible; }
.plan__fixtures, .plan__marker { pointer-events: none; }
.stage:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* Keep the outgoing room readable while a connection downloads. */
.stage[data-panorama-pending] .state--loading {
  inset: auto 1rem 8rem;
  padding: .6rem;
  flex-direction: row;
  background: var(--paper);
  color: var(--ink);
  backdrop-filter: none;
  border-radius: 8px;
  pointer-events: none;
}
.stage[data-panorama-pending] .state__text { color: var(--ink); }
.stage[data-panorama-pending] .state__spinner { border-color: var(--rule); border-top-color: var(--ink); }
@media (max-width: 640px), (max-height: 500px) and (max-width: 1000px) {
  html:not(.is-live) .connections {
    flex-direction: row;
    align-items: center;
    gap: .3rem;
    padding: .25rem .4rem;
  }
  html:not(.is-live) .connection {
    min-height: 44px;
    border-radius: 99px;
    padding: .45rem .7rem;
    font-size: .8rem;
  }
}

html:not(.is-live) .hotspot[data-label-align="left"] .hotspot__name { left: 0; transform: none; }
html:not(.is-live) .hotspot[data-label-align="right"] .hotspot__name { left: auto; right: 0; transform: none; }
.stage[data-panorama-pending] .hotspots { visibility: hidden; }

html:not(.is-live) .hotspot[data-label-placement="below"] .hotspot__name { bottom: auto; top: calc(100% + 7px); }
html:not(.is-live) .hud,
html:not(.is-live) .connections { z-index: 3; }

/* Explorer: room buttons gently float and pulse so they read as "tap me". */
@keyframes hotspot-float {
  0%, 100% { translate: 0 0; scale: 1; }
  50% { translate: 0 -4px; scale: 1.07; }
}
@keyframes hotspot-ping {
  0% { box-shadow: 0 0 0 0 rgba(27, 77, 143, .55); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(27, 77, 143, 0); }
}
html.is-live .hotspot {
  padding: .5rem .8rem .5rem .55rem;
  font-size: .86rem;
  border-color: rgba(23, 20, 15, .28);
  animation: hotspot-float 2.2s ease-in-out infinite;
}
html.is-live .hotspot::after {
  content: "\203A";
  margin-left: .1rem;
  font-size: 1.05rem;
  line-height: .8;
  color: var(--accent);
}
html.is-live .hotspot__dot {
  width: .6rem;
  height: .6rem;
  animation: hotspot-ping 1.8s ease-out infinite;
}
html.is-live .hotspot:hover, html.is-live .hotspot:focus-visible { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  html.is-live .hotspot, html.is-live .hotspot__dot { animation: none; }
}
/* Explorer room tags sit at half opacity (overrides the inline edge fade). */
html.is-live .hotspot { opacity: .5 !important; }
html.is-live .hotspot:hover, html.is-live .hotspot:focus-visible { opacity: 1 !important; }
/* The Rooms list button is gone; room names show on the plan drawing only (they would hide the bird's-eye model). */
.is-showcase #explorerRooms { display: none !important; }

/* Real photo of the room, offered while standing on a blue photo spot. A paper print, large enough to
   notice, that rises once and then pulses (it breathes and sends out a soft pale ring; no blue glow).
   ?peek=b|c are the two alternatives kept for comparison. */
.photo-peek { display: none; }
.is-showcase .photo-peek:not([hidden]) {
  display: flex; flex-direction: column; position: absolute; right: max(1.25rem, env(safe-area-inset-right)); bottom: calc(4.9rem + env(safe-area-inset-bottom, 0px));
  width: 248px; padding: 8px 8px 0; z-index: 45;
  border: 0; border-radius: 5px; background: var(--paper-raised); color: var(--ink); text-align: left;
  box-shadow: 0 1px 2px rgba(23, 20, 15, .2), 0 10px 28px rgba(23, 20, 15, .3), 0 0 0 0 rgba(255, 252, 245, .75); cursor: pointer;
  animation: photo-peek-up .42s var(--ease) both, photo-peek-pulse 1.8s ease-in-out .42s infinite;
}
.photo-peek__img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 2px; background: var(--paper-sunk); }
.photo-peek__label { display: block; padding: .65rem .2rem .7rem; font: 500 1.08rem/1 var(--serif); letter-spacing: -.005em; color: var(--ink); }
.photo-peek:hover { background: #fff; }
.photo-peek:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.is-showcase .stage[data-photo="true"] .explorer-hint { visibility: hidden; }
@keyframes photo-peek-up { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
/* The card grows and shrinks about its own centre, the same on every side. The ring is the third shadow. */
@keyframes photo-peek-pulse {
  0% { scale: 1; box-shadow: 0 1px 2px rgba(23, 20, 15, .2), 0 10px 28px rgba(23, 20, 15, .3), 0 0 0 0 rgba(255, 252, 245, .75); }
  50% { scale: 1.045; }
  100% { scale: 1; box-shadow: 0 1px 2px rgba(23, 20, 15, .2), 0 10px 28px rgba(23, 20, 15, .3), 0 0 0 18px rgba(255, 252, 245, 0); }
}
/* b: a plain rounded thumbnail with the caption on it */
[data-peek="b"] .is-showcase .photo-peek:not([hidden]), .is-showcase[data-peek="b"] .photo-peek:not([hidden]) { padding: 0; border-radius: 12px; overflow: hidden; background: #1b1814; }
[data-peek="b"] .photo-peek__img { border-radius: 0; }
[data-peek="b"] .photo-peek__label { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.3rem .7rem .6rem; background: linear-gradient(transparent, rgba(16, 14, 11, .7)); color: #fff; font: 600 .82rem/1 var(--sans); }
/* c: a slim caption pill with a tiny thumbnail */
.is-showcase[data-peek="c"] .photo-peek:not([hidden]) { flex-direction: row; align-items: center; gap: .6rem; width: auto; padding: .3rem 1rem .3rem .3rem; border-radius: 999px; }
[data-peek="c"] .photo-peek__img { width: 40px; height: 40px; aspect-ratio: 1; border-radius: 50%; }
[data-peek="c"] .photo-peek__label { padding: 0; font: 600 .84rem/1 var(--sans); white-space: nowrap; }

.photo-view { position: fixed; inset: 0; z-index: 62; display: grid; place-items: center; padding: calc(4.5rem + env(safe-area-inset-top, 0px)) 1.5rem max(1rem, env(safe-area-inset-bottom)); background: rgba(10, 9, 7, .92); animation: photo-view-in .22s var(--ease); }
.photo-view[hidden] { display: none; }
.photo-view__figure { margin: 0; width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; }
.photo-view__img { display: block; max-width: 100%; max-height: calc(100vh - 9.5rem); max-height: calc(100dvh - 9.5rem); min-height: 0; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.photo-view__img[hidden] { display: none; }
.photo-view__bar { color: #fff; font: 600 .9rem/1.3 var(--sans); text-align: center; }
/* Close: a big, high-contrast "✕ Luk" pill that is easy to spot and hit. */
.photo-view__close {
  position: absolute; z-index: 2; top: max(1rem, env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right));
  display: inline-flex; align-items: center; gap: .45rem; min-width: 52px; height: 52px; padding: 0 1.2rem 0 .95rem;
  border: 0; border-radius: 999px; background: #fff; color: var(--ink); font: 700 1rem/1 var(--sans); cursor: pointer;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .28), 0 8px 24px rgba(0, 0, 0, .45);
}
.photo-view__close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.photo-view__close:hover { background: #fff; transform: scale(1.05); }
.photo-view__close:active { transform: scale(.97); }
.photo-view__close:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@keyframes photo-view-in { from { opacity: 0; } to { opacity: 1; } }

/* Guide: four short steps. On a wide screen the card sits in the middle; on a phone just above the view buttons. */
.guide { position: fixed; inset: 0; z-index: 63; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.guide[hidden] { display: none; }
.guide__scrim { position: absolute; inset: 0; background: rgba(16, 14, 11, .4); }
.guide__panel {
  position: relative; width: min(23rem, 100%); max-height: calc(100vh - 7rem); max-height: calc(100dvh - 7rem); overflow-y: auto;
  padding: 1.25rem 1.25rem 1.1rem; border-radius: 14px; background: var(--paper-raised); color: var(--ink);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .35); animation: guide-in .25s var(--ease);
}
.guide__panel:focus { outline: none; }
.guide__art { height: 96px; margin: 0 0 .9rem; display: grid; place-items: center; border-radius: 10px; background: var(--paper-sunk); }
.guide__art svg { width: 170px; height: 88px; }
.guide__art .g-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.guide__art .g-soft { fill: none; stroke: var(--ink-mute); stroke-width: 1.5; stroke-dasharray: 4 4; }
.guide__art .g-dot { fill: var(--ink); stroke: none; }
.guide__art .g-blue { fill: rgba(47, 124, 246, .18); stroke: #2f7cf6; stroke-width: 3.5; }
.guide__step { margin: 0 0 .3rem; color: var(--ink-mute); font: 600 .75rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.guide__title { margin: 0 0 .45rem; font: 600 1.25rem/1.2 var(--serif); letter-spacing: -.01em; }
/* Room for the longest step, so the card and its buttons never move between steps. */
.guide__text { margin: 0; color: var(--ink-soft); font-size: .92rem; line-height: 1.5; min-height: 6em; }
.guide__dots { display: flex; gap: .35rem; margin: .9rem 0; }
.guide__dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); transition: background .2s var(--ease); }
.guide__dots .is-on { width: 20px; border-radius: 4px; background: var(--ink); }
.guide__actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.guide__actions .btn { min-height: 44px; padding-inline: 1rem; justify-content: center; text-align: center; cursor: pointer; }
.guide__actions #guidePrev:disabled { visibility: hidden; }
.guide__actions #guideNext { min-width: 8rem; }
@keyframes guide-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  /* Four buttons share a phone's width. */
  .is-showcase .explorer-nav { gap: 0; padding-inline: .15rem; justify-content: space-between; }
  .explorer-view { min-width: 44px; flex: 1 1 0; padding-inline: .2rem; font-size: .7rem; white-space: nowrap; align-items: center; justify-content: center; }
  .photo-view { padding-inline: .5rem; padding-top: calc(4.75rem + env(safe-area-inset-top, 0px)); }
  .photo-view__img { max-height: calc(100vh - 9rem); max-height: calc(100dvh - 9rem); }
  /* The guide sits just above the view buttons, within thumb reach, as wide as they are. */
  .guide { align-items: flex-end; padding: 1rem max(.75rem, env(safe-area-inset-right)) calc(5.4rem + env(safe-area-inset-bottom, 0px)) max(.75rem, env(safe-area-inset-left)); }
  .guide__panel { width: 100%; max-height: calc(100vh - 6.6rem); max-height: calc(100dvh - 6.6rem); padding: 1.1rem 1.1rem 1rem; }
  .guide__text { min-height: 7.5em; }
  /* Centred with margins, not a transform: a transform would make the pulse drift sideways. */
  .is-showcase .photo-peek:not([hidden]) { left: 0; right: 0; margin-inline: auto; bottom: calc(6.2rem + env(safe-area-inset-bottom, 0px)); width: 204px; }
  .is-showcase[data-peek="c"] .photo-peek:not([hidden]) { width: auto; }
}
@media (max-width: 640px) and (max-height: 620px) {
  /* A small embed: the picture goes, the words and the button stay, nothing scrolls. */
  .guide__art { display: none; }
  .guide__text { font-size: .88rem; min-height: 7.5em; }
  .guide__dots { margin: .7rem 0; }
}
@media (max-height: 500px) and (max-width: 1000px) {
  .photo-view { padding-top: max(1rem, env(safe-area-inset-top)); }
  .photo-view__img { max-height: calc(100vh - 4.5rem); max-height: calc(100dvh - 4.5rem); }
  .photo-view .photo-view__close { top: .6rem; right: .6rem; width: 56px; padding: 0; justify-content: center; }
  .photo-view .photo-view__close-text { display: none; }
  .photo-view__figure { gap: .3rem; }
  .is-showcase .photo-peek:not([hidden]) { left: .9rem; right: auto; margin-inline: 0; bottom: 4.4rem; width: 168px; }
  .is-showcase[data-peek="c"] .photo-peek:not([hidden]) { width: auto; }
}
@media (max-height: 500px) and (min-width: 641px) and (max-width: 1000px) {
  /* A phone on its side: picture beside the words. */
  .guide { align-items: center; justify-content: center; padding: .5rem; }
  .guide__panel { display: grid; grid-template-columns: 9rem 1fr; column-gap: 1.1rem; width: min(40rem, 100%); max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); padding: 1rem 1.1rem; }
  .guide__art { display: grid; grid-column: 1; grid-row: 1 / 7; height: auto; align-self: stretch; margin: 0; }
  .guide__panel > :not(.guide__art) { grid-column: 2; }
  .guide__art svg { width: 130px; }
  .guide__text { min-height: 4.5em; font-size: .88rem; }
  .guide__dots { margin: .6rem 0; }
}
@media (prefers-reduced-motion: reduce) {
  .is-showcase .photo-peek:not([hidden]), .photo-view, .guide__panel { animation: none; }
  .guide__dots span { transition: none; }
  .photo-view__close:hover, .photo-view__close:active { transform: none; }
}
@media (min-width: 641px) and (max-width: 860px) and (min-height: 521px) {
  .explorer-view { padding-inline: .6rem; gap: .35rem; font-size: .78rem; }
}
@media (max-width: 400px) {
  /* The long word breaks at its soft hyphen, so every button keeps a 44 px target. */
  .explorer-view { white-space: normal; hyphens: manual; line-height: 1.05; text-align: center; font-size: .6875rem; }
}
@media (max-width: 340px) {
  .explorer-view { padding-inline: .06rem; font-size: .6875rem; letter-spacing: -.015em; }
  .is-showcase .explorer-nav { left: .35rem; right: .35rem; }
}
