/* ==========================================================================
   素笺 · FOLIO — 手工纸墨与双页精装阅读系统（纯原生定制样式，零模板框架）
   ========================================================================== */

:root {
  /* 默认：宣白棉浆 300g */
  --desk-bg: #1e1b18;
  --desk-warmth: rgba(214, 182, 136, 0.09);
  --paper-base: #f4efe6;
  --paper-elevated: #faf6ef;
  --paper-edge-1: #e7dfd1;
  --paper-edge-2: #dad0bf;
  --paper-edge-3: #cdc1ad;
  --paper-shadow: rgba(15, 12, 9, 0.46);
  --spine-shadow-strong: rgba(34, 26, 18, 0.16);
  --spine-shadow-mid: rgba(34, 26, 18, 0.065);
  --spine-highlight: rgba(255, 253, 248, 0.62);

  --ink-primary: #221e1b;
  --ink-secondary: #5c534a;
  --ink-muted: #8b8073;
  --ink-faint: rgba(58, 48, 38, 0.13);
  --ink-rule: rgba(58, 48, 38, 0.11);

  --book-accent: #1e4640;
  --book-gold: #b38e59;
  --seal-red: #8e2f26;
  --ribbon-color: #8e2f26;

  --bar-bg: rgba(29, 26, 23, 0.82);
  --bar-border: rgba(235, 223, 204, 0.14);
  --bar-text: #e8dfd1;
  --bar-muted: #a69b8c;

  --reader-font: "Baskerville", "Georgia", "Songti SC", "STSong", "SimSun", "Hiragino Mincho ProN", serif;
  --ui-serif: "Baskerville", "Didot", "Songti SC", "STSong", serif;
  --ui-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;

  --reader-font-size: 19px;
  --reader-line-height: 1.95;

  --paper-grain-url: none;
  --desk-grain-url: none;
}

/* 古籍熟宣（温润茶褐纤维） */
body[data-paper="aged-linen"] {
  --desk-bg: #191512;
  --desk-warmth: rgba(198, 151, 92, 0.1);
  --paper-base: #eae0ce;
  --paper-elevated: #f1e8d8;
  --paper-edge-1: #dcd0ba;
  --paper-edge-2: #cfc1a8;
  --paper-edge-3: #bfb096;
  --spine-shadow-strong: rgba(42, 30, 16, 0.2);
  --spine-shadow-mid: rgba(42, 30, 16, 0.08);
  --spine-highlight: rgba(255, 248, 234, 0.48);

  --ink-primary: #292018;
  --ink-secondary: #5e4f3f;
  --ink-muted: #8a7863;
  --ink-faint: rgba(66, 48, 28, 0.15);
  --ink-rule: rgba(66, 48, 28, 0.13);
  --ribbon-color: #7d2922;
}

/* 沪夜冷杉（美术馆矿物冷灰） */
body[data-paper="fog-slate"] {
  --desk-bg: #15191d;
  --desk-warmth: rgba(148, 175, 190, 0.08);
  --paper-base: #ebedee;
  --paper-elevated: #f3f5f6;
  --paper-edge-1: #dcdfe1;
  --paper-edge-2: #cfd4d7;
  --paper-edge-3: #c1c7cb;
  --spine-shadow-strong: rgba(18, 26, 33, 0.16);
  --spine-shadow-mid: rgba(18, 26, 33, 0.06);
  --spine-highlight: rgba(255, 255, 255, 0.68);

  --ink-primary: #181d22;
  --ink-secondary: #4a545d;
  --ink-muted: #78848e;
  --ink-faint: rgba(28, 40, 52, 0.13);
  --ink-rule: rgba(28, 40, 52, 0.11);
  --ribbon-color: #1e4640;
}

/* 余烬暗金（深夜柔光黑曜羊皮） */
body[data-paper="obsidian-vellum"] {
  --desk-bg: #0c0b0a;
  --desk-warmth: rgba(196, 143, 82, 0.06);
  --paper-base: #191816;
  --paper-elevated: #211f1c;
  --paper-edge-1: #141311;
  --paper-edge-2: #100f0d;
  --paper-edge-3: #0b0a09;
  --paper-shadow: rgba(0, 0, 0, 0.72);
  --spine-shadow-strong: rgba(0, 0, 0, 0.52);
  --spine-shadow-mid: rgba(0, 0, 0, 0.22);
  --spine-highlight: rgba(255, 236, 205, 0.045);

  --ink-primary: #d5cdc0;
  --ink-secondary: #9c9284;
  --ink-muted: #6e665b;
  --ink-faint: rgba(218, 202, 178, 0.13);
  --ink-rule: rgba(218, 202, 178, 0.1);
  --ribbon-color: #b07d44;
}

/* 字体配对切换 */
body[data-font="serif"] {
  --reader-font: "Baskerville", "Georgia", "Songti SC", "STSong", "Hiragino Mincho ProN", serif;
}
body[data-font="sans"] {
  --reader-font: "Baskerville", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
body[data-font="kaiti"] {
  --reader-font: "Georgia", "Kaiti SC", "STKaiti", "Songti SC", serif;
}

/* 作品专属点缀色调 */
body[data-motif="timepiece"] {
  --book-accent: #1e4640;
  --book-gold: #b38e59;
}
body[data-motif="cinder"] {
  --book-accent: #7e2a23;
  --book-gold: #b47e46;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--desk-bg);
  color: var(--ink-primary);
  font-family: var(--ui-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: text;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ==================== 桌面木纹/岩板环境层 ==================== */
.studio-desk {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--desk-bg);
  background-image: var(--desk-grain-url);
  background-size: 280px 280px;
  transition: background-color 0.45s ease;
}

.desk-light {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 78% 65% at 50% 42%, var(--desk-warmth), transparent 72%),
    radial-gradient(circle at 18% 12%, rgba(255, 244, 224, 0.045), transparent 50%);
}

.desk-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.62);
}

/* ==================== 顶部悬浮雅集眉栏 ==================== */
.top-atelier-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 45;
  background: linear-gradient(to bottom, rgba(16, 14, 12, 0.72), rgba(16, 14, 12, 0));
  color: var(--bar-text);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.bar-left, .bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ui-serif);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--bar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

.colophon-book {
  color: var(--bar-text);
  font-weight: 500;
}

.atelier-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--bar-text);
  background: var(--bar-bg);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.2s ease;
}

.atelier-btn:hover {
  border-color: rgba(212, 180, 131, 0.45);
  background: rgba(42, 37, 32, 0.92);
  transform: translateY(-0.5px);
}

.atelier-btn.icon-only {
  width: 32px;
  padding: 0;
  justify-content: center;
}

.atelier-btn.active-mark {
  color: #e6a96b;
  border-color: rgba(212, 165, 106, 0.55);
}

.brand-seal-btn {
  padding-left: 7px;
}

.seal-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--seal-red);
  color: #f7efe4;
  font-family: var(--ui-serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px rgba(255, 240, 224, 0.28);
}

.count-pill {
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--bar-muted);
}

/* 顶部双小说快速切换器 */
.book-Seg-switcher {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  background: var(--bar-bg);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.book-pill-tab {
  height: 26px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: var(--ui-serif);
  letter-spacing: 0.04em;
  color: var(--bar-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.22s ease;
}

.book-pill-tab:hover {
  color: var(--bar-text);
}

.book-pill-tab.active {
  background: rgba(226, 206, 174, 0.16);
  color: #f6efe4;
  box-shadow: inset 0 0 0 1px rgba(212, 180, 131, 0.34);
}

.book-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--book-gold);
  opacity: 0.75;
}

/* 实时监听胶囊 */
.live-watch-pill {
  height: 32px;
  padding: 0 11px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--bar-muted);
  background: var(--bar-bg);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(14px);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ea878;
  box-shadow: 0 0 0 0 rgba(78, 168, 120, 0.55);
  animation: livePulse 2.8s infinite;
}

.pulse-dot.syncing {
  background: #e09f4c;
  animation: syncFlash 0.65s infinite;
}

.pulse-dot.offline {
  background: #a8544e;
  animation: none;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(78, 168, 120, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(78, 168, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(78, 168, 120, 0); }
}

@keyframes syncFlash {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.38); opacity: 0.7; }
}

/* ==================== 核心书案舞台与实体书册 ==================== */
.reading-stage {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  padding: 58px 44px 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.edge-nav {
  position: absolute;
  top: 64px;
  bottom: 32px;
  width: 54px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(235, 223, 204, 0.25);
  font-size: 30px;
  font-family: var(--ui-serif);
  opacity: 0;
  transition: opacity 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.edge-prev { left: 6px; }
.edge-next { right: 6px; }
.edge-label { display: none; }

.edge-nav:hover {
  opacity: 1;
  color: rgba(235, 223, 204, 0.82);
}

.edge-prev:hover .edge-arrow { transform: translateX(-3px); }
.edge-next:hover .edge-arrow { transform: translateX(3px); }

body[data-layout="scroll"] .edge-nav {
  display: none;
}

/* 书册外框：承载书口多层叠纸厚度与投影 */
.book-artifact {
  position: relative;
  width: min(1260px, calc(100vw - 96px));
  height: min(860px, calc(100vh - 86px));
  display: flex;
  align-items: stretch;
  justify-content: center;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-layout="single"] .book-artifact {
  width: min(720px, calc(100vw - 84px));
}

body[data-layout="scroll"] .book-artifact {
  width: min(780px, calc(100vw - 64px));
  height: calc(100vh - 76px);
}

/* 逼真书口叠纸侧边（模拟三百页棉浆毛边层叠） */
.page-stack {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 12px;
  z-index: 1;
  pointer-events: none;
}

.stack-left {
  left: -9px;
  border-radius: 3px 0 0 3px;
  background: repeating-linear-gradient(
    to right,
    var(--paper-edge-3) 0px,
    var(--paper-edge-1) 1.5px,
    var(--paper-edge-2) 3px
  );
  box-shadow: -4px 12px 24px rgba(0, 0, 0, 0.36);
}

.stack-right {
  right: -9px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(
    to left,
    var(--paper-edge-3) 0px,
    var(--paper-edge-1) 1.5px,
    var(--paper-edge-2) 3px
  );
  box-shadow: 4px 12px 24px rgba(0, 0, 0, 0.36);
}

body[data-layout="single"] .stack-left,
body[data-layout="scroll"] .stack-left {
  display: none;
}

/* 主书页纸面本体 */
.book-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background-color: var(--paper-base);
  background-image: var(--paper-grain-url);
  background-size: 220px 220px;
  box-shadow:
    0 26px 68px var(--paper-shadow),
    0 3px 10px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px var(--ink-rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.38s ease, color 0.38s ease;
}

/* 纸张弧面漫射高光 */
.paper-sheen {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.03) 0%,
    var(--spine-highlight) 18%,
    rgba(255, 255, 255, 0) 44%,
    rgba(255, 255, 255, 0) 56%,
    var(--spine-highlight) 82%,
    rgba(0, 0, 0, 0.03) 100%
  );
}

body[data-layout="single"] .paper-sheen,
body[data-layout="scroll"] .paper-sheen {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.035) 0%,
    var(--spine-highlight) 8%,
    rgba(255, 255, 255, 0) 45%,
    rgba(0, 0, 0, 0.02) 100%
  );
}

/* 双页中缝装订压痕与立体阴影 */
.spine-binding {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 88px;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0) 0%,
    var(--spine-shadow-mid) 34%,
    var(--spine-shadow-strong) 49%,
    rgba(0, 0, 0, 0.24) 50%,
    var(--spine-shadow-strong) 51%,
    var(--spine-shadow-mid) 66%,
    rgba(0, 0, 0, 0) 100%
  );
}

.spine-stitch {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    rgba(120, 96, 68, 0.24) 0px,
    rgba(120, 96, 68, 0.24) 8px,
    transparent 8px,
    transparent 16px
  );
}

body[data-layout="single"] .spine-binding,
body[data-layout="scroll"] .spine-binding {
  display: none;
}

/* 丝绸书签带 */
.silk-ribbon {
  position: absolute;
  top: -54px;
  right: 52px;
  z-index: 16;
  color: var(--ribbon-color);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.28));
  transition: top 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
  opacity: 0.42;
  cursor: pointer;
}

.silk-ribbon.pinned {
  top: -4px;
  opacity: 1;
}

/* ==================== 书页眉批与页脚版心 ==================== */
.sheet-header {
  position: relative;
  z-index: 5;
  height: 48px;
  padding: 16px 54px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--ui-serif);
  font-size: 11.5px;
  letter-spacing: 0.09em;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.header-verso, .header-recto {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 44%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body[data-layout="single"] .header-verso,
body[data-layout="scroll"] .header-verso {
  max-width: 35%;
}

body[data-layout="single"] .header-recto,
body[data-layout="scroll"] .header-recto {
  max-width: 60%;
}

.verso-emblem {
  display: inline-flex;
  align-items: center;
  color: var(--book-gold);
}

.recto-meta {
  font-size: 10.5px;
  color: var(--book-gold);
  opacity: 0.9;
}

.sheet-footer {
  position: relative;
  z-index: 5;
  height: 44px;
  padding: 0 54px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font-family: var(--ui-serif);
  font-size: 11.5px;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.footer-verso, .footer-recto {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 140px;
}

.footer-recto {
  justify-content: flex-end;
}

.folio-num {
  font-variant-numeric: oldstyle-nums tabular-nums;
  color: var(--ink-secondary);
  font-weight: 500;
}

.folio-note {
  font-size: 11px;
  opacity: 0.78;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-progress-track {
  flex: 1;
  max-width: 220px;
  height: 1.5px;
  background: var(--ink-rule);
  position: relative;
  overflow: hidden;
}

.footer-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--book-gold);
  transition: width 0.32s ease;
}

/* ==================== 核心正文排版与精确多栏视口 ==================== */
.page-viewport {
  position: relative;
  z-index: 5;
  flex: 1;
  margin: 10px 54px 8px;
  overflow: hidden;
}

.reader-status {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--ink-secondary);
  text-align: center;
  line-height: 1.6;
}

.reader-status[hidden],
.reader-status [hidden] {
  display: none;
}

.reader-refresh { text-decoration: none; }

.shelf-empty {
  color: var(--bar-text);
  padding: 24px 0;
}

body[data-layout="scroll"] .page-viewport {
  overflow-y: auto;
  overflow-x: hidden;
  margin: 8px 18px 8px 54px;
  padding-right: 36px;
}

body[data-layout="scroll"] .page-viewport::-webkit-scrollbar {
  width: 5px;
}
body[data-layout="scroll"] .page-viewport::-webkit-scrollbar-thumb {
  background: var(--ink-faint);
  border-radius: 99px;
}

.columns-track {
  height: 100%;
  column-fill: auto;
  will-change: transform;
  font-family: var(--reader-font);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--ink-primary);
  letter-spacing: 0.022em;
}

.columns-track.glide-transition {
  transition: transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

.columns-track.fade-transition {
  animation: inkCrossfade 0.24s ease;
}

@keyframes inkCrossfade {
  from { opacity: 0.22; }
  to { opacity: 1; }
}

body[data-layout="scroll"] .columns-track {
  height: auto;
  column-count: auto !important;
  column-width: auto !important;
  transform: none !important;
  padding-bottom: 64px;
}

/* ==================== 典藏正文精排细节 ==================== */

/* 章首扉头（Chapter Frontispiece） */
.chapter-frontispiece {
  padding: 18px 0 26px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--ink-rule);
  break-inside: avoid;
  text-align: center;
}

.frontispiece-ornament {
  color: var(--book-gold);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

.frontispiece-label {
  font-family: var(--ui-serif);
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--book-accent);
  margin-bottom: 8px;
  font-weight: 600;
}

body[data-paper="obsidian-vellum"] .frontispiece-label {
  color: var(--book-gold);
}

.frontispiece-title {
  font-family: var(--reader-font);
  font-size: 1.52em;
  line-height: 1.38;
  font-weight: 600;
  color: var(--ink-primary);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.frontispiece-submeta {
  font-family: var(--ui-serif);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

/* 小说段落首行缩进与两端呼吸感 */
.prose-p {
  text-indent: 2em;
  margin-bottom: 0.78em;
  text-align: justify;
  line-break: strict;
  hanging-punctuation: allow-end;
  position: relative;
}

/* 设定卷宗段落不强制缩进 */
.columns-track[data-doc-kind="archive"] .prose-p {
  text-indent: 0;
  margin-bottom: 0.85em;
}

/* 章节小标题 */
.prose-h2 {
  font-size: 1.2em;
  font-weight: 600;
  margin: 1.4em 0 0.65em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--ink-rule);
  color: var(--ink-primary);
  break-after: avoid;
}

.prose-h3 {
  font-size: 1.06em;
  font-weight: 600;
  margin: 1.15em 0 0.45em;
  color: var(--book-accent);
  break-after: avoid;
}

body[data-paper="obsidian-vellum"] .prose-h3 {
  color: var(--book-gold);
}

/* 定制场景转换花饰（替代生硬的 *** / ---） */
.scene-fleuron {
  margin: 1.55em 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--book-gold);
  break-inside: avoid;
}

.scene-fleuron::before,
.scene-fleuron::after {
  content: "";
  width: 52px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-faint), transparent);
}

/* 证物铭牌 / 专有编号（如 `23:17`、`WH-09`） */
.clue-badge {
  display: inline-block;
  text-indent: 0;
  padding: 0.04em 0.42em;
  margin: 0 0.12em;
  border-radius: 3px;
  font-family: "Baskerville", "Didot", "SF Mono", serif;
  font-size: 0.9em;
  letter-spacing: 0.06em;
  color: var(--book-accent);
  background: rgba(179, 142, 89, 0.11);
  border: 1px solid rgba(179, 142, 89, 0.28);
}

body[data-paper="obsidian-vellum"] .clue-badge {
  color: #DFB57B;
  background: rgba(196, 143, 82, 0.14);
}

/* 六维语义括号与专名分色体系（〈兵甲〉/【物品】/『技能』/「结社」/《典籍》） */
.codex-term,
.term-skill {
  color: #5e3682;
  font-weight: 600;
  font-family: "Songti SC", "STSong", "Baskerville", serif;
}
.term-weapon {
  color: #285872;
  font-weight: 600;
  font-family: "Songti SC", "STSong", "Baskerville", serif;
}
.term-item {
  color: #23634e;
  font-weight: 600;
  font-family: "Songti SC", "STSong", "Baskerville", serif;
}
.term-faction {
  color: #7b5324;
  font-weight: 600;
  font-family: "Songti SC", "STSong", "Baskerville", serif;
}
.term-tome {
  color: #7d5a22;
  font-weight: 600;
  font-family: "Songti SC", "STSong", "Baskerville", serif;
}

body[data-paper="obsidian-vellum"] .codex-term,
body[data-paper="obsidian-vellum"] .term-skill { color: #c4a1f0; }
body[data-paper="obsidian-vellum"] .term-weapon { color: #85bede; }
body[data-paper="obsidian-vellum"] .term-item { color: #78c7ab; }
body[data-paper="obsidian-vellum"] .term-faction { color: #ddb47a; }
body[data-paper="obsidian-vellum"] .term-tome { color: #e3be7d; }

/* 语义人物、敌魔、地标与特殊字体精排体系（自适应四色纸张） */
.hl-roan {
  color: #8b2e24;
  font-weight: 600;
}
.hl-evelyn {
  color: #26567c;
  font-weight: 600;
}
.hl-tia {
  color: #2b684b;
  font-weight: 600;
}
.hl-selena {
  color: #5d3a8a;
  font-weight: 600;
}
.hl-foe {
  color: #8c2b20;
  font-weight: 600;
}
.hl-place {
  color: #785027;
  font-weight: 600;
  border-bottom: 1px dotted rgba(120, 80, 39, 0.42);
  padding-bottom: 0.04em;
}
.hl-power, .hl-key {
  color: #945118;
  font-weight: 600;
}
.font-incant {
  font-family: "STKaiti", "Kaiti SC", "Baskerville", "Georgia", serif;
  font-style: italic;
  letter-spacing: 0.07em;
  color: #7a2822;
  font-weight: 500;
}
.font-epistle {
  font-family: "STKaiti", "Kaiti SC", "FangSong", "STFangsong", serif;
  letter-spacing: 0.045em;
  color: var(--ink-secondary);
}
.font-whisper {
  font-family: "Kaiti SC", "STKaiti", serif;
  letter-spacing: 0.03em;
  color: #753c32;
}

body[data-paper="obsidian-vellum"] .hl-roan { color: #e48270; }
body[data-paper="obsidian-vellum"] .hl-evelyn { color: #8cbbe8; }
body[data-paper="obsidian-vellum"] .hl-tia { color: #7ec8a0; }
body[data-paper="obsidian-vellum"] .hl-selena { color: #bea0eb; }
body[data-paper="obsidian-vellum"] .hl-foe { color: #e58374; }
body[data-paper="obsidian-vellum"] .hl-place {
  color: #dbb27c;
  border-bottom-color: rgba(219, 178, 124, 0.36);
}
body[data-paper="obsidian-vellum"] .hl-power,
body[data-paper="obsidian-vellum"] .hl-key { color: #eba965; }
body[data-paper="obsidian-vellum"] .font-incant { color: #e8a472; }
body[data-paper="obsidian-vellum"] .font-epistle { color: #c7bba8; }
body[data-paper="obsidian-vellum"] .font-whisper { color: #dfa194; }

/* 词条悬浮笺注（按类别区分虚线色相与浮窗徽章） */
.has-glossary,
.glossary-ref {
  cursor: help;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.glossary-ref {
  border-bottom: 1px dashed rgba(138, 104, 62, 0.42);
  padding-bottom: 0.04em;
}

.glossary-ref[data-gcat="敌人"],
.glossary-ref[data-gcat="魔物"] {
  color: #7d2c22;
  border-bottom-color: rgba(152, 48, 36, 0.52);
}
.glossary-ref[data-gcat="兵甲"] {
  border-bottom-color: rgba(40, 88, 114, 0.52);
}
.glossary-ref[data-gcat="物品"] {
  border-bottom-color: rgba(35, 99, 78, 0.52);
}
.glossary-ref[data-gcat="技能"],
.glossary-ref[data-gcat="阶位"] {
  border-bottom-color: rgba(94, 54, 130, 0.48);
}

body[data-paper="obsidian-vellum"] .glossary-ref {
  border-bottom-color: rgba(214, 174, 118, 0.36);
}
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="敌人"],
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="魔物"] {
  color: #df8a7c;
  border-bottom-color: rgba(224, 126, 110, 0.46);
}
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="兵甲"] {
  border-bottom-color: rgba(133, 190, 222, 0.46);
}
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="物品"] {
  border-bottom-color: rgba(120, 199, 171, 0.46);
}
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="技能"],
body[data-paper="obsidian-vellum"] .glossary-ref[data-gcat="阶位"] {
  border-bottom-color: rgba(196, 161, 240, 0.46);
}

.has-glossary:hover,
.has-glossary.glossary-active,
.glossary-ref:hover,
.glossary-ref.glossary-active {
  background-color: rgba(179, 142, 89, 0.14);
  border-radius: 2px;
}

.glossary-hover-card {
  position: fixed;
  z-index: 98;
  width: min(344px, calc(100vw - 32px));
  padding: 13px 15px 14px;
  border-radius: 8px;
  background: rgba(27, 23, 19, 0.96);
  border: 1px solid rgba(214, 178, 124, 0.38);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 245, 228, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #f0e7d8;
  pointer-events: none;
  animation: gcardFadeIn 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

.glossary-hover-card[hidden] {
  display: none !important;
}

@keyframes gcardFadeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.gcard-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.gcard-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: rgba(197, 156, 99, 0.2);
  color: #eac793;
  border: 1px solid rgba(197, 156, 99, 0.34);
  flex-shrink: 0;
}

.gcard-badge[data-cat="人物"] {
  background: rgba(146, 86, 52, 0.28);
  color: #f3c09d;
  border-color: rgba(196, 124, 82, 0.38);
}

.gcard-badge[data-cat="敌人"],
.gcard-badge[data-cat="魔物"] {
  background: rgba(162, 42, 34, 0.32);
  color: #f79e94;
  border-color: rgba(214, 74, 62, 0.44);
}

.gcard-badge[data-cat="兵甲"] {
  background: rgba(44, 96, 128, 0.32);
  color: #9ed4f2;
  border-color: rgba(88, 154, 192, 0.42);
}

.gcard-badge[data-cat="物品"] {
  background: rgba(38, 108, 84, 0.3);
  color: #9be3c8;
  border-color: rgba(76, 164, 134, 0.4);
}

.gcard-badge[data-cat="典籍"] {
  background: rgba(154, 114, 46, 0.3);
  color: #f2d494;
  border-color: rgba(202, 156, 76, 0.42);
}

.gcard-badge[data-cat="地点"],
.gcard-badge[data-cat="势力"] {
  background: rgba(138, 102, 56, 0.28);
  color: #e6c697;
  border-color: rgba(186, 142, 84, 0.38);
}

.gcard-badge[data-cat="技能"],
.gcard-badge[data-cat="阶位"] {
  background: rgba(118, 76, 148, 0.28);
  color: #d6b8f2;
  border-color: rgba(154, 108, 188, 0.38);
}

.gcard-title {
  font-family: var(--ui-serif);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fbf5eb;
}

.gcard-meta {
  font-size: 11.5px;
  color: #c8a878;
  letter-spacing: 0.04em;
  margin-bottom: 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(226, 206, 174, 0.13);
}

.glossary-hover-card[data-cat="人物"],
.glossary-hover-card[data-cat="敌人"] {
  width: min(406px, calc(100vw - 32px));
}

.gcard-desc {
  font-family: var(--ui-sans);
  font-size: 12.5px;
  line-height: 1.62;
  color: #dcd1c0;
  text-align: justify;
}

.gcard-field {
  margin-bottom: 5px;
  line-height: 1.56;
}

.gcard-field:last-child {
  margin-bottom: 0;
}

.gcard-field-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #e8c48e;
  background: rgba(197, 156, 99, 0.16);
  border: 1px solid rgba(197, 156, 99, 0.26);
  vertical-align: baseline;
}

/* 引用批注块 */
.prose-quote {
  margin: 1.1em 0;
  padding: 0.72em 1.1em;
  border-left: 2px solid var(--book-gold);
  background: rgba(179, 142, 89, 0.055);
  color: var(--ink-secondary);
  font-size: 0.94em;
  line-height: 1.8;
  break-inside: avoid;
}

.prose-list {
  margin: 0.6em 0 1em 1.35em;
}

.prose-list li {
  margin-bottom: 0.42em;
  line-height: 1.78;
}

/* 设定卷宗表格典雅排版 */
.prose-table-wrap {
  margin: 1em 0 1.3em;
  overflow-x: auto;
  break-inside: avoid;
  border: 1px solid var(--ink-rule);
  border-radius: 4px;
}

.prose-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84em;
  line-height: 1.62;
}

.prose-table th {
  text-align: left;
  padding: 8px 11px;
  background: rgba(179, 142, 89, 0.09);
  border-bottom: 1px solid var(--ink-faint);
  font-weight: 600;
  color: var(--ink-primary);
}

.prose-table td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--ink-rule);
  color: var(--ink-secondary);
  vertical-align: top;
}

/* 实时热修改段落温和呼吸高亮 */
.live-edited-block {
  animation: blockWarmPulse 3.4s ease forwards;
  border-radius: 3px;
}

@keyframes blockWarmPulse {
  0% {
    background-color: rgba(208, 155, 78, 0.24);
    box-shadow: -3px 0 0 var(--book-gold);
  }
  75% {
    background-color: rgba(208, 155, 78, 0.09);
    box-shadow: -2px 0 0 rgba(179, 142, 89, 0.5);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

/* 章尾导读铭牌 */
.chapter-colophon-end {
  margin-top: 2.2em;
  padding: 1.2em 0 0.6em;
  border-top: 1px solid var(--ink-rule);
  text-align: center;
  break-inside: avoid;
}

.end-seal {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--book-gold);
  color: var(--book-gold);
  font-family: var(--ui-serif);
  font-size: 11px;
  letter-spacing: 0.16em;
  margin-bottom: 10px;
}

.next-chap-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 99px;
  font-family: var(--ui-serif);
  font-size: 13px;
  color: var(--ink-secondary);
  border: 1px solid var(--ink-faint);
  transition: all 0.2s ease;
}

.next-chap-link:hover {
  color: var(--ink-primary);
  border-color: var(--book-gold);
  background: rgba(179, 142, 89, 0.08);
}

/* ==================== 3D 双面仿真微卷翻页引擎 ==================== */
.turn-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  perspective: 2500px;
  overflow: hidden;
}

.turn-under-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  background-color: var(--paper-base);
  background-image: var(--paper-grain-url);
  background-size: 220px 220px;
}

.turn-under-left { left: 0; }
.turn-under-right { left: 50%; }

.turn-under-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(12, 9, 6, 0.22);
  opacity: 0;
}

.turn-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}

.turn-leaf-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-color: var(--paper-base);
  background-image: var(--paper-grain-url);
  background-size: 220px 220px;
}

.turn-leaf-back {
  transform: rotateY(180deg);
}

.half-inner-clone {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.leaf-curl-gradient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

.turn-leaf-front .leaf-curl-gradient {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.14) 0%,
    rgba(255, 252, 245, 0.22) 8%,
    rgba(255, 255, 255, 0) 34%,
    var(--spine-shadow-strong) 100%
  );
}

.turn-leaf-back .leaf-curl-gradient {
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.13) 0%,
    rgba(255, 252, 245, 0.24) 9%,
    rgba(255, 255, 255, 0) 36%,
    var(--spine-shadow-strong) 100%
  );
}

/* 双页向前翻动：右页绕中缝向左翻覆 -180deg */
.turn-leaf.anim-forward {
  animation: leafTurnForward 0.52s cubic-bezier(0.32, 0.04, 0.18, 1) forwards;
}
.turn-under-left.shade-forward .turn-under-shade {
  animation: shadeGrowIn 0.52s ease forwards;
}
.turn-under-right.shade-forward .turn-under-shade {
  animation: shadeFadeOut 0.52s ease forwards;
}

/* 双页向后翻动：左页绕中缝向右翻回 0deg */
.turn-leaf.anim-backward {
  transform: rotateY(-180deg);
  animation: leafTurnBackward 0.52s cubic-bezier(0.32, 0.04, 0.18, 1) forwards;
}
.turn-under-left.shade-backward .turn-under-shade {
  animation: shadeFadeOut 0.52s ease forwards;
}
.turn-under-right.shade-backward .turn-under-shade {
  animation: shadeGrowIn 0.52s ease forwards;
}

@keyframes leafTurnForward {
  0%   { transform: rotateY(0deg); box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08); }
  45%  { box-shadow: -26px 0 44px rgba(0, 0, 0, 0.28); }
  100% { transform: rotateY(-180deg); box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05); }
}

@keyframes leafTurnBackward {
  0%   { transform: rotateY(-180deg); box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08); }
  55%  { box-shadow: -26px 0 44px rgba(0, 0, 0, 0.28); }
  100% { transform: rotateY(0deg); box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05); }
}

@keyframes shadeGrowIn {
  0%   { opacity: 0; }
  55%  { opacity: 0.72; }
  100% { opacity: 0; }
}

@keyframes shadeFadeOut {
  0%   { opacity: 0.72; }
  65%  { opacity: 0.12; }
  100% { opacity: 0; }
}

/* 单页模式仿真微卷翻页 */
.single-turn-sheet {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background-color: var(--paper-base);
  background-image: var(--paper-grain-url);
  background-size: 220px 220px;
  overflow: hidden;
  will-change: transform, opacity;
}

.single-turn-sheet.single-forward {
  animation: singleLeafForward 0.46s cubic-bezier(0.26, 0.08, 0.18, 1) forwards;
}

.single-turn-sheet.single-backward {
  animation: singleLeafBackward 0.44s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes singleLeafForward {
  0% { transform: rotateY(0deg); opacity: 1; box-shadow: 12px 0 30px rgba(0,0,0,0.18); }
  75% { opacity: 0.92; }
  100% { transform: rotateY(-108deg); opacity: 0; box-shadow: 40px 0 60px rgba(0,0,0,0.35); }
}

@keyframes singleLeafBackward {
  0% { transform: rotateY(-96deg); opacity: 0.25; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

/* ==================== 左侧卷目与设定档案抽屉 ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 7, 6, 0.56);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: flex-start;
  animation: fadeBackdrop 0.22s ease;
}

.drawer-backdrop[hidden],
.studio-popover[hidden],
.shelf-modal[hidden],
.auth-gate[hidden],
.share-modal[hidden],
.auth-error[hidden],
.atelier-btn[hidden],
.drawer-tab[hidden],
.shelf-path[hidden] {
  display: none !important;
}

@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.atelier-drawer {
  width: min(430px, 90vw);
  height: 100%;
  background: var(--paper-elevated);
  background-image: var(--paper-grain-url);
  background-size: 220px 220px;
  color: var(--ink-primary);
  box-shadow: 18px 0 54px rgba(0, 0, 0, 0.5);
  border-right: 1px solid var(--ink-rule);
  display: flex;
  flex-direction: column;
  animation: slideDrawerIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideDrawerIn {
  from { transform: translateX(-28px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  padding: 24px 24px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-eyebrow {
  font-family: var(--ui-serif);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--book-gold);
  margin-bottom: 4px;
}

.drawer-book-title {
  font-family: var(--ui-serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.close-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink-muted);
}

.close-icon-btn:hover {
  background: var(--ink-rule);
  color: var(--ink-primary);
}

.drawer-world-card {
  margin: 0 24px 14px;
  padding: 11px 13px;
  border-radius: 6px;
  background: rgba(179, 142, 89, 0.08);
  border: 1px solid rgba(179, 142, 89, 0.22);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-secondary);
}

.world-meta-line {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
}
.world-meta-line:last-child { margin-bottom: 0; }
.world-meta-key {
  color: var(--book-gold);
  font-weight: 600;
  flex-shrink: 0;
}

.drawer-tabs {
  margin: 0 24px;
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--ink-rule);
}

.drawer-tab {
  padding: 9px 2px 11px;
  font-size: 13px;
  font-family: var(--ui-serif);
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.drawer-tab span {
  font-size: 11px;
  opacity: 0.75;
  margin-left: 3px;
}

.drawer-tab.active {
  color: var(--ink-primary);
  font-weight: 600;
  border-bottom-color: var(--book-gold);
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.toc-item {
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}

.toc-item:hover {
  background: rgba(179, 142, 89, 0.08);
}

.toc-item.active {
  background: rgba(179, 142, 89, 0.13);
  border-color: rgba(179, 142, 89, 0.34);
}

.toc-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toc-label {
  font-family: var(--ui-serif);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--book-gold);
  font-weight: 600;
}

.toc-words {
  font-size: 11px;
  color: var(--ink-muted);
}

.toc-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--reader-font);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-primary);
}

.toc-excerpt {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fresh-badge {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  background: var(--seal-red);
  color: #f9f2e8;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.drawer-foot {
  padding: 12px 24px;
  border-top: 1px solid var(--ink-rule);
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== 右侧纸墨工坊调校卡 ==================== */
.studio-popover {
  position: fixed;
  top: 56px;
  right: 22px;
  z-index: 58;
  width: 326px;
  animation: popDown 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes popDown {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.studio-card {
  padding: 18px;
  border-radius: 10px;
  background: rgba(26, 23, 20, 0.95);
  border: 1px solid rgba(226, 206, 174, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(20px);
  color: #ebe2d4;
}

.studio-section {
  margin-bottom: 16px;
}
.studio-section:last-child { margin-bottom: 0; }

.studio-label {
  font-family: var(--ui-serif);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: #b7aa97;
  margin-bottom: 9px;
}

.paper-swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.paper-swatch {
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  transition: all 0.18s ease;
}

.paper-swatch:hover {
  border-color: rgba(212, 180, 131, 0.4);
}

.paper-swatch.active {
  border-color: #c89d62;
  background: rgba(200, 157, 98, 0.13);
}

.swatch-chip {
  width: 22px;
  height: 14px;
  border-radius: 3px;
  margin-bottom: 2px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.chip-ivory { background: #f4efe6; }
.chip-linen { background: #e8dcc6; }
.chip-slate { background: #e8ecee; }
.chip-obsidian { background: #1c1a18; border-color: rgba(212, 180, 131, 0.4); }

.swatch-name { font-size: 12.5px; font-weight: 500; }
.swatch-sub { font-size: 10.5px; color: #9c9080; }

.seg-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.seg-btn {
  height: 28px;
  border-radius: 5px;
  font-size: 12px;
  color: #a89c8c;
  transition: all 0.18s ease;
}

.seg-btn.active {
  background: rgba(216, 185, 138, 0.2);
  color: #f7efe4;
  box-shadow: inset 0 0 0 1px rgba(216, 185, 138, 0.34);
}

.slider-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #bfb3a2;
}

.slider-title em {
  font-style: normal;
  color: #e6c089;
  margin-left: 4px;
}

.stepper-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-btn {
  width: 26px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px;
}

input[type="range"] {
  width: 112px;
  accent-color: #c89d62;
}

.sound-toggle-row {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #bfb3a2;
  cursor: pointer;
}

.sound-toggle-row input {
  accent-color: #c89d62;
}

/* ==================== 典藏书匣扉页（双小说精装书封） ==================== */
.shelf-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(14, 12, 10, 0.88);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
  animation: fadeBackdrop 0.28s ease;
}

.shelf-container {
  width: min(1040px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
}

.shelf-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(226, 206, 174, 0.15);
  color: #f3eadc;
}

.shelf-eyebrow {
  font-family: var(--ui-serif);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #c59c63;
  margin-bottom: 6px;
}

.shelf-title {
  font-family: var(--ui-serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.shelf-path {
  margin-top: 5px;
  font-size: 12px;
  color: #968b7c;
  font-family: "SF Mono", Menlo, monospace;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 24px;
}

.folio-card {
  position: relative;
  border-radius: 10px;
  padding: 26px 26px 22px 34px;
  background: linear-gradient(145deg, #25211d, #1a1714);
  border: 1px solid rgba(226, 206, 174, 0.16);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
  color: #efe7da;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.28s ease;
}

.folio-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 12px;
  background: var(--card-spine, #1e4640);
  box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.38), 1px 0 0 rgba(212, 180, 131, 0.28);
}

.folio-card:hover {
  transform: translateY(-4px);
  border-color: rgba(212, 180, 131, 0.46);
}

.folio-card.current-book {
  border-color: rgba(212, 180, 131, 0.55);
}

.folio-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.folio-en {
  font-family: var(--ui-serif);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: #c59c63;
  margin-bottom: 6px;
}

.folio-book-name {
  font-family: var(--ui-serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.folio-genre {
  font-size: 12.5px;
  color: #b5a896;
}

.folio-crest {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(212, 180, 131, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cfb78d;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
}

.folio-logline {
  font-family: var(--reader-font);
  font-size: 13.5px;
  line-height: 1.72;
  color: #cabfae;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.folio-world-box {
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  line-height: 1.55;
  color: #afa290;
}

.folio-card-foot {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #9e9180;
}

.folio-cta {
  color: #e4bd82;
  font-family: var(--ui-serif);
  letter-spacing: 0.06em;
}

/* ==================== 实时热更新通知胶囊 ==================== */
.toast-stack {
  position: fixed;
  bottom: 22px;
  right: 24px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.sync-toast {
  pointer-events: auto;
  padding: 10px 15px;
  border-radius: 8px;
  background: rgba(24, 21, 18, 0.94);
  border: 1px solid rgba(212, 175, 118, 0.38);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  color: #f2e9db;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sync-toast-action {
  padding: 3px 9px;
  border-radius: 4px;
  background: rgba(212, 175, 118, 0.2);
  color: #ecc68c;
  font-size: 11.5px;
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 小屏自适应退化为单页 */
@media (max-width: 960px) {
  .reading-stage {
    padding: 54px 16px 18px;
  }
  .book-artifact {
    width: calc(100vw - 32px) !important;
  }
  .sheet-header, .sheet-footer {
    padding-left: 26px;
    padding-right: 26px;
  }
  .page-viewport {
    margin-left: 26px;
    margin-right: 26px;
  }
  .bar-center {
    display: none;
  }
  .shelf-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px), (max-width: 960px) and (pointer: coarse) {
  body {
    --reader-bar-height: calc(54px + env(safe-area-inset-top));
    --reader-left: max(10px, env(safe-area-inset-left));
    --reader-right: max(10px, env(safe-area-inset-right));
    --reader-bottom: env(safe-area-inset-bottom);
  }

  .top-atelier-bar {
    height: var(--reader-bar-height);
    padding: env(safe-area-inset-top) var(--reader-right) 0 var(--reader-left);
    gap: 6px;
  }

  .bar-left, .bar-right { gap: 5px; }

  .top-atelier-bar .atelier-btn,
  .live-watch-pill,
  .shelf-close-btn,
  .reader-status .atelier-btn {
    min-height: 44px;
    white-space: nowrap;
  }

  .top-atelier-bar .atelier-btn { padding: 0 8px; }
  .top-atelier-bar .icon-only { width: 44px; }
  .live-watch-pill { min-width: 44px; padding: 0 9px; justify-content: center; }

  .live-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .book-Seg-switcher,
  .count-pill,
  .recto-meta,
  .folio-note,
  .shelf-path,
  .shortcut-hint,
  .drawer-world-card,
  #layoutControl [data-layout="spread"] {
    display: none;
  }

  .reading-stage {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: var(--reader-bar-height) var(--reader-right) calc(56px + var(--reader-bottom)) var(--reader-left);
  }

  .book-artifact, body[data-layout="scroll"] .book-artifact {
    width: 100% !important;
    height: 100%;
    min-width: 0;
  }

  .sheet-header, .sheet-footer { padding-inline: 15px; }
  .sheet-header { height: 36px; padding-top: 6px; gap: 8px; }
  .sheet-footer { height: 29px; padding-bottom: 4px; gap: 12px; }
  .footer-verso, .footer-recto { min-width: 0; }

  .verso-title, .recto-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .verso-emblem { flex-shrink: 0; }

  .page-viewport,
  body[data-layout="scroll"] .page-viewport {
    margin: 4px 15px;
    min-height: 0;
    padding-right: 0;
    overscroll-behavior: contain;
  }

  .columns-track { overflow-wrap: anywhere; }
  body[data-layout="scroll"] .columns-track { padding-bottom: 22px; }
  .chapter-frontispiece { padding: 12px 0 17px; margin-bottom: 16px; }
  .frontispiece-title { font-size: 1.35em; }

  .edge-nav, body[data-layout="scroll"] .edge-nav {
    display: flex;
    top: auto;
    bottom: calc(5px + var(--reader-bottom));
    width: auto;
    min-width: 94px;
    height: 44px;
    padding: 0 12px;
    gap: 7px;
    border: 1px solid var(--bar-border);
    border-radius: 8px;
    background: var(--bar-bg);
    color: var(--bar-text);
    opacity: 1;
  }

  .edge-prev { left: var(--reader-left); }
  .edge-next { right: var(--reader-right); }
  .edge-label { display: inline; font: 13px var(--ui-sans); }
  .edge-nav:disabled { opacity: 0.45; cursor: default; }

  .drawer-backdrop {
    padding: env(safe-area-inset-top) var(--reader-right) var(--reader-bottom) env(safe-area-inset-left);
  }
  .atelier-drawer { width: min(100%, 430px); }
  .drawer-head, .drawer-foot { padding-inline: 14px; }
  .drawer-tabs { margin-inline: 14px; gap: 4px; }
  .drawer-tab { flex: 1; min-height: 44px; }
  .drawer-list { min-height: 0; padding-inline: 8px; overscroll-behavior: contain; }
  .close-icon-btn { width: 44px; height: 44px; flex-shrink: 0; }

  .studio-popover {
    top: var(--reader-bar-height);
    right: var(--reader-right);
    bottom: calc(5px + var(--reader-bottom));
    width: min(340px, calc(100% - var(--reader-right) - var(--reader-left)));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #layoutControl { grid-template-columns: repeat(2, 1fr); }
  .seg-btn, .step-btn { min-height: 40px; }
  .step-btn { min-width: 36px; }

  .shelf-modal {
    align-items: flex-start;
    padding: calc(12px + env(safe-area-inset-top)) var(--reader-right) calc(12px + var(--reader-bottom)) var(--reader-left);
  }

  .shelf-container { width: 100%; max-height: 100%; overscroll-behavior: contain; }
  .shelf-header { align-items: center; gap: 8px; margin-bottom: 12px; padding: 0 0 12px; }
  .shelf-eyebrow { display: none; }
  .shelf-title { font-size: 22px; }
  .shelf-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .folio-card { padding: 16px 14px 14px 21px; gap: 10px; }
  .folio-card::before { width: 7px; }
  .folio-book-name { font-size: 21px; }
  .folio-card-top { gap: 8px; }
  .folio-crest { width: 40px; height: 40px; }
  .folio-card-foot { flex-wrap: wrap; gap: 6px; }
  .toast-stack {
    bottom: calc(56px + var(--reader-bottom));
    left: var(--reader-left);
    right: var(--reader-right);
  }
}

/* ==================== 云端凭笺门禁 & 赠阅管理弹窗 ==================== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: radial-gradient(circle at 50% 35%, rgba(44, 36, 28, 0.72), rgba(12, 10, 8, 0.94));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeBackdrop 0.25s ease;
}

.auth-card {
  width: min(440px, 100%);
  padding: 36px 34px 30px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--paper-elevated), var(--paper-base));
  color: var(--ink-primary);
  border: 1px solid rgba(179, 142, 89, 0.35);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.56), inset 0 0 0 1px rgba(255, 252, 246, 0.55);
  text-align: center;
}

.auth-seal {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 9px;
  background: var(--seal-red);
  color: #f8f1e6;
  font-family: var(--ui-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(142, 47, 38, 0.32);
}

.auth-eyebrow {
  font-family: var(--ui-serif);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--book-gold);
  margin-bottom: 6px;
}

.auth-title {
  font-family: var(--ui-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.auth-desc {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-secondary);
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  gap: 8px;
}

.auth-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid rgba(66, 48, 28, 0.22);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
  border-color: var(--seal-red);
  box-shadow: 0 0 0 3px rgba(142, 47, 38, 0.12);
}

.auth-submit-btn {
  height: 42px;
  padding: 0 18px;
  justify-content: center;
  background: #231f1c;
  color: #f4efe6;
  border-color: rgba(179, 142, 89, 0.45);
  font-family: var(--ui-serif);
  font-size: 13.5px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.auth-submit-btn:hover {
  background: var(--seal-red);
  border-color: var(--seal-red);
}

.auth-error {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--seal-red);
}

.auth-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-muted);
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgba(12, 10, 8, 0.84);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  animation: fadeBackdrop 0.24s ease;
}

.share-container {
  width: min(760px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 12px;
  padding: 26px 28px;
  background: linear-gradient(155deg, #24201c, #191613);
  border: 1px solid rgba(212, 180, 131, 0.24);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.56);
  color: #f2e9db;
}

.share-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(226, 206, 174, 0.14);
}

.share-title {
  font-family: var(--ui-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.share-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.share-panel {
  padding: 16px 18px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.share-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.share-section-title {
  font-family: var(--ui-serif);
  font-size: 15px;
  font-weight: 500;
  color: #e6c590;
  margin-bottom: 6px;
}

.share-panel-head .share-section-title {
  margin-bottom: 0;
}

.share-section-note {
  font-size: 12px;
  color: #9f9384;
  margin-bottom: 12px;
}

.share-book-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12.5px;
  color: #e6dccb;
  cursor: pointer;
}

.share-check-pill input {
  accent-color: #c89d62;
}

.share-create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.share-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #b5a896;
}

.share-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.share-input {
  height: 36px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: #f4ece0;
  font-size: 13px;
  outline: none;
}

.share-input:focus {
  border-color: #c89d62;
}

.share-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.share-primary-btn {
  background: rgba(179, 142, 89, 0.22);
  border-color: rgba(212, 180, 131, 0.45);
  color: #f6ead8;
}

.share-inline-status {
  font-size: 12px;
  color: #c89d62;
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-item {
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-item.paused {
  opacity: 0.62;
}

.share-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.share-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: #f4ece0;
}

.share-item-tags {
  font-size: 11.5px;
  color: #a99c8c;
}

.share-item-url {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: #d6b37d;
  word-break: break-all;
}

.share-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-danger-btn {
  color: #e7998f;
  border-color: rgba(231, 153, 143, 0.28);
}

.share-empty {
  padding: 18px 8px;
  text-align: center;
  font-size: 12.5px;
  color: #938778;
}

@media (max-width: 700px), (max-width: 960px) and (pointer: coarse) {
  .auth-card {
    padding: 28px 20px 24px;
  }

  .auth-form {
    flex-direction: column;
  }

  .share-modal {
    align-items: flex-start;
    padding: calc(12px + env(safe-area-inset-top)) var(--reader-right) calc(12px + var(--reader-bottom)) var(--reader-left);
  }

  .share-container {
    width: 100%;
    max-height: 100%;
    padding: 18px 14px;
  }

  .share-field-row {
    grid-template-columns: 1fr;
  }

  .share-item-head,
  .share-item-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 370px) {
  .brand-seal-btn .seal-stamp { display: none; }
}
