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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-family: var(--font-title);
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  user-select: none;
}
.brand:active { cursor: pointer; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 搜索框：夹在标题和按钮之间，收窄居中 */
.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 340px;
  margin: 0 12px;
}
.search input {
  width: 100%;
  box-sizing: border-box;
  appearance: none;
  border: 1px solid var(--ui-border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 6px 30px 6px 12px;
  border-radius: 999px;
  outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #f5e6c6; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* 框内右侧的动态计数：索引命中一次、全文每攒一批再刷。有它时把输入区右内距撑开，
   免得长句子压到数字上 */
.qcount {
  position: absolute;
  top: 50%;
  right: 34px;
  transform: translateY(-50%);
  font-family: var(--font-ui);
  font-size: 11.5px;
  line-height: 1;
  color: var(--ink-faint);
  letter-spacing: .02em;
  pointer-events: none;
  white-space: nowrap;
}
.qcount[hidden] { display: none; }
.search[data-count="1"] input { padding-right: 96px; }

.qclear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qclear:hover { color: var(--accent); background: var(--ui-active); }
.qclear svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.qpanel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 52vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  box-shadow: 0 16px 40px -20px rgba(50, 40, 26, 0.5);
  z-index: 20;
  padding: 4px;
}
.qpanel .qi {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-ui);
  color: var(--ink);
}
.qpanel .qi:hover, .qpanel .qi.cur { background: var(--ui-active); }
/* 标题行排成一排：标题 → 作者·朝代 → 集子名。标题是唯一可压缩的，长了就省略，
   作者和集子名不缩写 */
.qpanel .qi-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
/* min-width 必须归零，否则长标题撑开 flex 项、省略号不出现。
   作者与集子名不缩，宽度固定，所以标题总有剩余空间，不会被压没 */
.qpanel .qi b { font-weight: 600; font-size: 13px; flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qpanel .qi span { color: var(--ink-soft); font-size: 12px; }
.qpanel .qi .qi-sub { flex: 0 0 auto; }
/* 集子名靠右贴齐，6 字以内才显示（更长的由脚本直接隐藏），顺带作为标题的右边界 */
.qpanel .qi .qi-coll { flex: 0 0 auto; margin-left: auto; padding-left: 10px; opacity: .75; }
.qpanel .qi .qi-coll[hidden] { display: none; }
.qpanel .qi em { display: block; font-style: normal; color: var(--ink-soft); font-size: 12px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qpanel .qn { padding: 7px 9px; color: var(--ink-soft); font-size: 12px; }
.qpanel .qn i { font-style: normal; color: var(--accent); }

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* 逗号断行按钮：直接用逗号字符当图标，字形比手画 SVG 准确 */
.btn.icon .comma-glyph {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-3px);   /* 逗号在基线下，抬高一点看起来居中 */
}

/* 自动排版规则指示：只显示不响应点击，应用了规则时变朱红 */
.btn.icon.typeset { cursor: default; }
.btn.icon.typeset:hover { background: transparent; color: var(--ink-soft); }
.btn.icon.typeset[data-on="true"],
.btn.icon.typeset[data-on="true"]:hover { color: var(--accent); }

/* 划词搜索按钮：钉在视口坐标，跟着选区右下角 */
.sel-search { position: fixed; z-index: 20; }
/* 单字时挂在搜索按钮右侧的汉典入口 */
.han-search img { width: 14px; height: 14px; display: block; object-fit: contain; }

/* 纸张上沿的书签：上边贴住纸张，向下垂一条，底部留书签缺口；
   只有鼠标进到右上角热区才从上往下渐显，已收藏时常显 */
.fav-hotzone {
  position: absolute;
  top: 0;
  right: 6px;
  width: 46px;
  height: 48px;
  z-index: 7;
}
.paper-fav {
  position: absolute;
  top: 0;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
  color: var(--ink-soft);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-14px);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  transition: opacity .18s ease, transform .24s cubic-bezier(.22, .61, .36, 1), background .15s ease;
  z-index: 8;
}
.fav-hotzone:hover + .paper-fav,
.paper-fav:hover,
.paper-fav:focus-visible { opacity: 1; pointer-events: auto; transform: none; }
.paper-fav:hover { background: color-mix(in srgb, var(--accent) 44%, transparent); }
/* 取消收藏的瞬间先让书签退场，只留碎片，免得它靠 hover 还赖着不走 */
.paper-fav.is-bursting {
  opacity: 0 !important;
  transform: translateY(-14px) !important;
  pointer-events: none !important;
  transition: opacity .1s linear, transform .1s linear;
}
/* 已收藏：常态略透明，不抢正文；悬停时回到实色 */
.paper-fav[data-on="true"] { opacity: .7; pointer-events: auto; transform: none; background: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.paper-fav[data-on="true"]:hover,
.paper-fav[data-on="true"]:focus-visible { opacity: 1; }

.btn:hover { background: var(--ui-hover); color: var(--ink); }
/* hidden 属性会被上面的 display:inline-flex 覆盖，单独兜底 */
.btn[hidden] { display: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.icon { width: 32px; height: 32px; padding: 0; }
.btn.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* 纸张三态：默认双箭头 → 大纸四角外扩 → 全屏四角内收 */
.btn.icon[data-act="wide"] .ic-max,
.btn.icon[data-act="wide"] .ic-shrink { display: none; }
.btn.icon[data-act="wide"][data-level="1"] .ic-wide { display: none; }
.btn.icon[data-act="wide"][data-level="1"] .ic-max { display: block; }
.btn.icon[data-act="wide"][data-level="2"] .ic-wide,
.btn.icon[data-act="wide"][data-level="2"] .ic-max { display: none; }
.btn.icon[data-act="wide"][data-level="2"] .ic-shrink { display: block; }
.btn.icon[data-on="true"] { color: var(--accent); }
.btn.icon[data-on="true"] svg { fill: none; }

/* 贴合图标：横竖两条边夹着纸面。全屏下贴合管的是高度，图标顺时针转 90° 呼应「改成上下方向」 */
.btn.icon[data-act="fit"] svg { transition: transform .18s ease; }
.btn.icon[data-act="fit"][data-vert="1"] svg { transform: rotate(90deg); }

/* 文字按钮的开启态（如赏析展开）：淡底色 + 描边；图标按钮只变朱红，不加底纹 */
.btn[data-on="true"]:not(.icon) {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* 版式浮层 */
.topbar { position: relative; }
.layout-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 18px;
  width: 274px;
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  box-shadow: 0 16px 40px -20px rgba(50, 40, 26, 0.5);
  z-index: 20;
  font-family: var(--font-ui);
}
.layout-panel[hidden] { display: none; }
.lp-head {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.lp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.lp-row input {
  width: 132px;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: var(--ui-bg);
  color: var(--ink);
}
.lp-row select {
  width: 132px;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 6px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: var(--ui-bg);
  color: var(--ink);
}
/* 生僻字注音开关：滑动式 switch，覆盖上面 .lp-row input 的通用宽度/内距 */
.lp-row input.lp-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 38px;
  height: 21px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background: var(--ui-bg);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.lp-row input.lp-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: transform .2s, background .2s;
}
.lp-row input.lp-switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.lp-row input.lp-switch:checked::after {
  transform: translateX(17px);
  background: #fff;
}
.lp-row input.lp-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 「点击单字注音」挂在注音块上：注音关掉时这一项不可点。
   外观一律与上一行保持一致——不给文字或圆点上别的色，否则同是「关」却看着是两个控件 */
.lp-row[data-off="1"] {
  cursor: default;
}
.lp-row[data-off="1"] input {
  cursor: default;
}
/* 禁用态显式回到「关闭」的配色，别让浏览器默认样式给圆点上别的色 */
.lp-row input.lp-switch:disabled {
  background: var(--ui-bg);
  border-color: var(--ui-border);
}
.lp-row input.lp-switch:disabled::after {
  background: var(--ink-faint);
}

.lp-foot {
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-faint);
}

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vh 4vw;
}

/* 竖排纸面：高度只在这里定（--paper-h-v），宽度按 1.38 比例自动推导 */
:root { --paper-h-v: 68vh; }

.card {
  position: relative;
  width: min(820px, 92vw);
  min-height: var(--paper-h-v);
  border: 1px solid var(--surface-edge);
  border-radius: 6px;
  box-shadow: 0 8px 22px -14px rgba(60, 48, 30, 0.3);
  overflow: hidden;
}

/* 竖排纸面固定 1.38 宽高比：宽度随纸面高度推导，窄屏用 92vw 兜底 */
.card[data-orient="v"] { width: min(92vw, calc(var(--paper-h-v) * 1.38)); }

/* 加宽：纸面占视口 95%，同时放开左右留白 */
body[data-wmode="wide"] { height: 100vh; overflow: hidden; }
body[data-wmode="wide"] .stage { padding-left: 2.5vw; padding-right: 2.5vw; padding-top: 2vh; padding-bottom: 2vh; min-height: 0; }
body[data-wmode="wide"] .card { width: 95vw; max-height: 100%; }
/* 竖排宽度由纸面高度推导，加宽时把纸面一并放大（82vh），比例仍是 1.38 */
body[data-wmode="wide"] .card[data-orient="v"] { width: min(95vw, calc(82vh * 1.38)); }
body[data-wmode="wide"] .card[data-orient="v"] .paper,
body[data-wmode="wide"] .card[data-orient="v"] { min-height: 82vh; max-height: 82vh; }
/* 横排内容超出时在纸面内部滚动，不撑出页面级滚动条 */
body[data-wmode="wide"] .card[data-orient="h"] .paper { overflow-y: auto; max-height: 100%; }

/* ---------- 纸面滚动条：细轨无箭头，半透明暖棕，藏在纸里不抢字 ----------
   thumb 用 border 2px transparent + background-clip 收细，比直接调 width 更像纸上的淡痕 */
body:not([data-surface]) .paper {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 98, 62, 0.3) transparent;
}
body:not([data-surface]) .paper::-webkit-scrollbar { width: 9px; height: 9px; }
body:not([data-surface]) .paper::-webkit-scrollbar-track { background: transparent; }
body:not([data-surface]) .paper::-webkit-scrollbar-thumb {
  background: rgba(122, 98, 62, 0.26);
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 999px;
}
body:not([data-surface]) .paper::-webkit-scrollbar-thumb:hover { background: rgba(122, 98, 62, 0.44); background-clip: content-box; }
body:not([data-surface]) .paper::-webkit-scrollbar-corner { background: transparent; }
body[data-mode="dark"]:not([data-surface]) .paper { scrollbar-color: rgba(231, 223, 205, 0.24) transparent; }
body[data-mode="dark"]:not([data-surface]) .paper::-webkit-scrollbar-thumb { background: rgba(231, 223, 205, 0.22); background-clip: content-box; }
body[data-mode="dark"]:not([data-surface]) .paper::-webkit-scrollbar-thumb:hover { background: rgba(231, 223, 205, 0.38); background-clip: content-box; }

/* 全屏：纸面铺满工具栏以下的视口，去掉留白、圆角、边框与投影。
   高度交给 flex 撑满剩余空间，不再写 100vh，否则叠上顶栏会撑出竖向滚动条；
   body 锁死一屏高，避免内容溢出时再长出滚动条 */
body[data-wmode="full"] {
  --paper-h-v: 100%;
  height: 100vh;
  overflow: hidden;
}
body[data-wmode="full"] .stage {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
}
body[data-wmode="full"] .card {
  width: 100vw;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
body[data-wmode="full"] .card[data-orient="v"] { width: 100vw; }
/* renderPoem 排版时会给纸面写内联高度，全屏要铺满，这里用 !important 压过内联。
   全屏 + 贴合例外：那时纸面高度就是内容高度（见下面那条），不能再钉成 100% */
body[data-wmode="full"]:not([data-fit="1"]) .card[data-orient="v"] .paper,
body[data-wmode="full"]:not([data-fit="1"]) .card[data-orient="h"] .paper {
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  padding-top: 3vh;
  padding-bottom: 3vh;
}

/* 全屏 + 贴合：看不到纸的轮廓了，贴合改成「高度服帖」——
   纸宽仍是 100vw，高度回到内容高度，成一条通栏横幅，由 stage 垂直居中。
   renderPoem 写入的内联高度在这里生效，所以不要用 !important 覆盖它 */
body[data-wmode="full"][data-fit="1"] { --paper-h-v: 0px; }
body[data-wmode="full"][data-fit="1"] .card {
  height: auto;
  min-height: 0;
  max-height: 100%;
}
body[data-wmode="full"][data-fit="1"] .paper {
  height: auto;
  min-height: 0;
  max-height: none;
  padding-top: 4vh;
  padding-bottom: 4vh;
}

/* 贴合：纸宽服从内容，短诗可比默认窄（脚本下限 360px），最多到视口 95%。
   它是叠在尺寸上的一层，能与大纸同用；全屏时贴的是高度（见上一条），所以这里排除全屏 */
body[data-fit="1"]:not([data-wmode="full"]) .stage { padding-left: 2.5vw; padding-right: 2.5vw; }
body[data-fit="1"]:not([data-wmode="full"]) .card { width: fit-content; min-width: min(320px, 92vw); max-width: 95vw; }
/* 竖排先回落到当前档位的宽度，再由脚本按内容伸缩；贴合允许比默认更窄 */
body[data-fit="1"]:not([data-wmode="full"]) .card[data-orient="v"] {
  width: min(92vw, calc(var(--paper-h-v) * 1.38));
  min-width: 0;
  max-width: 95vw;
}
/* 大纸 + 贴合：回退宽度跟着大纸档的纸高走，否则首帧会按默认高度闪一下 */
body[data-wmode="wide"][data-fit="1"] .card[data-orient="v"] {
  width: min(95vw, calc(82vh * 1.38));
}
body[data-fit="1"]:not([data-wmode="full"]) .card[data-orient="h"] .paper { padding-left: 56px; padding-right: 64px; }

body[data-mode="dark"] .card { box-shadow: 0 8px 22px -14px rgba(0, 0, 0, 0.55); }

.paper {
  min-height: var(--paper-h-v);
  padding: 6vh 6vw;
}

/* 全页不设档位上限，完全随内容 */
.card[data-size] { --paper-h: auto; }

.card[data-orient="h"] .paper {
  min-height: var(--paper-h-v);
  max-height: none;
  overflow: visible;
}

.card[data-orient="v"] .paper {
  height: var(--paper-h-v);
  overflow-x: auto;
}

.card[data-orient="v"][data-size] { --paper-h: var(--paper-h-v); }

.card[data-orient="v"] .title { font-size: var(--fs-title-user, 23px); margin-left: 18px; }
.card[data-orient="v"] .body { font-size: var(--fs-body-user, 22px); margin-left: 28px; line-height: var(--lh-body-user, 2.2); }

.card[data-orient="h"] .title { font-size: var(--fs-title-user, 23px); }
.card[data-orient="h"] .body { font-size: var(--fs-body-user, 19px); line-height: var(--lh-body-user, 2.05); }

/* 展开页标题悬停会浮出来源标签，单击可复制；打印台不可见，排除掉避免误显手型 */
body:not([data-surface="print"]) .title[data-pool] { cursor: pointer; }

.empty { color: var(--ink-faint); font-size: 13px; text-align: center; }

/* 换首：旧纸面先淡出 120ms，再渲染新诗并播入场 */
.paper.leaving { opacity: 0; transition: opacity .12s ease-out; }

/* 换首入场：逐句浮现 —— 顺序号 --i 由 poem.js 按阅读方向写入；
   步长与单句时长也由 JS 按条目数下发，列少时放慢，免得一闪而过 */
.paper.enter-lines .head,
.paper.enter-lines .body .clause,
.paper.enter-lines .gloss {
  animation: enter-line var(--enter-dur, .42s) cubic-bezier(.22, .61, .36, 1) both;
  animation-delay: calc(min(var(--i, 0), 18) * var(--enter-step, 45ms));
}
.card[data-orient="v"] .paper.enter-lines .head,
.card[data-orient="v"] .paper.enter-lines .body .clause,
.card[data-orient="v"] .paper.enter-lines .gloss { animation-name: enter-line-v; }
@keyframes enter-line {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes enter-line-v {
  from { opacity: 0; transform: translateX(6px); }
  to { opacity: 1; transform: none; }
}

/* 换首入场：卷轴 —— 纸面从右（竖排）/ 从上（横排）揭开 */
.paper.enter-scroll { animation: enter-scroll .6s cubic-bezier(.22, .61, .36, 1) both; }
.card[data-orient="h"] .paper.enter-scroll { animation-name: enter-scroll-h; }
@keyframes enter-scroll {
  from { clip-path: inset(0 0 0 100%); opacity: .35; }
  to { clip-path: inset(0); opacity: 1; }
}
@keyframes enter-scroll-h {
  from { clip-path: inset(0 0 100% 0); opacity: .35; }
  to { clip-path: inset(0); opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  color: var(--ui-bg);
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 14px;
  pointer-events: none;
}

/* 按住 Ctrl 时在纸张顶部居中显示正文字数 */
.wordcount {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: none;
  border: 0;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
}
.wordcount[hidden] { display: none; }

/* 点字数弹出的「原诗词」浮层：排版前的原始分行 */
.orig-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(24, 20, 16, 0.18);
}
.orig-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: fit-content;
  min-width: min(300px, 92vw);
  max-width: min(400px, 92vw);
  overflow: hidden;
  padding: 18px 20px 14px;
  border-radius: 10px 0 0 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.28);
  animation: orig-drawer-in 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes orig-drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.orig-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-size: 15px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid currentColor;
  cursor: move;
  user-select: none;
}
.orig-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.orig-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.5;
  opacity: 0.55;
}
.orig-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.orig-panel.dragging { cursor: grabbing; }
.orig-body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.orig-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid currentColor;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.orig-hr {
  height: 1px;
  margin: 6px 0;
  background: currentColor;
  opacity: 0.16;
}
.orig-meta-row {
  word-break: break-all;
}
.orig-tip {
  flex: 0 0 auto;
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--ink-soft);
}

/* 雪花画布：浮在纸张之上，但不接收任何鼠标事件 */
.snow {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
@media print { .snow { display: none; } }

/* ---------- 「更多」菜单：只在窄屏出现，按钮由 poem.js 搬进来 ---------- */
.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 10px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 168px;
  max-height: 68vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 18px 44px -22px rgba(50, 40, 26, 0.55);
}
/* display:flex 会盖掉 hidden 的默认样式，单独兜底 */
.more-menu[hidden] { display: none; }
/* 搬进来的按钮保留 icon 尺寸，但改成图标 + 文字的行 */
.more-menu .btn.icon {
  width: auto;
  height: 44px;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
}
.more-menu .btn.icon svg { width: 18px; height: 18px; flex: 0 0 auto; }
.more-menu .mm-label {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ---------- 手机右下角的「下一首」圆钮：固定在视口上，浮于纸面 ---------- */
.fab-next { display: none; }

/* ---------- 手机窄屏（≤640px）：横排阅读、顶栏收窄、版式改底部抽屉 ---------- */
@media (max-width: 640px) {
  .fab-next {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 15;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--ui-border);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 20px -12px rgba(60, 48, 30, 0.55);
    color: var(--ink-soft);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .fab-next svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .fab-next:active { background: color-mix(in srgb, var(--surface) 92%, transparent); transform: scale(0.96); }

  html { -webkit-text-size-adjust: 100%; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 13px; letter-spacing: 0.1em; }
  /* 搜索框抢剩余宽度：max-width 放开、允许压到最小 */
  .search { margin: 0 2px; max-width: none; min-width: 0; }
  .search input { padding: 5px 28px 5px 10px; font-size: 13px; }
  .top-actions { gap: 2px; flex: 0 0 auto; }
  .btn { padding: 5px 9px; }
  .btn.icon { width: 34px; height: 34px; }
  /* 自动排版角标在手机上不占位 */
  #typeset-flag { display: none; }

  /* 纸比舞台宽时居中含让左侧滑不到，窄屏一律从左边起排 */
  .stage { padding: 8px 6px; overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
  .paper { padding: 16px 18px; }
  /* 竖排仍是默认：高度随内容；列排不下时纸整张变宽（宽度由 seatNarrowPaper 写死），
     横向滚动交给 stage，滑到哪一列脚下都是纸 */
  :root { --paper-h-v: 70vh; }
  /* 手机上没有「1.38 宽高比」这回事，纸宽直接吃满；纸比视口宽时不能让 flex 把它压回去 */
  .card[data-orient="v"] {
    width: 100%;
    flex: 0 0 auto;
    min-height: 0;
  }
  /* min-height 归零，高度交给 renderPoem 按内容写的内联值；
     换了诗先按视口宽排，再量出需要的宽度写回去，纸就跟着文字一起变宽 */
  .card[data-orient="v"] .paper {
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 0;
  }
  .card[data-orient="v"] .title { font-size: var(--fs-title-user, 21px); }
  .card[data-orient="v"] .body {
    font-size: var(--fs-body-user, 20px);
    line-height: var(--lh-body-user, 2.1);
  }
  /* 若用户在设置里选了横排，字号同样收一档 */
  .card[data-orient="h"] .title { font-size: var(--fs-title-user, 20px); }
  .card[data-orient="h"] .body {
    font-size: var(--fs-body-user, 17px);
    line-height: var(--lh-body-user, 1.95);
  }

  /* 版式浮层：改成贴底、占满宽度的抽屉，拇指够得着 */
  .layout-panel {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 78vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
    z-index: 20;
    box-shadow: 0 -18px 44px -24px rgba(50, 40, 26, 0.5);
  }
  .layout-panel .lp-row { padding: 9px 0; }
  /* 16px 是 iOS 不自动放大的底线 */
  .layout-panel .lp-row select,
  .layout-panel .lp-row input[type="number"],
  .layout-panel .lp-row input[type="text"] { font-size: 16px; width: 46%; }
}

