:root {
  color-scheme: dark;
  --ink: #f7faf8;
  --muted: rgba(247, 250, 248, 0.7);
  --panel: rgba(9, 15, 18, 0.74);
  --line: rgba(255, 255, 255, 0.16);
  --teal: #0f8a7d;
  --gold: #f4d483;
  --font-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Manrope", "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: -0.01em;
  background: #070b0d;
  color: var(--ink);
}

button {
  font: inherit;
}

.viewer-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  background: radial-gradient(circle at 45% 15%, #304253 0, #0f171d 42%, #050809 100%);
}

.stage {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}

.stage:active {
  cursor: grabbing;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: contrast(1.08) saturate(1.1) brightness(0.98);
}

.viewer-shell.is-loading .stage {
  visibility: hidden;
}

.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #172832;
}

.viewer-loading[hidden] { display: none; }

.viewer-loading-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.viewer-loading-card strong { font-size: 20px; }
.viewer-loading-card p { margin: 0; color: var(--muted); font-size: 14px; }
.viewer-loading-card button {
  padding: 12px 24px;
  border: 0;
  border-radius: 8px;
  background: var(--gold);
  color: #172832;
  cursor: pointer;
}

.viewer-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: viewer-spin 1s linear infinite;
}

@keyframes viewer-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .viewer-loading-spinner { animation: none; }
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand,
.actions,
.record-panel,
.hud,
.zoom-controls,
.help,
.object-tooltip {
  pointer-events: auto;
}

.object-tooltip {
  position: fixed;
  z-index: 9;
  max-width: 270px;
  padding: 9px 12px;
  border: 1px solid rgba(244, 212, 131, 0.48);
  border-radius: 7px;
  background: rgba(8, 15, 18, 0.92);
  color: #f7efe0;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  pointer-events: none;
  transform: translate(14px, 14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #0f5c50;
  color: white;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

h1,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.025em;
}

p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.105em;
  line-height: 1.35;
  text-transform: uppercase;
}

.actions {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.actions button,
.zoom-controls button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  border-radius: 7px;
  font-weight: 500;
  letter-spacing: 0.025em;
  cursor: pointer;
}

.actions button {
  min-width: 88px;
  height: 40px;
  font-size: 12px;
}

.actions button:hover,
.zoom-controls button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.actions button.is-active {
  background: #f3d17b;
  color: #182024;
}

.record-panel {
  position: absolute;
  z-index: 7;
  top: max(86px, calc(env(safe-area-inset-top) + 70px));
  right: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.record-panel button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 126px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.record-panel button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5c57;
  box-shadow: 0 0 0 3px rgba(255, 92, 87, 0.14);
}

.record-panel.is-recording #recordTour {
  border-color: rgba(255, 104, 95, 0.72);
  background: rgba(137, 28, 24, 0.76);
}

.record-panel.is-recording .record-dot {
  animation: record-pulse 1.1s ease-in-out infinite;
}

.record-panel.is-guided #guidedTour {
  border-color: rgba(243, 209, 123, 0.78);
  background: rgba(243, 209, 123, 0.92);
  color: #182024;
}

#recordTimer {
  min-width: 44px;
  padding-right: 7px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

@keyframes record-pulse {
  50% {
    opacity: 0.48;
    transform: scale(0.82);
  }
}

.hud {
  position: absolute;
  z-index: 5;
  left: 20px;
  bottom: 22px;
  display: grid;
  gap: 12px;
  min-width: min(410px, calc(100vw - 40px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.hud strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.035em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 99px;
}

.glass {
  background: #8fd1ec;
}

.light {
  background: var(--gold);
}

.green {
  background: #6bad55;
}

.zoom-controls {
  position: absolute;
  z-index: 5;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 8px;
}

.zoom-controls button {
  width: 46px;
  height: 46px;
  font-size: 24px;
}

.help {
  position: absolute;
  z-index: 5;
  right: 84px;
  bottom: 34px;
  color: rgba(247, 250, 248, 0.7);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.045em;
  text-shadow: 0 2px 12px #000;
}

@media (max-width: 760px) {
  .viewer-shell {
    min-height: 100svh;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    overflow-x: auto;
  }

  .actions button {
    min-width: 82px;
  }

  .record-panel {
    top: 142px;
    right: 12px;
  }

  .hud {
    left: 12px;
    right: 76px;
    bottom: 14px;
    min-width: 0;
  }

  .help {
    display: none;
  }
}

/* Compact controls for the property preview inside the iPhone app. */
.app-embed .viewer-shell { min-height: 0; height: 100dvh; }
.app-embed .stage canvas { filter: none; }
.app-embed .brand,
.app-embed .record-panel,
.app-embed .hud,
.app-embed .help { display: none; }
.app-embed .topbar { top: 8px; left: 8px; right: 8px; }
.app-embed .actions { gap: 4px; padding: 4px; justify-content: space-between; }
.app-embed .actions button { display: none; min-width: 0; height: 44px; flex: 1; font-size: 11px; }
.app-embed .actions button[data-camera="hero"],
.app-embed .actions button[data-camera="tower"],
.app-embed .actions button[data-camera="floor5"],
.app-embed .actions button[data-camera="amenities"],
.app-embed .actions button[data-camera="top"] { display: block; }
.app-embed .zoom-controls { right: 8px; bottom: 8px; gap: 6px; }
.map-controls { display: none; }
.app-embed .map-controls { display: block; position: absolute; z-index: 5; left: 8px; bottom: 8px; }
.map-controls button { display: flex; align-items: center; gap: 7px; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: 600 12px var(--font-ui); cursor: pointer; }
.map-controls button[aria-pressed="true"] { background: var(--gold); color: #182024; }
.map-controls button:disabled { opacity: .45; cursor: default; }
