/* 书房 · 样式
   两种材质：纸和木头，其余交给排印。 */
:root {
  --paper: #f7f2e7;
  --ink: #332f27;
  --ink-soft: #7b7161;
  --gold: #f0dcae;
  --line: rgba(84, 62, 30, .16);
  --serif: Georgia, "Songti SC", "Noto Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --rule: 34px; /* 横线纸的行距：文字行高和横线共用这一个数，才会对齐 */
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 460px at 50% -8%, #fdfaf2, rgba(253, 250, 242, 0)),
    repeating-linear-gradient(90deg, rgba(120, 95, 55, .028) 0 2px, rgba(120, 95, 55, 0) 2px 6px),
    linear-gradient(#f7f2e7, #eee5d3);
  background-attachment: fixed;
}

/* ── 顶栏 ───────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 22px;
  background: rgba(247, 242, 231, .88);
  backdrop-filter: blur(9px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .16em; }
.brand-sub { margin-left: 10px; font-size: 11.5px; font-weight: 400; letter-spacing: .1em; color: var(--ink-soft); }
.resume { min-width: 0; }
.link-btn {
  padding: 2px 0; font: inherit; font-size: 13px; color: #6b4a24; cursor: pointer;
  background: none; border: none; border-bottom: 1px dashed rgba(107, 74, 36, .45);
}
.link-btn:hover { color: #4e3416; }
.link-btn.danger { color: #8f3a33; border-bottom-color: rgba(143, 58, 51, .4); }
.link-btn.danger:hover { color: #6f251f; }
.search {
  flex: 1; min-width: 170px; max-width: 340px;
  padding: 8px 12px; font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 9px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus { border-color: rgba(107, 74, 36, .45); box-shadow: 0 0 0 3px rgba(171, 116, 64, .14); }
.actions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  padding: 8px 16px; font-family: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 9px;
  white-space: nowrap;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 12px -8px rgba(70, 45, 15, .7); }
.btn-primary { background: linear-gradient(#7e5729, #6a4420); border-color: #5a3818; color: #f8eed8; }
.btn-primary:hover { background: linear-gradient(#8a5f2e, #744b23); }
.btn-danger { background: #8f3a33; border-color: #7a2f29; color: #fbeae6; }
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--ink-soft); cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 8px;
}
.icon-btn:hover { color: var(--ink); background: rgba(84, 62, 30, .09); }

/* ── 书架间 ─────────────────────────────── */
.room { padding: 26px 18px 70px; }
.shelf { max-width: 1060px; margin: 0 auto 40px; }
.shelf-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 6px;
  font-family: var(--serif); letter-spacing: .12em; color: #5f5341;
}
.shelf-name { font-size: 15px; }
.shelf-count { margin-left: 10px; font-family: var(--sans); font-size: 11.5px; letter-spacing: .06em; color: var(--ink-soft); }
.shelf-stage { position: relative; }
.books {
  display: flex; align-items: flex-end; gap: 9px;
  min-height: 252px; padding: 0 18px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.books::-webkit-scrollbar { height: 6px; }
.books::-webkit-scrollbar-thumb { background: rgba(120, 90, 50, .3); border-radius: 3px; }
.board {
  height: 15px; border-radius: 2px 2px 3px 3px;
  background: linear-gradient(#b78147, #8d5c2b 55%, #6f4419);
  box-shadow:
    0 12px 18px -10px rgba(70, 45, 15, .55),
    inset 0 1px 0 rgba(255, 240, 210, .5),
    inset 0 -2px 3px rgba(60, 35, 10, .35);
}
.shelf.drop-hover .board {
  background: linear-gradient(#c79155, #9c6a35 55%, #7c4d1e);
  box-shadow: 0 0 0 3px rgba(171, 116, 64, .35), 0 12px 18px -10px rgba(70, 45, 15, .55);
}
.shelf-hint {
  align-self: center; margin: 0 6px 8px; padding: 9px 14px;
  font: inherit; font-size: 13px; color: #7c6a52; cursor: pointer;
  background: rgba(255, 253, 246, .6);
  border: 1px dashed rgba(124, 106, 82, .5); border-radius: 9px;
}
.shelf-hint:hover { color: #5c4a33; background: #fffdf6; border-color: rgba(92, 74, 51, .7); }

.book {
  position: relative; flex: 0 0 auto;
  width: var(--w); height: var(--h);
  border-radius: 3px 5px 5px 3px;
  cursor: pointer;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 32%, rgba(0, 0, 0, .16) 100%),
    var(--c);
  box-shadow:
    0 7px 13px -8px rgba(60, 35, 10, .65),
    inset 4px 0 0 rgba(255, 255, 255, .14),
    inset -5px 0 7px -5px rgba(0, 0, 0, .45);
  transform-origin: bottom center;
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.2), box-shadow .22s, opacity .2s, filter .2s;
}
.book:hover { transform: translateY(-11px) rotate(-1.1deg); box-shadow: 0 18px 24px -12px rgba(60, 35, 10, .7); }
.book.dragging { opacity: .45; }
.book.dim { opacity: .22; filter: saturate(.4); }
.book.hit { box-shadow: 0 0 0 3px rgba(214, 178, 94, .55), 0 7px 13px -8px rgba(60, 35, 10, .65); }
.book .spine {
  position: absolute; top: 13px; left: 50%; transform: translateX(-50%);
  height: calc(100% - 46px); overflow: hidden;
  writing-mode: vertical-rl;
  font-family: var(--serif); font-size: 13.5px; letter-spacing: .1em; line-height: 1.9;
  color: var(--gold); text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  user-select: none;
}
.book .spine-meta {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; letter-spacing: .04em; white-space: nowrap;
  color: rgba(248, 238, 216, .72); user-select: none;
}
.book .ribbon {
  position: absolute; top: -7px; left: 9px; width: 11px; height: 27px;
  background: linear-gradient(#c8453a, #a52f27);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
  filter: drop-shadow(0 2px 2px rgba(60, 20, 10, .5));
}

/* ── 空书房 ─────────────────────────────── */
.empty { max-width: 560px; margin: 9vh auto 0; padding: 0 16px; text-align: center; }
.empty h2 { margin: 0 0 14px; font-family: var(--serif); font-size: 23px; font-weight: 700; letter-spacing: .1em; }
.empty p { margin: 0 0 22px; font-size: 14.5px; line-height: 2; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-bottom: 24px; }
.chip {
  padding: 7px 15px; font: inherit; font-size: 13.5px; color: #5d4c33; cursor: pointer;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 999px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.chip:hover { transform: translateY(-1px); border-color: rgba(107, 74, 36, .4); box-shadow: 0 6px 12px -9px rgba(70, 45, 15, .8); }
.empty-actions { display: flex; justify-content: center; gap: 10px; }

/* ── 书本视图的公共外壳 ─────────────────── */
.bookview {
  position: fixed; inset: 0; z-index: 40;
  display: flex; justify-content: center;
  padding: 3.4vh 18px;
  background: linear-gradient(rgba(38, 27, 14, .44), rgba(38, 27, 14, .60));
  animation: veil .2s ease;
}
.bookview.hidden { display: none; }
/* 书打开时顶栏隐藏、背景不再滚动（沉浸时正文也不会被页面滚动条压到） */
.book-open { overflow: hidden; }
.book-open .topbar { visibility: hidden; }
@keyframes veil { from { opacity: 0; } to { opacity: 1; } }

/* ── 封面：从架上拿下来的那本书 ──────────── */
.cover-stage {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: 26px; padding: 34px 18px;
  overflow-y: auto;
}
.stage-back {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 16px; color: rgba(248, 238, 216, .92);
  background: rgba(28, 19, 8, .34);
  border: 1px solid rgba(248, 238, 216, .18);
  backdrop-filter: blur(4px);
}
.stage-back:hover { color: #fff; background: rgba(28, 19, 8, .55); border-color: rgba(255, 255, 255, .3); }

.cover-object { cursor: pointer; flex: 0 0 auto; perspective: 900px; }
.cover-face {
  position: relative;
  width: min(330px, 74vw);
  aspect-ratio: 3 / 4.05;
  padding: 46px 30px 30px;
  display: flex; flex-direction: column;
  border-radius: 4px 10px 10px 4px;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, 0) 34%, rgba(0, 0, 0, .18)),
    var(--c);
  box-shadow:
    0 34px 52px -22px rgba(10, 6, 0, .78),
    0 2px 0 rgba(0, 0, 0, .18),
    inset 7px 0 11px -8px rgba(0, 0, 0, .6),
    inset -2px 0 6px rgba(255, 255, 255, .12);
  transition: transform .3s, box-shadow .3s;
}
.cover-object:hover .cover-face {
  transform: translateY(-6px) rotateY(-4deg);
  box-shadow: 0 44px 62px -24px rgba(10, 6, 0, .82), inset 7px 0 11px -8px rgba(0, 0, 0, .6);
}
.cover-top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cover-title {
  max-height: 8.4em; overflow: hidden;
  font-family: var(--serif); font-size: 25px; line-height: 1.55; letter-spacing: .12em;
  color: #f6e9c9; text-align: center; text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
.cover-title-input {
  width: 100%; padding: 4px 6px;
  font-family: var(--serif); font-size: 24px; letter-spacing: .1em; text-align: center;
  color: #f6e9c9; background: rgba(0, 0, 0, .16);
  border: none; border-bottom: 1px dashed rgba(246, 233, 201, .6); outline: none; border-radius: 4px;
}
.cover-rule { width: 46px; height: 1px; margin: 20px 0 18px; background: rgba(246, 233, 201, .5); }
.cover-shelf { font-size: 12px; letter-spacing: .3em; color: rgba(246, 233, 201, .74); }
.cover-bottom { text-align: center; }
.cover-quote {
  max-height: 4.2em; overflow: hidden;
  font-family: var(--serif); font-size: 13.5px; line-height: 2.05;
  color: rgba(246, 233, 201, .66);
}
.cover-meta { margin-top: 14px; font-size: 11px; letter-spacing: .1em; color: rgba(246, 233, 201, .52); }
.cover-ribbon {
  position: absolute; top: -9px; left: 24px; width: 13px; height: 34px;
  background: linear-gradient(#c8453a, #a52f27);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
  filter: drop-shadow(0 2px 3px rgba(20, 5, 0, .6));
}

.cover-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cover-primary { display: flex; gap: 10px; }
/* 写作和阅读是同一本书的两种同等入口：同色、同尺寸，颜色取自这本书的封面（压暗一档保证可读） */
.cover-primary .btn {
  min-width: 96px;
  color: #f8eed8;
  background: var(--fill, #6a4420);
  border-color: var(--edge, #5a3818);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .18);
}
.cover-primary .btn:hover {
  background: var(--fill-hover, #744b23);
  border-color: var(--edge, #5a3818);
  box-shadow: 0 9px 20px -11px rgba(20, 10, 0, .75);
}
.cover-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.cover-stage .link-btn { color: rgba(248, 238, 216, .78); border-bottom-color: rgba(248, 238, 216, .32); }
.cover-stage .link-btn:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, .6); }
.cover-stage .link-btn.danger { color: #e3a79f; border-bottom-color: rgba(227, 167, 159, .4); }
.cover-stage .link-btn.danger:hover { color: #ffc9c2; }

/* ── 摊开：左目录，右横线纸 ─────────────── */
.book-sheet {
  display: flex; flex-direction: column;
  width: min(1040px, 100%); height: 100%;
  background: linear-gradient(#fdfaf3, #f8f2e6);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 34px 70px -26px rgba(20, 10, 0, .65), inset 0 0 0 1px rgba(255, 246, 228, .5);
  animation: sheet .26s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes sheet { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
/* 只有打开书的那一下播入场动画；切页、切模式、新建、删除都不重播，否则每次都像重新打开 */
.book-sheet.no-anim { animation: none; }
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  background: rgba(255, 253, 247, .7);
  border-bottom: 1px solid var(--line);
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 {
  margin: 0; font-family: var(--serif); font-size: 17.5px; letter-spacing: .06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.sheet-title h2:hover { color: #6b4a24; }
.sheet-sub { margin-top: 3px; font-size: 11.5px; letter-spacing: .05em; color: var(--ink-soft); }
.head-tools { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.page-jump {
  display: none;
  max-width: 160px; padding: 5px 7px;
  font-family: inherit; font-size: 12px; color: var(--ink-soft);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 8px; outline: none;
}

/* ── 阅读：只读的排印视图，和写作分开 ───── */
.read-sheet {
  display: flex; flex-direction: column;
  width: min(760px, 100%); height: 100%;
  padding: 26px 52px 20px;
  background: linear-gradient(#fdfbf5, #f9f4e8);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 34px 70px -26px rgba(20, 10, 0, .65), inset 0 0 0 1px rgba(255, 246, 228, .5);
}
.read-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 16px;
  font-size: 11.5px; letter-spacing: .08em; color: var(--ink-soft);
  border-bottom: 1px solid rgba(84, 62, 30, .08);
}
.read-book {
  max-width: 34%; padding: 0; text-align: left;
  font-family: var(--serif); font-size: 12.5px; color: #5f5341;
  background: none; border: none; border-bottom: 1px dashed transparent; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.read-book:hover { color: #6b4a24; border-bottom-color: rgba(107, 74, 36, .45); }
.read-date { flex: 1; text-align: center; white-space: nowrap; }
.read-body { flex: 1; min-height: 0; overflow-y: auto; padding: 30px 0; }
.read-text {
  max-width: 34em; margin: 0 auto;
  font-family: var(--serif); font-size: 17.5px; line-height: 2.15; color: #33302a;
  white-space: pre-wrap; word-break: break-word; user-select: text;
}
.read-empty { font-family: var(--sans); font-size: 14px; color: var(--ink-soft); }
.read-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 14px;
  font-size: 12px; color: var(--ink-soft);
  border-top: 1px solid rgba(84, 62, 30, .08);
}
.read-no { font-size: 13px; letter-spacing: .1em; color: #5f5544; }
.read-mid { display: flex; align-items: center; gap: 12px; }

/* ── 沉浸阅读：只剩纸、字和页脚页码 ───── */
.bookview.immersive { padding: 0; background: linear-gradient(#fbf7ee, #f3ebd9); }
.bookview.immersive .read-sheet {
  width: 100%; height: 100%; max-width: none;
  border-radius: 0; box-shadow: none;
  padding: 9vh 6vw 7vh;
}
.bookview.immersive .read-head,
.bookview.immersive .read-foot,
.bookview.immersive .edge-tab,
.bookview.immersive .drawer { display: none; }
.bookview.immersive .read-body {
  padding: 0;
  scrollbar-width: thin; scrollbar-color: rgba(84, 62, 30, .2) transparent;
}
.bookview.immersive .read-body::-webkit-scrollbar { width: 6px; }
.bookview.immersive .read-body::-webkit-scrollbar-thumb { background: rgba(84, 62, 30, .2); border-radius: 3px; }
.bookview.immersive .read-text { font-size: 18.5px; line-height: 2.25; }
.bookview.immersive .read-page-title { font-size: 22px; }

.immersive-bar {
  position: absolute; top: 18px; left: 50%; z-index: 60;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(252, 249, 241, .94);
  border: 1px solid rgba(84, 62, 30, .16);
  box-shadow: 0 12px 26px -16px rgba(30, 18, 5, .55);
  transform: translate(-50%, -8px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .22s, transform .22s, visibility .22s;
}
.immersive-bar.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); pointer-events: auto; }
.immersive-bar .link-btn { font-size: 12.5px; }
.immersive-hint { font-size: 12px; letter-spacing: .05em; color: var(--ink-soft); }
/* 沉浸时页码常驻页脚：控制条会走，页码不走 */
.immersive-foot {
  position: absolute; left: 0; right: 0; bottom: 24px; z-index: 5;
  text-align: center; pointer-events: none; user-select: none;
  font-family: var(--serif); font-size: 13px; letter-spacing: .14em; color: rgba(95, 85, 68, .74);
  animation: veil .45s ease;
}
.read-nav {
  padding: 7px 14px; white-space: nowrap;
  font: inherit; font-size: 12.5px; color: var(--ink-soft); cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 9px;
}
.read-nav:hover:not(:disabled) { color: var(--ink); background: rgba(171, 116, 64, .1); }
.read-nav:disabled { opacity: .32; cursor: default; }
.read-page-title {
  max-width: 34em; margin: 0 auto 10px;
  font-family: var(--serif); font-size: 20px; font-weight: 400; letter-spacing: .04em; color: #3a352c;
}

/* ── 抽屉：目录（阅读）和备注（两种模式） ── */
.book-sheet, .read-sheet { position: relative; }
.drawer {
  position: absolute; inset: 0; z-index: 25;
  display: none; background: rgba(38, 27, 14, .26);
}
.drawer.open { display: flex; }
.drawer-panel {
  width: min(320px, 88%);
  max-width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(#fdfaf3, #f8f2e6);
  box-shadow: 0 0 40px -12px rgba(20, 10, 0, .5);
}
.drawer-left { margin-right: auto; animation: drawerLeft .18s ease; }
.drawer-right { margin-left: auto; animation: drawerRight .18s ease; }
@keyframes drawerLeft { from { opacity: .5; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes drawerRight { from { opacity: .5; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 15px;
  font-family: var(--serif); font-size: 13.5px; letter-spacing: .06em; color: #5f5341;
  border-bottom: 1px solid var(--line);
}
.drawer-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.drawer-item {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 10px;
  text-align: left; font: inherit; background: none; border: none; border-radius: 8px; cursor: pointer;
}
.drawer-item:hover { background: rgba(171, 116, 64, .1); }
.drawer-item.active { background: rgba(171, 116, 64, .16); box-shadow: inset 2px 0 0 #a8703a; }
.note-input {
  flex: 1; min-height: 0; margin: 12px 14px; padding: 11px 12px;
  font-family: var(--serif); font-size: 14px; line-height: 1.95; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 10px;
  outline: none; resize: none;
}
.note-input:focus { border-color: rgba(107, 74, 36, .4); box-shadow: 0 0 0 3px rgba(171, 116, 64, .12); }
.drawer-foot { padding: 0 16px 14px; font-size: 11px; color: var(--ink-soft); }

/* 页边竖标签：目录（阅读）与备注（两种模式），像从纸边探出来的索引贴 */
.edge-tab {
  position: absolute; top: 50%; z-index: 6;
  width: 28px; height: 96px; padding: 12px 0;
  writing-mode: vertical-rl; text-align: center; letter-spacing: .22em; line-height: 26px;
  font-family: var(--serif); font-size: 12.5px; color: #6b5a44;
  background: linear-gradient(90deg, #fbf6ea, #efe4cf);
  border: 1px solid rgba(84, 62, 30, .18);
  cursor: pointer;
  box-shadow: 0 8px 16px -10px rgba(40, 25, 8, .6);
  transition: background .18s, color .18s, transform .18s;
}
.edge-tab:hover { color: #3f3020; background: linear-gradient(90deg, #fffdf6, #f6eddb); }
.edge-left { left: 0; transform: translateY(-50%); border-left: none; border-radius: 0 8px 8px 0; }
.edge-right { right: 0; transform: translateY(-50%); border-right: none; border-radius: 8px 0 0 8px; }
.edge-left:hover { transform: translateY(-50%) translateX(2px); }
.edge-right:hover { transform: translateY(-50%) translateX(-2px); }
.edge-tab .note-dot { margin: 7px 0 0; }

/* 提示条上的动作按钮（续页后的「撤销」） */
/* 提示条本身不挡操作，但里面的按钮要能点 */
.toast-action {
  pointer-events: auto;
  margin-left: 12px; padding: 4px 12px;
  font: inherit; font-size: 12.5px; color: #f8eed8; cursor: pointer;
  background: rgba(248, 238, 216, .14);
  border: 1px solid rgba(248, 238, 216, .32); border-radius: 7px;
}
.toast-action:hover { background: rgba(248, 238, 216, .26); }

.spread { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px 1fr; }

.toc {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; padding: 16px 14px 16px 18px;
  background: linear-gradient(#f9f4e8, #f3ebd9);
  border-right: 1px solid var(--line);
}
.toc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.spread.toc-hidden { grid-template-columns: 1fr; }
.spread.toc-hidden .toc { display: none; }
.mini-cover {
  flex: 0 0 auto; align-self: flex-start;
  width: 52px; height: 72px; padding: 9px 4px;
  writing-mode: vertical-rl; overflow: hidden;
  font-family: var(--serif); font-size: 10.5px; letter-spacing: .06em; color: #f3e6c8;
  background: linear-gradient(100deg, rgba(255, 255, 255, .16), rgba(0, 0, 0, .18)), var(--c);
  border: none; border-radius: 3px 5px 5px 3px; cursor: pointer;
  box-shadow: 0 6px 10px -6px rgba(60, 35, 10, .7);
  transition: transform .2s;
}
.mini-cover:hover { transform: translateY(-3px); }
.toc-time, .mode-switch {
  display: flex; gap: 3px; padding: 3px;
  background: rgba(84, 62, 30, .07); border-radius: 8px;
}
.mode-switch { flex: 0 0 auto; }
.seg {
  padding: 5px 12px; white-space: nowrap;
  font: inherit; font-size: 12.5px; color: var(--ink-soft);
  background: none; border: none; border-radius: 7px; cursor: pointer;
}
.toc-time .seg { flex: 1; }
.seg.active { background: #fffdf8; color: var(--ink); box-shadow: 0 1px 3px rgba(60, 40, 15, .18); }
.seg:hover:not(.active) { color: var(--ink); }
/* 沉浸是阅读里的一次动作，不是第三种模式：和模式段同一条底，但用细线隔开 */
.mode-sep { flex: 0 0 auto; width: 1px; align-self: stretch; margin: 4px 0; background: rgba(84, 62, 30, .16); }
.mode-action {
  flex: 0 0 auto; padding: 5px 8px; white-space: nowrap;
  font: inherit; font-size: 12.5px; color: #6b4a24;
  background: none; border: none; border-radius: 7px; cursor: pointer;
}
.mode-action:hover { color: #4e3416; background: rgba(171, 116, 64, .13); }
.toc-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.toc-item {
  position: relative;
  display: flex; align-items: flex-start; gap: 8px;
  width: 100%; padding: 8px 9px; text-align: left;
  font: inherit; background: none; border: none; border-radius: 8px;
  cursor: grab;
}
.toc-item:active { cursor: grabbing; }
.toc-item:hover { background: rgba(171, 116, 64, .1); }
.toc-item.active { background: rgba(171, 116, 64, .16); box-shadow: inset 2px 0 0 #a8703a; }
.toc-item.dragging { opacity: .35; }
.toc-item.drop-before::before,
.toc-item.drop-after::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 2px;
  background: #a8703a; border-radius: 2px;
}
.toc-item.drop-before::before { top: -2px; }
.toc-item.drop-after::after { bottom: -2px; }
.toc-no {
  flex: 0 0 24px; padding-top: 1px; text-align: right;
  font-family: var(--serif); font-size: 13px; color: rgba(84, 62, 30, .62);
}
.toc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toc-head {
  font-family: var(--serif); font-size: 13px; line-height: 1.5; color: #4f4636;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc-meta { font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); }
.toc-snippet {
  font-size: 12px; line-height: 1.5; color: rgba(123, 113, 97, .9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-dot {
  display: inline-block; width: 6px; height: 6px; margin-left: 6px;
  vertical-align: middle; border-radius: 50%; background: #b07d3f;
}
.toc-empty { padding: 10px 9px; font-size: 12px; color: var(--ink-soft); }
.toc-new {
  flex: 0 0 auto; margin-top: auto; padding: 8px 10px; text-align: left;
  font: inherit; font-size: 12.5px; color: #6b4a24; cursor: pointer;
  background: none; border: 1px dashed rgba(107, 74, 36, .35); border-radius: 8px;
}
.toc-new:hover { background: rgba(171, 116, 64, .1); }

.leaf {
  display: flex; flex-direction: column;
  min-height: 0; padding: 18px 42px 12px;
  overflow-y: auto;
  background: #fcf8ef;
}
.leaf-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding-bottom: 12px;
  font-size: 11.5px; letter-spacing: .1em; color: var(--ink-soft);
  border-bottom: 1px solid rgba(84, 62, 30, .1);
}
.leaf-title {
  flex: 0 0 auto; width: 100%; margin: 12px 0 0; padding: 0 0 7px;
  font-family: var(--serif); font-size: 17px; letter-spacing: .04em; color: var(--ink);
  background: none; border: none; border-bottom: 1px dashed transparent; outline: none;
}
.leaf-title::placeholder { font-size: 14px; color: rgba(123, 113, 97, .42); }
.leaf-title:hover { border-bottom-color: rgba(84, 62, 30, .16); }
.leaf-title:focus { border-bottom-color: rgba(107, 74, 36, .4); }
.leaf-input {
  flex: 1 1 auto; width: 100%; min-height: 60vh; margin-top: 14px; padding: 0 0 22px;
  font-family: var(--serif); font-size: 16.5px; line-height: var(--rule); color: var(--ink);
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 calc(var(--rule) - 1px),
    rgba(84, 62, 30, .13) calc(var(--rule) - 1px) var(--rule)
  );
  background-attachment: local;
  border: none; outline: none; resize: none;
  overflow: hidden;
}
.leaf-input::placeholder { color: rgba(123, 113, 97, .5); }
.leaf-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0 2px;
  font-size: 12px; color: var(--ink-soft);
  border-top: 1px solid rgba(84, 62, 30, .08);
}
.leaf-meta { font-size: 13px; letter-spacing: .04em; color: #5f5544; }
.leaf-actions { display: flex; align-items: center; gap: 12px; }
.leaf-count.over { color: #a8452f; }
.leaf-foot .link-btn { font-size: 12px; }
.over-split {
  padding: 4px 11px; border-radius: 999px;
  font: inherit; font-size: 12px; color: #a8452f; cursor: pointer;
  background: rgba(168, 69, 47, .07);
  border: 1px solid rgba(168, 69, 47, .28);
}
.over-split:hover { background: rgba(168, 69, 47, .14); }
.over-split[hidden] { display: none; }

.print-all { display: none; }

/* ── 弹层 / 菜单 / 提示 ─────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(38, 27, 14, .4);
  animation: veil .16s ease;
}
.modal {
  width: min(430px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: linear-gradient(#fdfaf3, #f8f2e6);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 26px 60px -22px rgba(20, 10, 0, .6);
  animation: sheet .2s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 15.5px; font-weight: 700; letter-spacing: .08em; }
.modal-body { padding: 16px; font-size: 14px; overflow-y: auto; }
.modal-text { margin: 0; line-height: 1.95; color: #544a3a; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 16px 15px; }
.field { display: block; margin-bottom: 14px; font-size: 12.5px; letter-spacing: .05em; color: var(--ink-soft); }
.field .input { display: block; width: 100%; margin-top: 6px; }
.field-hint { display: block; margin-top: 5px; font-size: 11px; line-height: 1.7; color: var(--ink-soft); }

/* 云同步 */
.sync-status {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 12px; padding: 9px 11px;
  font-size: 12px; color: #5f5341;
  background: rgba(84, 62, 30, .05); border-radius: 10px;
}
.sync-status div { display: flex; justify-content: space-between; gap: 12px; }
.sync-status span { color: var(--ink-soft); }
.sync-status b { font-weight: 600; color: var(--ink); text-align: right; }
.sync-dirty { color: #a8452f !important; }
.sync-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.sync-actions-vertical { flex-direction: column; align-items: stretch; }
.sync-actions-end { justify-content: flex-end; margin-top: 12px; }
.sync-choice-row {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin-top: 12px;
}
.sync-choice-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sync-choice-row .btn { width: 100%; padding: 8px 6px; font-size: 12.5px; }
.sync-code-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.sync-code-row .input { flex: 1; min-width: 0; }
.sync-code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.sync-or { margin: 16px 0 10px; text-align: center; font-size: 11.5px; color: var(--ink-soft); }
.sync-warn {
  margin: 10px 0 0; padding: 9px 11px;
  font-size: 11.5px; line-height: 1.8; color: #7a3a2c;
  background: rgba(168, 69, 47, .07);
  border: 1px solid rgba(168, 69, 47, .16); border-radius: 9px;
}
.sync-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 12px; padding: 10px 12px;
  font-size: 13px; line-height: 1.7; color: #8f3a33;
  background: rgba(168, 69, 47, .1);
  border: 1px solid rgba(168, 69, 47, .3); border-radius: 9px;
}
.sync-notice::before {
  content: '!'; flex: 0 0 18px; height: 18px;
  border-radius: 50%; background: #8f3a33; color: #fff;
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  line-height: 18px; text-align: center;
}
.sync-compare {
  display: flex; flex-direction: column; gap: 6px;
  margin: 12px 0; padding: 10px 12px;
  font-size: 12.5px; background: rgba(84, 62, 30, .045); border-radius: 9px;
}
.sync-compare div { display: flex; justify-content: space-between; gap: 12px; }
.sync-compare span { color: var(--ink-soft); }
.sync-compare b { font-weight: 500; color: var(--ink); text-align: right; }
.sync-cloud {
  margin: 0 0 12px; padding: 9px 11px;
  background: rgba(79, 107, 82, .055);
  border: 1px solid rgba(79, 107, 82, .16); border-radius: 10px;
}
.sync-cloud-head {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: #5f5341;
}
.sync-cloud-head span { color: var(--ink-soft); }
.sync-cloud-head b { font-weight: 600; color: var(--ink); text-align: right; }
.sync-cloud-counts { margin-top: 4px; font-size: 11.5px; color: var(--ink-soft); }
.sync-cloud-line {
  display: flex; gap: 10px; margin-top: 4px;
  font-size: 11.5px; line-height: 1.6;
}
.sync-cloud-line span { flex: 0 0 30px; color: var(--ink-soft); }
.sync-cloud-line b {
  flex: 1; min-width: 0; font-weight: 400; color: #4d4335;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-cloud-loading, .sync-cloud-error { font-size: 12px; color: var(--ink-soft); }
.sync-cloud-error .link-btn { margin-left: 6px; font-size: 12px; }
.sync-cloud-foot {
  margin-top: 9px; padding-top: 8px;
  border-top: 1px solid rgba(79, 107, 82, .16);
}
.sync-cloud-foot .btn { width: 100%; text-align: center; }
.btn-danger-soft {
  color: #8f3a33;
  background: rgba(143, 58, 51, .06);
  border-color: rgba(143, 58, 51, .28);
  font-size: 12.5px; padding: 8px 14px;
}
.btn-danger-soft:hover {
  color: #6f251f;
  background: rgba(143, 58, 51, .13);
  border-color: rgba(143, 58, 51, .4);
  box-shadow: 0 5px 12px -8px rgba(70, 20, 15, .7);
}
.sync-note {
  margin: 10px 0 0;
  font-size: 11px; line-height: 1.75; color: var(--ink-soft);
}
/* 桌面端同步弹窗收紧；手机端在下面改成全屏页 */
.modal.sync-modal { width: min(420px, 100%); }
.modal.sync-modal .modal-body { padding: 14px 16px; }
.modal.sync-modal .field { margin-bottom: 10px; }
.check {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; font-size: 13px; color: #544a3a; cursor: pointer;
}
.field .check { margin-bottom: 5px; }
.check input { width: 15px; height: 15px; accent-color: #6b4a24; }
.input {
  padding: 8px 11px; font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.input:focus { border-color: rgba(107, 74, 36, .45); box-shadow: 0 0 0 3px rgba(171, 116, 64, .13); }
.swatches { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: var(--c); border: 2px solid rgba(255, 255, 255, .55);
  box-shadow: 0 3px 7px -4px rgba(50, 30, 10, .8);
  transition: transform .12s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { outline: 3px solid rgba(246, 233, 201, .95); outline-offset: 2px; }
.ctx-menu {
  position: fixed; z-index: 70; min-width: 190px; padding: 6px;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 18px 40px -16px rgba(30, 18, 5, .5);
  animation: sheet .14s ease;
}
.ctx-item {
  display: block; width: 100%; padding: 8px 11px;
  font: inherit; font-size: 13.5px; color: var(--ink); text-align: left; cursor: pointer;
  background: none; border: none; border-radius: 7px;
}
.ctx-item:hover { background: rgba(171, 116, 64, .14); }
.ctx-item.danger { color: #8f3a33; }
.ctx-item.danger:hover { background: rgba(143, 58, 51, .12); }
.search-hits {
  position: fixed; z-index: 50; top: 62px; right: 22px;
  width: min(390px, calc(100vw - 44px)); max-height: 62vh; overflow-y: auto;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 20px 46px -20px rgba(30, 18, 5, .55);
  animation: sheet .16s ease;
}
.hits-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 13px;
  font-size: 12.5px; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.hit {
  display: block; width: 100%; padding: 10px 13px;
  font: inherit; text-align: left; cursor: pointer;
  background: none; border: none; border-bottom: 1px dashed var(--line);
}
.hit:last-child { border-bottom: none; }
.hit:hover { background: rgba(171, 116, 64, .1); }
.hit b { display: block; margin-bottom: 3px; font-family: var(--serif); font-size: 13.5px; letter-spacing: .05em; color: var(--ink); }
.hit span { display: block; font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); }
.hits-more { padding: 9px 13px; font-size: 12px; color: var(--ink-soft); }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  padding: 9px 17px;
  font-size: 13.5px; color: #f8eed8;
  background: rgba(48, 37, 22, .93); border-radius: 10px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .6);
  opacity: 0; transform: translate(-50%, 10px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 小屏 ───────────────────────────────── */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 9px; }
  .brand-sub { display: none; }
  .search { flex-basis: 100%; max-width: none; order: 9; }
  .actions { flex: 1; justify-content: flex-end; margin-left: 0; flex-wrap: nowrap; }
  .actions .btn { padding: 8px 11px; font-size: 13px; }
  .room { padding: 18px 10px 60px; }
  .books { min-height: 200px; padding: 0 12px; }
  .bookview { padding: 0; }
  .book-sheet { height: 100%; border-radius: 0; }
  .spread { grid-template-columns: 1fr; }
  .toc { display: none; }
  .toc-expand { display: none; }
  .page-jump { display: block; }
  .sheet-sub { display: none; }
  /* 手机上把翻页下拉和模式控件换到第二行，别把书名挤成一条缝 */
  .sheet-head { flex-wrap: wrap; row-gap: 8px; }
  .sheet-head #book-menu { order: 2; }
  .head-tools { order: 3; flex: 1 1 100%; }
  .head-tools .page-jump { flex: 1; max-width: none; }
  .leaf { padding: 14px 32px 10px 18px; }
  .leaf-input { min-height: 52vh; }
  .read-sheet { padding: 18px 32px 14px; border-radius: 0; }
  /* 手机上页脚信息单独一行，翻页按钮放第二行，避免文字换行挤成一团 */
  .read-foot { flex-wrap: wrap; row-gap: 8px; }
  .read-mid { order: -1; flex: 1 1 100%; justify-content: center; }
  .edge-tab { width: 22px; height: 78px; padding: 10px 0; font-size: 11.5px; line-height: 20px; letter-spacing: .16em; }
  .read-date { display: none; }
  .read-head { gap: 8px; }
  .read-book { flex: 1; max-width: none; min-width: 0; }
  /* 手机上把三段控件收紧一点，给书名多留一个字的位置 */
  #mode-switch { gap: 2px; }
  #mode-switch .seg { padding: 5px 10px; }
  #mode-switch .mode-action { padding: 5px 7px; }
  .read-text { font-size: 17px; line-height: 2.05; }
  .bookview.immersive .read-sheet { padding: 8vh 7vw 9vh; }
  .immersive-foot { bottom: 18px; font-size: 12.5px; }
  /* 手机端云同步变成全屏页，而不是压满屏幕的弹窗 */
  .modal-mask.sync-modal { padding: 0; align-items: stretch; }
  .modal.sync-modal { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .modal.sync-modal .modal-head { padding: 14px 18px; }
  .modal.sync-modal .modal-body { flex: 1; min-height: 0; padding: 16px 18px 24px; }
  .drawer-panel { width: min(300px, 92%); }
  .cover-stage { padding: 26px 14px; gap: 20px; }
  .cover-face { padding: 38px 24px 26px; }
  .cover-title { font-size: 22px; }
  .search-hits { top: 56px; right: 10px; }
}

/* ── 打印 ───────────────────────────────── */
@media print {
  body { background: #fff; }
  .topbar, .sheet-head, .toc, .leaf, .read-head, .read-body, .read-foot, .drawer, .edge-tab,
  .immersive-bar, .immersive-foot, .ctx-menu, .toast, .search-hits, .cover-actions, .stage-back { display: none !important; }
  .bookview { position: static; padding: 0; background: none; }
  .book-sheet, .read-sheet {
    width: auto; height: auto; padding: 0; border-radius: 0;
    box-shadow: none; animation: none; background: none; overflow: visible;
  }
  .spread { display: block; }
  .print-all { display: block; padding: 0 12mm; }
  .print-page { break-inside: avoid; margin-bottom: 10mm; }
  .print-title { margin: 0 0 4px; font-family: var(--serif); font-size: 13pt; letter-spacing: .06em; color: #333; }
  .print-meta { margin-bottom: 8px; font-size: 9pt; color: #888; }
  .print-text { font-family: var(--serif); font-size: 11.5pt; line-height: 2; white-space: pre-wrap; }
}
