/* 来过 · 日记阅读器
   一页一天/一个主题，电脑双页，手机单页。 */

.reader-body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background: var(--paper);
}

#reader {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 书页 ---------- */

/* 层次（从下到上）：雾蓝封皮 → 索引签 → 纸页（带书口纸边）→ 纸纹 / 订口阴影 */
.stage {
  --cover: 30px;
  --edge: 12px;
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0 var(--cover);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), transparent var(--cover), transparent calc(100% - var(--cover)), rgba(40, 55, 75, 0.1)),
    #a9b8c8;
}

/* 索引签：压在纸页底下，只露出一半 */
.book-tabs {
  position: absolute;
  top: 150px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: none;
}
.book-tabs--left { left: 0; }
.book-tabs--right { right: 0; }
.book-tab {
  display: block;
  width: 44px;
  height: 40px;
  box-shadow: 0 2px 4px rgba(40, 55, 75, 0.18);
}
.book-tab--pink { background: #eebccb; }
.book-tab--blue { background: #cfe0f2; }
.book-tabs--left .book-tab { border-radius: 6px 0 0 6px; }
.book-tabs--right .book-tab { border-radius: 0 6px 6px 0; }
.book-tabs .book-tab:nth-child(1) { height: 50px; }
.book-tabs .book-tab:nth-child(2) { height: 34px; margin-left: 2px; }
.book-tabs--left .book-tab:nth-child(2) { margin-left: -2px; }

.slot {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper-3);
  padding: 0;
  scrollbar-width: none;
}
.slot::-webkit-scrollbar { display: none; }
.slot--left { background: #f7f1e4; }

/* 书口：4 层很窄的纸边，一层比一层深 */
#slot-right {
  box-shadow:
    2px 0 0 #ece5d7,
    3px 0 0 #d9cfbe,
    5px 0 0 #e3dbcb,
    6px 0 0 #cfc4b1,
    8px 0 0 #dad0bf,
    9px 0 0 #c4b7a2,
    11px 0 0 #cdc1ad,
    12px 0 0 #b3a58f,
    16px 0 10px -6px rgba(30, 42, 58, 0.32);
}
.slot--left {
  box-shadow:
    -2px 0 0 #ece5d7,
    -3px 0 0 #d9cfbe,
    -5px 0 0 #e3dbcb,
    -6px 0 0 #cfc4b1,
    -8px 0 0 #dad0bf,
    -9px 0 0 #c4b7a2,
    -11px 0 0 #cdc1ad,
    -12px 0 0 #b3a58f,
    -16px 0 10px -6px rgba(30, 42, 58, 0.32);
}

/* 纸纹颗粒 + 四角压暗 + 订口阴影；盖在纸页上面，不挡点击 */
.sheet-fx {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  width: calc((100% - 2 * var(--cover)) / 2);
  pointer-events: none;
  mix-blend-mode: multiply;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .24 0 0 0 .2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --corners: radial-gradient(72% 72% at 50% 50%, transparent 66%, rgba(80, 62, 42, 0.16) 100%);
}
.sheet-fx--left {
  left: var(--cover);
  background:
    linear-gradient(270deg, rgba(48, 40, 30, 0.3) 0, rgba(48, 40, 30, 0.15) 9px, rgba(48, 40, 30, 0.06) 30px, transparent 72px),
    var(--corners),
    var(--grain);
}
.sheet-fx--right {
  right: var(--cover);
  background:
    linear-gradient(90deg, rgba(48, 40, 30, 0.3) 0, rgba(48, 40, 30, 0.15) 9px, rgba(48, 40, 30, 0.06) 30px, transparent 72px),
    var(--corners),
    var(--grain);
}

/* 页面风格铺满整张纸，内容仍是居中的一栏 */
.slot > .dp {
  max-width: none;
  min-height: 100%;
  margin: 0;
  padding: clamp(26px, 3vw, 40px) clamp(30px, 4.5vw, 64px) clamp(36px, 4.5vw, 64px);
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  box-shadow: none;
}
.slot > .dp > .dp__head,
.slot > .dp > .dp__body {
  width: 100%;
  max-width: 584px;
  margin-left: auto;
  margin-right: auto;
}
.slot > .dp > .page-stickies {
  left: 50%;
  right: auto;
  width: min(640px, 100%);
  transform: translateX(-50%);
}

.dp {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  --page-bg: transparent;
  --photo-filter: none;
  --display-font: var(--serif);
  --label-font: var(--sans);
  background: var(--page-bg);
}
.dp--style-paper {
  --page-bg: linear-gradient(180deg, rgba(255, 253, 246, 0.7), transparent 40%);
  --display-font: var(--font-wenkai);
  padding: 30px 28px 40px;
}
.dp--style-kraft {
  --ink: #3f2b1d;
  --ink-2: #6b4c35;
  --ink-3: #8b6b4f;
  --line: #c6a97e;
  --photo-filter: sepia(0.14) saturate(0.88) contrast(1.02);
  --display-font: var(--font-wenkai);
  --label-font: "Courier New", ui-monospace, monospace;
  --page-bg:
    radial-gradient(circle at 18% 12%, rgba(255, 247, 226, 0.32), transparent 30%),
    repeating-linear-gradient(4deg, rgba(86, 56, 27, 0.035) 0 1px, transparent 1px 5px),
    #e8d5b6;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 247, 226, 0.32), transparent 30%),
    repeating-linear-gradient(4deg, rgba(86, 56, 27, 0.035) 0 1px, transparent 1px 5px),
    #e8d5b6;
  padding: 30px 28px 40px;
  border: 1px solid #c9ab7f;
  border-radius: 1px;
  box-shadow: 0 18px 40px -34px rgba(60, 40, 20, 0.8);
}
.dp--style-film {
  --ink: #25241f;
  --ink-2: #4d4b42;
  --ink-3: #827d6e;
  --line: #bdb6a6;
  --photo-filter: grayscale(0.28) contrast(1.08) sepia(0.06);
  --display-font: var(--sans);
  --label-font: "Courier New", ui-monospace, monospace;
  --page-bg:
    linear-gradient(90deg, rgba(34, 34, 30, 0.035), transparent 12%, transparent 88%, rgba(34, 34, 30, 0.035)),
    #f4efe2;
  background:
    linear-gradient(90deg, rgba(34, 34, 30, 0.035), transparent 12%, transparent 88%, rgba(34, 34, 30, 0.035)),
    #f4efe2;
  padding: 30px 28px 40px;
  border-top: 5px solid #2c2b26;
  border-bottom: 5px solid #2c2b26;
  border-radius: 0;
  box-shadow: 0 18px 40px -34px rgba(30, 30, 25, 0.7);
}
.dp--style-ink {
  --ink: #2f3433;
  --ink-2: #59615f;
  --ink-3: #8a918e;
  --line: #d1d6d2;
  --photo-filter: grayscale(0.72) contrast(0.95);
  --display-font: var(--serif);
  --page-bg:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(74, 92, 86, 0.075) 31px 32px),
    #fbfbf7;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(74, 92, 86, 0.075) 31px 32px),
    #fbfbf7;
  padding: 30px 28px 40px;
  border-top: 1px solid #9aa7a0;
  border-radius: 0;
}
.dp--style-blueprint {
  --page-bg: #1b4d74;
  --ink: #f4fbff;
  --ink-2: #d8ecf8;
  --ink-3: #a9cbe0;
  --line: rgba(255, 255, 255, 0.3);
  --photo-filter: saturate(0.7) contrast(1.05) brightness(0.95);
  --display-font: var(--font-wenkai);
  --label-font: "Courier New", ui-monospace, monospace;
  background-color: #1b4d74;
  padding: 30px 28px 40px;
  border-radius: 2px;
  position: relative;
  isolation: isolate;
  box-shadow: 0 18px 40px -34px rgba(12, 40, 62, 0.9);
}
.dp--style-blueprint::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 75% 18%, rgba(255, 255, 255, 0.16), transparent 30%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 900'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.22' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M110 900C170 700 190 470 150 210'/%3E%3Cpath d='M150 270C100 230 76 180 70 120'/%3E%3Cpath d='M155 350C215 310 245 260 255 200'/%3E%3Cpath d='M160 440C100 410 68 360 58 300'/%3E%3Cpath d='M165 530C235 500 270 450 285 390'/%3E%3Cpath d='M170 620C110 590 80 540 72 480'/%3E%3Cpath d='M175 710C250 680 285 630 300 570'/%3E%3Cpath d='M180 790C120 770 90 720 82 660'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.08'%3E%3Cpath d='M70 120C50 90 60 55 95 40C110 80 100 105 70 120Z'/%3E%3Cpath d='M255 200C280 165 315 160 340 182C320 220 290 225 255 200Z'/%3E%3Cpath d='M58 300C30 275 28 238 55 215C83 242 84 275 58 300Z'/%3E%3Cpath d='M285 390C318 362 355 366 372 395C348 427 315 425 285 390Z'/%3E%3Cpath d='M72 480C42 458 36 420 62 397C92 423 95 456 72 480Z'/%3E%3Cpath d='M300 570C334 542 370 548 386 578C362 610 330 605 300 570Z'/%3E%3Cpath d='M82 660C52 638 46 600 72 577C102 603 105 636 82 660Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center bottom;
}
.dp--style-blueprint > .dp__head,
.dp--style-blueprint > .dp__body,
.dp--style-blueprint > .inline-write,
.dp--style-blueprint > .inline-open {
  position: relative;
  z-index: 1;
}
.dp--style-blueprint .dp__title { letter-spacing: 0.08em; }
.dp--style-blueprint .photo {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
}
.dp--style-blueprint .photo figcaption { color: #d8ecf8; }

.dp--style-mint {
  --ink: #1f4b3d;
  --ink-2: #3f6a58;
  --ink-3: #6f8f7e;
  --line: #b7d8c5;
  --photo-filter: saturate(0.95) contrast(1.02);
  --display-font: var(--font-wenkai);
  --page-bg:
    linear-gradient(rgba(255, 255, 255, 0.65) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.65) 1px, transparent 1px) 0 0 / 26px 26px,
    #dff3e7;
  padding: 30px 28px 40px;
  border: 1px solid #b9ddc8;
  border-radius: 2px;
}

.dp--style-pinkgrid {
  --ink: #5b3440;
  --ink-2: #855866;
  --ink-3: #b08a95;
  --line: #e9c5ce;
  --photo-filter: saturate(0.98) contrast(1.02);
  --display-font: var(--font-wenkai);
  --page-bg:
    linear-gradient(rgba(255, 255, 255, 0.68) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.68) 1px, transparent 1px) 0 0 / 26px 26px,
    #f8e2e7;
  padding: 30px 28px 40px;
  border: 1px solid #efcbd5;
  border-radius: 2px;
}

.dp--style-custom {
  --page-bg: #fbf7ee;
  background-color: var(--page-bg);
  background-image: var(--paper-image, none);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  padding: 30px 28px 40px;
  border-radius: 2px;
}

.dp--style-vellum {
  --page-bg: rgba(252, 252, 248, 0.58);
  --ink: #354544;
  --ink-2: #5a6b68;
  --ink-3: #80908c;
  --line: rgba(90, 108, 104, 0.28);
  --photo-filter: saturate(0.8) contrast(0.98);
  --display-font: var(--font-wenkai);
  background: rgba(252, 252, 248, 0.58);
  padding: 30px 28px 40px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 2px;
  position: relative;
  isolation: isolate;
  backdrop-filter: blur(1.2px);
  box-shadow: 0 18px 40px -36px rgba(40, 50, 48, 0.55);
}
.dp--style-vellum::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02) 42%, rgba(255, 255, 255, 0.2)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 5px);
  mix-blend-mode: screen;
}
.dp--style-vellum > .dp__head,
.dp--style-vellum > .dp__body,
.dp--style-vellum > .inline-write,
.dp--style-vellum > .inline-open {
  position: relative;
  z-index: 1;
}

.dp--style-paper .dp__title { font-weight: 600; }
.dp--style-kraft .dp__title { letter-spacing: 0.04em; font-weight: 600; }
.dp--style-film .dp__title { letter-spacing: 0.1em; font-weight: 500; }
.dp--style-ink .dp__title { font-weight: 400; letter-spacing: 0.14em; }
.dp--style-kraft .dp__meta,
.dp--style-kraft .seg__who,
.dp--style-kraft .photo figcaption { font-family: var(--label-font); }
.dp--style-film .dp__meta,
.dp--style-film .seg__who,
.dp--style-film .photo figcaption { font-family: var(--label-font); }
.dp--style-film .photo { border: 1px solid #2c2b26; padding: 5px; background: #fffdf6; }
.dp--style-film .photo img { border-radius: 0; }
.dp--style-ink .photo { border: 1px solid #cfd6d1; padding: 4px; background: #fff; }
.dp--style-ink .photo figcaption { letter-spacing: 0.12em; }

.dp--layout-magazine .dp__title { font-size: clamp(34px, 4vw, 50px); }
.dp--layout-magazine .seg__text { font-size: clamp(17px, 1.6vw, 18.5px); }
.dp--layout-magazine .photo--full {
  width: calc(100% + 56px);
  margin-left: -28px;
  margin-right: -28px;
}
.dp--layout-polaroid .photo {
  background: #fff;
  padding: 10px 10px 30px;
  box-shadow: 0 1px 1.5px rgba(60, 45, 25, 0.16), 0 4px 10px -4px rgba(60, 45, 25, 0.12);
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px))
    rotate(var(--pr, var(--tilt))) scale(var(--ps, 1));
}
.dp--layout-polaroid .photo:nth-of-type(even) {
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px))
    rotate(var(--pr, var(--tilt))) scale(var(--ps, 1));
}
.dp--layout-polaroid .photo figcaption { padding: 0 4px; }
.dp--layout-duo .photo--half { width: calc(50% - 10px); }

.photo {
  --tilt: -1.1deg;
  position: relative;
  box-sizing: border-box;
  width: min(94%, 560px);
  margin: 28px auto;
  padding: 7px 7px 25px;
  background: #fff;
  box-shadow: 0 1px 1.5px rgba(60, 45, 25, 0.16), 0 4px 10px -4px rgba(60, 45, 25, 0.12);
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px))
    rotate(var(--pr, var(--tilt))) scale(var(--ps, 1));
  transform-origin: center center;
}
.photo:nth-of-type(even) { --tilt: 1.2deg; }
.photo::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  z-index: 1;
  width: 56px;
  height: 15px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(206, 190, 158, 0.55);
  box-shadow: 0 1px 1px rgba(60, 45, 25, 0.1);
}
.photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
  filter: var(--photo-filter);
}
.photo--full { width: min(94%, 560px); }
.photo--half { width: min(52%, 360px); }
.photo--left { margin-left: 0; margin-right: auto; }
.photo--right { margin-left: auto; margin-right: 0; }
.photo--polaroid {
  background: #fff;
  padding: 9px 9px 28px;
  box-shadow: 0 1px 1.5px rgba(60, 45, 25, 0.16), 0 4px 10px -4px rgba(60, 45, 25, 0.12);
}
.photo figcaption {
  margin-top: 8px;
  padding: 0 6px;
  font-family: var(--font-wenkai);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
  text-align: left;
  letter-spacing: 0.02em;
}
.photo figcaption::before { content: "— "; color: var(--ink-3); }
.dp--style-blueprint .photo::before { background: rgba(255, 255, 255, 0.35); }
.dp--style-pinkgrid .photo::before { background: rgba(238, 176, 198, 0.62); }

.page-note {
  --note-bg: #f7e6a2;
  --note-ink: #3c3424;
  position: relative;
  width: min(78%, 360px);
  margin: 22px auto 26px;
  padding: 11px 14px 12px;
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: 0 1px 1.5px rgba(60, 45, 25, 0.14), 0 5px 10px -6px rgba(60, 45, 25, 0.16);
  transform: rotate(1.2deg);
  font-family: var(--font-wenkai);
}
.page-note--mengmeng { margin-left: auto; margin-right: 6%; }
.page-note--qinyu {
  transform: rotate(-1.2deg);
  margin-left: 6%;
  margin-right: auto;
}
.page-note__who {
  display: block;
  margin-bottom: 4px;
  font-family: var(--label-font);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.page-note p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 批注颜色：常驻淡色系 */
.note-color-yellow { --note-bg: #f7e6a2; --note-ink: #3c3424; }
.note-color-pink { --note-bg: #f6d9e2; --note-ink: #5a3340; }
.note-color-blue { --note-bg: #dbe9f5; --note-ink: #2f4355; }
.note-color-mint { --note-bg: #dcefe2; --note-ink: #2f4a3b; }
.note-color-lilac { --note-bg: #e7dff4; --note-ink: #443654; }
.note-color-peach { --note-bg: #f8e2ce; --note-ink: #573b2a; }

/* 批注形式：便签 / 回形针 / 小夹子 / 清单小票 */
.page-note--sticky::after,
.ed-note--sticky::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent color-mix(in srgb, var(--note-ink) 16%, transparent) transparent;
}

.page-note--clip::before,
.ed-note--clip::before {
  content: "";
  position: absolute;
  top: -17px;
  left: 16px;
  width: 9px;
  height: 20px;
  border: 2px solid #9a8d78;
  border-radius: 7px;
  border-bottom-color: transparent;
  transform: rotate(7deg);
  pointer-events: none;
}

.page-note--stand::before,
.ed-note--stand::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 54px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #9b825f, #6f5940);
  box-shadow: 0 3px 4px rgba(60, 45, 25, 0.2);
  pointer-events: none;
}

.page-note--receipt,
.ed-note--receipt {
  width: min(64%, 310px);
  padding: 14px 16px 16px;
  border-top: 1px dashed color-mix(in srgb, var(--note-ink) 30%, transparent);
  border-bottom: 1px dashed color-mix(in srgb, var(--note-ink) 30%, transparent);
  transform: none;
  font-family: "Courier New", ui-monospace, monospace;
  box-shadow: 0 1px 1.5px rgba(60, 45, 25, 0.14), 0 5px 10px -6px rgba(60, 45, 25, 0.16);
}
.page-note--receipt::before,
.ed-note--receipt::before {
  content: "清单 · RECEIPT";
  display: block;
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 1px dashed color-mix(in srgb, var(--note-ink) 22%, transparent);
  font-family: var(--label-font);
  font-size: 8px;
  letter-spacing: 0.18em;
  opacity: 0.6;
}
.page-note--receipt p,
.ed-note--receipt .ed-note__text {
  font-size: 12px;
  line-height: 1.9;
  font-family: "Courier New", ui-monospace, monospace;
}

.dp__title[contenteditable="true"] {
  cursor: text;
  outline: 1px dashed transparent;
  outline-offset: 5px;
  border-radius: 3px;
}
.dp__title[contenteditable="true"]:hover,
.dp__title[contenteditable="true"]:focus {
  outline-color: color-mix(in srgb, var(--rust) 35%, transparent);
  background: color-mix(in srgb, #fff 22%, transparent);
}

.inline-open {
  display: block;
  margin: 22px auto 8px;
  padding: 5px 12px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-wenkai);
  font-size: 11px;
  cursor: pointer;
  opacity: 0.55;
}
.inline-open:hover { opacity: 1; border-color: var(--ink-3); }

.inline-write {
  margin: 12px 0 22px;
  padding: 12px 0 8px;
  border-top: 1px dashed var(--line);
}
.inline-text {
  min-height: 92px;
  padding: 6px 2px;
  outline: none;
  color: var(--ink);
  font-family: var(--font-wenkai);
  font-size: clamp(16px, 1.5vw, 17.5px);
  line-height: 2.05;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.inline-text:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-3);
  opacity: 0.65;
}
.inline-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.inline-bar select {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink-2);
  font: inherit;
  font-size: 11px;
}
.inline-bar button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.inline-save {
  border-color: var(--ink) !important;
  background: var(--ink) !important;
  color: var(--paper-3) !important;
}
.dp--style-blueprint .inline-save {
  background: #f4fbff !important;
  border-color: #f4fbff !important;
  color: #1b4d74 !important;
}
.inline-cancel { margin-left: auto; opacity: 0.65; }
.inline-write.is-open .inline-text:focus { background: color-mix(in srgb, #fff 25%, transparent); }

.page-stickies {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}
.sticker {
  position: absolute;
  display: block;
  transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s));
  transform-origin: center;
  line-height: 1;
  user-select: none;
}
.sticker--emoji {
  font-size: 44px;
  filter: drop-shadow(0 1px 1px rgba(50, 38, 22, 0.16)) drop-shadow(0 3px 4px rgba(50, 38, 22, 0.08));
}
.sticker--image img {
  display: block;
  width: 96px;
  height: auto;
  filter: drop-shadow(0 1px 1px rgba(50, 38, 22, 0.16)) drop-shadow(0 3px 4px rgba(50, 38, 22, 0.08));
}
.sticker--bounce { animation: sticker-bounce 2.4s ease-in-out infinite; }
.sticker--float { animation: sticker-float 3.4s ease-in-out infinite; }
.sticker--swing { animation: sticker-swing 3.2s ease-in-out infinite; }
@keyframes sticker-bounce {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s)) translateY(0); }
  50% { transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s)) translateY(-9px); }
}
@keyframes sticker-float {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s)) translateY(0); }
  50% { transform: translate(-50%, -50%) rotate(calc(var(--r) + 4deg)) scale(var(--s)) translateY(-6px); }
}
@keyframes sticker-swing {
  0%, 100% { transform: translate(-50%, -50%) rotate(calc(var(--r) - 4deg)) scale(var(--s)); }
  50% { transform: translate(-50%, -50%) rotate(calc(var(--r) + 4deg)) scale(var(--s)); }
}

.dp__head {
  padding-bottom: 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.reader-body .dp__head { padding-top: 10px; }
.dp__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.dp__meta time { font-variant-numeric: tabular-nums; }
.dp__badges { display: flex; flex-wrap: wrap; gap: 5px; }

.wx {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 9px 0 2px;
  padding: 7px 0;
  border-top: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
  border-bottom: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
  color: var(--ink-3);
  font-family: var(--label-font);
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.03em;
}
.wx[hidden] { display: none !important; }
.wx__icon {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1;
  color: var(--ink-2);
}
.wx__text { color: var(--ink-2); }
.wx__place { color: var(--ink-3); }
.wx__place:not(:empty)::before { content: "· "; }
.wx__photos { margin-left: auto; color: var(--ink-3); }
.dp--style-blueprint .wx { color: #cfe4f5; border-color: rgba(255, 255, 255, 0.28); }
.dp--style-blueprint .wx__text,
.dp--style-blueprint .wx__icon { color: #f4fbff; }
.dp--style-blueprint .wx__place,
.dp--style-blueprint .wx__photos { color: #b9d8eb; }
.dp__title {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.3;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.dp__body { flex: 1; padding-top: 8px; }

/* ---------- 段落 ---------- */

.seg {
  position: relative;
  padding: 18px 0;
}
.seg + .seg { margin-top: 8px; }

.seg__who {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.seg__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rust);
  opacity: 0.7;
}
.seg__dot--m { background: #a35d62; }
.seg__model {
  padding: 1px 7px;
  border: 1px solid color-mix(in srgb, var(--rust) 26%, transparent);
  border-radius: 999px;
  font-size: 10px;
  color: color-mix(in srgb, var(--rust) 74%, #333);
  background: color-mix(in srgb, var(--rust) 5%, transparent);
}
.seg__sign {
  margin-top: 8px;
  text-align: right;
  font-family: var(--label-font);
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  opacity: 0.8;
}
.seg__text {
  margin-top: 9px;
  font-family: var(--font-wenkai);
  font-size: clamp(16px, 1.5vw, 17.5px);
  line-height: 2.05;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.seg__text.font-wenkai { font-family: var(--font-wenkai); }
.seg__text.font-chillkai { font-family: "ChillKai", var(--font-wenkai), serif; }
.seg__text.font-shoushuti { font-family: "ShouShuti", var(--font-wenkai), serif; }
.seg__text.font-huiwen { font-family: "Huiwen-mincho", var(--serif); }
.seg__text p { margin: 0 0 0.9em; }
.seg__text p:last-child { margin-bottom: 0; }
.seg__text blockquote {
  margin: 1em 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--line-2);
  color: var(--ink-2);
}
.seg__text ul,
.seg__text ol { margin: 0.7em 0; padding-left: 1.4em; }
.seg__text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: color-mix(in srgb, var(--line) 34%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
}

.badge {
  display: inline-block;
  padding: 1px 7px 2px;
  border: 1px solid color-mix(in srgb, var(--rust) 26%, transparent);
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: color-mix(in srgb, var(--rust) 74%, #333);
  background: color-mix(in srgb, var(--rust) 5%, transparent);
  white-space: nowrap;
}
.badge--mengmeng {
  border-color: color-mix(in srgb, #a35d62 30%, transparent);
  color: #874a50;
  background: color-mix(in srgb, #a35d62 6%, transparent);
}

/* ---------- 目录 ---------- */

.toc {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(88vw, 370px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #fbf7ee;
  border-right: 1px solid var(--line);
  box-shadow: 30px 0 70px -50px rgba(40, 30, 20, 0.8);
  transform: translateX(-104%);
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.toc.open { transform: translateX(0); }

.toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.32em;
}
.toc__head .icon-btn {
  position: static;
  width: 32px;
  height: 32px;
  font-size: 18px;
  box-shadow: none;
}
.toc__tools {
  display: flex;
  gap: 7px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--line);
}
.toc__tools input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  outline: none;
}
.toc__tools input:focus { border-color: var(--line-2); }
.sort-btn {
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink-2);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
  white-space: nowrap;
}

.toc__list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.toc__item { border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.toc__item.is-hidden { display: none; }
.toc__item a {
  display: block;
  padding: 12px 18px;
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease;
}
.toc__item a:hover,
.toc__item.is-on a { background: #f3ecdd; }
.toc__title {
  display: block;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.toc__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 10px;
  color: var(--ink-3);
}
.toc__meta time { margin-right: 2px; font-variant-numeric: tabular-nums; }
.toc__foot {
  display: flex;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
}
.toc__foot a { color: var(--ink-2); text-decoration: none; }
.toc__foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(38, 34, 29, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.demo-banner {
  position: fixed;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 5px 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper-3) 90%, transparent);
  color: color-mix(in srgb, var(--gold) 55%, var(--ink));
  font-size: 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.demo-banner a {
  margin-left: 7px;
  color: var(--rust);
  text-underline-offset: 2px;
}

/* ---------- 按钮 ---------- */

.icon-btn {
  position: fixed;
  left: 14px;
  top: 12px;
  z-index: 40;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper-3) 88%, transparent);
  backdrop-filter: blur(8px);
  color: var(--ink-2);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }

.edit-btn {
  position: fixed;
  right: 112px;
  top: 15px;
  z-index: 40;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-decoration: none;
  opacity: 0.6;
}
.edit-btn:hover { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }

.write-btn {
  position: fixed;
  right: 56px;
  top: 12px;
  z-index: 40;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
  opacity: 0.78;
}
.write-btn:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }

.nav-arrow {
  position: fixed;
  bottom: 12px;
  z-index: 35;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper-3) 82%, transparent);
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.46;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.nav-arrow:hover { opacity: 0.9; border-color: var(--line-2); }
.nav-arrow--prev { left: 16px; }
.nav-arrow--next { right: 16px; }
.nav-arrow.is-hidden { opacity: 0; pointer-events: none; }

.pageno {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 34;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 写 ---------- */

.compose {
  width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 3px 22px 22px 22px;
  padding: 24px;
  background: #fbf7ee;
  color: var(--ink);
  box-shadow: 0 38px 80px -40px rgba(40, 30, 20, 0.7);
}
.compose::backdrop { background: rgba(38, 34, 29, 0.4); }
.compose h2 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 0.1em;
}
.field {
  display: block;
  margin-bottom: 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.field input,
.field textarea,
.field select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
}
.field textarea { font-family: var(--font-wenkai); line-height: 1.9; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--line-2); }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  font-size: 12px;
  color: var(--ink-2);
}
.compose__actions { display: flex; justify-content: flex-end; gap: 8px; }
.compose__actions button {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.compose__actions button:last-child {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-3);
}
.compose__error { min-height: 1.2em; margin: 10px 0 0; font-size: 12px; color: #9b3d2c; }

/* ---------- 空 / 登录 ---------- */

.reader-empty,
.login {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.reader-empty h1,
.login h1 {
  margin: 15vh 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 6vw, 52px);
}
.reader-empty p,
.login__sub {
  margin: 14px 0;
  font-size: 13px;
  line-height: 2;
  color: var(--ink-3);
}
.reader-empty a { color: var(--rust); text-underline-offset: 3px; }
.login h1 { margin-top: 0; }
.login form {
  width: min(84vw, 320px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.login input {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.login button {
  padding: 10px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper-3);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.16em;
  cursor: pointer;
}
.login__error { min-height: 1.2em; color: #9b3d2c; font-size: 12px; }

/* ---------- 每块可挪 + 版心 ----------
   挪动量和版心都按“页宽”存（cqw），电脑和手机按比例对得上 */
.dp { container-type: inline-size; }
[data-k] {
  translate: calc(var(--ox, 0) * 100cqw) calc(var(--oy, 0) * 100cqw);
}

/* 自己上传的纸页：按原图比例铺，不拉伸；字再多就往下长 */
.dp.dp--style-custom.dp--paper-fixed {
  aspect-ratio: var(--paper-ar);
  /* 宽度定死跟着纸槽走；字多了只往下长，不许 aspect-ratio 反过来把纸撑宽 */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background-size: 100% auto;
  background-position: top center;
  background-repeat: no-repeat;
}
.slot > .dp.dp--style-custom.dp--paper-fixed { min-height: auto; }

/* 纸页接长：顶上一段、底下一段固定，中间一条（一个底纹周期）往下重复。
   用 border-image 切三段；左右各切 0.1% 只是为了让中间那条跟着页宽等比缩放。
   round：中间整条整条地铺，首尾都对齐，不会切出半条。 */
.paper-bg { display: none; }
.dp--style-custom.dp--paper-slice { background-image: none; isolation: isolate; }
.dp--style-custom.dp--paper-slice > .paper-bg {
  display: block;
  position: absolute;
  inset: 0;
  z-index: -1;
  box-sizing: border-box;
  pointer-events: none;
  border-style: solid;
  border-color: transparent;
  border-width: calc(var(--ps-t) * 100cqw) 0.1cqw calc(var(--ps-b) * 100cqw);
  border-image-source: var(--paper-image);
  border-image-slice: var(--ps-st) 0.1% var(--ps-sb) fill;
  border-image-width: calc(var(--ps-t) * 100cqw) 0.1cqw calc(var(--ps-b) * 100cqw);
  border-image-repeat: stretch round;
}

/* 版心：只在框里排字，避开纸页自带的装饰 */
.dp.dp--framed,
.slot > .dp.dp--framed { padding: 0; }
.dp--framed > .dp__head,
.slot > .dp.dp--framed > .dp__head {
  width: auto;
  max-width: none;
  margin: calc(var(--ft) * 100cqw) calc(var(--fr) * 100cqw) 6px calc(var(--fl) * 100cqw);
  padding-top: 0;
}
.dp--framed > .dp__body,
.slot > .dp.dp--framed > .dp__body {
  width: auto;
  max-width: none;
  margin: 0 calc(var(--fr) * 100cqw) 0 calc(var(--fl) * 100cqw);
  padding-bottom: calc(var(--fb) * 100cqw);
}
.slot > .dp.dp--framed > .page-stickies,
.slot > .dp.dp--paper-fixed > .page-stickies {
  left: 0;
  width: 100%;
  transform: none;
}

.ribbons { display: none; }
@keyframes page-land {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

/* ---------- 手机 ---------- */

@media (max-width: 900px) {
  /* 手机：一整张纸铺满，不露书边；书的感觉交给丝带书签和翻页 */
  .stage {
    --cover: 0px;
    grid-template-columns: 1fr;
    padding: 0;
    perspective: 1400px;
    /* 翻页时露出来的“下一张纸” */
    background:
      linear-gradient(90deg, rgba(48, 40, 30, 0.1), transparent 46px),
      #eee6d7;
  }
  .slot--left,
  .sheet-fx--left,
  .book-tabs { display: none; }
  #slot-right {
    box-shadow: none;
    transform-origin: left center;
  }
  .stage[data-turn="right"] #slot-right { transform-origin: right center; }
  .stage.is-turning #slot-right {
    transform: rotateY(calc(var(--turn, 0) * 88deg));
    will-change: transform;
    box-shadow: 0 0 28px rgba(40, 30, 20, calc(var(--turn-abs, 0) * 0.4));
    filter: brightness(calc(1 - var(--turn-abs, 0) * 0.14));
  }
  .stage.is-settling #slot-right {
    transition:
      transform 0.28s cubic-bezier(0.3, 0.1, 0.3, 1),
      box-shadow 0.28s ease,
      filter 0.28s ease;
  }
  #slot-right.is-landing { animation: page-land 0.24s ease-out; }
  .sheet-fx--right {
    left: 0;
    right: 0;
    width: auto;
    transition: opacity 0.12s ease;
    background: var(--corners), var(--grain);
  }
  .stage.is-turning .sheet-fx--right { opacity: 0; }

  /* 丝带书签：一粉一蓝从顶上垂下来，尾巴剪成燕尾 */
  .ribbons {
    position: absolute;
    top: 0;
    right: 8px;
    z-index: 5;
    display: flex;
    gap: 4px;
    pointer-events: none;
    filter: drop-shadow(1px 2px 1.5px rgba(60, 45, 25, 0.22));
  }
  .ribbon {
    display: block;
    width: 6px;
    height: 118px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 7px), 0 100%);
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.3), transparent 45%, rgba(0, 0, 0, 0.06)),
      var(--ribbon);
  }
  .ribbon--pink { --ribbon: #e9b0c2; }
  .ribbon--blue { --ribbon: #b9d1ea; height: 92px; }

  .slot > .dp { padding: 22px 22px 34px; }
  .reader-body .dp__head { padding-top: 34px; }
  .dp__title { font-size: clamp(26px, 7vw, 34px); }
  .dp--style-paper,
  .dp--style-kraft,
  .dp--style-film,
  .dp--style-ink { padding: 22px 16px 32px; }
  .dp--layout-magazine .photo--full {
    width: calc(100% + 32px);
    margin-left: -16px;
    margin-right: -16px;
  }
  .photo--half,
  .dp--layout-duo .photo--half { width: 100%; }
  .wx { font-size: 10px; }
  .sticker--emoji { font-size: 38px; }
  .sticker--image img { width: 82px; }
  .seg { padding-left: 14px; }
  .toc { width: min(92vw, 380px); }
  .nav-arrow { width: 34px; height: 34px; font-size: 20px; bottom: 10px; }
  .nav-arrow--prev { left: 12px; }
  .nav-arrow--next { right: 12px; }
  .pageno { bottom: 17px; }
  .icon-btn { left: 16px; }
  .write-btn { right: 34px; top: 13px; }
  .edit-btn { right: 84px; top: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .toc,
  .scrim { transition: none; }
}
