:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow: hidden;
  background: #27231f;
}

body.house-360-page {
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: #3b3025;
  background: #27231f;
  font-family: inherit;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
}

.house-360-modal {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.12), transparent 34%),
    rgba(33, 31, 28, 0.58);
  backdrop-filter: blur(14px) saturate(0.95);
}

.house-360-dialog {
  --house-360-fit-scale: 1;
  --house-360-control-scale: 1;
  position: relative;
  width: min(452px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.35dvh, 12px);
  margin: 0;
  padding: clamp(14px, 3vw, 20px);
  overflow: hidden;
  overscroll-behavior: contain;
  border-radius: clamp(22px, 6vw, 30px);
  background:
    radial-gradient(circle at 78% 9%, rgba(222, 202, 171, 0.28), transparent 26%),
    linear-gradient(180deg, #fffdf9 0%, #fbf7ee 56%, #f2e8d6 100%);
  box-shadow: 0 28px 84px rgba(29, 25, 20, 0.36);
  transform: scale(var(--house-360-fit-scale));
  transform-origin: center;
}

.house-360-close {
  position: absolute;
  top: clamp(10px, 2.6vw, 16px);
  right: clamp(10px, 2.6vw, 16px);
  z-index: 5;
  width: clamp(32px, 7.6vw, 42px);
  height: clamp(32px, 7.6vw, 42px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #6d5b43;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(92, 70, 44, 0.12);
  font-size: clamp(21px, 5vw, 27px);
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transform: scale(var(--house-360-control-scale));
  transform-origin: center;
}

.house-360-close::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: inherit;
}

.house-360-copy {
  padding: clamp(4px, 1vw, 8px) clamp(42px, 10vw, 58px) 0 0;
}

.house-360-kicker {
  display: inline-flex;
  align-items: center;
  height: clamp(20px, 4.45vw, 24px);
  padding: 0 clamp(9px, 2.15vw, 13px);
  border-radius: 999px;
  color: #a97835;
  background: rgba(237, 227, 212, 0.72);
  font-size: clamp(9px, 2.05vw, 11px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.house-360-copy h2 {
  margin: clamp(8px, 1.8vw, 12px) 0 clamp(3px, 0.85vw, 6px);
  color: #3b3025;
  font-size: clamp(19px, 4.15vw, 25px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.018em;
}

.house-360-copy p {
  max-width: 96%;
  margin: 0;
  color: rgba(73, 61, 49, 0.72);
  font-size: clamp(11px, 2.45vw, 13px);
  line-height: 1.42;
}

.house-360-showcase {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.45dvh, 12px);
  padding: clamp(5px, 1.1vw, 8px);
  border-radius: clamp(18px, 5vw, 28px);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    0 16px 44px rgba(91, 73, 46, 0.09);
}

.house-360-stage {
  position: relative;
  width: 100%;
  min-height: clamp(210px, 41dvh, 500px);
  max-height: min(52dvh, 560px);
  aspect-ratio: 1.28 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: clamp(16px, 4.2vw, 24px);
  background: #ececec;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    inset 0 0 0 6px rgba(255, 255, 255, 0.58),
    0 12px 30px rgba(68, 58, 45, 0.05);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.house-360-stage.is-dragging {
  cursor: grabbing;
}

.house-360-model {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: visible;
  transform: translate3d(var(--house-360-pan-x, 0px), var(--house-360-pan-y, 0px), 0) scale(var(--house-360-model-scale, 1));
  transform-origin: center;
  transition: transform 120ms ease-out;
  will-change: transform;
}

.house-360-stage.is-transforming .house-360-model {
  transition: none;
}

.house-360-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--house-360-frame-size, 170%);
  height: var(--house-360-frame-size, 170%);
  max-width: none;
  max-height: none;
  padding: 0;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  opacity: 0;
  z-index: 1;
  transform: translate(-50%, -50%);
  backface-visibility: hidden;
}

.house-360-frame.is-visible {
  opacity: 1;
  z-index: 2;
}

.house-360-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 2.4vw, 18px);
  z-index: 3;
  transform: translateX(-50%);
  padding: clamp(4px, 1.25vw, 7px) clamp(10px, 2.8vw, 15px);
  border-radius: 999px;
  color: rgba(86, 76, 66, 0.76);
  background: rgba(255, 255, 255, 0.88);
  font-size: clamp(9px, 2.2vw, 11px);
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(84, 70, 52, 0.09);
  transition: opacity 180ms ease;
}

.house-360-hint.is-hidden {
  opacity: 0;
}

.house-360-view-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 13px);
  padding: clamp(9px, 2vw, 14px);
  border-radius: clamp(16px, 4.4vw, 24px);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 32px rgba(91, 73, 46, 0.08);
}

.house-360-view {
  min-width: 0;
  padding: clamp(4px, 1.1vw, 6px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: clamp(12px, 3.4vw, 18px);
  color: rgba(71, 61, 50, 0.66);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(70, 55, 35, 0.06);
  cursor: pointer;
}

.house-360-view.is-active {
  border-color: #d79d45;
  color: #3b3025;
  box-shadow: 0 12px 26px rgba(196, 146, 66, 0.16);
}

.house-360-view-media {
  position: relative;
  display: block;
  aspect-ratio: 1.34 / 1;
  overflow: hidden;
  border-radius: clamp(9px, 2.8vw, 14px);
  background: #ececec;
}

.house-360-view-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.house-360-view-label {
  display: block;
  margin-top: 4px;
  text-align: center;
  font-size: clamp(9px, 2.25vw, 12px);
  font-weight: 650;
}

.house-360-highlights {
  padding: 0 clamp(7px, 1.6vw, 11px);
}

.house-360-highlights h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5vw, 9px);
  margin: clamp(1px, 0.4vw, 4px) 0 clamp(5px, 1.2vw, 8px);
  color: #3d3024;
  font-size: clamp(11px, 2.45vw, 13px);
  font-weight: 820;
  line-height: 1.2;
}

.house-360-highlights h3::before,
.house-360-highlights h3::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
}

.house-360-highlights h3::before {
  background: linear-gradient(90deg, transparent 0%, rgba(151, 123, 86, 0.22) 100%);
}

.house-360-highlights h3::after {
  background: linear-gradient(90deg, rgba(151, 123, 86, 0.22) 0%, transparent 100%);
}

.house-360-highlights h3 span {
  color: #a97835;
  font-size: clamp(10px, 2.2vw, 12px);
  line-height: 1;
}

.house-360-highlight-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.house-360-highlight-list > span {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: clamp(3px, 0.75vw, 5px) 3px 0;
  color: rgba(58, 48, 38, 0.8);
  text-align: center;
  font-size: clamp(8px, 1.95vw, 10px);
  font-weight: 500;
  line-height: 1.12;
  white-space: normal;
  overflow-wrap: anywhere;
}

.house-360-highlight-list > span + span {
  border-left: 1px solid rgba(151, 123, 86, 0.14);
}

.house-360-highlight-list > span::before {
  content: "✓";
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 10px;
  height: 10px;
  margin-right: 2px;
  border-radius: 999px;
  color: #fff;
  background: #c89545;
  font-size: 6px;
  font-weight: 800;
}

.house-360-highlight-list em {
  min-width: 0;
  color: inherit;
  font: inherit;
  font-style: normal;
  white-space: normal;
  overflow-wrap: anywhere;
}

.house-360-actions {
  display: flex;
  justify-content: center;
  padding-top: clamp(2px, 0.7vw, 5px);
}

.house-360-actions button {
  width: 100%;
  min-height: clamp(36px, 7.8vw, 44px);
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  color: #fffaf1;
  background: linear-gradient(135deg, #c89345 0%, #d4a861 56%, #bd8136 100%);
  box-shadow: 0 10px 22px rgba(175, 119, 43, 0.2);
  font-size: clamp(12px, 2.45vw, 14px);
  font-weight: 760;
  cursor: pointer;
}

:is(.house-360-close, .house-360-view, .house-360-primary):focus-visible {
  outline: 3px solid rgba(187, 128, 48, 0.72);
  outline-offset: 3px;
}

@media (min-width: 768px) and (min-height: 720px) {
  .house-360-dialog {
    width: min(580px, calc(100vw - 64px));
  }
}

@media (max-width: 380px), (max-height: 700px) {
  .house-360-dialog {
    gap: 7px;
    padding: 12px;
  }

  .house-360-copy h2 {
    margin-top: 8px;
    font-size: 19px;
  }

  .house-360-copy p {
    font-size: 11px;
  }

  .house-360-stage {
    min-height: 190px;
    max-height: 39dvh;
  }

  .house-360-view-strip {
    padding: 8px;
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .house-360-model,
  .house-360-hint {
    transition: none;
  }
}

@supports not (height: 100dvh) {
  body.house-360-page {
    min-height: 100vh;
  }
}

/* 户型展示页进入动效：内容按阅读顺序轻微渐入。 */
.house-360-modal.is-open {
  animation: house-360-scrim-enter 360ms ease-out both;
}

.house-360-modal.is-open .house-360-dialog {
  animation: house-360-dialog-enter 460ms 40ms cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: opacity, transform;
}

.house-360-modal.is-open .house-360-copy,
.house-360-modal.is-open .house-360-showcase,
.house-360-modal.is-open .house-360-highlights,
.house-360-modal.is-open .house-360-actions {
  animation: house-360-section-enter 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: opacity, transform;
}

.house-360-modal.is-open .house-360-copy {
  animation-delay: 120ms;
}

.house-360-modal.is-open .house-360-showcase {
  animation-delay: 170ms;
}

.house-360-modal.is-open .house-360-highlights {
  animation-delay: 230ms;
}

.house-360-modal.is-open .house-360-actions {
  animation-delay: 280ms;
}

@keyframes house-360-scrim-enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes house-360-dialog-enter {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0) scale(var(--house-360-fit-scale));
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(var(--house-360-fit-scale));
  }
}

@keyframes house-360-section-enter {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .house-360-modal.is-open,
  .house-360-modal.is-open .house-360-dialog,
  .house-360-modal.is-open .house-360-copy,
  .house-360-modal.is-open .house-360-showcase,
  .house-360-modal.is-open .house-360-highlights,
  .house-360-modal.is-open .house-360-actions {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 户型页平板全屏适配 v6：Via/第三方 WebView 报告宽视口时不再显示 580px 居中小卡片。 */
@media (min-width: 761px) and (max-width: 1366px) {
  html,
  body.house-360-page {
    width: 100% !important;
    width: var(--house-viewport-width, 100vw) !important;
    min-width: 0 !important;
    height: 100vh !important;
    height: var(--house-viewport-height, 100vh) !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .house-360-modal {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    width: 100% !important;
    width: var(--house-viewport-width, 100vw) !important;
    min-width: 0 !important;
    height: 100vh !important;
    height: var(--house-viewport-height, 100vh) !important;
    min-height: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: stretch !important;
    overflow: hidden !important;
    background: #f7f0e5 !important;
    backdrop-filter: none !important;
  }

  .house-360-dialog {
    --house-360-fit-scale: 1 !important;
    --house-360-control-scale: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding:
      max(18px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left)) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto minmax(0, 1fr) auto auto !important;
    gap: clamp(10px, 1.4vh, 18px) !important;
    overflow: hidden !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    transform-origin: center !important;
  }

  .house-360-copy {
    min-width: 0 !important;
    padding-right: 56px !important;
  }

  .house-360-showcase {
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    overflow: hidden !important;
  }

  .house-360-stage {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
  }

  .house-360-view-strip,
  .house-360-highlights,
  .house-360-actions {
    min-width: 0 !important;
  }

  .house-360-actions button {
    min-height: 46px !important;
  }
}

@media (min-width: 761px) and (max-width: 1366px) and (orientation: landscape) {
  .house-360-dialog {
    gap: clamp(8px, 1.15vh, 14px) !important;
  }

  .house-360-copy h2 {
    margin-top: 7px !important;
  }

  .house-360-showcase {
    grid-template-columns: minmax(0, 1fr) clamp(180px, 21vw, 260px) !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }

  .house-360-stage {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .house-360-view-strip {
    grid-column: 2 !important;
    grid-row: 1 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }

  .house-360-view {
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: hidden !important;
  }

  .house-360-view-media {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
  }

  .house-360-view-label {
    margin: 0 !important;
    padding-right: 4px !important;
    white-space: nowrap !important;
  }

  .house-360-highlights h3 {
    margin-top: 0 !important;
  }
}
