:root {
  --bg: #08080a;
  --text: #f5f5f7;
  --muted: #86868b;
  --line: rgba(255, 255, 255, 0.1);
  --glass: rgba(22, 22, 24, 0.62);
  --glass-strong: rgba(16, 16, 18, 0.82);
  --blue: #0071e3;
  --radius: 22px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang TC", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#viewport:active {
  cursor: grabbing;
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 42%, transparent 38%, rgba(0, 0, 0, 0.42) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.18));
}

.top-bar,
.model-panel,
.hero-copy,
.toolbar,
.loader,
.walk-hud,
.minimap {
  position: absolute;
  z-index: 2;
}

.top-bar {
  top: 22px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-hub {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  backdrop-filter: blur(20px);
  transition: background 180ms ease;
}

.back-hub[hidden] {
  display: none;
}

.back-hub:hover {
  background: rgba(255, 255, 255, 0.14);
}

.back-hub svg {
  width: 16px;
  height: 16px;
}

.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.brand__mark svg {
  width: 22px;
  height: 22px;
}

.brand__kicker {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand h1 {
  font-size: 20px;
  font-weight: 590;
  letter-spacing: -0.03em;
}

.icon-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  backdrop-filter: blur(22px) saturate(160%);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.minimap {
  top: 22px;
  right: 24px;
  width: 176px;
  padding: 8px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(180%);
  pointer-events: none;
}

.minimap canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 16px;
  background: #121214;
}

.minimap__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px 2px;
}

#floor-label {
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.03em;
}

.floor-dots {
  display: flex;
  gap: 5px;
}

.floor-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.floor-dots span.is-on {
  background: #7dc1ff;
}

.model-panel {
  top: 92px;
  left: 24px;
  width: 280px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(180%);
}

.panel-label {
  margin: 2px 6px 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.model-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding-right: 4px;
  /* 深色細捲軸：系統預設的淺灰軌道在玻璃面板上太突兀 */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.model-list::-webkit-scrollbar {
  width: 6px;
}

.model-list::-webkit-scrollbar-track {
  background: transparent;
}

.model-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.model-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

.model-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.model-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.model-card.is-active {
  background: rgba(0, 113, 227, 0.16);
  border-color: rgba(0, 113, 227, 0.38);
}

.model-card:disabled {
  opacity: 0.55;
  cursor: wait;
}

.model-card__icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.model-card__icon svg {
  width: 40px;
  height: 40px;
}

.model-card__copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.model-card__name {
  font-size: 15px;
  font-weight: 560;
  letter-spacing: -0.02em;
}

.model-card__meta {
  color: var(--muted);
  font-size: 12px;
}

.hero-copy {
  left: 332px;
  bottom: 118px;
  max-width: 420px;
  pointer-events: none;
}

.hero-copy__kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-copy h2 {
  margin: 6px 0 8px;
  font-size: 44px;
  font-weight: 620;
  letter-spacing: -0.045em;
}

.hero-copy__desc {
  color: #d2d2d7;
  font-size: 15px;
  line-height: 1.5;
}

.toolbar {
  left: 50%;
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(180%);
  transform: translateX(-50%);
  /* 置中的絕對定位預設最寬只有一半視窗，按鈕一多文字就被擠成兩行 */
  width: max-content;
  max-width: calc(100vw - 32px);
}

.tool-btn,
.exposure {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.tool-btn svg {
  width: 16px;
  height: 16px;
}

.tool-btn[hidden] {
  display: none !important;
}

.tool-btn:hover,
.tool-btn.is-on {
  background: rgba(255, 255, 255, 0.1);
}

.tool-btn.is-on {
  color: #7dc1ff;
}

.motion-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: rgba(48, 209, 88, 0.14);
  color: #30d158;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.motion-live[hidden] {
  display: none !important;
}

.motion-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7);
  animation: motion-pulse 1.4s ease-out infinite;
}

@keyframes motion-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.55);
  }
  100% {
    box-shadow: 0 0 0 8px rgba(48, 209, 88, 0);
  }
}

.exposure {
  color: var(--muted);
  cursor: default;
}

.exposure input {
  width: 88px;
  accent-color: var(--blue);
}

.exposure output {
  min-width: 34px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.walk-hud {
  inset: 0;
  pointer-events: none;
}

.walk-hud[hidden] {
  display: none;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(245, 245, 247, 0.78);
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

.crosshair::before {
  width: 16px;
  height: 1.5px;
}

.crosshair::after {
  width: 1.5px;
  height: 16px;
}

.walk-hint,
.walk-keys {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  letter-spacing: -0.01em;
  backdrop-filter: blur(24px) saturate(180%);
  white-space: nowrap;
}

.walk-hint {
  top: 24px;
}

.walk-keys {
  bottom: 92px;
  color: var(--muted);
}

.walk-keys span {
  padding: 0 6px;
}

.walk-stick {
  display: none;
  position: absolute;
  left: 28px;
  bottom: 108px;
  width: 112px;
  height: 112px;
  pointer-events: auto;
  touch-action: none;
}

.walk-stick__base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(22, 22, 24, 0.48);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.walk-stick__thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(245, 245, 247, 0.88);
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

body.is-walking .hero-copy {
  opacity: 0;
}

body.is-walking #btn-autorotate {
  display: none;
}

body.is-walking #viewport {
  cursor: none;
}

body.is-pointer-locked .walk-hint {
  opacity: 0;
}

@media (pointer: coarse) {
  .walk-stick {
    display: block;
  }
}

.loader {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 8, 10, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.loader.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loader__card {
  min-width: 220px;
  padding: 24px 28px 22px;
  border-radius: 24px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  text-align: center;
  backdrop-filter: blur(28px) saturate(180%);
}

.loader__ring {
  width: 28px;
  height: 28px;
  margin: 0 auto 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-top-color: #f5f5f7;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.loader__card p:first-of-type {
  font-size: 15px;
  font-weight: 560;
}

#loader-pct {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.loader__track {
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.loader__bar {
  width: 0;
  height: 100%;
  background: #f5f5f7;
  transition: width 160ms linear;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

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

@media (max-width: 860px) {
  .icon-btn {
    display: grid;
    place-items: center;
  }

  .model-panel {
    top: auto;
    bottom: 108px;
    left: 16px;
    right: 16px;
    width: auto;
    display: none;
  }

  .model-panel.is-open {
    display: block;
  }

  .model-list {
    max-height: 42vh;
  }

  .hero-copy {
    left: 20px;
    right: 20px;
    bottom: 108px;
  }

  .hero-copy h2 {
    font-size: 32px;
  }

  .toolbar {
    left: 16px;
    right: 16px;
    bottom: 16px;
    transform: none;
    overflow: auto;
    justify-content: flex-start;
  }

  .walk-stick {
    display: block;
  }

  .walk-keys {
    display: none;
  }

  .walk-hint {
    top: 78px;
    max-width: calc(100% - 32px);
    white-space: normal;
    text-align: center;
  }

  .minimap {
    top: 70px;
    right: 16px;
    width: 120px;
    padding: 6px;
    border-radius: 18px;
  }

  .minimap canvas {
    border-radius: 12px;
  }

  #floor-label {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader__ring,
  .model-card,
  .loader {
    animation: none;
    transition: none;
  }
}
