* {
  box-sizing: border-box;
}

: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;
}

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;
}

.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);
}

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

model-viewer {
  width: 100%;
  height: 100%;
  background: transparent;
  --poster-color: transparent;
}

.loading-overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(244, 245, 247, .08);
  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: grid;
  justify-items: center;
  align-items: center;
  gap: 11px;
  padding: 12px;
  color: #4b5563;
  text-align: center;
}

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

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

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

.loading-copy {
  display: grid;
  justify-items: center;
}

.loading-copy strong {
  font-size: 15px;
  font-weight: 650;
  color: #4b5563;
}

.loading-copy span {
  display: none;
  max-width: min(320px, calc(100vw - 40px));
  margin-top: 5px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.45;
}

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

.loading-overlay.is-error .loading-copy span {
  display: block;
}

.retry-button {
  margin-top: 2px;
  padding: 7px 10px;
  border-color: #d5dae1;
  background: #fff;
  color: #4b5563;
}

.ar-button {
  position: absolute;
  left: 50%;
  bottom: 54px;
  transform: translateX(-50%);
  padding: 10px 18px;
  color: #2563eb;
  font-weight: 600;
}

.status {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 15px;
  transform: translateX(-50%);
  max-width: calc(100vw - 28px);
  padding: 7px 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .76);
  color: #5b6472;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(15, 23, 42, .08);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.status.error {
  background: rgba(153, 27, 27, .9);
  color: #fff;
}

@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;
  }

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

  .loading-card {
    padding: 10px;
  }

  .status {
    display: none;
  }
}
