/* ── Domine 本地字体 ── */
@font-face {
  font-family: 'Domine';
  src: url('../fonts/Domine-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Domine';
  src: url('../fonts/Domine-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* ── 方正可变兰亭黑 GBK（子集化，仅含英文+数字+标点） ── */
@font-face {
  font-family: 'FZLanTingHei';
  src: url('../fonts/FZLanTingHei-subset.woff2') format('woff2');
  font-weight: 100 900;   /* 可变字体，声明整个字重区间 */
  font-style: normal;
  font-display: swap;
}
/* ── Mendl Sans Dusk ── B 风格模版大字用 ──
   注意：Md 和 Rg 的 family 名不同（Rg 叫 "Mendl Sans Dusk"，Md 叫 "Mendl Sans Dusk Medium"），
   不能用 weight 合并 */
@font-face {
  font-family: 'Mendl Sans Dusk';
  src: url('../fonts/MendlSans_Dusk_Rg.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mendl Sans Dusk Medium';
  src: url('../fonts/MendlSans_Dusk_Md.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ── Open-source text editor fonts (SIL OFL 1.1) ── */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('../fonts/PlayfairDisplay-Variable.ttf') format('truetype');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bebas Neue';
  src: url('../fonts/BebasNeue-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  src: url('../fonts/Caveat-Variable.ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Ma Shan Zheng';
  src: url('../fonts/MaShanZheng-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  overflow: hidden;
  background: #1a1a1a;
}
/* 桌面端：居中显示窄屏，模拟手机比例 */
body {
  display: flex; align-items: center; justify-content: center;
}
/* 主容器 — 手机全屏 / 桌面居中窄屏 */
.app-container {
  width: 100%; height: 100%;
  max-width: 430px;
  position: relative;
  overflow: hidden;
  background: #fff;
}
/* 桌面端给容器加圆角和阴影 */
@media (min-width: 500px) {
  body { background: #0a0a0a; }
  .app-container {
    max-height: 932px;
    border-radius: 20px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  }
}
/* 仅在非输入容器上禁止选中 */
.app-container, .shelf-card, .nav-back-pill, .edit-tool, .tp-variant-card,
.te-font-card, .te-color-dot, .te-align-btn, .te-preset-card, .te-style-btn,
#bookContainer, #pageIndicator {
  user-select: none; -webkit-user-select: none;
}
/* 确保所有输入类元素可以正常输入 */
input[type="text"], input[type="color"], input[type="range"],
input:not([type]), textarea {
  user-select: text !important; -webkit-user-select: text !important;
}

/* 状态栏 */
.status-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 52px;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 24px 8px; z-index: 200; pointer-events: none;
}
.status-bar.dark .sb-time, .status-bar.dark .sb-icons { color: #000; }
.sb-time { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; }
.sb-icons { display: flex; align-items: center; gap: 5px; }
.sb-icons svg { width: 16px; height: 12px; }

/* 顶部导航 (v=h: z-index 提到 800，高于所有浮层；返回按钮永远可点) */
.top-nav {
  position: absolute; top: max(20px, env(safe-area-inset-top, 0px)); left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); z-index: 800;
  pointer-events: none; /* 容器不拦截事件，只让里面的按钮接收点击，避免遮挡浮层 */
}
.top-nav > * { pointer-events: auto; }
.studio-primary-controls {
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.studio-primary-controls > * { pointer-events: auto; }
.nav-back-pill {
  width: 52px; height: 44px; min-width: 52px; min-height: 44px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}
.nav-back-pill:active { transform: scale(0.92); background: #f5f5f5; }
.nav-back-pill svg { width: 18px; height: 18px; stroke: #1a1a1a; stroke-width: 2.2; fill: none; }
.nav-back-pill svg.shelf-carousel-icon {
  width: 21px;
  height: 21px;
  stroke-width: 2.3;
}

/* ★ v=am8: 撤销/重做上移到顶栏，紧贴返回键右边的小药丸 */
.edit-history-group {
  height: 44px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.05);
  display: flex; align-items: center;
  padding: 0 6px; gap: 2px;
  flex-shrink: 0;
}
.edit-history-group > * { pointer-events: auto; }
.history-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.history-btn:active { transform: scale(0.88); background: #f5f5f5; }
.history-btn svg {
  width: 20px; height: 20px;
}
.history-btn svg path { stroke: #1a1a1a; }
.history-btn.disabled {
  pointer-events: none;
  opacity: 0.35;
}
.history-btn.disabled svg path { stroke: #9a9a9a; }
.nav-toolbar-pill {
  flex: none; margin-left: auto;
  height: 44px; border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.05);
  display: flex; align-items: center;
  padding: 0 8px; gap: 2px;
}
.nav-tool-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
  /* iOS Safari 稳：禁双击缩放 / 禁高亮 / 禁选中 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.nav-tool-icon:active { background: rgba(0,0,0,0.06); }
/* SVG 及内部 circle/path 全部穿透，确保 click 命中的永远是 .nav-tool-icon 本身 */
.nav-tool-icon svg { width: 18px; height: 18px; stroke: #2a2a2a; stroke-width: 1.7; fill: none; pointer-events: none; }
.nav-tool-icon svg * { pointer-events: none; }
.nav-divider { width: 1px; height: 20px; background: #e5e5e5; margin: 0 2px; }

/* 更多下拉菜单 */
.more-menu-wrap { position: relative; }
.more-menu {
  position: absolute; top: 42px; right: 0;
  background: #fff; border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.14), 0 0 0 0.5px rgba(0,0,0,0.06);
  min-width: 140px; padding: 6px 0;
  opacity: 0; transform: scale(0.9) translateY(-4px); transform-origin: top right;
  pointer-events: none; transition: opacity 0.18s, transform 0.18s;
  z-index: 1500;
}
.more-menu.mm-open { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.more-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; font-size: 13px; color: #1a1a1a;
  cursor: pointer; transition: background 0.12s; white-space: nowrap;
  /* 触屏稳定：禁止 300ms 延迟、禁止双指缩放、禁止高亮 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.more-menu-item:active { background: #f5f5f5; }
/* 点中 SVG 子元素时事件穿透到父 menu-item，避免命中 svg 不响应 */
.more-menu-item svg { width: 16px; height: 16px; stroke: #555; stroke-width: 1.8; fill: none; flex-shrink: 0; pointer-events: none; }

/* ════════════════════════════════════════
   状态1：书架
════════════════════════════════════════ */
#shelfView {
  position: absolute; inset: 0;
  background: #fff; overflow: hidden;
  transform-origin: center 46%;
  transition: transform 0.52s cubic-bezier(0.22, 0.72, 0, 1), opacity 0.42s ease, filter 0.42s ease;
  will-change: transform, opacity;
}
#shelfView.shelf-morph-out {
  transform: scale(0.78);
  opacity: 0;
  filter: blur(2px);
  pointer-events: none;
}
#shelfAppName {
  position: absolute; top: 56px; left: 20px;
  height: 44px; display: flex; align-items: center;
  font-size: 30px; font-weight: 800; color: #0d0d0d;
  letter-spacing: -0.8px; z-index: 300; pointer-events: none;
}
/* 首页右上角按钮组 */
.shelf-top-actions {
  position: absolute; top: 12px; right: 18px;
  display: flex; align-items: center; gap: 8px; z-index: 300;
}
.shelf-action-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  border: none; outline: none;
}
.shelf-action-btn:hover { background: rgba(0,0,0,0.10); }
.shelf-action-btn:active { transform: scale(0.9); background: rgba(0,0,0,0.14); }
.shelf-action-btn svg { width: 17px; height: 17px; }
.shelf-create-fab {
  position: absolute;
  right: 32px;
  bottom: calc(42px + env(safe-area-inset-bottom, 0));
  width: 57px;
  height: 57px;
  border: none;
  border-radius: 50%;
  background: #0f0f0f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 320;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(0,0,0,0.18);
  transition: transform 0.15s ease, background 0.15s ease;
}
.shelf-create-fab:active {
  transform: scale(0.94);
  background: #333;
}
.shelf-create-fab svg {
  width: 28px;
  height: 28px;
}
.collection-create-fab {
  position: absolute;
}

/* 首页右上角"更多"圆形小按钮 — 兼容旧 id */
#shelfMoreBtn {
  position: absolute; top: 62px; right: 20px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 300;
  transition: background 0.15s;
  display: none; /* 用新按钮组替代 */
}
#shelfMoreBtn:active { background: rgba(0,0,0,0.13); }
#shelfMoreBtn svg { width: 16px; height: 16px; }

/* 删除确认弹窗 */
.confirm-overlay {
  position: absolute; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.confirm-overlay.co-open { display: flex; }
.confirm-panel {
  background: #fff; border-radius: 20px;
  padding: 28px 24px 20px; width: 280px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: confirmIn 0.25s ease;
}
@keyframes confirmIn { from { transform: scale(0.85); opacity: 0; } }
.confirm-panel h3 { font-size: 17px; font-weight: 700; color: #1a1a1a; margin-bottom: 8px; }
.confirm-panel p { font-size: 13px; color: #888; margin-bottom: 20px; line-height: 1.5; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btn {
  flex: 1; height: 44px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.confirm-btn:active { transform: scale(0.96); }
.confirm-btn.cb-cancel { background: #f0f0f0; color: #666; }
.confirm-btn.cb-danger { background: #ff4444; color: #fff; }

/* 新建 Zine 色盘弹窗 */
.create-zine-overlay {
  position: absolute; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.create-zine-overlay.czo-open { display: flex; }
.create-zine-panel {
  background: #fff; border-radius: 24px;
  padding: 28px 24px 24px; width: 300px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  animation: confirmIn 0.25s ease;
}
.create-zine-panel h3 { font-size: 18px; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; letter-spacing: -0.3px; }
.create-zine-panel .czp-sub { font-size: 12px; color: #aaa; margin-bottom: 18px; }
.czp-input-group { margin-bottom: 16px; }
.czp-input-group label { font-size: 11px; color: #999; display: block; margin-bottom: 6px; letter-spacing: 0.3px; text-transform: uppercase; }
.czp-input {
  width: 100%; height: 44px; border: 1.5px solid #e5e5e5; border-radius: 12px;
  padding: 0 14px; font-size: 15px; color: #1a1a1a; outline: none;
  font-family: inherit; transition: border-color 0.2s;
  user-select: text; -webkit-user-select: text;
}
.czp-input:focus { border-color: #1a1a1a; }
.czp-colors { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.czp-color-dot {
  width: 36px; height: 36px; border-radius: 10px;
  cursor: pointer; border: 1.5px solid rgba(0,0,0,0.07);
  transition: transform 0.12s;
  position: relative;
}
.czp-color-dot:active { transform: scale(0.88); }
.czp-color-dot.czp-selected::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: rgba(255,255,255,0.8);
}
.czp-btns { display: flex; gap: 10px; }
.czp-btn {
  flex: 1; height: 48px; border: none; border-radius: 14px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s;
}
.czp-btn:active { transform: scale(0.96); }
.czp-btn.czp-cancel { background: #f0f0f0; color: #666; }
.czp-btn.czp-create { background: #1a1a1a; color: #fff; }

/* 背景选择器浮层 */
#bgPickerOverlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0); z-index: 490; display: none;
}
#bgPicker {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 0 0; z-index: 500;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.25,0.46,0.45,0.94);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.10);
  max-height: 78%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#bgPicker .bp-handle,
#bgPicker .bp-title {
  flex: 0 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}
#bgPicker .bp-handle {
  padding-left: 0; padding-right: 0;
}
.bp-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;                 /* 强制 scroll 而非 auto，确保 iOS 有滚动条区域 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 20px;
  /* 底部大 padding：24 页边距 + 32 手势区 + 系统安全区，确保最后一个按钮完全露出 */
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
}
#bgPicker.bp-open { transform: translateY(0); }
.bp-handle { width: 36px; height: 4px; background: #e0e0e0; border-radius: 2px; margin: 0 auto 18px; }
.bp-title { font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 16px; letter-spacing: -0.2px; }
.bp-section-label { font-size: 11px; color: #aaa; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 10px; margin-top: 16px; }
.bp-swatches { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.bp-swatch {
  width: 38px; height: 38px; border-radius: 10px;
  cursor: pointer; flex-shrink: 0;
  /* 用内阴影代替 border，极淡，浅色（米/白）上不会显得"有外框选中感" */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  transition: transform 0.12s, box-shadow 0.15s; position: relative;
}
.bp-swatch:active { transform: scale(0.88); }
/* 只有真的被选中的色才显示外框（明显的黑色外环 + 阴影） */
.bp-swatch.bp-selected {
  box-shadow: 0 0 0 2.5px #1a1a1a, inset 0 0 0 1px rgba(0,0,0,0.04);
}
/* 白色块默认：加一圈细灰边，否则跟白底浮层融在一起看不见 */
.bp-swatch.bp-swatch-white { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
/* 白色块选中态：外环 + 细灰边一起 */
.bp-swatch.bp-swatch-white.bp-selected {
  box-shadow: 0 0 0 2.5px #1a1a1a, inset 0 0 0 1px rgba(0,0,0,0.12);
}
/* 纹理块（波点/格纹）：显示截取的纹理缩略图，跟纯色块同尺寸排在一行 */
.bp-swatch.bp-swatch-texture {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.bp-swatch.bp-swatch-texture.bp-selected {
  box-shadow: 0 0 0 2.5px #1a1a1a, inset 0 0 0 1px rgba(0,0,0,0.08);
}
/* 自定义色块单独一行：按钮在左，灰字在右 */
.bp-color-row, .bp-custom-row {
  display: flex; flex-direction: row; align-items: center;
  gap: 10px; margin-top: 14px;
}
.bp-custom-hint { font-size: 12px; color: #aaa; letter-spacing: 0.2px; }
.bp-color-input-wrap {
  display: inline-block;
  width: 38px; height: 38px; border-radius: 10px;
  overflow: hidden; flex-shrink: 0; cursor: pointer; position: relative;
  /* 默认彩虹底，13 段 HSL 均匀色相，过渡更柔和、首尾平滑衔接 */
  background: conic-gradient(from 0deg,
    hsl(0,90%,60%),   hsl(30,90%,58%),  hsl(60,90%,56%),
    hsl(90,80%,52%),  hsl(120,75%,50%), hsl(150,75%,52%),
    hsl(180,80%,55%), hsl(210,85%,58%), hsl(240,85%,62%),
    hsl(270,80%,62%), hsl(300,80%,60%), hsl(330,85%,60%),
    hsl(360,90%,60%));
  /* 选中态由 JS 切纯色，给选中态预留外环位置 */
  transition: box-shadow 0.15s;
}
/* 自定义色被使用时显示的选中外环（JS 加 .bp-selected） */
.bp-color-input-wrap.bp-selected {
  box-shadow: 0 0 0 2.5px #1a1a1a;
}
.bp-color-input-wrap input[type="color"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: none; padding: 0; margin: 0; cursor: pointer;
  opacity: 0; background: transparent;
  -webkit-appearance: none; appearance: none;
  z-index: 2;
}
.bp-upload-btn {
  height: 50px; border: 1.5px dashed #dedede; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; transition: background 0.15s; margin-top: 14px;
}
.bp-upload-btn:active { background: rgba(0,0,0,0.03); }
.bp-upload-btn span { font-size: 12px; color: #999; }

/* 预设图片缩略图网格（一行 4 个，4:5 比例，跟 zine 页比例一致） */
.bp-bg-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.bp-bg-thumb {
  aspect-ratio: 4 / 5;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  transition: transform 0.12s, box-shadow 0.15s;
}
.bp-bg-thumb:active { transform: scale(0.93); }
.bp-bg-thumb.bp-selected {
  box-shadow: inset 0 0 0 2px #1a1a1a, 0 0 0 2px rgba(0,0,0,0.06);
}

/* 封面编辑面板 */
#coverEditorOverlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0); z-index: 490; display: none;
}
#coverEditor {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 20px 0; z-index: 500;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.25,0.46,0.45,0.94);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.10);
  /* 半屏高：头部固定、内容区滚动（见 .ce-scroll） */
  max-height: 56vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* 头部（handle + 标题 + 关闭）固定不滚，只有 .ce-scroll 滚 */
#coverEditor .ce-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 4px 32px;   /* 左右留 4px，防止选中黑圈外环被 overflow 裁切 */
  margin: 0 -4px;         /* 负 margin 抵消，保持内容视觉对齐 */
}
#coverEditor.ce-open { transform: translateY(0); }
/* 封面模板选项卡 */
.ce-tpl-row { display: flex; gap: 8px; }
.ce-tpl-opt {
  flex: 1; height: 40px; border-radius: 10px;
  border: 1.5px solid #e5e5e5; background: #fafafa;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; color: #888; cursor: pointer;
  transition: all 0.15s;
}
.ce-tpl-opt:active { transform: scale(0.97); }
.ce-tpl-opt.ce-tpl-active {
  border-color: #1a1a1a; background: #1a1a1a; color: #fff;
}
/* 镂空窗口位置选择：两个简笔缩略图 */
.ce-pos-row { display: flex; gap: 10px; }
.ce-pos-opt {
  flex: 1;
  border-radius: 10px;
  border: 1.5px solid #e5e5e5; background: #fafafa;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 0 8px;
  cursor: pointer; transition: all 0.15s;
}
.ce-pos-opt:active { transform: scale(0.97); }
.ce-pos-thumb { width: 34px; height: auto; display: block; }
.ce-pos-label { font-size: 12px; font-weight: 500; color: #888; transition: color 0.15s; }
.ce-pos-opt.ce-pos-active {
  border-color: #1a1a1a; background: #fff;
}
.ce-pos-opt.ce-pos-active .ce-pos-label { color: #1a1a1a; font-weight: 600; }
.ce-color-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.ce-color-row .bp-swatch { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
/* 色轮嵌入色块行末尾 —— 默认彩虹底（跟 bgPicker 自定义色块一致） */
.ce-color-wheel-wrap {
  width: 38px; height: 38px; border-radius: 10px;
  overflow: hidden; flex-shrink: 0; cursor: pointer;
  position: relative;
  /* 默认彩虹底，13 段 HSL 均匀色相 */
  background: conic-gradient(from 0deg,
    hsl(0,90%,60%),   hsl(30,90%,58%),  hsl(60,90%,56%),
    hsl(90,80%,52%),  hsl(120,75%,50%), hsl(150,75%,52%),
    hsl(180,80%,55%), hsl(210,85%,58%), hsl(240,85%,62%),
    hsl(270,80%,62%), hsl(300,80%,60%), hsl(330,85%,60%),
    hsl(360,90%,60%));
  /* 用内阴影替代 border，避免土黄色 input 透出来 */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}
.ce-color-wheel-wrap.bp-selected {
  box-shadow: inset 0 0 0 2px #1a1a1a, 0 0 0 2px rgba(0,0,0,0.06);
}
.ce-color-wheel-wrap.bp-selected::after {
  content: ''; /* 选中态不再显示 ✓，靠外环表达即可（跟 bgPicker 自定义色块行为一致） */
}
.ce-color-wheel-wrap input[type="color"] {
  position: absolute; top: -6px; left: -6px;
  width: calc(100% + 12px); height: calc(100% + 12px);
  border: none; padding: 0; cursor: pointer;
  background: none;
  opacity: 0;  /* 关键：隐藏 input 自身的默认色，只保留点击调起选色器的能力 */
  -webkit-appearance: none; appearance: none;
}
.ce-text-color-row {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
}
.ce-text-swatch {
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid rgba(0,0,0,0.07); flex-shrink: 0;
  transition: transform 0.12s; position: relative;
}
.ce-text-swatch:active { transform: scale(0.88); }
.ce-text-swatch.ce-selected {
  box-shadow: 0 0 0 2.5px #1a1a1a;
}
.ce-title-input {
  width: 100%; border: 1.5px solid #e0e0e0; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase; resize: none;
  outline: none; font-family: inherit; margin-top: 4px;
}
.ce-title-input:focus { border-color: #1a1a1a; }
.ce-apply-btn {
  width: 100%; height: 44px; border: none; border-radius: 12px;
  background: #1a1a1a; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; margin-top: 16px; transition: opacity 0.15s;
}
.ce-apply-btn:active { opacity: 0.7; }
.ce-upload-btn {
  flex: 1; height: 38px; border: 1.5px solid #e0e0e0; border-radius: 10px;
  background: #fff; color: #333; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.ce-upload-btn:active { background: #f0f0f0; }
.ce-remove-btn { color: #c44; border-color: #e0c0c0; }

/* 书架轨道
   用 clip-path 代替 overflow: hidden，只裁掉左右两侧多余书本，
   上下方向（尤其是书本下方的阴影）保持完整不被裁 */
.shelf-stage {
  position: absolute;
  top: 116px; left: 0; right: 0; bottom: 220px;
  display: flex; align-items: center;
  clip-path: inset(-200px 0);
}
.shelf-track {
  display: flex; align-items: center; padding: 0;
  transition: transform 0.42s cubic-bezier(0.25,0.46,0.45,0.94);
  will-change: transform; cursor: grab;
}
.shelf-track:active { cursor: grabbing; }
.shelf-card {
  /* ★ 书本统一比例：160 / 226（与工作台 #bookContainer 完全一致）
     宽 225 → 高 = 225 × 226/160 = 317.8px。所有出现"书"的地方都必须用这个比例 */
  flex-shrink: 0; width: 225px; aspect-ratio: 160 / 226; border-radius: 0 3px 3px 0;
  background: #EEEAE3;
  /* 书页厚度：右+下方向叠加少量冷灰硬边，薄薄一层，与底部阴影自然融合 */
  box-shadow:
    1px 0 0 #c9c9ce,
    2px 1px 0 #b8b8bf,
    3px 2px 4px rgba(0,0,0,0.12),
    0 14px 36px rgba(0,0,0,0.16),
    0 4px 12px rgba(0,0,0,0.09);
  position: relative; overflow: hidden; cursor: pointer;
  transition: transform 0.42s cubic-bezier(0.25,0.46,0.45,0.94),
              box-shadow 0.42s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.42s;
  margin: 0 18px;
}
.shelf-card.s-active {
  transform: scale(1.0);
  box-shadow:
    1px 0 0 #c9c9ce,
    2px 1px 0 #b8b8bf,
    4px 3px 6px rgba(0,0,0,0.13),
    0 22px 52px rgba(0,0,0,0.20),
    0 6px 14px rgba(0,0,0,0.11);
  z-index: 3;
}
.shelf-card.s-side { transform: scale(0.88); opacity: 0.55; box-shadow: 1px 0 0 #bcbcc2, 2px 2px 5px rgba(0,0,0,0.10), 0 8px 22px rgba(0,0,0,0.09); z-index: 2; }
.shelf-card.s-far  { transform: scale(0.82) translateY(8px); opacity: 0.45; z-index: 1; }
.shelf-card-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 24px; position: relative;
}
/* 当封面使用纹理背景时，去掉 padding 让纹理填满整张卡片 */
.shelf-card-inner:has(> .cover-page),
.shelf-card-inner:has(> .cover-cutout) {
  padding: 0;
}
.sc-num   { font-size: 9px; color: #aaa; letter-spacing: 2.5px; text-transform: uppercase; margin-bottom: 20px; }
.sc-title { font-size: 22px; font-weight: 700; color: #1a1a1a; text-align: center; line-height: 1.15; letter-spacing: -0.3px; margin-bottom: 14px; }
.sc-divider { width: 18px; height: 1px; background: rgba(0,0,0,0.2); margin-bottom: 14px; }
.sc-sub   { font-size: 8px; color: #999; text-align: center; line-height: 1.7; }
/* 圆点翻页：作为 .shelf-meta 内的普通 flex 子项，紧跟在标题/副标题下方 */
.shelf-dots {
  height: 20px; display: flex; justify-content: center; align-items: center; gap: 6px;
  margin-top: 8px;
}
.sh-dot { width: 5px; height: 5px; border-radius: 50%; background: #d0d0d0; transition: all 0.3s; }
.sh-dot.active { background: #333; width: 18px; border-radius: 2.5px; }
.shelf-tab-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 60px;
  background: #fff; border-top: 0.5px solid #ebebeb;
  display: flex; align-items: center; justify-content: space-around;
}
.tab-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; padding: 4px 20px; }
.tab-item svg { width: 26px; height: 26px; stroke-width: 1.6; fill: none; transition: stroke 0.15s; }
.tab-item.tab-active svg { stroke: #000; stroke-width: 2; }
.tab-item:not(.tab-active) svg { stroke: #b0b0b0; }

.view-toggle {
  position: absolute; top: 12px; left: 18px;
  display: flex; align-items: center; gap: 10px;
  z-index: 300;
}
.view-toggle-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.06);
  color: #333;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 300;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.view-toggle-btn.vt-active {
  background: #1a1a1a;
  color: #fff;
}
.view-toggle-btn:active { transform: scale(0.9); background: rgba(0,0,0,0.13); }
.view-toggle-btn.vt-active:active { background: #333; }
.view-toggle-btn svg { width: 17px; height: 17px; }
/* 书 icon 的 path 撑满 24×24 画布，视觉上比其他 icon 大，单独缩到 14px 保持视觉一致 */
.view-toggle-btn.vt-book svg { width: 14px; height: 14px; }

/* ── 轮播页当前书信息（书名可编辑 + 小字 + 圆点翻页） ──
   flex 纵向布局，把三个子元素紧凑排成一组，位于书本下方 */
.shelf-meta {
  position: absolute; left: 0; right: 0; bottom: 90px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; z-index: 250; pointer-events: none;
  padding: 0 32px;
}
.shelf-meta-title {
  display: inline-block;
  font-size: 21px; font-weight: 800; color: #0d0d0d;
  letter-spacing: -0.5px; line-height: 1.15;
  pointer-events: auto; cursor: text;
  padding: 2px 10px; border-radius: 8px;
  max-width: 100%; word-break: break-word;
  transition: background 0.15s;
}
.shelf-meta-title:active { background: rgba(0,0,0,0.04); }
/* 就地编辑输入框 */
.shelf-meta-title.editing {
  background: rgba(0,0,0,0.04);
  outline: 1.5px solid #1a1a1a;
}
.shelf-meta-sub {
  font-size: 12px; color: #b0b0b0; letter-spacing: 0.2px;
}

/* ════════════════════════════════════════
   收集页：所有 Zine 网格总览
════════════════════════════════════════ */
#collectionView {
  position: absolute; inset: 0;
  background: #fff;
  flex-direction: column;
  z-index: 400;
  /* 默认完全不渲染，避免常驻合成层拖累其他页面动画 */
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.075);
  transform-origin: center 44%;
  filter: blur(2px);
}
/* 挂载态：参与渲染但仍透明 */
#collectionView.cv-mounted {
  display: flex;
  transition: opacity 0.42s ease, transform 0.52s cubic-bezier(0.22, 0.72, 0, 1), filter 0.42s ease;
}
#collectionView.cv-show {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  pointer-events: auto;
}
/* 书本主体渐显 + 轻微上浮（仅进入时） */
.cv-card {
  opacity: 0;
  transform: translateY(10px);
}
#collectionView.cv-show .cv-card {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.42s ease, transform 0.46s cubic-bezier(0.22, 0.61, 0.36, 1);
  transition-delay: calc(var(--cv-index, 0) * 24ms);
}
.collection-top {
  position: relative; flex-shrink: 0;
  height: 112px;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 18px 12px;
}
.collection-select-btn {
  position: absolute; top: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  cursor: pointer; transition: background 0.2s, transform 0.15s;
}
.collection-select-btn { right: 18px; }
.collection-select-btn:active { transform: scale(0.9); background: rgba(0,0,0,0.13); }
.collection-select-btn svg { width: 17px; height: 17px; }
/* 多选态左上角"取消"文字按钮 */
.collection-cancel {
  position: absolute; left: 18px; bottom: 8px;
  height: 40px; display: none; align-items: center;
  font-size: 15px; color: #1a1a1a; cursor: pointer;
  padding: 0 4px;
}
.collection-title {
  font-size: 18px; font-weight: 700; color: #0d0d0d;
  letter-spacing: -0.3px; padding-bottom: 2px;
}
/* 多选态：隐藏返回和垃圾桶，显示取消 */
#collectionView.cv-select .collection-back,
#collectionView.cv-select .collection-select-btn,
#collectionView.cv-select .collection-create-fab { display: none; }
#collectionView.cv-select .collection-cancel { display: flex; }

.collection-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px 24px calc(132px + env(safe-area-inset-bottom, 0));
}
/* 所有 zine：两列网格（对齐 demo：居中书名、无分区无隔板） */
.collection-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 32px 22px;
}
/* 单本卡片 —— 缩到约 80%，在各自列内居中 */
.cv-card { cursor: pointer; position: relative; width: 80%; margin: 0 auto; }
.cv-card-cover {
  /* ★ 书本统一比例 160/226，与轮播页/工作台完全一致 */
  width: 100%; aspect-ratio: 160 / 226;
  border-radius: 0 3px 3px 0; overflow: hidden; position: relative;
  background: #EEEAE3;
  /* 淡投影，让书轻轻浮起 */
  box-shadow: 0 6px 18px rgba(0,0,0,0.10), 0 2px 5px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.2s;
}
.cv-card:active .cv-card-cover { transform: scale(0.96); }

/* 长按书本删除：拖拽期间才出现左下角垃圾桶 */
#shelfTrashDrop {
  position: absolute;
  left: 24px;
  bottom: calc(34px + env(safe-area-inset-bottom, 0));
  width: 74px;
  height: 74px;
  border-radius: 24px;
  z-index: 980;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  background: rgba(20,20,20,0.88);
  box-shadow: 0 14px 38px rgba(0,0,0,0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(24px) scale(0.72);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.34s cubic-bezier(0.22, 0.9, 0.3, 1), background 0.18s ease;
}
#shelfTrashDrop svg { width: 24px; height: 24px; }
#shelfTrashDrop span { font-size: 9px; font-weight: 650; white-space: nowrap; }
#shelfTrashDrop.trash-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#shelfTrashDrop.trash-hot {
  background: #e43d3d;
  transform: translateY(0) scale(1.12);
}
.book-drag-source { opacity: 0.18 !important; }
.book-drag-ghost {
  position: absolute !important;
  z-index: 990 !important;
  margin: 0 !important;
  pointer-events: none !important;
  transform-origin: center center !important;
  transform: scale(1.045) rotate(-1.2deg) !important;
  opacity: 0.96;
  filter: saturate(1.03);
  box-shadow: 0 28px 70px rgba(0,0,0,0.28), 0 7px 18px rgba(0,0,0,0.16) !important;
  transition: transform 0.18s ease, opacity 0.18s ease, left 0.26s cubic-bezier(0.22,0.72,0,1), top 0.26s cubic-bezier(0.22,0.72,0,1) !important;
}
.book-drag-ghost.is-over-trash {
  transform: scale(0.72) rotate(-4deg) !important;
  opacity: 0.8;
}
/* 把 cover-page 内容缩放填满卡片 */
.cv-card-cover > .cover-page,
.cv-card-cover > .cover-cutout {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.cv-card-title {
  margin-top: 11px;
  font-size: 12px; font-weight: 700; color: #1a1a1a;
  letter-spacing: -0.2px; line-height: 1.25;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cv-card-sub {
  margin-top: 3px;
  font-size: 11px; color: #b5b5b5; letter-spacing: 0.2px;
}

/* ── 多选态：勾选圈 + 选中反馈 ── */
.cv-check {
  position: absolute; top: 8px; left: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2), inset 0 0 0 1.5px rgba(0,0,0,0.15);
  display: none; align-items: center; justify-content: center;
  z-index: 5; pointer-events: none;
}
.cv-check svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
#collectionView.cv-select .cv-check { display: flex; }
.cv-card.cv-selected .cv-check {
  background: #1a1a1a; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.cv-card.cv-selected .cv-check svg { opacity: 1; }
.cv-card.cv-selected .cv-card-cover {
  box-shadow: 0 0 0 2.5px #1a1a1a, 0 4px 16px rgba(0,0,0,0.10);
}

/* ── 多选态底部操作栏 ── */
.collection-selbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0));
  padding: 0 20px calc(0px + env(safe-area-inset-bottom, 0));
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 0.5px solid #eee;
  display: none; align-items: center; justify-content: space-between;
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  z-index: 60;
}
#collectionView.cv-select .collection-selbar { display: flex; transform: translateY(0); }
.csb-count { font-size: 14px; color: #666; }
.csb-del-btn {
  height: 40px; padding: 0 24px; border: none; border-radius: 12px;
  background: #ff4444; color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.15s;
}
.csb-del-btn:active { transform: scale(0.96); }
.csb-del-btn:disabled { background: #e5e5e5; color: #aaa; cursor: not-allowed; }

/* ════════════════════════════════════════
   统一工作台（cover + reader + edit）
════════════════════════════════════════ */
#studioView {
  position: absolute; inset: 0;
  background: #E9EAEC; display: none;
  transition: background 0.3s;
}

/* 三态层 — 通过 st-active 类切换可见 */
#stCover, #stReader, #stEdit {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.36s ease, transform 0.42s cubic-bezier(0.34,1.05,0.64,1);
  opacity: 0; transform: scale(0.88);
}
/* ★ v=am8b: 阅读态书页与顶栏保持安全距离
   （编辑态由 JS calcZoomTransform 里 topBarH 保证，此处只管封面/阅读态） */
#stCover {
  padding-top: 40px;
  box-sizing: border-box;
  /* ★ v=an1：背景空白区也要接管左右滑动翻页，禁用浏览器原生横向手势
     （如 iOS 边缘滑动返回），避免和 JS 翻页手势打架；纵向仍允许（pan-y） */
  touch-action: pan-y;
}
#stCover { flex-direction: column; gap: 16px; overflow: hidden; }
#stEdit { flex-direction: column; align-items: stretch; justify-content: flex-start; }
#stCover.st-active, #stReader.st-active, #stEdit.st-active {
  opacity: 1; transform: scale(1); pointer-events: auto;
}

/* 封面+阅读 统一书本容器
   封面态: 160px宽，只显示封面（coverFlip在left:0）
   阅读态: 320px宽，coverFlip翻开=左页 + bookBase=右页
   
   关键原理：
   封面态 coverFlip left:0, 容器160px → 封面居中显示
   翻开时 coverFlip 移到 left:160px（书脊位置），然后绕左边缘翻转180°
   翻完后 coverFlip 落在 0~160px = 左页，bookBase 160~320px = 右页，紧贴！
*/
#bookContainer {
  position: relative;
  width: 160px; height: 226px;
  transform-origin: center center;
  perspective: 1200px;
  -webkit-perspective: 1200px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  margin-top: -10px;
  /* 提示浏览器在 Retina 屏幕上以高分辨率光栅化 transform 内容，避免缩放后文字模糊 */
  will-change: transform;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* crisptext v1：强化字形渲染精度 + 独立合成层，帮 Safari 在 scale 下重新光栅化文字 */
  text-rendering: geometricPrecision;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* am9Q7：书页整个范围禁用双击缩放，避免手指点到文字外触发 Safari zoom
     ★ 手势灵敏度修复（2026-07-14）：
     原来是 manipulation，浏览器会先愣一下判断"是不是双击缩放"，
     导致手指在书页内横向滑动翻页有延迟/被吞。
     改成 pan-y = 只允许纵向滚动，横向滑动直接给 JS 处理 → 翻页立即响应。
     副作用：编辑态图片裁剪的横向拖动也走 pan-y ——
     但那些手势用 e.preventDefault() 拦截了 touchmove，touch-action 不影响。
     回滚方法：改回 touch-action: manipulation */
  touch-action: pan-y;
}
#bookContainer.reader-mode { width: 320px; }

/* ═══════════════════════════════════════════════════
   手势灵敏度修复（2026-07-14）：书页内所有图片
   - pointer-events: none  → 手指按图会"穿透"到外框
     · 编辑态：外框是 imgCropInit 的手势宿主 → 拖动/缩放照常工作
     · 浏览态：外框也不响应 → 冒泡到 bookContainer 走翻页
   - -webkit-user-drag: none → 禁用 iOS 长按弹图片菜单/Safari 原生拖拽
   - user-select: none → 顺带禁选中，避免长按选文本
   ★ 只影响"看图"体验，编辑态的拖动/缩放绑在外框上不受影响。
   回滚方法：删除这一整段
   ═══════════════════════════════════════════════════ */
#bookContainer img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

#coverHomeActions {
  position: absolute;
  left: 50%;
  top: calc(50% + 222px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-top: 0;
  z-index: 120;
  transform: translateX(-50%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#bookContainer.reader-mode + #coverHomeActions,
body[data-studio-state="reader"] #coverHomeActions,
body[data-studio-state="edit"] #coverHomeActions {
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
}
.cha-primary,
.cha-secondary {
  border: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cha-primary {
  min-width: auto;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: transparent;
  color: #1a1a1a;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
  box-shadow: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.cha-primary::after {
  content: '→';
  display: inline-block;
  margin-left: 7px;
  font-size: 17px;
  transform: translateY(-1px);
}
.cha-primary:active {
  transform: scale(0.96);
  opacity: 0.62;
}
.cha-secondary-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.58);
  box-shadow: 0 8px 26px rgba(0,0,0,0.07), 0 0 0 0.5px rgba(0,0,0,0.045);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.cha-secondary {
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: rgba(26,26,26,0.72);
  font-size: 12px;
  font-weight: 600;
  box-shadow: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.cha-secondary + .cha-secondary {
  border-left: 1px solid rgba(0,0,0,0.08);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.cha-secondary:active {
  transform: scale(0.96);
  background: rgba(255,255,255,0.64);
}
.cha-secondary svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 右页（翻开后才可见） */
#bookBase {
  position: absolute; top: 0; left: 160px;
  width: 160px; height: 226px;
  background: #FFFFFF; border-radius: 0 3px 3px 0;
  overflow: hidden;
  transform-origin: left center;
  box-shadow: 4px 24px 72px rgba(0,0,0,0.22), 2px 4px 16px rgba(0,0,0,0.12);
}
/* 封面态：右页完全隐藏（含阴影），无过渡直接消失 */
#bookContainer.cover-mode #bookBase { opacity: 0; pointer-events: none; box-shadow: none; }

/* 封面翻页层
   封面态: left:0, 显示封面正面
   翻开时: JS 先把 left 改为 160px，然后 rotateY(-180deg)
   翻完后: 视觉上落在 0~160px（左页背面）
*/
#coverFlip {
  position: absolute; top: 0; left: 0;
  width: 160px; height: 226px;
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(0deg);
  z-index: 10; cursor: pointer;
  box-shadow: 0 24px 72px rgba(0,0,0,0.30), 0 4px 16px rgba(0,0,0,0.16);
}
/* 假厚度 — 底边+右侧露出细细的纸页边缘。
   改为半透明深色（自适应任意背景）+ 大幅弱化，避免固定米灰在深背景上突兀。 */
#coverFlip::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: calc(100% + 1px); height: calc(100% + 1px);
  background: rgba(0,0,0,0.16);
  border-radius: 0 3px 3px 0;
  z-index: -1;
  opacity: 0.5;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s;
}
/* 翻开后隐藏假厚度 */
#bookContainer.reader-mode #coverFlip::after { opacity: 0; }
#coverFlipFront {
  position: absolute; top: 0; right: 0; bottom: 0; left: -1px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0.5px);
  transform: translateZ(0.5px);
  overflow: hidden;
  border-radius: 0 3px 3px 0;
  /* 封面 cover-page 直接填满，左边多出 1px 遮盖白边 */
}
#coverFlipBack {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transform: rotateY(180deg);
  background: #FFFFFF; overflow: hidden;
  border-radius: 3px 0 0 3px;
}
/* 翻开后封面不可点击 */
#bookContainer.reader-mode #coverFlip { pointer-events: none; box-shadow: -4px 24px 72px rgba(0,0,0,0.13), -2px 4px 16px rgba(0,0,0,0.07); }

/* 合书后的封底仍保留完整跨页坐标：封底落在左页，右页为空。
   只动画合成层 transform，不动画 width/left，避免移动端重排和二次跳位。 */
#bookContainer.back-cover-mode { width: 320px; }
#bookContainer.back-cover-mode #bookBase {
  left: 160px;
  transform: none;
  opacity: 0;
  pointer-events: none;
  box-shadow: none;
}
#bookContainer.back-cover-mode #coverFlip {
  left: 160px;
  transform: rotateY(-180deg);
  opacity: 1;
  pointer-events: auto;
  border-radius: 3px 0 0 3px;
  box-shadow: 0 24px 72px rgba(0,0,0,.30), 0 4px 16px rgba(0,0,0,.16);
  cursor: pointer;
}
#bookContainer.back-cover-mode #coverFlip::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  box-shadow: inset 1px 0 rgba(255,255,255,.08), inset -1px 0 rgba(0,0,0,.12), inset 0 -1px rgba(0,0,0,.16);
  pointer-events: none;
}
#bookContainer.back-cover-closing #bookBase {
  opacity: 0;
  pointer-events: none;
  box-shadow: none;
}
#bookContainer.back-cover-mode #bindingCrease { opacity: 0; }
#bookContainer.reader-mode.back-cover-opening #bindingCrease { opacity: 0; }
#bookContainer.reader-mode.back-cover-opening #bookBase {
  opacity: 0;
  pointer-events: none;
  box-shadow: none;
}
#bookContainer.back-cover-closing,
#bookContainer.back-cover-opening { width: 320px; }
#bookContainer.back-cover-closing #bookBase,
#bookContainer.back-cover-opening #bookBase,
#bookContainer.back-cover-closing #coverFlip,
#bookContainer.back-cover-opening #coverFlip {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
body.back-cover-viewing #studioView { cursor: default; }


/* 书本 3D */
.book-scene { perspective: 1400px; perspective-origin: center center; position: relative; }
.book-spread {
  position: relative; display: flex; align-items: stretch;
  transform-style: preserve-3d; border-radius: 3px;
  box-shadow: 0 24px 72px rgba(0,0,0,0.30), 0 4px 16px rgba(0,0,0,0.16);
}
.page-left  { width: 160px; height: 226px; position: relative; border-radius: 3px 0 0 3px; overflow: hidden; background: #FFFFFF; flex-shrink: 0;
  text-rendering: geometricPrecision; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.page-right { width: 160px; height: 226px; position: relative; border-radius: 0 3px 3px 0; overflow: hidden; background: #FFFFFF; flex-shrink: 0;
  text-rendering: geometricPrecision; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
#bindingCrease { position: absolute; top: 0; left: 152px; width: 16px; height: 226px; pointer-events: none; z-index: 60; opacity: 0; }
#bookContainer.reader-mode #bindingCrease { opacity: 1; }
#bindingCrease svg { display: block; }
#flipper {
  position: absolute; top: 0; width: 160px; height: 226px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  display: none; z-index: 50;
  will-change: transform;
  left: 160px;
  transform-origin: left center;
  -webkit-transform-origin: left center;
}
.flipper-front, .flipper-back {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  overflow: hidden; background: #FAFAF8; border-radius: 0 3px 3px 0;
}
.flipper-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}
.page-content {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  padding: 14px 13px; display: flex; flex-direction: column;
}
/* ★ 2x 高清渲染层：320×452 渲染，scale(0.5) 回到 160×226
   （曾尝试 zoom:2+scale(0.25) 提到 4x，iOS Safari 无效果已回滚） */
.hires-wrap {
  position: absolute; top: 0; left: 0;
  width: 320px; height: 452px;
  transform: scale(0.5);
  transform-origin: 0 0;
}
.page-number { position: absolute; bottom: 9px; font-size: 7.5px; color: #c0c0c0; letter-spacing: 0.5px; }
.page-left  .page-number { left: 13px; }
.page-right .page-number { right: 13px; }
.page-title   { font-size: 7.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #333; margin-bottom: 8px; }
.page-body    { font-size: 6.5px; color: #666; line-height: 1.7; }
.page-img     { width: 100%; background: #ededeb; border-radius: 3px; margin: 6px 0; display: flex; align-items: center; justify-content: center; }
.page-tag     { display: inline-block; font-size: 5.5px; color: #aaa; border: 0.5px solid #e0e0e0; padding: 1.5px 5px; border-radius: 20px; letter-spacing: 0.5px; text-transform: uppercase; margin-top: 6px; }
.empty-page-clickable {
  color: #b9b9b9;
  transition: color 0.15s ease, transform 0.15s ease;
}
.empty-page-clickable .empty-page-plus path {
  stroke: currentColor;
}
.empty-page-hint {
  display: none;
  font-size: 14px;
  line-height: 1;
  color: currentColor;
  letter-spacing: 0.5px;
  font-weight: 500;
}
body[data-studio-state="edit"] .empty-page-clickable {
  color: #a8a8a8;
  cursor: pointer;
}
body[data-studio-state="edit"] .empty-page-hint {
  display: block;
}
body[data-studio-state="edit"] .empty-page-clickable:active {
  transform: scale(0.96);
  color: #777;
}
.ob-shelf-hint,
.ob-cover-hint,
.ob-reader-hint,
.ob-edit-hint {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.ob-shelf-hint {
  position: absolute;
  left: 50%;
  top: calc(50% + 205px);
  transform: translate(-50%, 8px);
  z-index: 320;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 6px 22px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.05);
  color: #555;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.ob-shelf-hint::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -17px;
  width: 1px;
  height: 14px;
  background: rgba(0,0,0,0.18);
}
.ob-shelf-hint.ob-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.ob-cover-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 330;
  transform: translate(-50%, calc(-50% + 8px));
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 5px 16px rgba(0,0,0,0.08);
  color: #8a8a8a;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.ob-cover-hint.ob-show {
  opacity: 1;
  transform: translate(-50%, -50%);
}
@media (max-height: 760px) {
  #coverHomeActions {
    top: calc(50% + 206px);
  }
}
.ob-reader-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 330;
  transform: translate(-50%, calc(-50% + 8px));
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 5px 16px rgba(0,0,0,0.08);
  color: #8a8a8a;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.ob-reader-hint.ob-show {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.ob-edit-hint {
  position: absolute;
  z-index: 430;
  transform: translateY(calc(-100% + 4px));
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 8px 7px 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.97);
  color: #3f3f3f;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.05);
  pointer-events: auto;
  white-space: nowrap;
}
.ob-edit-hint::after {
  content: '';
  position: absolute;
  left: var(--ob-caret-x, 50%);
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: rgba(255,255,255,0.97);
  border-radius: 0 0 3px 0;
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 3px 3px 8px rgba(0,0,0,0.04);
  z-index: -1;
}
/* ★ 箭头朝上变体：气泡在目标元素下方，箭头从气泡顶部指向上方目标（完成编辑按钮） */
.ob-edit-hint.caret-up {
  transform: translateY(-4px);
}
.ob-edit-hint.caret-up.ob-show {
  transform: translateY(8px);
}
.ob-edit-hint.caret-up::after {
  bottom: auto;
  top: -7px;
  border-radius: 3px 0 0 0;
  box-shadow: -3px -3px 8px rgba(0,0,0,0.04);
}
.ob-edit-hint.ob-show {
  opacity: 1;
  transform: translateY(calc(-100% - 8px));
}
.ob-edit-next {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.ob-edit-hint span {
  position: relative;
  z-index: 1;
}
.ob-edit-next svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* 引导 4：滑动翻页（居中气泡 + 向左箭头） */
.ob-swipe-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 340;
  transform: translate(-50%, calc(-50% + 8px));
  padding: 8px 7px 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.97);
  color: #3f3f3f;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.05);
  pointer-events: auto;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.ob-swipe-hint.ob-show {
  opacity: 1;
  transform: translate(-50%, -50%);
}
.ob-swipe-arrow {
  width: 18px;
  height: 18px;
  color: #3f3f3f;
  flex-shrink: 0;
  animation: obSwipeArrow 1.4s ease-in-out infinite;
}
@keyframes obSwipeArrow {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-6px); }
}
.cover-page {
  width: 100%; height: 100%;
  position: relative;
  background-color: var(--cover-color, #C8B862);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  /* ★ 容器查询基准：封面内部所有尺寸用 cqw（容器宽度的 1%），
     保证同一封面在轮播/工作台/收集页任意大小下都等比缩放、字号一致。
     设计基准宽度 160px：1cqw = 1.6px */
  container-type: inline-size;
}
/* 灰度纹理叠加层 — multiply 混合保留肌理、书脊等细节 */
.cover-page::before {
  content: '';
  position: absolute; inset: 0;
  background: url('../images/cover-texture.png?v=an7') center/cover no-repeat;
  filter: grayscale(1);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 0;
  /* ★ 纹理本身是浅色，multiply 后底色几乎被冲淡到看不见（iOS Safari 尤其明显）
     降低不透明度让底色清晰可见，同时保留一些布纹质感 */
  opacity: 0.25;
}
/* 自定义封面图模式：隐藏纹理层 */
/* 自定义整图封面：不显示纹理层，也不显示书脊压痕线（书脊线只属于基础/镂空模板） */
.cover-page-img::before,
.cover-page-img::after { display: none; }
/* ★ 装订压痕：定义在 .cover-page 上，用 cqw 等比 →
   所有出现封面的地方（轮播/工作台/收集页）自动一致，无需各处重复 */
.cover-page::after {
  content: ''; position: absolute;
  left: 2.2cqw; top: 0; bottom: 0; width: 2.7cqw;
  z-index: 2; pointer-events: none;
  background: linear-gradient(to right,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.09) 45%,
    rgba(0,0,0,0.07) 55%,
    rgba(0,0,0,0) 100%);
}
.cover-main-title {
  position: relative; z-index: 1;
  color: var(--cover-text, #E8E0C8);
  font-family: 'FZLanTingHei', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  /* cqw 基准 160px：9px = 5.625cqw（等比缩放，各处大小一致） */
  font-size: 5.625cqw; font-weight: 600;
  letter-spacing: 0.1875cqw;
  text-align: center; line-height: 1.35;
}
.cover-bottom-text {
  position: absolute; bottom: 8.75cqw; left: 0; right: 0;
  text-align: center;
  z-index: 1;
  color: var(--cover-text, #E8E0C8);
  font-family: 'Domine', Georgia, serif;
  font-size: 2.1875cqw; font-weight: 400;
  letter-spacing: 0.05cqw;
  text-transform: uppercase;
}

/* ════════════════════════════════════════
   镂空笔记本封面模板 (.cover-cutout)
   黄色皮质 + 轻纸张肌理 + 中部凹陷镂空窗口（放图）
   所有尺寸用 cqw，保证轮播/工作台/收集页等比一致
════════════════════════════════════════ */
.cover-cutout {
  width: 100%; height: 100%;
  position: relative;
  background-color: var(--cover-color, #efe287);
  overflow: hidden;
  box-sizing: border-box;
  container-type: inline-size;
}
/* 皮质纸张肌理：加强，皮面布纹更清晰 */
.cover-cutout::before {
  content: '';
  position: absolute; inset: 0;
  background: url('../images/cover-texture.png?v=an7') center/cover no-repeat;
  filter: grayscale(1) contrast(1.15);
  mix-blend-mode: multiply;
  opacity: 0.38;              /* 0.18 → 0.38，肌理更明显 */
  pointer-events: none;
  z-index: 0;
}
/* 皮面体积：整体顶光 + 上边缘窄高光 + 下边缘窄阴影（书封受光/厚度） */
.cover-cutout::after {
  content: '';
  position: absolute; inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* 上边缘：窄窄一条高光线（对齐下边缘窄度、降透明度、少渐变） */
    linear-gradient(to bottom, rgba(255,255,255,0.32) 0%, rgba(255,255,255,0.22) 0.5%, rgba(255,255,255,0) 1.05%),
    /* 下边缘：很窄的一条暗色条（书封底边厚度），高度约为原来的 2/3 */
    linear-gradient(to top, rgba(0,0,0,0.30) 0%, rgba(0,0,0,0.20) 0.5%, rgba(0,0,0,0) 1.05%),
    /* 整体柔和顶光渐变，增加体积 */
    linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,0.05) 100%);
}
/* 装订压痕（左侧竖折痕，和基础封面一致） */
.cover-cutout .cc-crease {
  position: absolute; left: 2.2cqw; top: 0; bottom: 0; width: 2.7cqw;
  z-index: 3; pointer-events: none;
  background: linear-gradient(to right,
    rgba(0,0,0,0) 0%, rgba(0,0,0,0.09) 45%, rgba(0,0,0,0.07) 55%, rgba(0,0,0,0) 100%);
}
/* 镂空窗口：白窗本身干净。切口厚度做在窗口外的【黄色皮面】上（见下方 box-shadow）。 */
.cover-cutout .cc-window {
  position: absolute;
  left: 34.5cqw; width: 31cqw;
  top: 30cqw; height: 41cqw;
  z-index: 2;
  overflow: hidden;
  background: #ffffff;
  /* 外投 box-shadow：投在四周黄色皮面上 = 皮面切出的凹槽壁。
     光从左上来 → 上壁/左壁暗（棕），下壁/右壁亮（高光，弱化 + 贴边对齐角点）。 */
  box-shadow:
    0 0 0 0.1cqw rgba(60,45,20,0.16),
    /* 左上：背光暗壁 */
    -0.45cqw -0.5cqw 0.9cqw -0.1cqw rgba(60,45,20,0.34),
    /* 右下：受光高光壁（弱化、收窄 blur，贴边让拐角更接近窗角） */
    0.4cqw 0.4cqw 0.5cqw -0.05cqw rgba(255,252,235,0.4),
    inset 0 0 0 0.08cqw rgba(0,0,0,0.10);
}
/* 镂空窗口位置：右上（只覆盖 left/top，宽高与阴影完全沿用居中态） */
.cover-cutout .cc-window--topright {
  left: 60cqw;
  top: 9cqw;
}
.cover-cutout .cc-window::after { display: none; }
/* 凹槽上壁投在图片上的一点点阴影（符合物理：光从上来，上壁遮挡）。窄而淡。 */
.cover-cutout .cc-window::before {
  content: '';
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.06) 2%, rgba(0,0,0,0) 5%),
    linear-gradient(to right, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0) 3%);
}
/* 窗口外圈：极细的一圈提亮，像皮面被切开露出的斜口高光 */
.cover-cutout .cc-window::after {
  content: '';
  position: absolute; inset: -0.5cqw;
  border-radius: 0.3cqw;
  box-shadow: 0 0.4cqw 0.8cqw rgba(0,0,0,0.12);
  pointer-events: none;
}
/* 窗口内图片 */
.cover-cutout .cc-window img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
  user-select: none; -webkit-user-drag: none;
}
/* 图片区保持干净：不在图片上叠切口阴影（切口体积做在窗口外的黄色皮面上） */
/* 底部文字 TIME TO ZINE（复用普通封面参数） */
.cover-cutout .cc-bottom-text {
  position: absolute; bottom: 8.75cqw; left: 0; right: 0;
  text-align: center; z-index: 3;
  color: var(--cover-text, #3a3320);
  font-family: 'Domine', Georgia, serif;
  font-size: 2.1875cqw; font-weight: 400;
  letter-spacing: 0.05cqw;
  text-transform: uppercase;
}
.page-indicator {
  position: absolute;
  /* 默认：阅读/封面态，缩略图栏贴底部（fallback 永远是底部，:has() 判错也不会飘） */
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  z-index: 401;  /* 高于工具栏 400，保证可见 */
  max-width: 85%; padding: 6px 10px;
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
/* 编辑态：工具栏 ~120px 高，缩略图栏上移避开 */
body:has(#editToolbar.toolbar-in) .page-indicator {
  bottom: calc(120px + env(safe-area-inset-bottom, 0));
}
/* 中间滚动区：按钮 flex 在两侧固定，缩略图在此横向滚动 */
.page-indicator-scroll {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}
.page-indicator-scroll::-webkit-scrollbar { display: none; }
.indicator-thumb {
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 3px;
  border: 1.5px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
  overflow: hidden;
  background: #fff;
  /* iOS：允许横滑滚动缩略图栏（pan-x），阻止其他手势（缩放/纵向滚/系统菜单） */
  touch-action: pan-x;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.indicator-thumb:active { transform: scale(0.94); }
.indicator-thumb.active { border-color: #1a1a1a; }
/* ★ 2026-07-16：选中态（"再点当前页"触发）—— 黑框加粗更明显 */
.indicator-thumb.selected {
  border-color: #1a1a1a;
  border-width: 2.5px;
}
/* ★ 2026-07-16：垃圾桶按钮复用 #teQuickBar 的黑色小气泡样式
   （黑底 + 白 icon + 底部小三角），position:fixed 挂 body 顶层
   之前的白底黑框圆按钮被用户吐槽丑，改回项目通用气泡风格保持一致 */
.thumb-trash-btn {
  position: fixed;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  background: #1a1a1a;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  color: #fff;
  cursor: pointer;
  transform: translate(-50%, -100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* 内部装 icon 的隐形容器尺寸 = 28×28（跟 #teQuickBar .te-qb-btn 一致） */
  width: 36px;
  height: 36px;
}
.thumb-trash-btn:active {
  background: #000;
}
.thumb-trash-btn svg {
  width: 18px;
  height: 18px;
}
/* 底部小三角，指向缩略图（跟 #teQuickBar::after 一致） */
.thumb-trash-btn::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #1a1a1a;
}
/* ── 长按拖拽换 spread 顺序：视觉反馈 ── */
/* 拖起来的克隆：跟手漂浮 + 半透明放大 + 无过渡 */
.indicator-thumb-drag-clone {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transform: scale(1.35);
  opacity: 0.9;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  border-radius: 3px;
  transition: none;
  will-change: transform, left, top;
}
/* 拖起源占位：变白 + 虚线边框，明确"这只是原来的位置" */
.indicator-thumb.dragging-source {
  opacity: 1;
  border: 1.5px dashed #999 !important;
  background: #fff;
}
.indicator-thumb.dragging-source > * {
  opacity: 0;
}
/* 落点指示：目标格稳定高亮，不区分左右不放大，避免闪烁 */
.indicator-thumb.drop-target {
  background: #fff5c2;
  box-shadow: 0 0 0 2px #1a1a1a;
  border-radius: 4px;
}
/* 拖拽期间：不改 overflow（自动滚动要用），仅屏蔽用户手动横滑（通过 pointer preventDefault 已够） */
.page-indicator-scroll.is-dragging {
  scroll-behavior: auto;
}
/* 拖拽期间禁用页面文字选择 + 禁 iOS 原生手势 */
body.is-dragging-thumb {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}
body.is-dragging-thumb * {
  touch-action: none !important;
}
/* 缩略图内部容器：等比缩放至 36px 宽（单页）或 48px（跨页） */
.thumb-cover {
  /* thumbfull2: 只包封面内容,不留空 */
  width: 24px; height: 36px;
  position: relative; overflow: hidden;
}
.thumb-spread {
  width: 48px; height: 36px;
  display: flex;
}
.thumb-half {
  width: 24px; height: 36px;
  position: relative; overflow: hidden;
}
/* 缩略图里禁用所有交互 + 缩放 page-content */
.indicator-thumb .page-content,
.indicator-thumb [data-cutout-root],
.indicator-thumb img {
  pointer-events: none !important;
}
.thumb-cover > *, .thumb-half > * {
  position: absolute !important;
  inset: 0 !important;
  /* ★ 塔塔模板重做后：内容以 hires-wrap 320x452 为基准（原本靠 scale(0.5) 缩到 160x226）。
     缩略图强制 width/height 到 320x452 + scale(0.075)（= 24/320），
     保持"图片布局按 320 走 → 整体几何缩到 24×36"，字号也一起缩，视觉与大图一致。
     旧值 width:160 + scale(0.15) 会让 textItem 字号看起来是大图的 2 倍。 */
  transform: scale(0.075) !important;
  transform-origin: top left !important;
  width: 320px !important;
  height: 452px !important;
}
.page-manage-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.85);
  border: none; cursor: pointer;
  display: none; /* 默认隐藏，reader/edit 态才显示 */
  align-items: center; justify-content: center;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
  transition: transform 0.15s, opacity 0.2s;
  padding: 0; flex-shrink: 0;
}
.page-manage-btn:active { transform: scale(0.85); }
.page-manage-btn svg { width: 12px; height: 12px; stroke: #555; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.page-manage-btn.pm-visible { display: flex; }

/* 编辑态 */
.edit-page-tag-inline { font-size: 11px; color: #999; letter-spacing: 0.3px; padding: 0 8px 0 4px; }
#editToolbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 6px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  z-index: 400; box-shadow: 0 -1px 0 rgba(0,0,0,0.06), 0 -4px 24px rgba(0,0,0,0.08);
}
#editToolbar.toolbar-in { transform: translateY(0); }
/* ★ v=am8e: toolbar-handle 已删除（原本是灰色小横条，无用还占空间） */
.toolbar-tools  { display: flex; justify-content: center; gap: 4px; padding: 0 16px; }
/* ★ 2026-07-15 图片选中浮层：盖在原工具栏之上（3 个按钮居中排） */
.toolbar-img-actions {
  position: absolute; left: 0; right: 0;
  top: 6px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  gap: 24px;
  display: none;
  align-items: center;
}
#editToolbar.img-selected .toolbar-img-actions { display: flex; }
.edit-tool {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; transition: transform 0.15s; flex: 1; max-width: 58px;
  padding: 4px 0;
}
.edit-tool:active { transform: scale(0.88); }
.edit-tool-icon {
  width: 44px; height: 44px; border-radius: 14px;
  background: #f5f5f5;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.edit-tool:active .edit-tool-icon { background: #ebebeb; }
.edit-tool-icon svg { width: 20px; height: 20px; stroke: #444; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.edit-tool-label { font-size: 10px; color: #777; letter-spacing: 0.2px; font-weight: 500; }

/* 模版操作浮层 */
#templatePicker {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 0 0; z-index: 450;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
  max-height: 60%; overflow: hidden;
  display: flex; flex-direction: column;
}
#templatePicker.tp-open { transform: translateY(0); }

/* ─── 素材库面板 ─── */
#assetPanel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 0 env(safe-area-inset-bottom, 0); z-index: 460;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
  /* am9M: 对齐模板浮层高度，防止内容少时浮层缩太小导致书页缩放算错 */
  min-height: 40vh; max-height: 60%; overflow: hidden;
  display: flex; flex-direction: column;
}
#assetPanel.ap-open { transform: translateY(0); }
.ap-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px 0 20px;              /* am9R3：左右都留 20px，视觉留白 */
  margin-bottom: 10px; flex-shrink: 0;
  position: relative;
  z-index: 3;
  gap: 12px;
}
.ap-header-left { flex: 1; min-width: 0; padding-right: 4px; }
.ap-header-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  padding-right: 44px;                   /* am9R3：给右上角 X 按钮留出安全区 */
}
/* am9R2：本页不放图按钮（灰底小胶囊） */
.ap-noimg-btn {
  height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid #e8e8e8;
  background: #fff; color: #555;
  font-size: 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.ap-noimg-btn:active { background: #f5f5f5; }
/* am9R2：应用 / 删除按钮（副标题右侧灰底方块） */
.ap-side-btn {
  width: 34px; height: 34px; padding: 0;
  border-radius: 8px; border: none;
  background: #f3f3f3; color: #333;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.ap-side-btn:active { background: #e8e8e8; }
.ap-title { font-size: 15px; font-weight: 600; color: #1a1a1a; }
.ap-subtitle { font-size: 11px; color: #999; margin-top: 2px; }
.ap-close {
  /* 44×44 真实命中区，视觉圆 26px（用 radial-gradient 画出灰底） */
  width: 44px; height: 44px;
  border-radius: 50%;
  color: #888; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  background:
    radial-gradient(circle at center, #f3f3f3 0, #f3f3f3 13px, transparent 13.5px);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 2;
}
.ap-close:active {
  background:
    radial-gradient(circle at center, #e5e5e5 0, #e5e5e5 13px, transparent 13.5px);
}

/* ═════════ 通用浮层关闭按钮（绝对定位，44×44 命中区） ═════════
 * 用法：直接放在浮层 (#bgPicker / #coverEditor / #templatePicker) 内部任意位置
 * 命中区 44×44，视觉是 28px 灰圆，位置固定在浮层右上角内侧
 * 不依赖 header 布局、不受 overflow:hidden 裁切影响
 */
.panel-close {
  position: absolute;
  top: 4px; right: 4px;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #888;
  background:
    radial-gradient(circle at center, #f3f3f3 0, #f3f3f3 14px, transparent 14.5px);
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  user-select: none; -webkit-user-select: none;
}
.panel-close:active {
  background:
    radial-gradient(circle at center, #e5e5e5 0, #e5e5e5 14px, transparent 14.5px);
}
.ap-action-row {
  display: flex; gap: 8px; padding: 0 16px 10px;
  flex-shrink: 0;
}
.ap-add-btn, .ap-apply-btn {
  flex: 1; min-height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: opacity 0.2s, background 0.2s;
}
/* 添加图片：黑底白字 */
.ap-add-btn { background: #1a1a1a; color: #fff; }
.ap-add-btn:active { opacity: 0.8; }
/* 应用到当前页：灰底黑字（不抢戏，跟添加图片同级） */
.ap-apply-btn { background: #f3f3f3; color: #1a1a1a; }
.ap-apply-btn:active { background: #e8e8e8; }
.ap-apply-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* 批量删除按钮：方形 icon，灰底，选中数为 0 时禁用 */
.ap-del-batch-btn {
  width: 38px; min-height: 38px; padding: 0;
  border-radius: 10px; border: none; cursor: pointer;
  background: #f3f3f3; color: #1a1a1a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, background 0.2s;
}
.ap-del-batch-btn:active { background: #e8e8e8; }
.ap-del-batch-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* 网格：5 列正方形格子，图按原比例完整显示（contain，不裁切） */
/* 关键：grid + grid-auto-rows + width 计算，比 aspect-ratio 在 iOS Safari 更稳 */
.ap-grid {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  grid-auto-rows: 1fr !important;
  gap: 6px !important;
  padding: 4px 20px 20px;                /* am9R3：与标题左右留白对齐 */
  overflow-y: auto;
  flex: 1; min-height: 0;
}
/* 每个格子：用 padding-bottom: 100% 强制正方形（iOS Safari 100% 支持，比 aspect-ratio 更兼容） */
.ap-grid-item {
  position: relative !important;
  width: 100% !important;
  padding-bottom: 100% !important;  /* 高度 = 宽度，强制正方形 */
  height: 0 !important;
  border-radius: 8px;
  background: #f3f3f3;
  cursor: pointer;
  border: 2px solid transparent;
  overflow: hidden;
}
/* ★ v=an3：素材图加载失败(空/坏 src) → 隐藏破图标，露出浅灰底 + 提示，避免纯黑吓人 */
.ap-grid-item > img.ap-img-broken { opacity: 0; }
.ap-grid-item:has(> img.ap-img-broken)::before {
  content: '图片丢失';
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #bbb; background: #f3f3f3;
}
.ap-grid-item > img {
  position: absolute !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  object-fit: contain !important;
  background: #fafafa;
  pointer-events: none;
}
/* ★ v=an5：选中态改为「高亮描边」而非压暗，跟"已用压暗"彻底区分。
   三态清晰：没用过=正常亮度；用过=压暗；选中=黑色粗边框+提亮(不管用没用过)
   注：.ap-grid-item 有 overflow:hidden，外投 box-shadow 会被裁，故用 inset 光晕 + 粗边框 */
.ap-grid-item.ap-selected {
  border-color: #1a1a1a;
  box-shadow: inset 0 0 0 2px #1a1a1a;
}
.ap-grid-item.ap-selected > img { filter: brightness(1.05) saturate(1.05); }
.ap-grid-item .ap-sel-badge {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #1a1a1a; color: #fff; font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.ap-grid-item.ap-selected .ap-sel-badge { display: flex; }
/* ★ v=an5：已用在页面上的素材 —— 仅用压暗区分(不加文字标签)，让没用过的图更醒目 */
.ap-grid-item.ap-used > img { filter: brightness(0.82); }
/* 选中态优先级更高：即使是已用图，选中时也走上面的提亮描边（这条留空占位说明，实际靠选择器权重） */
.ap-grid-item.ap-used.ap-selected > img { filter: brightness(1.05) saturate(1.05); }
.ap-grid-item .ap-del-btn {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.ap-grid-item:hover .ap-del-btn { opacity: 1; }
.ap-grid-item.ap-selected .ap-del-btn { display: none; }
.ap-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px 20px 30px; gap: 10px;
}
/* am9R2：空态时浮层收紧一点，避免圆和标题距离太远 */
#assetPanel.ap-empty-mode { min-height: 32vh; }
/* am9R：空态大圆按钮 */
.ap-empty-circle {
  width: 72px; height: 72px; border-radius: 50%;
  background: #f3f3f3; color: #666;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.ap-empty-circle:active { background: #e5e5e5; }
.ap-empty-hint { color: #888; font-size: 13px; }
/* am9R：网格末尾"+"卡片，虚线正方形 */
.ap-add-tile {
  position: relative !important;
  width: 100% !important;
  padding-bottom: 100% !important;
  height: 0 !important;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  border: 1.5px dashed #d0d0d0;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.ap-add-tile:active { background: #f5f5f5; border-color: #aaa; }
.ap-add-tile > svg {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #bbb;
}
/* am9R2：删除废弃的 .ap-topbar / .ap-top-* / .ap-source-* 样式（这些结构已不用） */
.tp-handle { width: 36px; height: 4px; background: #e0e0e0; border-radius: 2px; margin: 0 auto 10px; flex-shrink: 0; }
.tp-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 0 20px; margin-bottom: 14px; flex-shrink: 0;
}
.tp-title { font-size: 15px; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; letter-spacing: -0.3px; }
.tp-subtitle { font-size: 11px; color: #aaa; }
.tp-close-btn {
  width: 28px; height: 28px; border-radius: 50%; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #999; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
.tp-close-btn:active { background: #e0e0e0; }
.tp-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 32px; }
.tp-body::-webkit-scrollbar { display: none; }

/* 页面编辑模式切换：在图片入口旁提供独立文字模式 */
.tp-mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 0 20px; margin-bottom: 14px;
}
.tp-mode-btn {
  min-height: 46px; border: 1.5px solid #ececec; border-radius: 13px;
  background: #fafafa; color: #777; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 12px; font-weight: 650;
  transition: transform .15s, background .15s, color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tp-mode-btn:active { transform: scale(.97); }
.tp-mode-btn.tp-mode-active { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.tp-mode-icon { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.tp-mode-icon svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* 文字模式只保留新增文字按钮；提示直接浮在画布下方，不再使用底栏外框。 */
#textModeToolbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 455;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  border-radius: 0; background: transparent; box-shadow: none;
  transform: translateY(110%);
  transition: transform .35s cubic-bezier(.32,.72,0,1);
  pointer-events: none;
}
#textModeToolbar.text-mode-open { transform: translateY(0); pointer-events: none; }
.text-mode-topline { display: flex; align-items: center; justify-content: flex-start; }
.text-mode-add {
  height: 42px; padding: 0 14px; border: 0; border-radius: 12px;
  background: #1a1a1a; color: #fff; font: inherit; font-size: 12px; font-weight: 650;
  margin-left: auto; white-space: nowrap; cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
.text-mode-add:active { transform: scale(.97); }
.text-mode-hint {
  margin-top: 8px; border: 0; background: transparent; box-shadow: none;
  text-align: center; color: #999; font-size: 10px; line-height: 12px; letter-spacing: .1px;
  pointer-events: none;
}

body.text-edit-mode .te-text-item.te-editable,
body.text-edit-mode .hires-wrap { touch-action: none !important; }
body.text-edit-mode [data-img-crop],
body.text-edit-mode [data-img-crop] *,
body.text-edit-mode .cutout-item,
body.text-edit-mode .cutout-item * { pointer-events: none !important; }
body.text-edit-mode #coverFlipFront img,
body.text-edit-mode #coverBackContent img { pointer-events: none !important; }
body.text-edit-mode [data-img-crop][data-img-selected="1"]::after { display: none !important; }
body.text-edit-mode .cutout-item.cutout-selected { outline: none !important; }
body.text-edit-mode #navSwapBtn,
body.text-edit-mode #navDividerSwap,
body.text-edit-mode #navSwapBtnEdit,
body.text-edit-mode #navDividerSwapEdit { display: none !important; }
body.text-edit-mode #studioEditNavToolbar { display: none !important; }
body.text-edit-mode .te-text-item.te-editable { cursor: grab; }
body.text-edit-mode .te-text-item.te-gesture-active { cursor: grabbing; }

/* 文字拖到底部删除：单指拖动进入页面底部感应带后显示，松手命中时删除。 */
#textTrashDrop {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 510;
  min-width: 148px;
  height: 68px;
  padding: 0 20px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: rgba(20,20,20,.92);
  box-shadow: 0 14px 38px rgba(0,0,0,.26);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 24px) scale(.86);
  transform-origin: center bottom;
  pointer-events: none;
  transition: opacity .2s ease, transform .3s cubic-bezier(.22,.9,.3,1), background .18s ease, box-shadow .18s ease, visibility 0s linear .3s;
}
#textTrashDrop svg { width: 25px; height: 25px; flex: 0 0 auto; }
#textTrashDrop span { font-size: 11px; font-weight: 680; white-space: nowrap; }
#textTrashDrop.trash-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
  transition-delay: 0s;
}
#textTrashDrop.trash-hot {
  background: #c93131;
  box-shadow: 0 16px 42px rgba(201,49,49,.4);
  transform: translate(-50%, 0) scale(1.07);
}
body.te-text-dragging #textModeToolbar {
  transform: translateY(110%);
  pointer-events: none;
}
body.te-text-dragging #teInputBar { pointer-events: none; }
body.te-text-dragging #teQuickBar { display: none !important; }
body.te-text-dragging .te-text-item.te-delete-preview {
  opacity: .3 !important;
  filter: grayscale(.35);
}

@media (prefers-reduced-motion: reduce) {
  #textTrashDrop,
  body.te-text-dragging #textModeToolbar { transition-duration: .01ms; }
}

@media (pointer: coarse) {
  #teQuickBar .te-qb-btn { width: 44px; height: 44px; }
}

/* Step 1: 选择图片来源 */
.tp-source-row {
  display: flex; gap: 10px; padding: 0 20px; margin-bottom: 16px;
}
.tp-source-btn {
  flex: 1; height: 64px; border-radius: 16px;
  border: 1.5px solid #eee; background: #fafafa;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; transition: all 0.15s;
}
.tp-source-btn:active { transform: scale(0.96); background: #f0f0f0; }
.tp-source-btn .tp-src-icon { display: flex; align-items: center; justify-content: center; }
.tp-source-btn .tp-src-icon svg { width: 22px; height: 22px; stroke: #444; stroke-width: 1.8; fill: none; }
.tp-source-btn .tp-src-label { font-size: 11px; color: #666; font-weight: 500; }

/* 已上传图片预览 */
.tp-uploaded-row {
  padding: 0 20px; margin-bottom: 16px; display: none;
}
.tp-uploaded-row.has-imgs { display: block; }
.tp-uploaded-label { font-size: 11px; color: #aaa; letter-spacing: 0.3px; margin-bottom: 8px; text-transform: uppercase; }
.tp-uploaded-grid {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.tp-uploaded-thumb {
  width: 52px; height: 52px; border-radius: 10px;
  overflow: hidden; position: relative; flex-shrink: 0;
  border: 1.5px solid #eee;
}
.tp-uploaded-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tp-uploaded-thumb .tp-thumb-del {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  font-size: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1;
}
.tp-uploaded-add {
  width: 52px; height: 52px; border-radius: 10px;
  border: 1.5px dashed #ddd; background: #fafafa;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #ccc; cursor: pointer;
  transition: background 0.15s;
}
.tp-uploaded-add:active { background: #f0f0f0; }

/* Step 2: 模版变体选择 */
.tp-variants-section { padding: 0 20px; margin-bottom: 16px; display: none; }
.tp-variants-section.has-imgs { display: block; }
.tp-variants-label { font-size: 11px; color: #aaa; letter-spacing: 0.3px; margin-bottom: 10px; text-transform: uppercase; }
/* 排版分类 tab */
.tp-variants-tabs {
  display: flex; gap: 0; margin-bottom: 12px; border-radius: 8px;
  overflow: hidden; border: 1.5px solid #eee;
}
.tp-variants-tab {
  flex: 1; padding: 7px 0; text-align: center;
  font-size: 12px; font-weight: 600; color: #999;
  background: #fafafa; cursor: pointer;
  transition: all 0.18s; border: none; outline: none;
  letter-spacing: 0.2px;
}
.tp-variants-tab:not(:last-child) { border-right: 1.5px solid #eee; }
.tp-variants-tab.tp-tab-active {
  background: #1a1a1a; color: #fff;
}
.tp-variants-tab:active { opacity: 0.7; }
.tp-variants-grid {
  display: flex; gap: 8px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}
.tp-variants-grid::-webkit-scrollbar { display: none; }
/* ★ 2026-07-16：抠图开始/取消按钮容器 */
.tp-cutout-actions {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 10px; padding: 8px 0 4px;
}
.tp-cutout-start-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 20px; background: #1a1a1a; color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tp-cutout-start-btn:active { transform: scale(0.97); opacity: 0.85; }
.tp-cutout-cancel-btn {
  display: block;
  padding: 10px 20px; background: #fff; color: #1a1a1a;
  border: 1.5px solid #1a1a1a; border-radius: 8px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tp-cutout-cancel-btn:active { transform: scale(0.97); opacity: 0.85; }
.tp-cutout-status {
  text-align: center; font-size: 13px; color: #666;
  padding: 4px 0;
}
.tp-variant-card {
  flex-shrink: 0; width: 80px; cursor: pointer;
  transition: transform 0.15s;
}
.tp-variant-card:active { transform: scale(0.95); }
.tp-variant-preview {
  width: 80px; height: 113px; border-radius: 8px;
  border: 2px solid #eee; overflow: hidden;
  position: relative; background: #FFFFFF;
  transition: border-color 0.2s;
}
/* ★ 模板预览卡片：把 render() 出来的原始尺寸内容等比缩到 80x113
   render 内容按 .hires-wrap 基准尺寸 320x452 编写（字号、padding 都基于此）。
   ★ v=hd：为解决手机高 DPI 屏发糊，先 zoom:2 把 320 内容放到 640 像素密度，
      再 scale(0.125) 缩到 80x113。视觉大小不变，光栅化像素 4 倍 → 高清屏清晰。
      注：Safari 支持 zoom，跨浏览器兼容
   必须强制清 inset：render 根元素带 position:absolute;inset:0 会撑满父容器 */
.tp-variant-preview > * {
  position: absolute !important;
  top: 0 !important; left: 0 !important;
  right: auto !important; bottom: auto !important;
  zoom: 2 !important;
  transform: scale(0.125) !important;
  transform-origin: top left !important;
  width: 320px !important;
  height: 452px !important;
  pointer-events: none !important;
}
.tp-variant-card.tp-v-selected .tp-variant-preview { border-color: #1a1a1a; }
.tp-variant-name { font-size: 10px; color: #999; text-align: center; margin-top: 5px; letter-spacing: 0.2px; }

/* 色块颜色选择 */
.tp-color-section { padding: 0 20px; margin-bottom: 16px; display: none; }
.tp-color-section.has-imgs { display: block; }
.tp-color-label { font-size: 11px; color: #aaa; letter-spacing: 0.3px; margin-bottom: 8px; text-transform: uppercase; }
.tp-color-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tp-color-dot {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer;
  /* 不再用 border 占透明边（会把彩虹挤小），改用 box-shadow 做选中外环 */
  transition: transform 0.12s, box-shadow 0.15s;
  position: relative;
}
.tp-color-dot:active { transform: scale(0.88); }
/* 只有真正被选中的色才出现外环 */
.tp-color-dot.tp-c-selected { box-shadow: 0 0 0 2px #1a1a1a; }
/* 自定义色圆点：彩虹渐变（默认）。用户选完色后由 JS 改 inline style.background 覆盖，
   所以不能用 !important，否则 JS 改不动 */
.tp-color-dot.tp-custom-dot {
  background: conic-gradient(from 0deg,
    hsl(0,90%,60%),hsl(30,90%,58%),hsl(60,90%,56%),
    hsl(90,80%,52%),hsl(120,75%,50%),hsl(150,75%,52%),
    hsl(180,80%,55%),hsl(210,85%,58%),hsl(240,85%,62%),
    hsl(270,80%,62%),hsl(300,80%,60%),hsl(330,85%,60%),
    hsl(360,90%,60%));
  overflow: hidden;
}
/* 编辑排版浮层的"自定义颜色"独占下一行：彩虹按钮在左，灰字在右 */
.tp-custom-row {
  width: 100%; display: flex; flex-direction: row; align-items: center;
  gap: 10px; margin-top: 8px;
}
.tp-custom-hint-inline { font-size: 12px; color: #aaa; letter-spacing: 0.2px; }
/* RGB 色板行 */
.tp-color-picker-row {
  display: none; margin-top: 10px; align-items: center; gap: 8px;
}
.tp-color-picker-row.tp-picker-open { display: flex; }
.tp-color-picker-row input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 36px; border: 2px solid #e0e0e0; border-radius: 50%;
  padding: 0; cursor: pointer; background: none; overflow: hidden;
}
.tp-color-picker-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.tp-color-picker-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.tp-color-hex {
  font-size: 12px; color: #999; font-family: 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.3px; min-width: 60px;
}

/* ═══════ 描边区块（页面级：整页所有图片统一描边） ═══════ */
.tp-stroke-section .tp-stroke-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.tp-stroke-section .tp-color-label { margin-bottom: 0; }
/* iOS 风开关 */
.tp-switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.tp-switch input { opacity: 0; width: 0; height: 0; }
.tp-switch-slider {
  position: absolute; inset: 0; background: #e4e4e4; border-radius: 999px;
  transition: background 0.2s ease;
}
.tp-switch-slider::before {
  content: ''; position: absolute;
  width: 22px; height: 22px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.2s ease;
}
.tp-switch input:checked + .tp-switch-slider { background: #1a1a1a; }
.tp-switch input:checked + .tp-switch-slider::before { transform: translateX(18px); }

/* 确认按钮 sticky 在浮层底部，永远可见（v=h: 强制 display block，不依赖 has-imgs） */
#templatePicker .tp-confirm-row {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0));
  display: block !important; flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}
.tp-confirm-btn {
  width: 100%; height: 48px; border: none; border-radius: 14px;
  background: #1a1a1a; color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform 0.15s, opacity 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tp-confirm-btn:active { transform: scale(0.97); opacity: 0.85; }
.tp-confirm-btn.tp-disabled { opacity: 0.4; }
.tp-confirm-btn.tp-disabled:active { transform: none; opacity: 0.4; }

/* 导出浮层 */
#exportOverlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 600;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#exportOverlay.ex-open { display: flex; }
#exportPanel {
  background: #fff; border-radius: 20px;
  padding: 24px; width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: exportIn 0.3s ease;
}
@keyframes exportIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ex-title { font-size: 18px; font-weight: 700; color: #1a1a1a; margin-bottom: 6px; letter-spacing: -0.3px; }
.ex-desc { font-size: 12px; color: #999; margin-bottom: 20px; }
.ex-btn {
  width: 100%; height: 48px; border: none; border-radius: 14px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s, background 0.15s;
  margin-bottom: 10px;
}
.ex-btn-primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #171717 0%, #252525 58%, #5d244d 100%);
  box-shadow: 0 10px 24px rgba(0,0,0,0.16);
}
.ex-btn-primary:active { transform: translateY(1px); }
.ex-btn-social { min-height: 48px; font-size: 14px; }
.ex-btn-share-book { border-color: #cfcfcf; }
.ex-more-label {
  margin: 17px 2px 8px;
  color: #aaa;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}
.ex-btn:active { transform: scale(0.97); }
.ex-btn-primary { background: #1a1a1a; color: #fff; }
.ex-btn-secondary { background: #f4f4f4; color: #333; }
.ex-btn-cancel { background: none; color: #999; font-size: 13px; font-weight: 400; margin-bottom: 0; }

/* ── 导出中：隐藏所有格式按钮与标题描述，只留进度条 + 状态 + 取消按钮 ── */
#exportPanel.ex-busy .ex-title,
#exportPanel.ex-busy .ex-desc,
#exportPanel.ex-busy .ex-btn-primary,
#exportPanel.ex-busy .ex-btn-secondary,
#exportPanel.ex-busy .ex-more-label { display: none !important; }
/* 取消按钮改成醒目一点，让用户知道可以中断 */
#exportPanel.ex-busy .ex-btn-cancel {
  color: #d32f2f; font-size: 14px; font-weight: 500;
  margin-top: 8px;
}

.ex-progress {
  width: 100%; height: 4px; background: #f0f0f0; border-radius: 2px;
  margin: 12px 0; overflow: hidden; display: none;
}
.ex-progress-bar {
  height: 100%; background: #1a1a1a; border-radius: 2px;
  width: 0%; transition: width 0.3s;
}
.ex-status { font-size: 11px; color: #aaa; text-align: center; display: none; }

/* 抠图 loading：当前页加毛玻璃模糊（位置反馈），小条挂屏幕顶部（状态反馈） */
.cutout-loading-overlay {
  position: absolute; inset: 0; z-index: 600;
  background: rgba(255,255,255,0.3);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.cutout-loading-card {
  position: fixed;
  top: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  z-index: 9999;
}
.cutout-spinner {
  width: 14px; height: 14px;
  border: 2px solid #e0e0e0; border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: cutoutSpin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes cutoutSpin { to { transform: rotate(360deg); } }
.cutout-loading-text {
  font-size: 12px; color: #1a1a1a; letter-spacing: 0.2px;
}
.cutout-loading-progress {
  font-size: 11px; color: #999; font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

/* 抠图元素交互编辑 */
.cutout-item {
  position: absolute; touch-action: none;
  cursor: grab;
}
.cutout-item:active { cursor: grabbing; }
.cutout-item img {
  width: 100%; height: auto; display: block;
  pointer-events: none; user-select: none;
  -webkit-user-drag: none;
}
/* 选中态：灰色细虚线框（外边） + z-index 提升 */
.cutout-item.cutout-selected {
  z-index: 100 !important;
  outline: 1px dashed #999;
  outline-offset: 2px;
}
/* ★ 图片两段式选中态：黄色实线描边加在"图槽"（container）上
   用伪元素 ::after 而不是 outline/box-shadow 的原因：
   1) img 元素完全填满 container 会盖住 container 自己的 background/inset shadow
   2) 伪元素可以 z-index 到最顶层，绝不会被 img 或其他内容遮挡
   3) 伪元素相对 container 定位，不受 img transform:scale 影响，缩放图片时框不动
   4) pointer-events:none 保证不吃触摸事件
   模板画布 320×452 → scale(0.5) 到 160×226，所以宽度按 2× 写：4px 视觉约 2px */
[data-img-crop][data-img-selected="1"] {
  position: relative; /* 建立定位上下文供 ::after 使用 */
}
[data-img-crop][data-img-selected="1"]::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 4px solid #FFED00;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 9999;
}
/* 抠图选中态按钮组容器 */
.cutout-btn-group {
  position: absolute;
  left: 50%; top: -6px;
  transform: translate(-50%, -100%);
  display: flex;
  gap: 6px;
  z-index: 300;
  pointer-events: auto;
}
/* 加入素材库 / 删除 气泡按钮：白底黑字，简洁风 */
.cutout-asset-btn, .cutout-del-btn {
  background: #fff;
  color: #333;
  border: none;
  border-radius: 10px;
  padding: 3px 9px;
  font-size: 10px;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cutout-asset-btn:active, .cutout-del-btn:active { background: #f5f5f5; }
/* Toast 提示（白底黑字，简洁） */
.simple-toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #333;
  padding: 8px 16px;
  border-radius: 16px;
  font-size: 12px;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  text-align: center;
}
.simple-toast.show { opacity: 1; }

/* ═══════════════════════════════════════════════════
   常驻加载提示（2026-07-16 上传照片时用）
   ═══════════════════════════════════════════════════ */
.loading-toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.72);
  color: #fff;
  padding: 20px 24px;
  border-radius: 16px;
  font-size: 13px;
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 140px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.loading-toast.show { opacity: 1; }
.lt-spinner {
  width: 28px; height: 28px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ltSpin 0.9s linear infinite;
}
.lt-msg { color: #fff; }
@keyframes ltSpin {
  to { transform: rotate(360deg); }
}

/* ★ v=am3/am5/am6：模板序号(07)可点击热区扩大
   用 ::after 伪元素做透明覆盖层，不影响原元素盒模型 → 布局不会被撑大 */
.tpl-num-editable {
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  /* ★ v=am7d：极高 z-index 保证永远在图片之上 */
  z-index: 999 !important;
  pointer-events: auto !important;
}
/* 只在编辑模式（body.is-editing）下加透明点击热区
   ★ 加大到约 60×60 触控区（原 22/18 → 32/28），角落序号也能点到 */
body.is-editing .tpl-num-editable::after {
  content: '';
  position: absolute;
  left: -32px; right: -32px;
  top: -28px; bottom: -28px;
  /* 透明但可点击 */
  background: transparent;
  z-index: 1;
  pointer-events: auto;
}

/* ★ v=am7d：装饰文字（[Mind]/[ball]/body 等）在编辑态强制置顶 */
body.is-editing [data-tt-editable] {
  position: relative;
  z-index: 999 !important;
  pointer-events: auto !important;
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
}
/* am9P: 装饰文字始终禁用 Safari 双击缩放（不管是否编辑态） */
[data-tt-editable] {
  touch-action: manipulation;
}
/* 装饰文字热区扩大（编辑态） */
body.is-editing [data-tt-editable]::after {
  content: '';
  position: absolute;
  left: -8px; right: -8px;
  top: -6px; bottom: -6px;
  background: transparent;
  z-index: 1;
  pointer-events: auto;
}

/* ★ v=am3/am5/am6：抠图黄色序号 badge 点击热区扩大（伪元素透明层） */
.cutout-badge[data-badge-editable] {
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  position: absolute; /* 已有的，确认一下 */
}
body.is-editing .cutout-badge[data-badge-editable]::after {
  content: '';
  position: absolute;
  left: -20px; right: -20px;
  top: -16px; bottom: -16px;
  background: transparent;
  z-index: 1;
}
/* 拖拽中：只提升 z-index，不加 filter，保持画面干净 */
.cutout-item.cutout-dragging {
  z-index: 200 !important;
}

/* ── 抠图操纵杆面板 ── */
#cutoutJoystick {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 420;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.10);
}
#cutoutJoystick.cj-open { transform: translateY(0); }

.cj-handle { width: 36px; height: 4px; background: #e0e0e0; border-radius: 2px; margin: 0 auto 6px; }
.cj-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cj-title { font-size: 13px; font-weight: 600; color: #1a1a1a; letter-spacing: -0.2px; }
.cj-close-btn {
  width: 26px; height: 26px; border-radius: 50%; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #999; cursor: pointer; transition: background 0.15s;
}
.cj-close-btn:active { background: #e0e0e0; }

/* 元素选择条 */
.cj-items-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 0 0 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cj-items-row::-webkit-scrollbar { display: none; }
.cj-item-thumb {
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  border: 2px solid transparent; flex-shrink: 0; cursor: pointer;
  background: #f5f5f5; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, transform 0.15s;
}
.cj-item-thumb:active { transform: scale(0.92); }
.cj-item-thumb.cj-thumb-active { border-color: #ff5a5a; }
.cj-item-thumb img {
  width: 100%; height: 100%; object-fit: contain;
  pointer-events: none; user-select: none;
}

/* 控制区域 */
.cj-controls {
  display: none; /* 未选中时隐藏 */
  gap: 12px; align-items: center; padding-top: 6px;
}
.cj-controls.cj-has-selection { display: flex; }

/* 摇杆 */
.cj-joystick-wrap {
  width: 90px; height: 90px; flex-shrink: 0;
  position: relative;
}
.cj-joystick-ring {
  width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid #e8e8e8; background: #fafafa;
  position: relative; touch-action: none;
}
.cj-joystick-knob {
  width: 32px; height: 32px; border-radius: 50%;
  background: #1a1a1a; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  cursor: grab; touch-action: none;
  transition: box-shadow 0.15s;
}
.cj-joystick-knob:active { cursor: grabbing; box-shadow: 0 0 0 4px rgba(26,26,26,0.15); }
.cj-joystick-crosshair {
  position: absolute; top: 50%; left: 50%;
  width: 60%; height: 60%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cj-joystick-crosshair::before,
.cj-joystick-crosshair::after {
  content: ''; position: absolute; background: #e0e0e0;
}
.cj-joystick-crosshair::before {
  width: 1px; height: 100%; left: 50%; top: 0;
}
.cj-joystick-crosshair::after {
  height: 1px; width: 100%; top: 50%; left: 0;
}

/* 滑块区域 */
.cj-sliders {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
.cj-slider-row {
  display: flex; align-items: center; gap: 8px;
}
.cj-slider-label {
  font-size: 10px; color: #999; width: 24px; flex-shrink: 0;
  text-align: right; letter-spacing: 0.2px;
}
.cj-slider-track {
  flex: 1; height: 28px; position: relative;
  display: flex; align-items: center;
}
.cj-slider-track input[type="range"] {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: #eee; border-radius: 2px; outline: none;
}
.cj-slider-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: #1a1a1a; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.cj-slider-value {
  font-size: 10px; color: #bbb; width: 30px; text-align: left;
  font-variant-numeric: tabular-nums;
}

/* 层级按钮 */
.cj-layer-btns {
  display: flex; gap: 4px; justify-content: center; padding-top: 4px;
}
.cj-layer-btn {
  width: 32px; height: 26px; border-radius: 6px;
  border: 1.5px solid #eee; background: #fafafa;
  font-size: 12px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  color: #888; transition: all 0.15s;
}
.cj-layer-btn:active { background: #eee; transform: scale(0.92); }

/* ═══ 文字系统 ═══ */

/* 页面上的文字元素（渲染在书页内，跟着 scale 走） */
.te-text-item {
  position: absolute; z-index: 50;
  padding: 2px 4px;
  cursor: default;
  word-break: break-word; line-height: 1.4;
  pointer-events: auto;
  -webkit-user-select: none; user-select: none;
  /* am9O: 禁用 Safari 双击缩放，只保留 tap/pan */
  touch-action: manipulation;
}
/* ★ v=al7：装饰文字转来的 textItem 不换行，宽度自适应 */
.te-text-item.te-nowrap {
  white-space: nowrap !important;
  word-break: normal !important;
  width: auto !important;
  max-width: none !important;
}
/* ★ v=al7：装饰文字转来的 textItem 不换行，宽度自适应 */
.te-text-item.te-nowrap {
  white-space: nowrap !important;
  word-break: normal !important;
  width: auto !important;
  max-width: none !important;
}
/* 编辑模式下的文字 — 可点击/可拖拽 */
.te-text-item.te-editable {
  cursor: grab; border: 1px dashed transparent; border-radius: 3px;
  transition: border-color 0.15s;
  /* am9Q6：改 none → manipulation 阻止 Safari 双击缩放；拖动是手动 pointerdown 处理，不受影响 */
  touch-action: manipulation;
  -webkit-user-drag: none;
  /* 空文字也有最小可见区，让用户能看到位置 + 手柄不塌陷 */
  min-width: 24px; min-height: 16px;
}
.te-text-item.te-editable:hover { border-color: rgba(26,26,26,0.35); }
.te-text-item.te-text-item-active {
  border-color: rgba(26,26,26,0.7) !important;
  box-shadow: 0 0 0 2px rgba(26,26,26,0.12);
}

/* ★ v=ao2：单击文字/模板文字 → 出黑色 dashed 选中框（跟浮层打开时的高亮不同，无 shadow） */
.te-tap-selected {
  outline: 1.5px dashed rgba(26,26,26,0.7) !important;
  outline-offset: 2px;
  border-radius: 3px;
}
body.text-edit-mode .te-tap-selected {
  outline: 1.5px solid rgba(26,26,26,.86) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.75), 0 2px 12px rgba(0,0,0,.11);
}
/* 选中态时抑制 .te-editable 的 hover dashed border，避免"两层框" */
.te-text-item.te-editable.te-tap-selected { border-color: transparent !important; }
.te-text-item.te-editable.te-tap-selected:hover { border-color: transparent !important; }

/* 右下角缩放手柄 — 仅编辑态显示 */
.te-sticker-resize {
  display: none;
  position: absolute;
  right: -7px; bottom: -7px;
  width: 14px; height: 14px;
  background: #fff;
  border: 1.5px solid rgba(26,26,26,0.8);
  border-radius: 50%;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
/* ★ v=am8l：手柄默认不显示，只在 hover / 选中(active) 时才显示
   之前 .te-editable 就显示 → 用户拖文字时手指容易误触手柄，把宽度改成很小 */
.te-text-item.te-editable:hover .te-sticker-resize,
.te-text-item.te-text-item-active .te-sticker-resize {
  display: block;
  background: #1a1a1a;
  border-color: #fff;
}

/* ── 文字编辑高浮层（v=am9 轻量版） ── */
#teInputBar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  z-index: 480; transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.10);
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  /* v=am9：不再限制 max-height + 滚动 —— 浮层内容极简，一屏必然够 */
}
#teInputBar.te-open { transform: translateY(0); }

/* v=am9：轻量 header —— 只保留标题居中，无按钮 */
.te-ib-header-lite {
  display: flex; align-items: center; justify-content: center;
  padding: 4px 16px 6px;
  background: #fff;
}
.te-ib-header-lite .te-ib-title {
  font-size: 13px; font-weight: 500; color: #666;
}

/* v=am9：tab 横条 */
.te-tabbar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 16px 8px;
  border-bottom: 1px solid #f2f2f2;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.te-tabbar::-webkit-scrollbar { display: none; }
.te-tab {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px; color: #999; font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  user-select: none; -webkit-user-select: none;
}
.te-tab:active { background: #f5f5f5; }
.te-tab.te-tab-active {
  color: #1a1a1a; font-weight: 700;
}

/* v=am9：tab 内容行 —— 默认全部隐藏，只在对应 tab 激活时显示 */
.te-row-tab { display: none !important; }
.te-row-tab.te-row-tab-active { display: flex !important; }
/* ★ v=ao2：多小行的 tab（颜色 tab 有字色+透明度、格式 tab 有格式+对齐）→ 竖排 */
.te-row-tab.te-row-multi.te-row-tab-active {
  flex-direction: column; gap: 10px; align-items: stretch;
}

/* 顶部拖把（仿其他浮层） */
.te-ib-grabber {
  width: 36px; height: 4px; background: #e0e0e0; border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}

/* 头部：取消 / 标题 / 完成 */
.te-ib-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 8px;
  position: sticky; top: 0; background: #fff; z-index: 2;
  border-bottom: 1px solid #f2f2f2;
}
.te-ib-title { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.te-ib-btn {
  height: 32px; padding: 0 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.te-ib-btn:active { transform: scale(0.95); }
.te-ib-btn-done { background: #1a1a1a; color: #fff; }
.te-ib-btn-cancel { background: #f0f0f0; color: #666; }

/* 输入框 */
.te-ib-input-wrap { padding: 12px 16px 4px; }
#teInput {
  width: 100%; min-height: 40px; max-height: 100px;
  border: 1.5px solid #e8e8e8; border-radius: 12px;
  padding: 8px 12px; font-size: 15px; line-height: 1.4;
  resize: none; outline: none; font-family: inherit;
  transition: border-color 0.15s; background: #fafafa;
  box-sizing: border-box;
}
#teInput:focus { border-color: #1a1a1a; background: #fff; }

/* 控件分行容器 */
.te-ib-rows { padding: 8px 16px 16px; min-height: 44px; }
.te-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  /* v=am9：轻量版一次只显示 1 行 tab 内容，不再需要行间分隔线 */
}
.te-row:last-child { border-bottom: none; }
.te-row-label {
  /* v=am9：tab 已经在上面标了名，这里 label 不再需要 */
  display: none;
}
.te-row-ctrl {
  flex: 1; display: flex; align-items: center; gap: 10px;
  min-width: 0; /* 允许子元素 ellipsis */
}
.te-row-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  gap: 8px; padding-right: 8px;
}
.te-row-scroll::-webkit-scrollbar { display: none; }

/* 颜色圆点（行内）：所有色块尺寸严格等大 */
.te-color-dot {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 1px solid #e0e0e0; /* 固定细边，不会动盒子 */
  box-sizing: border-box;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.15s;
  padding: 0;
  background-clip: padding-box; /* 防止白色色块被边色透出来 */
}
.te-color-dot:active { transform: scale(0.88); }
.te-color-dot.te-c-active {
  /* 选中：用 box-shadow 做双圈，盒模型不变 */
  box-shadow: 0 0 0 2px #1a1a1a, inset 0 0 0 2px #fff;
}

/* 彩虹自定义色块（首位） */
.te-color-dot-rainbow {
  background: conic-gradient(
    from 0deg,
    #ff4d4d, #ffae00, #ffe600, #6fd64d,
    #4dc8ff, #4d6aff, #c14dff, #ff4dbf, #ff4d4d
  );
  position: relative;
  /* 当它是 <label> 时，确保对内部 input 的点击穿透到 label */
  display: inline-block;
}
.te-color-dot-rainbow::after {
  /* 中心小白点提示这是"自定义" */
  content: ''; position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  pointer-events: none; /* 不挡 label 点击 */
}

/* 隐藏的原生 color picker：必须留在文档流里，iOS 才弹得出 */
.te-color-picker-hidden {
  position: absolute;
  left: 50%; top: 0;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
}

/* （字体卡片已移除：不再让用户选字体） */

/* 通用滑块 */
.te-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: #e5e5e5; outline: none;
  min-width: 80px;
}
.te-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #1a1a1a; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.te-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: #1a1a1a; cursor: pointer;
}
.te-slider-val {
  font-size: 12px; color: #555; min-width: 36px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 格式按钮组 */
.te-fmt-row { gap: 10px; }

/* ★ v=ao2：字体选择胶囊（字体行内滚动） —— 直接用该字体渲染字体名 */
.te-font-chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1.5px solid #eee; background: #fafafa;
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
  color: #333; font-size: 15px; line-height: 1;
}
.te-font-chip:active { transform: scale(0.96); }
.te-font-chip.te-font-chip-active {
  background: #1a1a1a; border-color: #1a1a1a; color: #fff;
}

.te-style-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid #eee;
  background: #fafafa; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
  font-size: 14px; color: #555; font-weight: 600;
}
.te-style-btn:active { transform: scale(0.9); }
.te-style-btn.te-active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

/* ★ 装饰文字模式（模板 body / [ball] / Music* 等）：
   v=am9 更新：只显示"字号" tab，其他 tab 隐藏，避免用户误触发丑陋样式 */
#teInputBar.te-tt-decor-mode .te-tab:not([data-tab="size"]) {
  display: none !important;
}
#teInputBar.te-tt-decor-mode .te-row-tab:not([data-tab="size"]) {
  display: none !important;
}

/* ── v=am9：文字/贴纸头顶操作条 ── */
#teActionBar {
  position: absolute;
  z-index: 470;
  background: #fff;
  border-radius: 999px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.04);
  pointer-events: auto;
  transition: opacity 0.15s;
}
.te-act-btn {
  width: 36px; height: 36px;
  border: none; background: transparent;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #333;
  transition: background 0.12s, transform 0.1s;
}
.te-act-btn:active { transform: scale(0.9); background: #f0f0f0; }
.te-act-btn.te-act-btn-danger { color: #d33; }

/* 删除按钮：右下角浮动（中性灰，符合黑白灰视觉规范） */
.te-ib-btn-del {
  position: absolute;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 38px; height: 38px; border-radius: 50%;
  background: #fafafa; border: 1.5px solid #e5e5e5;
  color: #666; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.15s; padding: 0;
  z-index: 3;
}
.te-ib-btn-del:active { transform: scale(0.9); background: #f0f0f0; }

/* ═════════════════════════════════════════════════
   导出第二步：缩略图勾选面板
   ═════════════════════════════════════════════════ */
#exPickerOverlay {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(0,0,0,0.55);
  display: none; align-items: stretch; justify-content: center;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#exPickerPanel {
  width: 100%; max-width: 480px; margin: auto;
  height: 90vh; max-height: 760px;
  background: #fff; border-radius: 18px;
  display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,0.25);
}
.exp-header {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px; border-bottom: 1px solid #f0f0f0;
}
.exp-title { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.exp-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f3f3f3; color: #666;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; user-select: none;
}
.exp-close:active { background: #e5e5e5; }
.exp-toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid #f5f5f5;
}
.exp-tool-btn {
  padding: 5px 12px; font-size: 12px;
  border: 1px solid #ddd; border-radius: 14px;
  background: #fff; color: #333; cursor: pointer;
}
.exp-tool-btn:active { background: #f3f3f3; }
.exp-count { margin-left: auto; font-size: 12px; color: #888; }

/* ── 清晰度选择行 ── */
.exp-quality-row {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid #f5f5f5;
  font-size: 12px;
}
.exp-quality-label { color: #666; flex: 0 0 auto; }
.exp-quality-seg {
  display: inline-flex; align-items: stretch;
  border: 1px solid #ddd; border-radius: 14px; overflow: hidden;
  background: #fff;
}
.exp-q-btn {
  padding: 5px 12px; font-size: 12px;
  border: none; background: transparent; color: #333;
  cursor: pointer; border-right: 1px solid #ddd;
}
.exp-q-btn:last-child { border-right: none; }
.exp-q-btn:active { background: #f3f3f3; }
.exp-q-btn.exp-q-active { background: #1a1a1a; color: #fff; }
.exp-quality-hint { margin-left: auto; font-size: 11px; color: #999; }
.exp-grid {
  flex: 1 1 auto; overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); /* ★ 一排 3 个 */
  gap: 10px; padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.exp-card {
  position: relative; cursor: pointer; user-select: none;
  border-radius: 10px; overflow: hidden;
  border: 2px solid transparent;
  background: #fafafa;
  opacity: 0.55; /* ★ 默认未选中：半透明灰 */
  transition: border-color .15s, transform .1s, opacity .15s, box-shadow .15s;
}
.exp-card.selected {
  border-color: #1a1a1a;
  opacity: 1; /* ★ 选中：黑色边框 + 完全不透明 */
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}
.exp-card:active { transform: scale(0.97); }
/* ★ 缩略图：正方形（aspect-ratio 兜底 + JS 强写 height = width） */
.exp-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* CSS 兜底 */
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
/* ★ inner 容器按真实页尺寸 640x904 渲染，居中后用 scale 整体缩放至完全装进正方形 thumb（letterbox 留白） */
.exp-thumb-inner {
  position: absolute;
  left: 50%; top: 50%;
  width: 640px;
  height: 904px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--exp-scale, 0.15));
  pointer-events: none;
  background: #fff;
}
.exp-check {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #bbb; border: 1.5px solid #d8d8d8;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  transition: all .15s;
}
.exp-card.selected .exp-check {
  background: #1a1a1a; color: #fff; border-color: #1a1a1a;
}
.exp-label {
  text-align: center; font-size: 11px; color: #666;
  padding: 6px 0 4px;
}
.exp-footer {
  flex: 0 0 auto;
  padding: 12px 18px 16px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.exp-confirm-btn {
  width: 100%; height: 44px; border-radius: 22px;
  background: #1a1a1a; color: #fff; font-size: 15px; font-weight: 600;
  border: none; cursor: pointer;
}
.exp-confirm-btn:disabled {
  background: #e0e0e0; color: #999; cursor: not-allowed;
}
.exp-confirm-btn:not(:disabled):active { background: #000; }
.exp-tip {
  text-align: center; font-size: 11px; color: #aaa;
  margin-top: 8px;
}

/* ════════════════════════════════════════
   模板内的占位文字（如 "点击「文字」添加内容"）
   - 默认 pointer-events:none，不挡其它操作
   - 只在编辑态变成可点（由 body[data-studio-state="edit"] 控制）
   - 导出路径会直接剥掉这类节点（_stripPlaceholders），所以不会出现在成品里
   ════════════════════════════════════════ */
.tpl-placeholder {
  pointer-events: none;
  user-select: none;
  font-style: italic;
  opacity: 0.85;
  transition: color 0.15s, opacity 0.15s;
}
body[data-studio-state="edit"] .tpl-placeholder {
  pointer-events: auto;
  cursor: pointer;
}
body[data-studio-state="edit"] .tpl-placeholder:hover {
  color: #888 !important;
  opacity: 1;
}

/* ── am9L：文字头顶操作条 ── */
#teQuickBar {
  position: fixed;
  z-index: 490;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transform: translate(-50%, -100%);
  /* JS 会设置 left/top，这里只定基础样式 */
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}
#teQuickBar .te-qb-btn {
  width: 28px; height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s;
}
#teQuickBar .te-qb-btn:active {
  background: rgba(255,255,255,0.15);
}
/* 底部小三角，指向文字 */
#teQuickBar::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #1a1a1a;
}

/* ── am9M：纯享模式（阅读态隐藏所有工具栏） ── */
body.pure-view #studioNav,
body.pure-view #pageIndicator,
body.pure-view #editToolbar,
body.pure-view #coverHomeActions {
  display: none !important;
}

/* 默认观赏模式：从封面开始，只保留书本本体和翻页手势。 */
body.book-viewing #studioNav,
body.book-viewing #pageIndicator,
body.book-viewing #editToolbar,
body.book-viewing #coverHomeActions,
body.book-viewing .ob-cover-hint,
body.book-viewing .ob-reader-hint,
body.book-viewing .ob-swipe-hint,
body.book-viewing .ob-thumb-hint {
  display: none !important;
}
body.book-viewing #stCover {
  padding-top: 0;
  gap: 0;
}
body.book-viewing #bookContainer {
  margin-top: 0;
}
/* 单页观赏：实际仍保留完整跨页与 3D 翻页结构，封面背面/左页为主画面，
   右页只在画面右缘露出纸边。 */
body.book-viewing #bookContainer.reader-mode #bookBase {
  box-shadow:
    0 24px 72px rgba(0,0,0,0.22),
    0 4px 16px rgba(0,0,0,0.12);
}
body.book-viewing #bookContainer.reader-mode #coverFlip {
  box-shadow: 0 18px 48px rgba(0,0,0,0.14);
}
body.book-viewing #studioView {
  cursor: default;
}

/* ── 观赏模式：返回 / 分享 ───────────────────────────── */
#viewerChrome {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  z-index: 860;
  display: none;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transition: opacity .28s ease, transform .34s cubic-bezier(.22,.72,0,1);
  transform: translateY(-5px);
}
body.book-viewing #viewerChrome {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.viewer-chrome-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 15px;
  background: rgba(255,255,255,.92);
  color: #171717;
  box-shadow: 0 8px 30px rgba(0,0,0,.13), inset 0 0 0 .5px rgba(0,0,0,.06);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, opacity .2s ease;
}
.viewer-chrome-btn:active { transform: scale(.9); background: #fff; }
.viewer-chrome-btn svg { width: 21px; height: 21px; pointer-events: none; }

/* 分享面板：仅保留单页 JPG 与整本分享。 */
#viewerShareOverlay {
  position: absolute;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  background: rgba(10,10,12,.42);
  -webkit-backdrop-filter: blur(14px) saturate(.82);
  backdrop-filter: blur(14px) saturate(.82);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
#viewerShareOverlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.viewer-share-panel {
  position: relative;
  width: 100%;
  max-width: 396px;
  padding: 28px 18px 18px;
  border-radius: 26px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 30px 90px rgba(0,0,0,.28);
  transform: translateY(34px) scale(.98);
  opacity: .4;
  transition: transform .42s cubic-bezier(.2,.82,.18,1), opacity .24s ease;
}
#viewerShareOverlay.is-open .viewer-share-panel { transform: translateY(0) scale(1); opacity: 1; }
.viewer-share-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f0f0f0;
  color: #676767;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.viewer-share-kicker {
  margin-bottom: 7px;
  color: #979797;
  font-family: 'Domine', Georgia, serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.8px;
}
.viewer-share-panel h2 { font-size: 23px; letter-spacing: -.7px; color: #151515; }
.viewer-share-panel > p { margin: 7px 0 22px; color: #8c8c8c; font-size: 13px; }
.viewer-share-option {
  width: 100%;
  min-height: 68px;
  padding: 10px 13px;
  margin-top: 10px;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 18px;
  background: #f5f5f5;
  color: #1d1d1d;
  display: grid;
  grid-template-columns: 42px 1fr 20px;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.viewer-share-option-primary { background: #171717; color: #fff; }
.viewer-share-option:active { transform: scale(.975); }
.viewer-share-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: #fff;
  color: #111;
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.viewer-share-option strong { display: block; font-size: 15px; line-height: 1.25; }
.viewer-share-option small { display: block; margin-top: 4px; color: #969696; font-size: 11px; font-weight: 400; }
.viewer-share-option-primary small { color: rgba(255,255,255,.58); }
.viewer-share-option-arrow { color: #a2a2a2; font-size: 24px; text-align: right; }

/* ── 长按页面：Cover Flow 模板选择 ────────────────────── */
#viewerTemplateMode,
#viewerCoverTemplateMode {
  position: absolute;
  inset: 0;
  z-index: 1420;
  overflow: hidden;
  background: rgba(233,234,236,.96);
  -webkit-backdrop-filter: blur(18px) grayscale(1) saturate(.35);
  backdrop-filter: blur(18px) grayscale(1) saturate(.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .34s ease, visibility 0s linear .34s;
}
#viewerTemplateMode.is-open,
#viewerCoverTemplateMode.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
body.viewer-template-mode #bookContainer,
body.viewer-cover-template-mode #bookContainer {
  opacity: 0 !important;
  filter: blur(18px) grayscale(1) saturate(.2);
  transform: scale(.88) !important;
  transition: opacity .3s ease, filter .38s ease, transform .42s cubic-bezier(.22,.72,0,1) !important;
}
body.viewer-template-mode #viewerChrome,
body.viewer-cover-template-mode #viewerChrome { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.viewer-template-topbar {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  z-index: 4;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .3s ease .14s, transform .38s cubic-bezier(.22,.72,0,1) .12s;
}
#viewerTemplateMode.is-open .viewer-template-topbar,
#viewerCoverTemplateMode.is-open .viewer-template-topbar { opacity: 1; transform: translateY(0); }
.viewer-template-topbar-spacer { width: 64px; height: 1px; }
.viewer-template-kicker { color: #9a9a9a; font-family: 'Domine', Georgia, serif; font-size: 8px; letter-spacing: 1.45px; }
#viewerTemplateTitle,
#viewerCoverTemplateTitle { margin-top: 3px; color: #242424; font-size: 13px; font-weight: 700; }
.viewer-template-count { color: #8e8e8e; font-family: 'Domine', Georgia, serif; font-size: 11px; text-align: right; }
.viewer-template-stage {
  position: absolute;
  inset: 74px 0 calc(108px + env(safe-area-inset-bottom, 0px));
  perspective: 1100px;
  touch-action: none;
  cursor: grab;
}
.viewer-template-stage.is-dragging { cursor: grabbing; }
.viewer-template-stage.is-background-dragging { cursor: ew-resize; }
#viewerCoverTemplateStage { bottom: calc(108px + env(safe-area-inset-bottom, 0px)); }
.viewer-template-track { position: absolute; inset: 0; transform-style: preserve-3d; }
#viewerTemplateMode.is-scene-background-changing::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(255,255,255,.10);
  animation: viewer-scene-background-in .34s ease both;
}
@keyframes viewer-scene-background-in {
  from { opacity: .72; }
  to { opacity: 0; }
}
.viewer-template-stage { z-index: 2; }
.viewer-template-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160px;
  height: 226px;
  margin-left: -80px;
  margin-top: -113px;
  transform-origin: center center;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
}
.viewer-template-card.is-center {
  pointer-events: auto;
  touch-action: none;
}
.viewer-template-card.is-center img { -webkit-touch-callout: none; }
.viewer-template-card:not(.is-dragging) {
  transition: transform .46s cubic-bezier(.2,.78,.18,1);
}
.viewer-template-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 26px 72px rgba(0,0,0,.23), 0 6px 18px rgba(0,0,0,.12);
  backface-visibility: hidden;
}
.viewer-template-card.is-center .viewer-template-page { box-shadow: 0 30px 84px rgba(0,0,0,.26), 0 8px 20px rgba(0,0,0,.13); }
.viewer-template-actions {
  position: absolute;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translateX(-50%);
}
.viewer-template-assets-btn {
  position: absolute;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  color: #171717;
  display: grid;
  place-items: center;
  transform: translate(-50%, 8px) scale(.92);
  opacity: 0;
  box-shadow: 0 12px 34px rgba(0,0,0,.17), inset 0 0 0 1px rgba(0,0,0,.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .28s ease .17s, transform .42s cubic-bezier(.2,.82,.18,1) .14s;
}
#viewerTemplateMode.is-open .viewer-template-assets-btn,
#viewerCoverTemplateMode.is-open .viewer-template-assets-btn { opacity: 1; transform: translate(-50%, 0) scale(1); }
.viewer-template-assets-btn:active { transform: translate(-50%, 0) scale(.94) !important; }
.viewer-template-actions .viewer-template-assets-btn {
  position: relative;
  left: auto;
  bottom: auto;
  flex: 0 0 56px;
  transform: translateY(8px) scale(.92);
}
#viewerTemplateMode.is-open .viewer-template-actions .viewer-template-assets-btn,
#viewerCoverTemplateMode.is-open .viewer-template-actions .viewer-template-assets-btn {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.viewer-template-actions .viewer-template-assets-btn:active {
  transform: translateY(0) scale(.94) !important;
}
.viewer-template-text-glyph {
  display: block;
  font-family: 'Domine', Georgia, serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-1px);
}
body.viewer-mode #viewerTemplateTextBtn,
body.viewer-mode #viewerCoverAssetsBtn,
body.viewer-mode #viewerCoverTextBtn { display: none !important; }
.viewer-template-assets-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
}
.viewer-template-assets-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.viewer-template-photo-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #171717;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 11px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 3px 9px rgba(0,0,0,.23);
}

/* ── 阅读模式素材库 ───────────────────────────────────── */
#viewerAssetMode,
#viewerCoverAssetMode {
  position: absolute;
  inset: 0;
  z-index: 18;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility 0s linear .3s;
}
#viewerAssetMode.is-open,
#viewerCoverAssetMode.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.viewer-asset-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(18,18,20,.2);
  -webkit-backdrop-filter: blur(6px) saturate(.7);
  backdrop-filter: blur(6px) saturate(.7);
}
.viewer-asset-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(58%, 560px);
  min-height: 360px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  background: rgba(252,252,252,.98);
  box-shadow: 0 -18px 60px rgba(0,0,0,.19);
  display: flex;
  flex-direction: column;
  transform: translateY(104%);
  transition: transform .42s cubic-bezier(.2,.82,.18,1);
}
#viewerAssetMode.is-open .viewer-asset-sheet,
#viewerCoverAssetMode.is-open .viewer-asset-sheet { transform: translateY(0); }
.viewer-asset-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 9px;
  border-radius: 99px;
  background: #d2d2d2;
  flex: none;
}
.viewer-asset-header {
  min-height: 55px;
  padding: 0 18px 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
}
.viewer-asset-header h2 { margin: 0; color: #171717; font-size: 17px; line-height: 1.2; }
.viewer-asset-header p { margin: 4px 0 0; color: #969696; font-size: 11px; }
.viewer-asset-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.viewer-asset-info-toggle,
.viewer-asset-apply,
.viewer-asset-close {
  height: 36px;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.viewer-asset-info-toggle {
  min-width: 78px;
  padding: 0 10px;
  border: 1px solid rgba(23, 23, 23, .09);
  border-radius: 12px;
  background: rgba(242, 242, 242, .94);
  color: #6d6d6d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}
.viewer-asset-info-toggle:active { transform: scale(.96); }
.viewer-asset-info-toggle.is-active {
  border-color: #181818;
  background: #181818;
  color: #fff;
}
.viewer-asset-info-icon {
  width: 15px;
  height: 15px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10px;
  font-style: italic;
  line-height: 1;
}
.viewer-asset-apply {
  min-width: 58px;
  padding: 0 15px;
  border-radius: 12px;
  background: #171717;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.viewer-asset-close {
  width: 36px;
  padding: 0;
  border-radius: 50%;
  background: #ededed;
  color: #6f6f6f;
  font-size: 21px;
  font-weight: 300;
}

/* 照片信息只出现在图片框外；JS 会按模板留白自动选择上、下或侧边。 */
.photo-info-chip {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  color: rgba(20,20,20,.76);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 7px;
  font-weight: 520;
  line-height: 1.28;
  letter-spacing: .055em;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
body.text-edit-mode .photo-info-chip[data-photo-info-editable="1"] {
  pointer-events: auto !important;
  cursor: text;
  z-index: 1001;
  border-radius: 2px;
  outline: 1px dashed rgba(15, 15, 15, .28);
  outline-offset: 3px;
}
body.text-edit-mode .photo-info-chip[data-photo-info-editable="1"].is-on-dark,
body.text-edit-mode .photo-info-chip[data-photo-info-editable="1"].is-inside {
  outline-color: rgba(255, 255, 255, .52);
}
.photo-info-empty-label { display: none; white-space: nowrap; }
.photo-info-chip.is-empty { visibility: hidden !important; opacity: 0 !important; }
body.text-edit-mode .photo-info-chip.is-empty[data-photo-info-editable="1"] {
  visibility: visible !important;
  opacity: .72 !important;
}
body.text-edit-mode .photo-info-chip.is-empty .photo-info-empty-label { display: inline-block; }
.photo-info-chip::before {
  content: '';
  display: block;
  width: 14px;
  height: 1px;
  margin-bottom: 3px;
  background: currentColor;
  opacity: .48;
}
.photo-info-chip::after {
  content: '';
  display: none;
  width: 14px;
  height: 1px;
  margin-top: 3px;
  background: currentColor;
  opacity: .48;
}
.photo-info-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 5px;
  row-gap: 1px;
  overflow: visible;
  white-space: normal;
}
.photo-info-line:empty { display: none; }
.photo-info-line:not(:empty) + .photo-info-line:not(:empty) {
  margin-top: 2px;
}
.photo-info-item {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
}
.photo-info-chip.is-above::before { display: none; }
.photo-info-chip.is-above::after { display: block; }
.photo-info-chip.is-left { text-align: right; }
.photo-info-chip.is-left .photo-info-line,
.photo-info-chip.is-inside-right .photo-info-line { justify-content: flex-end; }
.photo-info-chip.is-left::before,
.photo-info-chip.is-right::before {
  position: absolute;
  top: 1px;
  width: 1px;
  height: 14px;
  margin: 0;
}
.photo-info-chip.is-left { padding-right: 5px; }
.photo-info-chip.is-left::before { right: 0; }
.photo-info-chip.is-right { padding-left: 5px; }
.photo-info-chip.is-right::before { left: 0; }
.photo-info-chip.is-on-dark { color: rgba(255,255,255,.82); }
.photo-info-chip.is-inside {
  color: rgba(255,255,255,.96);
  text-shadow: 0 1px 5px rgba(0,0,0,.58);
}
.photo-info-chip.is-inside-right { text-align: right; }
.photo-info-chip.is-inside-right::before { margin-left: auto; }
.photo-info-chip.is-inside.is-over-light {
  color: rgba(18,18,18,.82);
  text-shadow: 0 1px 4px rgba(255,255,255,.62);
}

#teInputBar.te-photo-info-mode .te-tabbar,
#teInputBar.te-photo-info-mode .te-ib-rows,
#teInputBar.te-photo-info-mode .te-ib-btn-del {
  display: none !important;
}

@media (max-width: 430px) {
  .viewer-asset-header { padding-left: 14px; padding-right: 12px; gap: 8px; }
  .viewer-asset-info-toggle { min-width: 70px; padding: 0 8px; gap: 5px; font-size: 10px; }
  .viewer-asset-apply { min-width: 52px; padding: 0 12px; }
}
.viewer-asset-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 18px 20px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 7px;
}
.viewer-asset-item,
.viewer-asset-add {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.viewer-asset-item {
  border: 2px solid transparent;
  background: #efefef;
}
.viewer-asset-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.viewer-asset-item.is-on-page {
  border-color: #181818;
  box-shadow: inset 0 0 0 1px #181818;
}
.viewer-asset-order {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 99px;
  background: #181818;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.viewer-asset-item.is-on-page .viewer-asset-order { display: flex; }
.viewer-cover-slot-strip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.viewer-cover-slot-strip::-webkit-scrollbar { display: none; }
.viewer-cover-slot {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 13px;
  background: #ececec;
  cursor: pointer;
}
.viewer-cover-slot.is-active {
  border-color: #171717;
  box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 0 0 4px rgba(23,23,23,.14);
}
.viewer-cover-slot img { width: 100%; height: 100%; display: block; object-fit: cover; pointer-events: none; }
.viewer-cover-slot span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: #171717;
  color: #fff;
  font: 700 10px/1 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
#viewerCoverAssetMode .viewer-asset-item.is-on-page { border-color: rgba(23,23,23,.42); }
#viewerCoverAssetMode .viewer-asset-item.is-active-slot { border-color: #171717; box-shadow: inset 0 0 0 1px #171717; }
.viewer-asset-add {
  border: 1.5px dashed #c8c8c8;
  background: transparent;
  color: #777;
  display: grid;
  place-items: center;
  font-size: 29px;
  font-weight: 200;
}
.viewer-asset-empty {
  grid-column: 1 / -1;
  padding: 38px 12px;
  color: #999;
  font-size: 12px;
  text-align: center;
}
#viewerTemplateMode.is-assets .viewer-template-topbar,
#viewerTemplateMode.is-assets .viewer-template-assets-btn {
  opacity: 0 !important;
  pointer-events: none;
  transition-delay: 0s !important;
}
#viewerTemplateMode.is-assets .viewer-template-actions,
#viewerTemplateMode.is-cropping .viewer-template-actions {
  visibility: hidden;
  pointer-events: none;
}
#viewerTemplateMode.is-assets .viewer-template-card { filter: grayscale(.7) blur(2px) !important; }
#viewerCoverTemplateMode.is-assets .viewer-template-topbar,
#viewerCoverTemplateMode.is-assets .viewer-template-assets-btn {
  opacity: 0 !important;
  pointer-events: none;
  transition-delay: 0s !important;
}
#viewerCoverTemplateMode.is-assets .viewer-template-card { filter: grayscale(.7) blur(2px) !important; }

/* ── 模板内照片取景 ─────────────────────────────────── */
#viewerTemplateMode.is-cropping .viewer-template-topbar,
#viewerTemplateMode.is-cropping .viewer-template-assets-btn,
#viewerCoverTemplateMode.is-cropping .viewer-template-topbar,
#viewerCoverTemplateMode.is-cropping .viewer-template-assets-btn {
  opacity: 0 !important;
  transform: translateY(-8px) !important;
  pointer-events: none;
  transition-delay: 0s !important;
}
#viewerTemplateMode.is-cropping .viewer-template-card:not(.is-center),
#viewerCoverTemplateMode.is-cropping .viewer-template-card:not(.is-center) {
  opacity: 0 !important;
  filter: blur(12px) grayscale(1) !important;
  pointer-events: none;
}
#viewerTemplateMode.is-cropping .viewer-template-card.is-center,
#viewerCoverTemplateMode.is-cropping .viewer-template-card.is-center {
  opacity: .17 !important;
  filter: grayscale(1) saturate(.2) blur(1.5px) !important;
  pointer-events: none;
}
#viewerCropMode {
  position: absolute;
  inset: 0;
  z-index: 1450;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
#viewerCropMode.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.viewer-crop-topbar {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  z-index: 8;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  text-align: center;
  color: #222;
}
.viewer-crop-topbar > div { display: flex; flex-direction: column; gap: 3px; }
.viewer-crop-topbar strong { font-size: 13px; }
.viewer-crop-kicker {
  color: #8f8f8f;
  font-family: 'Domine', Georgia, serif;
  font-size: 8px;
  letter-spacing: 1.45px;
}
.viewer-crop-cancel {
  height: 38px;
  border: 0;
  border-radius: 13px;
  background: rgba(255,255,255,.9);
  color: #444;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 5px 18px rgba(0,0,0,.09);
  cursor: pointer;
}
.viewer-crop-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.viewer-crop-canvas.is-dragging { cursor: grabbing; }
.viewer-crop-image {
  position: absolute;
  display: block;
  max-width: none !important;
  max-height: none !important;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  object-fit: fill;
  object-position: 50% 50%;
  transform: none;
  transform-origin: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: left, top, width, height;
}
.viewer-crop-image-dim {
  opacity: .3;
  filter: saturate(.72) contrast(.94);
}
.viewer-crop-frame {
  position: absolute;
  z-index: 4;
  overflow: hidden;
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.94), 0 0 0 999px rgba(28,28,30,.10), 0 12px 38px rgba(0,0,0,.22);
  cursor: pointer;
}
.viewer-crop-image-clear { opacity: 1; filter: none; }
.viewer-crop-corner {
  position: absolute;
  z-index: 6;
  width: 14px;
  height: 14px;
  border-color: #fff;
  border-style: solid;
  pointer-events: none;
}
.viewer-crop-corner-tl { top: 0; left: 0; border-width: 2px 0 0 2px; }
.viewer-crop-corner-tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.viewer-crop-corner-bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.viewer-crop-corner-br { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.viewer-crop-hint {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  text-align: center;
  pointer-events: none;
  color: #262626;
  text-shadow: 0 1px 10px rgba(255,255,255,.72);
}
.viewer-crop-hint strong { display: block; font-size: 14px; }
.viewer-crop-hint span { display: block; margin-top: 5px; color: #737373; font-size: 11px; }
#viewerCropMode.is-springing .viewer-crop-image {
  transition: left .38s cubic-bezier(.2,.86,.18,1.18), top .38s cubic-bezier(.2,.86,.18,1.18), width .38s cubic-bezier(.2,.86,.18,1.18), height .38s cubic-bezier(.2,.86,.18,1.18);
}

@media (max-height: 700px) {
  .viewer-template-stage { top: 64px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .viewer-template-actions { bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .viewer-template-assets-btn { bottom: calc(26px + env(safe-area-inset-bottom, 0px)); }
  .viewer-asset-sheet { min-height: 310px; height: 62%; }
  .viewer-crop-hint { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  #shelfView,
  #collectionView.cv-mounted,
  #collectionView.cv-show .cv-card,
  #shelfTrashDrop,
  .book-drag-ghost {
    transition-duration: 0.01ms !important;
  }
}
/* 纯享模式提示 toast */
.pure-view-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.pure-view-toast.show { opacity: 1; }

/* ═══════════════════════════════════════════════════ */
/* 只读浏览模式（VIEWER MODE）                             */
/* URL 带 ?viewer=1 时 body 会加上 .viewer-mode class      */
/* 只在此模式生效，正常访问零影响                            */
/* ═══════════════════════════════════════════════════ */

/* 隐藏所有编辑相关 UI */
body.viewer-mode #studioNav,
body.viewer-mode #studioEditNavToolbar,
body.viewer-mode #editToolbar,
body.viewer-mode #editHistoryGroup,
body.viewer-mode #exportOverlay,
body.viewer-mode #storyReadyView,
body.viewer-mode #shareVideoView,
body.viewer-mode .tpl-placeholder,
body.viewer-mode .empty-page-hint,
body.viewer-mode #collectionView,
body.viewer-mode .nav-back-pill {
  display: none !important;
}

/* 屏蔽编辑热区的点击（保留图片本身不影响翻页） */
body.viewer-mode .te-text-item,
body.viewer-mode .te-sticker,
body.viewer-mode .cutout-item,
body.viewer-mode .cutout-badge {
  pointer-events: none !important;
}

/* ===== anchorfix1 (20260708 anchorfix1) =====
   点占位符打开输入面板时，隐藏所有占位符，避免"灰字 + 空文本框"重叠。
   anchorfix4：改用 :has() 选择器，只在 #teInputBar.te-open 时隐藏，不用管关闭时机。 */
body:has(#teInputBar.te-open) .tpl-placeholder {
  display: none !important;
}

/* ===== crisptext v1 (20260707 crisptext1) =====
   书页处于 transform:scale 状态下，Safari 会把文字光栅化后再拉伸，导致糊。
   给书页内所有文字节点强制高清渲染 + 独立合成层，让浏览器尽量按目标尺寸重画。 */
#bookContainer * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}
#bookContainer .cover-page,
#bookContainer .cover-cutout,
#bookContainer .book-spread,
#bookContainer .book-page,
#bookContainer .te-text-item,
#bookContainer .te-sticker,
#bookContainer .cover-main-title,
#bookContainer .cover-bottom-text {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ═══════════════════════════════════════════════════
   新建 Zine：上传与照片分析（.cz-*）
   ═══════════════════════════════════════════════════ */
/* 弹窗尺寸略放大以容纳向导 */
.create-zine-panel.cz-wizard {
  width: 320px;
  padding: 20px 22px 22px;
  position: relative;
  max-height: 92vh;
  overflow: hidden;
}
.cz-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border: none; background: transparent;
  color: #999; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: background 0.15s, color 0.15s;
}
.cz-close:active { background: #f2f2f2; color: #333; }

/* 进度指示条 */
.cz-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin: 6px 0 22px;
}
.cz-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid #1a1a1a; background: #fff;
  transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; color: #fff; font-weight: 700; line-height: 1;
}
.cz-dot.cz-current { background: #1a1a1a; }
.cz-dot.cz-done { background: #1a1a1a; }
.cz-dot.cz-done::after {
  content: '✓'; font-size: 7px; color: #fff;
}
.cz-line {
  width: 32px; height: 1.5px; background: #1a1a1a; opacity: 0.35;
  transition: opacity 0.2s;
}
.cz-line.cz-line-done { opacity: 1; }

/* 步骤显隐 */
.cz-step { display: none; }
.cz-step.cz-step-active { display: block; }

/* 标题/副标题 */
.cz-title {
  font-size: 18px; font-weight: 700; color: #1a1a1a;
  margin: 0 0 6px; letter-spacing: -0.3px; text-align: center;
}
.cz-sub {
  font-size: 12px; color: #999; margin-bottom: 18px; text-align: center;
  line-height: 1.5;
}
.cz-kicker {
  margin: 2px 0 8px;
  color: #a4a4a4;
  font-family: 'Domine', Georgia, serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-align: center;
}

/* 旧版手动风格控件（保留兼容） */
.cz-style-radios {
  display: flex; gap: 24px; justify-content: center;
  margin-bottom: 16px;
}
.cz-radio {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  font-size: 14px; color: #1a1a1a;
}
.cz-radio input { display: none; }
.cz-radio-mark {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid #ccc; background: #fff;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0; position: relative;
}
.cz-radio input:checked + .cz-radio-mark {
  border-color: #1a1a1a; background: #1a1a1a;
  box-shadow: inset 0 0 0 3px #fff;
}

/* 旧版风格示例（保留兼容） */
.cz-style-preview {
  width: 100%;
  aspect-ratio: 1.41 / 1;   /* 匹配 style01.jpg 宽高比（5288×3743），contain 后不留白 */
  background: #f5f5f5; border-radius: 12px;
  margin-bottom: 12px; padding: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}
.cz-style-preview-inner {
  width: 100%; height: 100%;
  display: flex; gap: 6px;
  border-radius: 6px; overflow: hidden;
  background-size: contain; background-position: center; background-repeat: no-repeat;
}
.cz-style-swatch {
  flex: 1; height: 100%; border-radius: 6px;
  transition: background 0.25s;
}
/* 风格 A：用 style01.jpg 铺满，隐藏占位 swatch */
.cz-style-preview[data-style="A"] .cz-style-preview-inner {
  background-image: url('../images/styles/style01-shiguang.jpg?v=shiguang1');
}
.cz-style-preview[data-style="A"] .cz-style-swatch { display: none; }
/* 风格 B：用 style02.jpg 铺满，隐藏占位 swatch */
.cz-style-preview[data-style="B"] .cz-style-preview-inner {
  background-image: url('../images/styles/style02-shiguang.jpg?v=shiguang1');
}
.cz-style-preview[data-style="B"] .cz-style-swatch { display: none; }

/* ★ 2026-07-16 恢复原样式：黑字 + 更明显的箭头 */
.cz-more-link {
  font-size: 12px; color: #1a1a1a; text-align: right;
  margin-bottom: 18px; cursor: pointer;
  transition: opacity 0.15s;
}
.cz-more-link:active { opacity: 0.6; }
.cz-more-arrow {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  vertical-align: -1px;
  margin-left: 2px;
  transform: scaleX(1.2);
  transform-origin: left center;
}

/* 通用按钮组 */
.cz-btns { display: flex; gap: 10px; }
.cz-btn {
  flex: 1; height: 46px; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, opacity 0.15s;
}
.cz-btn:active { transform: scale(0.97); }
.cz-btn-secondary { background: #f0f0f0; color: #666; }
.cz-btn-primary { background: #1a1a1a; color: #fff; }
.cz-btn-primary:disabled {
  background: #d5d5d5; color: #fff; cursor: not-allowed;
}
.cz-btn-primary:disabled:active { transform: none; }

/* Step 1：上传空态 */
.cz-upload-wrap {
  min-height: 180px;
  margin-bottom: 18px;
}
.cz-upload-empty {
  width: 100%; min-height: 180px;
  border: 1.5px dashed #d5d5d5; border-radius: 14px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cz-upload-empty:active { border-color: #1a1a1a; background: #fafafa; }
.cz-upload-plus {
  font-size: 36px; color: #ccc; font-weight: 300; line-height: 1;
}
.cz-upload-hint { font-size: 12px; color: #aaa; }

/* Step 1：已选网格 */
.cz-upload-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
  max-height: min(40vh, 330px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
.cz-cell {
  position: relative;
  width: 100%;
  padding-bottom: 100%; /* 1:1 */
  border-radius: 8px;
  overflow: hidden;
  background: #f2f2f2;
}
.cz-cell-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.cz-cell-add {
  position: absolute; inset: 0;
  border: 1.5px dashed #d5d5d5; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #ccc; font-weight: 300;
  cursor: pointer; background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.cz-cell-add:active { border-color: #1a1a1a; background: #fafafa; }
.cz-cell-add.cz-disabled {
  opacity: 0.35; cursor: not-allowed;
}
.cz-cell-del {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.65); color: #fff;
  border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.cz-cell-del:active { background: #000; }
.cz-cell-del svg { width: 10px; height: 10px; }

.cz-upload-count {
  font-size: 11px; color: #999; text-align: center;
  margin-bottom: 4px;
}

/* Step 2：分析中
   已移除所有 loading 动画（书本/spinner/typing 三个圆点都放弃）
   保留：标题 + 副标题 + 5 个进度小圆点 + N/5 计数
   高度按内容走，不撑高弹窗 */
#czStep2 {
  text-align: center;
  padding: 12px 0;   /* 上下留一点呼吸空间即可，不再 min-height */
}

.cz-loading-dots {
  display: flex; justify-content: center; gap: 8px;
  margin: 18px 0 8px;
}
.cz-ldot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #e0e0e0;
  transition: background 0.2s, transform 0.2s;
}
.cz-ldot.cz-ldot-on {
  background: #1a1a1a;
  transform: scale(1.15);
}
.cz-loading-count {
  font-size: 11px; color: #aaa; letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════
   照片分析后的三册候选
   ═══════════════════════════════════════════════════ */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.cz-candidate-view {
  position: absolute;
  inset: 0;
  z-index: 850;
  display: none;
  overflow: hidden;
  background: #fff;
  color: #111;
}
.cz-candidate-view.cz-open { display: block; }
.cz-candidate-shell {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
}
.cz-candidate-header {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: start;
}
.cz-candidate-back {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f2f3;
  color: #1d1d1f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.cz-candidate-back:active { background: #e5e5e7; }
.cz-candidate-heading {
  grid-column: 2;
  min-width: 0;
  text-align: center;
}
.cz-candidate-kicker {
  margin: 3px 0 10px;
  color: #86868b;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.7px;
}
.cz-candidate-heading h2 {
  margin: 0;
  color: #111;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  font-size: clamp(20px, 5.5vw, 24px);
  font-weight: 650;
  line-height: 1.16;
  letter-spacing: -0.85px;
}
.cz-candidate-heading p {
  margin: 9px 0 0;
  color: #86868b;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: -0.08px;
}
.cz-candidate-list {
  --cz-picker-card-width: min(74vw, 292px);
  min-width: 0;
  min-height: 0;
  margin: 0 -12px;
  padding: 34px calc((100% - var(--cz-picker-card-width)) / 2) 22px;
  border: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cz-picker-card-width);
  gap: 24px;
  align-items: start;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: calc((100% - var(--cz-picker-card-width)) / 2);
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
}
.cz-candidate-list::-webkit-scrollbar { display: none; }
.cz-candidate-list.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}
.cz-candidate-list .cz-candidate-label { cursor: grab; }
.cz-candidate-list.is-dragging .cz-candidate-label { cursor: grabbing; }
.cz-candidate-card {
  min-width: 0;
  height: fit-content;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.cz-candidate-label {
  position: relative;
  display: block;
  padding: 0 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  color: #1d1d1f;
  opacity: 0.62;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
.cz-candidate-card.is-selected .cz-candidate-label {
  background: transparent;
  opacity: 1;
  transform: scale(1);
  box-shadow: none;
}
.cz-candidate-radio:focus-visible + .cz-candidate-label {
  outline: 3px solid #111;
  outline-offset: 6px;
}
.cz-candidate-art {
  position: relative;
  width: 100%;
  aspect-ratio: 160 / 226;
  display: grid;
  place-items: center;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}
.cz-candidate-book {
  position: relative;
  z-index: 1;
  width: 88%;
  aspect-ratio: 160 / 226;
  overflow: hidden;
  border-radius: 0 3px 3px 0;
  background: #eeeae3;
  transform: scale(0.97);
  box-shadow:
    1px 0 0 #c9c9ce,
    2px 1px 0 #b8b8bf,
    3px 2px 4px rgba(0,0,0,0.12),
    0 14px 36px rgba(0,0,0,0.16),
    0 4px 12px rgba(0,0,0,0.09);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
}
.cz-candidate-card.is-selected .cz-candidate-book {
  transform: translateY(-3px) scale(1);
  box-shadow:
    1px 0 0 #c9c9ce,
    2px 1px 0 #b8b8bf,
    4px 3px 6px rgba(0,0,0,0.13),
    0 22px 52px rgba(0,0,0,0.20),
    0 6px 14px rgba(0,0,0,0.11);
}
.cz-candidate-book-cover {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: 0 3px 3px 0;
  background: #f9f8ef;
  box-shadow: none;
}
.cz-candidate-book-cover > * {
  position: absolute !important;
  inset: 0 !important;
}
.cz-candidate-book-cover img {
  pointer-events: none;
  user-select: none;
}
.cz-candidate-copy {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 0 0;
  text-align: center;
}
.cz-candidate-copy strong {
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  font-size: 25px;
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: -0.4px;
}
.cz-candidate-copy small {
  color: #b0b0b5;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}
.cz-candidate-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 10px;
  margin-top: 12px;
}
.cz-candidate-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d1d6;
  transition: width 0.24s ease, border-radius 0.24s ease, background 0.24s ease;
}
.cz-candidate-dot.is-active {
  width: 24px;
  border-radius: 999px;
  background: #3a3a3c;
}
.cz-candidate-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding-top: 10px;
}
.cz-candidate-confirm,
.cz-candidate-retry {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  cursor: pointer;
}
.cz-candidate-confirm {
  padding: 0 18px;
  background: #111;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(0,0,0,0.14);
}
.cz-candidate-confirm:disabled { opacity: 0.45; cursor: wait; }
.cz-candidate-retry {
  padding: 0 14px;
  background: #f2f2f3;
  color: #6e6e73;
  font-size: 11px;
}
.cz-candidate-confirm:active,
.cz-candidate-retry:active { transform: scale(0.98); }

@media (max-height: 700px) {
  .cz-candidate-shell { padding-top: max(14px, env(safe-area-inset-top, 0px)); }
  .cz-candidate-list { padding-top: 24px; }
  .cz-candidate-book { width: 76%; }
  .cz-candidate-copy { padding-top: 14px; }
}

@media (max-height: 620px) {
  .cz-candidate-list {
    --cz-picker-card-width: min(66vw, 244px);
    padding-top: 16px;
  }
  .cz-candidate-kicker { margin-bottom: 6px; }
  .cz-candidate-heading h2 { font-size: 18px; }
  .cz-candidate-heading p { margin-top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .cz-candidate-label,
  .cz-candidate-confirm,
  .cz-candidate-retry { transition: none; }
}

/* ═══════════════════════════════════════════════════
   作品生成完成：传播入口
   ═══════════════════════════════════════════════════ */
.story-ready-view {
  position: fixed;
  inset: 0;
  z-index: 100100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) 16px max(18px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  color: #fff;
  background:
    radial-gradient(circle at 50% 24%, rgba(109,65,98,0.45), transparent 31%),
    radial-gradient(circle at 15% 86%, rgba(58,77,121,0.30), transparent 28%),
    #090909;
}
.story-ready-view.is-open { display: flex; }
.story-ready-shell {
  position: relative;
  width: min(100%, 430px);
  margin: auto;
  text-align: center;
  animation: storyReadyIn .42s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes storyReadyIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.story-ready-close {
  position: absolute;
  top: -2px;
  right: 0;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.72);
  font: 300 26px/1 system-ui, sans-serif;
}
.story-ready-kicker,
.sv-kicker {
  color: rgba(255,255,255,.48);
  font: 700 10px/1.2 'Domine', Georgia, serif;
  letter-spacing: 1.8px;
}
.story-ready-shell h2 {
  max-width: 350px;
  margin: 11px auto 8px;
  font-size: clamp(24px, 7.2vw, 32px);
  line-height: 1.12;
  letter-spacing: -1px;
}
.story-ready-summary {
  max-width: 360px;
  margin: 0 auto;
  color: rgba(255,255,255,.62);
  font-size: 12px;
  line-height: 1.6;
}
.story-ready-chips {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 12px auto 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.story-ready-chips::-webkit-scrollbar { display: none; }
.story-ready-chips span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.68);
  font-size: 9px;
}
.story-ready-preview {
  position: relative;
  width: 168px;
  height: 216px;
  margin: 18px auto 16px;
  perspective: 800px;
}
.story-ready-page {
  position: absolute;
  width: 126px;
  height: 178px;
  overflow: hidden;
  border: 6px solid #f9f7f0;
  border-radius: 3px;
  background: #eee;
  box-shadow: 0 22px 46px rgba(0,0,0,.46);
}
.story-ready-page img { width: 100%; height: 100%; display: block; object-fit: cover; }
.story-ready-page-back { right: 0; bottom: 0; transform: rotate(7deg); opacity: .88; }
.story-ready-page-front { left: 0; top: 0; transform: rotate(-4deg); }
.story-ready-page-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 48%, rgba(0,0,0,.66));
}
.story-ready-page-front span {
  position: absolute;
  left: 10px;
  right: 8px;
  bottom: 10px;
  z-index: 1;
  color: #fff;
  font: 700 10px/1.2 'Domine', Georgia, serif;
  letter-spacing: .5px;
  text-align: left;
}
.story-ready-primary {
  width: 100%;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: #111;
  box-shadow: 0 16px 44px rgba(0,0,0,.30);
  text-align: left;
}
.story-ready-primary-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 11px;
  padding-left: 2px;
}
.story-ready-primary strong,
.story-ready-primary small { display: block; }
.story-ready-primary strong { font-size: 14px; line-height: 1.25; }
.story-ready-primary small { margin-top: 3px; color: #666; font-size: 11px; font-weight: 500; }
.story-ready-secondary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.story-ready-secondary-row button,
.story-ready-adjust {
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.84);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}
.story-ready-adjust {
  min-height: 34px;
  margin-top: 7px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.48);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.story-ready-music-note { margin: 4px 0 0; color: rgba(255,255,255,.58); font-size: 11px; }

/* ═══════════════════════════════════════════════════
   9:16 分享短片制作器
   ═══════════════════════════════════════════════════ */
.sv-view {
  position: fixed;
  inset: 0;
  z-index: 100200;
  display: none;
  overflow-y: auto;
  color: #fff;
  background:
    radial-gradient(circle at 35% 18%, rgba(112,65,103,.38), transparent 28%),
    #080808;
}
.sv-view.is-open { display: block; }
.sv-shell {
  width: min(100%, 960px);
  min-height: 100%;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top, 0px)) 18px max(18px, env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  gap: 14px;
}
.sv-header { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 12px; align-items: start; }
.sv-back {
  width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%;
  background: rgba(255,255,255,.08); color: #fff; font-size: 20px;
}
.sv-header h2 { margin: 6px 0 3px; font-size: 22px; line-height: 1.15; letter-spacing: -.7px; }
.sv-header p { margin: 0; color: rgba(255,255,255,.50); font-size: 11px; }
.sv-layout { min-height: 0; display: grid; align-items: center; gap: 18px; }
.sv-preview-stage { display: grid; justify-items: center; gap: 8px; }
.sv-preview-frame {
  position: relative;
  height: min(49vh, 520px);
  height: min(49dvh, 520px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  background: linear-gradient(160deg, #262028, #0d0e12 58%, #242034);
  box-shadow: 0 24px 70px rgba(0,0,0,.52);
}
.sv-preview-frame::before {
  content: '';
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 50% 48%, rgba(255,255,255,.13), transparent 38%);
}
.sv-preview-hook {
  position: absolute; top: 8%; left: 9%; right: 9%; z-index: 2;
  font: 800 clamp(18px,5vw,28px)/1.12 system-ui, sans-serif; letter-spacing: -.8px;
}
.sv-preview-frame.is-vlm-director .sv-preview-hook {
  left: 8%; right: 8%;
  font-size: 22px;
  line-height: 1.14;
  letter-spacing: -.45px;
}
.sv-preview-frame.is-vlm-director .sv-preview-book {
  top: 59%;
  width: 54%;
}
.sv-preview-book {
  position: absolute; left: 50%; top: 52%; z-index: 2;
  width: 58%; aspect-ratio: 640 / 904;
  padding: 5px; border-radius: 2px; background: #f8f5ef;
  box-shadow: 0 22px 50px rgba(0,0,0,.48);
  transform: translate(-50%,-50%) rotate(-3deg);
}
.sv-preview-book img { width: 100%; height: 100%; display: block; object-fit: cover; }
.sv-preview-signature {
  position: absolute; right: 7%; bottom: 5%; z-index: 2;
  color: rgba(255,255,255,.65); font: 700 8px/1 'Domine', Georgia, serif; letter-spacing: 1.4px;
}
.sv-duration { color: rgba(255,255,255,.68); font-size: 11px; letter-spacing: .5px; }
.sv-controls { display: grid; gap: 9px; }
.sv-control-card {
  padding: 13px 14px; border: 1px solid rgba(255,255,255,.11); border-radius: 14px;
  background: rgba(255,255,255,.055);
}
.sv-control-label { display: block; margin-bottom: 5px; color: #efc1e5; font-size: 11px; font-weight: 750; letter-spacing: .6px; }
.sv-control-card strong { display: block; font-size: 12px; line-height: 1.35; }
.sv-control-card p { margin: 4px 0 0; color: rgba(255,255,255,.66); font-size: 11px; line-height: 1.5; }
.sv-device-note { min-height: 16px; color: #ffd8bd; font-size: 11px; line-height: 1.45; }
.sv-footer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px; }
.sv-primary,
.sv-secondary {
  min-height: 50px;
  border: 0;
  border-radius: 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
}
.sv-primary { background: #fff; color: #111; }
.sv-primary:disabled { opacity: .42; }
.sv-secondary { padding: 0 15px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.07); color: rgba(255,255,255,.76); }
.story-ready-view button:focus-visible,
.sv-view button:focus-visible { outline: 3px solid #9ed0ff; outline-offset: 3px; }

@media (min-width: 800px) {
  .sv-shell { padding-left: 36px; padding-right: 36px; }
  .sv-layout { grid-template-columns: minmax(280px, .9fr) minmax(300px, 1.1fr); gap: 48px; }
  .sv-preview-frame { height: min(62vh, 610px); height: min(62dvh, 610px); }
  .sv-footer { width: calc(55% - 24px); margin-left: auto; }
}
@media (max-height: 700px) {
  .story-ready-preview { width: 132px; height: 168px; margin: 10px auto 9px; }
  .story-ready-page { width: 98px; height: 139px; border-width: 4px; }
  .story-ready-shell h2 { margin-top: 7px; font-size: 23px; }
  .story-ready-chips { margin-top: 7px; }
  .story-ready-primary { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  .story-ready-shell { animation: none; }
}

/* ═══════════════════════════════════════════════════
   更多示例全屏页
   ═══════════════════════════════════════════════════ */
.cz-preview-view {
  position: fixed; inset: 0; z-index: 700;
  background: #0a0a0a;
  display: none;
  overflow: hidden;
}
.cz-preview-view.cz-open { display: block; }
.cz-preview-back {
  position: fixed; top: max(16px, env(safe-area-inset-top, 0));
  left: 12px; z-index: 10;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s;
}
.cz-preview-back:active { background: rgba(255,255,255,0.22); }
.cz-preview-scroll {
  position: absolute; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 72px 20px 40px;
  display: flex; flex-direction: column;
  gap: 20px; align-items: center;
}
.cz-preview-spread {
  width: 100%; max-width: 480px;
  aspect-ratio: 2 / 1.3;
  border-radius: 10px;
  display: flex;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.cz-preview-spread .cz-preview-half {
  flex: 1; height: 100%;
}
/* 风格 A 占位 */
.cz-preview-view[data-style="A"] .cz-preview-half:first-child { background: #e5e5e5; }
.cz-preview-view[data-style="A"] .cz-preview-half:last-child { background: #b8b8b8; }
/* 风格 B 占位 */
.cz-preview-view[data-style="B"] .cz-preview-half:first-child { background: #d8d4cc; }
.cz-preview-view[data-style="B"] .cz-preview-half:last-child { background: #8a8579; }
/* 风格 A 整册长图 */
.cz-preview-longimg {
  display: block;
  width: 100%; max-width: 480px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  user-select: none; -webkit-user-select: none;
  -webkit-user-drag: none; -webkit-touch-callout: none;
}

/* ═══════════════════════════════════════════════════
   通用简易弹窗（复用 .cz-close/.cz-title/.cz-sub 样式）
   ═══════════════════════════════════════════════════ */
.cz-simple-overlay {
  position: fixed; inset: 0; z-index: 620;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}
.cz-simple-overlay.cz-open { display: flex; }
.cz-simple-panel {
  background: #fff; border-radius: 24px;
  padding: 22px 22px 24px; width: 340px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  animation: confirmIn 0.25s ease;
  position: relative;
}

/* ═══════════════════════════════════════════════════
   拼图张数选项（.cg-*）
   ═══════════════════════════════════════════════════ */
.cg-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.cg-opt {
  border: none; background: transparent;
  padding: 0; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: transform 0.15s;
}
.cg-opt:active { transform: scale(0.95); }
.cg-opt-preview {
  width: 100%;
  aspect-ratio: 4 / 5;               /* 跟真实产物一致的 4:5 竖版 */
  background: #f5f5f5; border-radius: 8px;
  padding: 8px;
  display: flex; flex-direction: column;
  gap: 3px; box-sizing: border-box;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.cg-opt:active .cg-opt-preview,
.cg-opt.cg-opt-hover .cg-opt-preview {
  border-color: #1a1a1a; background: #ebebeb;
}
/* 选中态（用户已点选，等待确认） */
.cg-opt.cg-opt-selected .cg-opt-preview {
  border-color: #1a1a1a;
  background: #f2f2f2;
  box-shadow: 0 0 0 2px rgba(26,26,26,0.08);
}
.cg-opt.cg-opt-selected .cg-opt-label {
  color: #1a1a1a;
  font-weight: 600;
}
/* 确认按钮 */
.cg-confirm-row {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
.cg-confirm-btn {
  min-width: 200px;
  padding: 12px 32px;
  border-radius: 12px;
  border: none;
  background: #1a1a1a;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cg-confirm-btn:active { background: #333; }
.cg-confirm-btn:disabled {
  background: #d5d5d5;
  color: #999;
  cursor: not-allowed;
  opacity: 0.7;
}
.cg-p {
  background: #d5d5d5;
  border-radius: 2px;
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;   /* 防止 grid item 内的子元素撑破格子 */
  min-width: 0;
}
.cg-p img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cg-p img.cg-p-ready {
  opacity: 1;
}
/* 加载态：淡淡的呼吸动画 */
.cg-p:not(:has(.cg-p-ready)) {
  animation: cgPulse 1.4s ease-in-out infinite;
}
@keyframes cgPulse {
  0%, 100% { background: #d8d8d8; }
  50%      { background: #ececec; }
}
.cg-opt-label {
  font-size: 12px; color: #666; letter-spacing: 0.3px;
}
/* 2 个：上下堆叠 */
.cg-preview-2 { display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 3px; }
/* 3 个：竖着叠 3 行（1 列） */
.cg-preview-3 { display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 3px; }
/* 4 个：2×2 */
.cg-preview-4 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; }
/* 5 个：上 1 宽 + 中 2 + 下 2 (呈现为 上1 中2 下2) */
.cg-preview-5 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 3px; }
.cg-preview-5 .cg-p-wide { grid-column: 1 / -1; }
/* 6 个：3×2 */
.cg-preview-6 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 3px; }
/* 7 个：上 1 宽 + 3×2 */
.cg-preview-7 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 0.8fr 1fr 1fr 1fr; gap: 3px; }
.cg-preview-7 .cg-p-wide { grid-column: 1 / -1; }
/* 8 个：4×2 */
.cg-preview-8 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr 1fr; gap: 3px; }
/* 单张 1 个：正中一个大块 */
.cg-p-1 { flex: 1; }

/* ── 序号编辑弹窗 ─────────────────────────── */
.be-panel { max-width: 320px; padding: 22px 20px; }
.be-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 16px;   /* iOS 不缩放 */
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
  background: #fafafa;
  color: #1a1a1a;
}
.be-input:focus { border-color: #333; background: #fff; }
.be-color-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
}
.be-color-label {
  font-size: 13px; color: #666; margin-right: 4px;
}
.be-color-swatch {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  color: #666;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.be-color-swatch:active { transform: scale(0.92); }
.be-color-swatch.be-color-black { background: #000; border-color: #222; color: #fff; }
.be-color-swatch.be-color-white { background: #fff; border-color: #ccc; }
/* 选中态：外黑圈 + 内白点，任何背景色都清晰 */
.be-color-swatch.be-selected {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.2);
  position: relative;
}
.be-color-swatch.be-selected::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 2px solid #fff;
  pointer-events: none;
}
/* 白色按钮选中时内圈白框看不见，改成黑点 */
.be-color-swatch.be-color-white.be-selected::after {
  border-color: #1a1a1a;
}
.be-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px;
}
.be-btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 40px;
}
.be-btn-ghost { background: transparent; color: #666; }
.be-btn-ghost:active { background: #f0f0f0; }
.be-btn-primary { background: #1a1a1a; color: #fff; font-weight: 600; }
.be-btn-primary:active { opacity: 0.8; }

/* ═══════════════════════════════════════════════════
   电影日记样书 · 独立视觉系统
   所有书页按 320 × 452 设计，再由 .hires-wrap 缩放显示。
   只使用稳定的布局、纯色与渐变，确保 JPG / PDF 导出一致。
   ═══════════════════════════════════════════════════ */

/* 分享浮层里的次级入口：比导出主按钮克制，但仍能被清楚发现。 */
.ex-btn-cinematic {
  position: relative;
  justify-content: flex-start;
  gap: 10px;
  min-height: 46px;
  padding: 0 13px;
  overflow: hidden;
  border: 1px solid #d7cec3;
  background: #f3eee7;
  color: #241c1b;
  font-size: 13px;
  letter-spacing: .1px;
}
.ex-btn-cinematic::after {
  content: '';
  position: absolute;
  right: -18px;
  bottom: -27px;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(113,24,30,.10);
  border-radius: 50%;
  pointer-events: none;
}
.ex-btn-cinematic:active { background: #e9e1d8; }
.cinematic-entry-mark {
  position: relative;
  flex: 0 0 26px;
  width: 26px;
  height: 18px;
  padding: 4px 3px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border: 1px solid #6e2026;
  background: #751d24;
  box-shadow: inset 0 3px 0 #f0e7dc, inset 0 -3px 0 #f0e7dc;
}
.cinematic-entry-mark i {
  display: block;
  width: 3px;
  background: #f0e7dc;
}
.cinematic-entry-arrow {
  position: relative;
  z-index: 1;
  margin-left: auto;
  color: #7a252b;
  font-size: 16px;
  font-weight: 400;
}

/* VLM 导演版：沿用电影入口的卡片轮廓，以冷色识别 AI 语义重排。 */
.ex-btn-vlm {
  position: relative;
  height: auto;
  min-height: 62px;
  justify-content: flex-start;
  gap: 10px;
  padding: 9px 13px;
  overflow: hidden;
  border: 1px solid #bec6ea;
  background: linear-gradient(135deg, #f3f4ff 0%, #ecefff 64%, #f5f0ff 100%);
  color: #181d3b;
  box-shadow: 0 8px 20px rgba(55, 65, 135, .10);
  text-align: left;
}
.ex-btn-vlm::after {
  content: '';
  position: absolute;
  right: -22px;
  top: -29px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(105, 88, 211, .15) 0 2px, transparent 3px 100%);
  background-size: 10px 10px;
  pointer-events: none;
}
.ex-btn-vlm:active { background: #e6e9fb; }
.vlm-entry-mark {
  position: relative;
  z-index: 1;
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #202852, #6552c9);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.17), 0 5px 12px rgba(48, 46, 112, .20);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .7px;
}
.vlm-entry-mark i {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 7px;
  height: 7px;
  border: 2px solid #f3f4ff;
  border-radius: 50%;
  background: #8f77f0;
}
.vlm-entry-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.2;
}
.vlm-entry-copy strong {
  color: #181d3b;
  font-size: 13px;
  font-weight: 700;
}
.vlm-entry-copy small {
  color: #6d7290;
  font-size: 10px;
  font-weight: 500;
}
.vlm-entry-arrow {
  position: relative;
  z-index: 1;
  margin-left: auto;
  color: #5948b0;
  font-size: 16px;
  font-weight: 400;
}

/* ── Page foundation ───────────────────────────── */
.cinematic-page {
  --cinematic-black: #09090a;
  --cinematic-charcoal: #151315;
  --cinematic-paper: #eee5d7;
  --cinematic-paper-dim: #bdb3a5;
  --cinematic-red: #741f27;
  --cinematic-red-bright: #9a3037;
  --cinematic-line: rgba(238,229,215,.30);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 !important;
  overflow: hidden;
  isolation: isolate;
  box-sizing: border-box;
  background: var(--cinematic-black);
  color: var(--cinematic-paper);
  font-family: "Helvetica Neue", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.cinematic-page *,
.cinematic-page *::before,
.cinematic-page *::after { box-sizing: border-box; }
.cinematic-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: .17;
  pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 19% 23%, rgba(255,255,255,.32) 0, rgba(255,255,255,.32) .35px, transparent .6px, transparent 3px),
    repeating-linear-gradient(91deg, transparent 0, transparent 12px, rgba(255,255,255,.06) 13px, transparent 14px);
  background-size: 7px 9px, 31px 100%;
}
.cinematic-page::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.055);
  background:
    linear-gradient(90deg, rgba(0,0,0,.25), transparent 8%, transparent 92%, rgba(0,0,0,.32)),
    linear-gradient(180deg, rgba(0,0,0,.18), transparent 13%, transparent 86%, rgba(0,0,0,.30));
}
.cinematic-page > * { position: relative; z-index: 2; }
.cinematic-grain {
  position: absolute !important;
  inset: 0;
  z-index: 18 !important;
  opacity: .13;
  pointer-events: none;
  background-image: repeating-radial-gradient(circle at 71% 61%, rgba(255,255,255,.26) 0, rgba(255,255,255,.26) .35px, transparent .75px, transparent 3px);
  background-size: 8px 7px;
}
.cinematic-media,
.cinematic-frame > img,
.cinematic-contact-cell > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cinematic-frame {
  position: relative;
  overflow: hidden;
  background: #211e1f;
  border: 1px solid rgba(238,229,215,.18);
}
.cinematic-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border: 1px solid rgba(0,0,0,.36);
  box-shadow: inset 0 0 22px rgba(0,0,0,.23);
}
.cinematic-kicker,
.cinematic-meta,
.cinematic-timecode,
.cinematic-frame-label,
.cinematic-contact-index {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}
.cinematic-kicker {
  margin: 0;
  color: var(--cinematic-red-bright);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2.1px;
  line-height: 1.2;
}
.cinematic-title {
  margin: 0;
  max-width: 278px;
  color: var(--cinematic-paper);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -1.2px;
}
.cinematic-meta {
  margin: 0;
  color: var(--cinematic-paper-dim);
  font-size: 7px;
  line-height: 1.65;
  letter-spacing: 1px;
}
.cinematic-timecode {
  position: absolute !important;
  z-index: 7 !important;
  color: rgba(238,229,215,.78);
  font-size: 7px;
  line-height: 1;
  letter-spacing: .75px;
  text-shadow: 0 1px 2px #000;
}
.cinematic-timecode:not([style]) { top: 12px; right: 15px; }
.cinematic-timecode:not([style])::before {
  content: 'REC';
  display: inline-block;
  margin-right: 7px;
  color: #d75055;
  font-size: 6px;
  letter-spacing: .9px;
}
.cinematic-caption {
  position: absolute !important;
  z-index: 8 !important;
  margin: 0;
  color: #f5ecdf;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: .45px;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}
.cinematic-caption:not([style]) { left: 24px; right: 24px; bottom: 28px; }
.cinematic-caption::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 1px;
  margin: 0 8px 3px 0;
  background: var(--cinematic-red-bright);
}
.cinematic-rule {
  height: 1px;
  background: var(--cinematic-line);
}
.cinematic-red-label {
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  padding: 0 7px;
  background: var(--cinematic-red);
  color: #fff7eb;
  font-family: ui-monospace, monospace;
  font-size: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Opening / cover ────────────────────────────── */
.cinematic-opening,
.cinematic-cover {
  background:
    linear-gradient(155deg, rgba(116,31,39,.34), transparent 43%),
    #09090a;
}
.cinematic-opening .cinematic-frame:not([style]),
.cinematic-cover .cinematic-frame:not([style]) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.cinematic-opening .cinematic-frame::before,
.cinematic-cover .cinematic-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(8,8,9,.10) 18%, rgba(8,8,9,.78) 78%, #09090a 100%),
    linear-gradient(90deg, rgba(116,31,39,.42), transparent 58%);
}
.cinematic-opening .cinematic-kicker:not([style]),
.cinematic-cover .cinematic-kicker:not([style]) {
  position: absolute;
  left: 22px;
  top: 28px;
  z-index: 6;
}
.cinematic-opening .cinematic-title:not([style]),
.cinematic-cover .cinematic-title:not([style]) {
  position: absolute;
  left: 22px;
  right: 19px;
  bottom: 62px;
  z-index: 6;
  font-size: 39px;
  text-shadow: 0 2px 9px rgba(0,0,0,.82);
}
.cinematic-opening .cinematic-meta:not([style]),
.cinematic-cover .cinematic-meta:not([style]) {
  position: absolute;
  left: 23px;
  right: 22px;
  bottom: 26px;
  z-index: 6;
  padding-top: 8px;
  border-top: 1px solid rgba(238,229,215,.35);
}

/* ── 2.39:1 hero frame / subtitle still ─────────── */
.cinematic-widescreen,
.cinematic-subtitle {
  padding: 0 !important;
  background: #0a0a0b;
}
.cinematic-widescreen .cinematic-kicker:not([style]),
.cinematic-subtitle .cinematic-kicker:not([style]) {
  position: absolute;
  top: 41px;
  left: 17px;
}
.cinematic-widescreen > .cinematic-frame:not([style]),
.cinematic-subtitle > .cinematic-frame:not([style]) {
  position: absolute;
  top: 96px;
  left: 15px;
  width: 290px;
  height: 121px;
  aspect-ratio: 2.39 / 1;
  border-color: rgba(238,229,215,.25);
  box-shadow: 0 14px 32px rgba(0,0,0,.34);
}
.cinematic-widescreen > .cinematic-frame::before,
.cinematic-subtitle > .cinematic-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  box-shadow: inset 0 13px 0 rgba(0,0,0,.30), inset 0 -13px 0 rgba(0,0,0,.30);
  pointer-events: none;
}
.cinematic-widescreen .cinematic-title:not([style]) {
  position: absolute;
  top: 244px;
  left: 18px;
  right: 26px;
  font-size: 25px;
  line-height: 1.1;
}
.cinematic-widescreen .cinematic-meta:not([style]) {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 31px;
  padding-top: 9px;
  border-top: 1px solid rgba(238,229,215,.20);
}
.cinematic-subtitle > .cinematic-frame:not([style]) { top: 102px; }
.cinematic-subtitle .cinematic-caption:not([style]) {
  left: 26px;
  right: 26px;
  bottom: 104px;
  font-size: 11px;
}
.cinematic-subtitle .cinematic-meta:not([style]) {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 29px;
  padding-top: 8px;
  border-top: 1px solid rgba(238,229,215,.18);
}

/* ── Portrait / censored memory ─────────────────── */
.cinematic-dark-portrait,
.cinematic-redacted {
  background:
    linear-gradient(180deg, #171315, #09090a 72%);
}
.cinematic-dark-portrait > .cinematic-frame:not([style]),
.cinematic-redacted > .cinematic-frame:not([style]) {
  position: absolute;
  top: 48px;
  left: 58px;
  width: 204px;
  height: 286px;
  border-color: rgba(238,229,215,.27);
  box-shadow: 11px 14px 0 rgba(116,31,39,.28);
}
.cinematic-dark-portrait .cinematic-kicker:not([style]),
.cinematic-redacted .cinematic-kicker:not([style]) {
  position: absolute;
  left: 18px;
  top: 21px;
}
.cinematic-dark-portrait .cinematic-meta:not([style]),
.cinematic-redacted .cinematic-meta:not([style]) {
  position: absolute;
  left: 18px;
  bottom: 24px;
}
.cinematic-redacted .cinematic-caption:not([style]) {
  left: 40px;
  right: 40px;
  bottom: 64px;
  padding: 7px 9px;
  background: rgba(8,8,9,.88);
}

/* ── Two-frame scene / plot pair ────────────────── */
.cinematic-split-scene:not([style]),
.cinematic-plot-pair:not([style]) {
  padding: 28px 18px 24px !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 255px auto 1fr;
  gap: 8px;
  background: #efe6d8;
  color: #161214;
}
.cinematic-split-scene::after,
.cinematic-plot-pair::after {
  background: linear-gradient(90deg, rgba(116,31,39,.08), transparent 15%, transparent 85%, rgba(116,31,39,.09));
}
.cinematic-split-scene .cinematic-kicker,
.cinematic-plot-pair .cinematic-kicker { grid-column: 1 / -1; }
.cinematic-split-scene > .cinematic-frame:not([style]),
.cinematic-plot-pair > .cinematic-frame:not([style]) {
  position: relative;
  width: 100%;
  height: 255px;
  border-color: rgba(20,16,17,.25);
  background: #231e20;
}
.cinematic-split-scene > .cinematic-frame:not([style]):nth-of-type(2),
.cinematic-plot-pair > .cinematic-frame:not([style]):nth-of-type(2) { margin-top: 19px; height: 236px; }
.cinematic-split-scene .cinematic-title:not([style]),
.cinematic-plot-pair .cinematic-title:not([style]) {
  grid-column: 1 / -1;
  align-self: end;
  color: #21191b;
  font-size: 21px;
}
.cinematic-split-scene .cinematic-meta:not([style]),
.cinematic-plot-pair .cinematic-meta:not([style]) {
  grid-column: 1 / -1;
  align-self: end;
  color: #6f6460;
  border-top: 1px solid rgba(33,25,27,.24);
  padding-top: 7px;
}

/* ── Three-beat storyboard ──────────────────────── */
.cinematic-storyboard:not([style]),
.cinematic-triple-beat:not([style]) {
  padding: 30px 17px 24px !important;
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto 185px auto 1fr;
  gap: 7px;
  background: #0b0b0c;
}
.cinematic-storyboard .cinematic-kicker,
.cinematic-triple-beat .cinematic-kicker { grid-column: 1 / -1; }
.cinematic-storyboard > .cinematic-frame:not([style]),
.cinematic-triple-beat > .cinematic-frame:not([style]) {
  width: 100%;
  height: 185px;
  border-color: rgba(238,229,215,.22);
}
.cinematic-storyboard > .cinematic-frame:not([style]):nth-of-type(2),
.cinematic-triple-beat > .cinematic-frame:not([style]):nth-of-type(2) { margin-top: 13px; height: 172px; }
.cinematic-storyboard > .cinematic-frame:not([style]):nth-of-type(3),
.cinematic-triple-beat > .cinematic-frame:not([style]):nth-of-type(3) { margin-top: 26px; height: 159px; }
.cinematic-storyboard .cinematic-frame-label,
.cinematic-triple-beat .cinematic-frame-label {
  position: absolute;
  z-index: 5;
  left: 5px;
  bottom: 5px;
  padding: 3px 4px;
  background: rgba(9,9,10,.82);
  color: #eee5d7;
  font-size: 5px;
  letter-spacing: .5px;
}
.cinematic-storyboard .cinematic-title:not([style]),
.cinematic-triple-beat .cinematic-title:not([style]) {
  grid-column: 1 / -1;
  margin-top: 15px;
  font-size: 22px;
}
.cinematic-storyboard .cinematic-meta:not([style]),
.cinematic-triple-beat .cinematic-meta:not([style]) {
  grid-column: 1 / -1;
  align-self: end;
  padding-top: 8px;
  border-top: 1px solid rgba(238,229,215,.20);
}

/* ── Contact sheet ──────────────────────────────── */
.cinematic-contact-sheet:not([style]) {
  padding: 25px 16px 21px !important;
  background: #e9dfd0;
  color: #1b1718;
}
.cinematic-contact-sheet::before { opacity: .10; }
.cinematic-contact-sheet .cinematic-kicker { color: var(--cinematic-red); }
.cinematic-contact-sheet .cinematic-title:not([style]) {
  margin-top: 9px;
  color: #201a1b;
  font-size: 24px;
}
.cinematic-contact-grid {
  display: grid;
}
.cinematic-contact-grid:not([style]) {
  width: 100%;
  margin-top: 20px;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 112px;
  gap: 8px 7px;
}
.cinematic-contact-grid.is-six,
.cinematic-contact-grid[data-count="6"] {
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 83px;
}
.cinematic-contact-cell {
  position: relative;
  overflow: hidden;
  padding: 4px 4px 14px;
  border: 1px solid rgba(31,24,26,.28);
  background: #f5eee4;
  box-shadow: 0 2px 0 rgba(31,24,26,.08);
}
.cinematic-contact-cell > img,
.cinematic-contact-cell > .cinematic-media { height: calc(100% - 10px); }
.cinematic-contact-index {
  position: absolute !important;
  right: 4px;
  bottom: 3px;
  color: #4d4240;
  font-size: 5px;
  letter-spacing: .5px;
}
.cinematic-contact-sheet .cinematic-meta:not([style]) {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  color: #6a5e5b;
  border-top: 1px solid rgba(31,24,26,.24);
  padding-top: 6px;
}

/* ── Finale / end credits ───────────────────────── */
.cinematic-finale:not([style]),
.cinematic-credits:not([style]) {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 35px 28px !important;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(116,31,39,.18), transparent 32%),
    #080809;
}
.cinematic-credit-roll:not([style]) {
  width: 100%;
  max-width: 248px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 15px;
  margin-top: 26px;
  color: var(--cinematic-paper-dim);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 6px;
  line-height: 1.6;
  letter-spacing: .8px;
  text-transform: uppercase;
}
.cinematic-credit-roll:not([style]) > :nth-child(odd) {
  color: rgba(238,229,215,.45);
  text-align: right;
}
.cinematic-credit-roll:not([style]) > :nth-child(even) {
  color: var(--cinematic-paper);
  text-align: left;
}
.cinematic-end-mark:not([style]) {
  position: relative;
  margin-top: 34px;
  color: var(--cinematic-paper);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 25px;
  letter-spacing: 5px;
}
.cinematic-end-mark:not([style])::before,
.cinematic-end-mark:not([style])::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 36px;
  height: 1px;
  background: var(--cinematic-red);
}
.cinematic-end-mark:not([style])::before { right: calc(100% + 13px); }
.cinematic-end-mark:not([style])::after { left: calc(100% + 8px); }
.cinematic-finale .cinematic-meta:not([style]),
.cinematic-credits .cinematic-meta:not([style]) {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 22px;
  padding-top: 7px;
  border-top: 1px solid rgba(238,229,215,.17);
  text-align: center;
}

/* 编辑时仍保留照片槽位点击；装饰层不拦截手势。 */
body[data-studio-state="edit"] .cinematic-page .cinematic-frame,
body[data-studio-state="edit"] .cinematic-page .cinematic-contact-cell {
  pointer-events: auto;
}
.cinematic-page::before,
.cinematic-page::after,
.cinematic-grain,
.cinematic-frame::after { pointer-events: none !important; }

@media (max-width: 420px), (max-height: 680px) {
  #exportPanel { max-height: calc(100dvh - 24px); overflow-y: auto; }
  .ex-btn-cinematic { min-height: 44px; }
  .ex-btn-vlm { min-height: 58px; }
}

@media print {
  .cinematic-page,
  .cinematic-page * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .cinematic-page { break-inside: avoid; }
}
