/* ============================================================
 * NX 小说阅读器 —— Switch 720p 蓝本样式
 * 设计画布 1280×720（对应 Switch 手持 720p；底座 1080p = scale 1.5）
 * 两把字号尺子：
 *   --ui-scale   全局 UI 字号倍率（0.85/1.00/1.15/1.30）
 *   --body-size  正文字号（仅阅读页正文，18/20/22/24/27/30 逻辑 px）
 * ============================================================ */

:root {
  --canvas-w: 1280px;
  --canvas-h: 720px;

  --bg: #14171b;
  --panel: #1d2228;
  --card: #252b32;
  --accent: #e0a33c;
  --focus: #4da3ff;          /* Switch 风格蓝色焦点 */
  --text: #dde2e8;
  --muted: #a4aeb8;
  --danger: #c0534f;

  --ui-scale: 1.0;          /* 运行时由 JS 写入 */
  --ui-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;

  /* 阅读主题 */
  --reader-bg: #121212;
  --reader-fg: #b8b8b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; }
body {
  font-family: var(--ui-font);
  color: var(--text);
  overflow: hidden;
}

/* ===== 1280×720 画布，缩放居中 ===== */
#viewport {
  position: fixed;
  width: var(--canvas-w);
  height: var(--canvas-h);
  transform-origin: 0 0;
  background: var(--bg);
  overflow: hidden;
  /* 圆角在 TV 上无意义，桌面预览时略去 */
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: calc(14px * var(--ui-scale)); }
.spacer { flex: 1; }

/* ===== 视图 ===== */
.view { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.view.active { display: flex; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 76px; padding: 0 24px;
  background: var(--panel);
  border-bottom: 2px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.topbar .brand { font-weight: 800; font-size: calc(26px * var(--ui-scale)); color: var(--accent); white-space: nowrap; letter-spacing: 1px; }
.topbar .title { flex: 1; text-align: center; font-size: calc(22px * var(--ui-scale)); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.searchbox { flex: 1; max-width: 520px; }
.searchbox input {
  width: 100%; height: 44px; padding: 0 16px; border-radius: 22px;
  border: 2px solid rgba(255,255,255,.12); background: var(--bg); color: var(--text);
  font-size: calc(18px * var(--ui-scale)); outline: none;
}
.searchbox input:focus { border-color: var(--accent); }

/* ===== 按钮 ===== */
.btn {
  height: 44px; padding: 0 20px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,.14);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: calc(18px * var(--ui-scale)); white-space: nowrap; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #1a1206; border-color: transparent; font-weight: 700; }
.btn.danger { background: var(--danger); border-color: transparent; }
.btn.tile { flex: 1; min-width: 0; }

/* 焦点环（手柄导航） */
.focus { outline: 3px solid var(--focus); outline-offset: 2px; border-color: var(--focus) !important; }

/* ===== 继续阅读 ===== */
.resume-wrap { padding: 16px 24px 0; flex-shrink: 0; }
.resume-wrap h3 { font-size: calc(15px * var(--ui-scale)); color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.resume-cards { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.resume-card {
  flex: 0 0 auto; width: 240px; padding: 12px 16px; border-radius: 12px;
  background: var(--card); cursor: pointer; border: 2px solid rgba(255,255,255,.05);
}
.resume-card:hover { border-color: var(--accent); }
.resume-card .rc-title { font-weight: 700; font-size: calc(18px * var(--ui-scale)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-card .rc-ch { font-size: calc(14px * var(--ui-scale)); color: var(--muted); margin: 5px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-bar { height: 5px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
.rc-bar i { display: block; height: 100%; background: var(--accent); }

/* ===== 书架 ===== */
.shelf-head { display: flex; align-items: baseline; gap: 12px; padding: 18px 24px 6px; flex-shrink: 0; }
.shelf-head h2 { font-size: calc(22px * var(--ui-scale)); }
.shelf-grid { flex: 1; overflow-y: auto; padding: 8px 24px 24px; }

.shelf-grid.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }
.book-card { cursor: pointer; border-radius: 12px; padding: 6px; }
.book-card:hover { background: var(--card); }
.book-card.focus { background: var(--card); }
.book-cover {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px;
  display: flex; align-items: flex-end; padding: 12px;
  color: #fff; font-weight: 800; font-size: calc(20px * var(--ui-scale)); line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,.55); overflow: hidden;
}
.book-cover .bk-author { font-size: calc(13px * var(--ui-scale)); font-weight: 400; opacity: .85; margin-top: 3px; }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; opacity: 0; transition: opacity .25s; }
/* 不能用 display:none 隐藏未加载的封面：display:none 的图不参与渲染，
   loading="lazy" 永远不触发加载 → 封面一张都出不来。改用 opacity 过渡。 */
.book-cover img.ok { opacity: 1; }
.book-card .bk-title { font-size: calc(18px * var(--ui-scale)); font-weight: 600; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card .bk-meta { font-size: calc(13px * var(--ui-scale)); color: var(--muted); margin-top: 2px; }
.book-card .bk-meta.small { font-size: calc(11px * var(--ui-scale)); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card .book-cover { position: relative; }
.bk-full, .bk-short { font-size: .85em; font-weight: 700; padding: 0 4px; border-radius: 4px; }
.bk-full { color: #8ee0a4; border: 1px solid rgba(142,224,164,.45); }
.bk-short { color: #f0b37e; border: 1px solid rgba(240,179,126,.45); }
.bk-badge {
  position: absolute; top: 6px; right: 6px;
  padding: 2px 7px; border-radius: 9px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: calc(11px * var(--ui-scale)); font-weight: 700;
  border: 1px solid rgba(255,255,255,.25);
}
.online-status {
  padding: 10px 24px 0; min-height: 30px;
  font-size: calc(14px * var(--ui-scale)); color: var(--muted);
}
.book-card .bk-progress { height: 5px; background: rgba(255,255,255,.1); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.book-card .bk-progress i { display: block; height: 100%; background: var(--accent); }

.shelf-grid.list { display: flex; flex-direction: column; gap: 10px; }
.shelf-grid.list .book-card { display: flex; align-items: center; gap: 16px; background: var(--card); border-radius: 12px; padding: 10px; }
.shelf-grid.list .book-cover { width: 66px; height: 88px; aspect-ratio: auto; flex-shrink: 0; font-size: calc(16px * var(--ui-scale)); padding: 8px; }
.shelf-grid.list .book-info { flex: 1; min-width: 0; }
.shelf-grid.list .bk-title { margin-top: 0; }
.shelf-grid.list .bk-progress { margin-top: 6px; }

.empty-hint { text-align: center; padding: 90px 24px; color: var(--text); line-height: 2; }
.empty-hint p { margin-bottom: 8px; font-size: calc(18px * var(--ui-scale)); }
.empty-hint .btn { margin-top: 16px; height: 52px; font-size: calc(20px * var(--ui-scale)); }

/* ===== 目录 ===== */
.toc-list { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
.toc-item {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: calc(19px * var(--ui-scale));
}
.toc-item:hover { background: var(--card); }
.toc-item.focus { background: var(--card); }
.toc-item.current { color: var(--accent); font-weight: 700; }
.toc-item .toc-no { color: var(--muted); font-size: calc(14px * var(--ui-scale)); width: 48px; flex-shrink: 0; }
.toc-item .toc-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item .toc-free { font-size: calc(13px * var(--ui-scale)); color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 6px; }
.bookmark-sec { border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 6px; padding-bottom: 6px; }
.bm-head { padding: 14px 28px 4px; font-size: calc(14px * var(--ui-scale)); color: var(--accent); font-weight: 700; }

/* ===== 阅读器 ===== */
#reader { background: var(--reader-bg); }
.reader-stage { position: relative; flex: 1; overflow: hidden; }
.pages {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  color: var(--reader-fg); overflow: hidden;
}
.pages .ln {
  font-size: var(--body-size, 24px);
  line-height: var(--lineh, 1.7);
  white-space: nowrap;
  text-align: left;
}
.pages .ln.empty { height: 0.5em; }

.reader-status {
  position: relative; flex-shrink:0; width:100%; min-height:42px; padding:10px 28px;
  display: flex; justify-content: space-between; align-items:center; gap:12px;
  border:0; background:var(--reader-bg); cursor:pointer; text-align:left;
  font-size: calc(14px * var(--ui-scale)); color: var(--muted);
  font-family:var(--ui-font);
}
.reader-status span:first-child { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1; }
.reader-status span:not(:first-child) { white-space:nowrap; }
.status-action { color:var(--accent); }

/* 滚动模式：整章行流，随 stage 纵向滚动 */
#reader.scroll-mode .pages { position: relative; height: auto; overflow: visible; }
#reader.scroll-mode .reader-stage { overflow-y: auto; }

/* ===== 阅读菜单（底部覆盖层） ===== */
.reader-menu {
  position: absolute; left: 0; right: 0; bottom:52px;
  background: var(--panel); border-radius:16px 16px 0 0;
  padding: 18px 28px; z-index: 10;
  box-shadow: 0 -8px 30px rgba(0,0,0,.24);max-height:85%;overflow:auto;overscroll-behavior:contain;
}
.reader-menu .menu-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.reader-menu .menu-book-title { font-size: calc(22px * var(--ui-scale)); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-menu .menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.reader-menu .ctl {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border-radius: 10px; border: 2px solid rgba(255,255,255,.14); background: var(--card);
}
.reader-menu .ctl-label { font-size: calc(15px * var(--ui-scale)); color: var(--muted); margin-right: 2px; }
.reader-menu .val { min-width: 40px; text-align: center; color: var(--accent); font-weight: 700; font-size: calc(18px * var(--ui-scale)); }
.reader-menu .ctl .btn { height: 34px; padding: 0 12px; }
.reader-menu .menu-hint { font-size: calc(13px * var(--ui-scale)); color: var(--muted); margin-top: 14px; }
.menu-close { margin-top:16px;width:100%; }

/* ===== 底部按键提示栏 ===== */
.hintbar {
  display: flex; gap: 22px; align-items: center; justify-content: center;
  height: 52px; background: var(--panel); border-top: 2px solid rgba(255,255,255,.05);
  font-size: calc(15px * var(--ui-scale)); color: var(--muted); flex-shrink: 0;
}
.hintbar b { color: var(--text); font-weight: 700; margin-right: 4px; }

/* ===== 主题 ===== */
body.theme-paper { --reader-bg: #f5efe0; --reader-fg: #3a3226; }
body.theme-eye   { --reader-bg: #cfe8d4; --reader-fg: #2b3a2e; }
body.theme-dark  { --reader-bg: #121212; --reader-fg: #b8b8b8; }

body.font-serif .pages { font-family: var(--serif); }
body.font-sans  .pages { font-family: var(--ui-font); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(8px);
  background: rgba(20,22,26,.96); color: #fff; border: 2px solid rgba(255,255,255,.15);
  padding: 10px 22px; border-radius: 24px; font-size: 16px; z-index: 99;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
 * 数据源页（书源池体检 / 四层分级）
 * 左列：T0~T3 四层，可开关；右列：体检数字 + 5 本书实测 + 两个 App 的口径
 * ============================================================ */
.src-summary {
  display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0;
  padding: 14px 24px 10px;
}
.src-chip {
  background: var(--card); border: 1px solid rgba(255,255,255,.07);
  border-radius: 999px; padding: 6px 14px; white-space: nowrap;
  font-size: calc(14px * var(--ui-scale)); color: var(--muted);
}
.src-chip b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.src-chip.warn b { color: var(--accent); }

.src-body {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 448px 1fr;
  gap: 18px; padding: 0 24px 14px;
}
.src-tiers { display: flex; flex-direction: column; gap: 11px; overflow-y: auto; padding-right: 4px; }
.src-tier {
  background: var(--card); border: 2px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 11px 14px; cursor: pointer;
}
.src-tier:hover { border-color: var(--accent); }
.src-tier.focus { border-color: var(--focus); background: #2b323a; }
.src-tier .st-top { display: flex; align-items: center; gap: 9px; }
.src-tier .st-badge {
  font-size: calc(12px * var(--ui-scale)); font-weight: 800; color: #1a1206;
  background: var(--accent); border-radius: 6px; padding: 2px 7px; letter-spacing: .5px;
}
.src-tier.off .st-badge { background: var(--muted); }
.src-tier .st-name { font-size: calc(18px * var(--ui-scale)); font-weight: 700; }
.src-tier .st-state {
  margin-left: auto; font-size: calc(12px * var(--ui-scale)); font-weight: 800;
  padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor;
}
.src-tier .st-state.on { color: #8ee0a4; }
.src-tier .st-state.off { color: var(--muted); }
.src-tier .st-desc {
  margin-top: 6px; font-size: calc(13px * var(--ui-scale)); color: var(--muted); line-height: 1.55;
}
.src-tier .st-nums {
  margin-top: 5px; font-size: calc(13px * var(--ui-scale)); color: var(--text);
  font-variant-numeric: tabular-nums;
}

.src-panel { overflow-y: auto; display: flex; flex-direction: column; gap: 13px; padding-right: 4px; }
.src-block {
  background: var(--card); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 13px 16px;
}
.src-block h3 {
  font-size: calc(14px * var(--ui-scale)); color: var(--accent); font-weight: 800;
  letter-spacing: .6px; margin-bottom: 9px;
}
.src-kv {
  display: grid; grid-template-columns: 1fr auto; gap: 5px 16px;
  font-size: calc(14px * var(--ui-scale));
}
.src-kv .k { color: var(--muted); }
.src-kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.src-kv .v.weak { color: var(--muted); font-weight: 400; }

.src-bar { display: grid; grid-template-columns: 104px 1fr 92px; align-items: center; gap: 10px; margin-bottom: 7px; }
.src-bar:last-child { margin-bottom: 0; }
.src-bar .bl { font-size: calc(14px * var(--ui-scale)); }
.src-bar .bl .genre { margin-left: 6px; font-size: calc(11px * var(--ui-scale)); color: var(--muted); }
.src-bar .bt { height: 8px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.src-bar .bt i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f3cd7c); }
.src-bar .bv { font-size: calc(13px * var(--ui-scale)); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.src-bar .bv b { color: var(--text); }

.src-table { width: 100%; border-collapse: collapse; font-size: calc(13px * var(--ui-scale)); }
.src-table th, .src-table td { padding: 4px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.06); }
.src-table th { color: var(--muted); font-weight: 700; }
.src-table td.n { text-align: right; font-variant-numeric: tabular-nums; }
.src-table tr:last-child td { border-bottom: none; }
.src-table .good { color: #8ee0a4; }
.src-table .bad { color: var(--danger); }
.src-verdict td { vertical-align: top; line-height: 1.5; }
.src-verdict td:nth-child(2) { white-space: nowrap; font-weight: 800; }
.src-verdict tr:first-child th:nth-child(2) { width: 76px; }

.src-note { margin-top: 8px; font-size: calc(12px * var(--ui-scale)); color: var(--muted); line-height: 1.6; }

/* ============================================================
 * 流水线页（APK → 服务端 → Switch）
 * 左列固定六段，右列先跑一条真实搜索、再解释当前段
 * ============================================================ */
.pipe-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 322px 1fr; gap: 18px;
  padding: 16px 24px 10px;
}
.pipe-rail { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; padding-right: 2px; }
.pipe-stage {
  padding: 6px 11px; border-radius: 10px; background: var(--card);
  border: 2px solid rgba(255,255,255,.05); cursor: pointer; flex-shrink: 0;
}
.pipe-stage:hover { border-color: var(--accent); }
.pipe-stage.on { border-color: var(--accent); background: #2b323a; }
.pipe-stage .ps-top { display: flex; align-items: baseline; gap: 8px; }
.pipe-stage .ps-no { color: var(--accent); font-weight: 800; font-size: calc(14px * var(--ui-scale)); }
.pipe-stage .ps-name { font-weight: 700; font-size: calc(16px * var(--ui-scale)); line-height: 1.2; }
.pipe-stage .ps-sub { color: var(--muted); font-size: calc(11px * var(--ui-scale)); margin-top: 1px; line-height: 1.25; }
.pipe-stage .ps-metric {
  margin-top: 3px; font-size: calc(12px * var(--ui-scale)); color: var(--muted);
  font-variant-numeric: tabular-nums; line-height: 1.25;
}
.pipe-stage .ps-metric b { color: var(--text); font-weight: 800; }

.pipe-panel { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.pipe-block {
  background: var(--panel); border-radius: 12px; padding: 13px 16px;
  border: 1px solid rgba(255,255,255,.05);
}
.pipe-block h3 {
  font-size: calc(15px * var(--ui-scale)); font-weight: 800; margin-bottom: 9px;
  display: flex; align-items: center; gap: 10px;
}
.pipe-kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 12px; font-size: calc(13px * var(--ui-scale)); line-height: 1.55; }
.pipe-kv .k { color: var(--muted); }
.pipe-kv .v { color: var(--text); }
.pipe-kv .v b { color: var(--accent); }
.pipe-note { margin-top: 9px; font-size: calc(12px * var(--ui-scale)); color: var(--muted); line-height: 1.6; }
.pipe-note code, .pipe-kv code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; font-size: .95em; }
.pipe-err { color: var(--danger); font-size: calc(13px * var(--ui-scale)); margin-top: 8px; }

/* 跑一次 */
.pipe-run { border-color: rgba(224,163,60,.35); }
.pipe-tag { font-size: calc(11px * var(--ui-scale)); color: var(--muted); font-weight: 600; }
.pipe-runbar { display: flex; gap: 10px; align-items: center; }
.pipe-runbar input {
  flex: 1; height: 42px; padding: 0 14px; border-radius: 9px;
  border: 2px solid rgba(255,255,255,.12); background: var(--bg); color: var(--text);
  font-size: calc(16px * var(--ui-scale)); outline: none;
}
.pipe-runbar input:focus { border-color: var(--accent); }
.pipe-trace-out { margin-top: 11px; }
.pipe-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; font-size: calc(14px * var(--ui-scale)); }
.pipe-chip {
  padding: 3px 9px; border-radius: 20px; background: rgba(255,255,255,.07);
  font-size: calc(12px * var(--ui-scale)); color: var(--muted); font-variant-numeric: tabular-nums;
}
.pipe-chip.warn { background: rgba(224,163,60,.18); color: var(--accent); }

.pipe-stages { display: flex; flex-direction: column; gap: 3px; }
.pt-row { display: grid; grid-template-columns: 88px 1fr 74px; align-items: center; gap: 10px; }
.pt-name { font-size: calc(13px * var(--ui-scale)); font-weight: 700; }
.pt-bar { height: 9px; background: rgba(255,255,255,.07); border-radius: 5px; overflow: hidden; }
.pt-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f3cd7c); border-radius: 5px; }
.pt-ms { text-align: right; font-size: calc(12px * var(--ui-scale)); color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-detail { font-size: calc(11px * var(--ui-scale)); color: var(--muted); padding: 0 0 6px 98px; line-height: 1.45; }

.pipe-srcs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.pipe-src {
  display: flex; flex-direction: column; padding: 5px 10px; border-radius: 8px;
  background: rgba(255,255,255,.05); font-size: calc(12px * var(--ui-scale)); font-weight: 700;
}
.pipe-src i { font-style: normal; color: var(--muted); font-weight: 400; font-size: calc(10px * var(--ui-scale)); margin-top: 2px; }
.pipe-src.bad { opacity: .5; }

.pipe-plan { margin-top: 11px; padding: 11px 13px; border-radius: 10px; background: rgba(224,163,60,.08); border: 1px solid rgba(224,163,60,.28); }
.pp-title { font-size: calc(13px * var(--ui-scale)); font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.pp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 12px; }
.pp-grid div { display: flex; flex-direction: column; }
.pp-grid span { font-size: calc(10px * var(--ui-scale)); color: var(--muted); }
.pp-grid b { font-size: calc(13px * var(--ui-scale)); font-variant-numeric: tabular-nums; }

/* ⑤ 流程图 */
.pipe-flow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 11px; }
.pipe-flow .pf {
  padding: 5px 11px; border-radius: 7px; background: rgba(255,255,255,.06);
  font-size: calc(12px * var(--ui-scale)); font-weight: 700;
}
.pipe-flow i { color: var(--muted); font-style: normal; font-size: calc(12px * var(--ui-scale)); }

/* ============================================================
 * 场景条 / 系统页（账号与场景、缓存与离线、接口契约）
 * 这一块对应宿主里的「情景切换 → 小说」，以及 Switch 端的 NovelSystemView。
 * ============================================================ */

/* ===== 场景条 ===== */
.scene-bar {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 24px;
  background: rgba(224,163,60,.07);
  border-bottom: 1px solid rgba(224,163,60,.18);
  font-size: calc(12px * var(--ui-scale));
  flex-shrink: 0;
}
.scene-name { color: var(--accent); font-weight: 800; letter-spacing: .5px; }
.scene-sep { color: rgba(255,255,255,.22); }
.scene-user { color: var(--text); }
.scene-net {
  padding: 2px 9px; border-radius: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.scene-net.online { background: rgba(90,180,120,.16); color: #7fd39a; }
.scene-net.offline { background: rgba(192,83,79,.18); color: #e08b87; }
.scene-cache { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== 系统页 ===== */
.sys-tabs { display: flex; gap: 8px; }
.sys-tab { height: 38px; padding: 0 16px; font-size: calc(14px * var(--ui-scale)); }
.sys-tab.on { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 800; }

.sys-body { flex: 1; overflow-y: auto; padding: 18px 24px 26px; }
.sys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sys-card {
  background: var(--panel); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 15px 17px;
}
.sys-card.wide { grid-column: 1 / -1; }
.sys-card h3 {
  font-size: calc(15px * var(--ui-scale)); font-weight: 800;
  color: var(--accent); margin-bottom: 11px;
}
.kv { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; font-size: calc(13px * var(--ui-scale)); }
.kv span { width: 96px; color: var(--muted); flex-shrink: 0; }
.kv b { font-weight: 600; }
.kv b.ok { color: #7fd39a; }
.kv b.warn { color: var(--accent); }

.sys-token { display: flex; gap: 8px; margin: 11px 0 8px; }
.sys-token input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 9px;
  border: 2px solid rgba(255,255,255,.12); background: var(--bg); color: var(--text);
  font-size: calc(12px * var(--ui-scale)); outline: none;
}
.sys-token input:focus { border-color: var(--accent); }
.sys-token .btn { height: 40px; padding: 0 14px; font-size: calc(13px * var(--ui-scale)); }

.sys-note { margin-top: 9px; color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.6; }
.sys-note code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; }

.scene-stack { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.ss-node {
  padding: 5px 11px; border-radius: 8px; background: rgba(255,255,255,.06);
  font-size: calc(12px * var(--ui-scale)); font-weight: 700;
}
.ss-node.on { background: var(--accent); color: #1a1206; }
.ss-arrow { color: var(--muted); font-size: calc(12px * var(--ui-scale)); }

.sys-table { width: 100%; border-collapse: collapse; font-size: calc(12px * var(--ui-scale)); }
.sys-table th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sys-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,.04); }
.sys-table tr:last-child td { border-bottom: none; }

.sys-metrics { display: flex; gap: 26px; margin: 6px 0 14px; }
.sys-metrics div { display: flex; align-items: baseline; gap: 5px; }
.sys-metrics b { font-size: calc(26px * var(--ui-scale)); font-variant-numeric: tabular-nums; color: var(--accent); }
.sys-metrics span { font-size: calc(11px * var(--ui-scale)); color: var(--muted); }
.sys-actions { display: flex; gap: 9px; }
.sys-actions .btn { height: 38px; padding: 0 15px; font-size: calc(13px * var(--ui-scale)); }

/* ===== 接口契约 ===== */
.sys-api-head {
  background: var(--panel); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 13px 17px; margin-bottom: 13px;
}
.sys-api-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 13px; }
.sys-call {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 13px; border-radius: 10px; text-align: left;
  background: var(--card); border: 1px solid rgba(255,255,255,.06);
  color: var(--text); cursor: pointer;
  font-family: var(--ui-font);
}
.sys-call:hover, .sys-call.focus { border-color: var(--focus); }
.sc-method {
  flex-shrink: 0; width: 46px; text-align: center; padding: 2px 0;
  border-radius: 5px; background: rgba(77,163,255,.16); color: #8ec4ff;
  font-size: calc(11px * var(--ui-scale)); font-weight: 800;
}
.sc-path { font-size: calc(13px * var(--ui-scale)); font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sc-note { margin-left: auto; color: var(--muted); font-size: calc(11px * var(--ui-scale)); }

.sys-api-out {
  background: var(--panel); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 13px 17px; min-height: 150px;
}
.api-line { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: calc(12px * var(--ui-scale)); }
.api-line b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
.api-line i { margin-left: auto; color: var(--muted); font-style: normal; font-variant-numeric: tabular-nums; }
.api-ok { padding: 2px 8px; border-radius: 5px; background: rgba(90,180,120,.18); color: #7fd39a; font-weight: 800; }
.api-bad { padding: 2px 8px; border-radius: 5px; background: rgba(192,83,79,.2); color: #e08b87; font-weight: 800; }
.api-json {
  max-height: 320px; overflow: auto; padding: 11px 13px; border-radius: 9px;
  background: #101317; border: 1px solid rgba(255,255,255,.05);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: calc(11px * var(--ui-scale)); line-height: 1.55; color: #b9c6d2;
  white-space: pre-wrap; word-break: break-all;
}

/* Account surfaces share the bookshop palette; they never inherit canvas scaling. */
::selection { background:#e0a33c; color:#14171b; }
:focus-visible { outline:3px solid var(--focus);outline-offset:3px; }
input { caret-color:var(--accent); }
* { scrollbar-color:#58636e #1d2228;scrollbar-width:thin; }
button { font-family:inherit; }
button:disabled { opacity:.55;cursor:wait; }
.topbar { gap:10px; }
.topbar .brand { font-size:24px;letter-spacing:0; }
.topbar .btn { padding-inline:15px; }
.sync-action,.text-action { border:0;background:transparent;color:var(--accent);font:inherit;cursor:pointer;padding:10px; }
.sync-action { font-size:14px; }
.cover-type { position:absolute;inset:20px 16px;display:flex;flex-direction:column;justify-content:space-between;pointer-events:none; }
.cover-type strong { font-family:var(--serif);font-size:29px;line-height:1.6;overflow:hidden;max-height:6.4em; }
.book-cover:has(img) .cover-type { display:none; }
.account-screen { position:fixed;inset:0;z-index:500;background:var(--bg);overflow:auto; }
.account-layout { min-height:100%;max-width:1240px;margin:auto;display:grid;grid-template-columns:1.1fr 1fr; }
.account-intro { padding:64px 64px 32px;position:relative;overflow:hidden; }
.account-brand { color:var(--accent);font-weight:700;font-size:22px;text-decoration:none; }
.account-intro h1 { font-family:var(--serif);font-weight:500;font-size:52px;line-height:1.5;letter-spacing:-.02em;margin:45px 0 18px;text-wrap:balance; }
.account-intro p { color:var(--muted);font-size:17px;line-height:1.9;max-width:38ch; }
.account-book { margin:36px 0 28px;max-width:300px;height:195px;background:#332d24;border-radius:4px 12px 12px 4px;box-shadow:8px 12px 28px #0004;padding:28px 28px 22px;display:flex;flex-direction:column; }
.account-book span { font:36px var(--serif);color:#e4c48b; }
.account-book i { display:block;height:1px;background:#967b4f;margin:14px 0; }
.account-book small { color:#d4bb91;font-family:var(--serif); }
.account-intro .account-note { font-size:14px; }
.account-form-wrap { padding:32px 56px;display:flex;flex-direction:column;justify-content:center;align-items:stretch;background:var(--panel); }
.account-top-actions { display:flex;justify-content:space-between;gap:16px; }
.account-form { display:flex;flex-direction:column;padding:34px 0;gap:16px; }
.account-form h2 { font-size:30px;font-weight:650;letter-spacing:-.02em; }
.account-form>p { color:var(--muted);font-size:16px;line-height:1.7;margin-bottom:14px; }
.account-form label { font-size:15px;margin-top:8px; }
.account-form input { width:100%;min-width:0;padding:14px 16px;font:17px var(--ui-font);color:var(--text);background:var(--bg);border:1px solid #63707c;border-radius:10px;height:52px; }
.account-form input::placeholder { color:#a4aeb8; }
.account-form .btn { min-height:50px; }
.password-row { display:flex;position:relative; }
.password-row input { padding-right:70px; }
.password-row button { position:absolute;right:8px;top:6px;height:40px;background:transparent;border:0;color:var(--accent);padding:0 10px;cursor:pointer; }
.account-register { color:var(--muted);font-size:14px;text-align:center;text-underline-offset:4px; }
.account-error { color:#ffb7af;font-size:15px;line-height:1.6;min-height:24px; }
#deviceForm { display:flex;flex-direction:column;gap:14px;padding-block:22px; }
#deviceCode { letter-spacing:.16em;font-variant-numeric:tabular-nums;text-transform:uppercase; }
#deviceStatus { line-height:1.6;color:var(--accent); }
.sync-conflict { padding-block:24px;border-top:1px solid var(--muted);display:flex;flex-direction:column;gap:12px; }
.sync-conflict p { color:var(--muted);line-height:1.7; }
@media (max-width:759px) {
  .account-layout { grid-template-columns:1fr; }
  .account-intro { padding:28px 24px 18px; }
  .account-intro h1 { font-size:33px;line-height:1.45;margin:22px 0 12px; }
  .account-intro h1 br { display:none; }
  .account-intro p { font-size:15px; }
  .account-book,.account-note { display:none; }
  .account-form-wrap { padding:12px 24px 36px; }
  .account-form { padding:14px 0;gap:12px; }
  .account-form h2 { font-size:26px; }
  .topbar { height:auto;min-height:64px;padding:14px 16px;flex-wrap:wrap;gap:8px; }
  .topbar .brand { font-size:22px;flex:1 0 calc(100% - 100px); }
  .topbar .btn { font-size:15px;height:40px;padding:0 12px; }
  .topbar .searchbox { min-width:100%;order:1; }
  .topbar .searchbox input { font-size:16px;height:42px; }
  .scene-bar { gap:4px;padding:6px 16px;flex-wrap:wrap;height:auto;min-height:40px;font-size:12px; }
  .scene-name,.scene-sep,#sceneCache { display:none; }
  .scene-bar .spacer { display:none; }
  .scene-net { margin-left:auto; }
  .sync-action { font-size:12px;padding:8px; }
  .shelf-head { padding:20px 16px 8px; }
  .shelf-grid.grid { grid-template-columns:repeat(2,minmax(0,1fr));gap:20px 14px;padding:12px 16px 24px; }
  .book-cover { height:200px; }
  .cover-type strong { font-size:24px; }
  .resume-wrap { padding:16px 16px 0; }
  .resume-card { width:245px; }
  .hintbar { display:none; }
  .online-status { font-size:14px;padding:16px; }
  .reader-stage { flex:1;min-height:0; }
  .reader-menu { bottom:0;max-height:85dvh;overflow:auto;padding:16px 16px max(16px,env(safe-area-inset-bottom)); }
  .reader-menu .menu-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .reader-menu .ctl { grid-column:1 / -1;justify-content:space-between;padding:0 12px;min-height:48px; }
  .reader-menu .ctl .btn { min-width:44px;min-height:40px; }
  .reader-menu .menu-book-title { min-width:0;flex:1;font-size:18px; }
  .reader-menu .menu-top { gap:12px; }
  .reader-menu .menu-hint { display:none; }
  .menu-grid .btn { font-size:15px; }
  .reader-status { font-size:12px;padding:12px 16px max(12px,env(safe-area-inset-bottom));min-height:48px; }
  .sys-body { padding:16px; }
}

/* Day mode changes every app surface; the existing dark palette remains night. */
html[data-appearance="day"] { background:#f7f4ee; }
body { background:var(--bg); }
body.appearance-night { --reader-bg:#121212;--reader-fg:#b8b8b8; }
body.appearance-day {
  --bg:#f7f4ee;--panel:#fffdf8;--card:#eee7db;--accent:#875821;--focus:#1265a7;
  --text:#2d2a25;--muted:#6b6255;--danger:#963e36;--reader-bg:#faf7f0;--reader-fg:#332d25;
}
.appearance-day .btn.primary { color:#fffaf0; }
.appearance-day .btn,.appearance-day .ctl,.appearance-day .searchbox input { border-color:#b9aa95; }
.appearance-day .btn.danger,.appearance-night .btn.danger { color:#fff4ec; }
.appearance-day .account-form input { border-color:#9c8d7c; }
.account-form input::placeholder { color:var(--muted); }
.appearance-day .account-error { color:#963e36; }
.appearance-day .account-book { background:#e9dbc1;box-shadow:8px 12px 28px #7e663222; }
.appearance-day .account-book span { color:#68471f; }
.appearance-day .account-book i { background:#aa906b; }
.appearance-day .account-book small { color:#69512d; }
.appearance-day .resume-card,.appearance-day .shelf-grid.list .book-card { border-color:#d4c7b5; }
.appearance-day .scene-bar { background:#eee7db;color:var(--text); }
.appearance-day * { scrollbar-color:#b9aa95 #f7f4ee; }
.appearance-day ::selection { background:#875821;color:#fffaf0; }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important;transition:none!important;animation:none!important; } }
