/* ===== 主题变量 ===== */
:root {
  --accent: #3b82f6;
  --radius: 12px;
}
body[data-theme="light"] {
  --bg: #ffffff; --bg2: #f6f7f8; --bg3: #ffffff;
  --text: #1a1a1a; --text2: #777777;
  --border: #e6e6e6; --shadow: rgba(0,0,0,.10);
  --hl: rgba(59,130,246,.16);
}
body[data-theme="sepia"] {
  --bg: #f5f0e1; --bg2: #ede6d3; --bg3: #faf6ea;
  --text: #5b4636; --text2: #8b7355;
  --border: #ddd3bc; --shadow: rgba(91,70,54,.14);
  --hl: rgba(186,117,23,.18);
}
body[data-theme="dark"] {
  --bg: #1a1a1a; --bg2: #242424; --bg3: #2a2a2a;
  --text: #c8c8c8; --text2: #8a8a8a;
  --border: #383838; --shadow: rgba(0,0,0,.5);
  --hl: rgba(59,130,246,.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  transition: background .25s, color .25s;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

.view { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ===== 通用按钮 ===== */
.btn-primary {
  background: var(--accent); color: #fff; padding: 9px 18px;
  border-radius: 20px; font-size: 14px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  color: var(--text2); padding: 8px 12px; border-radius: 8px; font-size: 14px;
}
.btn-ghost:hover { background: var(--bg2); color: var(--text); }
.btn-store { display: inline-flex; align-items: center; gap: 6px; }
.btn-store .btn-ic { width: 16px; height: 16px; flex: none; }
.badge {
  background: var(--accent); color: #fff; font-size: 11px;
  padding: 1px 7px; border-radius: 10px; margin-left: 2px;
}

/* ===== 书架 ===== */
.shelf-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 40px 16px;
}
.shelf-title h1 { font-size: 22px; font-weight: 600; }
.stat-line { font-size: 12px; color: var(--text2); }
.shelf-actions { display: flex; gap: 8px; align-items: center; }
.shelf-grid {
  flex: 1; overflow-y: auto; padding: 12px 40px 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 28px 24px; align-content: start;
}
.book-card { position: relative; cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 260px; }
.book-cover {
  width: 100%; aspect-ratio: 3/4.2; border-radius: 6px;
  background: var(--bg2); border: 1px solid var(--border);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px var(--shadow);
  transition: transform .18s;
}
.book-card:hover .book-cover { transform: translateY(-4px); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 14px; text-align: center;
}
.cover-placeholder .cp-type { font-size: 11px; color: var(--accent); letter-spacing: 2px; margin-bottom: 10px; }
.cover-placeholder .cp-title { font-size: 14px; font-weight: 600; line-height: 1.5; word-break: break-word; }
.book-name {
  margin-top: 8px; font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-progress { font-size: 11px; color: var(--text2); margin-top: 2px; }
.book-del {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 12px;
  display: none; align-items: center; justify-content: center;
}
.book-card:hover .book-del { display: flex; }
.shelf-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text2); padding-bottom: 80px;
}
.shelf-empty p:first-of-type { font-size: 16px; color: var(--text); }
.empty-hint { font-size: 13px; }
.empty-book-icon {
  width: 64px; height: 80px; border: 2px solid var(--border); border-radius: 4px 10px 10px 4px;
  border-left-width: 8px; margin-bottom: 8px;
}
.drop-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(59,130,246,.12);
  border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center;
}
.drop-tip { font-size: 20px; color: var(--accent); font-weight: 600; }

/* ===== 生词本 ===== */
.sub-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 40px; border-bottom: 1px solid var(--border);
}
.sub-header h2 { font-size: 17px; font-weight: 600; }
.vocab-list { flex: 1; overflow-y: auto; padding: 16px 40px 40px; max-width: 860px; width: 100%; margin: 0 auto; }
.vocab-item {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  content-visibility: auto; contain-intrinsic-size: auto 72px;
}
.vocab-main { flex: 1; min-width: 0; }
.vocab-word { font-size: 16px; font-weight: 600; font-family: Georgia, serif; }
.vocab-phonetic { font-size: 12px; color: var(--text2); margin-left: 8px; }
.vocab-def { font-size: 13px; color: var(--text); margin-top: 4px; line-height: 1.5; }
.vocab-meta { font-size: 11px; color: var(--text2); margin-top: 4px; }
.vocab-ops { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== 古腾堡书城 ===== */
.store-bar { display: flex; gap: 10px; padding: 16px 40px 8px; }
.store-bar .search-input { flex: 1; min-width: 0; height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); font-size: 14px; outline: none; transition: all .15s; }
.store-bar .search-input::placeholder { color: var(--text2); opacity: .7; }
.store-bar .search-input:focus { background: var(--bg3); border-color: var(--accent); box-shadow: 0 0 0 3px var(--hl); }
.store-status { text-align: center; font-size: 13px; color: var(--text2); padding: 24px 16px; }
.store-card { position: relative; cursor: default; content-visibility: auto; contain-intrinsic-size: auto 260px; }
.store-card .book-author { font-size: 11px; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-dl { width: 100%; margin-top: 8px; padding: 8px 0; border-radius: 8px; font-size: 12px; background: var(--accent); color: #fff; border: none; transition: filter .15s; }
.store-dl:hover:not(:disabled) { filter: brightness(1.08); }
.store-dl:disabled { background: var(--bg2); color: var(--text2); cursor: default; }
.store-dl.done { background: #16a34a; color: #fff; }
.store-more-wrap { text-align: center; padding: 10px 0 28px; }

/* ===== 阅读视图 ===== */
#view-reader { position: relative; background: var(--bg); }
.reader-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20; height: 48px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  transition: transform .25s, opacity .25s;
}
.reader-title { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.reader-top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 14px; font-weight: 600;
  background: transparent; border: 1px solid transparent;
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg2); border-color: var(--border); }
.icon-btn svg { width: 18px; height: 18px; }
#btn-fs .ic-exit { display: none; }
#btn-fs.is-fs .ic-enter { display: none; }
#btn-fs.is-fs .ic-exit { display: block; }
/* 兑换码模块关闭时隐藏其全部 UI（入口 / 设置行 / 激活模态） */
body.no-license .trial-banner,
body.no-license .set-row-license,
body.no-license #btn-activate,
body.no-license #activate-status,
body.no-license #activate-modal,
body.no-license #activate-mask { display: none !important; }
.reader-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--bg2); border-top: 1px solid var(--border);
  transition: transform .25s, opacity .25s;
}
body.chrome-hidden .reader-top { transform: translateY(-100%); opacity: 0; }
body.chrome-hidden .reader-bottom { transform: translateY(100%); opacity: 0; }
.progress-track { height: 3px; background: var(--border); }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.reader-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px;
}
.tool-btn {
  padding: 7px 14px; border-radius: 8px; font-size: 13px; color: var(--text2);
  border: 1px solid var(--border); background: var(--bg3);
}
.tool-btn:hover { color: var(--text); border-color: var(--text2); }
.page-label { font-size: 12px; color: var(--text2); min-width: 72px; text-align: center; }

.reader-container {
  position: absolute; inset: 48px 0 52px; overflow: hidden;
  touch-action: manipulation; /* 去除双击缩放延迟，让双击整句手势更跟手 */
  contain: layout style; /* 隔离阅读区布局，避免大内容影响外部重排 */
}
body.chrome-hidden .reader-container { inset: 0; }

/* TXT 阅读器 */
.txt-viewport {
  height: 100%; margin: 0 auto; max-width: 1080px; padding: 0;
  overflow: hidden; position: relative;
}
.txt-content {
  height: 100%; column-fill: auto;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.9; transition: transform .18s ease-out;
  padding: 28px 0;
  will-change: transform; /* 翻页走 GPU 合成层，避免主线程重排卡顿 */
  contain: layout style;
}
.txt-content p { margin-bottom: 1em; text-align: justify; }

/* PDF 阅读器 */
.pdf-stage {
  height: 100%; display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px;
  contain: layout style;
}
.pdf-page { position: relative; box-shadow: 0 4px 18px var(--shadow); }
.pdf-page canvas { display: block; }
body[data-theme="dark"] .pdf-page canvas { filter: invert(0.92) hue-rotate(180deg); }
body[data-theme="sepia"] .pdf-page canvas { filter: sepia(0.35) brightness(0.98); }
.textLayer {
  position: absolute; inset: 0; overflow: hidden; line-height: 1;
  opacity: 1; text-size-adjust: none; forced-color-adjust: none;
}
.textLayer span { position: absolute; white-space: pre; transform-origin: 0 0; color: transparent; cursor: text; }
.textLayer .w { position: static; display: inline; cursor: pointer; }
.textLayer .w:hover { background: var(--hl); }

/* 单词交互 */
.w { cursor: pointer; -webkit-touch-callout: none; }
.w:hover { background: var(--hl); border-radius: 2px; }
.w.w-active { background: var(--hl); border-radius: 2px; }

/* ===== 目录抽屉 ===== */
.toc-drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: 300px; z-index: 40;
  background: var(--bg3); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .25s; display: flex; flex-direction: column;
}
.toc-drawer.open { transform: translateX(0); }
.toc-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.toc-head h3 { font-size: 15px; }
.toc-list { flex: 1; overflow-y: auto; padding: 8px 10px 20px; }
.toc-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px; font-size: 13px;
  border-radius: 8px; color: var(--text); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc-item:hover { background: var(--bg2); }
.toc-item.lv2 { padding-left: 28px; color: var(--text2); font-size: 12px; }

/* ===== 书签抽屉（复用 toc-drawer 骨架） ===== */
.bm-add-row { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bm-add-row .tool-btn { width: 100%; }
.bm-empty { padding: 26px 18px; font-size: 13px; color: var(--text2); line-height: 1.7; text-align: center; }
.bm-item { display: flex; align-items: stretch; gap: 6px; padding: 4px 10px; }
.bm-jump {
  flex: 1; min-width: 0; text-align: left; padding: 10px 12px; border-radius: 8px;
  background: var(--bg2); display: flex; flex-direction: column; gap: 3px;
}
.bm-jump:hover { background: var(--hl); }
.bm-name { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-label { font-size: 11px; color: var(--text2); }
.bm-del {
  flex: none; width: 34px; border-radius: 8px; color: var(--text2); font-size: 13px;
  background: var(--bg2);
}
.bm-del:hover { color: #e5484d; background: var(--hl); }

/* 朗读按钮激活态（连续朗读中） */
.tool-btn.reading { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool-btn.reading:hover { color: #fff; filter: brightness(1.06); }
.mask { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.3); }

/* ===== 设置面板 ===== */
.settings-panel {
  position: absolute; left: 50%; bottom: 64px; transform: translate(-50%, 20px);
  width: min(480px, calc(100vw - 32px)); z-index: 60;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 10px 40px var(--shadow); padding: 18px 22px;
  opacity: 0; pointer-events: none; transition: all .22s;
}
.settings-panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.set-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; }
.set-label { font-size: 13px; color: var(--text2); width: 64px; flex-shrink: 0; }
.set-hint { font-size: 12px; color: var(--text2); line-height: 1.5; }
.set-row-col { flex-direction: column; align-items: stretch; gap: 8px; }
.set-row-col > .set-label { width: auto; }
.theme-swatches { display: flex; gap: 12px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border); }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--hl); }
.swatch-light { background: #ffffff; }
.swatch-sepia { background: #f5f0e1; }
.swatch-dark { background: #1a1a1a; }
.font-ctrl { display: flex; align-items: center; gap: 12px; }
#font-size-label { font-size: 14px; min-width: 24px; text-align: center; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { padding: 7px 12px; font-size: 12px; color: var(--text2); }
.seg button.on { background: var(--accent); color: #fff; }

/* ===== 词典卡片 ===== */
.dict-popup {
  position: fixed; z-index: 80; width: 320px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 8px 32px var(--shadow); padding: 16px 18px;
}
.dict-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dict-word { font-size: 19px; font-weight: 600; font-family: Georgia, serif; }
.dict-phonetic { font-size: 13px; color: var(--text2); font-family: "Segoe UI", sans-serif; }
.dict-body { margin-top: 10px; max-height: 220px; overflow-y: auto; }
.dict-pos { font-size: 11px; color: var(--accent); margin-top: 8px; }
.dict-def { font-size: 13px; line-height: 1.6; margin-top: 2px; }
.dict-zh { font-size: 14px; line-height: 1.6; margin-top: 2px; font-weight: 500; }
.dict-loading { font-size: 13px; color: var(--text2); padding: 8px 0; }
.dict-actions { display: flex; gap: 10px; margin-top: 14px; }
.chip {
  padding: 7px 14px; border-radius: 16px; font-size: 12px;
  border: 1px solid var(--border); color: var(--text2); background: var(--bg2);
}
.chip:hover { color: var(--text); }
.chip-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-accent:hover { color: #fff; filter: brightness(1.08); }

/* ===== 句子弹层（锚定在单词上方/下方） ===== */
.sent-popup {
  position: fixed; z-index: 80; width: min(560px, calc(100vw - 24px));
  background: var(--bg3); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 8px 32px var(--shadow); padding: 16px 18px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.sent-popup.open { opacity: 1; pointer-events: auto; }
.sent-zh { font-size: 15px; line-height: 1.8; }

/* ===== 提示 ===== */
.toast {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%); z-index: 300;
  background: rgba(30,30,30,.88); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 20px;
}
.loading {
  position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.25);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: #fff; font-size: 14px;
}
.spinner {
  width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* EPUB 容器 */
.epub-holder { height: 100%; width: 100%; contain: layout style; }

/* ===== 句子翻译：选中单词在译文中内联加粗 ===== */
.kw { font-weight: 700; color: var(--accent); }

/* ===== 翻译代理设置行 ===== */
.set-input {
  height: 40px; width: 100%; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg2); color: var(--text); font-size: 13px;
  outline: none; transition: all .15s;
}
.set-input::placeholder { color: var(--text2); opacity: .7; }
.set-input:focus { background: var(--bg3); border-color: var(--accent); box-shadow: 0 0 0 3px var(--hl); }
.proxy-input-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.proxy-input-row .set-input { flex: 1; min-width: 0; }
#proxy-test { flex: none; }
.link-btn {
  color: var(--accent); text-decoration: underline; font-size: 12px;
  border: none; background: none; padding: 0; cursor: pointer;
}
.set-hint.ok { color: #16a34a; }
body[data-theme="dark"] .set-hint.ok { color: #4ade80; }
.set-hint.err { color: #dc2626; }
body[data-theme="dark"] .set-hint.err { color: #f87171; }

/* ===== 代理部署引导弹层 ===== */
.proxy-help-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96);
  width: min(560px, calc(100vw - 32px)); z-index: 60; max-height: 86vh; overflow-y: auto;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 22px; box-shadow: 0 12px 48px var(--shadow);
  opacity: 0; pointer-events: none; transition: all .2s;
}
.proxy-help-panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.ph-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ph-head h3 { font-size: 15px; }
.ph-steps { margin: 0 0 12px 18px; font-size: 12.5px; line-height: 1.7; color: var(--text); }
.ph-steps code { background: var(--bg2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.ph-code {
  max-height: 240px; overflow: auto; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font-size: 11.5px; line-height: 1.5; white-space: pre; color: var(--text);
}
.ph-actions { display: flex; gap: 10px; margin-top: 12px; }
.ph-actions .chip { text-decoration: none; }

/* ===== 诊断面板 ===== */
.diag-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); z-index: 60; max-height: 86vh; overflow-y: auto;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 22px; box-shadow: 0 12px 48px var(--shadow);
}
.diag-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.diag-head h3 { font-size: 15px; }
.diag-body {
  max-height: 320px; overflow: auto; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all; color: var(--text);
}
.diag-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ===== 书内搜索面板 ===== */
.search-panel {
  position: absolute; left: 50%; top: 58px; transform: translate(-50%, -10px);
  width: min(560px, calc(100vw - 28px)); z-index: 55;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 16px 50px var(--shadow); padding: 14px;
  opacity: 0; pointer-events: none; transition: all .22s cubic-bezier(.16,.84,.44,1);
  display: flex; flex-direction: column; max-height: min(72vh, 600px);
}
.search-panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.search-head { display: flex; gap: 10px; align-items: center; }
.search-input {
  flex: 1; min-width: 0; height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg2);
  color: var(--text); font-size: 14px; outline: none;
  transition: all .15s;
}
.search-input::placeholder { color: var(--text2); opacity: .7; }
.search-input:focus {
  background: var(--bg3); border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--hl);
}
.search-status { font-size: 12px; color: var(--text2); padding: 10px 4px 2px; }
.search-results { overflow-y: auto; margin-top: 8px; padding-right: 4px; }
.search-results:empty { display: none; }
.search-hit {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.6; color: var(--text); background: transparent; border: none;
  content-visibility: auto; contain-intrinsic-size: auto 56px;
  transition: background .12s;
}
.search-hit:hover { background: var(--bg2); }
.search-hit .hit-label { font-size: 11px; color: var(--text2); display: block; margin-bottom: 3px; }
.search-hit b { color: var(--accent); font-weight: 700; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .shelf-header, .sub-header { padding: 20px 28px 14px; }
  .shelf-grid { padding: 10px 28px 32px; }
  .vocab-list { padding: 14px 28px 32px; }
}
@media (max-width: 768px) {
  .shelf-header { flex-wrap: wrap; gap: 10px; }
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 20px 16px; }
  .reader-top { padding: 0 10px; }
  .reader-title { max-width: 40%; }
  .reader-bottom .reader-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .page-label { min-width: 56px; }
  .settings-panel { width: calc(100vw - 24px); bottom: 8px; }
  .dict-popup { width: min(340px, calc(100vw - 20px)); }
  .sent-popup { width: calc(100vw - 16px); }
}
@media (max-width: 640px) {
  .shelf-header, .sub-header { padding-left: 16px; padding-right: 16px; }
  .store-bar { padding: 14px 16px 8px; }
  .shelf-grid { padding: 8px 16px 24px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 14px; }
  .vocab-list { padding: 8px 16px 24px; }
  .dict-popup { width: calc(100vw - 20px); }
  .tool-btn { padding: 6px 10px; font-size: 12px; }
  .set-row { gap: 10px; }
  .set-label { width: 56px; }
}
@media (max-width: 420px) {
  .shelf-title h1 { font-size: 18px; }
  .reader-toolbar .tool-btn { padding: 6px 8px; font-size: 11px; }
  .page-label { min-width: 48px; font-size: 11px; }
}

/* ===== 尊重系统「减少动态效果」偏好：关闭翻页/抽屉/卡片动画，避免眩晕 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .txt-content { transition: none !important; }
}

/* ===== 试用提示条 ===== */
.trial-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  background: linear-gradient(90deg, #f59e0b, #ef8c0b); color: #fff;
  font-size: 13px; text-align: center; padding: 7px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.trial-banner.hidden { display: none; }
/* 试用条显示时把顶部内容下推，避免遮挡标题/工具栏 */
body.trial-on .shelf-header { padding-top: 44px; }
body.trial-on .sub-header { padding-top: 44px; }
body.trial-on .store-bar { padding-top: 56px; }
body.trial-on .reader-top { top: 34px; }

/* ===== 兑换码激活模态 ===== */
.activate-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96);
  width: min(420px, calc(100vw - 28px)); z-index: 75;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 60px var(--shadow); padding: 22px;
  opacity: 0; pointer-events: none; transition: all .2s;
  display: flex; flex-direction: column; gap: 12px;
}
.activate-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.activate-modal h3 { margin: 0; font-size: 18px; }
.activate-modal .set-hint { margin: 0; }
.activate-input { text-transform: uppercase; letter-spacing: 1px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.activate-error { color: #ef4444; font-size: 13px; }
.activate-error.hidden { display: none; }
.activate-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.set-ok { color: #16a34a !important; font-weight: 600; }
.tool-btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool-btn-accent:hover { filter: brightness(1.06); }
.tool-btn:disabled { opacity: .6; cursor: default; }

