:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d7d3c8;
  --paper: #171714;
  --paper-deep: #2b2923;
  --accent: #9a6a45;
  --accent-dark: #6f4a2e;
  --panel: #ffffff;
  --shadow: 0 24px 70px rgba(36, 32, 28, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    linear-gradient(126deg, transparent 0 10%, rgba(255, 255, 255, 0.28) 10.3%, transparent 11.2% 28%, rgba(92, 99, 101, 0.16) 28.4%, transparent 29.8% 62%, rgba(255, 255, 255, 0.34) 62.4%, transparent 64%),
    linear-gradient(143deg, transparent 0 18%, rgba(255, 255, 255, 0.42) 18.4%, transparent 19.4% 44%, rgba(78, 86, 88, 0.18) 44.2%, transparent 45.8% 72%, rgba(255, 255, 255, 0.26) 72.3%, transparent 73.5%),
    linear-gradient(34deg, transparent 0 20%, rgba(232, 236, 236, 0.34) 20.3%, transparent 21.5% 50%, rgba(108, 116, 118, 0.13) 50.4%, transparent 52%),
    radial-gradient(ellipse at 28% 18%, rgba(245, 247, 247, 0.5), transparent 28rem),
    radial-gradient(ellipse at 78% 72%, rgba(98, 106, 108, 0.2), transparent 34rem),
    linear-gradient(135deg, #bfc4c3 0%, #9ea6a6 38%, #c8ccca 72%, #929a9b 100%);
  background-size: 100% 100%, 78rem 78rem, 54rem 54rem, 100% 100%, 100% 100%, 100% 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  min-width: 0;
  padding: 18px clamp(12px, 2.2vw, 34px) 32px;
}

.settings-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.14);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 26px rgba(36, 32, 28, 0.14);
  backdrop-filter: blur(10px);
  font-size: 17px;
  line-height: 1;
}

.settings-button:hover,
.settings-button.active {
  color: #ffffff;
  background: var(--ink);
}

.book-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.18);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(36, 32, 28, 0.12);
}

.quick-button {
  width: 38px;
  height: 38px;
  font-size: 15px;
  font-weight: 800;
}

#firstPage {
  order: -2;
}

#prevPage {
  order: -1;
}

#nextPage {
  order: 1;
}

#lastPage {
  order: 2;
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.icon-button:active,
.tool-button:active,
.segment:active {
  transform: translateY(1px);
}

.page-meter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 38px;
  border: 1px solid rgba(32, 33, 36, 0.13);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  font-weight: 700;
}

.book-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  perspective: 2200px;
  touch-action: pan-y;
}

.book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(94vw, 920px);
  aspect-ratio: 18 / 16;
  max-height: 86vh;
  border-radius: 14px;
  box-shadow:
    0 42px 42px rgba(31, 27, 24, 0.24),
    0 10px 18px rgba(31, 27, 24, 0.12);
  transform: rotateX(4deg);
  transform-style: preserve-3d;
  transition:
    width 520ms cubic-bezier(0.2, 0.72, 0.16, 1),
    transform 520ms cubic-bezier(0.2, 0.72, 0.16, 1),
    border-radius 520ms ease;
  contain: layout style;
  will-change: transform;
}

.book.closed-front,
.book.closed-back {
  grid-template-columns: 1fr;
  width: min(56vw, 430px);
  aspect-ratio: 9 / 16;
  max-height: 86vh;
  border-radius: 20px 12px 12px 20px;
  transform: rotateX(5deg) rotateZ(-0.45deg);
}

.book.closed-front .page-right,
.book.closed-back .page-left {
  display: none;
}

.book.closed-front .page-left,
.book.closed-back .page-right {
  display: block;
  border: 1px solid rgba(225, 220, 208, 0.78);
  border-radius: 20px 12px 12px 20px;
  box-shadow:
    inset -20px 0 34px rgba(255, 255, 255, 0.1),
    inset 12px 0 22px rgba(0, 0, 0, 0.22),
    10px 12px 0 -5px #efe5d2,
    15px 17px 0 -8px #d7c7aa,
    0 32px 46px rgba(31, 27, 24, 0.24);
  transform: translateZ(18px);
}

.book.closed-back .page-right {
  border-radius: 12px 20px 20px 12px;
  transform: translateZ(18px);
  box-shadow:
    inset 20px 0 34px rgba(255, 255, 255, 0.1),
    inset -12px 0 22px rgba(0, 0, 0, 0.22),
    -10px 12px 0 -5px #efe5d2,
    -15px 17px 0 -8px #d7c7aa,
    0 32px 46px rgba(31, 27, 24, 0.24);
}

.book.closed-front .page-left::before,
.book.closed-back .page-right::before {
  opacity: 0.54;
  background:
    linear-gradient(112deg, transparent 0 24%, rgba(255, 255, 255, 0.38) 38%, transparent 52%),
    linear-gradient(72deg, transparent 0 58%, rgba(255, 255, 255, 0.22) 64%, transparent 72%),
    repeating-linear-gradient(82deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 28px);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.book.closed-front::after,
.book.closed-back::after {
  display: block;
  inset: 0 auto 0 0;
  width: 18px;
  transform: none;
  border-radius: 20px 0 0 20px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.56), rgba(255, 255, 255, 0.15) 48%, transparent);
  z-index: 9;
}

.book.closed-back::after {
  inset: 0 0 0 auto;
  border-radius: 0 20px 20px 0;
  background:
    linear-gradient(270deg, rgba(0, 0, 0, 0.56), rgba(255, 255, 255, 0.15) 48%, transparent);
}

.book::before {
  content: "";
  position: absolute;
  left: 1.8%;
  right: 1.8%;
  bottom: -18px;
  height: 34px;
  border-radius: 0 0 18px 18px;
  background:
    repeating-linear-gradient(0deg, #ddd2bf 0 2px, #fff8ea 3px 5px),
    linear-gradient(90deg, #c4b49c, #fff7e8 18%, #ddc8aa 50%, #fff7e8 82%, #bfae96);
  box-shadow: 0 26px 46px rgba(32, 25, 20, 0.2);
  transform: translateZ(-24px) rotateX(-6deg);
  transform-origin: top center;
  z-index: -2;
}

.book.closed-front::before,
.book.closed-back::before {
  left: 5%;
  right: 5%;
  bottom: -22px;
  height: 44px;
  transform: translateZ(-28px) rotateX(-8deg);
}

.page {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.14)),
    radial-gradient(ellipse at 50% 104%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(90deg, rgba(15, 13, 12, 0.94), rgba(44, 40, 35, 0.46) 38%, rgba(210, 205, 192, 0.28) 50%, rgba(34, 31, 27, 0.58) 68%, rgba(12, 11, 10, 0.92)),
    repeating-linear-gradient(78deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 34px),
    var(--paper);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  box-shadow: inset 0 -10px 18px rgba(78, 56, 36, 0.08);
}

.page.cover-page,
.page.back-cover-page {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.18), transparent 22rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 38%),
    linear-gradient(145deg, #11100f 0%, #312b25 42%, #070706 100%);
}

.page.cover-page .page-content,
.page.back-cover-page .page-content {
  align-content: center;
  grid-template-rows: auto auto auto;
}

.page.cover-page h1,
.page.cover-page h2,
.page.back-cover-page h1,
.page.back-cover-page h2 {
  max-width: 9ch;
  font-size: clamp(36px, 4.8vw, 72px);
}

.page-left {
  border-radius: 14px 2px 2px 14px;
  transform-origin: right center;
  box-shadow:
    inset -26px 0 38px rgba(0, 0, 0, 0.5),
    inset 0 -30px 26px rgba(255, 255, 255, 0.16);
}

.page-right {
  border-radius: 2px 14px 14px 2px;
  border-left: 0;
  transform-origin: left center;
  background:
    linear-gradient(270deg, rgba(0, 0, 0, 0.42), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.14)),
    radial-gradient(ellipse at 48% 104%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(90deg, rgba(70, 66, 60, 0.68), rgba(220, 216, 205, 0.42) 17%, rgba(36, 33, 29, 0.9) 32%, rgba(24, 23, 21, 0.92) 70%, rgba(7, 7, 6, 0.98)),
    repeating-linear-gradient(102deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 34px),
    var(--paper);
  box-shadow:
    inset 26px 0 38px rgba(0, 0, 0, 0.5),
    inset 0 -30px 26px rgba(255, 255, 255, 0.16);
}

.page::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 25%;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.66), transparent);
  pointer-events: none;
  z-index: 1;
}

.page::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(105deg, transparent 0 34%, rgba(255, 255, 255, 0.58) 48%, transparent 62%);
  pointer-events: none;
  z-index: 4;
}

.book::after {
  content: "";
  position: absolute;
  inset: 0 50%;
  width: 26px;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse at center, rgba(18, 13, 10, 0.34), transparent 62%),
    linear-gradient(90deg, rgba(40, 31, 25, 0.34), rgba(255, 255, 255, 0.5), rgba(40, 31, 25, 0.26));
  pointer-events: none;
  z-index: 8;
}

.book.is-turning {
  pointer-events: none;
}

.book.gesture-turning {
  cursor: grabbing;
  transition: none;
}

.book.cover-opening-stage,
.book.back-cover-opening-stage {
  grid-template-columns: 1fr 1fr;
  width: min(94vw, 920px);
  aspect-ratio: 18 / 16;
  border-radius: 14px;
  transform: rotateX(4deg);
}

.book.cover-closing-stage,
.book.back-cover-closing-stage {
  grid-template-columns: 1fr;
  width: min(56vw, 430px);
  aspect-ratio: 9 / 16;
  border-radius: 20px 12px 12px 20px;
  transform: rotateX(5deg) rotateZ(-0.45deg);
}

.book.back-cover-closing-stage {
  border-radius: 12px 20px 20px 12px;
}

.turn-underlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  transform-style: preserve-3d;
}

.book .turn-underlay .page-left,
.book .turn-underlay .page-right,
.book .turn-sheet .page-left,
.book .turn-sheet .page-right,
.book .cover-turn-sheet .page-left,
.book .cover-turn-sheet .page-right {
  display: block;
  height: 100%;
  transform: none;
}

.book .turn-underlay .page-left,
.book .turn-sheet .page-left {
  border-radius: 14px 2px 2px 14px;
  box-shadow:
    inset -26px 0 38px rgba(0, 0, 0, 0.5),
    inset 0 -30px 26px rgba(255, 255, 255, 0.16);
}

.book .turn-underlay .page-right,
.book .turn-sheet .page-right {
  border-left: 0;
  border-radius: 2px 14px 14px 2px;
  box-shadow:
    inset 26px 0 38px rgba(0, 0, 0, 0.5),
    inset 0 -30px 26px rgba(255, 255, 255, 0.16);
}

.turn-sheet,
.cover-turn-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 18;
  pointer-events: none;
  transform-style: preserve-3d;
  contain: layout paint style;
  isolation: isolate;
  will-change: transform;
}

.turn-sheet {
  width: 50%;
}

.turn-next {
  left: 50%;
  transform-origin: left center;
  animation: smoothTurnNext 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.turn-prev {
  left: 0;
  transform-origin: right center;
  animation: smoothTurnPrev 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.boundary-turn-sheet {
  z-index: 20;
}

.front-boundary-sheet,
.front-boundary-sheet .turn-face,
.front-boundary-sheet .page {
  border-radius: 20px 12px 12px 20px;
}

.back-boundary-sheet,
.back-boundary-sheet .turn-face,
.back-boundary-sheet .page {
  border-radius: 12px 20px 20px 12px;
}

.glass-turn-sheet {
  filter: drop-shadow(0 24px 28px rgba(20, 20, 18, 0.18));
}

.glass-turn-sheet .turn-face {
  overflow: visible;
  background: transparent;
}

.glass-turn-sheet .turn-face::before {
  background:
    linear-gradient(105deg, transparent 0 24%, rgba(255, 255, 255, 0.62) 42%, transparent 58%),
    linear-gradient(72deg, transparent 0 42%, rgba(255, 255, 255, 0.28) 48%, transparent 56%);
}

.glass-turn-sheet .turn-face::after {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 24%, rgba(255, 255, 255, 0.18) 72%, rgba(0, 0, 0, 0.2)),
    radial-gradient(ellipse at 50% 96%, rgba(255, 255, 255, 0.28), transparent 36%);
}

.glass-page {
  border: 1px solid rgba(255, 255, 255, 0.46);
  background:
    linear-gradient(116deg, rgba(255, 255, 255, 0.68) 0 9%, rgba(215, 226, 226, 0.5) 10% 34%, rgba(255, 255, 255, 0.72) 43%, rgba(204, 217, 217, 0.54) 53% 100%),
    repeating-linear-gradient(82deg, rgba(255, 255, 255, 0.2) 0 1px, rgba(207, 219, 219, 0.08) 1px 24px),
    radial-gradient(ellipse at 44% 92%, rgba(255, 255, 255, 0.46), rgba(211, 222, 222, 0.22) 24%, transparent 46%),
    linear-gradient(135deg, #e4ebea, #c9d4d3 48%, #edf2f1);
  background-color: #dce5e4;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.28),
    inset 18px 0 36px rgba(255, 255, 255, 0.18),
    inset -22px 0 44px rgba(26, 31, 31, 0.18),
    0 18px 38px rgba(28, 28, 24, 0.16);
  backdrop-filter: blur(16px) saturate(1.16);
  -webkit-backdrop-filter: blur(16px) saturate(1.16);
}

.glass-page .page-content {
  position: absolute;
  inset: 0;
  display: block;
  height: auto;
  padding: 0;
  overflow: hidden;
}

.glass-page .eyebrow,
.glass-page h1,
.glass-page h2,
.glass-page .body-copy,
.glass-page .page-links,
.glass-page .character-layer {
  display: none;
}

.glass-page::before {
  opacity: 1;
  background:
    linear-gradient(100deg, rgba(218, 229, 229, 0.2) 0 22%, rgba(255, 255, 255, 0.56) 34%, rgba(218, 229, 229, 0.24) 49%),
    linear-gradient(74deg, rgba(218, 229, 229, 0.18) 0 56%, rgba(255, 255, 255, 0.34) 62%, rgba(218, 229, 229, 0.22) 70%);
}

.glass-page::after {
  inset: 0;
  height: auto;
  opacity: 0.86;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.42), rgba(220, 230, 230, 0.22) 28%, transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(218, 229, 229, 0.22) 22%, rgba(120, 138, 138, 0.16));
}

.glass-content {
  position: absolute;
  inset: 0;
  display: block;
  height: auto;
  padding: 0;
  overflow: hidden;
}

.glass-fog,
.glass-ridge,
.glass-edge {
  position: absolute;
  pointer-events: none;
}

.glass-fog {
  inset: 6%;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 50% 78%, rgba(255, 255, 255, 0.42), rgba(224, 234, 234, 0.2) 32%, transparent 54%),
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.28), rgba(224, 234, 234, 0.16) 28%, transparent 48%);
  filter: blur(4px);
  opacity: 0.86;
}

.glass-ridge {
  top: -8%;
  bottom: -8%;
  width: 38%;
  background: linear-gradient(95deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: skewX(-10deg);
  opacity: 0.56;
}

.front-glass-page .glass-ridge {
  left: 18%;
}

.back-glass-page .glass-ridge {
  right: 18%;
}

.glass-edge {
  top: 0;
  bottom: 0;
  width: 9px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.08));
  opacity: 0.72;
}

.front-glass-page .glass-edge {
  left: 0;
}

.back-glass-page .glass-edge {
  right: 0;
  transform: scaleX(-1);
}

.front-glass-page,
.back-glass-page {
  background-blend-mode: screen, normal, normal, normal;
}

.front-glass-page .glass-fog,
.back-glass-page .glass-fog {
  inset: 0;
  background:
    linear-gradient(135deg, rgba(237, 244, 243, 0.72), rgba(202, 216, 216, 0.54)),
    radial-gradient(ellipse at 52% 68%, rgba(255, 255, 255, 0.52), rgba(220, 231, 231, 0.22) 34%, transparent 58%);
  opacity: 0.95;
}

.cover-turn-sheet {
  z-index: 20;
  width: var(--cover-sheet-width, var(--cover-start-width));
}

.front-cover-sheet {
  left: 0;
  transform-origin: left center;
}

.back-cover-sheet {
  right: 0;
  transform-origin: right center;
}

.front-cover-sheet.cover-sheet-opening {
  animation: frontCoverOpenSmooth 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.front-cover-sheet.cover-sheet-closing {
  animation: frontCoverCloseSmooth 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.back-cover-sheet.cover-sheet-closing {
  animation: backCoverCloseSmooth 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.back-cover-sheet.cover-sheet-opening {
  animation: backCoverOpenSmooth 1040ms cubic-bezier(0.16, 0.78, 0.16, 1) both;
}

.gesture-turn-sheet,
.gesture-turn-sheet .turn-face::before,
.gesture-turn-sheet .turn-face::after {
  animation: none !important;
}

.gesture-turn-sheet .turn-face::before {
  opacity: var(--turn-gloss-opacity, 0);
  transform: translateX(var(--turn-gloss-x, -42%));
}

.gesture-turn-sheet .turn-face::after {
  opacity: var(--turn-shade, 0.08);
}

.turn-sheet.gesture-turn-sheet::after,
.cover-turn-sheet.gesture-turn-sheet::after {
  content: "";
  position: absolute;
  inset: 5% -5% -7%;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.32), transparent 68%);
  opacity: calc(var(--turn-lift, 0) * 0.72);
  transform: translateY(14px) scaleX(0.92);
  pointer-events: none;
}

.turn-prep {
  animation-play-state: paused;
}

.turn-prep .turn-face::before,
.turn-prep .turn-face::after {
  animation-play-state: paused;
}

.turn-prep.turn-live {
  animation-play-state: running;
}

.turn-prep.turn-live .turn-face::before,
.turn-prep.turn-live .turn-face::after {
  animation-play-state: running;
}

.turn-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.turn-front {
  transform: rotateY(0deg) translateZ(1px);
}

.turn-back {
  transform: rotateY(180deg) translateZ(1px);
}

.turn-face .page {
  width: 100%;
  height: 100%;
  cursor: default;
  contain: layout paint style;
  transform: translateZ(0);
}

.cover-turn-sheet .turn-face .page {
  border-radius: inherit;
}

.front-cover-sheet,
.front-cover-sheet .turn-face,
.front-cover-sheet .page {
  border-radius: 20px 12px 12px 20px;
}

.back-cover-sheet,
.back-cover-sheet .turn-face,
.back-cover-sheet .page {
  border-radius: 12px 20px 20px 12px;
}

.turn-face::before,
.turn-face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.turn-face::before {
  background: linear-gradient(105deg, transparent 0 26%, rgba(255, 255, 255, 0.56) 46%, transparent 68%);
  animation: turnGloss 1040ms ease both;
}

.turn-face::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.48), transparent 30%, rgba(255, 255, 255, 0.12) 72%, rgba(0, 0, 0, 0.36));
  animation: turnShade 1040ms ease both;
}

.flip-canvas {
  position: absolute;
  inset: 0;
  z-index: 14;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cover-flip {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: grid;
  grid-template-columns: 1fr;
  border-radius: 18px 10px 10px 18px;
  overflow: hidden;
  transform-style: preserve-3d;
  transform-origin: left center;
  box-shadow:
    0 32px 58px rgba(22, 17, 14, 0.34),
    inset -24px 0 36px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  will-change: transform;
}

.cover-flip .page {
  border-radius: inherit;
  height: 100%;
}

.cover-opening {
  animation: coverOpen 1280ms cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

.cover-closing {
  animation: coverClose 1280ms cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

.back-cover-closing {
  transform-origin: right center;
  animation: backCoverClose 1280ms cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

.back-cover-opening {
  transform-origin: right center;
  animation: backCoverOpen 1280ms cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

.page.is-covered .page-content {
  visibility: hidden;
}

.flip-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: visible;
  pointer-events: none;
  z-index: 12;
  transform-style: preserve-3d;
  contain: layout style;
}

.flip-slice {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--i) * 100% / var(--n));
  width: calc(100% / var(--n));
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  box-shadow: var(--slice-shadow);
}

.flip-slice .page-content {
  height: 100%;
  width: calc(var(--n) * 100%);
  margin-left: calc(var(--i) * -100%);
}

.sheet-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(71, 52, 33, 0.14), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.62)),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(92, 72, 45, 0.035) 29px 30px),
    radial-gradient(circle at 38% 16%, rgba(255, 255, 255, 0.7), transparent 16rem),
    var(--paper);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.sheet-front {
  transform: rotateY(0deg) translateZ(1px);
}

.sheet-back {
  transform: rotateY(180deg) translateZ(1px);
}

.flip-slice::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    linear-gradient(110deg, transparent 0 28%, rgba(255, 255, 255, 0.68) 43%, rgba(71, 52, 33, 0.2) 58%, transparent 72%);
  pointer-events: none;
  z-index: 4;
}

.flip-slice::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: var(--slice-shade);
  pointer-events: none;
  z-index: 5;
}

.flip-slice .page-content::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  pointer-events: none;
  z-index: 6;
}

.flip-slice .page-content::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  opacity: 0.65;
  pointer-events: none;
}

.flip-next {
  left: 50%;
  transform-origin: left center;
}

.flip-next .flip-slice {
  --slice-shadow: -10px 14px 28px rgba(20, 16, 13, 0.16);
  --slice-shade: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.34));
  transform-origin: left center;
  animation: curlNext 1500ms cubic-bezier(0.18, 0.72, 0.16, 1) both;
}

.flip-next .sheet-face {
  border-radius: 0;
}

.flip-next .edge-end .sheet-face {
  border-right: 1px solid var(--line);
  border-radius: 0 10px 10px 0;
}

.flip-next .page-content::after {
  left: 0;
  background: linear-gradient(90deg, rgba(38, 27, 19, 0.28), transparent);
}

.flip-next .page-content::before {
  right: -1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.55), #d7c7ac 42%, rgba(89, 63, 42, 0.3));
  transform: translateZ(3px);
}

.flip-prev {
  left: 0;
  transform-origin: right center;
}

.flip-prev .flip-slice {
  --slice-shadow: 10px 14px 28px rgba(20, 16, 13, 0.16);
  --slice-shade: linear-gradient(270deg, transparent, rgba(0, 0, 0, 0.34));
  transform-origin: right center;
  animation: curlPrev 1500ms cubic-bezier(0.18, 0.72, 0.16, 1) both;
}

.flip-prev .sheet-face {
  border-radius: 0;
}

.flip-prev .edge-start .sheet-face {
  border-left: 1px solid var(--line);
  border-radius: 10px 0 0 10px;
}

.flip-prev .page-content::after {
  right: 0;
  background: linear-gradient(270deg, rgba(38, 27, 19, 0.28), transparent);
}

.flip-prev .page-content::before {
  left: -1px;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.55), #d7c7ac 42%, rgba(89, 63, 42, 0.3));
  transform: translateZ(3px);
}

.flip-next .flip-slice::before,
.flip-prev .flip-slice::before {
  animation: pageGloss 1500ms ease both;
}

.flip-next .flip-slice::after,
.flip-prev .flip-slice::after {
  animation: pageShadow 1500ms ease both;
}

.page-content {
  position: relative;
  height: 100%;
  padding: clamp(28px, 4.7vw, 72px);
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.eyebrow {
  position: relative;
  z-index: 4;
  min-height: 24px;
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  font-size: clamp(14px, 1.5vw, 19px);
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  position: relative;
  z-index: 4;
  max-width: 14ch;
  min-height: 52px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(26px, 3.4vw, 54px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.62);
}

h2 {
  font-size: clamp(24px, 3vw, 48px);
}

.body-copy {
  position: relative;
  z-index: 4;
  align-self: end;
  max-width: 32ch;
  min-height: 0;
  margin: 0 0 clamp(18px, 2.4vw, 32px);
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(12px, 1.15vw, 16px);
  line-height: 1.55;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.72);
  white-space: pre-wrap;
}

.page-links {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 10px;
  align-self: end;
  width: min(100%, 320px);
  margin-bottom: clamp(18px, 2.4vw, 32px);
}

.page-links button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  padding: 0 14px;
  font-weight: 700;
  text-align: left;
  backdrop-filter: blur(10px);
}

.page-links button::after {
  content: ">";
  opacity: 0.74;
}

.page-links button:hover {
  background: rgba(255, 255, 255, 0.16);
}

[contenteditable="true"] {
  outline: 0;
}

[contenteditable="true"]:focus {
  border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(200, 80, 80, 0.2);
}

.character-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.character {
  position: absolute;
  left: 48%;
  top: 38%;
  width: 150px;
  max-width: 48%;
  transform: translate(-50%, -50%);
  transform-origin: center bottom;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  filter: drop-shadow(0 18px 16px rgba(34, 25, 18, 0.24));
}

.character.page-video,
.character.page-media {
  max-width: none;
  filter: none;
  transform: none;
  pointer-events: none;
}

.character img,
.character video {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
}

.character video {
  border-radius: 6px;
  height: 100%;
  object-fit: cover;
}

.character.page-video video,
.character.page-media img,
.character.page-media video {
  border-radius: 0;
  pointer-events: none;
  height: 100%;
  object-fit: cover;
}

.mini-media-control {
  margin: 0;
}

.character.selected {
  outline: 2px solid rgba(200, 80, 80, 0.78);
  outline-offset: 5px;
  border-radius: 8px;
}

.motion-walk img,
.motion-walk video {
  animation: walk 1.8s ease-in-out infinite;
}

.motion-float img,
.motion-float video {
  animation: float 2.6s ease-in-out infinite;
}

.motion-pulse img,
.motion-pulse video {
  animation: pulse 2.2s ease-in-out infinite;
}

.motion-still img,
.motion-still video {
  animation: none;
}

.editor-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 24;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(330px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 18px;
  border: 1px solid rgba(32, 33, 36, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 22px 54px rgba(39, 32, 25, 0.18);
  backdrop-filter: blur(12px);
  transform: translateX(105%);
  transition: transform 240ms ease;
  overflow: auto;
}

.editor-panel.open {
  transform: translateX(0);
}

.mini-editor {
  display: grid;
  gap: 10px;
}

.mini-toolbar,
.mini-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-toolbar {
  justify-content: center;
}

.mini-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mini-nav {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.14);
  border-radius: 999px;
  background: #ffffff;
  font-size: 22px;
  line-height: 1;
}

.mini-page-meter {
  min-width: 68px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mini-book {
  display: grid;
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 18 / 16;
  border-radius: 8px;
  overflow: hidden;
  background: #1b1a17;
  box-shadow: 0 14px 28px rgba(31, 27, 24, 0.2);
}

.mini-page {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.92);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.52), transparent 70%),
    #161512;
  text-align: left;
  overflow: hidden;
}

.mini-page.cover-page,
.mini-page.back-cover-page {
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(145deg, #11100f, #3a322a 48%, #080807);
}

.mini-page.glass-page {
  background:
    linear-gradient(116deg, rgba(255, 255, 255, 0.52), transparent 34%, rgba(255, 255, 255, 0.42) 52%, transparent 100%),
    repeating-linear-gradient(82deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 16px),
    linear-gradient(135deg, rgba(238, 244, 241, 0.54), rgba(182, 195, 193, 0.24));
}

.mini-page.glass-page .mini-kicker,
.mini-page.glass-page strong,
.mini-page.glass-page .mini-copy {
  display: none;
}

.mini-page.active {
  outline: 2px solid #d46767;
  outline-offset: -3px;
}

.mini-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.78;
  pointer-events: auto;
}

.mini-video img,
.mini-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-kicker,
.mini-page strong,
.mini-copy {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.72);
  cursor: text;
}

.mini-kicker {
  font-size: 10px;
  font-weight: 800;
}

.mini-page strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1;
}

.mini-copy {
  align-self: end;
  font-size: 10px;
  line-height: 1.35;
}

.tool-button.confirm {
  color: #ffffff;
  background: var(--ink);
}

.panel-section {
  display: none;
  gap: 12px;
  padding-bottom: 17px;
  border-bottom: 1px solid rgba(32, 33, 36, 0.12);
}

.section-title {
  font-size: 17px;
  font-weight: 850;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid rgba(32, 33, 36, 0.14);
  border-radius: 10px;
  background: #f3f1ec;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.segment.active {
  color: #ffffff;
  background: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(32, 33, 36, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  outline: 0;
}

.field input,
.field select {
  height: 42px;
  padding: 0 11px;
}

.field textarea {
  resize: vertical;
  min-height: 110px;
  padding: 10px 11px;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(200, 80, 80, 0.64);
  box-shadow: 0 0 0 3px rgba(200, 80, 80, 0.14);
}

.compact {
  grid-template-columns: 58px 1fr;
  align-items: center;
}

.switch-field {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
}

.switch-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

.upload-button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: 100%;
  border: 1px solid rgba(32, 33, 36, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
}

.upload-button input {
  display: none;
}

.tool-button {
  background: #f9f7f2;
}

.tool-button.danger {
  color: #a23636;
}

@keyframes smoothTurnNext {
  0% {
    transform: rotateY(0deg) rotateX(0deg) translateZ(10px) translateX(0) skewY(0deg);
  }
  16% {
    transform: rotateY(-28deg) rotateX(0.7deg) translateZ(34px) translateX(-4px) skewY(-0.12deg);
  }
  48% {
    transform: rotateY(-104deg) rotateX(2.2deg) translateZ(72px) translateX(-22px) skewY(-0.55deg);
  }
  76% {
    transform: rotateY(-156deg) rotateX(0.8deg) translateZ(32px) translateX(-8px) skewY(-0.18deg);
  }
  100% {
    transform: rotateY(-180deg) rotateX(0deg) translateZ(8px) translateX(0) skewY(0deg);
  }
}

@keyframes smoothTurnPrev {
  0% {
    transform: rotateY(0deg) rotateX(0deg) translateZ(10px) translateX(0) skewY(0deg);
  }
  16% {
    transform: rotateY(28deg) rotateX(0.7deg) translateZ(34px) translateX(4px) skewY(0.12deg);
  }
  48% {
    transform: rotateY(104deg) rotateX(2.2deg) translateZ(72px) translateX(22px) skewY(0.55deg);
  }
  76% {
    transform: rotateY(156deg) rotateX(0.8deg) translateZ(32px) translateX(8px) skewY(0.18deg);
  }
  100% {
    transform: rotateY(180deg) rotateX(0deg) translateZ(8px) translateX(0) skewY(0deg);
  }
}

@keyframes frontCoverOpenSmooth {
  0% {
    transform: scaleX(var(--cover-start-scale)) rotateY(0deg) rotateX(0deg) translateZ(26px);
  }
  36% {
    transform: scaleX(var(--cover-mid-scale)) rotateY(-78deg) rotateX(1.6deg) translateZ(58px) translateX(-10px);
  }
  72% {
    transform: scaleX(var(--cover-end-scale)) rotateY(-144deg) rotateX(0.7deg) translateZ(24px) translateX(-5px);
  }
  100% {
    transform: scaleX(var(--cover-end-scale)) rotateY(-180deg) rotateX(0deg) translateZ(8px);
  }
}

@keyframes frontCoverCloseSmooth {
  0% {
    transform: scaleX(var(--cover-start-scale)) rotateY(-180deg) rotateX(0deg) translateZ(8px);
  }
  28% {
    transform: scaleX(var(--cover-start-scale)) rotateY(-132deg) rotateX(0.8deg) translateZ(28px) translateX(-7px);
  }
  66% {
    transform: scaleX(var(--cover-mid-scale)) rotateY(-48deg) rotateX(1.4deg) translateZ(54px) translateX(-10px);
  }
  100% {
    transform: scaleX(var(--cover-end-scale)) rotateY(0deg) rotateX(0deg) translateZ(26px);
  }
}

@keyframes backCoverCloseSmooth {
  0% {
    transform: scaleX(var(--cover-start-scale)) rotateY(0deg) rotateX(0deg) translateZ(26px);
  }
  36% {
    transform: scaleX(var(--cover-mid-scale)) rotateY(78deg) rotateX(1.6deg) translateZ(58px) translateX(10px);
  }
  72% {
    transform: scaleX(var(--cover-end-scale)) rotateY(144deg) rotateX(0.7deg) translateZ(24px) translateX(5px);
  }
  100% {
    transform: scaleX(var(--cover-end-scale)) rotateY(180deg) rotateX(0deg) translateZ(8px);
  }
}

@keyframes backCoverOpenSmooth {
  0% {
    transform: scaleX(var(--cover-start-scale)) rotateY(180deg) rotateX(0deg) translateZ(8px);
  }
  28% {
    transform: scaleX(var(--cover-start-scale)) rotateY(132deg) rotateX(0.8deg) translateZ(28px) translateX(7px);
  }
  66% {
    transform: scaleX(var(--cover-mid-scale)) rotateY(48deg) rotateX(1.4deg) translateZ(54px) translateX(10px);
  }
  100% {
    transform: scaleX(var(--cover-end-scale)) rotateY(0deg) rotateX(0deg) translateZ(26px);
  }
}

@keyframes turnGloss {
  0%,
  100% {
    opacity: 0;
    transform: translateX(-48%);
  }
  24% {
    opacity: 0.36;
    transform: translateX(-12%);
  }
  52% {
    opacity: 0.68;
    transform: translateX(32%);
  }
  76% {
    opacity: 0.24;
    transform: translateX(58%);
  }
}

@keyframes turnShade {
  0%,
  100% {
    opacity: 0.08;
  }
  32% {
    opacity: 0.2;
  }
  52% {
    opacity: 0.46;
  }
  78% {
    opacity: 0.22;
  }
}

@keyframes curlNext {
  0% {
    transform: rotateY(0deg) rotateX(0deg) translateZ(3px) translateX(0) skewY(0deg);
  }
  18% {
    transform: rotateY(var(--open-angle)) rotateX(var(--lift-x)) translateZ(var(--open-z)) translateX(var(--open-x)) skewY(-0.35deg);
  }
  48% {
    transform: rotateY(var(--mid-angle)) rotateX(var(--mid-x)) translateZ(var(--mid-z)) translateX(var(--mid-shift)) skewY(var(--curl-skew));
  }
  72% {
    transform: rotateY(var(--close-angle)) rotateX(var(--close-x)) translateZ(var(--close-z)) translateX(var(--close-shift)) skewY(-0.55deg);
  }
  100% {
    transform: rotateY(-180deg) rotateX(0deg) translateZ(3px) translateX(0) skewY(0deg);
  }
}

@keyframes curlPrev {
  0% {
    transform: rotateY(0deg) rotateX(0deg) translateZ(3px) translateX(0) skewY(0deg);
  }
  18% {
    transform: rotateY(var(--open-angle)) rotateX(var(--lift-x)) translateZ(var(--open-z)) translateX(var(--open-x)) skewY(0.35deg);
  }
  48% {
    transform: rotateY(var(--mid-angle)) rotateX(var(--mid-x)) translateZ(var(--mid-z)) translateX(var(--mid-shift)) skewY(var(--curl-skew));
  }
  72% {
    transform: rotateY(var(--close-angle)) rotateX(var(--close-x)) translateZ(var(--close-z)) translateX(var(--close-shift)) skewY(0.55deg);
  }
  100% {
    transform: rotateY(180deg) rotateX(0deg) translateZ(3px) translateX(0) skewY(0deg);
  }
}

@keyframes pageGloss {
  0%,
  100% {
    opacity: 0;
    transform: translateX(-36%);
  }
  28% {
    opacity: 0.56;
    transform: translateX(-8%);
  }
  52% {
    opacity: 1;
    transform: translateX(28%);
  }
  74% {
    opacity: 0.36;
    transform: translateX(54%);
  }
}

@keyframes pageShadow {
  0%,
  100% {
    opacity: 0.1;
  }
  30% {
    opacity: 0.22;
  }
  52% {
    opacity: 0.48;
  }
  72% {
    opacity: 0.34;
  }
}

@keyframes coverOpen {
  0% {
    transform: rotateY(0deg) translateZ(28px);
    filter: brightness(1);
  }
  36% {
    transform: rotateY(-76deg) translateZ(46px) rotateX(1.5deg);
    filter: brightness(0.96);
  }
  68% {
    transform: rotateY(-132deg) translateZ(26px) rotateX(0.6deg);
    filter: brightness(0.78);
  }
  100% {
    transform: rotateY(-178deg) translateZ(8px);
    filter: brightness(0.58);
  }
}

@keyframes coverClose {
  0% {
    transform: rotateY(-178deg) translateZ(8px);
    filter: brightness(0.58);
  }
  36% {
    transform: rotateY(-112deg) translateZ(36px) rotateX(1deg);
    filter: brightness(0.78);
  }
  72% {
    transform: rotateY(-38deg) translateZ(42px) rotateX(0.8deg);
    filter: brightness(0.96);
  }
  100% {
    transform: rotateY(0deg) translateZ(28px);
    filter: brightness(1);
  }
}

@keyframes backCoverClose {
  0% {
    transform: rotateY(0deg) translateZ(28px);
    filter: brightness(1);
  }
  36% {
    transform: rotateY(76deg) translateZ(46px) rotateX(1.5deg);
    filter: brightness(0.96);
  }
  68% {
    transform: rotateY(132deg) translateZ(26px) rotateX(0.6deg);
    filter: brightness(0.78);
  }
  100% {
    transform: rotateY(178deg) translateZ(8px);
    filter: brightness(0.58);
  }
}

@keyframes backCoverOpen {
  0% {
    transform: rotateY(178deg) translateZ(8px);
    filter: brightness(0.58);
  }
  36% {
    transform: rotateY(112deg) translateZ(36px) rotateX(1deg);
    filter: brightness(0.78);
  }
  72% {
    transform: rotateY(38deg) translateZ(42px) rotateX(0.8deg);
    filter: brightness(0.96);
  }
  100% {
    transform: rotateY(0deg) translateZ(28px);
    filter: brightness(1);
  }
}

@keyframes walk {
  0%,
  100% {
    transform: translateX(-4px) rotate(-1deg);
  }
  50% {
    transform: translateX(7px) rotate(1deg);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.045);
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 64vh;
    padding: 14px 14px 20px;
  }

  .book {
    width: min(96vw, 760px);
    max-height: none;
  }

  .editor-panel {
    min-height: 100vh;
    border-top: 0;
  }
}

@media (max-width: 620px) {
  .editor-panel {
    top: 8px;
    right: 8px;
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    padding: 14px;
  }

  .mini-page {
    padding: 10px;
  }

  .mini-page strong {
    font-size: 16px;
  }

  .mini-copy,
  .mini-kicker {
    font-size: 9px;
  }

  .book {
    grid-template-columns: 1fr;
    width: min(92vw, 430px);
    aspect-ratio: 9 / 16;
  }

  .page-left {
    display: none;
  }

  .page-right {
    border-left: 1px solid var(--line);
    border-radius: 10px;
  }

  .book.glass-back-spread .page-left {
    display: block;
    border-radius: 10px;
  }

  .book.glass-back-spread .page-right {
    display: none;
  }

  .book::after {
    display: none;
  }

  .page-content {
    padding: 28px;
  }

  h1,
  h2 {
    max-width: 9ch;
    font-size: clamp(32px, 12vw, 48px);
  }
}

@media (max-width: 620px) {
  .turn-underlay {
    grid-template-columns: 1fr;
  }

  .book .turn-underlay .page-left {
    display: none;
  }

  .book .turn-underlay .page-right,
  .book .turn-sheet .page-left,
  .book .turn-sheet .page-right,
  .book .cover-turn-sheet .page-left,
  .book .cover-turn-sheet .page-right {
    display: block;
  }

  .turn-sheet.single-page-turn {
    left: 0;
    width: 100%;
  }

  .turn-sheet.single-page-turn.turn-next {
    transform-origin: left center;
  }

  .turn-sheet.single-page-turn.turn-prev {
    transform-origin: right center;
  }
}

/* Seam-locked gesture flipping */
.turn-sheet.gesture-turn-sheet,
.cover-turn-sheet.gesture-turn-sheet {
  transform-box: border-box;
  backface-visibility: hidden;
}

.turn-sheet.gesture-turn-sheet.turn-next {
  transform-origin: 0 50%;
}

.turn-sheet.gesture-turn-sheet.turn-prev {
  transform-origin: 100% 50%;
}

.turn-sheet.gesture-turn-sheet.single-page-turn {
  left: 0;
  width: 100%;
}

.turn-page-clone,
.turn-page-clone .page-content,
.turn-page-clone .character-layer {
  transform: translateZ(0);
}

.turn-page-clone .character-layer {
  inset: 0;
  overflow: hidden;
  contain: layout paint style;
  backface-visibility: hidden;
}

.turn-page-clone .character.page-video,
.turn-page-clone .character.page-media {
  left: var(--media-left);
  top: var(--media-top);
  width: var(--media-width);
  height: var(--media-height);
  max-width: none;
  overflow: hidden;
  transform: translateZ(0);
  filter: none;
  backface-visibility: hidden;
  pointer-events: none;
}

.turn-page-clone .character.page-video video,
.turn-page-clone .character.page-media img,
.turn-page-clone .character.page-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Natural pointer-driven flip v2 */
.turn-sheet.gesture-turn-sheet {
  overflow: visible;
  transform-box: border-box;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.turn-sheet.gesture-turn-sheet.turn-next {
  transform-origin: 0 50%;
}

.turn-sheet.gesture-turn-sheet.turn-prev {
  transform-origin: 100% 50%;
}

.gesture-turn-sheet .turn-face {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

.gesture-turn-sheet .turn-front {
  transform: rotateY(0deg) translateZ(0.2px);
}

.gesture-turn-sheet .turn-back {
  transform: rotateY(180deg) translateZ(0.2px);
}

.gesture-turn-sheet .turn-face .page {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.gesture-turn-sheet .turn-face::before {
  mix-blend-mode: screen;
}

.gesture-turn-sheet .turn-face::after {
  mix-blend-mode: multiply;
}

.turn-page-clone .character,
.turn-page-clone .character img,
.turn-page-clone .character video {
  animation: none !important;
}

.turn-page-clone .character.page-video,
.turn-page-clone .character.page-media {
  clip-path: inset(0);
  contain: layout paint style;
}

.turn-page-clone .character.page-video video,
.turn-page-clone .character.page-media img,
.turn-page-clone .character.page-media video {
  object-position: center center;
  transform: translate3d(0, 0, 0);
}

/* Explicit front/back face swap */
.turn-sheet.gesture-turn-sheet,
.cover-turn-sheet.gesture-turn-sheet {
  backface-visibility: visible !important;
  -webkit-backface-visibility: visible !important;
  contain: layout style;
}

.gesture-turn-sheet .turn-face,
.gesture-turn-sheet .turn-face .page {
  backface-visibility: visible !important;
  -webkit-backface-visibility: visible !important;
}

.gesture-turn-sheet .turn-front {
  z-index: var(--turn-front-z, 2);
  opacity: var(--turn-front-opacity, 1);
  visibility: visible;
}

.gesture-turn-sheet .turn-back {
  z-index: var(--turn-back-z, 1);
  opacity: var(--turn-back-opacity, 0);
  visibility: hidden;
}

.gesture-turn-sheet.show-turn-back .turn-front {
  visibility: hidden;
}

.gesture-turn-sheet.show-turn-back .turn-back {
  visibility: visible;
}

.gesture-turn-sheet.show-turn-front .turn-back {
  visibility: hidden;
}

/* Apple-style centered book with side rails */
.stage {
  --rail-width: clamp(52px, 5.2vw, 74px);
  --rail-edge-left: max(10px, env(safe-area-inset-left));
  --rail-edge-right: max(10px, env(safe-area-inset-right));
  grid-template-rows: 1fr;
  min-height: 100dvh;
  padding: 0;
  overflow: hidden;
}

.book-wrap {
  grid-row: 1;
  width: 100%;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top))
    calc(var(--rail-width) + 24px)
    max(8px, env(safe-area-inset-bottom));
}

.book {
  width: min(
    calc(100vw - (var(--rail-width) * 2) - 64px),
    calc((100dvh - 22px) * 18 / 16),
    1160px
  );
  max-height: calc(100dvh - 22px);
}

.side-rail,
.book-toolbar {
  position: fixed;
  top: 50%;
  z-index: 32;
  width: var(--rail-width);
  padding: 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  background: rgba(245, 249, 250, 0.36);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    0 18px 38px rgba(32, 40, 42, 0.16);
  backdrop-filter: blur(18px) saturate(1.18);
  -webkit-backdrop-filter: blur(18px) saturate(1.18);
}

.status-rail {
  left: var(--rail-edge-left);
  min-height: min(76dvh, 430px);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(38, 45, 48, 0.82);
}

.rail-brand {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.rail-meta {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

.rail-meta span {
  font-size: 9px;
  font-weight: 800;
  color: rgba(84, 94, 102, 0.72);
}

.rail-meta strong {
  writing-mode: vertical-rl;
  max-height: 92px;
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.rail-progress {
  position: relative;
  width: 3px;
  flex: 1;
  min-height: 78px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(32, 40, 42, 0.13);
}

.rail-progress span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(80, 92, 98, 0.5));
}

.rail-page {
  display: grid;
  justify-items: center;
  gap: 1px;
  font-size: 10px;
  font-weight: 800;
  color: rgba(45, 54, 58, 0.76);
}

.rail-menu-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.1);
  border-radius: 50%;
  color: rgba(32, 36, 40, 0.8);
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 8px 18px rgba(36, 32, 28, 0.11);
}

.book-toolbar {
  right: var(--rail-edge-right);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.settings-button {
  top: max(10px, env(safe-area-inset-top));
  right: calc(var(--rail-edge-right) + 8px);
  width: 42px;
  height: 42px;
  z-index: 33;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 30px;
}

.quick-button {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.page-meter {
  width: 44px;
  min-width: 44px;
  height: 36px;
  padding: 0;
  font-size: 12px;
}

@media (orientation: landscape) and (max-height: 540px) {
  .stage {
    --rail-width: 54px;
  }

  .book {
    width: min(
      calc(100vw - (var(--rail-width) * 2) - 54px),
      calc((100dvh - 16px) * 18 / 16),
      1080px
    );
    max-height: calc(100dvh - 16px);
  }

  .side-rail,
  .book-toolbar {
    padding: 6px 5px;
  }

  .status-rail {
    gap: 8px;
    min-height: min(78dvh, 330px);
  }

  .rail-meta strong {
    max-height: 64px;
    font-size: 10px;
  }

  .rail-progress {
    min-height: 54px;
  }

  .settings-button {
    width: 34px;
    height: 34px;
    right: calc(var(--rail-edge-right) + 10px);
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 23px;
  }

  .quick-button {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .page-meter {
    width: 38px;
    min-width: 38px;
    height: 30px;
    font-size: 11px;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .status-rail {
    display: none;
  }

  .book-toolbar {
    left: 50%;
    right: auto;
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    transform: translateX(-50%);
    flex-direction: row;
    border-radius: 999px;
  }

  .settings-button {
    right: max(10px, env(safe-area-inset-right));
  }

  .book-wrap {
    padding: 66px 12px 76px;
  }

  .book {
    width: min(92vw, 430px);
    max-height: calc(100dvh - 150px);
  }
}

/* Final visual balance: centered book + dot-style left rail */
.book-wrap {
  align-items: center;
  justify-items: center;
  padding-top: max(34px, env(safe-area-inset-top));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.book {
  transform: translateY(26px) rotateX(4deg);
}

.book.is-turning,
.book.gesture-turning {
  transform: translateY(26px) rotateX(4deg);
}

.status-rail {
  width: 56px;
  min-height: 300px;
  left: max(12px, env(safe-area-inset-left));
  padding: 10px 7px;
  gap: 16px;
  border-radius: 999px;
  background: rgba(245, 249, 250, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18),
    0 20px 42px rgba(25, 32, 34, 0.13);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

.rail-brand {
  writing-mode: horizontal-tb;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
  color: rgba(43, 50, 54, 0.72);
}

.rail-meta {
  display: none;
}

.rail-page.compact {
  display: grid;
  justify-items: center;
  gap: 0;
  font-size: 10px;
  line-height: 1.12;
  font-weight: 800;
  color: rgba(54, 64, 70, 0.7);
}

.rail-dots {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  width: auto;
  flex: 1;
  min-height: 104px;
  background: transparent;
}

.rail-dots span {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(45, 55, 60, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition:
    width 220ms ease,
    height 220ms ease,
    background 220ms ease,
    transform 220ms ease;
}

.rail-dots span.active {
  background: rgba(72, 86, 94, 0.38);
}

.rail-dots span.current {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 1px rgba(62, 72, 78, 0.12),
    0 4px 12px rgba(25, 32, 34, 0.18);
}

.rail-menu-button {
  width: 34px;
  height: 34px;
  font-size: 17px;
  color: rgba(45, 54, 60, 0.72);
  background: rgba(255, 255, 255, 0.58);
}

@media (orientation: landscape) and (max-height: 540px) {
  .book {
    transform: translateY(22px) rotateX(4deg);
  }

  .book.is-turning,
  .book.gesture-turning {
    transform: translateY(22px) rotateX(4deg);
  }

  .status-rail {
    width: 50px;
    min-height: 270px;
    gap: 12px;
  }

  .rail-dots {
    gap: 7px;
    min-height: 82px;
  }
}

/* Effect mockup polish: balanced book and iOS-style dot rail */
.book-wrap {
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.book {
  width: min(
    calc(100vw - (var(--rail-width) * 2) - 92px),
    calc((100dvh - 76px) * 18 / 16),
    1100px
  );
  max-height: calc(100dvh - 76px);
  transform: translateY(8px) rotateX(4deg);
}

.book.is-turning,
.book.gesture-turning {
  transform: translateY(8px) rotateX(4deg);
}

.status-rail {
  width: 58px;
  min-height: 244px;
  max-height: 62dvh;
  left: max(18px, env(safe-area-inset-left));
  gap: 12px;
  justify-content: space-between;
  padding: 11px 8px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(226, 235, 235, 0.18)),
    rgba(238, 246, 246, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.54);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    inset 0 -1px 0 rgba(255, 255, 255, 0.2),
    0 18px 34px rgba(24, 31, 34, 0.13);
}

.status-rail::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.rail-brand {
  display: grid;
  width: 42px;
  height: 24px;
  place-items: center;
  writing-mode: horizontal-tb;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  color: rgba(38, 47, 52, 0.64);
}

.rail-page.compact {
  display: flex;
  width: 40px;
  height: 42px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.24);
  color: rgba(45, 54, 60, 0.68);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    0 8px 20px rgba(30, 38, 42, 0.06);
}

.rail-page.compact span:nth-child(1) {
  font-size: 13px;
  line-height: 1;
}

.rail-page.compact span:nth-child(2) {
  display: none;
}

.rail-page.compact span:nth-child(3) {
  font-size: 10px;
  line-height: 1;
  opacity: 0.62;
}

.rail-page.compact span:nth-child(3)::before {
  content: "/";
  margin-right: 1px;
}

.rail-dots {
  flex: 0 0 auto;
  display: grid;
  min-height: 86px;
  width: 40px;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 6px 0;
  background: transparent;
}

.rail-dots span {
  position: static;
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(54, 65, 72, 0.22);
  box-shadow: none;
}

.rail-dots span.active {
  background: rgba(54, 65, 72, 0.34);
}

.rail-dots span.current {
  width: 16px;
  height: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 1px rgba(60, 72, 78, 0.08),
    0 4px 12px rgba(18, 28, 32, 0.18);
}

.rail-menu-button {
  width: 38px;
  height: 38px;
  font-size: 18px;
  color: rgba(42, 52, 58, 0.7);
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    0 8px 20px rgba(30, 38, 42, 0.11);
}

@media (orientation: landscape) and (max-height: 540px) {
  .book-wrap {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .book {
    width: min(
      calc(100vw - (var(--rail-width) * 2) - 94px),
      calc((100dvh - 68px) * 18 / 16),
      1080px
    );
    max-height: calc(100dvh - 68px);
    transform: translateY(6px) rotateX(4deg);
  }

  .book.is-turning,
  .book.gesture-turning {
    transform: translateY(6px) rotateX(4deg);
  }

  .status-rail {
    width: 54px;
    min-height: 224px;
    gap: 9px;
    padding: 9px 7px;
  }

  .rail-brand {
    width: 38px;
    height: 22px;
    font-size: 9px;
  }

  .rail-page.compact {
    width: 36px;
    height: 38px;
  }

  .rail-dots {
    width: 36px;
    min-height: 72px;
    gap: 6px;
  }

  .rail-menu-button {
    width: 34px;
    height: 34px;
  }
}

/* Store-ready customer ordering layer */
.settings-button {
  opacity: 0.72;
}

.cart-rail-button {
  display: grid;
  width: 42px;
  min-height: 48px;
  place-items: center;
  gap: 3px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  color: rgba(41, 49, 56, 0.78);
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 10px 22px rgba(30, 38, 42, 0.12);
}

.cart-rail-button span {
  font-size: 10px;
  font-weight: 800;
}

.cart-rail-button strong {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.96);
  background: rgba(30, 36, 40, 0.76);
  font-size: 12px;
}

.cart-rail-button.has-items {
  color: rgba(18, 28, 34, 0.88);
  background: rgba(255, 255, 255, 0.78);
}

.page-links {
  gap: 9px;
}

.page-links button.product-link {
  min-height: 48px;
  border-radius: 10px;
  border-color: rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06)),
    rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 12px 24px rgba(0, 0, 0, 0.12);
  font-size: clamp(11px, 1vw, 14px);
}

.page-links button.product-link::after {
  content: "+";
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.order-drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(16, 20, 22, 0);
  pointer-events: none;
  transition: background 220ms ease;
}

.order-drawer.open {
  background: rgba(16, 20, 22, 0.22);
  pointer-events: auto;
}

.order-card {
  display: grid;
  gap: 14px;
  width: min(360px, calc(100vw - 28px));
  max-height: min(620px, calc(100dvh - 28px));
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(234, 241, 241, 0.7)),
    rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 26px 70px rgba(18, 22, 24, 0.28);
  backdrop-filter: blur(24px) saturate(1.18);
  -webkit-backdrop-filter: blur(24px) saturate(1.18);
  transform: translateX(calc(100% + 24px));
  transition: transform 260ms cubic-bezier(0.2, 0.72, 0.16, 1);
}

.order-drawer.open .order-card {
  transform: translateX(0);
}

.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-head span {
  display: block;
  color: rgba(78, 88, 94, 0.74);
  font-size: 11px;
  font-weight: 800;
}

.order-head strong {
  display: block;
  color: rgba(26, 32, 36, 0.9);
  font-size: 24px;
  line-height: 1.1;
}

.order-close {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 50%;
  color: rgba(35, 42, 46, 0.7);
  background: rgba(255, 255, 255, 0.72);
  font-size: 26px;
  line-height: 1;
}

.order-list {
  display: grid;
  gap: 10px;
}

.empty-order {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  color: rgba(52, 62, 68, 0.7);
  background: rgba(255, 255, 255, 0.44);
  font-size: 14px;
  line-height: 1.45;
}

.cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
}

.cart-row span {
  display: block;
  color: rgba(84, 94, 100, 0.72);
  font-size: 11px;
  font-weight: 800;
}

.cart-row strong {
  display: block;
  color: rgba(24, 30, 34, 0.9);
  font-size: 16px;
}

.cart-row small {
  color: rgba(54, 64, 70, 0.7);
  font-size: 12px;
  font-weight: 700;
}

.cart-stepper {
  display: grid;
  grid-template-columns: 30px 24px 30px;
  align-items: center;
  justify-items: center;
  gap: 4px;
}

.cart-stepper button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 50%;
  color: rgba(22, 28, 32, 0.78);
  background: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  font-weight: 800;
}

.cart-stepper b {
  color: rgba(24, 30, 34, 0.86);
  font-size: 14px;
}

.table-field {
  display: grid;
  gap: 6px;
}

.table-field span {
  color: rgba(70, 80, 86, 0.7);
  font-size: 12px;
  font-weight: 800;
}

.table-field input {
  height: 44px;
  border: 1px solid rgba(32, 33, 36, 0.1);
  border-radius: 14px;
  padding: 0 14px;
  color: rgba(24, 30, 34, 0.88);
  background: rgba(255, 255, 255, 0.68);
  font-size: 18px;
  font-weight: 800;
}

.order-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 4px;
  color: rgba(34, 42, 46, 0.82);
}

.order-total span {
  font-size: 14px;
  font-weight: 800;
}

.order-total strong {
  font-size: 28px;
}

.checkout-button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #22282c, #111416);
  box-shadow: 0 16px 30px rgba(17, 20, 22, 0.22);
  font-weight: 800;
}

.checkout-button:disabled {
  cursor: default;
  opacity: 0.46;
}

.order-note {
  margin: 0;
  color: rgba(56, 66, 72, 0.72);
  font-size: 12px;
  line-height: 1.45;
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 90;
  max-width: min(380px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  color: rgba(22, 28, 32, 0.84);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 40px rgba(20, 26, 28, 0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.status-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (orientation: landscape) and (max-height: 540px) {
  .cart-rail-button {
    width: 34px;
    min-height: 40px;
  }

  .cart-rail-button span {
    font-size: 9px;
  }

  .cart-rail-button strong {
    width: 19px;
    height: 19px;
    font-size: 10px;
  }

  .order-card {
    width: min(330px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 14px;
    border-radius: 20px;
  }
}

/* Mobile fit pass: keep the original desktop book, but give phones a true
   single-page canvas with controls that never compete for book space. */
@media (orientation: portrait) and (max-width: 760px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    min-height: 100dvh;
  }

  .app-shell,
  .stage {
    min-height: 100dvh;
  }

  .stage {
    --mobile-top: max(14px, env(safe-area-inset-top));
    --mobile-bottom: max(86px, calc(76px + env(safe-area-inset-bottom)));
    display: grid;
    place-items: center;
    padding: 0;
    overflow: hidden;
  }

  .status-rail {
    display: none;
  }

  .book-wrap {
    width: 100%;
    min-height: 100dvh;
    padding: var(--mobile-top) 10px var(--mobile-bottom);
    align-items: center;
    justify-items: center;
  }

  .book,
  .book.cover-opening-stage,
  .book.back-cover-opening-stage,
  .book.closed-front,
  .book.closed-back,
  .book.cover-closing-stage,
  .book.back-cover-closing-stage {
    grid-template-columns: 1fr;
    width: min(
      calc(100vw - 28px),
      calc((100dvh - var(--mobile-top) - var(--mobile-bottom) - 10px) * 9 / 16),
      430px
    );
    max-height: calc(100dvh - var(--mobile-top) - var(--mobile-bottom) - 10px);
    aspect-ratio: 9 / 16;
    border-radius: 18px 12px 12px 18px;
    transform: none;
  }

  .book.is-turning,
  .book.gesture-turning {
    transform: none;
  }

  .book::before {
    bottom: -12px;
    height: 24px;
  }

  .book::after {
    display: none;
  }

  .book .page-left {
    display: none;
  }

  .book .page-right,
  .book.closed-front .page-left,
  .book.closed-back .page-right,
  .book.glass-back-spread .page-left {
    display: block;
    border: 1px solid rgba(225, 220, 208, 0.78);
    border-radius: 18px 12px 12px 18px;
    transform: translateZ(0);
  }

  .book.glass-back-spread .page-right {
    display: none;
  }

  .page-content {
    padding: clamp(20px, 7.5vw, 30px);
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .page.cover-page h1,
  .page.cover-page h2,
  .page.back-cover-page h1,
  .page.back-cover-page h2,
  h1,
  h2 {
    max-width: 10ch;
    min-height: auto;
    overflow-wrap: anywhere;
    font-size: clamp(30px, 11vw, 46px);
    line-height: 0.98;
  }

  h2 {
    font-size: clamp(28px, 10vw, 42px);
  }

  .eyebrow {
    min-height: 0;
    margin-bottom: 8px;
    font-size: clamp(12px, 4vw, 16px);
  }

  .body-copy {
    max-width: 28ch;
    margin-bottom: clamp(12px, 5vw, 22px);
    overflow: hidden;
    font-size: clamp(11px, 3.45vw, 14px);
    line-height: 1.48;
  }

  .page-links {
    width: min(100%, 280px);
    gap: 7px;
    margin-bottom: clamp(10px, 4vw, 18px);
  }

  .page-links button,
  .page-links button.product-link {
    min-height: 40px;
    padding: 0 10px;
    gap: 8px;
    border-radius: 8px;
    font-size: 11px;
  }

  .page-links button.product-link::after {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
  }

  .character {
    max-width: 58%;
  }

  .book-toolbar {
    left: 50%;
    right: auto;
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(calc(100vw - 20px), 430px);
    min-height: 54px;
    padding: 7px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: clamp(5px, 1.8vw, 9px);
    border-radius: 999px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    font-size: 27px;
  }

  .quick-button {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 12px;
  }

  .page-meter {
    width: 48px;
    min-width: 48px;
    height: 34px;
    font-size: 12px;
  }

  .cart-rail-button {
    width: 48px;
    min-height: 38px;
    flex: 0 0 48px;
    border-radius: 16px;
  }

  .cart-rail-button span {
    font-size: 9px;
  }

  .cart-rail-button strong {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .settings-button {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: 40px;
    height: 40px;
  }

  .editor-panel {
    inset: 0;
    width: 100vw;
    max-height: none;
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    transform: translateX(100%);
  }

  .order-drawer {
    place-items: end center;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .order-card {
    width: min(100%, 430px);
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 16px;
    border-radius: 22px 22px 18px 18px;
    transform: translateY(calc(100% + 24px));
  }

  .order-drawer.open .order-card {
    transform: translateY(0);
  }

  .cart-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .cart-stepper {
    justify-content: start;
  }

  .status-toast {
    bottom: max(72px, calc(66px + env(safe-area-inset-bottom)));
  }
}

@media (orientation: portrait) and (max-width: 380px) {
  .stage {
    --mobile-bottom: max(80px, calc(70px + env(safe-area-inset-bottom)));
  }

  .book-toolbar {
    gap: 4px;
    padding: 6px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 24px;
  }

  .quick-button {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    font-size: 11px;
  }

  .page-meter {
    width: 42px;
    min-width: 42px;
    height: 30px;
    font-size: 11px;
  }

  .cart-rail-button {
    width: 42px;
    flex-basis: 42px;
  }

  .page-content {
    padding: 20px;
  }
}
