* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #fff;
  color: #1f2937;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

button {
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 9px;
  padding: 8px 13px;
  background: rgba(255, 255, 255, .92);
  color: #1f2937;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

button:hover {
  background: #fff;
  border-color: rgba(15, 23, 42, .28);
}

.viewer-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  overscroll-behavior: none;
  touch-action: none;
}

.topbar {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  pointer-events: none;
}

.topbar h1 {
  max-width: min(68vw, 760px);
  margin: 0;
  overflow: hidden;
  color: #111827;
  font-size: clamp(17px, 2.2vw, 24px);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(255, 255, 255, .85);
}

.viewer-shell[data-title-align="center"] .topbar { justify-content: center; }
.viewer-shell[data-title-align="right"] .topbar { justify-content: flex-end; padding-right: 126px; }
.viewer-shell[data-title-wrap="true"] .topbar h1 { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }

.actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

model-viewer {
  width: 100%;
  height: 100%;
  background: transparent;
  --poster-color: transparent;
  --progress-bar-height: 0px;
  overscroll-behavior: none;
  touch-action: none;
}

.loading-overlay {
  position: absolute;
  z-index: 5;
  right: 14px;
  bottom: 14px;
  display: block;
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease, visibility .3s ease;
  pointer-events: none;
}

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

.loading-overlay.is-error {
  pointer-events: auto;
}

.loading-card {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  color: #4b5563;
}

.progress-ring {
  --progress: 0%;
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#596273 var(--progress), #dfe3e8 0);
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #fff;
}

.progress-ring span {
  position: relative;
  z-index: 1;
  color: #4b5563;
  font-size: 9px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.loading-overlay.is-error .progress-ring {
  background: conic-gradient(#dc6262 100%, #f0d6d6 0);
}

.loading-overlay.is-error {
  left: 50%;
  right: auto;
  bottom: 50%;
  transform: translate(-50%, 50%);
}

.retry-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: #d5dae1;
  background: #fff;
  color: #4b5563;
  font-size: 20px;
}

.standard-views {
  position: absolute;
  z-index: 4;
  top: 14px;
  right: 14px;
  display: grid;
  gap: 7px;
}

.standard-views button {
  width: auto;
  min-width: 46px;
  max-width: 94px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  background: rgba(255, 255, 255, .88);
  color: #374151;
  font-size: 11px;
  font-weight: 650;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .08);
  backdrop-filter: blur(8px);
}

.standard-views button:hover,
.standard-views button:focus-visible {
  border-color: rgba(37, 99, 235, .45);
  color: #2563eb;
  outline: none;
}

.product-control-stack {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 18px;
  display: flex;
  width: calc(100% - 32px);
  max-width: 720px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.product-control-stack nav { pointer-events: auto; }

.product-poses {
  display: flex;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.product-poses button {
  max-width: 112px;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  font-size: 11px;
}

.product-poses button.is-active {
  border-color: #3974c7;
  background: #3974c7;
  color: #fff;
}

.product-pose-slider {
  display: grid;
  width: min(270px, calc(100vw - 64px));
  gap: 3px;
  padding: 7px 11px 6px;
  border: 1px solid rgba(31,41,55,.14);
  border-radius: 6px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 3px 14px rgba(15,23,42,.1);
  backdrop-filter: blur(8px);
}

.product-pose-slider-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #556173;
  font-size: 10px;
  font-weight: 650;
}

.product-pose-slider input {
  width: 100%;
  height: 17px;
  margin: 0;
  accent-color: #3974c7;
  cursor: ew-resize;
}

.product-looks {
  display: flex;
  max-width: 100%;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  overflow-x: auto;
}

.product-looks button {
  display: grid;
  justify-items: center;
  gap: 4px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #344054;
  font-size: 10px;
  box-shadow: none;
}

.product-looks i {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255,255,255,.94);
  border-radius: 50%;
  background: var(--swatch, #fff);
  box-shadow: 0 2px 11px rgba(15,23,42,.25);
}

.product-looks button:hover i,
.product-looks button:focus-visible i {
  outline: 2px solid rgba(37,99,235,.5);
}

.product-model-looks {
  display: flex;
  max-width: 100%;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
}

.product-model-looks button {
  display: grid;
  justify-items: center;
  gap: 4px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #344054;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: none;
}

.product-model-looks button i {
  display: grid;
  place-items: center;
  width: var(--model-look-icon-size,34px);
  height: var(--model-look-icon-size,34px);
  border: 2px solid rgba(255,255,255,.94);
  border-radius: 4px;
  background: rgba(255,255,255,.94);
  color: #4b5b70;
  font-size: 10px;
  font-style: normal;
  box-shadow: 0 2px 11px rgba(15,23,42,.22);
  overflow: hidden;
}

.product-model-looks button i.is-color-icon { background: var(--model-look-color,#3974c7); }
.product-model-looks button i img { display: block; width: 100%; height: 100%; object-fit: contain; }

.product-model-looks button:hover i,
.product-model-looks button:focus-visible i {
  outline: 2px solid rgba(37,99,235,.5);
}

.product-model-looks button.is-active i {
  outline: 2px solid #3974c7;
  outline-offset: 2px;
  background: #3974c7;
  color: #fff;
}

.animation-toggle {
  min-height: 32px;
  border: 1px solid rgba(31,41,55,.16);
  border-radius: 5px;
  padding: 5px 9px;
  background: rgba(255,255,255,.92);
  color: #3d4858;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(15,23,42,.1);
}

.animation-toggle[aria-pressed="true"] {
  border-color: #3974c7;
  background: #3974c7;
  color: #fff;
}

.animation-toggle {
  position: absolute;
  z-index: 6;
  top: 14px;
  right: 14px;
}

.viewer-shell.has-animation-toggle .standard-views { top: 56px; }

.product-poses[hidden],
.product-looks[hidden],
.product-model-looks[hidden],
.animation-toggle[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .loading-overlay { transition: none; }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    padding: 12px;
  }

  .topbar h1 {
    max-width: 48vw;
  }

  .viewer-shell[data-title-align="right"] .topbar { padding-right: 66px; }

  button {
    padding: 7px 10px;
    font-size: 13px;
  }

  .standard-views {
    right: 9px;
  }

  .viewer-shell.has-animation-toggle .standard-views {
    top: 12px;
    right: 70px;
  }

  .product-control-stack { bottom: 14px; width: calc(100% - 24px); gap: 8px; }
  .product-pose-slider { width: min(220px, calc(100vw - 54px)); }

  .animation-toggle {
    top: 52px;
    right: 10px;
  }
}
