:root {
  color-scheme: light;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171918;
  background: #f1f0eb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(190, 132, 52, 0.34);
  outline-offset: 3px;
}

.viewer-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  background: #f1f0eb;
}

.scene,
.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.scene canvas {
  cursor: grab;
  touch-action: none;
}

.scene canvas:active {
  cursor: grabbing;
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px 28px;
  pointer-events: none;
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #f7f4eb;
  background: #203f38;
  border-radius: 6px;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.8;
}

.brand-name {
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-divider {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: rgba(23, 25, 24, 0.2);
}

.brand-section {
  color: #606561;
  font-size: 14px;
  white-space: nowrap;
}

.top-actions {
  gap: 10px;
  pointer-events: auto;
}

.model-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  color: #515651;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(34, 40, 36, 0.1);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #408263;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(64, 130, 99, 0.12);
}

.command-button,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 650;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.command-button {
  color: #f8f7f2;
  background: #1d211f;
  box-shadow: 0 8px 24px rgba(20, 23, 21, 0.14);
}

.command-button:hover {
  background: #343a36;
}

.command-button svg,
.save-button svg {
  width: 17px;
  height: 17px;
}

.product-summary {
  position: absolute;
  z-index: 6;
  top: 122px;
  left: 32px;
  max-width: min(320px, calc(100vw - 64px));
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 9px;
  color: #9a6a2c;
  font-size: 12px;
  font-weight: 750;
}

.product-summary h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 720;
  line-height: 1.18;
  letter-spacing: 0;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
  color: #676c68;
  font-size: 13px;
}

.viewer-tools {
  position: absolute;
  z-index: 8;
  top: 50%;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(-50%);
}

.icon-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: #4c514e;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(31, 35, 32, 0.11);
  border-radius: 6px;
  box-shadow: 0 7px 24px rgba(33, 39, 35, 0.08);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.icon-button:hover,
.icon-button.is-active {
  color: #f7f5ed;
  background: #234c43;
  border-color: #234c43;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}

.icon-button::after {
  position: absolute;
  top: 50%;
  right: calc(100% + 9px);
  padding: 6px 8px;
  color: #f7f5ef;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  content: attr(data-tooltip);
  background: #252927;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translate(4px, -50%);
  transition: 150ms ease;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.customization-panel {
  position: absolute;
  z-index: 9;
  right: 50%;
  bottom: 22px;
  display: flex;
  align-items: center;
  width: min(1100px, calc(100vw - 136px));
  min-height: 86px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(33, 38, 35, 0.09);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(34, 39, 35, 0.12);
  backdrop-filter: blur(18px);
  transform: translateX(50%);
}

.option-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 9px;
}

.color-group {
  padding: 0 20px 0 8px;
}

.material-group {
  min-width: 246px;
  padding: 0 18px;
  flex: 1;
}

.pattern-group {
  min-width: 370px;
  padding: 0 18px;
  flex: 1.1;
}

.option-label {
  color: #6b716c;
  font-size: 12px;
  font-weight: 650;
}

.color-options,
.segmented-control {
  display: flex;
  align-items: center;
}

.color-options {
  gap: 10px;
}

.color-swatch {
  position: relative;
  width: 27px;
  height: 27px;
  padding: 0;
  background: var(--swatch);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(24, 27, 25, 0.16);
  cursor: pointer;
}

.color-swatch.is-selected::after {
  position: absolute;
  inset: -5px;
  content: "";
  border: 1.5px solid #202522;
  border-radius: 50%;
}

.color-swatch--light {
  box-shadow: 0 0 0 1px rgba(24, 27, 25, 0.24);
}

.panel-divider {
  width: 1px;
  height: 48px;
  flex: 0 0 auto;
  background: rgba(23, 28, 25, 0.11);
}

.segmented-control {
  width: 100%;
  padding: 3px;
  background: #eeefeb;
  border-radius: 6px;
}

.segment {
  height: 31px;
  padding: 0 16px;
  flex: 1;
  color: #676c68;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.segment.is-selected {
  color: #1e2421;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(28, 32, 29, 0.1);
}

.pattern-controls,
.pattern-adjustments,
.pattern-adjustment {
  display: flex;
  align-items: center;
}

.pattern-controls {
  gap: 9px;
  min-height: 37px;
}

.pattern-adjustments {
  gap: 12px;
}

.pattern-placement {
  display: inline-flex;
  width: 176px;
  height: 35px;
  padding: 3px;
  flex: 0 0 176px;
  background: #e9e9e5;
  border-radius: 5px;
}

.pattern-placement-option {
  min-width: 0;
  padding: 0;
  flex: 1;
  color: #6b716c;
  font-size: 12px;
  font-weight: 650;
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

.pattern-placement-option.is-selected {
  color: #1e2421;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(28, 32, 29, 0.1);
}

.pattern-placement-option:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.pattern-upload-button,
.pattern-remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 35px;
  color: #2b332f;
  background: #f2f2ee;
  border: 1px solid rgba(31, 36, 33, 0.12);
  border-radius: 5px;
  cursor: pointer;
}

.pattern-upload-button {
  gap: 6px;
  min-width: 104px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 650;
}

.pattern-remove-button {
  width: 35px;
  padding: 0;
  flex: 0 0 35px;
}

.pattern-upload-button:hover,
.pattern-remove-button:hover:not(:disabled) {
  color: #ffffff;
  background: #234c43;
  border-color: #234c43;
}

.pattern-upload-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.pattern-upload-button svg,
.pattern-remove-button svg {
  width: 16px;
  height: 16px;
}

.pattern-remove-button:disabled {
  color: #a5aaa6;
  cursor: not-allowed;
  opacity: 0.58;
}

.pattern-adjustment {
  display: grid;
  min-width: 0;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 18px;
  gap: 2px 6px;
  flex: 1;
  color: #6b716c;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pattern-adjustment > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.pattern-adjustment input {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  height: 18px;
  margin: 0;
  accent-color: #bb7e34;
  cursor: pointer;
}

.pattern-adjustment output {
  min-width: 0;
  grid-column: 2;
  grid-row: 1;
  color: #343a36;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pattern-adjustment input:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.save-button {
  min-width: 126px;
  height: 48px;
  color: #ffffff;
  background: #bb7e34;
}

.save-button:hover {
  background: #a86d29;
}

.save-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.save-button:disabled:hover {
  background: #bb7e34;
}

/* 预览模式：客户只看衣服，隐藏标题、右侧工具和编辑面板 */
body.is-preview .customization-panel,
body.is-preview #openModelButton,
body.is-preview .product-meta,
body.is-preview .topbar,
body.is-preview .product-summary,
body.is-preview .viewer-tools {
  display: none;
}

.loading-screen {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: #f1f0eb;
  transition: opacity 360ms ease, visibility 360ms ease;
}

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

.loading-mark {
  display: grid;
  width: 108px;
  height: 108px;
  place-items: center;
  overflow: hidden;
  background: transparent;
  border-radius: 24px;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

.loading-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loading-copy {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 5px;
}

.loading-copy strong {
  font-size: 16px;
}

.loading-copy span {
  color: #707570;
  font-size: 13px;
}

.loading-track {
  width: min(240px, 72vw);
  height: 3px;
  overflow: hidden;
  background: #d8d9d4;
  border-radius: 2px;
}

.loading-track span {
  display: block;
  width: 28%;
  height: 100%;
  background: #bb7e34;
  transform-origin: left;
  transition: width 180ms ease;
}

.toast {
  position: absolute;
  z-index: 40;
  top: 88px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  color: #f5f4ef;
  font-size: 13px;
  font-weight: 600;
  background: #252a27;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(20, 25, 22, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 17px;
  height: 17px;
  color: #85c9a2;
}

@keyframes loadingPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.94);
  }
}

@media (max-width: 760px) {
  .viewer-shell {
    min-height: 520px;
  }

  .topbar {
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-divider,
  .brand-section,
  .model-status,
  .command-button span {
    display: none;
  }

  .command-button {
    width: 40px;
    height: 40px;
    padding: 0;
  }

  .product-summary {
    top: 78px;
    left: 16px;
    max-width: calc(100vw - 80px);
  }

  .product-summary h1 {
    font-size: 23px;
  }

  .product-meta {
    margin-top: 7px;
  }

  .viewer-tools {
    top: 37%;
    right: 12px;
    gap: 7px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .icon-button::after {
    display: none;
  }

  .customization-panel {
    right: 0;
    bottom: 0;
    display: grid;
    width: 100%;
    min-height: 204px;
    padding: 13px 14px calc(13px + env(safe-area-inset-bottom));
    grid-template-columns: 1fr auto;
    gap: 12px 14px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    transform: none;
  }

  .color-group,
  .material-group,
  .pattern-group {
    padding: 0;
  }

  .color-group {
    min-width: 0;
  }

  .color-options {
    gap: 9px;
  }

  .color-swatch {
    width: 25px;
    height: 25px;
  }

  .material-group {
    min-width: 0;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .pattern-group {
    min-width: 0;
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .pattern-controls {
    flex-wrap: wrap;
  }

  .pattern-adjustments {
    width: 100%;
    gap: 8px;
  }

  .panel-divider {
    display: none;
  }

  .save-button {
    min-width: 112px;
    height: 48px;
    align-self: end;
    grid-column: 2;
    grid-row: 1;
  }

  .segment {
    padding: 0 10px;
  }

  .toast {
    top: 70px;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .customization-panel {
    width: calc(100vw - 126px);
  }

  .color-group {
    padding-right: 14px;
  }

  .material-group,
  .pattern-group {
    min-width: 250px;
    padding: 0 13px;
  }

  .pattern-controls {
    flex-wrap: wrap;
  }

  .save-button {
    min-width: 50px;
    width: 50px;
    padding: 0;
  }

  .save-button span {
    display: none;
  }
}

@media (max-width: 390px) {
  .brand-name {
    max-width: 96px;
    font-size: 15px;
  }

  .customization-panel {
    gap: 11px 10px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .color-options {
    gap: 7px;
  }

  .save-button {
    min-width: 102px;
    padding: 0 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
