/* 繼祖書房 */

:root {
  --serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', 'MingLiU', serif;
  --sans: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --latin: 'Cormorant Garamond', 'Times New Roman', serif;

  --bg: #F3EFE6;
  --surface: #FBF9F4;
  --ink: #1C1A17;
  --ink2: #4F4A42;
  --ink3: #6E675C;
  --rule: #DCD5C7;
  --track: #E2DBCC;
  --btn-bg: #1C1A17;
  --btn-fg: #FBF9F4;
  --hover-bg: #EBE5D8;
  --shadow: 0 1px 2px rgba(28,26,23,0.14), 0 26px 48px -18px rgba(60,45,20,0.5);
  --focus: #2C4870;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1A1815;
  --surface: #22201C;
  --ink: #E8E2D6;
  --ink2: #C4BCAE;
  --ink3: #9C9485;
  --rule: #36322C;
  --track: #3A362F;
  --btn-bg: #E8E2D6;
  --btn-fg: #1A1815;
  --hover-bg: #26231F;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 26px 48px -18px rgba(0,0,0,0.8);
  --focus: #93AAD3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.book-accent { --a: var(--accent); }
:root[data-theme="dark"] .book-accent { --a: var(--accent-dark); }

/* ---------- 頁首 ---------- */
.site-head {
  height: 88px; padding: 0 max(24px, calc((100vw - 1200px) / 2));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 14px; text-decoration: none; min-height: 44px; align-items: center; }
.brand b { font-family: var(--serif); font-weight: 900; font-size: 24px; letter-spacing: 0.14em; }
.brand span { font-family: var(--latin); font-weight: 600; font-size: 13px; letter-spacing: 0.28em; color: var(--ink3); }
.head-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chip-link {
  height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  font-size: 14px; color: var(--ink2); text-decoration: none;
  border: 1px solid var(--rule); border-radius: 22px; white-space: nowrap;
}
.chip-link:hover { border-color: var(--ink3); color: var(--ink); }
.dot { width: 6px; height: 6px; border-radius: 3px; background: var(--a, #A3302A); flex-shrink: 0; }
.round-btn {
  width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--rule); border-radius: 22px;
  background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.round-btn:hover { border-color: var(--ink3); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ---------- 書架 ---------- */
.intro { padding: 72px 0 56px; display: flex; align-items: flex-end; justify-content: space-between; gap: 48px; }
.intro h1 { margin: 0 0 16px; font-family: var(--serif); font-weight: 900; font-size: 48px; letter-spacing: 0.12em; line-height: 1.1; }
.intro p { margin: 0; font-size: 17px; line-height: 1.8; color: var(--ink2); max-width: 600px; }
.intro .count { font-size: 14px; color: var(--ink3); white-space: nowrap; }

.shelf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 64px; }
.bk { display: flex; gap: 36px; align-items: flex-start; }
.bk-cover { flex-shrink: 0; display: block; }
.bk-cover img { width: 256px; height: auto; aspect-ratio: 0.7059; object-fit: cover; box-shadow: var(--shadow); transition: transform .25s ease; background: var(--track); }
.bk-cover:hover img { transform: translateY(-4px); }
.bk-info { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding-top: 2px; }
.latin { font-family: var(--latin); font-weight: 600; font-size: 12px; letter-spacing: 0.22em; color: var(--ink3); }
.bk-info h2 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 40px; letter-spacing: 0.06em; line-height: 1.1; }
.bk-info h2 a { text-decoration: none; }
.author { font-size: 14px; color: var(--ink2); letter-spacing: 0.2em; }
.tagline { margin: 4px 0 0; font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.7; color: var(--a); }
.meta { font-size: 13px; color: var(--ink3); }
.prog { margin-top: 4px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; }
.prog-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink3); }
.prog-where { font-size: 15px; font-weight: 500; }
.bar { height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--a); }
.btns { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.btn {
  height: 44px; padding: 0 20px; display: inline-flex; align-items: center; gap: 10px;
  font-size: 15px; text-decoration: none; border-radius: 2px; cursor: pointer; white-space: nowrap;
}
.btn-solid { background: var(--btn-bg); color: var(--btn-fg); font-weight: 500; border: 1px solid var(--btn-bg); }
.btn-solid:hover { background: var(--a); border-color: var(--a); color: #fff; }
.btn-line { border: 1px solid var(--ink); color: var(--ink); background: transparent; }
.btn-line:hover { background: var(--ink); color: var(--bg); }
.btn small { font-size: 14px; opacity: 0.75; font-weight: 400; }
.text-link { font-size: 14px; color: var(--ink2); text-underline-offset: 4px; padding: 6px 0; align-self: flex-start; }
.text-link:hover { color: var(--ink); }

.features { margin-top: 80px; padding-top: 40px; border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 48px; }
.features svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.features h3 { margin: 10px 0; font-family: var(--serif); font-weight: 600; font-size: 19px; }
.features p { margin: 0; font-size: 15px; line-height: 1.8; color: var(--ink2); }

.site-foot { max-width: 1200px; margin: 0 auto; padding: 48px 24px 40px; display: flex; justify-content: space-between; align-items: flex-end; gap: 48px; font-size: 13px; line-height: 1.8; color: var(--ink3); }
.site-foot p { margin: 0; max-width: 820px; }

/* 手機書架 */
.continue-card { display: none; }
@media (max-width: 760px) {
  .site-head { height: 60px; padding: 0 8px 0 20px; }
  .brand b { font-size: 20px; }
  .brand span { display: none; }
  .head-tools .chip-link { display: none; }
  .round-btn { border: 0; }
  .wrap { padding: 0 20px; }
  .continue-card {
    display: flex; margin: 20px 0 0; padding: 14px; align-items: center; gap: 14px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; text-decoration: none;
  }
  .continue-card img { width: 52px; aspect-ratio: 0.7059; height: auto; object-fit: cover; box-shadow: 0 6px 12px -6px rgba(60,45,20,0.5); }
  .continue-card .cc { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  .continue-card .cc small { font-size: 12px; color: var(--ink3); }
  .continue-card .cc b { font-family: var(--serif); font-weight: 600; font-size: 17px; }
  .continue-card .cc span { font-size: 13px; color: var(--ink2); }
  .continue-card .bar { height: 3px; }
  .intro { padding: 32px 0 20px; display: block; }
  .intro h1 { font-size: 30px; margin-bottom: 8px; }
  .intro p { font-size: 14px; }
  .intro .count { display: none; }
  .shelf { gap: 18px; }
  .bk { flex-direction: column; gap: 10px; }
  .bk-cover img { width: 100%; }
  .bk-info { gap: 8px; }
  .bk-info .latin, .bk-info .author, .bk-info .prog, .bk-info .btns, .bk-info .text-link { display: none; }
  .bk-info h2 { font-size: 20px; margin-top: 4px; }
  .tagline { font-size: 13px; margin: 0; line-height: 1.6; }
  .meta { font-size: 12px; }
  .meta-full { display: none; }
  .features { margin-top: 48px; grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .site-foot { display: block; padding: 32px 20px 28px; font-size: 12px; }
  .site-foot span { display: block; margin-top: 8px; }
}
@media (min-width: 761px) { .meta-short { display: none; } }
@media (min-width: 761px) and (max-width: 1100px) {
  .shelf { grid-template-columns: 1fr; gap: 56px; }
  .features { gap: 32px; }
}

/* ---------- 書籍頁 ---------- */
.crumb { padding: 28px 0 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink3); }
.crumb a { min-height: 44px; display: flex; align-items: center; gap: 6px; color: var(--ink2); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.detail { padding: 32px 0 80px; display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 96px; align-items: start; }
.detail-left { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 24px; }
.detail-left img { width: 100%; height: auto; aspect-ratio: 0.7059; box-shadow: var(--shadow); background: var(--track); }
.detail-left .btns { margin: 0; flex-wrap: nowrap; }
.detail-left .btn { height: 52px; font-size: 16px; }
.detail-left .btn-solid { flex-grow: 1; justify-content: center; }
.note { font-size: 13px; color: var(--ink3); }
.detail-right { max-width: 720px; }
.detail-right .latin { font-size: 14px; letter-spacing: 0.26em; }
.detail-right h1 { margin: 14px 0 0; font-family: var(--serif); font-weight: 900; font-size: 76px; letter-spacing: 0.06em; line-height: 1.1; }
.detail-right .author { display: block; margin-top: 16px; font-size: 16px; letter-spacing: 0.24em; }
.quote { margin: 48px 0 0; font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.6; color: var(--a); }
.blurb { margin-top: 28px; display: flex; flex-direction: column; gap: 18px; font-family: var(--serif); font-size: 18px; line-height: 2; }
.blurb p { margin: 0; }
.blurb strong { font-weight: 900; }
.facts { margin-top: 44px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; padding: 22px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts div { display: flex; flex-direction: column; gap: 6px; }
.facts small { font-size: 13px; color: var(--ink3); }
.facts b { font-size: 16px; font-weight: 500; }
.law { margin-top: 28px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.9; color: var(--ink2); }
.law small { font-size: 13px; color: var(--ink3); letter-spacing: 0.1em; }

.toc-sec { padding: 56px 0 0; border-top: 1px solid var(--ink); }
.toc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; }
.toc-head h2 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 32px; letter-spacing: 0.16em; }
.toc-head span { font-size: 14px; color: var(--ink3); }
.toc-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 56px; }
.toc-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.toc-grid h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; letter-spacing: 0.2em; color: var(--ink3); }
.toc-row { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 0 4px; border-bottom: 1px solid var(--rule); text-decoration: none; }
.toc-row:hover { background: var(--hover-bg); }
.toc-row .n { width: 64px; flex-shrink: 0; font-size: 13px; color: var(--ink3); }
.toc-row .t { flex-grow: 1; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.toc-row .s { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink3); white-space: nowrap; }
.toc-row .s.now { color: var(--a); }
.toc-row .s svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toc-row .p { width: 36px; flex-shrink: 0; text-align: right; font-size: 14px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.toc-row.done .t { color: var(--ink3); }

@media (max-width: 1100px) {
  .detail { grid-template-columns: 320px minmax(0, 1fr); gap: 56px; }
  .detail-right h1 { font-size: 60px; }
  .toc-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
}
@media (max-width: 760px) {
  .crumb { padding-top: 12px; }
  .detail { display: flex; flex-direction: column; gap: 32px; padding: 16px 0 48px; }
  .detail-left { position: static; align-items: stretch; }
  .detail-left img { width: 62%; margin: 0 auto; }
  .detail-right h1 { font-size: 44px; }
  .quote { margin-top: 28px; font-size: 21px; }
  .blurb { font-size: 16px; line-height: 1.95; }
  .facts { grid-template-columns: 1fr 1fr; gap: 16px; }
  .toc-sec { padding-top: 36px; }
  .toc-head { display: block; }
  .toc-head span { display: block; margin-top: 8px; }
  .toc-grid, .toc-grid.cols-2 { grid-template-columns: 1fr; gap: 24px; }
  .toc-grid.cols-2 { gap: 0; }  /* 沒有分部的書：兩欄接成一欄，中間不要空一段 */
  .toc-row { min-height: 54px; }
  .toc-row .n { width: 58px; font-size: 12px; }
  .toc-row .t { font-size: 17px; }
}

/* ---------- 閱讀器共用 ---------- */
.reader { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.rbar { flex-shrink: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; padding: 0 12px; transition: transform .25s ease, opacity .25s ease; z-index: 5; }
.rbar.top { height: 60px; padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
.r-left, .r-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.r-right { justify-content: flex-end; }
.r-back { height: 44px; padding: 0 12px 0 8px; display: flex; align-items: center; gap: 4px; border-radius: 6px; text-decoration: none; font-size: 14px; flex-shrink: 0; }
.r-back svg { width: 20px; height: 20px; }
.r-sep { width: 1px; height: 20px; background: var(--r-rule); margin: 0 8px; flex-shrink: 0; }
.r-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.r-title b { font-family: var(--serif); font-weight: 600; font-size: 15px; white-space: nowrap; }
.r-title span { font-size: 14px; color: var(--r-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; padding: 3px; gap: 2px; background: var(--r-chip); border-radius: 8px; }
.seg a, .seg button, .seg span { height: 38px; padding: 0 18px; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 14px; text-decoration: none; border: 0; background: transparent; cursor: pointer; white-space: nowrap; }
.seg [aria-current="true"], .seg [aria-pressed="true"] { background: var(--r-chip-on); color: var(--r-chip-on-fg); font-weight: 500; }
.ibtn { width: 44px; height: 44px; border: 0; border-radius: 6px; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex-shrink: 0; }
.ibtn:hover, .r-back:hover { background: var(--r-hover); }
.ibtn[aria-pressed="true"] { background: var(--r-chip); }
.ibtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.aa { font-family: var(--serif); width: auto; padding: 0 14px; align-items: baseline; gap: 1px; }
.aa span:first-child { font-size: 14px; } .aa span:last-child { font-size: 20px; font-weight: 600; }
.r-divider { width: 1px; height: 20px; background: var(--r-rule); margin: 0 6px; }
.zoom-val { width: 48px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--r-muted); }

.turn-wrap { width: 96px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.turn { width: 56px; height: 56px; border-radius: 28px; border: 1px solid var(--r-rule); background: var(--r-turn); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.turn:hover { background: var(--r-hover); }
.turn:disabled { opacity: 0.3; cursor: default; }
.turn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.turn-wrap small { font-size: 13px; color: var(--r-muted); }

/* 抽屜：目錄 */
.scrim { position: absolute; inset: 0; background: rgba(20,18,15,0.45); z-index: 20; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100%; z-index: 21; background: var(--r-panel); color: var(--r-fg); border-left: 1px solid var(--r-rule); display: flex; flex-direction: column; box-shadow: -18px 0 40px -12px rgba(0,0,0,0.4); }
.drawer-head { padding: 12px 12px 12px 20px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--r-rule); padding-top: calc(12px + env(safe-area-inset-top)); }
.drawer-head img { width: 44px; aspect-ratio: 0.7059; height: auto; object-fit: cover; box-shadow: 0 6px 12px -6px rgba(0,0,0,0.5); }
.drawer-head .dh { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.drawer-head .dh b { font-family: var(--serif); font-weight: 900; font-size: 18px; letter-spacing: 0.06em; }
.dh-prog { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--r-muted); font-variant-numeric: tabular-nums; }
.dh-prog .bar { flex-grow: 1; height: 3px; background: var(--r-rule); }
.drawer-body { flex-grow: 1; overflow-y: auto; padding: 0 20px 24px; overscroll-behavior: contain; }
.drawer-body h3 { margin: 18px 0 2px; font-size: 12px; font-weight: 700; letter-spacing: 0.24em; color: var(--r-muted); }
.d-row { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--r-rule); background: transparent; text-align: left; cursor: pointer; padding: 0 4px; }
.d-row:hover { background: var(--r-hover); }
.d-row .n { width: 58px; flex-shrink: 0; font-size: 12px; color: var(--r-muted); }
.d-row .t { flex-grow: 1; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.d-row .s { font-size: 12px; display: flex; align-items: center; gap: 5px; color: var(--r-accent); white-space: nowrap; }
.d-row .p { width: 32px; flex-shrink: 0; text-align: right; font-size: 13px; color: var(--r-muted); font-variant-numeric: tabular-nums; }
.d-row.done .t { color: var(--r-muted); }
.d-row svg { width: 15px; height: 15px; fill: none; stroke: var(--r-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 原版（頁面圖） ---------- */
.reader.pdf {
  --r-bg: #23211D; --r-bar: #1A1815; --r-fg: #EDE7DB; --r-muted: #A39B8C; --r-rule: #3A362F;
  --r-chip: #2A2722; --r-chip-on: #F3EFE6; --r-chip-on-fg: #1C1A17; --r-hover: #2E2B26; --r-turn: rgba(255,255,255,0.05);
  --r-panel: #211F1B; --r-accent: #D2584E;
  background: var(--r-bg); color: var(--r-fg);
}
.reader .rbar { background: var(--r-bar); color: var(--r-fg); }
.reader .rbar.top { border-bottom: 1px solid var(--r-bar-rule, var(--r-rule)); }
.reader .rbar.bottom { border-top: 1px solid var(--r-bar-rule, var(--r-rule)); }
.pdf-stage { flex-grow: 1; min-height: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: relative; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.pdf-stage.zoomed { overflow: auto; justify-content: flex-start; align-items: flex-start; touch-action: auto; }
.spread-wrap { flex-grow: 1; min-width: 0; height: 100%; display: flex; }
.spread-wrap .spread { margin: auto; }  /* 放大超出時 auto 邊距歸零，左上角捲得到 */
.pdf-stage.zoomed .spread-wrap { height: auto; min-height: 100%; padding: 24px; }
.spread { position: relative; display: flex; flex-direction: row-reverse; box-shadow: 0 30px 70px -20px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.4); background: #fff; }
.spread img { background: #fff; -webkit-user-drag: none; user-select: none; }
.spread.two::after { content: ''; position: absolute; top: 0; bottom: 0; left: calc(50% - 30px); width: 60px; pointer-events: none;
  background: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.10) 46%, rgba(0,0,0,0.16) 50%, rgba(0,0,0,0.10) 54%, rgba(0,0,0,0) 100%); }
.pg-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #6E675C; font-size: 14px; }

.pdf-foot { height: 76px; display: flex; align-items: center; gap: 32px; padding: 0 32px; padding-bottom: env(safe-area-inset-bottom); height: calc(76px + env(safe-area-inset-bottom)); }
.pf-l, .pf-r { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; }
.pf-r { align-items: flex-end; }
.pf-l b, .pf-r b { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pf-l b span { color: var(--r-muted); font-weight: 400; }
.pf-l small, .pf-r small { font-size: 12px; color: var(--r-muted); }

.slider { flex-grow: 1; position: relative; height: 44px; }
.slider .track { position: absolute; left: 0; right: 0; top: 20px; height: 4px; border-radius: 2px; background: var(--r-rule); }
.slider .fill { position: absolute; right: 0; top: 20px; height: 4px; border-radius: 2px; background: var(--r-accent); }
.slider .tick { position: absolute; top: 18px; width: 2px; height: 8px; margin-right: -1px; background: #5E584E; }
.slider .tick.part { top: 15px; height: 14px; background: #8C8474; }
.slider .tick.passed { background: var(--r-bar); }
.slider .thumb { position: absolute; top: 14px; width: 16px; height: 16px; margin-right: -8px; border-radius: 8px; background: #F3EFE6; border: 3px solid var(--r-accent); pointer-events: none; }
.slider .bubble { position: absolute; bottom: 38px; transform: translateX(50%); white-space: nowrap; font-size: 12px; padding: 4px 8px; border-radius: 4px; background: var(--r-chip); color: var(--r-fg); pointer-events: none; }
.slider input { position: absolute; inset: 0; width: 100%; height: 44px; margin: 0; opacity: 0; cursor: pointer; }
.slider input:focus-visible + .focus-ring { outline: 2px solid var(--r-accent); }

@media (max-width: 760px) {
  .rbar { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 4px; }
  .rbar .r-sep, .rbar .r-hide-m { display: none !important; }
  .r-back span { display: none; }
  .r-back { padding: 0 8px; }
  .r-title { flex-direction: column; gap: 1px; align-items: flex-start; }
  .r-title span { font-size: 12px; }
  .r-mid { display: none; }
  .mode-pill { height: 36px; padding: 0 12px; margin: 0 2px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--r-rule); border-radius: 18px; font-size: 13px; text-decoration: none; white-space: nowrap; }
  .pdf-stage { padding: 0; }
  .turn-wrap { display: none; }
  .pdf-foot { gap: 0; padding: 10px 20px; height: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)); flex-direction: column-reverse; align-items: stretch; }
  .pf-l, .pf-r { width: auto; }
  .pf-l { flex-direction: row; justify-content: space-between; }
  .pf-l small, .pf-r { display: none; }
  .pf-l .pct-m { display: inline; }
  .slider { height: 32px; }
  .slider .track, .slider .fill { top: 14px; }
  .slider .tick { top: 12px; } .slider .tick.part { top: 9px; }
  .slider .thumb { top: 8px; }
  .slider input { height: 32px; }
  /* 手機：工具列浮在內容上，顯示／隱藏不改變版面（直排不必重新分頁） */
  .reader .rbar { position: absolute; left: 0; right: 0; }
  .reader .rbar.top { top: 0; }
  .reader .rbar.bottom { bottom: 0; }
  .reader.bars-hidden .rbar.top { transform: translateY(-100%); opacity: 0; pointer-events: none; }
  .reader.bars-hidden .rbar.bottom { transform: translateY(100%); opacity: 0; pointer-events: none; }
  .drawer { top: auto; height: 90%; width: 100%; border-left: 0; border-radius: 18px 18px 0 0; }
  .drawer-head { padding-top: 12px; }
  .coach { position: absolute; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; height: 36px; padding: 0 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap;
    background: rgba(26,24,21,0.88); color: #EDE7DB; border: 1px solid #3F3B34; border-radius: 18px; font-size: 13px; }
  .coach svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
}
@media (min-width: 761px) { .mode-pill, .pct-m, .coach { display: none !important; } }

/* ---------- 文字版 ---------- */
.reader.txt {
  --r-bg: #FBF9F4; --r-fg: #1C1A17; --r-muted: #6E675C; --r-bar: #F3EFE6; --r-rule: #DCD5C7; --r-panel: #FFFFFF;
  --r-accent: #A3302A; --r-chip: #ECE6D9; --r-chip-on: #1C1A17; --r-chip-on-fg: #FBF9F4; --r-hover: #ECE6D9; --r-turn: transparent;
  background: var(--r-bg); color: var(--r-fg);
}
.reader.txt[data-rt="sepia"] {
  --r-bg: #F1E7D0; --r-fg: #2E2619; --r-muted: #66583F; --r-bar: #E8DCC0; --r-rule: #D3C4A2; --r-panel: #F8F0DC;
  --r-accent: #9A2E26; --r-chip: #E3D4B2; --r-chip-on: #2E2619; --r-chip-on-fg: #F8F0DC; --r-hover: #E3D4B2;
}
.reader.txt[data-rt="night"] {
  --r-bg: #1A1815; --r-fg: #D9D2C4; --r-muted: #9C9485; --r-bar: #141210; --r-rule: #33302A; --r-panel: #211F1B;
  --r-accent: #E0776D; --r-chip: #2E2B26; --r-chip-on: #D9D2C4; --r-chip-on-fg: #1A1815; --r-hover: #2E2B26;
}
.txt-body { flex-grow: 1; min-height: 0; display: flex; }
.txt-main { flex-grow: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: relative; }
.txt-main.h { padding: 0; }

.page-view { position: relative; flex-grow: 1; min-width: 0; height: 100%; overflow: hidden; margin: 0 12px; }
.page-clip { position: absolute; inset: 40px 0 40px 0; overflow: hidden; }
.v-article { position: absolute; top: 0; right: 0; height: 100%; writing-mode: vertical-rl; -webkit-writing-mode: vertical-rl; will-change: transform; }
.scroll-view { flex-grow: 1; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.h-article { max-width: 34em; margin: 0 auto; padding: 56px 24px 40px; }

.art { font-family: var(--r-font, var(--serif)); font-size: var(--r-size, 20px); line-height: var(--r-lh, 2); text-align: justify; color: var(--r-fg);
  font-kerning: normal; hanging-punctuation: allow-end; }
.art p { margin: 0; text-indent: 2em; }
.h-article.art p { margin-bottom: 0.55em; }
.art .ch-head { margin-block-end: 1.4em; }
.art .ch-part { margin: 0; text-indent: 0; font-size: 0.72em; letter-spacing: 0.4em; color: var(--r-muted); margin-block-end: 0.8em; }
.art .ch-num { margin: 0; text-indent: 0; font-size: 0.75em; letter-spacing: 0.3em; color: var(--r-muted); }
.art .ch-title { margin: 0; margin-block-start: 0.3em; font-size: 1.9em; font-weight: 900; line-height: 1.4; letter-spacing: 0.12em; }
.art .sec { margin: 0; margin-block: 0.4em 0.8em; font-size: 1em; font-weight: 600; text-indent: 0; }
.art .grp { margin: 0; margin-block: 1em 0.3em; font-size: 0.85em; font-weight: 700; letter-spacing: 0.2em; color: var(--r-muted); }
.art .sep { text-indent: 0; text-align: center; letter-spacing: 0.6em; color: var(--r-muted); margin-block: 0.6em; }
.art blockquote { margin: 0; margin-block: 0.5em; margin-inline-start: 2em; font-size: 0.9em; }
.art blockquote p { text-indent: 0; }
.h-article.art blockquote p { margin-bottom: 0.3em; }
.art blockquote.epigraph { margin-inline-start: 1em; color: var(--r-muted); margin-block-end: 1.6em; }
.art blockquote.epigraph p:last-child:not(:first-child) { text-align: end; font-size: 0.9em; margin-block-start: 0.4em; }
.art .gap { white-space: pre; }
.v-article .tcy { text-combine-upright: all; -webkit-text-combine: horizontal; }
.art strong { font-weight: 700; }
.v-article.art .sec { margin-block: 0.5em 0.5em; }

.chap-nav { margin: 40px 0 8px; padding-top: 24px; border-top: 1px solid var(--r-rule); display: flex; justify-content: space-between; gap: 12px; font-family: var(--sans); }
.chap-nav button { min-height: 52px; padding: 8px 16px; border: 1px solid var(--r-rule); border-radius: 8px; background: transparent; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.chap-nav button small { font-size: 12px; color: var(--r-muted); }
.chap-nav button.next { margin-left: auto; text-align: right; background: var(--r-chip); }

.txt-foot { height: 60px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; padding: 0 32px; font-size: 13px; color: var(--r-muted); height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.tf-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tf-mid b { color: var(--r-fg); font-weight: 400; font-variant-numeric: tabular-nums; }
.mini { width: 200px; height: 3px; border-radius: 2px; background: var(--r-rule); display: flex; overflow: hidden; }
.mini.rtl { justify-content: flex-end; }
.mini i { display: block; height: 3px; background: var(--r-accent); }
.tf-r { text-align: right; font-variant-numeric: tabular-nums; }

/* 設定面板 */
.settings { width: 360px; flex-shrink: 0; padding: 24px 28px; background: var(--r-panel); border-left: 1px solid var(--r-rule); display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.set-head { display: flex; align-items: center; justify-content: space-between; }
.set-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.set-head .done { display: none; }
.set-row { display: flex; flex-direction: column; gap: 10px; }
.set-row > span { font-size: 13px; color: var(--r-muted); }
.set-seg { display: grid; gap: 2px; padding: 3px; background: var(--r-chip); border-radius: 8px; }
.set-seg button { height: 40px; border: 0; border-radius: 6px; background: transparent; font-size: 15px; cursor: pointer; }
.set-seg button[aria-pressed="true"] { background: var(--r-chip-on); color: var(--r-chip-on-fg); }
.size-row { display: flex; align-items: center; gap: 8px; }
.size-row button { width: 52px; height: 44px; border: 1px solid var(--r-rule); border-radius: 8px; background: transparent; font-family: var(--serif); cursor: pointer; }
.size-row button:disabled { opacity: 0.35; cursor: default; }
.size-row .val { flex-grow: 1; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.size-row .val b { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.size-row .val small { font-size: 12px; color: var(--r-muted); }
.swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.swatches button { height: 76px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 0; font-size: 13px; color: var(--r-muted); }
.swatches button[aria-pressed="true"] { color: var(--r-fg); }
.swatches i { width: 38px; height: 38px; border-radius: 19px; box-shadow: inset 0 0 0 1px var(--sw-edge); background: var(--sw); }
.swatches button[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--r-panel), 0 0 0 4px var(--r-accent); }
.set-note { margin: auto 0 0; font-size: 12px; line-height: 1.7; color: var(--r-muted); }

@media (max-width: 760px) {
  .txt-main { padding: 0; }
  .page-view { margin: 0 18px; }
  .page-clip { inset: 44px 0 44px 0; }
  .txt-foot { display: none; }
  .m-status { position: absolute; left: 0; right: 0; display: flex; justify-content: center; font-size: 12px; color: var(--r-muted); letter-spacing: 0.06em; pointer-events: none; z-index: 1; }
  .m-status.top { top: calc(14px + env(safe-area-inset-top)); }
  .m-status.bot { bottom: calc(14px + env(safe-area-inset-bottom)); justify-content: space-between; padding: 0 22px; font-variant-numeric: tabular-nums; }
  .reader.txt:not(.bars-hidden) .m-status { opacity: 0; }
  .h-article { padding: 64px 22px 40px; }
  .settings { position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 80%; z-index: 22; padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); border-left: 0; border-top: 1px solid var(--r-rule); border-radius: 18px 18px 0 0; box-shadow: 0 -18px 40px -12px rgba(0,0,0,0.45); gap: 10px; }
  .settings::before { content: ''; align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--r-rule); margin: 2px 0 4px; flex-shrink: 0; }
  .set-head h2 { font-size: 16px; }
  .set-head .close { display: none; }
  .set-head .done { display: block; height: 44px; margin-right: -8px; padding: 0 8px; border: 0; background: transparent; color: var(--r-accent); font-size: 15px; font-weight: 500; cursor: pointer; }
  .set-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; }
  .set-row > span { font-size: 14px; }
  .set-row > .set-seg, .set-row > .size-row, .set-row > .swatches { width: 224px; flex-shrink: 0; }
  .set-seg button { height: 38px; }
  .swatches button { height: 72px; font-size: 12px; }
  .swatches i { width: 36px; height: 36px; }
  .set-note { display: none; }
}
@media (min-width: 761px) { .m-status { display: none; } }

/* 載入、錯誤 */
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink3); font-size: 15px; }
.err { max-width: 520px; margin: 120px auto; padding: 0 24px; line-height: 1.9; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
