/* ===== Embedded Pyidaungsu 2.5.3 WOFF2 (Non-overlapping unicode-range) ===== */
@font-face {
  font-family: 'Pyidaungsu';
  src: url('./fonts/Pyidaungsu-2.5.3-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-002F, U+003A-103F, U+104A-10FFFF;
}

@font-face {
  font-family: 'Pyidaungsu';
  src: url('./fonts/Pyidaungsu-2.5.3-Numbers.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0030-0039, U+1040-1049;
}

@font-face {
  font-family: 'Pyidaungsu';
  src: url('./fonts/Pyidaungsu-2.5.3-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ===== Theme Variables ===== */
:root,
html[data-theme="light"] {
  --bg-page: #faf7f0;
  --bg-surface: #ffffff;
  --bg-elevated: #f3ede0;
  --bg-pali: #eef6f2;
  --bg-highlight: #fff3b0;
  --text-main: #1f2421;
  --text-muted: #5a635e;
  --accent: #174e3b;
  --accent-hover: #103a2b;
  --accent-soft: rgba(23, 78, 59, 0.1);
  --gold: #c4933f;
  --gold-soft: rgba(196, 147, 63, 0.15);
  --border: #e5decb;
  --shadow: 0 6px 24px rgba(23, 78, 59, 0.07);
}

html[data-theme="sepia"] {
  --bg-page: #f2ead7;
  --bg-surface: #fbf5e7;
  --bg-elevated: #e8dec5;
  --bg-pali: #efe6cf;
  --bg-highlight: #ffe699;
  --text-main: #3b2a1e;
  --text-muted: #6f5949;
  --accent: #6b3419;
  --accent-hover: #522611;
  --accent-soft: rgba(107, 52, 25, 0.1);
  --gold: #b07d2b;
  --gold-soft: rgba(176, 125, 43, 0.16);
  --border: #dfd2b5;
  --shadow: 0 6px 24px rgba(60, 35, 15, 0.08);
}

html[data-theme="dark"] {
  --bg-page: #111513;
  --bg-surface: #191f1c;
  --bg-elevated: #222a26;
  --bg-pali: #1d2b24;
  --bg-highlight: #5c4b14;
  --text-main: #e6ebe8;
  --text-muted: #9aa7a0;
  --accent: #5ec298;
  --accent-hover: #79d4ad;
  --accent-soft: rgba(94, 194, 152, 0.14);
  --gold: #dfb45b;
  --gold-soft: rgba(223, 180, 91, 0.16);
  --border: #2b3530;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html[data-font="serif"] {
  --font-family: 'Pyidaungsu', Georgia, serif;
}

html[data-font="sans"] {
  --font-family: 'Noto Sans Myanmar', 'Padauk', system-ui, -apple-system, sans-serif;
}

:root {
  --reader-scale: 1;
  --reader-lh: 1.95;
  --topbar-h: 60px;
  --sidebar-w: 310px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* ===== Progress Bar ===== */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  z-index: 1200;
  transition: width 0.15s ease;
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  min-width: 0;
}

.brand-emblem {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.offline-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.offline-badge.ready {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.offline-badge.ready .dot {
  background: #16a34a;
}

.nav-pill, .icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 10px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
}

.nav-pill:hover, .icon-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--gold);
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #123e2e 0%, #1d5d46 60%, #276e54 100%);
  color: #fff;
  padding: 44px 16px 38px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-inner {
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.pali-motto {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(224, 178, 86, 0.5);
  color: #f7dc9c;
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 3.6vw, 2.3rem);
  line-height: 1.35;
}

.hero-desc {
  margin: 0 auto 22px;
  max-width: 680px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.98rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
}

/* ===== Container & Home Sections ===== */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.continue-card {
  background: var(--bg-surface);
  border: 1px solid var(--gold);
  border-left: 5px solid var(--gold);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.continue-meta small {
  color: var(--gold);
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

.continue-meta strong {
  font-size: 1.04rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:hover { border-color: var(--accent); }

/* ===== Search & Filter ===== */
.library-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.home-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
  box-shadow: var(--shadow);
}

.home-search-box:focus-within {
  border-color: var(--accent);
}

.home-search-box input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.96rem;
  padding: 10px 8px;
  outline: none;
}

.clear-btn {
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== Search Results ===== */
.search-results-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: border-color 0.15s;
}

.search-result-item:hover { border-color: var(--accent); }

.search-result-meta {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.search-result-title {
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.65;
}

mark {
  background: var(--bg-highlight);
  color: inherit;
  padding: 0 3px;
  border-radius: 4px;
}

/* ===== Books Grid ===== */
.books-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.book-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
}

.book-icon {
  font-size: 1.5rem;
}

.book-card h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent);
}

.book-author {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: -4px 0 0;
}

.book-highlights {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 4px 0;
  list-style: none;
}

.book-highlights li {
  font-size: 0.88rem;
  padding: 3px 0;
  color: var(--text-main);
}

.book-highlights li::before {
  content: '❖ ';
  color: var(--gold);
}

.book-progress-wrap {
  margin-top: auto;
}

.book-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.book-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.book-card-actions .btn-primary { flex: 1; }

/* ===== Study Section ===== */
.study-section {
  margin-top: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.study-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.study-section h3 { margin: 0; }

.study-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-page);
  margin-top: 8px;
}

.study-item-link {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
}

.study-item-link strong { color: var(--accent); display: block; }
.study-item-link small { color: var(--text-muted); display: block; margin-top: 2px; }

/* ===== Reader Layout ===== */
.view-reader {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.reader-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.reader-sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-w));
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-book-switch {
  display: flex;
  gap: 6px;
}

.sidebar-book-switch button {
  flex: 1;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-book-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-search-wrap input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
}

.sidebar-toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.toc-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  padding: 10px 8px 4px;
  text-transform: uppercase;
}

.toc-item-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.toc-item-btn:hover { background: var(--bg-elevated); }

.toc-item-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.toc-read-mark {
  color: #16a34a;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* ===== Reader Main Content ===== */
.reader-main {
  flex: 1;
  min-width: 0;
  padding: 28px 20px 64px;
}

.reader-content {
  max-width: 780px;
  margin: 0 auto;
}

.chapter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px clamp(18px, 4vw, 42px);
  box-shadow: var(--shadow);
}

.chapter-header {
  text-align: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.chapter-num-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.chapter-header h1 {
  margin: 0 0 10px;
  font-size: calc(1.48rem * var(--reader-scale));
  color: var(--accent);
  line-height: 1.45;
}

.chapter-meta-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-bottom: 14px;
}

.chapter-action-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-body {
  font-size: calc(1.06rem * var(--reader-scale));
  line-height: var(--reader-lh);
}

.chapter-body p.reader-para {
  margin: 0 0 1.05em;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}

.chapter-body p.reader-para:hover {
  background: var(--bg-elevated);
}

.chapter-body p.reader-para.is-highlighted {
  background: var(--bg-highlight);
  border-left: 3px solid var(--gold);
}

.chapter-body p.text-center { text-align: center; }
.chapter-body p.text-bold { font-weight: 700; }

.chapter-body h2 {
  font-size: calc(1.22rem * var(--reader-scale));
  color: var(--accent);
  margin: 1.6em 0 0.7em;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}

.chapter-body h3 {
  font-size: calc(1.08rem * var(--reader-scale));
  color: var(--gold);
  margin: 1.3em 0 0.5em;
}

.pali-box {
  background: var(--bg-pali);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: calc(1rem * var(--reader-scale));
  line-height: 1.85;
}

.pali-box p { margin: 4px 0; }

.reader-table-wrap {
  overflow-x: auto;
  margin: 18px 0;
}

.reader-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.reader-table th, .reader-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.reader-table tr:first-child td {
  background: var(--bg-elevated);
  font-weight: 700;
}

.para-note-badge {
  display: block;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--gold);
  font-size: 0.85rem;
  color: var(--text-main);
}

.chapter-nav-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}

.ch-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  color: var(--text-main);
  font-family: inherit;
  transition: border-color 0.15s;
}

.ch-nav-btn:hover { border-color: var(--accent); }
.ch-nav-btn.next { text-align: right; }
.ch-nav-btn small { color: var(--text-muted); display: block; font-size: 0.78rem; }
.ch-nav-btn strong { color: var(--accent); font-size: 0.94rem; }

/* ===== Book Overview / Frontmatter in Reader ===== */
.book-cover-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.book-cover-card h1 { color: var(--accent); margin: 10px 0 8px; }
.frontmatter-box {
  text-align: left;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 18px 0;
  font-size: 0.92rem;
}

/* ===== Floating Back to Top ===== */
.fab-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  z-index: 800;
}

/* ===== Mobile Bottom Nav (Hidden on Desktop >= 768px) ===== */
.mobile-bottom-nav {
  display: none;
}

.mobile-only { display: none; }

/* ===== Modals ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
}

.sheet-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
  max-height: 82vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  z-index: 1010;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.sheet-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-header h2 { margin: 0; font-size: 1.05rem; }

.close-modal-btn {
  border: none;
  background: var(--bg-elevated);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.sheet-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-scope-chips { margin: 12px 0; }

.aa-group { margin-bottom: 18px; }
.aa-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.aa-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.aa-opt {
  flex: 1;
  min-width: 90px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.aa-opt.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.bm-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.site-footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: #1a201d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 1300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ===== Mobile Responsive (<= 767px) ===== */
@media (max-width: 767px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }
  .offline-badge .badge-label { display: none; }
  .hide-xs { display: none; }

  .books-grid {
    grid-template-columns: 1fr;
  }

  .reader-sidebar {
    display: none;
  }

  .reader-main {
    padding: 14px 10px 36px;
  }

  .chapter-card {
    padding: 20px 14px;
  }

  .chapter-nav-footer {
    grid-template-columns: 1fr;
  }

  .fab-top {
    bottom: calc(76px + env(safe-area-inset-bottom));
    right: 14px;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }

  .mb-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
  }

  .mb-tab span { font-size: 1.05rem; }

  .sheet-modal {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
  }
}
