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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: #0f1115;
  color: #e8eaed;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ---- viewer ---- */

.viewer-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.viewer-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.top-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  max-width: calc(100% - 32px);
}

.top-title {
  padding: 8px 18px;
  background: rgba(20, 22, 28, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70vw;
}

.viewer-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 21, 0.72);
  z-index: 20;
  gap: 16px;
  color: #9aa0a6;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2a2f3a;
  border-top-color: #e85a4f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.viewer-error {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1115;
  z-index: 30;
  color: #f28b82;
  padding: 24px;
  text-align: center;
}

/* ---- bottom dock ---- */

.dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.dock.is-collapsed {
  /* keep handle visible: body height ≈ strip + nav */
  transform: translateY(calc(100% - 28px));
}

.dock-handle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 48px;
  height: 28px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: rgba(30, 32, 38, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.dock-handle-bar {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.55);
}

.dock-body {
  width: 100%;
  max-width: 720px;
  padding: 12px 12px 10px;
  border-radius: 16px;
  background: rgba(28, 30, 36, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.scene-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.scene-item {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  height: 66px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  scroll-snap-align: start;
  background: #252830;
  transition: border-color 0.2s, transform 0.15s;
}

.scene-item:active {
  transform: scale(0.96);
}

.scene-item.is-active {
  border-color: #e85a4f;
}

.scene-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.scene-item-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 4px 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-size: 11px;
  text-align: center;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .dock {
    left: 50%;
    right: auto;
    width: min(720px, calc(100% - 48px));
    transform: translateX(-50%);
  }

  .dock.is-collapsed {
    transform: translateX(-50%) translateY(calc(100% - 28px));
  }

  .scene-item {
    width: 100px;
    height: 74px;
  }
}
