:root {
  color-scheme: dark;
  --glass: rgba(22, 21, 19, 0.58);
  --glass-strong: rgba(18, 17, 15, 0.82);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f7f4ee;
  --muted: rgba(247, 244, 238, 0.68);
  --accent: #d8b988;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #12110f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.tour-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  color: var(--text);
  background: radial-gradient(circle at 50% 44%, #3c3933, #11100e 78%);
  isolation: isolate;
}

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

.tour-shell::before {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.46), transparent 29%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.53), transparent 36%);
}

.tour-shell::after {
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.42);
}

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

#viewer:active {
  cursor: grabbing;
}

.loading {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--muted);
  background: #151411;
  letter-spacing: 0.14em;
  font-size: 12px;
  transition: opacity 700ms ease, visibility 700ms ease;
}

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

.loading-mark {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.identity {
  position: absolute;
  z-index: 3;
  top: clamp(24px, 5vw, 54px);
  left: clamp(22px, 4.5vw, 70px);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.22em;
  font-size: 10px;
  font-weight: 700;
}

.identity h1 {
  margin: 0;
  font-family: "Noto Serif TC", "Songti TC", Georgia, serif;
  font-size: clamp(27px, 3vw, 42px);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.subline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a7c79b;
  box-shadow: 0 0 0 5px rgba(167, 199, 155, 0.12);
}

.drag-hint {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  margin: 0;
  padding: 10px 14px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 99px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(18, 17, 15, 0.36);
  backdrop-filter: blur(10px);
  font-size: 11px;
  letter-spacing: 0.1em;
  transition: opacity 500ms ease, transform 500ms ease;
  pointer-events: none;
}

.drag-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
}

.tool-rail {
  position: absolute;
  z-index: 4;
  top: 50%;
  right: clamp(16px, 3.2vw, 46px);
  display: grid;
  gap: 8px;
  transform: translateY(-50%);
}

.tool-button {
  display: grid;
  place-items: center;
  width: 54px;
  min-height: 54px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: rgba(255, 255, 255, 0.8);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(120%);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.tool-button span {
  font-size: 20px;
  line-height: 1;
}

.tool-button small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.tool-button:hover,
.tool-button:focus-visible,
.tool-button.is-active {
  border-color: rgba(216, 185, 136, 0.58);
  background: rgba(44, 39, 33, 0.74);
  outline: none;
}

.tool-button:hover {
  transform: translateY(-1px);
}

.info-panel {
  position: absolute;
  z-index: 6;
  top: 50%;
  right: clamp(84px, 9vw, 130px);
  width: min(430px, calc(100vw - 122px));
  padding: 28px;
  transform: translate(18px, -50%);
  border: 1px solid var(--line);
  border-radius: 24px;
  opacity: 0;
  visibility: hidden;
  background: var(--glass-strong);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(22px) saturate(120%);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.info-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

.info-panel h2 {
  margin: 0 0 16px;
  font-family: "Noto Serif TC", "Songti TC", Georgia, serif;
  font-size: 24px;
  font-weight: 500;
}

.info-panel p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.study-detail {
  margin: 18px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.04);
}

.study-detail img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

.study-detail figcaption {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.panel-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 25px;
  cursor: pointer;
}

.scene-dock {
  position: absolute;
  z-index: 4;
  bottom: var(--safe-bottom);
  left: clamp(18px, 4.5vw, 70px);
  width: min(790px, calc(100vw - 155px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--glass);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px) saturate(120%);
}

.scene-heading {
  display: flex;
  justify-content: space-between;
  padding: 0 3px 10px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.scene-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.scene-button {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 14px;
  aspect-ratio: 16 / 9;
  color: #fff;
  background: #2a2722;
  cursor: pointer;
}

.scene-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.06) 65%),
    var(--scene-image);
  background-size: cover;
  background-position: center;
  transition: transform 300ms ease, filter 300ms ease;
}

.scene-button:hover::before {
  transform: scale(1.04);
}

.scene-button.is-active {
  border-color: var(--accent);
}

.scene-button span {
  position: absolute;
  z-index: 1;
  right: 10px;
  bottom: 8px;
  left: 10px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.hotspot {
  position: absolute;
  z-index: 3;
  padding: 8px 12px 8px 10px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  color: #fff;
  background: rgba(21, 20, 18, 0.5);
  backdrop-filter: blur(9px);
  font-size: 11px;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition: opacity 120ms linear, border-color 160ms ease, background 160ms ease;
}

.hotspot::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(216, 185, 136, 0.14);
}

.hotspot:hover,
.hotspot:focus-visible {
  border-color: var(--accent);
  outline: none;
  background: rgba(31, 29, 25, 0.74);
}

.legal-note {
  position: absolute;
  z-index: 3;
  right: clamp(16px, 3vw, 44px);
  bottom: var(--safe-bottom);
  color: rgba(255, 255, 255, 0.38);
  writing-mode: vertical-rl;
  font-size: 8px;
  letter-spacing: 0.18em;
}

noscript {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: #fff;
  background: #12110f;
}

@media (max-width: 700px) {
  .tour-shell {
    min-height: 440px;
  }

  .identity {
    top: max(20px, env(safe-area-inset-top));
  }

  .identity h1 {
    font-size: 26px;
  }

  .subline {
    max-width: 210px;
    line-height: 1.5;
  }

  .tool-rail {
    top: auto;
    right: 14px;
    bottom: calc(var(--safe-bottom) + 104px);
    display: flex;
    transform: none;
  }

  .tool-button {
    width: 45px;
    min-height: 45px;
    border-radius: 14px;
  }

  .tool-button small,
  .legal-note {
    display: none;
  }

  .scene-dock {
    right: 14px;
    left: 14px;
    width: auto;
  }

  .scene-list {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 136px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .scene-list::-webkit-scrollbar {
    display: none;
  }

  .scene-button {
    aspect-ratio: 16 / 9;
  }

  .info-panel {
    top: auto;
    right: 14px;
    bottom: calc(var(--safe-bottom) + 102px);
    left: 14px;
    width: auto;
    transform: translateY(16px);
  }

  .info-panel.is-open {
    transform: none;
  }

  .drag-hint {
    top: 46%;
  }
}

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