/* ═══════════════════════════════════════════════════════════
   reader.css — 阅读器 App：三栏布局 / 目录 TOC / 排版密度 / 全屏翻译
   ═══════════════════════════════════════════════════════════ */

/* ── 布局骨架 ── */
#win-reader .window-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.reader-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text3); }
.reader-empty .empty-icon { font-size: 56px; }
.reader-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0,1fr) 250px; }

/* ── 左栏：目录 TOC ── */
.reader-toc { border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 10px; background: var(--bg2); }
.reader-toc .toc-title { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; padding: 0 10px 10px; }
.toc-item { font-size: 12px; color: var(--text2); padding: 6px 10px; border-radius: 7px; cursor: pointer; line-height: 1.4; border-left: 2px solid transparent; transition: background .12s, color .12s; }
.toc-item:hover { background: var(--bg3); color: var(--text); }
.toc-item.active { background: rgba(124,92,252,.12); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-h2 { padding-left: 22px; font-size: 11.5px; }
.toc-h3 { padding-left: 34px; font-size: 11px; color: var(--text3); }

/* ── 中栏：正文 ── */
.reader-content { position: relative; overflow-y: auto; padding: 0 0 80px; scroll-behavior: smooth; background: var(--bg); }
.reader-progress { position: sticky; top: 0; height: 3px; background: var(--bg3); z-index: 20; }
.reader-progress > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .12s linear; }
.reader-page { max-width: min(112ch, 960px); margin: 0 auto; padding: 32px 24px 0; }
.reader-title { font-size: 22px; font-weight: 700; line-height: 1.5; color: var(--text); margin-bottom: 10px; }
.reader-title a { color: inherit; text-decoration: none; }
.reader-title a:hover { color: var(--accent2); }
.reader-sub { font-size: 12px; color: var(--text3); line-height: 1.7; margin-bottom: 6px; }
.reader-tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.reader-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0 8px; }

/* 正文章节（TOC 锚点） */
.reader-sec { margin-bottom: 8px; }
.reader-sec-title { font-size: 15px; font-weight: 700; color: var(--accent); margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--section-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; scroll-margin-top: 14px; }
.reader-sec-title .sec-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.reader-sec .text-bubble { background: transparent; border: none; }
.reader-sec .text-bubble-content { padding: 0; }
.reader-sec .text-bubble-footer { padding-left: 0; }

/* 排版密度三档（作用于正文容器） */
.reader-page[data-density="compact"] { font-size: 14px; }
.reader-page[data-density="compact"] .translation-article { font-size: 14px; line-height: 1.65; }
.reader-page[data-density="cozy"] { font-size: 15px; }
.reader-page[data-density="cozy"] .translation-article { font-size: 16px; line-height: 1.8; }
.reader-page[data-density="loose"] { font-size: 16px; }
.reader-page[data-density="loose"] .translation-article { font-size: 17px; line-height: 2.0; }
.reader-page[data-density="loose"] .translation-article p { margin: 14px 0; }

/* ── 右栏：元信息 ── */
.reader-meta { border-left: 1px solid var(--border); overflow-y: auto; padding: 16px 14px; background: var(--bg2); }
.reader-meta-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.reader-meta-card h4 { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.reader-meta-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text2); padding: 4px 0; gap: 8px; }
.reader-meta-row b { color: var(--text); font-weight: 600; text-align: right; }
.reader-status-badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.reader-status-badge.unread { background: rgba(100,116,139,.15); color: var(--text2); }
.reader-status-badge.reading { background: rgba(245,158,11,.15); color: var(--yellow); }
.reader-status-badge.read { background: rgba(16,185,129,.15); color: var(--green); }
.reader-timer { font-size: 12px; color: var(--accent2); font-variant-numeric: tabular-nums; }
.reader-actions { display: grid; gap: 8px; }
.reader-actions button { width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; background: var(--bg2); border: 1px solid var(--border); color: var(--text2); transition: border-color .15s, color .15s, background .15s; text-align: left; }
.reader-actions button:hover { border-color: var(--accent); color: var(--text); }
.reader-actions button:disabled { opacity: .45; cursor: not-allowed; }
.reader-actions a.btn-link { display: block; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 12px; background: var(--bg2); border: 1px solid var(--border); color: var(--accent2); text-decoration: none; box-sizing: border-box; }
.reader-actions a.btn-link:hover { border-color: var(--accent2); }
.reader-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reader-nav button { padding: 8px 6px; border-radius: 8px; font-size: 12px; cursor: pointer; background: var(--bg2); border: 1px solid var(--border); color: var(--text2); transition: border-color .15s, color .15s; }
.reader-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.reader-nav button:disabled { opacity: .35; cursor: not-allowed; }
.density-toggle { display: flex; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.density-toggle button { flex: 1; background: none; border: none; color: var(--text2); font-size: 11px; padding: 6px 4px; cursor: pointer; }
.density-toggle button.active { background: rgba(124,92,252,.2); color: var(--accent); font-weight: 600; }
.reader-meta .star-row { font-size: 18px; }
.reader-meta .star-btn { font-size: 20px; }

/* ── 正文排版（translation-article，全局共用：阅读器 / 列表气泡 / 全屏） ── */
.translation-article { font-size: 15px; line-height: 1.8; color: var(--text); word-break: break-word; }
.translation-article h1 { font-size: 19px; font-weight: 700; color: var(--accent2); margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--section-border); scroll-margin-top: 14px; }
.translation-article h2 { font-size: 17px; font-weight: 600; color: var(--accent2); margin: 20px 0 10px; scroll-margin-top: 14px; }
.translation-article h3 { font-size: 15px; font-weight: 600; color: var(--accent); margin: 18px 0 8px; scroll-margin-top: 14px; }
.translation-article h4 { font-size: 14px; font-weight: 600; color: var(--text2); margin: 16px 0 6px; scroll-margin-top: 14px; }
.translation-article p { margin: 10px 0; }
.translation-article ul, .translation-article ol { margin: 10px 0; padding-left: 28px; }
.translation-article li { margin: 5px 0; }
.translation-article strong { color: var(--text); font-weight: 700; }
.translation-article em { color: var(--accent2); font-style: italic; }
.translation-article code { font-family: 'SF Mono','Fira Code',monospace; font-size: 13px; background: var(--bg3); padding: 2px 6px; border-radius: 4px; color: var(--accent2); }
.translation-article pre { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; overflow-x: auto; margin: 14px 0; }
.translation-article pre code { background: none; padding: 0; color: var(--text); }
.translation-article blockquote { border-left: 3px solid var(--accent); padding: 10px 18px; margin: 14px 0; background: rgba(124,92,252,.08); border-radius: 0 8px 8px 0; color: var(--text2); }
.translation-article blockquote p { margin: 6px 0; }
.translation-article hr { border: none; border-top: 1px dashed var(--border); margin: 20px 0; }
.translation-article table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13px; display: block; overflow-x: auto; }
.translation-article table thead { background: var(--bg3); }
.translation-article table th, .translation-article table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.translation-article table th { color: var(--accent2); font-weight: 600; }
.translation-article table tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
.translation-article img { max-width: 100%; border-radius: 8px; margin: 10px auto; display: block; }
.translation-article figure { margin: 18px 0; text-align: center; }
.translation-article figure img { max-width: 100%; max-height: 560px; object-fit: contain; border-radius: 8px; margin: 0 auto; display: block; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.translation-article figcaption { font-size: 12px; color: var(--text3); margin-top: 8px; line-height: 1.5; text-align: center; }
.translation-article a { color: var(--accent); text-decoration: none; }
.translation-article a:hover { text-decoration: underline; }
.translation-article .chunk-divider { text-align: center; color: var(--text3); margin: 20px 0; font-size: 12px; letter-spacing: 4px; }

/* ── 全屏翻译阅读模式 ── */
.trans-fullscreen-overlay { display: none; position: fixed; inset: 0; z-index: 950; background: var(--bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); flex-direction: column; }
.trans-fullscreen-overlay.open { display: flex; }
.trans-fullscreen-topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.trans-fullscreen-topbar .topbar-title { font-size: 14px; color: var(--text2); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trans-fullscreen-topbar .topbar-actions { display: flex; gap: 10px; align-items: center; }
.btn-exit-fullscreen { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); padding: 6px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; }
.btn-exit-fullscreen:hover { border-color: var(--red); color: var(--red); }
.trans-fullscreen-progress { width: 100%; height: 3px; background: var(--bg3); flex-shrink: 0; }
.trans-fullscreen-progress .progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width .15s ease; }
.trans-fullscreen-body { flex: 1; overflow-y: auto; padding: 48px 24px 80px; scroll-behavior: smooth; }
.trans-fullscreen-content { max-width: 860px; margin: 0 auto; padding: 48px 56px; background: var(--bg2); border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.25); }
.trans-fullscreen-content .translation-article { font-size: 16px; line-height: 1.95; }
.trans-fullscreen-content .translation-article p { margin: 14px 0; text-indent: 2em; text-align: justify; }
.trans-fullscreen-content .translation-article p:first-of-type { text-indent: 0; }
.trans-fullscreen-toc { position: fixed; top: 70px; right: 24px; width: 240px; max-height: 60vh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.4); transform: translateX(20px); opacity: 0; pointer-events: none; transition: transform .2s, opacity .2s; z-index: 960; }
.trans-fullscreen-toc.show { transform: none; opacity: 1; pointer-events: auto; }
.trans-fullscreen-toc .toc-title { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }

/* 桌面/平板隐藏移动工具栏与背板（须置于媒体查询之前，避免被后置规则覆盖） */
.reader-mobile-bar, .reader-panel-backdrop { display: none; }

/* ── 响应式：窄屏单栏 ── */
@media (max-width: 1200px) {
  .reader-layout { grid-template-columns: minmax(0,1fr) 250px; }
  .reader-toc { display: none; }
}
@media (max-width: 860px) {
  .reader-layout { grid-template-columns: minmax(0,1fr); }
  .reader-page { padding: 20px 16px 0; }
  .trans-fullscreen-content { padding: 28px 20px; }
  .reader-content { padding-bottom: 96px; }
  /* 移动端工具栏（吸顶） */
  .reader-mobile-bar { display: flex; position: sticky; top: 0; z-index: 30;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    padding: 6px 10px; gap: 6px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
  .reader-mobile-bar button { flex: 1; min-height: 34px; background: var(--bg3);
    border: 1px solid var(--border); color: var(--text2); border-radius: 8px;
    font-size: 12px; cursor: pointer; }
  .reader-mobile-bar button:active { background: rgba(124,92,252,.15); }
  .reader-mobile-bar button:disabled { opacity: .35; }
  /* 移动端抽屉面板：目录 / 操作 */
  .reader-toc { display: block; position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
    width: min(320px, 86vw); transform: translateX(-102%);
    box-shadow: 12px 0 40px rgba(0,0,0,.35); transition: transform .26s cubic-bezier(.2,.9,.3,1);
    background: var(--bg2); }
  .reader-meta { display: block; position: fixed; top: 0; bottom: 0; right: 0; z-index: 70;
    width: min(330px, 92vw); transform: translateX(102%);
    box-shadow: -12px 0 40px rgba(0,0,0,.35); transition: transform .26s cubic-bezier(.2,.9,.3,1);
    background: var(--bg2); }
  .reader-toc.open { transform: none; }
  .reader-meta.open { transform: none; }
  .reader-panel-backdrop { display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(0,0,0,.42); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .reader-panel-backdrop.show { opacity: 1; pointer-events: auto; }
}

@media (min-width: 861px) {
  .reader-mobile-bar { display: none !important; }
  .reader-panel-backdrop { display: none !important; }
}

/* ── 阅读器空态：最近阅读列表 ── */
.reader-recent-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; background: var(--bg2); transition: border-color .15s, transform .1s; }
.reader-recent-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.reader-recent-title { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; text-align: left; }
.reader-recent-meta { font-size: 11px; color: var(--text3); white-space: nowrap; }
