:root {
  color-scheme: light;
  --paper: #f6f2ec;
  --ink: #24201d;
  --muted: #655c51;
  --edge: #dbd2c5;
  --stage: #cec4b6;
  --gold: #d9c197;
  --focus: #8b501a;
  --gutter: clamp(24px, 4.15vw, 72px);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.65 var(--sans);
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible,
#viewer-canvas:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

button:disabled { cursor: default; }

.page-header,
.showcase {
  width: min(100% - 2 * var(--gutter), 1500px);
  margin-inline: auto;
}

.page-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--edge);
}

.brand {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .19em;
  white-space: nowrap;
}

.page-caption {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .055em;
  white-space: nowrap;
}

.showcase {
  display: grid;
  grid-template-columns: minmax(250px, .91fr) minmax(0, 1.86fr);
  grid-template-rows: 1fr auto auto 1fr;
  grid-template-areas:
    ". stage"
    "title stage"
    "controls stage"
    ". stage";
  column-gap: clamp(28px, 4vw, 72px);
  align-items: start;
  padding-block: clamp(24px, 4.2vh, 54px) max(30px, env(safe-area-inset-bottom));
}

.product-identity { grid-area: title; }

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(54px, 6.25vw, 96px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.055em;
}

h1 span {
  display: block;
  margin-top: .1em;
  white-space: nowrap;
}

.viewer-stage {
  grid-area: stage;
  isolation: isolate;
  position: relative;
  width: 100%;
  height: clamp(460px, calc(100svh - 161px), 760px);
  overflow: hidden;
  background: var(--stage);
  box-shadow: 0 0 0 1px rgba(75, 58, 37, .11);
}

.viewer-fallback,
#viewer-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.viewer-fallback {
  object-fit: contain;
  object-position: 50% 50%;
}

.viewer-stage[data-state="loading"] .viewer-fallback { visibility: hidden; }

#viewer-canvas {
  visibility: hidden;
  touch-action: none;
  cursor: grab;
}

#viewer-canvas:active { cursor: grabbing; }
#viewer-canvas:focus-visible { outline-offset: -5px; }

.viewer-stage[data-state="ready"] #viewer-canvas { visibility: visible; }
.viewer-stage[data-state="ready"] .viewer-fallback { display: none; }

.stage-status {
  position: absolute;
  bottom: 16px;
  inset-inline-start: 16px;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 7px 11px;
  background: rgba(246, 242, 236, .94);
  color: var(--muted);
  border: 1px solid rgba(92, 70, 47, .13);
  font-size: 12px;
  line-height: 1.45;
}

.reset-view {
  position: absolute;
  bottom: 16px;
  inset-inline-end: 16px;
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 11px 5px 9px;
  border: 1px solid rgba(92, 70, 47, .18);
  background: rgba(246, 242, 236, .93);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.viewer-stage[data-state="ready"] .reset-view:not([hidden]) { display: inline-flex; }
.reset-view:hover:not(:disabled) { background: var(--paper); }

.reset-mark {
  font: 400 20px/1 system-ui, sans-serif;
  margin-bottom: 2px;
}

.viewer-controls {
  grid-area: controls;
  padding-top: clamp(26px, 4.15vh, 46px);
}

.viewer-stage[data-state="fallback"] ~ .viewer-controls { display: none; }

.drawer-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 168px;
  min-height: 50px;
  padding: 12px 17px;
  background: var(--ink);
  color: #faf4e9;
  border: 1px solid var(--ink);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease;
}

.drawer-button:hover:not(:disabled) { background: #463a2e; }
.drawer-button:disabled { opacity: .53; }

.drawer-arrow {
  width: 21px;
  height: 13px;
  position: relative;
  color: var(--gold);
  transform: rotate(90deg);
  transition: transform .22s ease;
}

.drawer-arrow::before,
.drawer-arrow::after {
  content: "";
  position: absolute;
}

.drawer-arrow::before {
  width: 19px;
  top: 6px;
  inset-inline-end: 1px;
  border-top: 1px solid currentColor;
}

.drawer-arrow::after {
  top: 3px;
  inset-inline-end: 1px;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1px 1px 0 0;
  transform: rotate(45deg);
}

body[data-open="true"] .drawer-arrow { transform: rotate(-90deg); }

#viewer-help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.touch-help { display: none; }

@media (pointer: coarse) {
  .touch-help { display: inline; }
}

@media (max-width: 760px) {
  :root { --gutter: clamp(16px, 5vw, 32px); }

  .page-header { min-height: 60px; }
  .brand { font-size: 19px; }
  .page-caption { font-size: 11px; }

  .showcase {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "title" "stage" "controls";
    row-gap: 17px;
    padding-top: 25px;
  }

  h1 {
    font-size: clamp(37px, 9vw, 60px);
    letter-spacing: -.06em;
  }

  h1 span {
    display: inline;
    margin-top: 0;
  }

  .viewer-stage { height: clamp(350px, min(126vw, 68svh), 570px); }

  .reset-view {
    bottom: 10px;
    inset-inline-end: 10px;
  }

  .stage-status {
    bottom: 10px;
    inset-inline-start: 10px;
  }

  .viewer-controls { padding-top: 0; }
  .drawer-button { width: 100%; }
  #viewer-help { margin-top: 9px; }
}

@media (max-width: 760px) and (max-height: 650px) {
  .page-header { min-height: 52px; }
  .showcase { row-gap: 13px; padding-top: 16px; }
  .viewer-stage { height: clamp(282px, calc(100svh - 202px), 440px); }
}

@media (prefers-reduced-motion: reduce) {
  .drawer-button, .drawer-arrow { transition: none; }
}
