/* DreamBook Framework - 阅读器 + 作者工具面板 + 导出引擎 公共样式
 * 来源: 由 himalayan-fireworks v014 抽取参数化。
 * 本文件放在每本绘本的 assets/ 下, 字体路径相对于本文件。
 * 封面图由 dreambook.js 按 BOOK_META.cover 设置。 */
@font-face { font-family: "LXGW WenKai"; src: url("fonts/LXGWWenKai-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  --desk: #f4f5f3;
  --paper: #fffdf8;
  --paper-edge: #ebe6da;
  --ink: #2f332d;
  --muted: #777469;
  --green: #2d7d62;
  --blue: #3e6f91;
  --red: #b65744;
  --bar: rgba(255, 255, 255, .82);
  --shadow: 0 24px 72px rgba(34, 38, 34, .16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "LXGW WenKai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 14%, rgba(255,255,255,.75), transparent 30%),
    radial-gradient(circle at 82% 76%, rgba(196,205,202,.28), transparent 36%),
    linear-gradient(135deg, #fafaf8, var(--desk));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image:
    linear-gradient(90deg, rgba(96,105,101,.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(96,105,101,.04) 1px, transparent 1px);
  background-size: 16px 16px, 19px 19px;
  mix-blend-mode: multiply;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.splash {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  cursor: pointer;
  transition: opacity .45s ease;
}

.splash-cover {
  position: relative;
  width: min(500px, 78vw);
  aspect-ratio: 5 / 6.8;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: clamp(34px, 6vw, 64px) 28px 32px;
  text-align: center;
  /* 封面图由 dreambook.js 按 BOOK_META.cover 内联设置; 这里只留占位底色 */
  background: linear-gradient(rgba(0,0,0,.08), rgba(0,0,0,.28)), #d8cfbd;
  border-radius: 16px;
  box-shadow:
    0 24px 70px rgba(34,38,34,.22),
    0 0 0 1px rgba(255,255,255,.62) inset;
  transform: perspective(1900px) rotateY(-7deg) rotateX(1deg);
  transition: transform .9s ease;
  isolation: isolate;
}

.splash-cover:hover {
  transform: perspective(1900px) rotateY(0deg) rotateX(0deg);
}

.splash-cover::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 18px;
  border-radius: 0 16px 16px 0;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.18) 35%, rgba(0,0,0,.16)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.22) 0 1px, transparent 1px 7px);
}

.splash-cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 28px;
  border-radius: 16px 0 0 16px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.08) 54%, transparent);
  mix-blend-mode: multiply;
  opacity: .5;
}

.splash-title {
  max-width: 7em;
  margin: 0;
  color: #fff;
  font-size: clamp(38px, 8vw, 66px);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 2px 2px 10px rgba(0,0,0,.72);
}

.splash-author {
  margin-top: 18px;
  color: #fff;
  font-size: clamp(17px, 2.8vw, 24px);
  text-shadow: 1px 1px 8px rgba(0,0,0,.8);
}

.click-to-open {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  min-width: 190px;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0,0,0,.58);
  font-size: 16px;
  backdrop-filter: blur(3px);
}

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr;
}

.book-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 26px 26px 18px;
  perspective: 2400px;
}

.book-wrap::after {
  content: "";
  position: absolute;
  width: min(1120px, calc(100vw - 42px));
  height: 34px;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(44,48,44,.18), rgba(0,0,0,0) 70%);
  filter: blur(14px);
  z-index: 0;
}

/* 全端统一: 单页卡片 + 轮播 (桌面横版, 移动竖版) */
.book {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
  border: 1px solid rgba(76,83,78,.12);
  border-radius: 18px;
  touch-action: pan-y;
  user-select: none;
}

.page {
  position: relative;
  min-width: 0;
  min-height: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 22% 16%, rgba(180,156,105,.10) 0 1px, transparent 1.4px),
    radial-gradient(circle at 76% 82%, rgba(80,68,48,.08) 0 1px, transparent 1.5px),
    linear-gradient(100deg, rgba(255,255,255,.38), rgba(255,255,255,0) 35%, rgba(100,80,54,.05));
  background-size: 18px 18px, 23px 23px, 100% 100%;
  border: 1px solid rgba(60,52,38,.10);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.36),
    inset 0 0 18px rgba(116,93,57,.045);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background:
    repeating-linear-gradient(0deg, rgba(116,93,57,.08) 0 1px, transparent 1px 6px),
    linear-gradient(90deg, rgba(255,255,255,.46), transparent 34%, rgba(100,80,54,.08));
  mix-blend-mode: multiply;
  z-index: 2;
}

.spread .page {
  border-radius: 0;
}

.image-page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.image-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 13px rgba(253,251,241,.22);
  z-index: 3;
}

.text-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 5vw, 70px);
}

.text-page > * {
  position: relative;
  z-index: 4;
}

.text-page h1,
.text-page h2 {
  margin: 0;
  color: #262b25;
  letter-spacing: 0;
  font-weight: 700;
}

.text-page h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.18;
}

.text-page h1 + p {
  margin-top: 26px;
}

.text-page h2 {
  font-size: clamp(27px, 3.4vw, 43px);
  line-height: 1.22;
}

.text-page p {
  margin: 0;
  width: 100%;
  font-size: clamp(20px, 2.18vw, 30px);
  line-height: 1.9;
  text-align: justify;
}

.text-page p:first-of-type::first-letter {
  float: left;
  margin: .05em .08em 0 0;
  font-size: 2.55em;
  line-height: .78;
  color: var(--green);
  font-weight: 700;
}

.text-page .blue::first-letter {
  color: var(--blue);
}

.text-page .red::first-letter {
  color: var(--red);
}

.small-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: clamp(15px, 1.45vw, 18px);
  line-height: 1.8;
}

.page-mark {
  position: absolute;
  right: 32px;
  bottom: 24px;
  color: rgba(47,51,45,.48);
  font: 600 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .08em;
}

.spread {
  display: none;
}

.spread.active {
  display: grid;
  grid-template-rows: 3fr 1fr;
  width: 100%;
  height: 100%;
  transform: translateX(0);
  will-change: transform;
}

.book.dragging .spread.active,
.book.mobile-animating .spread.active {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform: translateX(var(--active-x, 0px));
  transition: none;
}

.spread.mobile-peer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: 3fr 1fr;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: translateX(var(--peer-x, 100%));
  will-change: transform;
}

.book.dragging .spread.mobile-peer,
.book.mobile-animating .spread.mobile-peer {
  transition: none;
}

.book.carousel-settle .spread.active,
.book.carousel-settle .spread.mobile-peer {
  transition: transform .28s cubic-bezier(.2,.72,.2,1);
}

.spread.active:not(:has(.image-page)),
.spread.mobile-peer:not(:has(.image-page)) {
  grid-template-rows: 1fr 1fr;
}

.credit-spread.active,
.credit-spread.mobile-peer {
  grid-template-rows: minmax(0, 1fr) minmax(0, .72fr);
  background:
    linear-gradient(180deg, rgba(255,255,255,.36), rgba(255,255,255,0)),
    var(--paper);
}

.spread.active .image-page,
.spread.mobile-peer .image-page {
  order: 1;
  display: block;
  min-height: 0;
  border-radius: 18px 18px 0 0;
}

.spread.active .text-page,
.spread.mobile-peer .text-page {
  order: 2;
  display: flex;
  justify-content: center;
  min-height: 0;
  height: 100%;
  border-radius: 0 0 18px 18px;
}

.credit-spread.active .text-page,
.credit-spread.mobile-peer .text-page {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.credit-spread.active .text-page:first-child,
.credit-spread.mobile-peer .text-page:first-child {
  border-radius: 18px 18px 0 0;
  border-bottom: 1px solid rgba(47,51,45,.10);
}

.credit-spread.active .text-page:last-child,
.credit-spread.mobile-peer .text-page:last-child {
  border-radius: 0 0 18px 18px;
}

.credit-spread .text-page p::first-letter {
  float: none;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  font-weight: inherit;
}

/* 桌面横版卡片: 16:12 卡片 => 3fr 图区正好 16:9, 插画完整显示 */
@media (min-width: 861px) {
  .book {
    aspect-ratio: 16 / 12;
    height: min(calc(100vh - 110px), calc((100vw - 190px) * .75), 860px);
    min-height: 420px;
  }

  .book-wrap::after {
    width: min(960px, 72vw);
  }

  .text-page {
    padding: clamp(14px, 2.2vh, 26px) clamp(28px, 4vw, 60px);
  }

  .text-page p {
    font-size: clamp(16px, 1.5vw, 21px);
    line-height: 1.75;
  }

  .small-note {
    margin-top: 10px;
    font-size: clamp(13px, 1.1vw, 16px);
  }

  .page-mark {
    right: 18px;
    bottom: 12px;
  }

  .credit-spread.active .text-page p {
    max-width: 17em;
    font-size: clamp(19px, 1.9vw, 25px);
    line-height: 1.85;
    text-align: center;
  }

  .credit-spread.active .text-page:last-child p {
    max-width: 12em;
    color: #2f463c;
    font-size: clamp(21px, 2.2vw, 29px);
    line-height: 1.7;
  }
}

.splash-bar {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  left: calc(20px + env(safe-area-inset-left));
  z-index: 62;
  display: flex;
  align-items: center;
  gap: 8px;
}

.splash-tools {
  width: 32px;
  height: 32px;
  opacity: .82;
  font-size: 16px;
}

.splash-tools:hover {
  opacity: 1;
}

.splash-home {
  padding: 8px 14px;
  border: 1px solid rgba(47,51,45,.09);
  border-radius: 999px;
  color: rgba(47,51,45,.62);
  background: rgba(255,255,255,.55);
  box-shadow: 0 8px 24px rgba(34,38,34,.08);
  backdrop-filter: blur(14px);
  font: 680 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none;
  transition: opacity .2s ease, background .2s ease;
  opacity: .78;
}

.splash-home:hover {
  opacity: 1;
  background: rgba(255,255,255,.9);
}

.side-rail {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 57;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 7px;
  border: 1px solid rgba(47,51,45,.10);
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  box-shadow: 0 12px 34px rgba(34,38,34,.10);
  backdrop-filter: blur(16px);
}

.rail-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: rgba(47,51,45,.64);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  font: 700 17px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rail-btn:hover {
  background: rgba(47,51,45,.08);
  color: rgba(47,51,45,.92);
}

.rail-btn:disabled {
  opacity: .28;
  cursor: default;
  background: transparent;
}

.rail-sep {
  width: 16px;
  height: 1px;
  background: rgba(47,51,45,.14);
}

.rail-page {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 4px 0 2px;
  color: rgba(47,51,45,.55);
  font: 680 11px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rail-page i {
  width: 12px;
  height: 1px;
  background: rgba(47,51,45,.25);
}

.tool-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-home {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(47,51,45,.58);
  background: rgba(47,51,45,.06);
  text-decoration: none;
  font: 760 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tool-home:hover {
  background: rgba(47,51,45,.12);
}

/* 末页: 整卡封底 */
.ending-spread.active,
.ending-spread.mobile-peer {
  display: grid;
  grid-template-rows: 1fr !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.36), rgba(255,255,255,0)),
    var(--paper);
}

.ending-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 3.4vh, 34px);
  padding: clamp(24px, 4vw, 48px);
  text-align: center;
}

.ending-main {
  display: grid;
  justify-items: center;
  gap: clamp(12px, 2vh, 20px);
}

.ending-title {
  color: #2f463c;
  font-size: clamp(26px, 3.2vw, 42px);
  font-weight: 700;
  letter-spacing: .02em;
}

.ending-dedication {
  color: var(--ink);
  font-size: clamp(15px, 1.6vw, 21px);
  line-height: 1.9;
}

.ending-colophon {
  color: var(--muted);
  font-size: clamp(12px, 1.1vw, 15px);
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.ending-button {
  padding: 10px 20px;
  border: 1px solid rgba(47,51,45,.12);
  border-radius: 999px;
  color: rgba(47,51,45,.78);
  background: rgba(255,255,255,.6);
  cursor: pointer;
  text-decoration: none;
  font: 700 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ending-button:hover {
  background: #fff;
  color: rgba(47,51,45,.95);
}

.ending-related {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.ending-related-label {
  color: rgba(47,51,45,.42);
  font: 680 11px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .3em;
}

.ending-related-row {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 2vw, 20px);
}

.related-card {
  width: clamp(120px, 15vw, 176px);
  display: grid;
  gap: 7px;
  text-decoration: none;
}

.related-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(47,51,45,.10);
  box-shadow: 0 10px 26px rgba(34,38,34,.14);
}

.related-card span {
  color: rgba(47,51,45,.66);
  font-size: 12.5px;
  line-height: 1.4;
}

.related-card:hover img {
  box-shadow: 0 14px 32px rgba(34,38,34,.22);
}



.reader-tools {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(18px + env(safe-area-inset-right));
  z-index: 60;
  display: flex;
  gap: 8px;
  opacity: .34;
  transition: opacity .2s ease, transform .2s ease;
}

.reader-tools:hover,
.reader-tools:focus-within,
body.tools-open .reader-tools { opacity: 1; }

.tool-dot {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(47,51,45,.10);
  border-radius: 50%;
  color: rgba(47,51,45,.72);
  background: rgba(255,255,255,.62);
  box-shadow: 0 10px 28px rgba(34,38,34,.10);
  backdrop-filter: blur(16px);
  cursor: pointer;
  font: 760 18px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.corner-page {
  position: fixed;
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 58;
  min-width: 58px;
  padding: 7px 10px;
  border: 1px solid rgba(47,51,45,.09);
  border-radius: 999px;
  color: rgba(47,51,45,.58);
  background: rgba(255,255,255,.54);
  box-shadow: 0 8px 24px rgba(34,38,34,.08);
  backdrop-filter: blur(14px);
  font: 680 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
  pointer-events: none;
  transition: opacity .2s ease;
}

.tool-panel {
  position: fixed;
  left: calc(74px + env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 59;
  width: min(430px, calc(100vw - 110px));
  max-height: min(82vh, 760px);
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(47,51,45,.10);
  border-radius: 18px;
  background: rgba(255,253,248,.9);
  box-shadow: 0 26px 80px rgba(34,38,34,.18);
  backdrop-filter: blur(22px);
}

body.tools-open .tool-panel {
  display: grid;
  animation: toolPanelIn .2s ease;
}

@keyframes toolPanelIn {
  from { opacity: 0; transform: translateY(-50%) translateX(-12px); }
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

body.tools-open #railTools {
  background: rgba(47,51,45,.10);
  color: rgba(47,51,45,.95);
}
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px 10px; border-bottom: 1px solid rgba(47,51,45,.08); }
.tool-title { margin: 0; font: 760 15px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: rgba(47,51,45,.86); }
.tool-close { width: 30px; height: 30px; border: 0; border-radius: 50%; color: rgba(47,51,45,.58); background: rgba(47,51,45,.06); cursor: pointer; font: 760 18px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.tool-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px 12px; border-bottom: 1px solid rgba(47,51,45,.08); }
.tool-tab { border: 0; border-radius: 999px; padding: 8px 10px; color: rgba(47,51,45,.62); background: transparent; cursor: pointer; font: 720 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.tool-tab.active { color: rgba(47,51,45,.92); background: rgba(47,51,45,.08); }
.tool-body { overflow: auto; padding: 14px 16px 18px; }
.tool-section { display: none; }
.tool-section.active { display: block; }
.version-list { display: grid; gap: 10px; }
.version-item { display: block; padding: 12px 13px; border: 1px solid rgba(47,51,45,.08); border-radius: 12px; color: inherit; background: rgba(255,255,255,.44); text-decoration: none; }
.version-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font: 740 13px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.version-note { margin: 0; color: rgba(47,51,45,.62); font: 13px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.script-actions, .export-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.mini-button { border: 1px solid rgba(47,51,45,.10); border-radius: 999px; padding: 8px 12px; color: rgba(47,51,45,.78); background: rgba(255,255,255,.52); cursor: pointer; font: 720 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.mini-button.active { background: rgba(47,51,45,.08); color: rgba(47,51,45,.92); }
.tool-pre { max-height: 54vh; margin: 0; overflow: auto; white-space: pre-wrap; color: rgba(47,51,45,.78); background: rgba(255,255,255,.45); border: 1px solid rgba(47,51,45,.08); border-radius: 12px; padding: 13px; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.export-note { margin: 0 0 12px; color: rgba(47,51,45,.62); font: 13px/1.7 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.export-progress { margin: 0 0 12px; padding: 10px 11px 11px; border: 1px solid rgba(47,51,45,.08); border-radius: 12px; background: rgba(255,255,255,.48); }
.export-progress[hidden] { display: none; }
.export-progress-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: rgba(47,51,45,.68); font: 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.export-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(47,51,45,.10); }
.export-progress-bar { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #579a60, #88c56f); transition: width .18s ease; }
.export-list { display: grid; gap: 12px; }
.export-card { border: 1px solid rgba(47,51,45,.08); border-radius: 12px; background: rgba(255,255,255,.44); overflow: hidden; }
.export-card canvas { width: 100%; display: block; background: #fffdf8; }
.export-card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; color: rgba(47,51,45,.68); font: 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.print-export { display: none; }

@media print {
  body.printing-export { overflow: visible; background: #fff; }
  body.printing-export > *:not(.print-export) { display: none !important; }
  body.printing-export .print-export { display: block; }
  .print-page { page-break-after: always; width: 100vw; min-height: 100vh; display: grid; place-items: center; background: #fff; }
  .print-page img { width: 100%; height: auto; display: block; }
}

.mobile-reader-ui,
.swipe-hint {
  display: none;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
    touch-action: none;
  }

  .app {
    position: fixed;
    min-height: 100dvh;
    grid-template-rows: minmax(0, 1fr);
  }

  .book-wrap {
    min-height: 0;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  }

  .book-wrap::after {
    content: none;
  }

  .book {
    width: min(620px, calc(100vw - 24px));
    height: min(860px, calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    min-height: 0;
    display: block;
    overflow: hidden;
    background: var(--paper);
    box-shadow: 0 18px 50px rgba(34, 38, 34, .16);
    border: 1px solid rgba(76,83,78,.12);
    border-radius: 18px;
    gap: 0;
    transform: none;
    touch-action: pan-y;
    user-select: none;
  }

  .book::before,
  .book::after {
    content: none;
  }

  .page {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 18px !important;
    box-shadow:
      inset 0 0 0 1px rgba(255,255,255,.42),
      inset 0 0 18px rgba(116,93,57,.045);
  }

  .spread.active .page:first-child,
  .spread.active .page:last-child {
    box-shadow:
      inset 0 0 0 1px rgba(255,255,255,.42),
      inset 0 0 18px rgba(116,93,57,.045);
  }

  .spread.active {
    display: grid;
    grid-template-rows: 3fr 1fr;
    width: 100%;
    height: 100%;
    transform: translateX(0);
    will-change: transform;
  }

  .book.dragging .spread.active,
  .book.mobile-animating .spread.active {
    position: absolute;
    inset: 0;
    z-index: 3;
    transform: translateX(var(--active-x, 0px));
    transition: none;
  }

  .spread.mobile-peer {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    grid-template-rows: 3fr 1fr;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: translateX(var(--peer-x, 100%));
    will-change: transform;
  }

  .book.dragging .spread.mobile-peer,
  .book.mobile-animating .spread.mobile-peer {
    transition: none;
  }

  .book.carousel-settle .spread.active,
  .book.carousel-settle .spread.mobile-peer {
    transition: transform .28s cubic-bezier(.2,.72,.2,1);
  }

  .spread.mobile-peer:not(:has(.image-page)) {
    grid-template-rows: 1fr 1fr;
  }

  .credit-spread.mobile-peer {
    grid-template-rows: minmax(0, 1fr) minmax(0, .72fr);
    background:
      linear-gradient(180deg, rgba(255,255,255,.36), rgba(255,255,255,0)),
      var(--paper);
  }

  .spread.mobile-peer .image-page {
    order: 1;
    display: block;
    min-height: 0;
    border-radius: 18px 18px 0 0 !important;
  }

  .spread.mobile-peer .text-page {
    order: 2;
    display: flex;
    justify-content: flex-start;
    min-height: 0;
    height: 100%;
    border-radius: 0 0 18px 18px !important;
  }

  .spread.active:not(:has(.image-page)) {
    grid-template-rows: 1fr 1fr;
  }

  .credit-spread.active {
    grid-template-rows: minmax(0, 1fr) minmax(0, .72fr);
    background:
      linear-gradient(180deg, rgba(255,255,255,.36), rgba(255,255,255,0)),
      var(--paper);
  }

  .spread.active .image-page {
    order: 1;
    display: block;
    min-height: 0;
    border-radius: 18px 18px 0 0 !important;
  }

  .spread.active .text-page {
    order: 2;
    display: flex;
    justify-content: flex-start;
    min-height: 0;
    height: 100%;
    border-radius: 0 0 18px 18px !important;
  }

  .image-page img {
    height: 100%;
    object-fit: cover;
  }

  .text-page {
    min-height: 0;
    overflow: hidden;
    padding: clamp(14px, 4.3vw, 24px);
  }

  .text-page p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
    font-size: clamp(13px, 3.45vw, 17px);
    line-height: 1.48;
    text-align: left;
  }

  .credit-spread.active .text-page,
  .credit-spread.mobile-peer .text-page {
    justify-content: center;
    align-items: center;
    padding: clamp(24px, 7vw, 44px);
    text-align: center;
  }

  .credit-spread.active .text-page:first-child,
  .credit-spread.mobile-peer .text-page:first-child {
    border-radius: 18px 18px 0 0 !important;
    border-bottom: 1px solid rgba(47,51,45,.10);
  }

  .credit-spread.active .text-page:last-child,
  .credit-spread.mobile-peer .text-page:last-child {
    border-radius: 0 0 18px 18px !important;
  }

  .credit-spread.active .text-page p,
  .credit-spread.mobile-peer .text-page p {
    display: block;
    max-width: 15em;
    overflow: visible;
    font-size: clamp(18px, 4.8vw, 25px);
    line-height: 1.9;
    text-align: center;
  }

  .credit-spread.active .text-page:last-child p,
  .credit-spread.mobile-peer .text-page:last-child p {
    max-width: 11em;
    color: #2f463c;
    font-size: clamp(20px, 5.4vw, 30px);
    line-height: 1.75;
  }

  .text-page p:first-of-type::first-letter {
    float: none;
    margin: 0;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    font-weight: inherit;
  }

  .small-note {
    margin-top: 12px;
    font-size: clamp(13px, 3.4vw, 16px);
  }

  .page-mark {
    display: none;
  }


  .reader-tools { top: calc(14px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); opacity: .22; }
  .reader-tools:hover, .reader-tools:focus-within, body.tools-open .reader-tools { opacity: 1; }
  .tool-dot { width: 34px; height: 34px; background: rgba(255,255,255,.50); }
  .corner-page { right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); opacity: 0; }
  .app.page-peek .corner-page, body.tools-open .corner-page { opacity: 1; }
  .tool-panel { top: auto; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; max-height: min(78dvh, 680px); border-radius: 20px; transform: none; }

  body.tools-open .tool-panel { animation: toolPanelInMobile .22s ease; }

  @keyframes toolPanelInMobile {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }

  .mobile-reader-ui {
    display: none;
  }

  .mobile-reader-ui button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(47,51,45,.10);
    border-radius: 50%;
    color: rgba(47,51,45,.72);
    background: rgba(255,255,255,.58);
    box-shadow: 0 8px 22px rgba(34,38,34,.10);
    backdrop-filter: blur(14px);
    pointer-events: auto;
    cursor: pointer;
  }

  .mobile-counter {
    justify-self: center;
    min-width: 72px;
    padding: 7px 12px;
    border: 1px solid rgba(47,51,45,.08);
    border-radius: 999px;
    color: rgba(47,51,45,.66);
    background: rgba(255,255,255,.54);
    box-shadow: 0 8px 22px rgba(34,38,34,.08);
    backdrop-filter: blur(14px);
    font: 650 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: center;
  }

  .swipe-hint {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 31;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border: 1px solid rgba(47,51,45,.08);
    border-radius: 999px;
    color: rgba(47,51,45,.72);
    background: rgba(255,255,255,.58);
    box-shadow: 0 10px 28px rgba(34,38,34,.10);
    backdrop-filter: blur(16px);
    font: 650 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 12px);
  }

  .swipe-hint::before {
    content: "←";
    display: inline-block;
    animation: hintArrow 1.1s ease-in-out infinite;
  }

  .swipe-hint::after {
    content: "滑动翻页";
  }

  .app.show-swipe-hint .swipe-hint {
    animation: hintBubble 2.8s ease both;
  }

  @keyframes hintBubble {
    0% { opacity: 0; transform: translate(-50%, 12px); }
    14%, 78% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 6px); }
  }

  @keyframes hintArrow {
    0%, 100% { transform: translateX(4px); opacity: .55; }
    50% { transform: translateX(-5px); opacity: 1; }
  }
}

@media (max-width: 430px) {
  .splash {
    padding: 18px;
  }

  .splash-cover {
    width: min(390px, 86vw);
  }

  .book {
    height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .text-page p {
    font-size: clamp(13px, 3.45vw, 16px);
  }
}

/* 桌面: 显示左侧竖栏, 隐藏浮动工具点与角标页码 (置于文件末尾保证覆盖) */
@media (min-width: 861px) {
  .side-rail {
    display: flex;
  }

  .reader-tools {
    display: none;
  }

  .corner-page {
    display: none;
  }
}
