:root {
  color-scheme: light dark;
  --bg: #f7f3eb;
  --surface: #fffdf8;
  --surface-2: #f1eadf;
  --text: #26221d;
  --muted: #746b61;
  --line: #ded5c8;
  --accent: #9f3d24;
  --accent-soft: #f4ddd3;
  --shadow: 0 14px 38px rgba(75, 57, 38, .09);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --surface: #211e1a;
    --surface-2: #2a251f;
    --text: #f3ede4;
    --muted: #b4aa9e;
    --line: #403930;
    --accent: #ee8a68;
    --accent-soft: #4a2b22;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  line-height: 1.7;
}
a { color: var(--accent); }
button, input, select { font: inherit; }

.library-shell, .reader-shell {
  width: min(100% - 32px, 940px);
  margin: 0 auto;
  padding: 42px 0 72px;
}
.library-header { padding: 20px 0 30px; }
.eyebrow, .book-id {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(32px, 6vw, 54px); line-height: 1.15; }
.lead { max-width: 620px; margin: 12px 0 0; color: var(--muted); }
.site-vitality { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 11px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.site-vitality strong { color: var(--text); }
.live-status { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 700; }
.live-status i, .activity-label i { width: 8px; height: 8px; border-radius: 50%; background: #31a461; box-shadow: 0 0 0 0 rgba(49,164,97,.35); animation: live-pulse 2.2s infinite; }
@keyframes live-pulse { 55% { box-shadow: 0 0 0 7px rgba(49,164,97,0); } }
.continue-reading {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px;
  margin-bottom: 18px; padding: 22px 24px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 18px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); box-shadow: var(--shadow);
}
#continue-cover-slot, #book-cover { display: block; line-height: normal; }
#continue-cover-slot[hidden], #book-cover[hidden] { display: none; }
.continue-cover { width: 68px; aspect-ratio: 2 / 3; object-fit: contain; background: var(--surface-2); border-radius: 7px; box-shadow: 0 5px 16px #0003; }
.continue-reading h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 25px; }
.continue-reading #continue-book { margin: 8px 0 0; font-weight: 750; }
.continue-chapter { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.primary-action, .card-action {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 15px;
  border-radius: 999px; background: var(--accent); color: white; font-weight: 750; text-decoration: none; white-space: nowrap;
}
.discovery-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 26px; }
.discovery-actions a, .discovery-actions button {
  min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); color: var(--text); font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
}
.discovery-actions a:hover, .discovery-actions button:hover { border-color: var(--accent); color: var(--accent); }
.activity-strip { display: flex; align-items: center; gap: 14px; min-height: 48px; margin-bottom: 26px; padding: 10px 16px; overflow: hidden; border: 1px solid color-mix(in srgb, #31a461 35%, var(--line)); border-radius: 13px; background: color-mix(in srgb, #31a461 7%, var(--surface)); font-size: 13px; }
.activity-label { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; color: #27834e; font-weight: 800; }
#activity-message { overflow: hidden; opacity: 1; text-overflow: ellipsis; white-space: nowrap; transition: opacity .18s ease; }
#activity-message.changing { opacity: 0; }
.shelf-section { margin: 28px 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 25px; line-height: 1.25; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
.book-shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(132px, 158px); gap: 12px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x proximity; }
.shelf-card { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: inherit; text-decoration: none; scroll-snap-align: start; box-shadow: var(--shadow); }
.shelf-cover { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: contain; background: var(--surface-2); }
.shelf-copy { display: grid; gap: 4px; padding: 10px; }
.shelf-copy strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; min-height: 2.8em; font-size: 14px; line-height: 1.4; }
.shelf-copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.shelf-empty { margin: 0; padding: 22px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.popularity-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.popularity-item { display: grid; grid-template-columns: 34px 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 68px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.popularity-item:hover { border-color: var(--accent); }
.popularity-rank { color: var(--accent); font-family: Georgia, serif; font-size: 20px; font-weight: 800; }
.popularity-cover { width: 42px; aspect-ratio: 2 / 3; object-fit: contain; overflow: hidden; border-radius: 5px; background: var(--surface-2); }
.popularity-cover.generated-cover { padding: 4px; font-size: 6px; }
.popularity-cover.generated-cover::before { inset: 3px; }
.popularity-cover.generated-cover .generated-cover-kicker,
.popularity-cover.generated-cover .generated-cover-author { display: none; }
.popularity-copy { display: grid; min-width: 0; }
.popularity-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.popularity-copy small { color: var(--muted); font-size: 11px; }
.popularity-score { padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; white-space: nowrap; }
.update-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.update-item { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 11px; min-height: 66px; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: inherit; text-decoration: none; }
.update-cover { width: 42px; aspect-ratio: 2 / 3; object-fit: contain; background: var(--surface-2); border-radius: 5px; }
.update-copy { display: grid; min-width: 0; }
.update-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.update-copy small { color: var(--muted); font-size: 12px; }

.toolbar, .chapter-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search-box { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.search-box input, select {
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.filter-bar { display: flex; gap: 8px; overflow-x: auto; margin-top: 14px; padding-bottom: 2px; }
.chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.chip.active { border-color: var(--accent); background: var(--accent); color: white; }
.chip-count { margin-left: 6px; opacity: .7; font-size: 12px; }
.result-count { margin: 24px 0 12px; color: var(--muted); font-size: 14px; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.book-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .16s ease, border-color .16s ease;
}
.book-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.book-cover-link { display: block; aspect-ratio: 2 / 3; overflow: hidden; background: var(--surface-2); color: inherit; text-decoration: none; }
.book-cover { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--surface-2); }
.generated-cover {
  position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden; padding: 10%; border: 1px solid hsl(var(--cover-hue) 28% 35% / .2);
  background:
    radial-gradient(circle at 82% 14%, hsl(var(--cover-hue-2) 62% 85% / .8) 0 13%, transparent 14%),
    linear-gradient(145deg, hsl(var(--cover-hue) 42% 90%), hsl(var(--cover-hue-2) 40% 72%));
  color: hsl(var(--cover-hue) 34% 18%); font-family: Georgia, "Noto Serif TC", serif;
}
.generated-cover::before {
  position: absolute; z-index: -1; inset: 6%; border: 1px solid currentColor; border-radius: 3px;
  content: ''; opacity: .25;
}
.generated-cover::after {
  position: absolute; z-index: -1; right: -28%; bottom: -12%; width: 90%; aspect-ratio: 1;
  border: 1px solid currentColor; border-radius: 50%; content: ''; opacity: .14;
}
.generated-cover-kicker { overflow: hidden; font-family: system-ui, "Noto Sans TC", sans-serif; font-size: .46em; font-weight: 800; letter-spacing: .12em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.generated-cover-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; font-size: 1em; line-height: 1.38; letter-spacing: .04em; }
.generated-cover-author { overflow: hidden; font-family: system-ui, "Noto Sans TC", sans-serif; font-size: .45em; opacity: .7; text-overflow: ellipsis; white-space: nowrap; }
.generated-cover-seal { position: absolute; right: 9%; bottom: 9%; display: grid; width: 1.7em; aspect-ratio: 1; place-items: center; border-radius: 3px; background: hsl(var(--cover-hue) 48% 34%); color: white; font-size: .55em; font-weight: 800; }
.book-cover.generated-cover { font-size: clamp(17px, 2.1vw, 25px); }
.shelf-cover.generated-cover { font-size: 17px; }
.continue-cover.generated-cover { font-size: 9px; }
.update-cover.generated-cover { padding: 5px; font-size: 6px; }
.update-cover.generated-cover::before { inset: 3px; }
.update-cover.generated-cover .generated-cover-kicker,
.update-cover.generated-cover .generated-cover-author { display: none; }
.book-detail-cover.generated-cover { font-size: 15px; }
.book-card-body { display: flex; flex-direction: column; min-height: 210px; padding: 16px; }
.book-title-link { color: inherit; text-decoration: none; }
.book-title { margin: 0 0 8px; font-family: Georgia, "Noto Serif TC", serif; font-size: 18px; line-height: 1.45; }
.book-author, .chapter-state { margin: 0; color: var(--muted); font-size: 14px; }
.book-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.book-stats .stat-popularity { color: var(--accent); font-weight: 750; }
.card-action { align-self: flex-start; min-height: 38px; margin-top: auto; padding: 7px 13px; font-size: 13px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag { padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.empty, .pending { padding: 30px; border: 1px dashed var(--line); border-radius: 14px; text-align: center; color: var(--muted); }
.stats-disabled { margin: 28px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; }
.stats-disabled button { margin-left: 8px; border: 0; background: transparent; color: var(--accent); cursor: pointer; text-decoration: underline; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; margin: 28px 0 8px; }
.pagination button, .pagination a { min-width: 40px; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; }
.pagination button:hover, .pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active, .pagination [aria-current="page"] { border-color: var(--accent); background: var(--accent); color: white; }
.pagination > span { padding: 0 3px; color: var(--muted); }
.seo-pagination { margin-top: 32px; }

.reader-shell { width: min(100% - 32px, 1040px); }
.top-nav {
  position: sticky; top: 0; z-index: 12; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 14px; min-height: 58px; margin-bottom: 26px; padding: 8px 2px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  transition: transform .22s ease, opacity .22s ease;
}
.top-nav a { text-decoration: none; }
.compact-title { overflow: hidden; color: var(--muted); font-size: 13px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.nav-action { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; }
.book-header { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 24px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.book-detail-cover { width: 120px; aspect-ratio: 2 / 3; object-fit: contain; background: var(--surface-2); border-radius: 10px; box-shadow: 0 8px 24px #0003; }
.book-header h1 { font-size: clamp(28px, 5vw, 44px); }
.book-header .book-author { margin-top: 12px; }
.book-secondary-link { display: inline-block; margin-top: 12px; color: var(--muted); font-size: 13px; text-decoration: none; }
.description-wrap { margin-top: 18px; color: var(--muted); }
.description-wrap summary { color: var(--accent); cursor: pointer; }
.description-wrap p { white-space: pre-wrap; }
.chapter-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 14px; margin: 26px 0; }
.chapter-state { grid-column: 1 / -1; }
.chapter-pending-option { color: var(--muted); }
.toc-trigger { min-height: 44px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--text); font-weight: 750; cursor: pointer; text-align: left; }

.reader {
  width: min(100%, 760px); margin-inline: auto;
  min-height: 300px;
  padding: clamp(22px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.reader h2 { margin: 0 0 30px; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(23px, 4vw, 32px); line-height: 1.4; }
.chapter-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(18px, 2.2vw, 21px);
  line-height: 2;
  letter-spacing: .025em;
}
.audio-section { margin: 0 0 28px; padding: 16px; border-radius: 14px; background: var(--surface-2); }
.audio-toolbar { display: grid; grid-template-columns: 1fr 110px auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.audio-toolbar label { font-size: 13px; color: var(--muted); }
.check-label { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.audio-section audio { width: 100%; }
.image-section { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); }
.image-section h3 { font-size: 16px; color: var(--muted); }
.image-gallery { display: grid; gap: 18px; }
.image-gallery a { display: block; }
.image-gallery img { display: block; max-width: 100%; width: auto; max-height: 86dvh; height: auto; margin: auto; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.chapter-text.has-blocks { white-space: normal; }
.chapter-text.has-blocks p { margin: 0 0 1em; white-space: pre-wrap; }
.inline-illustration { margin: 1.5em 0; }
.inline-illustration a { display: block; }
.inline-illustration img { display: block; max-width: 100%; width: auto; max-height: 86dvh; height: auto; margin: auto; object-fit: contain; border-radius: 8px; }
.missing-illustration { padding: 20px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.reader-controls { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; width: min(100%, 760px); margin: 22px auto 0; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 7px 25px #0003; backdrop-filter: blur(12px); transition: transform .22s ease, opacity .22s ease; }
.reading-chrome-hidden .top-nav { transform: translateY(-120%); opacity: 0; pointer-events: none; }
.reading-chrome-hidden .reader-controls { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.reader-controls button {
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.reader-controls button:last-child { justify-self: end; }
.reader-controls button:disabled { opacity: .4; cursor: not-allowed; }
.toc-bottom { display: grid; place-items: center; min-width: 68px; padding: 5px 10px !important; color: var(--muted) !important; font-size: 13px; }
.toc-bottom small { font-size: 10px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.toc-open { overflow: hidden; }
.toc-backdrop { position: fixed; inset: 0; z-index: 29; background: #0008; }
.toc-drawer { position: fixed; top: 0; right: 0; z-index: 30; width: min(520px, 100vw); height: 100dvh; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); overflow-y: auto; background: var(--surface); color: var(--text); box-shadow: -16px 0 50px #0005; transform: translateX(100%); transition: transform .18s ease; }
.toc-drawer.open { transform: translateX(0); }
.toc-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toc-heading-row h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 27px; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 24px; cursor: pointer; }
.toc-search { display: block; margin: 20px 0 14px; }
.toc-search input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--text); }
.toc-volume { border-bottom: 1px solid var(--line); }
.toc-volume summary { display: flex; justify-content: space-between; gap: 12px; padding: 15px 4px; font-weight: 750; cursor: pointer; }
.toc-volume summary small { flex: 0 0 auto; color: var(--muted); font-weight: 400; }
.toc-chapters { display: grid; gap: 4px; padding: 0 0 12px 10px; }
.toc-chapter { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.toc-chapter:hover { background: var(--surface-2); }
.toc-chapter.current { background: var(--accent-soft); color: var(--accent); font-weight: 750; }
.toc-chapter small { padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.toc-empty { padding: 28px; color: var(--muted); text-align: center; }

@media (max-width: 680px) {
  .library-shell, .reader-shell { width: min(100% - 24px, 940px); padding-top: 24px; }
  .library-header { padding-top: 4px; }
  .continue-reading { grid-template-columns: 54px minmax(0, 1fr); gap: 10px 14px; padding: 16px; }
  .continue-cover { grid-row: 1 / span 2; width: 54px; }
  .continue-reading .primary-action { grid-column: 2; justify-self: start; min-height: 38px; padding-block: 6px; }
  .continue-reading h2 { font-size: 21px; }
  .continue-copy .eyebrow { display: none; }
  .continue-reading #continue-book { margin-top: 2px; font-size: 14px; }
  .discovery-actions { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 22px; }
  .discovery-actions a, .discovery-actions button { min-height: 42px; padding: 7px 9px; font-size: 13px; }
  .site-vitality { margin-top: 14px; font-size: 12px; }
  .activity-strip { align-items: flex-start; flex-direction: column; gap: 2px; padding: 10px 12px; }
  #activity-message { width: 100%; }
  .shelf-section { margin: 24px 0; }
  .section-heading h2 { font-size: 21px; }
  .section-heading > p { max-width: 48%; font-size: 11px; }
  .book-shelf { grid-auto-columns: 118px; gap: 9px; margin-right: -12px; padding-right: 12px; }
  .shelf-copy { padding: 8px; }
  .shelf-copy strong { font-size: 13px; }
  .update-list { grid-template-columns: 1fr; }
  .popularity-list { grid-template-columns: 1fr; }
  .popularity-item { grid-template-columns: 30px 38px minmax(0, 1fr) auto; min-height: 62px; padding: 8px 10px; }
  .popularity-cover { width: 38px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pagination { gap: 5px; }
  .pagination button, .pagination a { min-width: 36px; min-height: 38px; padding: 7px 9px; }
  .book-card-body { min-height: 190px; padding: 12px; }
  .book-title { font-size: 15px; }
  .book-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
  .book-author { font-size: 12px; }
  .book-stats { gap: 4px 8px; margin-top: 9px; }
  .book-stats .stat-detail { display: none; }
  .card-action { padding-inline: 10px; }
  .book-header { grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; }
  .book-detail-cover { width: 76px; }
  .book-header h1 { font-size: 24px; }
  .book-header .book-author { font-size: 12px; }
  .book-header .tag-row, .book-header .description-wrap { display: none; }
  .audio-toolbar { grid-template-columns: 1fr 100px; }
  .check-label { grid-column: 1 / -1; min-height: auto; }
  .reader { padding: 24px 18px; border-radius: 12px; }
  .reader h2 { margin-bottom: 22px; font-size: 23px; }
  .reader-controls { gap: 6px; bottom: max(6px, env(safe-area-inset-bottom)); }
  .reader-controls button { padding-inline: 10px; }
  .toc-drawer { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-status i, .activity-label i { animation: none; }
  #activity-message { transition: none; }
}

/* Explicit reader themes override system colors only on the reading page. */
:root[data-reader-theme="warm"] {
  color-scheme: dark;
  --bg: #181714; --surface: #181714; --surface-2: #24221d;
  --text: #e6dcc8; --muted: #b8ad98; --line: #494338;
  --accent: #e2b780; --accent-soft: #352b20; --shadow: none;
}
:root[data-reader-theme="parchment"] {
  color-scheme: light;
  --bg: #eee2ca; --surface: #f3e8d2; --surface-2: #e9dcc0;
  --text: #443b30; --muted: #6d604d; --line: #cbbd9f;
  --accent: #864527; --accent-soft: #e8d6b7; --shadow: none;
}
:root[data-reader-theme="paper"] {
  color-scheme: light;
  --bg: #f1f0eb; --surface: #faf9f5; --surface-2: #eeede7;
  --text: #303030; --muted: #65645e; --line: #d5d3c9;
  --accent: #805035; --accent-soft: #eee2d7; --shadow: none;
}
[data-reader-theme] .chapter-panel { grid-template-columns: minmax(0, 1fr) auto; }
.theme-toggle {
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
  white-space: nowrap; min-height: 36px;
}
.floating-theme { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; box-shadow: 0 3px 15px #0003; }
.theme-picker { position: fixed; right: 18px; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 48px); z-index: 21; width: 210px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 5px 24px #0003; }
.theme-picker p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.theme-picker button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.theme-picker button[aria-pressed="true"] { border-color: var(--accent); }
.theme-sample { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; border: 1px solid #8886; font-family: Georgia, serif; }
[data-theme="warm"] .theme-sample { background: #181714; color: #e6dcc8; }
[data-theme="parchment"] .theme-sample { background: #f3e8d2; color: #443b30; }
[data-theme="paper"] .theme-sample { background: #faf9f5; color: #303030; }
.theme-check { margin-left: auto; visibility: hidden; }
[aria-pressed="true"] .theme-check { visibility: visible; }
.theme-toggle:focus-visible, .theme-picker button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
@media (max-width: 680px) {
  [data-reader-theme] .chapter-panel { grid-template-columns: minmax(0, 1fr) auto; }
  .floating-theme, .theme-picker { right: 12px; }
}

@font-face { font-family: 'Reader GenWan'; src: url('/fonts/genwan-m-v1.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Reader Noto Serif'; src: url('/fonts/noto-serif-regular-v1.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Reader Noto Sans'; src: url('/fonts/noto-sans-regular-v1.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Reader WenKai'; src: url('/fonts/wenkai-regular-v1.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
[data-reader-font="genwan"] { --reading-font: 'Reader GenWan', 'Noto Serif TC', serif; --reading-weight: 500; }
[data-reader-font="serif"] { --reading-font: 'Reader Noto Serif', 'Noto Serif TC', serif; --reading-weight: 400; }
[data-reader-font="sans"] { --reading-font: 'Reader Noto Sans', 'Noto Sans TC', system-ui, sans-serif; --reading-weight: 400; }
[data-reader-font="wenkai"] { --reading-font: 'Reader WenKai', 'Noto Serif TC', serif; --reading-weight: 400; }
[data-reader-font] .chapter-text, .font-preview { font-family: var(--reading-font); font-weight: var(--reading-weight); }

/* Crawlable public catalogue and reading pages. */
.seo-shell { padding-bottom: 64px; }
.seo-book-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 20px; }
.seo-book-card { min-width: 0; }
.seo-book-card a { display: grid; gap: 10px; color: var(--text); text-decoration: none; }
.seo-book-card img { width: 100%; height: auto; aspect-ratio: 5/7; object-fit: cover; border-radius: 10px; background: var(--surface-2); box-shadow: var(--shadow); }
.seo-book-card span { display: grid; gap: 4px; }
.seo-book-card strong { line-height: 1.45; }
.seo-book-card small { color: var(--muted); }
.seo-book-header { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 28px; margin: 30px 0 42px; align-items: start; }
.seo-book-header > img { width: 100%; height: auto; border-radius: 12px; box-shadow: var(--shadow); }
.seo-book-header h1 { margin: 4px 0 10px; font-size: clamp(28px,5vw,44px); line-height: 1.25; }
.seo-description { margin-top: 22px; color: var(--muted); line-height: 1.9; white-space: pre-wrap; }
.seo-toc { padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.seo-toc header { margin-bottom: 18px; }
.seo-toc header h2 { margin: 3px 0; }
.seo-toc header p:last-child { color: var(--muted); }
.seo-toc ol { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.seo-toc li { border-bottom: 1px solid var(--line); }
.seo-toc li a { display: flex; justify-content: space-between; gap: 18px; padding: 14px 4px; color: var(--text); text-decoration: none; }
.seo-toc li a > span { display: grid; gap: 3px; }
.seo-toc li small { color: var(--muted); }
.seo-toc li b { flex: 0 0 auto; color: var(--accent); font-size: 13px; }
.seo-reader header { margin-bottom: 26px; }
.seo-reader h1 { margin: 4px 0; font-size: clamp(26px,5vw,38px); line-height: 1.4; }
.seo-reader .chapter-text p { white-space: pre-wrap; }
.seo-chapter-nav { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 10px; margin-top: 18px; }
.seo-chapter-nav a { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; text-align: center; }
.seo-chapter-nav a:last-child { text-align: right; }
.seo-chapter-nav a:first-child { text-align: left; }
.seo-chapter-nav span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 680px) {
  .seo-book-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
  .seo-book-header { grid-template-columns: 90px minmax(0,1fr); gap: 16px; }
  .seo-description { grid-column: 1/-1; }
  .seo-toc { padding: 18px 14px; }
  .seo-chapter-nav a span { display: none; }
}
.theme-picker { width: min(300px, calc(100vw - 24px)); max-height: calc(100dvh - 90px); overflow-y: auto; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-heading #close-reader-settings { width: 36px; height: 36px; justify-content: center; padding: 0; font-size: 22px; }
.font-label { display: block; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 12px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.theme-picker .font-preview { margin: 14px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 20px; line-height: 1.9; }
.theme-picker .font-status { margin: 6px 0 0; font-size: 12px; }
.theme-picker .font-status:empty { display: none; }
