.viewer, .viewer-compare {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 1rem auto;
  aspect-ratio: 16 / 10;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #e7ecf1 70%, #dde3ea 100%);
  touch-action: none; /* let OrbitControls handle touch gestures */
}

/* The compare strip holds all three models side by side, so it's wider. */
.viewer-compare { max-width: 760px; aspect-ratio: 16 / 7; }

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

.viewer-controls {
  position: absolute;
  right: 10px;
  bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

/* Play/pause + drag-to-seek progress bar, pinned along the bottom edge. */
.viewer-transport {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-play {
  flex: 0 0 auto;
  padding: .2rem .5rem;
  line-height: 1;
  font-size: .9rem;
}

.viewer-scrub {
  flex: 1 1 auto;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: #1b1f24;
  opacity: .8;
  transition: opacity .15s ease;
}

.viewer-scrub:hover { opacity: 1; }

.viewer-btn {
  padding: .45rem .8rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: .85rem;
  color: #1b1f24;
  background: rgba(255, 255, 255, .85);
  border: 1px solid #d0d7de;
  border-radius: 6px;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background .15s ease;
}

.viewer-btn:hover { background: #fff; }
.viewer-btn:active { transform: translateY(1px); }

.viewer:fullscreen, .viewer-compare:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
}

.viewer.is-loading::after, .viewer-compare.is-loading::after {
  content: "Loading 3D model\2026";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #57606a;
  font-size: .95rem;
}

.viewer.has-error::after, .viewer-compare.has-error::after {
  content: "Could not load this model.";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b35900;
  font-size: .95rem;
}

.ar-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(10, 14, 20, .82);
  backdrop-filter: blur(3px);
}

.ar-overlay .ar-viewer {
  width: min(92vw, 900px);
  height: min(72vh, 640px);
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #e7ecf1 70%, #dde3ea 100%);
  border-radius: 12px;
}

.ar-overlay .ar-hint {
  margin: 0;
  max-width: 40rem;
  text-align: center;
  color: #e8edf2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: .9rem;
}

.ar-overlay .ar-close { align-self: flex-end; }

@media (max-width: 600px) {
  .viewer { aspect-ratio: 4 / 3; }
}
