:root {
  color-scheme: light;
  --paper: #d6c1b0;
  --ink: #302a22;
  --muted: #645c50;
  --brass: #80653b;
  --hair: rgba(88, 71, 48, .29);
  --edge: clamp(24px, 4.8vw, 88px);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "Times New Roman", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button {
  color: inherit;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 410px;
  overflow: hidden;
  background: radial-gradient(ellipse at 39% 39%, #eedcc9 0%, #dfcbb9 51%, #c8b09e 100%);
}
#scene, #fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene { display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
#fallback {
  pointer-events: none;
  opacity: 1;
  container-type: size;
  --poster-height: min(86cqh, 166.9926cqw);
  --poster-width: calc(var(--poster-height) * 941 / 1672);
  --poster-left: calc(54.5cqw - var(--poster-width) / 2);
  --poster-top: calc(47cqh - var(--poster-height) / 2);
}
/* Extend only the outermost image pixels into the surrounding studio backdrop. */
#fallback::before {
  content: "";
  position: absolute;
  inset: 0;
  border-image-source: url("./assets/hero.webp");
  border-image-slice: 1 fill;
  border-image-width: var(--poster-top) calc(100cqw - var(--poster-left) - var(--poster-width))
    calc(100cqh - var(--poster-top) - var(--poster-height)) var(--poster-left);
  border-image-repeat: stretch;
  filter: blur(7px);
}
#fallback img {
  position: absolute;
  top: var(--poster-top);
  left: var(--poster-left);
  width: var(--poster-width);
  height: var(--poster-height);
  object-fit: contain;
  display: block;
}
.state-loaded #fallback { opacity: 0; visibility: hidden; }
.state-error #fallback { opacity: 1; visibility: visible; }
.masthead {
  position: absolute;
  top: max(4vh, env(safe-area-inset-top));
  left: var(--edge);
  right: var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.wordmark { display: grid; gap: 4px; justify-items: center; }
.wordmark span:first-child {
  font: 600 clamp(19px, 1.45vw, 25px)/1.05 var(--serif);
  letter-spacing: .16em;
  margin-right: -.16em;
}
.wordmark span:last-child { font: 10px/1.25 Georgia, "Times New Roman", serif; letter-spacing: .16em; }
.reset, .zoom button { display: inline-flex; justify-content: center; align-items: center; }
.reset {
  pointer-events: auto;
  min-height: 44px;
  gap: 7px;
  font-size: 12px;
  letter-spacing: .06em;
}
.reset svg { width: 17px; height: 17px; }
.identity {
  position: absolute;
  pointer-events: none;
  left: var(--edge);
  top: 45%;
  transform: translateY(-50%);
}
h1, h2, p { margin: 0; }
h1 {
  font: 500 clamp(33px, 3.9vw, 67px)/1.22 var(--serif);
  letter-spacing: .055em;
}
h1 span { display: block; }
.product-en { margin-top: 17px; font: italic clamp(14px, 1.13vw, 20px)/1.36 Georgia, "Times New Roman", serif; color: var(--muted); }
.volume { margin-top: 30px; width: fit-content; border-top: 1px solid var(--hair); padding-top: 11px; font: 17px/1 Georgia, "Times New Roman", serif; letter-spacing: .035em; }
.volume span { font-size: 12px; }
.zoom {
  position: absolute;
  right: var(--edge);
  top: 48%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  border-block: 1px solid var(--hair);
}
.zoom button { width: 44px; height: 44px; }
.zoom button + button { border-top: 1px solid var(--hair); }
.zoom svg { width: 17px; height: 17px; }
.controls {
  position: absolute;
  inset-inline: var(--edge);
  bottom: max(4.3vh, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
  pointer-events: none;
}
.view-controls, .opening-control, .angles button { pointer-events: auto; }
h2, .opening-label label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: .12em;
}
.angles { display: flex; width: max-content; gap: clamp(3px, .68vw, 12px); margin-left: -4px; }
.angles button {
  position: relative;
  min-width: 40px;
  min-height: 44px;
  font-size: 13px;
  line-height: 1;
  letter-spacing: .045em;
  color: var(--muted);
}
.angles button::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 20px;
  height: 2px;
  background: var(--brass);
  transform: translateX(-50%) scaleX(0);
  transition: transform .16s ease;
}
.angles button:is([aria-pressed="true"], .active, .is-active) { color: var(--ink); font-weight: 600; }
.angles button:is([aria-pressed="true"], .active, .is-active)::after { transform: translateX(-50%) scaleX(1); }
.gesture {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 8px;
  min-height: 44px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  white-space: nowrap;
}
.gesture svg { width: 20px; height: 20px; }
.hint-divider { padding-inline: 3px; color: var(--brass); }
.touch-hint { display: none; }
.opening-control { width: min(100%, 204px); justify-self: end; }
.opening-label { display: flex; align-items: center; justify-content: space-between; gap:5px; }
.drawer-trigger { display:inline-flex; align-items:center; gap:6px; min-height:32px; padding:0 11px; border-radius:3px; background:#44382d; color:#fff6e8; font-size:12px; }
.drawer-trigger svg { width:14px; height:14px; }
.drawer-trigger[aria-expanded="true"] svg { transform:rotate(180deg); }
#open-value { font: 12px/1.2 Georgia, "Times New Roman", serif; color: var(--brass); font-variant-numeric: tabular-nums; }
#opening {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--brass);
  accent-color: var(--brass);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
#opening::-webkit-slider-runnable-track { height: 2px; background: var(--hair); border-radius: 0; }
#opening::-moz-range-track { height: 2px; background: var(--hair); border-radius: 0; }
#opening::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--brass); background: var(--brass); margin-top: -4.5px; }
#opening::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--brass); background: var(--brass); }
#status { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); }
.no-script, #stage.state-error #status:not(:empty) {
  position: absolute; top: 14%; left: var(--edge); right: var(--edge); text-align: center;
  height: auto; width: auto; clip-path: none; font-size: 12px; color: var(--muted); pointer-events: none;
}
@media (hover: hover) {
  .angles button:hover, .reset:hover, .zoom button:hover { color: var(--brass); }
  .drawer-trigger:hover { background:#554533; }
  .zoom button:hover { background: rgba(128, 101, 59, .055); }
}
@media (pointer: coarse) {
  .wheel-hint { display: none; }
  .touch-hint { display: inline; }
}
@media (max-width: 800px) {
  :root { --edge: clamp(19px, 4.6vw, 32px); }
  #fallback {
    --poster-height: min(calc(100cqh - 210px), 163.4687cqw);
    --poster-left: calc(50cqw - var(--poster-width) / 2);
    --poster-top: calc(50cqh - var(--poster-height) / 2);
  }
  .masthead { top: max(17px, env(safe-area-inset-top)); }
  .wordmark { gap: 3px; }
  .wordmark span:first-child { font-size: 18px; }
  .wordmark span:last-child { font-size: 9px; }
  .identity { top: calc(max(17px, env(safe-area-inset-top)) + 62px); transform: none; }
  h1 { font-size: clamp(18px, 3vw, 25px); }
  h1 span { display: inline; }
  .product-en { display: none; }
  .volume { display: inline-block; border: 0; margin: 5px 0 0; padding: 0; font-size: 13px; }
  .volume span { font-size: 10px; }
  .zoom { right: max(12px, env(safe-area-inset-right)); }
  .zoom button { width: 38px; }
  .controls {
    bottom: max(12px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(195px, 1.1fr) minmax(99px, 1fr);
    gap: 0 16px;
    padding-top: 12px;
  }
  .gesture { grid-column: 1 / -1; grid-row: 2; min-height: 20px; gap: 6px; font-size: 10px; }
  .gesture svg { width: 16px; height: 16px; }
  .opening-control { grid-column: 2; grid-row: 1; max-width: 175px; }
  .angles { gap: 0; }
  .angles button { min-width: 39px; font-size: 12px; }
  .angles button::after { bottom: 7px; width: 16px; }
  h2, .opening-label label { font-size: 10px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #stage { min-height: 280px; }
  .masthead { top: max(8px, env(safe-area-inset-top)); }
  .identity { top: 44%; transform: translateY(-50%); }
  h1 { font-size: 22px; }
  h1 span { display: block; }
  .product-en { display: none; }
  .volume { margin-top: 8px; padding-top: 5px; }
  .controls { bottom: max(5px, env(safe-area-inset-bottom)); padding-top: 5px; grid-template-columns: 1fr auto 1fr; }
  .gesture { grid-column: 2; grid-row: 1; min-height: 44px; }
  .opening-control { grid-column: 3; grid-row: 1; }
  #fallback {
    --poster-height: min(calc(100cqh - 88px), 90cqw);
    --poster-left: calc(54.5cqw - var(--poster-width) / 2);
    --poster-top: calc(46cqh - var(--poster-height) / 2);
  }
}
@media (max-height: 520px) and (orientation: landscape) and (max-width: 850px) {
  .controls { grid-template-columns: minmax(195px, 1fr) minmax(99px, 1fr); }
  .gesture { display: none; }
  .opening-control { grid-column: 2; }
}
@media (max-width: 420px) and (orientation: portrait) {
  .controls { grid-template-columns: minmax(0, 1fr); padding-top: 3px; }
  .view-controls { display: flex; align-items: center; justify-content: space-between; }
  .opening-control {
    grid-column: 1; grid-row: 2; width: 100%; max-width: none;
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px;
  }
  .opening-label { gap: 7px; }
  .angles { gap: 0; margin-left: 0; }
  .angles button { min-width: clamp(34px, 10.2vw, 40px); }
  .gesture { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) { *, *::after { transition-duration: 0s !important; } }
