/* ==========================================================================
   StoryComet 风格体系 · 小小拾光 3D 绘本书桌
   深邃午夜蓝、温润橡木、精装布纹与羊皮纸质感
   ========================================================================== */

/* 1. 字体配置：童趣与绘本专用的圆润字体 */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/fredoka-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/fredoka-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/fredoka-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/baloo-2-600.woff2') format('woff2');
}

/* 2. 核心调色板与弹簧缓动曲线 */
:root {
  --midnight: #141a33;
  --navy: #1d2649;
  --navy-soft: #273361;
  --cream: #f8f0dd;
  --paper: #f4ebd9;
  --paper-card: #fdf8ed;
  --ink: #2c2a3e;
  --ink-soft: #5e5772;
  --ink-muted: #88829c;
  --honey: #d9a45c;
  --oak: #c98d4f;
  --gold: #e6bd66;
  --gold-glow: #ffd777;
  --coral: #e8604a;
  --sky: #8fb8e6;
  --shelf-wood: #b88554;
  --shadow-deep: 0 12px 32px rgba(10, 14, 30, 0.45);
  --shadow-soft: 0 6px 18px rgba(12, 16, 32, 0.28);
  --shadow-wood: 0 5px 9px rgba(5, 8, 26, 0.44);
  --spring: cubic-bezier(0.2, 1.35, 0.3, 1);
  --soft: cubic-bezier(0.22, 0.8, 0.2, 1);
  --ui-font: "Fredoka", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --heading-font: "Baloo 2", "Fredoka", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--midnight);
  color: var(--cream);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

/* 3. 动画：StoryComet 标志性的 HUD 登场弹簧动画 */
.hud {
  animation: hud-pop 700ms var(--spring) both;
  animation-delay: calc(var(--i, 0) * 80ms + 120ms);
}
@keyframes hud-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 189, 102, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(230, 189, 102, 0); }
}

/* 4. 木质控件体系：真实木质圆纽与药丸按钮 */
.round-button, button.round {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: url("assets/ui/round.png") center / 100% 100% no-repeat;
  display: inline-grid;
  place-items: center;
  box-shadow: var(--shadow-wood);
  color: var(--ink);
  font-weight: 700;
  font-size: 22px;
  transition: transform 260ms var(--spring), box-shadow 260ms var(--soft);
}
.round-button:hover, button.round:hover {
  transform: translateY(-3px) scale(1.08) rotate(-3deg);
  box-shadow: 0 9px 16px rgba(5, 8, 26, 0.55);
}
.round-button:active, button.round:active {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 2px 5px rgba(5, 8, 26, 0.4);
  transition-duration: 80ms;
}

.pill-button, button.primary, .book-toolbar button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 24px;
  border: 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  background: transparent;
  border-image: url("assets/ui/pill.png") 112 fill / 26px / 0 stretch;
  border-radius: 999px;
  box-shadow: var(--shadow-wood);
  transition: transform 260ms var(--spring), box-shadow 260ms var(--soft), color 200ms;
  white-space: nowrap;
}
.pill-button:hover, button.primary:hover, .book-toolbar button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 9px 15px rgba(5, 8, 26, 0.45);
}
.pill-button:active, button.primary:active,
.pill-button[aria-pressed="true"], button.primary[aria-pressed="true"],
.book-toolbar button:active {
  border-image-source: url("assets/ui/pill-pressed.png");
  color: var(--cream);
  transform: translateY(2px) scale(0.97);
  box-shadow: 0 2px 5px rgba(5, 8, 26, 0.35);
  transition-duration: 80ms;
}

button.primary {
  min-height: 52px;
  padding: 10px 28px;
  font-size: 17px;
  font-weight: 700;
  color: #2b1f0c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* 5. 顶部导航 Header：深夜星空微透明磨砂 + 金色徽标 */
header {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(20, 26, 51, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(230, 189, 102, 0.22);
  box-shadow: 0 4px 20px rgba(8, 12, 28, 0.5);
  z-index: 20;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--gold);
  text-decoration: none;
  font-family: var(--heading-font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(230, 189, 102, 0.25);
  transition: transform 250ms var(--spring);
}
.brand:hover {
  transform: scale(1.02);
}
.brand-symbol {
  width: 32px;
  height: 32px;
  background: url("assets/ui/moon.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 6px rgba(255, 230, 130, 0.45));
}
.brand small {
  font-family: var(--ui-font);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #b8b2cd;
  font-weight: 400;
  padding-left: 6px;
  border-left: 1px solid rgba(230, 189, 102, 0.28);
}
.account {
  display: flex;
  gap: 12px;
  align-items: center;
}
.account button {
  min-height: 40px;
  padding: 6px 16px;
  font-size: 14px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(230, 189, 102, 0.35);
  border-radius: 999px;
  transition: all 240ms var(--soft);
}
.account button:hover {
  background: rgba(230, 189, 102, 0.18);
  border-color: var(--gold);
  transform: translateY(-2px);
  color: #fff;
}
#accountBtn {
  background: linear-gradient(135deg, rgba(230, 189, 102, 0.22), rgba(201, 141, 79, 0.28));
  font-weight: 600;
}
#quota {
  font-size: 12px;
  background: rgba(232, 96, 74, 0.22);
  border: 1px solid rgba(232, 96, 74, 0.45);
  color: #ffb8aa;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
}
#libraryToggle {
  display: none;
  font-size: 24px;
  color: var(--gold);
}

/* 6. 主体布局与侧边书架 Aside */
main {
  display: flex;
  min-height: 0;
  flex: 1;
  position: relative;
}
aside {
  width: 220px;
  flex: 0 0 220px;
  padding: 24px 18px 20px;
  background: linear-gradient(180deg, #1b2345 0%, #161b36 100%);
  border-right: 1px solid rgba(230, 189, 102, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 15;
  box-shadow: 4px 0 24px rgba(6, 9, 22, 0.5);
}
.library-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--heading-font);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(230, 189, 102, 0.28);
}
.library-heading button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(230, 189, 102, 0.15);
  border: 1px solid rgba(230, 189, 102, 0.4);
  color: var(--gold);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform 200ms var(--spring), background 200ms;
}
.library-heading button:hover {
  background: var(--gold);
  color: var(--midnight);
  transform: scale(1.15) rotate(90deg);
}

#myBooks {
  overflow-y: auto;
  max-height: 48%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
#myBooks::-webkit-scrollbar { width: 5px; }
#myBooks::-webkit-scrollbar-thumb { background: rgba(230, 189, 102, 0.25); border-radius: 4px; }

.book-item {
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #ded9ec;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 220ms var(--soft);
}
.book-item:hover {
  background: rgba(230, 189, 102, 0.12);
  border-color: rgba(230, 189, 102, 0.3);
  transform: translateX(3px);
  color: #fff;
}
.book-item.active {
  background: linear-gradient(135deg, rgba(230, 189, 102, 0.25), rgba(201, 141, 79, 0.3));
  border: 1px solid var(--gold);
  color: #fff;
  box-shadow: 0 4px 12px rgba(230, 189, 102, 0.15);
}
.book-item b {
  background: linear-gradient(135deg, #d9a45c, #c98d4f);
  color: #2b1f0c;
  width: 24px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px 2px 2px 4px;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.3);
  flex: none;
}
.book-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.book-item small {
  flex: none;
  font-size: 10px;
  color: var(--gold);
  opacity: 0.85;
}
.book-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.book-row .book-item { flex: 1; min-width: 0; }
.book-delete {
  flex: none;
  width: 32px;
  border-radius: 8px;
  font-size: 16px;
  color: #a39bb8;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: color 180ms, background 180ms;
}
.book-delete:hover, .book-delete:focus-visible {
  color: #ffb4a4;
  background: rgba(214, 96, 72, 0.18);
}

.storage-label {
  font-size: 11px;
  color: #928cb0;
  line-height: 1.5;
  margin: 0;
}
.examples {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px dashed rgba(230, 189, 102, 0.22);
}
.section-label {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.05em;
}
.example-card {
  padding: 8px;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(230, 189, 102, 0.25);
  border-radius: 8px;
  transition: all 220ms var(--soft);
}
.example-card:hover {
  background: rgba(230, 189, 102, 0.15);
  border-color: var(--gold);
  transform: translateY(-2px);
}
.example-card img {
  width: 44px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  flex: none;
}
.example-card span {
  font-size: 12px;
  line-height: 1.5;
  color: var(--cream);
  font-weight: 600;
}
.example-card small {
  display: block;
  color: #a7a1be;
  font-size: 10px;
  font-weight: 400;
  margin-top: 3px;
}
#copyExample {
  font-size: 12px;
  color: var(--gold);
  border: 1px solid rgba(230, 189, 102, 0.4);
  padding: 8px;
  border-radius: 6px;
  background: rgba(230, 189, 102, 0.1);
  transition: background 200ms;
}
#copyExample:hover {
  background: var(--gold);
  color: var(--midnight);
}

/* 7. 3D 绘本书桌 Desk Stage */
.desk {
  flex: 1;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #1e264f 0%, #11152a 75%, #0d1020 100%);
}
#book3d {
  position: absolute;
  inset: 0;
  z-index: 0;
}
#book3d canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#book3d.grabbing canvas {
  cursor: grabbing;
}

/* 顶部状态条与书名 */
.desk-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  position: relative;
  z-index: 10;
  pointer-events: none;
  gap: 16px;
}
.desk-top button {
  pointer-events: auto;
  background: rgba(26, 33, 64, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(230, 189, 102, 0.35);
  color: var(--cream);
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(5, 8, 20, 0.4);
  transition: all 240ms var(--spring);
}
.desk-top button:hover {
  border-color: var(--gold);
  background: rgba(35, 45, 85, 0.9);
  transform: translateY(-2px);
  color: #fff;
}

/* 顶部显眼的返回书架大胶囊按钮 */
.top-shelf-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 20px !important;
  min-height: 44px;
  background: linear-gradient(135deg, rgba(230, 189, 102, 0.28), rgba(201, 141, 79, 0.35)), rgba(20, 26, 51, 0.85) !important;
  border: 1.5px solid var(--gold) !important;
  border-radius: 999px !important;
  color: #fff7e6 !important;
  font-family: var(--ui-font);
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.38), 0 0 14px rgba(230, 189, 102, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
  cursor: pointer;
  flex: none;
}
.top-shelf-btn:hover {
  background: linear-gradient(135deg, rgba(255, 215, 119, 0.45), rgba(217, 164, 92, 0.55)), rgba(30, 38, 72, 0.9) !important;
  border-color: #ffe68a !important;
  transform: translateY(-2px) scale(1.03) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 22px rgba(255, 215, 119, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  color: #fff !important;
}
.top-shelf-btn:active {
  transform: translateY(1px) scale(0.97) !important;
}
.top-shelf-btn .back-arrow {
  font-size: 20px;
  line-height: 1;
  color: var(--gold);
  margin-right: -2px;
  transition: transform 200ms var(--spring);
}
.top-shelf-btn:hover .back-arrow {
  transform: translateX(-3px);
}
.top-shelf-btn .shelf-icon {
  font-size: 15px;
  color: #f7e2a9;
}
.top-shelf-btn .btn-text {
  font-weight: 700;
}

.book-meta-hud {
  display: flex;
  align-items: center;
  gap: 12px;
}
#renameBook {
  font-family: var(--heading-font);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#renameBook small {
  font-size: 13px;
  color: #b0a9c8;
}
#saveStatus {
  display: inline-block;
  font-size: 11px;
  margin: 0;
  color: #a49ec0;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
#overviewBtn {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}

/* 悬浮新手引导气泡 */
.guide {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  text-align: center;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-card);
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  box-shadow: 0 8px 24px rgba(5, 8, 20, 0.35);
  white-space: nowrap;
  pointer-events: none;
  animation: hud-pop 600ms var(--spring);
}
.guide small {
  display: block;
  font-size: 11px;
  margin-top: 3px;
  color: var(--ink-soft);
}

/* 3D 舞台居中翻页导航按钮 */
.book-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  padding: 0 4%;
  z-index: 2;
}
button.round#prev, button.round#next {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  font-size: 32px;
  line-height: 1;
  color: #2e2311;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
#fallback {
  margin: auto;
  background: var(--paper-card);
  color: var(--ink);
  padding: 24px 32px;
  border-radius: 14px;
  border: 1px solid var(--gold);
  pointer-events: auto;
  box-shadow: var(--shadow-deep);
  max-width: 400px;
  text-align: center;
}

/* 8. 底部操作工坊 Work Area */
.work-area {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  width: min(680px, calc(100% - 40px));
  margin: 0 auto 16px;
  pointer-events: none;
  transition: opacity 300ms var(--soft), transform 400ms var(--spring);
}

/* 书架模式（首屏）下的轻量展陈状态：隐藏底部编辑工坊与翻页圆钮，视线完全聚焦在双层书架上 */
#book3d[data-mode="shelf"] ~ .work-area,
#book3d[data-mode="picking"] ~ .work-area {
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px);
}
#book3d[data-mode="shelf"] ~ .book-stage button.round,
#book3d[data-mode="picking"] ~ .book-stage button.round {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}
#book3d[data-mode="shelf"] ~ .desk-top,
#book3d[data-mode="picking"] ~ .desk-top {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
}
#book3d[data-mode="shelf"] ~ .guide {
  top: 28px;
  background: rgba(253, 248, 237, 0.95);
  border: 2px solid var(--gold);
  box-shadow: 0 0 25px rgba(255, 215, 119, 0.4), 0 8px 32px rgba(0, 0, 0, 0.45);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 28px;
  letter-spacing: 0.03em;
}
#backToShelfBtn {
  background: linear-gradient(135deg, rgba(230, 189, 102, 0.35), rgba(201, 141, 79, 0.45)) !important;
  color: #2b1f0c !important;
  font-weight: 700 !important;
  border: 1px solid var(--gold) !important;
}

.pulse-highlight {
  animation: pulse-card 1s ease-in-out infinite alternate;
}
@keyframes pulse-card {
  0% { transform: scale(1) rotate(-3deg); box-shadow: 0 0 0 0 rgba(230, 189, 102, 0.8); }
  100% { transform: scale(1.08) rotate(0deg); box-shadow: 0 0 22px 6px rgba(230, 189, 102, 0.9); }
}

.work-area button, .work-area select, .work-area label {
  pointer-events: auto;
}

/* 工具栏导航按钮组 */
.book-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.book-toolbar button {
  min-height: 40px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(5, 8, 20, 0.3);
}
.book-toolbar > span {
  background: rgba(22, 28, 56, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(230, 189, 102, 0.35);
  color: var(--gold);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 紧凑编辑器面板（羊皮纸纸艺风格） */
.compact-editor {
  display: grid;
  grid-template-columns: 106px 1fr;
  gap: 16px;
  height: 116px;
}
.reference {
  position: relative;
  padding: 6px;
  background: #fffdf7;
  box-shadow: 0 8px 20px rgba(5, 8, 20, 0.45);
  border-radius: 6px;
  border: 1px solid #e2d9c5;
  transform: rotate(-3deg);
  overflow: hidden;
  min-height: 0;
  transition: transform 260ms var(--spring), box-shadow 260ms;
}
.reference:hover {
  transform: rotate(0deg) scale(1.05);
  box-shadow: 0 12px 28px rgba(5, 8, 20, 0.55);
}
.reference img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 3px;
}
.reference #uploadHint {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 28px;
  color: var(--oak);
  gap: 4px;
  font-weight: 700;
}
.reference small {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.change-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  background: rgba(20, 26, 51, 0.85);
  color: var(--gold);
  font-size: 10px;
  padding: 3px 0;
  font-weight: 600;
}

/* 效果配置主面板 */
.effect-panel {
  background: var(--paper-card);
  padding: 14px 20px 10px;
  box-shadow: 0 10px 30px rgba(5, 8, 20, 0.45);
  border-radius: 12px;
  border: 1px solid rgba(230, 189, 102, 0.45);
  position: relative;
}
/* 贴纸胶带小装饰 */
.effect-panel:before {
  content: '';
  position: absolute;
  top: -8px;
  left: 38%;
  width: 64px;
  height: 16px;
  background: rgba(230, 189, 102, 0.45);
  backdrop-filter: blur(2px);
  transform: rotate(-2deg);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.effect-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.effect-top button {
  font-size: 12px;
  color: var(--oak);
  font-weight: 600;
}
.effect-bottom {
  display: flex;
  gap: 12px;
  align-items: center;
}
.effect-bottom label {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid #dcd3be;
  border-radius: 8px;
  padding: 2px 10px;
}
select {
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
  padding: 8px 0;
  outline: none;
}
.editor-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 8px;
  font-weight: 600;
}
.editor-foot button {
  font-size: 11px;
  padding: 2px 6px;
  color: var(--oak);
  font-weight: 700;
}
.scene-note {
  text-align: center;
  font-size: 11px;
  color: #aba4c5;
  margin-top: 8px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 9. 古典羊皮纸弹窗与复古金边转角 Corner Ornaments */
dialog {
  border: 2px solid var(--gold);
  border-radius: 16px;
  background: var(--paper-card);
  width: min(720px, 92vw);
  max-height: 88dvh;
  color: var(--ink);
  padding: 32px 36px;
  box-shadow: 0 25px 90px rgba(5, 8, 25, 0.75);
  position: relative;
  overflow: visible;
}
dialog::backdrop {
  background: rgba(10, 14, 32, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* StoryComet 标志性的古典金角标 */
i.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  background: url("assets/ui/corner.png") center / contain no-repeat;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(180, 130, 40, 0.35));
}
i.corner.tl { top: -2px; left: -2px; }
i.corner.tr { top: -2px; right: -2px; transform: scaleX(-1); }
i.corner.bl { bottom: -2px; left: -2px; transform: scaleY(-1); }
i.corner.br { bottom: -2px; right: -2px; transform: scale(-1, -1); }

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(201, 141, 79, 0.35);
}
.dialog-header h2 {
  font-family: var(--heading-font);
  font-size: 22px;
  margin: 0;
  color: var(--ink);
}
.dialog-header button {
  font-size: 26px;
  color: var(--ink-soft);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 200ms var(--spring), background 200ms;
}
.dialog-header button:hover {
  background: rgba(232, 96, 74, 0.15);
  color: var(--coral);
  transform: rotate(90deg) scale(1.1);
}
dialog p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-soft);
}
.form-stack {
  display: grid;
  gap: 16px;
}
input, textarea {
  background: #fffdf9;
  border: 1px solid #dcd4c0;
  border-radius: 8px;
  padding: 12px 16px;
  width: 100%;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 200ms, box-shadow 200ms;
}
input:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(230, 189, 102, 0.25);
  outline: none;
}
textarea {
  height: 120px;
  resize: vertical;
}
.error {
  color: var(--coral);
  font-size: 13px;
  min-height: 20px;
  font-weight: 600;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 20px;
}
.modal-actions button:not(.primary) {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid #dcd4c0;
  color: var(--ink-soft);
  font-weight: 600;
}
.modal-actions button:not(.primary):hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

/* 10. 36 面缩略图网格与裁剪窗口 */
.page-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}
.thumb {
  position: relative;
  aspect-ratio: 3/4;
  padding: 0;
  border: 2px dashed #d5ceba;
  background: #fffbf2;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: transform 220ms var(--spring), border-color 200ms, box-shadow 200ms;
}
.thumb:hover {
  transform: translateY(-4px) scale(1.05);
  border-color: var(--gold);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(253, 248, 237, 0.92);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  padding: 4px;
  text-align: center;
}
.thumb.selected {
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px rgba(230, 189, 102, 0.35);
}
.thumb.empty {
  color: #beb7a2;
  font-size: 26px;
  display: grid;
  place-items: center;
}

.crop-box {
  width: min(300px, 64vw);
  aspect-ratio: 3/4;
  position: relative;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  margin: auto;
  border: 2px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  cursor: move;
}
.crop-box img {
  position: absolute;
  max-width: none;
  user-select: none;
  pointer-events: none;
}
.crop-box:after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background:
    linear-gradient(90deg, transparent 33%, rgba(255, 255, 255, 0.4) 33%, rgba(255, 255, 255, 0.4) 33.3%, transparent 33.3%, transparent 66%, rgba(255, 255, 255, 0.4) 66%, rgba(255, 255, 255, 0.4) 66.3%, transparent 66.3%),
    linear-gradient(transparent 33%, rgba(255, 255, 255, 0.4) 33%, rgba(255, 255, 255, 0.4) 33.3%, transparent 33.3%, transparent 66%, rgba(255, 255, 255, 0.4) 66%, rgba(255, 255, 255, 0.4) 66.3%, transparent 66.3%);
  pointer-events: none;
}
.range-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  font-weight: 600;
  color: var(--ink);
}
.range-row input {
  flex: 1;
  accent-color: var(--oak);
}

.auth-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid #e7decb;
}
.auth-tabs button {
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 200ms;
}
.auth-tabs .active {
  border-color: var(--oak);
  color: var(--oak);
}

/* 11. Toast 提示 */
#toast {
  position: fixed;
  z-index: 100;
  bottom: 32px;
  left: 50%;
  transform: translate(-50%, 20px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  background: rgba(20, 26, 51, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--cream);
  border: 1px solid var(--gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 12px 24px;
  border-radius: 999px;
  max-width: 90vw;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 300ms var(--spring), opacity 300ms var(--soft);
}
#toast.show {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

/* 12. 响应式布局优化 */
@media (max-width: 860px) {
  aside {
    width: 170px;
    flex-basis: 170px;
    padding: 18px 12px;
  }
  .brand small { display: none; }
  .work-area { width: calc(100% - 24px); }
  .compact-editor { grid-template-columns: 86px 1fr; }
  button.round#prev, button.round#next { width: 48px; height: 48px; font-size: 24px; }
}
@media (max-width: 640px) {
  header {
    height: 54px;
    flex-basis: 54px;
    padding: 0 16px;
  }
  .brand { font-size: 18px; }
  .brand-symbol { width: 26px; height: 26px; }
  .account { gap: 8px; }
  .account button { font-size: 12px; padding: 5px 10px; }
  #libraryToggle { display: block; }
  aside {
    display: none;
    position: absolute;
    top: 54px;
    bottom: 0;
    left: 0;
    width: 210px;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.6);
  }
  aside.open { display: flex; }
  .desk-top { padding: 12px 16px; }
  .top-shelf-btn {
    padding: 6px 12px !important;
    min-height: 36px;
    font-size: 12px !important;
    gap: 4px !important;
  }
  #renameBook { font-size: 16px; }
  .guide { top: 80px; font-size: 12px; padding: 8px 14px; }
  .compact-editor { grid-template-columns: 78px 1fr; gap: 10px; height: 108px; }
  .work-area { margin-bottom: 8px; }
  .book-toolbar { margin-bottom: 8px; gap: 4px; }
  .book-toolbar button { min-height: 34px; padding: 4px 12px; font-size: 11px; }
  .page-grid { grid-template-columns: repeat(3, 1fr); }
  dialog { padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    transition: none !important;
    animation: none !important;
  }
}

/* 阅读视角独立于翻页手势，原生滑杆支持触摸及键盘操作。 */
.reading-angle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 10px;
  padding: 8px 14px 12px;
  border: 1px solid rgba(230, 189, 102, 0.4);
  border-radius: 16px;
  background: rgba(22, 28, 56, 0.94);
  color: #f8f0dd;
  font-size: 12px;
  pointer-events: auto;
}
#book3d[data-mode="open"] ~ .reading-angle:not([hidden]) { display: flex; }
.reading-angle legend { padding: 0 6px; color: var(--gold); }
.reading-angle label { display: flex; align-items: center; gap: 6px; }
.reading-angle output { min-width: 3ch; font-variant-numeric: tabular-nums; }
.reading-angle input { width: clamp(65px, 9vw, 120px); min-height: 28px; accent-color: var(--gold); }
.reading-angle button { min-height: 32px; padding: 4px 12px; }
.reading-angle :focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.reading-angle { position: absolute; top: 100px; right: 16px; z-index: 5; width: 180px; }
#book3d[data-mode="open"] ~ .guide { display: none; }
@media (max-width: 900px) {
  .reading-angle { position: relative; top: auto; right: auto; width: fit-content; margin: 0 auto 8px; flex-shrink: 0; }
}

@media (min-width: 901px) {
  .reading-angle { top: 80px; width: 196px; gap: 4px; padding: 4px 10px 8px; }
  .reading-angle label { white-space: nowrap; }
  .reading-angle input { width: 100px; }
}

#book3d[data-mode="shelf"] ~ .book-stage button.round,
#book3d[data-mode="picking"] ~ .book-stage button.round,
#book3d[data-mode="shelf"] ~ .work-area,
#book3d[data-mode="picking"] ~ .work-area,
#book3d[data-mode="shelf"] ~ .desk-top,
#book3d[data-mode="picking"] ~ .desk-top { visibility: hidden; }

.reading-angle input[type="range"] { padding: 0; border: 0; height: 24px; min-height: 24px; background: transparent; }

/* 手机以一本书为中心，编辑工具按需展开。 */
.mobile-shelf, .mobile-tools, .library-backdrop { display: none; }
@media (max-width: 740px), (max-width: 960px) and (max-height: 500px) {
  header { height: auto; min-height: 56px; flex: 0 0 auto; padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); gap: 6px; }
  .brand { font-size: 17px; gap: 5px; letter-spacing: 0; white-space: nowrap; }
  .brand-symbol { width: 23px; height: 23px; }
  .brand small { display: none; }
  .account { gap: 4px; margin-left: auto; }
  .account button { min-height: 44px; padding: 6px 9px; font-size: 12px; }
  #libraryToggle { display: grid; place-items: center; width: 40px; min-height: 44px; flex: none; }
  #quota { position: absolute; right: 10px; top: 60px; z-index: 22; font-size: 10px; padding: 4px 8px; }
  aside { display: none; position: absolute; inset: 0 auto 0 0; width: min(290px, 84vw); padding: 20px 16px max(20px, env(safe-area-inset-bottom)); z-index: 30; overflow-y: auto; }
  aside.open { display: flex; }
  .library-backdrop:not([hidden]) { display: block; position: absolute; inset: 0; z-index: 29; background: rgba(8,12,26,.65); backdrop-filter: blur(4px); }
  .library-heading button, .book-item, .book-delete, #copyExample { min-height: 44px; }
  .desk-top { padding: 10px 12px 6px; gap: 6px; flex-wrap: wrap; flex: none; }
  .top-shelf-btn { min-height: 44px; padding: 6px 12px !important; }
  .top-shelf-btn .shelf-icon { display: none; }
  .book-meta-hud { order: 3; width: 100%; min-width: 0; justify-content: center; gap: 6px; }
  #renameBook { min-width: 0; max-width: 70%; font-size: 14px; padding: 4px 10px; min-height: 32px; }
  #bookTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #saveStatus { font-size: 10px; padding: 3px 5px; }
  #overviewBtn { margin-left: auto; min-height: 44px; font-size: 12px; padding: 6px 12px; }
  .guide { display: none !important; }
  .mobile-shelf { position: absolute; bottom: 0; left: 0; right: 0; z-index: 6; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(20,26,51,.98) 70%, rgba(20,26,51,0)); }
  #book3d[data-mode="shelf"] ~ .mobile-shelf { display: block; }
  .mobile-shelf p { display: flex; justify-content: space-between; margin: 6px 4px 12px; font-size: 12px; color: #dac8a5; }
  #shelfPosition { color: #c1b8d4; font-variant-numeric: tabular-nums; }
  .shelf-picker { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; gap: 8px; align-items: center; }
  .shelf-picker > button { min-height: 52px; border-radius: 16px; background: rgba(230,189,102,.12); border: 1px solid rgba(230,189,102,.35); font-size: 26px; color: var(--gold); }
  #shelfOpen { padding: 12px 4px; background: var(--paper-card); color: var(--ink); }
  #shelfOpen strong { display: block; font-size: 16px; }
  #shelfOpen small { display: block; font-size: 12px; font-weight: 400; margin-top: 4px; color: #766043; }
  #mobileCreate { width: 100%; min-height: 44px; margin-top: 8px; color: var(--gold); font-size: 13px; }
  .book-stage { padding: 0 14px 8px; align-items: flex-end; }
  button.round#prev, button.round#next { width: 44px; height: 44px; font-size: 24px; }
  .work-area { width: 100%; margin: 0; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(230,189,102,.24); background: rgba(20,26,51,.94); }
  .book-toolbar { margin: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  .book-toolbar button { min-height: 44px; padding: 4px 6px; font-size: 12px; }
  #backToShelfBtn { display: none; }
  #pageCounter { grid-column: 1/-1; order: -1; text-align: center; border: 0; box-shadow: none; background: none; font-size: 11px; padding: 2px 0 6px; }
  #adjustBtn { display: none; }
  .desk[data-panel="editor"] #adjustBtn { display: block; grid-column: 1/-1; }
  .mobile-tools { display: flex; gap: 8px; margin-top: 8px; }
  .mobile-tools button { min-height: 44px; flex: 1; border-radius: 12px; border: 1px solid rgba(230,189,102,.35); font-size: 13px; color: var(--gold); }
  .mobile-tools button[aria-expanded="true"] { background: rgba(230,189,102,.18); }
  #mobileAngleToggle { display: none; }
  #book3d[data-mode="open"] ~ .work-area #mobileAngleToggle { display: block; }
  .compact-editor { display: none; }
  .desk[data-panel="editor"] .compact-editor { display: grid; grid-template-columns: 70px minmax(0,1fr); gap: 10px; height: auto; margin-top: 14px; max-height: 36dvh; overflow-y: auto; pointer-events: auto; }
  .reference { min-height: 112px; transform: none; }
  .effect-panel { padding: 10px; min-width: 0; }
  .effect-top { font-size: 12px; margin-bottom: 4px; gap: 4px; }
  .effect-top button { min-height: 36px; font-size: 11px; }
  .effect-bottom { flex-direction: column; gap: 6px; align-items: stretch; }
  .effect-bottom label { padding: 0 6px; }
  .effect-bottom select { font-size: 16px; min-height: 44px; }
  .effect-bottom .primary { min-height: 44px; padding: 6px; font-size: 14px; }
  .editor-foot { flex-wrap: wrap; gap: 4px; margin-top: 4px; }
  .editor-foot button { min-height: 44px; font-size: 12px; }
  #progressText { display: none; }
  .scene-note { display: none; }
  #book3d[data-mode="open"] ~ .reading-angle:not([hidden]) { display: none; }
  .desk[data-panel="angle"] #book3d[data-mode="open"] ~ .reading-angle:not([hidden]) { display: flex; }
  .reading-angle { position: relative; top: auto; right: auto; margin: 4px 12px 8px; width: auto; max-width: none; padding: 6px 10px; gap: 4px 12px; }
  .reading-angle label { flex: 1; min-width: 130px; }
  .reading-angle input[type="range"] { width: 100%; min-width: 50px; min-height: 44px; flex: 1; }
  .reading-angle button { min-height: 44px; }
  #book3d[data-mode="shelf"] ~ .desk-top, #book3d[data-mode="shelf"] ~ .work-area { display: none; }
  dialog { width: calc(100% - 24px); max-height: calc(100dvh - 32px); padding: 20px 16px; overflow-y: auto; overscroll-behavior: contain; }
  dialog input, dialog textarea, dialog select { font-size: 16px; user-select: text; }
  .dialog-header { margin-bottom: 14px; }
  .dialog-header h2 { font-size: 20px; }
  .dialog-header button { min-width: 44px; min-height: 44px; }
  .page-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  #toast { bottom: max(16px, env(safe-area-inset-bottom)); font-size: 12px; border-radius: 16px; padding: 10px 14px; }
  .round-button:hover, button.round:hover, .pill-button:hover, button.primary:hover, .book-toolbar button:hover, .reference:hover { transform: none; }
}
@media (max-width: 960px) and (max-height: 500px) {
  .desk-top { flex-wrap: nowrap; }
  .book-meta-hud { width: auto; order: 0; flex: 1; }
  .work-area { position: absolute; right: 0; top: 60px; bottom: 0; width: 250px; overflow-y: auto; border-left: 1px solid rgba(230,189,102,.24); }
  .book-stage { margin-right: 250px; }
  .reading-angle { position: absolute; bottom: 4px; top: auto; left: 4px; right: 256px; z-index: 12; }
  .mobile-shelf { width: 250px; left: auto; top: 0; display: none; padding-top: 30px; }
  .desk[data-panel="editor"] .compact-editor { max-height: none; }
}
.page-reader img { display: block; width: 100%; height: min(65dvh, 650px); object-fit: contain; border-radius: 8px; }
.reader-navigation { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; font-size: 13px; }
.reader-navigation button { width: 48px; min-height: 44px; border-radius: 12px; background: #eee0c5; font-size: 26px; color: var(--ink); }
@media (max-width: 740px), (max-width: 960px) and (max-height: 500px) {
  .desk[data-panel="editor"] .work-area { max-height: 52dvh; overflow-y: auto; }
  .desk[data-panel="editor"] .compact-editor { max-height: none; }
  .mobile-tools button { font-size: 12px; padding: 4px; }
}
@media (max-width: 960px) and (max-height: 500px) {
  .desk[data-panel="editor"] .work-area { max-height: none; }
}
@media (max-width: 740px), (max-width: 960px) and (max-height: 500px) {
  dialog { overflow-x: hidden; }
  .page-reader img { height: min(62dvh, calc(100dvh - 180px)); }
  .desk[data-panel="editor"] #closeBook, .desk[data-panel="editor"] #backCover, .desk[data-panel="editor"] #readBook { display: none; }
  .desk[data-panel="editor"] .work-area { display: flex; flex-direction: column; }
  .desk[data-panel="editor"] .mobile-tools { order: -1; flex-shrink: 0; margin: 0 0 8px; }
  .desk[data-panel="editor"] .book-toolbar, .desk[data-panel="editor"] .compact-editor { flex-shrink: 0; }
}

/* 阅读与制作分别提供明确的操作空间。 */
.desk[data-reading="true"] .compact-editor,
.desk[data-reading="true"] #adjustBtn { display: none; }
.desk[data-reading="true"] #readerCopy { background: #ecd4a0; color: #302719; }
.desk[data-reading="true"] .work-area { width: min(760px, calc(100% - 32px)); }
#mobileZoom { display: inline-block; }
@media (min-width: 741px) and (min-height: 501px) {
  .mobile-tools { display: flex; justify-content: center; margin-top: 8px; pointer-events: auto; }
  .mobile-tools button { min-height: 40px; padding: 6px 18px; color: var(--gold); border: 1px solid rgba(230,189,102,.35); border-radius: 16px; background: #18243a; }
  #mobileEditToggle, #mobileAngleToggle { display: none; }
}
@media (max-width: 740px), (max-width: 960px) and (max-height: 500px) {
  .mobile-shelf { background: linear-gradient(0deg, rgba(20,26,51,1) 85%, rgba(20,26,51,0)); }
  .desk[data-reading="true"] #mobileEditToggle { display: none; }
  .desk[data-reading="true"] .work-area { width: 100%; }
  .desk[data-reading="false"] .scene-note { display: block; font-size: 11px; margin: 6px 0 0; text-align: center; }
}
