:root {
  color-scheme: light;
  --ink: #202321;
  --muted: #777d79;
  --line: rgba(32, 35, 33, .12);
  --paper: #f5f6f5;
  --accent: #fe4f02;
  --edge: clamp(18px, 3vw, 44px);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); }
button, a { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.studio {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 64px;
  overflow: hidden;
}
.topbar, .bottombar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  padding: 0 var(--edge);
  background: var(--paper);
}
.topbar { gap: 17px; border-bottom: 1px solid var(--line); }
.wordmark {
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .13em;
  font-weight: 700;
}
.page-title { color: #555b57; font-size: 14px; }
.stage { position: relative; min-height: 0; overflow: hidden; isolation: isolate; background: #e9ecea; }
.stage-wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,255,255,.94) 0%, rgba(248,249,248,.78) 32%, rgba(231,235,233,.35) 74%),
    linear-gradient(145deg, #edf0ee 0%, #e4e8e6 100%);
}
model-viewer {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background-color: transparent;
  touch-action: none;
  outline: none;
}
model-viewer:focus-visible { outline: 2px solid var(--accent); outline-offset: -5px; }
.load-state {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: min(260px, calc(100% - 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translate(-50%, -50%);
  color: #69706c;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.load-state[hidden] { display: none; }
.loader {
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(32,35,33,.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { width: 100%; height: 2px; overflow: hidden; background: rgba(32,35,33,.11); }
.progress-track[hidden] { display: none; }
.progress-track > span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s ease-out; }
.load-state.is-error { pointer-events: auto; color: var(--ink); }
.load-state.is-error .loader, .load-state.is-error .progress-track { display: none; }
.retry-button {
  padding: 9px 15px;
  border: 1px solid rgba(32,35,33,.25);
  border-radius: 2px;
  background: rgba(255,255,255,.5);
  font-size: 13px;
  cursor: pointer;
}
.retry-button:hover { border-color: var(--accent); }
.view-tools {
  position: absolute;
  right: var(--edge);
  bottom: var(--edge);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(32,35,33,.1);
  border-radius: 4px;
  background: rgba(250,251,250,.79);
  box-shadow: 0 5px 22px rgba(24,30,27,.06);
  backdrop-filter: blur(12px);
}
.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { background: rgba(32,35,33,.07); }
.icon-button:focus-visible, .retry-button:focus-visible, .model-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-button:disabled { opacity: .42; cursor: default; }
.reset-button { font-size: 21px; }
.tool-rule { width: 1px; height: 22px; margin: 0 2px; background: var(--line); }
.bottombar { justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); }
.interaction-copy { display: flex; align-items: center; gap: 10px; min-width: 0; }
.interaction-copy p { margin: 0; color: #626965; font-size: 13px; }
.interaction-copy p span { padding: 0 4px; color: #a0a5a1; }
.model-details { position: relative; flex: 0 0 auto; }
.model-details summary { display: flex; align-items: center; gap: 8px; color: #4f5652; font-size: 14px; cursor: pointer; list-style: none; }
.model-details summary::-webkit-details-marker { display: none; }
.details-chevron { display: inline-block; color: #8a908c; transition: transform .2s ease; }
.model-details[open] .details-chevron { transform: rotate(180deg); }
.details-panel {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: calc(100% + 16px);
  width: min(320px, calc(100vw - 36px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(250,251,250,.97);
  box-shadow: 0 12px 35px rgba(24,30,27,.12);
}
.stats-status { margin: 0; color: var(--muted); font-size: 14px; }
.stats-grid { display: grid; grid-template-columns: 1fr auto; gap: 10px 22px; margin: 0; font-size: 14px; }
.stats-grid[hidden] { display: none; }
.stats-grid dt { color: var(--muted); }
.stats-grid dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }

@supports (height: 100dvh) {
  body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
  .studio { height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .studio { min-height: 400px; grid-template-rows: 56px minmax(0, 1fr) 62px; }
  .topbar { gap: 12px; }
  .view-tools { right: 12px; bottom: 12px; gap: 2px; padding: 4px; }
  .icon-button { width: 44px; height: 44px; }
  .bottombar { gap: 12px; padding: 0 16px; }
  .interaction-copy { gap: 8px; }
  .interaction-copy p { max-width: 176px; font-size: 14px; line-height: 1.35; }
  .model-details summary { gap: 5px; font-size: 14px; white-space: nowrap; }
  .details-panel { bottom: calc(100% + 12px); }
}
@media (max-width: 380px) {
  .bottombar { gap: 8px; }
  .interaction-copy p { max-width: 145px; font-size: 14px; }
}
@media (max-height: 400px) and (orientation: landscape) {
  .studio { grid-template-rows: 48px minmax(0, 1fr) 52px; }
  .topbar, .bottombar { padding-left: 18px; padding-right: 18px; }
  .view-tools { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
