@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&family=Noto+Serif+TC:wght@400;600;700&display=swap");

:root {
  --bg: #0c0e14;
  --bg-elevated: #141824;
  --panel: #1a2030;
  --panel-hover: #222a3d;
  --text: #eceff6;
  --muted: #8f9bb3;
  --accent: #8ec5ff;
  --accent-dim: #5a8fc4;
  --gold: #c7a24a;
  --ok: #72c99a;
  --warn: #e8b86d;
  --danger: #e88;
  --border: #2c3448;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font-serif: "Noto Serif TC", "PingFang TC", "Songti TC", serif;
  --font-sans: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  --font-reading: "Noto Serif TC", "PingFang TC", "Songti TC", serif;
  --sticky-top-bg: rgba(12, 14, 20, 0.94);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse at 12% -5%, #1a2d4f 0%, transparent 48%),
    radial-gradient(ellipse at 98% 2%, #2e1f3d 0%, transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-text strong {
  font-family: var(--font-serif);
  font-weight: 600;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--sticky-top-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.chapter-sticky-top {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--sticky-top-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.chapter-sticky-top .site-header {
  position: static;
  border-bottom: none;
  box-shadow: none;
  backdrop-filter: none;
  background: transparent;
  padding-bottom: 0.35rem;
}

.chapter-sticky-top .chapter-nav {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 0.65rem;
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: 0;
  margin-bottom: 0;
}

.library-sticky-top {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--sticky-top-bg);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.22);
  overflow-x: clip;
}

.library-sticky-top .site-header {
  position: static;
  border-bottom: none;
  box-shadow: none;
  backdrop-filter: none;
  background: transparent;
  padding-bottom: 0.35rem;
}

.library-toolbar {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  width: 100%;
  min-width: 0;
}

.library-sticky-top.is-compact .library-toolbar {
  padding-bottom: 0.4rem;
  gap: 0;
}

.library-sticky-top.is-compact .lib-tb-quick {
  display: none;
}

.lib-tb-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.lib-tb-nav {
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
  padding-top: 0.15rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.library-sticky-top.is-compact .lib-tb-nav {
  padding-top: 0.1rem;
  border-top-color: color-mix(in srgb, var(--border) 45%, transparent);
}

.lib-tb-btn {
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  flex-shrink: 0;
}

.lib-tb-btn:hover:not(:disabled) {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.lib-tb-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.lib-tb-page {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.12rem 0.55rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent-dim) 35%, var(--border));
  background: color-mix(in srgb, var(--bg-elevated) 90%, #1a2a44);
  line-height: 1.15;
}

.lib-tb-page-no {
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lib-tb-page-meta {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.library-sticky-top.is-compact .lib-tb-page-meta {
  display: none;
}

.lib-tb-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
}

.lib-tb-jump input {
  width: 3.4rem;
  font: inherit;
  font-size: 0.78rem;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.22rem 0.35rem;
  line-height: 1.3;
}

.lib-tb-jump input::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  font-size: 0.72rem;
}

.lib-tb-go {
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent-dim) 50%, var(--border));
  background: linear-gradient(135deg, rgba(42, 64, 104, 0.55), rgba(34, 48, 72, 0.55));
  color: var(--accent);
  padding: 0.22rem 0.55rem;
  line-height: 1.3;
  white-space: nowrap;
}

.lib-tb-go:hover {
  border-color: var(--accent-dim);
}

.lib-tb-size {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.lib-tb-size select {
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.2rem 0.35rem;
  min-width: 2.6rem;
}

.library-sticky-top.is-compact .lib-tb-size-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.lib-tb-quick {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.05rem;
}

.lib-tb-quick::-webkit-scrollbar {
  display: none;
}

.lib-tb-quick .pager-quick {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.28rem;
  min-width: min-content;
  padding: 0.05rem 0.1rem 0.1rem;
}

.lib-tb-quick .pager-mark {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

@media (max-width: 640px) {
  .library-sticky-top .lib-tb-nav {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas:
      "prev page next size"
      "jump jump jump jump";
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .library-sticky-top #page-prev { grid-area: prev; }
  .library-sticky-top .lib-tb-page { grid-area: page; justify-self: center; min-width: 0; }
  .library-sticky-top #page-next { grid-area: next; }
  .library-sticky-top .lib-tb-size { grid-area: size; margin-left: 0; justify-self: end; }
  .library-sticky-top .lib-tb-jump {
    grid-area: jump;
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }

  .lib-tb-jump input {
    flex: 1;
    width: auto;
    min-width: 0;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
}

.brand-link:hover { text-decoration: none; }

.brand-logo {
  width: 32px;
  height: 32px;
  max-width: 32px;
  max-height: 32px;
  flex-shrink: 0;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}

.brand-tag, .brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.82rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
}

.site-nav .nav-sep {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  font-size: 0.75rem;
  user-select: none;
  padding: 0 0.05rem;
  line-height: 1;
}

.site-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel);
  text-decoration: none;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem 5rem;
}

h1 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
  max-width: 52ch;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.meta code {
  font-family: ui-monospace, Menlo, monospace;
  color: #b8c7e8;
  font-size: 0.85em;
}

.note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.note[hidden] {
  display: none;
}

.note-warn {
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
  color: color-mix(in srgb, var(--warn) 75%, var(--muted));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok { color: var(--ok); border-color: #3d6a55; }
.badge.warn { color: var(--warn); border-color: #6a5a3d; }
.badge.muted { color: var(--muted); border-color: var(--border); }
.badge.accent { color: var(--accent); border-color: #3d5a6a; }

.shelf-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0.5rem;
}

.filter-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.filter-chip:hover {
  color: var(--text);
  border-color: #4a5f78;
}

.filter-chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(120, 170, 210, 0.12);
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.novel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  color: inherit;
}

.novel-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.novel-card .cover-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.novel-card .cover-link:hover { text-decoration: none; }

.novel-card .cover {
  aspect-ratio: 320 / 440;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}

.novel-card .cover-fallback {
  aspect-ratio: 320 / 440;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a2540, #241a30);
  color: var(--muted);
  font-size: 0.9rem;
}

.novel-card .body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.novel-card h2 {
  margin: 0;
  font-size: 1.12rem;
}

.novel-card .author {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: -0.25rem;
}

.novel-card .blurb {
  color: var(--muted);
  font-size: 0.88rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.novel-card .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.novel-card .card-cta {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: 0.15rem;
}

.novel-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.novel-card .card-actions .btn {
  font-size: 0.82rem;
  padding: 0.38rem 0.75rem;
}

.site-disclaimer {
  margin-top: 3rem;
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  font-family: var(--font-sans);
  line-height: 1.7;
  max-width: 62ch;
}

.site-disclaimer strong {
  color: var(--text);
  font-weight: 600;
}

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0;
  margin: 0.5rem 0 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.chapter-nav.bottom {
  margin-top: 2rem;
  margin-bottom: 0;
}

.chapter-nav a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.chapter-nav a:hover:not(.disabled) {
  border-color: var(--border);
  background: var(--panel);
  text-decoration: none;
}

.chapter-nav a.disabled {
  color: var(--muted);
  opacity: 0.45;
  pointer-events: none;
}

.chapter-nav .center {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.chapter-nav .center a { padding: 0.2rem 0.4rem; }

.btn {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: #2a4068; border-color: #4a6fa8; }
.btn:disabled { opacity: 0.45; cursor: default; }

.library-hero {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

.library-hero .cover {
  width: 88px;
  flex-shrink: 0;
  border-radius: 6px;
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.library-hero .info { flex: 1; min-width: 0; }

.library-hero h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.library-hero .meta { margin-bottom: 0.5rem; }

.library-hero .blurb {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.55rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-hero .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.library-hero .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.edition-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0.65rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, var(--border));
  border: 1px solid var(--border);
}

.edition-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.edition-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.edition-btn.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--border));
}

.feature-matrix {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  display: none;
}

body.library-debug .feature-matrix:not([hidden]) {
  display: block;
}

.library-debug-bar {
  display: none;
  margin: 0;
  padding: 0.35rem 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  text-align: center;
}

body.library-debug .library-debug-bar:not([hidden]) {
  display: block;
}

.feature-matrix h2 {
  font-size: 0.92rem;
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-weight: 600;
}

.feature-matrix table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.feature-matrix th,
.feature-matrix td {
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.feature-matrix tr:last-child th,
.feature-matrix tr:last-child td {
  border-bottom: none;
}

.feature-matrix th {
  color: var(--muted);
  font-weight: 500;
  width: 7.5rem;
}

.feature-matrix .feat-ok { color: var(--ok); }
.feature-matrix .feat-warn { color: var(--warn); }
.feature-matrix .feat-muted { color: var(--muted); }

.character-refs-panel {
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.character-refs-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.character-refs-hint {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.character-refs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.character-ref-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0f1520;
  cursor: zoom-in;
}

.character-ref-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #1a2332;
}

.character-ref-card figcaption {
  padding: 0.45rem 0.5rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
}

.character-ref-card strong {
  display: block;
  color: var(--text);
  font-size: 0.76rem;
  margin-bottom: 0.15rem;
}

.chapter-list { display: flex; flex-direction: column; gap: 0.6rem; }

.chapter-list-head {
  display: none;
  grid-template-columns: 1fr repeat(4, 3.2rem) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.85rem;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}

body.library-debug .chapter-list-head:not([hidden]) {
  display: grid;
}

.volume-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.1rem 0 0.35rem;
  padding: 0.35rem 0 0.15rem;
  border-top: 1px solid var(--border);
}
.volume-section-header:first-child {
  margin-top: 0.25rem;
  border-top: none;
}
.volume-badge {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}
.volume-arc {
  font-size: 0.82rem;
  color: var(--muted);
}

.vol-char-wall-inline {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.65rem;
  background: #1e2838;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.vol-char-wall-inline::before {
  content: "本卷主要人物";
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.vol-char-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
}
.vol-char-card {
  margin: 0;
  width: 4.5rem;
  text-align: center;
}
.vol-char-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.vol-char-card-link:hover {
  background: rgba(255, 255, 255, 0.04);
}
.vol-char-card-link:hover .vol-char-name {
  color: var(--accent, #7eb8ff);
}
.vol-char-avatar {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 0.3rem;
  border-radius: 50%;
  overflow: hidden;
  background: #243044;
  border: 1px solid #3d4f66;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vol-char-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.vol-char-avatar-img.is-loaded {
  opacity: 1;
}
.vol-char-avatar-ph {
  position: relative;
  z-index: 1;
  font-size: 1.1rem;
  font-weight: 600;
  color: #94a8c4;
  line-height: 1;
}
.vol-char-name {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vol-char-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #243044;
  border: 1px solid #334155;
  color: var(--text);
}

.chapter-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

body.library-debug .chapter-row {
  grid-template-columns: 1fr repeat(4, 3.2rem) auto;
}

.chapter-row.playing { border-color: var(--accent); }
.chapter-row .title { font-size: 1rem; margin: 0 0 0.15rem; }
.chapter-row .chapter-cover {
  width: 56px;
  height: 74px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  flex-shrink: 0;
}

.chapter-row .chapter-main {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  min-width: 0;
}

.chapter-feat {
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.2;
}

.chapter-feat.ok { color: var(--ok); }
.chapter-feat.warn { color: var(--warn); }
.chapter-feat.muted { color: var(--muted); }

.chapter-row .sub {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-row .badges { display: flex; gap: 0.35rem; margin-top: 0.2rem; flex-wrap: wrap; }

.chapter-row .actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .library-hero { flex-direction: column; align-items: center; text-align: center; }
  .library-hero .cover { width: 120px; }
  .library-hero .badges, .library-hero .hero-actions { justify-content: center; }
}

.progress-bar {
  height: 6px;
  background: #252b3d;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 999px;
}

.pager-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, var(--panel));
  backdrop-filter: blur(8px);
  font-size: 0.82rem;
  font-family: var(--font-sans);
}

.pager-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.pager-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pager-info {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 7rem;
  text-align: center;
}

.pager-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.pager-mark {
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--muted);
  padding: 0.18rem 0.42rem;
}

.pager-mark:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.pager-controls {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin-left: auto;
}

.pager-size,
.pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.pager-bar button,
.pager-bar select,
.pager-bar input {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.3;
}

.pager-arrow {
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.pager-size select {
  padding: 0.18rem 0.35rem;
  min-width: 2.5rem;
}

.pager-jump input {
  width: 3rem;
  text-align: center;
  padding: 0.18rem 0.25rem;
}

.pager-jump button {
  padding: 0.18rem 0.4rem;
}

.pager-bar button:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 640px) {
  .pager-top {
    flex-direction: column;
    align-items: stretch;
  }

  .pager-nav {
    justify-content: center;
  }

  .pager-controls {
    margin-left: 0;
    justify-content: center;
  }
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
}

.pager button, .pager select, .pager input {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.35rem 0.75rem;
}

.pager button:disabled { opacity: 0.4; cursor: default; }

.offline-panel {
  display: none;
}

.offline-chip {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(114, 201, 154, 0.35);
  background: rgba(114, 201, 154, 0.1);
  color: #9edfb8;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 0.1rem;
}

.offline-chip:hover {
  border-color: rgba(114, 201, 154, 0.6);
  background: rgba(114, 201, 154, 0.16);
}

body.offline-drawer-open {
  overflow: hidden;
}

.pwa-install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(142, 197, 255, 0.35);
  background: color-mix(in srgb, var(--panel) 92%, #1a2a44);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.pwa-install-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.pwa-install-text strong {
  color: var(--text);
  font-size: 0.9rem;
}

.pwa-install-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

body.has-global-player .pwa-install-banner {
  bottom: calc(6.75rem + env(safe-area-inset-bottom, 0px));
}

.offline-drawer {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.offline-drawer[hidden] {
  display: none !important;
}

.offline-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(4, 6, 12, 0.62);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.offline-sheet {
  position: relative;
  width: min(480px, 100%);
  max-height: min(88vh, 640px);
  overflow: auto;
  margin: 0;
  padding: 1.1rem 1.15rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  animation: offline-slide-up 0.22s ease-out;
}

@keyframes offline-slide-up {
  from { transform: translateY(12px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.offline-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.offline-sheet-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.offline-sheet-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.offline-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}

.offline-close:hover { color: var(--text); }

.offline-status {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.offline-range {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.offline-range label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1;
}

.offline-range input {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  width: 100%;
}

.offline-range-sep {
  color: var(--muted);
  padding-bottom: 0.55rem;
}

.offline-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.offline-primary-actions {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.offline-progress {
  display: block;
  width: 100%;
  margin: 0.35rem 0 0.75rem;
  height: 0.45rem;
  accent-color: var(--accent);
}

.offline-sheet-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.btn.sm {
  font-size: 0.8rem;
  padding: 0.32rem 0.65rem;
}

.btn.danger {
  border-color: rgba(232, 136, 136, 0.45);
  color: #f0a8a8;
}

.btn.danger:hover {
  background: rgba(232, 136, 136, 0.12);
}

.chapter-row .badge.cached {
  border-color: rgba(114, 201, 154, 0.45);
  color: var(--ok);
}

footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--font-sans);
}

footer code {
  font-family: ui-monospace, Menlo, monospace;
  color: #b8c7e8;
  font-size: 0.85em;
}

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .chapter-list-head { display: none; }
  .chapter-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .chapter-row .chapter-feat {
    display: inline-block;
    margin-right: 0.5rem;
    text-align: left;
  }
  .chapter-row .actions { justify-content: flex-end; }
}

/* ── Demo galleries (turnaround, image-edit comparisons) ── */
.demo-page {
  --demo-layout-max: 1100px;
}

.demo-page .demo-topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--sticky-top-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.demo-page .demo-topbar .site-header {
  max-width: var(--demo-layout-max);
  margin: 0 auto;
  padding: 1rem 1.25rem 0.85rem;
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  position: static;
}

.demo-page main {
  max-width: var(--demo-layout-max);
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
}

.demo-warn-banner {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

.demo-warn-banner strong {
  color: var(--warn);
}

.demo-warn-banner ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.demo-warn-banner p {
  margin: 0.35rem 0 0;
}

.demo-warn-banner--info {
  border-left-color: var(--accent-dim);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.demo-warn-banner--info strong {
  color: var(--accent);
}

.demo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.demo-gallery-grid img {
  width: 100%;
  border-radius: 8px;
  background: #0a0c10;
}

.demo-gallery-grid figcaption {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.demo-page footer.demo-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.demo-breadcrumb {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 1rem;
  font-family: var(--font-sans);
}

.demo-breadcrumb a {
  color: var(--accent-dim);
}

.demo-breadcrumb span {
  margin: 0 0.35rem;
}

.demo-hero {
  margin-bottom: 1.5rem;
}

.demo-hero .lead {
  max-width: 68ch;
}

.demo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.demo-legend .pass { color: var(--ok); }
.demo-legend .fail { color: var(--danger); }

.demo-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.demo-card h2 {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}

.demo-card .meta {
  margin-bottom: 0.65rem;
  font-size: 0.82rem;
}

.demo-card .meta code {
  font-size: 0.78rem;
}

.demo-pose-group {
  margin-bottom: 2rem;
}

.demo-pose-group > h2 {
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.demo-pose-goal {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.35rem 0 1rem;
}

.demo-backend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.demo-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.demo-frame {
  aspect-ratio: 3 / 4;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-frame.charonly {
  background:
    repeating-conic-gradient(#1e2433 0% 25%, #161b28 0% 50%) 50% / 14px 14px;
}

.demo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}

.demo-frame figcaption {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-family: var(--font-sans);
}

.demo-ref-frame {
  max-width: min(360px, 100%);
  margin: 0 auto;
}

.demo-ref-frame .demo-frame {
  aspect-ratio: 3 / 4;
}

.demo-prompt details {
  margin-top: 0.65rem;
}

.demo-prompt summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--accent);
  user-select: none;
}

.demo-prompt pre {
  font-size: 0.7rem;
  white-space: pre-wrap;
  color: #b8c7e8;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin: 0.5rem 0 0;
  max-height: 12rem;
  overflow: auto;
}

.demo-prompt mark.prompt-hl {
  background: rgba(199, 162, 74, 0.35);
  color: var(--gold);
  border-radius: 2px;
  padding: 0 2px;
}

.demo-note {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg-elevated);
  border-left: 3px solid var(--gold);
  padding: 0.55rem 0.75rem;
  margin: 0.5rem 0 0;
  border-radius: 0 8px 8px 0;
}

.qa-pass { color: var(--ok); font-weight: 500; }
.qa-fail { color: var(--danger); font-weight: 500; }

.demo-nav-ext a {
  font-size: 0.82rem;
}

.demo-frame.demo-frame-empty {
  color: var(--muted);
  font-size: 1.5rem;
}

.demo-compare.demo-compare-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
  .demo-compare { grid-template-columns: 1fr; }
  .demo-backend-grid { grid-template-columns: 1fr; }
}
