:root {
  --panel: rgba(16, 21, 18, .8);
  --panel-strong: rgba(16, 21, 18, .94);
  --line: rgba(255, 255, 255, .18);
  --text: #fffaf0;
  --muted: rgba(255, 250, 240, .72);
  --accent: #d7ad58;
  --green: #82b99f;
  --shadow: 0 18px 48px rgba(0, 0, 0, .35);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d120f;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.tour {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  background: #0d120f;
  isolation: isolate;
}

#viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#viewer.is-dragging {
  cursor: grabbing;
}

.tour::before,
.tour::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
}

.tour::before {
  top: 0;
  height: 25%;
  background: linear-gradient(180deg, rgba(0, 0, 0, .52), rgba(0, 0, 0, 0));
}

.tour::after {
  bottom: 0;
  height: 28%;
  background: linear-gradient(0deg, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
}

.topbar,
.plan-card,
.scene-strip,
.hotspots,
.step-transition,
.loading {
  position: absolute;
  z-index: 4;
}

.topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  pointer-events: none;
}

.title-card,
.plan-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.title-card {
  flex: 1 1 420px;
  width: auto;
  max-width: 520px;
  min-width: 0;
  padding: 14px 16px 15px;
  pointer-events: auto;
}

.title-card p,
.plan-card h2 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 2.1vw, 32px);
  line-height: 1.06;
  letter-spacing: 0;
}

.meta {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.meta i {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.title-card .demo-disclosure {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
}

.title-card .demo-disclosure a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  pointer-events: auto;
}

.language-control {
  min-width: 156px;
  display: grid;
  gap: 4px;
  padding: 7px 9px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.language-control label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.language-control select {
  width: 100%;
  min-height: 22px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  outline: 0;
}

.language-control option {
  color: #111;
}

.icon-button,
.hotspot,
.scene-chip,
.map-area {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button:hover,
.scene-chip:hover,
.map-area:hover {
  border-color: rgba(255, 255, 255, .34);
  background: rgba(255, 255, 255, .13);
}

.plan-card {
  top: 92px;
  right: 18px;
  width: 320px;
  padding: 12px;
}

.plan {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .055);
}

.plan svg {
  display: none;
}

.room {
  fill: rgba(255, 255, 255, .08);
  stroke: rgba(255, 255, 255, .24);
  stroke-width: 2;
}

.room.porch {
  fill: rgba(130, 185, 159, .12);
  stroke: rgba(130, 185, 159, .4);
}

.room.hall {
  fill: rgba(215, 173, 88, .1);
  stroke: rgba(215, 173, 88, .36);
}

.map-nodes {
  position: absolute;
  inset: 0;
}

.map-area {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 6px;
  background: rgba(255, 255, 255, .075);
  color: rgba(255, 250, 240, .76);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.05;
  text-align: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}

.map-area[aria-current="true"] {
  border-color: rgba(215, 173, 88, .9);
  background: rgba(215, 173, 88, .24);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(215, 173, 88, .22), 0 8px 18px rgba(0, 0, 0, .22);
}

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

.scene-strip {
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
  pointer-events: auto;
}

.scene-chip {
  flex: 0 0 auto;
  min-width: 128px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .22);
  text-align: left;
  backdrop-filter: blur(14px);
}

.scene-chip strong,
.scene-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-chip strong {
  font-size: 13px;
  line-height: 1.1;
}

.scene-chip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.scene-chip[aria-current="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(215, 173, 88, .3), 0 12px 26px rgba(0, 0, 0, .22);
}

.hotspots {
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  min-width: 72px;
  min-height: 58px;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: transparent;
  pointer-events: auto;
}

.hotspot:hover,
.hotspot:focus-visible {
  z-index: 2;
}

.hotspot::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 11px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(215, 173, 88, .98);
  box-shadow: 0 0 0 8px rgba(215, 173, 88, .22), 0 14px 26px rgba(0, 0, 0, .34);
}

.hotspot::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 20px;
  width: 22px;
  height: 25px;
  background: #1b211c;
  clip-path: polygon(50% 0, 100% 46%, 68% 46%, 68% 100%, 32% 100%, 32% 46%, 0 46%);
}

.hotspot-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px + var(--label-offset, 0px));
  width: max-content;
  max-width: 180px;
  padding: 7px 9px;
  transform: translateX(calc(-50% + var(--preview-shift, 0px)));
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius);
  background: rgba(13, 17, 14, .84);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  backdrop-filter: blur(12px);
}

.hotspot-preview {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 42px);
  width: 188px;
  min-height: 136px;
  overflow: hidden;
  transform: translateX(calc(-50% + var(--preview-shift, 0px))) translateY(8px) scale(.96);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius);
  background: rgba(13, 17, 14, .9);
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  backdrop-filter: blur(12px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.hotspot-preview img {
  display: block;
  width: 100%;
  height: 86px;
  object-fit: cover;
  object-position: center;
}

.hotspot-preview strong,
.hotspot-preview small {
  display: block;
  overflow: hidden;
  padding: 0 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hotspot-preview strong {
  margin-top: 9px;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.1;
}

.hotspot-preview small {
  margin-top: 4px;
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.hotspot:hover .hotspot-preview,
.hotspot:focus-visible .hotspot-preview {
  opacity: 1;
  visibility: visible;
  transform: translateX(calc(-50% + var(--preview-shift, 0px))) translateY(0) scale(1);
}

.step-transition {
  inset: 0;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, .16), rgba(0, 0, 0, 0) 28%),
    rgba(8, 10, 9, .72);
  pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
}

.step-transition::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%) scale(.86);
  border: 2px solid rgba(255, 255, 255, .48);
  border-radius: 999px;
  background: rgba(215, 173, 88, .22);
  transition: transform .34s ease;
}

.step-transition::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 38px;
  transform: translate(-50%, -50%);
  background: #fffaf0;
  clip-path: polygon(50% 0, 100% 46%, 68% 46%, 68% 100%, 32% 100%, 32% 46%, 0 46%);
}

.step-transition.is-active {
  opacity: 1;
  visibility: visible;
}

.step-transition.is-active::before {
  transform: translate(-50%, -50%) scale(1.22);
}

.loading {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 13, 11, .82);
  transition: opacity .25s ease, visibility .25s ease;
  pointer-events: none;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading span {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin .9s linear infinite;
}

.loading code {
  max-width: min(680px, 88vw);
  padding: 12px;
  border-radius: var(--radius);
  background: #1b211d;
  color: #fff;
  white-space: pre-wrap;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (max-width: 980px) {
  .plan-card {
    display: none;
  }

  .hotspot-preview {
    display: none;
  }
}

@media (max-width: 640px) {
  .tour {
    min-height: 600px;
  }

  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .title-card {
    flex-basis: calc(100vw - 148px);
    max-width: none;
    padding: 11px 12px;
  }

  h1 {
    font-size: 22px;
  }

  .meta {
    font-size: 12px;
  }

  .actions {
    gap: 6px;
  }

  .actions .icon-button {
    display: none;
  }

  .language-control {
    min-width: 118px;
    padding: 6px 7px;
  }

  .scene-strip {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .scene-chip {
    min-width: 116px;
    min-height: 40px;
    padding: 7px 9px;
  }

  .hotspot-label {
    max-width: min(156px, 42vw);
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
