:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #151918;
  --muted: #767e7b;
  --accent: #e76f3d;
  --line: #dfe3df;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 75% 10%, rgba(231, 111, 61, 0.10), transparent 28rem),
    #f2f3f0;
}

.viewer-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.viewer-header {
  position: absolute;
  z-index: 5;
  top: 28px;
  left: 32px;
  right: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

.angle-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.angle-display span {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.angle-display small {
  margin-top: 2px;
  color: var(--muted);
}

.viewer {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #fff;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  outline: none;
}

.viewer:focus-visible {
  box-shadow: 0 0 0 3px rgba(231, 111, 61, 0.35), 0 24px 70px rgba(36, 42, 39, 0.09);
}

.viewer.dragging {
  cursor: grabbing;
}

#viewerCanvas,
#productImage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#viewerCanvas {
  opacity: 0;
  transition: opacity 0.2s ease;
}

#productImage {
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  opacity: 1;
}

.viewer.ready #viewerCanvas {
  opacity: 1;
}

.viewer.ready #productImage {
  opacity: 0;
}

.loading {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  transition: opacity 0.25s ease;
}

.viewer.ready .loading {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.drag-hint {
  position: absolute;
  z-index: 4;
  bottom: 98px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 15px;
  color: #fff;
  border-radius: 99px;
  background: rgba(21, 25, 24, 0.78);
  backdrop-filter: blur(8px);
  font-size: 12px;
  transform: translateX(-50%);
  transition: opacity 0.3s ease;
}

.viewer.interacted .drag-hint {
  opacity: 0;
}

.hint-arrow {
  color: #ffad89;
  font-size: 16px;
}

.controls {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(560px, calc(100% - 40px));
  transform: translateX(-50%);
}

.nav-button {
  flex: 0 0 64px;
  width: 64px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(36, 42, 39, 0.06);
  font-size: 21px;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.nav-button:active {
  transform: translateY(0) scale(0.96);
}

.nav-button:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.instruction {
  display: none;
}

@media (max-width: 600px) {
  .viewer-header {
    top: 20px;
    left: 20px;
    right: 20px;
  }

  .controls {
    bottom: 22px;
  }

  .drag-hint {
    bottom: 84px;
  }

  .angle-display span {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
