:root {
  --bg: #faf7f2; --surface: #ffffff; --ink: #23201c; --muted: #6f6a61;
  --accent: #c2410c; --accent-soft: #ffedd5; --line: #e7e0d4; --badge: #15803d;
}
body[data-theme="sepia"] { --bg: #f3e9d2; --surface: #fbf3dd; --ink: #3d3225; --muted: #7a6a52; --line: #e0d0a8; --accent-soft: #fde9c8; }
body[data-theme="dark"] { --bg: #17181c; --surface: #1f2126; --ink: #e8e6e1; --muted: #a3a09a; --line: #33363d; --accent: #fb923c; --accent-soft: #3a2a1a; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.site-header { position: sticky; top: 0; z-index: 40; display: flex; gap: 16px; align-items: center; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { font-size: 22px; font-weight: 800; color: var(--ink); }
.logo span { color: var(--accent); }
.search-box { flex: 1; max-width: 420px; }
.search-box input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 14px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { color: #fff; opacity: .92; }
.page { max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; }
.hero { display: flex; gap: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 28px; }
.cover { flex: 0 0 150px; width: 150px; height: 210px; border-radius: 10px; position: relative; overflow: hidden; color: #fff; }
.cover svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover img.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover:has(> img.cover-img)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48%; background: linear-gradient(transparent, rgba(0,0,0,.5)); pointer-events: none; }
.cover:has(> img.cover-img) .cover-title { z-index: 1; }
.cover .cover-title { position: absolute; left: 10px; right: 10px; bottom: 12px; font-weight: 700; font-size: 15px; line-height: 1.35; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.cover-small { flex-basis: 96px; width: 96px; height: 134px; }
.score-badge { display: inline-block; background: var(--badge); color: #fff; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.score-badge.pending { background: #b45309; }
.meta { color: var(--muted); font-size: 14px; line-height: 1.7; }
.rail { margin-bottom: 30px; }
.rail h2 { font-size: 19px; margin: 0 0 14px; }
.card-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.book-card { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.book-card h3 { margin: 0 0 4px; font-size: 16px; }
.update-list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.update-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.update-row:last-child { border-bottom: none; }
.toolbar { position: sticky; top: 57px; z-index: 30; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 18px; }
.toolbar .group { display: flex; gap: 4px; align-items: center; }
.toolbar button { padding: 6px 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 7px; cursor: pointer; font-size: 13px; }
.toolbar button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#readProgressWrap { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; }
#readProgress { height: 100%; width: 0; background: var(--accent); }
.reader-wrap { max-width: 720px; margin: 0 auto; }
.chapter-body { font-size: var(--reader-size, 19px); line-height: 1.85; }
.chapter-body p { margin: 0 0 1.1em; text-align: justify; }
.illus-frame { margin: 26px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.illus-frame .illus-art { aspect-ratio: 16 / 9; display: block; width: 100%; }
.illus-frame figcaption { padding: 10px 14px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.illus-frame figcaption strong { color: var(--ink); display: block; font-size: 13px; }
body.images-off .illus-frame { display: none; }
.audio-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; }
.audio-box audio { width: 100%; }
.end-block { margin-top: 34px; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: center; }
.chapter-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.toc-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.toc-controls input { width: 130px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.toc-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.toc-list li { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.toc-list li:last-child { border-bottom: none; }
.toc-list li.highlight { background: var(--accent-soft); }
.toc-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 20px 30px; margin-top: 30px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; max-width: 1080px; margin: 0 auto; font-size: 14px; }
.site-footer p { max-width: 1080px; margin: 12px auto 0; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) {
  .hero { flex-direction: column; }
  .site-header { flex-wrap: wrap; }
  .toolbar { position: static; }
  .chapter-body { font-size: var(--reader-size, 18px); }
}

/* --- Production additions (UI rework 2026-10-24): components rendered by
   the SSR templates in functions/ that the prototype only had inline. --- */
::selection { background: var(--accent-soft); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tagline { color: var(--muted); font-size: 13px; white-space: nowrap; }
.header-nav { display: flex; gap: 14px; align-items: center; margin-left: auto; font-size: 14px; }
.header-nav a { color: var(--ink); font-weight: 600; }
.header-nav a.locale-switch { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.hero-info { flex: 1; min-width: 0; }
.hero-info h1 { margin: 8px 0 6px; font-size: 30px; line-height: 1.2; }
.eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.cover-small .cover-title { font-size: 12px; left: 8px; right: 8px; bottom: 8px; }
.book-card-info { min-width: 0; }
.book-card h3 a { color: var(--ink); }
.book-card h3 a:hover { color: var(--accent); }
.update-row a { font-weight: 600; }
.gate-box { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.gate-box p { margin: 8px 0 0; font-size: 14px; }
.breadcrumb { margin: 0 0 12px; }
.chapter-title { font-size: 25px; line-height: 1.3; margin: 4px 0 16px; }
.toc-status { font-size: 12px; white-space: nowrap; border-radius: 999px; padding: 2px 9px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.toc-status.st-ready { color: var(--badge); border-color: var(--badge); font-weight: 600; }
.toc-status.st-translating, .toc-status.st-partial { color: #b45309; border-color: #b45309; }
.toc-status.st-failed { color: #b91c1c; border-color: #b91c1c; }
.toc-list li a { flex: 1; min-width: 0; }
.jump-form { display: flex; gap: 8px; align-items: center; }
.jump-form input { width: 110px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }
.btn-disabled { opacity: .45; cursor: default; }
.btn-disabled:hover { border-color: var(--line); }
.prep-state { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 22px; text-align: center; margin-bottom: 18px; }
.prep-state .prep-line { color: var(--muted); }
.spinner { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: comictq-spin 0.9s linear infinite; }
@keyframes comictq-spin { to { transform: rotate(360deg); } }
.prep-line { color: var(--muted); font-size: 14px; }
.empty-state { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 40px 24px; text-align: center; }
.empty-state h1 { margin: 0 0 8px; font-size: 34px; }
.illus-frame img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.illus-pending-art { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--accent-soft), var(--line)); }
.audio-box audio { margin-top: 8px; }
.end-block p { margin: 10px 0 0; font-size: 14px; }
.chapter-nav { flex-wrap: wrap; }
.chapter-nav .btn { flex: 1; text-align: center; }
@media (max-width: 640px) {
  .tagline { display: none; }
  .search-box { order: 3; flex-basis: 100%; max-width: none; }
  .hero-info h1 { font-size: 24px; }
  .chapter-title { font-size: 21px; }
  .chapter-nav .btn { flex-basis: 100%; }
}
