:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #252629;
  background: #fafafa;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button { font: inherit; color: inherit; }
.product {
  width: min(100%, 672px);
  margin: 0 auto;
  padding: max(36px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.intro { margin-bottom: 26px; text-align: center; }
h1 { margin: 0 0 12px; font-size: clamp(28px, 5.5vw, 38px); font-weight: 600; line-height: 1.15; letter-spacing: -1.2px; }
.intro p { max-width: 32ch; margin: 0 auto; color: #65666b; font-size: 15px; line-height: 1.5; }
.viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: #f1f1f1;
  box-shadow: 0 8px 32px rgb(25 27 30 / 4%);
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline-offset: 5px;
  cursor: progress;
}
.viewer[data-ready="true"] { cursor: grab; }
.viewer.is-dragging { cursor: grabbing; }
.viewer:focus-visible, button:focus-visible { outline: 2px solid #252629; outline-offset: 5px; }
.product-frame { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 20px; padding: 28px; background: #f1f1f1;
}
.loading-label { font-size: 14px; color: #55575b; }
.progress-row { display: flex; align-items: center; gap: 12px; width: min(220px, 100%); }
progress { appearance: none; border: 0; height: 3px; width: 100%; background: #dadddf; color: #34363a; border-radius: 3px; overflow: hidden; }
progress::-webkit-progress-bar { background: #dadddf; }
progress::-webkit-progress-value { background: #34363a; }
progress::-moz-progress-bar { background: #34363a; }
#load-percentage { min-width: 4ch; font-size: 12px; color: #65666b; font-variant-numeric: tabular-nums; text-align: right; }
.hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 11px 16px; border-radius: 30px; background: rgb(255 255 255 / 95%);
  color: #45474b; font-size: 12px; box-shadow: 0 2px 12px rgb(0 0 0 / 5%);
  pointer-events: none;
}
.viewer-controls { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 18px; }
.step-button {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid #dedfe1; background: transparent; cursor: pointer;
  touch-action: manipulation;
}
.step-button:disabled { opacity: .35; cursor: default; }
.step-button:active:not(:disabled) { background: #e6e7e9; }
.angle { min-width: 108px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: #45474b; }
.keyboard-help { margin: 12px 0 0; text-align: center; font-size: 12px; line-height: 1.5; color: #6e7075; }
.fallback-notice { margin: 20px 0 0; font-size: 13px; line-height: 1.5; text-align: center; color: #62646a; }
.error-message { padding: 24px 12px 0; text-align: center; font-size: 14px; line-height: 1.6; }
.error-message p { margin: 0 auto 16px; max-width: 40ch; }
.retry-button { min-height: 44px; padding: 10px 18px; background: #252629; color: #fff; border: 0; border-radius: 8px; cursor: pointer; }
.no-script { font-size: 14px; line-height: 1.5; text-align: center; }
@media (hover: hover) {
  .step-button:hover:not(:disabled) { background: #edeef0; border-color: #c7c9cc; }
  .retry-button:hover { background: #3d3f43; }
}
@media (min-width: 700px) {
  .product { padding-top: 52px; }
  .intro { margin-bottom: 30px; }
  .intro p { max-width: none; font-size: 16px; }
}
@media (max-width: 359px) {
  .product { padding-left: 16px; padding-right: 16px; }
  .intro p { font-size: 14px; }
  .hint { bottom: 14px; padding: 9px 12px; }
}

/* A página da peça funciona como uma tela fixa em celulares e tablets de toque. */
@media (max-width: 699px), (max-width: 1000px) and (max-height: 600px), (hover: none) and (pointer: coarse) {
  html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  body {
    position: fixed;
    inset: 0;
    min-width: 0;
    height: 100%;
    height: 100dvh;
    touch-action: pinch-zoom;
  }
  .product {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    height: 100%;
    max-width: 720px;
    padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow: hidden;
  }
  .intro { margin: 0; }
  h1 { margin-bottom: 10px; font-size: clamp(26px, 6.5vw, 32px); }
  .intro p { font-size: 14px; line-height: 1.4; }
  .viewer-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
  }
  .viewer-stage {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: grid;
    place-items: center;
    container-type: size;
  }
  .viewer {
    /* Primeiro valor é reserva para navegadores sem unidades de contêiner. */
    width: min(100%, calc(100vh - 220px));
    width: min(100cqw, 100cqh);
    height: auto;
    max-width: 100%;
    aspect-ratio: 1;
    overscroll-behavior: none;
  }
  .viewer-controls { flex: 0 0 auto; margin-top: 12px; }
  .keyboard-help { display: none; }
  .fallback-notice { flex: 0 0 auto; margin-top: 10px; }
  .error-message { max-width: 400px; padding: 16px; }
  .no-script { font-size: 12px; }
}
/* Em paisagem, a altura define o tamanho da peça, sem cortar os controles. */
@media (max-width: 1000px) and (max-height: 500px) {
  .product { gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  h1 { margin-bottom: 4px; font-size: 24px; }
  .intro p { max-width: none; font-size: 13px; }
  .viewer-controls { margin-top: 8px; }
  .hint { bottom: 10px; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
