:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, sans-serif;
  background: #25221d;
  color: #f3ead9;
  --panel: #332d25;
  --border: #776757;
  --muted: #d3c1ab;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main {
  display: grid; grid-template-rows: auto minmax(150px, 1fr) auto;
  height: 100vh; height: 100dvh; min-height: 280px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.masthead, footer { padding-inline: clamp(.75rem, 3vw, 2rem); }
.masthead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: .6rem; padding-block: .66rem;
}
a { color: var(--muted); font-size: .85rem; text-underline-offset: .22em; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.26rem, 4vw, 1.8rem); margin-top: .13rem; }
h1, h2 { font-family: Georgia, serif; font-weight: 500; }
button { cursor: pointer; font: inherit; font-weight: 650; color: inherit; background: var(--panel); border: 1px solid var(--border); border-radius: .62rem; padding: .55rem .8rem; min-height: 44px; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid #f5cf96; outline-offset: 3px; }
.masthead-actions { display: flex; justify-self: end; gap: .4rem; }
.masthead-actions button { white-space: nowrap; }
.mode-switch {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .18rem;
  padding: .15rem; border: 1px solid #655648; border-radius: .78rem; background: #211e1a;
}
.mode-switch button {
  padding: .38rem .54rem; border: 1px solid transparent; border-radius: .58rem;
  background: transparent; color: #f3ead9; font-size: .88rem; white-space: nowrap;
}
.mode-switch button[aria-pressed="true"] { background: #e9cba6; color: #30251c; }
.mode-switch button[aria-pressed="false"]:enabled:hover { background: #3d332b; }
.mode-switch button[aria-disabled="true"] { cursor: wait; }
.scene { position: relative; overflow: hidden; background: #5b5040; }
.viewport, .overlay { position: absolute; inset: 0; }
.overlay { z-index: 4; background: #332d25; display: grid; place-content: center; justify-items: center; gap: .7rem; }
.scene-status {
  position: absolute; left: .75rem; top: .75rem; z-index: 2;
  display: flex; align-items: center; gap: .38rem; max-width: calc(100% - 1.5rem); pointer-events: none;
}
.location {
  padding: .38rem .58rem; border-radius: .45rem; color: #fff5e6;
  font-size: .84rem; background: #27211dda; overflow-wrap: anywhere;
}
#service-toggle, #service-picker { padding-inline: .55rem; font-size: .82rem; pointer-events: auto; flex: none; }
#service-toggle[aria-pressed="true"] { background: #e9cba6; color: #30251c; border-color: #e9cba6; }
.mode-feedback {
  position: absolute; top: .75rem; right: .75rem; z-index: 3; display: flex;
  align-items: center; gap: .55rem; max-width: min(24rem, calc(100% - 1.5rem)); font-size: .84rem;
}
.mode-feedback.has-message { padding: .45rem .6rem; border-radius: .52rem; background: #27211df2; }
.mode-feedback button { font-size: .8rem; }
#service-markers { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.service-marker {
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  isolation: isolate; pointer-events: auto; background: transparent; color: #2d241b;
  font-size: .88rem; touch-action: manipulation;
}
.service-marker::before {
  content: ""; position: absolute; inset: 9px; z-index: -1; border-radius: 50%;
  background: #f0d5ac; box-shadow: 0 0 0 1px #584537, 0 1px 5px #21180eb3;
}
.service-marker:is(:hover, :focus-visible, [aria-expanded="true"])::before { background: #ffe9c6; }
.service-marker-label {
  position: absolute; top: 50%; left: calc(50% + 16px); transform: translateY(-50%); pointer-events: none;
  padding: .22rem .38rem; border-radius: .33rem; color: #fff5e6;
  background: #27211df2; font-size: .73rem; white-space: nowrap;
}
.service-marker[data-label-side="left"] .service-marker-label { right: calc(50% + 16px); left: auto; }
#service-card {
  position: absolute; right: .75rem; bottom: .75rem; z-index: 2;
  width: min(23rem, calc(100% - 10.5rem)); max-height: min(13rem, calc(100% - 4.5rem)); overflow: auto;
  padding: .5rem .65rem .7rem .8rem; border: 1px solid var(--border); border-radius: .65rem;
  background: #27211df5; color: #fff5e6; box-shadow: 0 6px 20px #17130f66;
}
.service-card-header { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
#service-card-title { font-size: 1.06rem; overflow-wrap: anywhere; }
#service-card-close { flex: none; width: 44px; padding: 0; font-size: 1.4rem; line-height: 1; }
#service-card-text { margin-top: .24rem; font-size: .83rem; line-height: 1.4; overflow-wrap: anywhere; }
.directions { position: absolute; left: .75rem; bottom: .75rem; z-index: 3; display: grid; grid-template: auto auto / repeat(3, 44px); gap: .3rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.directions button { padding: 0; min-height: 44px; background: #28221dec; font-size: 1.28rem; }
.directions button[data-pressed] { background: #76513e; }
.forward { grid-column: 2; }
.left, .back, .right { grid-row: 2; }
footer { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: .2rem 1rem; padding-block: .48rem; color: var(--muted); font-size: .77rem; }
#mode-note { justify-self: end; }
dialog { width: min(34rem, calc(100% - 1.5rem)); color: inherit; background: #25221d; border: 1px solid var(--border); border-radius: .9rem; padding: 1rem; }
dialog { max-height: calc(100dvh - 2rem); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: #17130fc9; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.views button { text-align: left; }
.view-group + .view-group { margin-top: .9rem; }
.view-group h3 { margin: 0 0 .42rem; color: var(--muted); font-weight: 600; font-size: .84rem; }
#dimension-toggle[aria-pressed="true"] { background: #e9cba6; color: #30251c; border-color: #e9cba6; }
#wall-dimensions { position: absolute; inset: 0; overflow: hidden; z-index: 1; pointer-events: none; }
#wall-dimensions svg { display: block; width: 100%; height: 100%; }
#wall-dimensions .is-outside { display: none; }
#wall-dimensions path { fill: none; stroke-linecap: round; }
#wall-dimensions .dimension-outline { stroke: #382b21; stroke-width: 4px; opacity: .80; }
#wall-dimensions .dimension-ruler { stroke: #fff0c6; stroke-width: 1.65px; }
#wall-dimensions text {
  fill: #fff4d7; paint-order: stroke fill; stroke: #2d241a;
  stroke-width: 5px; stroke-linejoin: round;
  font: 700 13px system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
#dimension-area {
  position: absolute; right: .75rem; bottom: .75rem; z-index: 1; pointer-events: none;
  border-radius: .42rem; background: #27211de6; color: #fff5e6;
  padding: .30rem .48rem; font-size: .78rem;
}

@media (max-width: 46rem) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto; }
  .mode-switch { grid-column: 1 / -1; grid-row: 2; }
  .mode-feedback { top: 4rem; }
}

@media (max-width: 34rem) {
  .masthead-actions { gap: .28rem; }
  .masthead-actions button { padding-inline: .55rem; font-size: .82rem; }
  h1 { font-size: clamp(1.03rem, 4.4vw, 1.26rem); }
  footer { grid-template-columns: 1fr; }
  #mode-note { justify-self: start; }
}

@media (max-width: 27rem) {
  #service-card {
    bottom: calc(88px + 1.65rem); width: min(23rem, calc(100% - 1.5rem));
    max-height: min(12rem, calc(100% - 10.4rem));
  }
}

@media (orientation: landscape) and (max-height: 28rem) {
  main { min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
  .masthead { padding-block: .35rem; }
  h1 { font-size: 1.2rem; }
  footer { padding-block: .25rem; }
}

@media (orientation: landscape) and (max-height: 28rem) and (min-width: 34rem) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto auto; }
  .mode-switch { grid-column: 2; grid-row: 1; }
  .masthead-actions { grid-column: 3; grid-row: 1; }
}

.door-controls {
  position: absolute; right: .75rem; bottom: 3.45rem; z-index: 4;
  display: grid; justify-items: end; gap: .35rem;
  max-width: min(17rem, calc(100% - 10.5rem)); text-align: right;
}
#door-action {
  color: #30251c; background: #e9cba6; border-color: #f0dcb8;
  padding-inline: .65rem; font-size: .88rem; text-align: center;
  box-shadow: 0 2px 12px #1b171366;
}
#door-notice {
  max-width: 13rem; border-radius: .42rem; color: #fff4df; background: #27211df5;
  padding: .4rem .55rem; font-size: .82rem;
}

.street-view-link {
  display: inline-flex; align-items: center; min-height: 44px; margin-top: .24rem;
  color: #f0d5ac; font-weight: 600;
}

.mode-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: row; }
.mode-switch button { font-size: clamp(.76rem, 2.9vw, .88rem); }
.yard-choices { display: grid; gap: .48rem; padding: 0; margin: 0; border: 0; }
.yard-choices label {
  display: flex; align-items: center; min-height: 44px; gap: .65rem;
  border: 1px solid var(--border); padding: .45rem .65rem; border-radius: .62rem;
  background: var(--panel); cursor: pointer;
}
.yard-choices input { width: 1.1rem; height: 1.1rem; accent-color: #e9cba6; }
#yard-status:not(:empty) { padding-top: .72rem; font-size: .88rem; color: var(--muted); }
@media (max-width: 63.99rem) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto; }
  .mode-switch { grid-column: 1 / -1; grid-row: 2; }
  .masthead-actions { grid-column: 2; grid-row: 1; }
}
@media (min-width: 64rem) {
  .masthead { grid-template-columns: minmax(10.8rem, 1fr) auto max-content; }
}
@media (min-width: 77rem) {
  .mode-switch { grid-template-columns: repeat(6, max-content); }
  .mode-switch button { padding-inline: .78rem; }
}
@media (max-width: 25rem) {
  .masthead-actions button { font-size:.73rem; padding-inline:.4rem; }
  .mode-switch { grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 1.18fr); }
  .mode-switch button { font-size:.75rem; padding-inline:.21rem; }
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
