:root {
  color-scheme: light;
  --ink: #202b3c;
  --muted: #657181;
  --accent: #0e357f;
  --surface: #fff;
  --line: #d9dde3;
  --scene: #f1f2f4;
  --w: 500px;
  --paper-h: 441.176px;
  --base-h: 547.059px;
  --floor-y: 520.284px;
  --floor-depth: 338.1px;
  --floor-z: 169.05px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--scene);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
button:focus-visible, select:focus-visible { outline: 3px solid #3972c9; outline-offset: 4px; }
.header {
  height: 88px;
  margin: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
h1 { display: flex; align-items: baseline; gap: 17px; margin: 0; font-weight: 500; }
h1 strong { font-size: 32px; letter-spacing: -1.5px; font-weight: 650; }
h1 span { font-size: 15px; letter-spacing: 2px; }
.header-note { font-size: 13px; color: var(--muted); }
main { display: flex; flex-direction: column; min-height: calc(100dvh - 88px); }
.viewport {
  position: relative;
  flex: 1;
  min-height: 320px;
  height: calc(100dvh - 264px);
  perspective: 2300px;
  perspective-origin: 50% 42%;
  overflow: hidden;
}
.anchor {
  position: absolute;
  width: var(--w);
  height: var(--base-h);
  left: 50%;
  transform: translateX(-50%);
  transform-style: preserve-3d;
}
.framing, .calendar, .leaves {
  position: absolute;
  width: var(--w);
  height: var(--base-h);
  transform-style: preserve-3d;
  transform-origin: 50% 0;
}
.framing { transition: transform 210ms ease; }
.framing.is-flipping { transform: translateY(var(--flip-shift)) scale(var(--flip-scale)); }
.calendar {
  transform: rotateX(-7deg) rotateY(-12deg);
  transition: transform 720ms cubic-bezier(.25,.6,.25,1);
}
.calendar.is-rear { transform: rotateX(-7deg) rotateY(168deg); }
.base-panel {
  position: absolute;
  width: var(--w);
  height: var(--base-h);
  background: #fff;
  border: 1px solid #d0d3d8;
  transform-origin: 50% 0;
  backface-visibility: hidden;
  box-shadow: 0 1px 0 1px #b9bec6, 0 2px 0 2px #dddfe3;
}
.base-panel img { display: block; width: 100%; height: 100%; object-fit: contain; }
.base-front { transform: rotateX(18deg); }
.base-back { transform: rotateX(-18deg) rotateY(180deg); }
/* Hide the flat drawing's old printed hole marks; the model supplies its rings. */
.base-back::after { content: ""; position: absolute; inset: 0 0 auto; height: 5.5%; background: white; }
.base-floor {
  position: absolute;
  width: var(--w);
  height: var(--floor-depth);
  top: var(--floor-y);
  background: #d5d9df;
  transform-origin: 50% 0;
  transform: translateZ(var(--floor-z)) rotateX(-90deg);
}
.leaf {
  position: absolute;
  width: var(--w);
  height: var(--paper-h);
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  transition: transform 820ms cubic-bezier(.4,.12,.24,1);
}
.face {
  position: absolute;
  inset: 0;
  background: white;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 0 1px 1px;
  box-shadow: 0 0 0 .5px #c4c8cf, 0 5px 8px -5px #3e475458;
  overflow: hidden;
}
.face-front { transform: translateZ(.16px); }
.face-back { transform: rotateY(180deg) translateZ(.16px); }
.face img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #2935490d, transparent 3%, transparent 98%, #141b2706);
}
.binding {
  position: absolute;
  width: 100%;
  height: 30px;
  top: -15px;
  transform-style: preserve-3d;
}
.binding-front { transform: translateZ(9px); }
.binding-back { transform: translateZ(-9px) rotateY(180deg); }
.wire {
  position: absolute;
  top: 0;
  width: 1.1%;
  min-width: 3px;
  height: 28px;
  border: 2px solid #8d96a1;
  border-left-color: #e5e8ed;
  border-right-color: #5e6875;
  border-radius: 45%;
  box-shadow: 1px 1px 1px #2f394633;
  background: transparent;
}
.wire::after { content: ""; position: absolute; inset: -2px; transform: translateX(5px); border: inherit; border-radius: inherit; }
.ground-shadow {
  position: absolute;
  left: 50%;
  height: 24px;
  border-radius: 50%;
  background: #26344c;
  opacity: .17;
  filter: blur(14px);
  transform: translateX(-50%) rotate(-2deg);
}
.calendar.instant .leaf { transition: none; }
.reader-controls { position: relative; padding: 12px 20px 23px; text-align: center; }
.caption { min-height: 41px; display: flex; align-items: baseline; justify-content: center; gap: 16px; }
.caption h2 { font-weight: 550; font-size: 16px; margin: 0; }
.caption span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; align-items: center; justify-content: center; gap: 8px; }
.toolbar button, select {
  border: 1px solid var(--line);
  border-radius: 9px;
  height: 44px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
  transition: background 150ms, border-color 150ms;
}
.toolbar button:not(:disabled):hover { background: #e8edf6; border-color: #bcc8db; }
.nav-button { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 16px; }
.nav-button span[aria-hidden] { font-size: 25px; line-height: 1; font-weight: 300; }
.page-picker { display: block; }
select { width: 175px; padding: 0 12px; cursor: pointer; }
.toolbar .reverse-button { margin-left: 12px; padding: 0 18px; color: var(--accent); border-color: #c4cede; }
.hint { color: var(--muted); font-size: 12px; margin: 15px 0 0; min-height: 18px; }
.asset-error { font-size: 13px; color: #a43227; margin: 12px auto 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 600px) {
  .header { height: 72px; margin: 0 22px; }
  h1 { gap: 12px; }
  h1 strong { font-size: 28px; }
  h1 span { font-size: 13px; }
  main { min-height: calc(100dvh - 72px); }
  .viewport { height: calc(100dvh - 288px); min-height: 300px; }
  .reader-controls { padding: 8px 16px 22px; }
  .caption { gap: 10px; min-height: 36px; }
  .caption h2 { font-size: 15px; }
  .toolbar { display: grid; grid-template-columns: 82px minmax(115px, 175px) 82px; gap: 8px; }
  .nav-button { padding: 0 10px; gap: 7px; }
  select { width: 100%; font-size: 12px; padding: 0 8px; }
  .toolbar .reverse-button { grid-column: 1 / -1; justify-self: center; margin: 3px 0 0; height: 37px; }
  .hint { margin-top: 12px; font-size: 11px; }
  .wire { height: 22px; border-width: 1.5px; }
  .wire::after { inset: -1.5px; transform: translateX(4px); }
  .binding { top: -11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .framing.is-flipping { transform: none; }
}
