/* ============================================================
   KHO SÁCH VIỆT — Main Stylesheet
   ============================================================ */

/* ── 1. Variables ─────────────────────────────────────────── */
:root {
  /* Colors - Light */
  --bg:           #faf8f4;
  --bg-alt:       #f0ebe0;
  --surface:      #ffffff;
  --text:         #1c1410;
  --text-muted:   #7a6a58;
  --accent:       #8b1a1a;
  --accent-hover: #a82424;
  --border:       #e0d8c8;
  --shadow-sm:    0 1px 3px rgba(44, 33, 16, .07);
  --shadow-md:    0 4px 16px rgba(44, 33, 16, .10);
  --shadow-lg:    0 8px 32px rgba(44, 33, 16, .14);

  /* Typography */
  --font-serif: 'Noto Serif', Georgia, 'Times New Roman', serif;
  --font-ui:    'Inter', system-ui, -apple-system, sans-serif;

  /* Layout */
  --max-w:        1100px;
  --reading-w:    70ch;
  --sidebar-w:    260px;
  --header-h:     56px;

  /* Transitions */
  --t-fast:  150ms ease;
  --t-base:  220ms ease;
  --t-slow:  350ms ease;
}

[data-theme="dark"] {
  --bg:           #151210;
  --bg-alt:       #1e1a16;
  --surface:      #242018;
  --text:         #ede5d8;
  --text-muted:   #a09080;
  --accent:       #c9956c;
  --accent-hover: #e0a878;
  --border:       #3a3228;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.25);
  --shadow-md:    0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.50);
}

/* ── 2. Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background var(--t-slow), color var(--t-slow);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast), opacity var(--t-fast);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── 3. Header ────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background var(--t-slow), border-color var(--t-slow);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent); }
.logo-mark { font-size: 1.2rem; }

/* Book info in header (chapter pages) */
.header-book-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--text-muted);
  overflow: hidden;
  min-width: 0;
}
.header-book-title {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.header-book-title:hover { color: var(--accent); }
.header-sep { flex-shrink: 0; }
.header-chapter-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 500;
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }

/* Reading progress bar */
.reading-progress-bar {
  height: 2px;
  background: var(--accent);
  width: 0%;
  transition: width 100ms linear;
  transform-origin: left;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-alt); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Show/hide sun/moon icons */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: none; }

/* ── 4. Footer ────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
  color: var(--text-muted);
}
.footer-brand { display: flex; flex-direction: column; gap: .125rem; }
.footer-brand strong { color: var(--text); }
.footer-links { display: flex; gap: 1.5rem; }

/* ── 5. Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .625rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139,26,26,.3);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; box-shadow: 0 4px 12px rgba(139,26,26,.4); }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text); }

/* ── 6. Home — Hero ───────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-alt) 100%);
  border-bottom: 1px solid var(--border);
  padding: 5rem 1.5rem 4rem;
  text-align: center;
}
.hero-eyebrow {
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.15;
  margin-bottom: .75rem;
}
.hero-sub {
  font-size: 1.125rem;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 48ch;
  margin: 0 auto;
}

/* ── 7. Home — Library section ────────────────────────────── */
.library-section { padding: 4rem 0; }
.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--border);
}

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2rem;
}

/* Book card */
.book-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base), box-shadow var(--t-base);
  color: var(--text);
  text-decoration: none;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.book-cover {
  aspect-ratio: 5/7;
  overflow: hidden;
  background: var(--bg-alt);
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}
.book-card:hover .book-cover img { transform: scale(1.04); }

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  padding: 1.25rem;
}
.cover-title-overlay {
  font-family: var(--font-serif);
  font-size: .875rem;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}

.book-info {
  padding: 1rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
}
.book-title-vi {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.book-title-en { font-size: .75rem; color: var(--text-muted); font-style: italic; }
.book-author    { font-size: .8125rem; color: var(--text-muted); margin-top: .25rem; }
.book-meta      { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .625rem; }
.meta-tag {
  font-size: .6875rem;
  font-weight: 500;
  padding: .2em .6em;
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* About strip */
.about-strip {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 3.5rem 0;
}
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}
.about-item { text-align: center; }
.about-icon { font-size: 2rem; margin-bottom: .75rem; }
.about-item h3 {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--text);
}
.about-item p { font-size: .875rem; color: var(--text-muted); line-height: 1.65; }

/* ── 8. Book page ─────────────────────────────────────────── */
.book-hero {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 3rem 0;
}
.book-hero-inner {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}
.book-hero-cover {
  flex-shrink: 0;
  width: 160px;
}
.book-hero-cover img {
  width: 160px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}
.book-cover-lg {
  width: 160px;
  aspect-ratio: 5/7;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-end;
  padding: 1rem;
}
.book-cover-lg span {
  font-family: var(--font-serif);
  font-size: .8rem;
  color: rgba(255,255,255,.9);
  line-height: 1.4;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}

.book-hero-meta { flex: 1; min-width: 0; }
.book-hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: .75rem 0 .25rem;
}
.book-hero-title-en { font-style: italic; color: var(--text-muted); margin-bottom: .25rem; }
.book-hero-author   { font-weight: 500; color: var(--text); }
.book-hero-year     { font-size: .875rem; color: var(--text-muted); margin-top: .25rem; }
.book-hero-actions  { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* Register strip */
.register-strip { padding: 2rem 0; }
.register-quote {
  border-left: 3px solid var(--accent);
  padding: 1rem 1.5rem;
  background: var(--bg-alt);
  border-radius: 0 8px 8px 0;
  max-width: 72ch;
}
.register-quote p {
  font-family: var(--font-serif);
  font-size: .9375rem;
  line-height: 1.8;
  color: var(--text);
  font-style: italic;
}
.register-quote footer {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: .75rem;
}

/* Chapter list */
.chapter-list-section { padding: 2.5rem 0 4rem; }
.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.chapter-list-item {}
.chapter-list-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .875rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.chapter-list-link:hover {
  background: var(--bg-alt);
  border-color: var(--border);
  color: var(--text);
}
.chapter-number {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.chapter-list-titles { flex: 1; display: flex; flex-direction: column; gap: .1rem; }
.chapter-list-title  { font-weight: 500; font-size: .9375rem; }
.chapter-list-sub    { font-size: .8125rem; color: var(--text-muted); }
.chapter-arrow       { color: var(--text-muted); flex-shrink: 0; }

/* ── 9. Chapter / Character layout ───────────────────────── */
.chapter-layout,
.char-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--header-h));
  max-width: var(--max-w);
  margin: 0 auto;
}

/* Sidebar */
.chapter-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-inner {
  padding: 1.5rem 1rem;
}
.sidebar-heading {
  font-family: var(--font-serif);
  font-size: .875rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: .75rem;
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-heading a { color: inherit; }
.sidebar-heading a:hover { color: var(--accent); }

.sidebar-chapter-list { list-style: none; display: flex; flex-direction: column; gap: .125rem; }
.sidebar-chapter-list li a {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .5rem .625rem;
  border-radius: 6px;
  font-size: .8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-chapter-list li a:hover { background: var(--border); color: var(--text); }
.sidebar-chapter-list li.active a {
  background: var(--accent);
  color: #fff;
}
.sidebar-num {
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 600;
  width: 1.25rem;
  text-align: center;
  margin-top: .125rem;
}
.sidebar-charmap-link a {
  border-top: 1px solid var(--border);
  margin-top: .5rem;
  padding-top: .75rem !important;
}

/* Reading area */
.reading-area {
  padding: 2rem 3rem 4rem;
  max-width: 100%;
  overflow: hidden;
}

.chapter-topbar { margin-bottom: 2rem; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8125rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span:last-child { color: var(--text); }

/* ── 10. Reading Content ──────────────────────────────────── */
.reading-content {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.875;
  color: var(--text);
  max-width: var(--reading-w);
}

.reading-content p { margin: 0 0 1.25em; }

/* Chapter headings */
.reading-content h1,
.reading-content h2 {
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  margin: 2.5em 0 .25em;
  line-height: 1.4;
}
.reading-content h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  text-align: center;
  margin: .25em 0 2em;
  color: var(--text-muted);
}
.reading-content h4 {
  font-size: 1rem;
  font-weight: 600;
  font-style: italic;
  text-align: center;
  margin: .25em 0 2em;
  color: var(--text-muted);
}
.reading-content h5 { font-size: .9375rem; margin: 1.5em 0 .5em; }

/* Horizontal rule — visual section break */
.reading-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em auto;
  max-width: 12ch;
}

/* Dialogue list items (- Text format from localization) */
.reading-content ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
}
.reading-content ul > li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: .625em;
}
.reading-content ul > li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--text);
  font-weight: 400;
}

/* Verse / lyric tables (single column, empty header) */
.reading-content table {
  border-collapse: collapse;
  margin: 1.75em auto;
  font-size: inherit;
}
.reading-content table:has(thead tr th:only-child:empty) {
  /* Verse block */
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.reading-content table:has(thead tr th:only-child:empty) th,
.reading-content table:has(thead tr th:only-child:empty) td {
  padding: .875rem 1.25rem;
  font-style: italic;
  text-align: center;
  border: none;
}
/* Normal tables (character map) */
.reading-content table:not(:has(thead tr th:only-child:empty)) {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: .875rem;
  font-family: var(--font-ui);
}
.reading-content table:not(:has(thead tr th:only-child:empty)) th {
  background: var(--bg-alt);
  font-weight: 600;
  padding: .625rem .875rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.reading-content table:not(:has(thead tr th:only-child:empty)) td {
  padding: .5625rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}
.reading-content table:not(:has(thead tr th:only-child:empty)) tr:last-child td { border-bottom: none; }
.reading-content table:not(:has(thead tr th:only-child:empty)) tr:hover td { background: var(--bg-alt); }

/* Images */
.reading-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  margin: 2em auto;
}
.reading-content img + em,
.reading-content img + p > em:only-child {
  display: block;
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: -1.25em;
  margin-bottom: 1.5em;
}

/* Bold & italic */
.reading-content strong { font-weight: 700; }
.reading-content em     { font-style: italic; }

/* Footnote superscripts */
.reading-content sup { font-size: .65em; vertical-align: super; line-height: 0; }
.reading-content sup a.footnote-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25em;
  height: 1.25em;
  padding: 0 .2em;
  background: var(--accent);
  color: #fff !important;
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: .6875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
  text-decoration: none;
}
.reading-content sup a.footnote-ref:hover {
  background: var(--accent-hover);
  transform: scale(1.15);
}

/* Footnotes section at bottom */
.reading-content .footnotes {
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  line-height: 1.65;
}
.reading-content .footnotes hr { display: none; }
.reading-content .footnotes ol { padding-left: 1.5em; }
.reading-content .footnotes li { margin-bottom: .75em; }
.reading-content .footnotes li p { margin: 0; }
.reading-content .footnotes a.footnote-backref {
  font-size: .75rem;
  color: var(--accent);
  margin-left: .25em;
}

/* When JS is active, style footnotes section more subtly */
body.js-ready .reading-content .footnotes {
  font-size: .8125rem;
  opacity: .8;
}

/* ── 11. Footnote Popover ─────────────────────────────────── */
.footnote-popover {
  position: fixed;
  z-index: 999;
  max-width: 340px;
  width: max-content;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: .875rem 1.125rem;
  font-family: var(--font-ui);
  font-size: .825rem;
  line-height: 1.65;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.footnote-popover.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.footnote-popover p { margin: 0; }
.footnote-popover strong { font-weight: 600; }
.footnote-popover::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
}
.footnote-popover.arrow-down::before {
  bottom: -12px;
  border-top-color: var(--border);
}
.footnote-popover.arrow-up::before {
  top: -12px;
  border-bottom-color: var(--border);
}

/* ── 12. Chapter Navigation ───────────────────────────────── */
.chapter-nav {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.chapter-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.chapter-nav-btn {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .875rem 1.125rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .875rem;
  background: var(--surface);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  max-width: 44%;
}
.chapter-nav-btn:hover { border-color: var(--accent); background: var(--bg-alt); color: var(--text); transform: translateY(-1px); }
.chapter-nav-btn span { display: flex; flex-direction: column; }
.chapter-nav-btn small { font-size: .7rem; color: var(--text-muted); }
.chapter-nav-btn strong { font-weight: 600; line-height: 1.35; }
.chapter-nav-btn.prev { flex-direction: row; }
.chapter-nav-btn.next { flex-direction: row-reverse; text-align: right; }
.chapter-nav-book {
  font-size: .8125rem;
  color: var(--text-muted);
  padding: .5rem .875rem;
  border-radius: 6px;
  transition: color var(--t-fast), background var(--t-fast);
}
.chapter-nav-book:hover { color: var(--accent); background: var(--bg-alt); }

/* ── 13. Character page ───────────────────────────────────── */
.char-content-area {
  padding: 2rem 3rem 4rem;
  overflow-x: hidden;
}
.char-topbar { margin-bottom: 2rem; }
.char-reading-content { font-size: .9375rem; }
.char-reading-content table { max-width: 100%; overflow-x: auto; display: block; }
.char-back { margin-top: 3rem; }

/* Mermaid diagram */
.mermaid {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-size: .875rem;
}

/* ── 14. Misc ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 0;
  font-size: 1rem;
}
.empty-state code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15em .4em;
  font-size: .875em;
  color: var(--accent);
}

/* ── 15. Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .chapter-layout,
  .char-layout {
    grid-template-columns: 1fr;
  }
  .chapter-sidebar {
    display: none; /* hidden on mobile — use breadcrumb nav */
  }
  .reading-area,
  .char-content-area {
    padding: 1.5rem 1.25rem 3rem;
  }
  .book-hero-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .book-hero-actions { justify-content: center; }
  .register-quote { margin: 0 auto; }
  .chapter-nav-btn { max-width: 48%; padding: .75rem .875rem; }
}

@media (max-width: 640px) {
  .header-book-info { display: none; }
  .hero { padding: 3.5rem 1.25rem 3rem; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .about-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .footer-links { flex-direction: column; gap: .25rem; }
  .chapter-nav-btn strong { font-size: .8125rem; }
  .reading-content { font-size: 1.0625rem; }
  .book-hero-cover { width: 120px; }
  .book-cover-lg,
  .book-hero-cover img { width: 120px; }
}

@media (max-width: 380px) {
  .book-grid { grid-template-columns: 1fr; }
}

/* ── 16. Print ────────────────────────────────────────────── */
@media print {
  .site-header, .chapter-sidebar, .chapter-nav, .site-footer,
  .theme-toggle, .breadcrumb { display: none !important; }
  .reading-content { font-size: 12pt; max-width: 100%; }
}
