/* 来源：paper-reader 227e4de `site/r/css/eink-base.css`，改动见 SOURCE.md
   墨水屏（html[data-theme="eink"]，DESIGN §8）：和手机同一套版式，只是黑白、没有动画、没有阴影、没有色块（16 级灰下色块会抖成网点）。
   只用 #000、#333、#FFF 三个值（tools/contrast.py 查 tokens.css 那一套；这里另写的也只用这三个）。
   M0 车道 B 第一步（B1）先管外观：动画和过渡一律 0、按钮描边加粗、选中黑底白字；第二步（B2）加书库页（书架、设置页）的分页和
   底部 56px 的书架栏（eink/lib.js；原型 docs/proto/css/eink.css 的 .libbar）；第四步（B4）加阅读视图的原页（eink/page.js：一屏一页、
   整页 / 去白边、切屏、页图压白）、22px 页码行（eink/foot.js）、点正中叫出的菜单（eink/menu.js）、浮层按屏滚。 */
html[data-theme="eink"] *, html[data-theme="eink"] *::before, html[data-theme="eink"] *::after { transition: none !important; animation: none !important; box-shadow: none !important; text-shadow: none !important; }
html[data-theme="eink"] ::selection { background: #000; color: #fff; }
html[data-theme="eink"] .seg, html[data-theme="eink"] .btn-line { border: 1.5px solid #000; background: #fff; color: #000; }
html[data-theme="eink"] .seg[aria-checked="true"], html[data-theme="eink"] .jump-lab[aria-pressed="true"] { background: #000; color: #fff; }
/* 墨水屏只用 #000、#333、#FFF：输入框的提示字、停用的按钮不靠透明度变灰（16 级灰上会抖成网点；审查 BL8）。停用的按钮改成虚线框、白底黑字 */
html[data-theme="eink"] ::placeholder { color: #333; opacity: 1; }
html[data-theme="eink"] button:disabled, html[data-theme="eink"] .tb-i[aria-disabled="true"] { opacity: 1; }
html[data-theme="eink"] .btn-fill:disabled, html[data-theme="eink"] .btn-fill.danger:disabled { background: #fff; color: #000; border: 1.5px dashed #000; }
html[data-theme="eink"] .btn-line:disabled, html[data-theme="eink"] .seg:disabled, html[data-theme="eink"] .pm-btns .tb-i[aria-disabled="true"] { border-style: dashed; }
html[data-theme="eink"] .btn-fill { background: #000; color: #fff; }
html[data-theme="eink"] .in { border: 1.5px solid #000; }
html[data-theme="eink"] .ib { color: #000; }
html[data-theme="eink"] .row-a:active, html[data-theme="eink"] .ib:active { background: #fff; }
/* 整宽浮层（DESIGN §8.3：白底黑线，点外面关闭）：按内容的高贴底，上面露出底下的页（点那里关）。模态 <dialog> 上下 inset 都是 0，
   height: auto 会撑满整屏（审查 BL3），所以用 fit-content */
html[data-theme="eink"] dialog.sheet { width: 100vw; max-width: 100vw; height: fit-content; max-height: 100dvh; margin: auto 0 0; border-radius: 0; border: 0; border-top: 2px solid #000;
  overflow-y: auto; touch-action: pinch-zoom; }
html[data-theme="eink"] dialog.sheet::backdrop { background: transparent; }
html[data-theme="eink"] .opg-box { background: #fff; outline: 1px solid #000; outline-offset: -1px; }
html[data-theme="eink"] .opg-cap, html[data-theme="eink"] .row .mt, html[data-theme="eink"] .set h3 { color: #333; }
html[data-theme="eink"] .pane { scrollbar-width: none; }

/* ---------- 书库页（书架、设置页）分页：页面不滚动，eink/pager.js 把内容上移、裁掉这一页以下 ---------- */
html[data-theme="eink"] body { overflow: hidden; }
html[data-theme="eink"] #lib.pane { overflow: hidden; }
html[data-theme="eink"] .elib { position: relative; height: 100dvh; overflow: hidden; background: #fff; touch-action: pinch-zoom; }
html[data-theme="eink"] .pager { position: relative; overflow: hidden; background: #fff; touch-action: pinch-zoom; }
html[data-theme="eink"] .pg-cols { padding-inline: var(--m); display: flow-root; }
html[data-theme="eink"] .elib .pg-cols .wrap { max-width: 46rem; margin-inline: auto; padding-inline: 0; padding-bottom: 0; }
html[data-theme="eink"] .elib .page, html[data-theme="eink"] .elib .shelf { padding-bottom: 0; }
html[data-theme="eink"] .pg-hide { display: none !important; }
html[data-theme="eink"] .row .pr, html[data-theme="eink"] .up.bad .up-s, html[data-theme="eink"] .up[data-st="net"] .up-s { color: #000; }
html[data-theme="eink"] .up-s, html[data-theme="eink"] .up-resume { color: #333; }
html[data-theme="eink"] .sh-item.danger { color: #000; text-decoration: underline; text-underline-offset: 3px; }
html[data-theme="eink"] .btn-fill.danger { background: #000; color: #fff; }
html[data-theme="eink"] .btn-up { border: 1.5px solid #000; color: #000; }

/* ---------- 书架栏（DESIGN §3.1、§8.6；规则 21）：“‹ 第 1 / 3 页 › · 上传 · 设置”，设置页“‹ 第 1 / n 页 › · 书架”。
   到头的 ‹ › 带 aria-disabled、改成虚线框，图标不变；中间的页码格点不了，不画框。放不下时 eink/lib.js fitBar 逐级压：
   .s1 页码写短“1/3”，.s2 按钮只留图标（读屏名字照旧），.l3 折成两行 ---------- */
.libbar { display: none; }
html[data-theme="eink"] .libbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; min-height: 56px; display: flex; align-items: center; gap: 6px; padding: 4px 8px calc(4px + var(--safe-b)); border-top: 1px solid #000; background: #fff; color: #000; }
html[data-theme="eink"] .lb-arr { width: var(--tap); height: var(--tap); border: 1.5px solid #000; border-radius: 50%; display: grid; place-items: center; flex: none; color: #000; background: #fff; }
html[data-theme="eink"] .lb-arr svg { width: 24px; height: 24px; fill: currentColor; }
html[data-theme="eink"] .lb-arr[aria-disabled="true"] { border-style: dashed; cursor: default; }
html[data-theme="eink"] .lb-pg { flex: none; display: flex; align-items: center; justify-content: center; min-width: 5.5rem; min-height: var(--tap); padding: 0 8px; }
html[data-theme="eink"] .lb-pg b { font-size: .875rem; font-weight: 600; white-space: nowrap; }
html[data-theme="eink"] .lb-pg .pg-short { display: none; }
html[data-theme="eink"] .lb-sp { flex: 1; min-width: 0; }
html[data-theme="eink"] .lb-btn { min-height: var(--tap); min-width: var(--tap); padding: 0 12px; border: 1.5px solid #000; border-radius: 24px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: .9375rem; font-weight: 600; flex: none; background: #fff; color: #000; white-space: nowrap; }
html[data-theme="eink"] .lb-btn svg { width: 20px; height: 20px; fill: currentColor; }
html[data-theme="eink"] .libbar.s1 .lb-pg .pg-full { display: none; }
html[data-theme="eink"] .libbar.s1 .lb-pg .pg-short { display: inline; }
html[data-theme="eink"] .libbar.s1 .lb-pg { min-width: 0; }
html[data-theme="eink"] .libbar.s2 .lb-t { display: none; }
html[data-theme="eink"] .libbar.s2 .lb-btn { padding: 0 11px; }
html[data-theme="eink"] .libbar.l3 { flex-wrap: wrap; row-gap: 4px; }
html[data-theme="eink"] .libbar.l3 .lb-sp { flex-basis: 100%; height: 0; }

/* ---------- 阅读视图：原页（eink/page.js；DESIGN §8.4；原型 e04、e18、e19）----------
   一屏一页、不滚动。正文容器 .ebody 里只有这一屏的页图（规则 19：不放能点的东西；site/dev/redline.js einkBodyTap 按它查）。
   .epg.whole 整页：页框按页的比例放进可用区、居中，四周 1px 黑线（用 outline，不占地方）；.epg.one 去白边放得下一屏：撑满宽、上下居中；
   .epg.slice 放不下：页框就是这一屏，里面那一页（.epg-pg）往上挪到这一屏的上沿（eink/page.js 算好 top、height），最后一屏下面留白。
   页图的位置（--il/--it/--iw/--ih）按框算：框外的部分裁掉。 */
.pg-foot, .pg-top, .pg-menu { display: none; }
html[data-theme="eink"] .pane.read { overflow: hidden; }
html[data-theme="eink"] .ebook { position: relative; height: 100dvh; overflow: hidden; background: #fff; touch-action: pinch-zoom; -webkit-user-select: none; user-select: none; }
html[data-theme="eink"] .ebody { position: relative; height: calc(100dvh - 22px); overflow: hidden; background: #fff; }
html[data-theme="eink"] .epg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
html[data-theme="eink"] .epg.slice { align-items: flex-start; }
html[data-theme="eink"] .epg-box { position: relative; flex: none; overflow: hidden; background: #fff; }
html[data-theme="eink"] .epg.whole .epg-box { outline: 1px solid #000; outline-offset: -1px; }
html[data-theme="eink"] .epg-pg { position: absolute; left: 0; width: 100%; overflow: hidden; }
/* 页图先压白（规则 15）：brightness(.9091) contrast(1.8333) 就是 (x − 0.25) / 0.60——色阶白点 0.85、黑点 0.25，亮度 85% 以上一律变白、
   墨色压深——再转灰，发灰的纸面不在 16 级灰上抖成网点。先 brightness（<1，不会先截到 1）再 contrast，中间不丢值 */
html[data-theme="eink"] .epg-pg > .pimg { position: absolute; display: block; max-width: none; left: var(--il, 0); top: var(--it, 0); width: var(--iw, 100%); height: var(--ih, 100%);
  filter: brightness(.9091) contrast(1.8333) grayscale(1); -webkit-user-select: none; user-select: none; pointer-events: none; }
html[data-theme="eink"] .epg .opg-st { color: #333; }
html[data-theme="eink"] .epg .opg-st.bad { color: #000; }

/* ---------- 页码行（22px，eink/foot.js；DESIGN §8.2）：左一项状态、中页码、右章节 ---------- */
html[data-theme="eink"] .pg-foot { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 22px; padding: 0 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 8px; border-top: 1px solid #000; background: #fff; color: #000; font-size: .75rem; line-height: 1; }
html[data-theme="eink"] .pf-l { white-space: nowrap; overflow: hidden; }
html[data-theme="eink"] .pf-c { white-space: nowrap; font-variant-numeric: tabular-nums; }
html[data-theme="eink"] .pf-r { text-align: right; white-space: nowrap; overflow: hidden; color: #333; font-family: var(--latin-serif); }

/* ---------- 菜单（点正中一格，eink/menu.js；DESIGN §8.3；原型 e07、v-m0-emenu）：顶行“‹ 书架”连同书名是一个链接（规则 25）；
   中行 回到第 n 页 · 37 / 745 · 收起菜单；底行 跳到、更多（M0，Q10）。盖住页码行，没有动画 ---------- */
html[data-theme="eink"] .pg-top { position: fixed; z-index: 22; top: 0; left: 0; right: 0; display: flex; align-items: center; min-height: 56px; padding: 0 8px 0 4px; background: #fff; color: #000; border-bottom: 2px solid #000; }
html[data-theme="eink"] .ab-link { flex: 1; min-width: 0; min-height: var(--tap); display: flex; align-items: center; gap: 6px; padding-left: 8px; color: #000; text-decoration: none; }
html[data-theme="eink"] .ab-link svg { flex: none; width: 24px; height: 24px; fill: currentColor; }
html[data-theme="eink"] .ab-title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.3; }
html[data-theme="eink"] .ab-title b { font-size: .875rem; font-weight: 600; }
html[data-theme="eink"] .ab-title small { font-size: .8125rem; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--latin-serif); }
html[data-theme="eink"] .pg-menu { display: block; position: fixed; z-index: 22; left: 0; right: 0; bottom: 0; padding-bottom: var(--safe-b); background: #fff; color: #000; border-top: 2px solid #000; }
html[data-theme="eink"] .pm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; min-height: var(--tap); padding: 0 8px; border-bottom: 1px solid #000; font-size: .875rem; }
html[data-theme="eink"] .pm-row > :first-child { justify-self: start; }
html[data-theme="eink"] .pm-row > :last-child { justify-self: end; }
html[data-theme="eink"] .pm-l, html[data-theme="eink"] .pm-r { min-height: var(--tap); min-width: var(--tap); padding: 0 6px; background: #fff; color: #000; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
html[data-theme="eink"] .pm-pg { font-variant-numeric: tabular-nums; white-space: nowrap; }
html[data-theme="eink"] .pm-btns { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 10px 8px 12px; }
html[data-theme="eink"] .pm-btns .tb-i { min-width: 76px; min-height: 56px; border: 1.5px solid #000; border-radius: 12px; background: #fff; color: #000; }
html[data-theme="eink"] .pm-btns .tb-i:active { background: #fff; }
