/**
 * BoxyKit Libris - Core Stylesheet & Design System
 * @file plugins/libris/web/css/libris.css
 *
 * Professional E-Reader & Scripture Study Design System:
 * - Fluid typography, sacred geometry proportions, optimal measure (65-75 CPL)
 * - True parallel dual-translation alignment with gutter verse numbers
 * - Multi-theme reading surfaces (Dark Obsidian, Warm Sepia Parchment, Clean Day, OLED Night)
 * - Glassmorphic floating toolbars and command drawers
 * - Responsive breakpoints for mobile, tablet, and desktop
 */

/* =============================================================================
   0. Critical CSS Reset & Utility Overrides
   ============================================================================= */

[hidden] {
  display: none !important;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Dynamic Typography Engine Variables */
  --reader-font-size: 17.5px;
  --reader-line-height: 1.85;
  --reader-content-max-width: 860px;
  --reader-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --reader-font-serif: "Newsreader", "Charter", "Georgia", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --reader-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --reader-font-mono: ui-monospace, "SF Mono", Monaco, Consolas, monospace;

  /* Surface Paper Variables (Default Dark Obsidian) */
  --reading-surface-bg: rgba(15, 23, 42, 0.72);
  --reading-surface-card: rgba(22, 31, 50, 0.55);
  --reading-surface-border: rgba(255, 255, 255, 0.08);
  --reading-surface-text: #f1f5f9;
  --reading-surface-sub: #94a3b8;
  --reading-surface-muted: #64748b;
  --reading-surface-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);

  --verse-gutter-color: #6366f1;
  --verse-hover-bg: rgba(99, 102, 241, 0.07);
  --verse-highlight-bg: rgba(99, 102, 241, 0.22);
  --verse-divider: rgba(255, 255, 255, 0.05);

  --kjv-accent: #818cf8;
  --kjv-bg: rgba(99, 102, 241, 0.12);
  --web-accent: #22d3ee;
  --web-bg: rgba(6, 182, 212, 0.12);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode Overrides */
[data-theme="light"] {
  --reading-surface-bg: #ffffff;
  --reading-surface-card: #f8fafc;
  --reading-surface-border: rgba(0, 0, 0, 0.07);
  --reading-surface-text: #0f172a;
  --reading-surface-sub: #475569;
  --reading-surface-muted: #94a3b8;
  --reading-surface-shadow: 0 10px 30px -6px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);

  --verse-gutter-color: #4f46e5;
  --verse-hover-bg: rgba(79, 70, 229, 0.05);
  --verse-highlight-bg: rgba(79, 70, 229, 0.14);
  --verse-divider: rgba(0, 0, 0, 0.05);

  --kjv-accent: #4338ca;
  --kjv-bg: rgba(79, 70, 229, 0.1);
  --web-accent: #0891b2;
  --web-bg: rgba(6, 182, 212, 0.1);
}

/* Sepia (羊皮纸沉浸护眼模式) */
[data-reading-theme="sepia"],
[data-theme="light"][data-reading-theme="sepia"],
[data-theme="dark"][data-reading-theme="sepia"] {
  --reading-surface-bg: #f9f4e8 !important;
  --reading-surface-card: #f2eade !important;
  --reading-surface-border: #e6dac3 !important;
  --reading-surface-text: #34281d !important;
  --reading-surface-sub: #6e5c4a !important;
  --reading-surface-muted: #968370 !important;
  --reading-surface-shadow: 0 12px 32px -8px rgba(85, 65, 45, 0.12), 0 0 0 1px #e6dac3 !important;

  --verse-gutter-color: #a16207 !important;
  --verse-hover-bg: rgba(161, 98, 7, 0.06) !important;
  --verse-highlight-bg: rgba(202, 138, 4, 0.2) !important;
  --verse-divider: rgba(110, 92, 74, 0.12) !important;

  --kjv-accent: #854d0e !important;
  --kjv-bg: rgba(161, 98, 7, 0.12) !important;
  --web-accent: #0f766e !important;
  --web-bg: rgba(15, 118, 110, 0.12) !important;
}

html[data-reading-theme="sepia"],
html[data-reading-theme="sepia"] body {
  background-color: #f7f2e7 !important;
  background-image: radial-gradient(circle at 50% 0%, rgba(217, 187, 145, 0.22) 0%, transparent 60%) !important;
  color: #34281d !important;
}

html[data-reading-theme="sepia"] .app-header {
  background: rgba(247, 242, 231, 0.94) !important;
  border-bottom-color: rgba(146, 115, 77, 0.2) !important;
}

html[data-reading-theme="sepia"] .header-title-link,
html[data-reading-theme="sepia"] .nav-link,
html[data-reading-theme="sepia"] .scripture-picker-btn {
  color: #34281d !important;
}

html[data-reading-theme="sepia"] .verse-num-badge {
  background: rgba(161, 98, 7, 0.12) !important;
  color: #854d0e !important;
}

html[data-reading-theme="sepia"] .reading-surface {
  background: #fdfbf7 !important;
  box-shadow: 0 16px 40px -8px rgba(85, 65, 45, 0.14), 0 0 0 1px #e4d7bf !important;
}

html[data-reading-theme="sepia"] .parallel-col-header {
  background: rgba(253, 251, 247, 0.95) !important;
}

/* Dark Night OLED Mode */
[data-reading-theme="dark"],
[data-theme="light"][data-reading-theme="dark"],
[data-theme="dark"][data-reading-theme="dark"] {
  --reading-surface-bg: #090d16 !important;
  --reading-surface-card: #0e1422 !important;
  --reading-surface-border: rgba(255, 255, 255, 0.07) !important;
  --reading-surface-text: #f1f5f9 !important;
  --reading-surface-sub: #94a3b8 !important;
  --reading-surface-muted: #64748b !important;
  --reading-surface-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.7) !important;

  --verse-gutter-color: #818cf8 !important;
  --verse-hover-bg: rgba(99, 102, 241, 0.09) !important;
  --verse-highlight-bg: rgba(99, 102, 241, 0.25) !important;
  --verse-divider: rgba(255, 255, 255, 0.06) !important;
}

/* Light Day Paper Mode */
[data-reading-theme="light"] {
  --reading-surface-bg: #ffffff !important;
  --reading-surface-card: #f8fafc !important;
  --reading-surface-border: rgba(0, 0, 0, 0.08) !important;
  --reading-surface-text: #0f172a !important;
  --reading-surface-sub: #475569 !important;
  --reading-surface-muted: #94a3b8 !important;
  --reading-surface-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.08) !important;

  --verse-gutter-color: #4f46e5 !important;
  --verse-hover-bg: rgba(79, 70, 229, 0.05) !important;
  --verse-highlight-bg: rgba(79, 70, 229, 0.14) !important;
  --verse-divider: rgba(0, 0, 0, 0.06) !important;
}

/* =============================================================================
   1. Base Page & Ambient Backdrop
   ============================================================================= */

html, body {
  min-height: 100%;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  overflow-x: hidden;
}

.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb-1 {
  position: absolute;
  top: -10%;
  left: 12%;
  width: 650px;
  height: 650px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.14) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(90px);
  animation: floatOrb 28s ease-in-out infinite alternate;
}

.aurora-orb-2 {
  position: absolute;
  top: 35%;
  right: -5%;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.11) 0%, rgba(6, 182, 212, 0) 70%);
  filter: blur(95px);
  animation: floatOrb 22s ease-in-out infinite alternate-reverse;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(35px, 25px) scale(1.06); }
  100% { transform: translate(-25px, -15px) scale(0.96); }
}

/* Glass Panels */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

/* =============================================================================
   2. Header Sub-Route Navigation Tabs
   ============================================================================= */

.header-nav-slot {
  display: flex;
  align-items: center;
  gap: 12px;
}

.subroute-tabs {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
  gap: 3px;
}

[data-theme="light"] .subroute-tabs {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
}

.subroute-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.subroute-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .subroute-tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

.subroute-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

/* =============================================================================
   3. Main App Layout & View Containers
   ============================================================================= */

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 60px;
  min-height: calc(100vh - 72px);
}

.view-panel {
  display: none;
  animation: viewFadeIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.view-panel.active {
  display: block;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   4. Unified Floating Toolbars
   ============================================================================= */

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  position: sticky;
  top: 14px;
  z-index: 50;
  transition: all var(--transition-normal);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Modern Button Hierarchy */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  height: 46px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-surface-solid);
  border-color: var(--border-highlight);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

[data-theme="light"] .btn-ghost:hover {
  background: rgba(0, 0, 0, 0.06);
}

.btn-close {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
}

[data-theme="light"] .btn-close:hover {
  background: rgba(0, 0, 0, 0.07);
}

/* Unified Scripture Navigator Pill Button */
.scripture-nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 38px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.scripture-nav-trigger:hover {
  border-color: var(--primary);
  background: var(--bg-surface-solid);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.scripture-nav-trigger .book-icon {
  font-size: 16px;
  line-height: 1;
}

.scripture-nav-trigger .chevron-icon {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.scripture-nav-trigger[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

/* Quick Stepper Buttons (< >) */
.chapter-nav-btns {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.chapter-nav-btns .btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  border-radius: var(--radius-sm);
}

.chapter-nav-btns .btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

[data-theme="light"] .chapter-nav-btns .btn-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Select Dropdown Wrappers (Kept accessible, stylized) */
.quick-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-wrapper {
  position: relative;
  display: inline-flex;
}

.custom-select {
  appearance: none;
  -webkit-appearance: none;
  height: 38px;
  padding: 0 32px 0 14px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-surface-elevated) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-select:hover {
  border-color: var(--border-medium);
}

.custom-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-select-sm {
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

/* Segmented Control (Mode Switcher) */
.segmented-control {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.segmented-control-sm {
  padding: 2px;
  border-radius: var(--radius-md);
}

.segmented-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-sub);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.segmented-control-sm .segmented-btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.segmented-btn:hover {
  color: var(--text-main);
}

.segmented-btn.active {
  background: var(--bg-surface-solid);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .segmented-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Search Trigger Button */
.btn-search-trigger {
  gap: 10px;
  padding: 0 14px;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-medium);
  border-radius: var(--radius-full);
}

.btn-search-trigger:hover {
  background: var(--bg-surface-solid);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.shortcut-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--text-sub);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .shortcut-badge {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.06);
}

/* =============================================================================
   5. 圣经双译本研读器 (Bible Scripture Surface & Layout)
   ============================================================================= */

.scripture-viewport {
  max-width: 1200px;
  margin: 0 auto;
  transition: all var(--transition-normal);
}

/* Chapter Masthead Banner */
.chapter-header-banner {
  text-align: center;
  padding: 36px 24px 28px;
  margin-bottom: 24px;
  background: var(--reading-surface-card);
  border: 1px solid var(--reading-surface-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--reading-surface-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.chapter-header-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.6;
}

.chapter-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.testament-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
}

.total-verses-badge {
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.chapter-title {
  font-size: 30px;
  font-weight: 700;
  color: var(--reading-surface-text);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-family: var(--reader-font-serif);
}

.chapter-subtitle {
  font-size: 14px;
  color: var(--reading-surface-sub);
  max-width: 640px;
  margin: 0 auto;
}

/* Pinned Parallel Column Headers */
.parallel-column-headers {
  display: grid;
  grid-template-columns: 48px 1fr 1fr;
  gap: 24px;
  padding: 12px 20px;
  margin-bottom: 12px;
  background: var(--reading-surface-card);
  border: 1px solid var(--reading-surface-border);
  border-radius: var(--radius-lg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--reading-surface-sub);
  letter-spacing: 0.3px;
  position: sticky;
  top: 72px;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.parallel-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.parallel-col-header.col-web {
  padding-left: 12px;
  border-left: 1px solid var(--verse-divider);
}

.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tag-kjv {
  background: var(--kjv-bg);
  color: var(--kjv-accent);
}

.tag-web {
  background: var(--web-bg);
  color: var(--web-accent);
}

/* Verses Feed Container */
.verses-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 40px;
}

/* Scripture Reading Sheet */
.verse-row {
  display: grid;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
  background: transparent;
}

/* Gutter & Dual Column Grid */
.parallel-mode .verse-row {
  grid-template-columns: 48px 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.single-mode .verse-row {
  grid-template-columns: 48px 1fr;
  gap: 16px;
  align-items: start;
  max-width: var(--reader-content-max-width);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.verse-row:hover {
  background: var(--verse-hover-bg);
  border-color: var(--reading-surface-border);
}

/* Flash Highlight when Jumping to Verse */
@keyframes verseFlashHighlight {
  0% {
    background: var(--verse-highlight-bg);
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.008);
  }
  60% {
    background: var(--verse-highlight-bg);
    box-shadow: 0 0 0 1px var(--primary);
  }
  100% {
    background: transparent;
    box-shadow: none;
    transform: scale(1);
  }
}

.verse-row.verse-flash-highlight {
  animation: verseFlashHighlight 2.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: var(--radius-lg);
}

/* Verse Gutter & Numbering */
.verse-gutter {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding-top: 3px;
  user-select: none;
}

.verse-num-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--verse-gutter-color);
  opacity: 0.85;
  transition: opacity var(--transition-fast);
}

.verse-row:hover .verse-num-badge {
  opacity: 1;
}

/* Floating / Gutter Action Icons */
.btn-verse-quick-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  color: var(--reading-surface-muted);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
}

.verse-row:hover .btn-verse-quick-copy {
  opacity: 0.7;
}

.btn-verse-quick-copy:hover {
  opacity: 1 !important;
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Verse Columns & Literary Typography */
.verse-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.parallel-mode .verse-col:nth-child(3) {
  padding-left: 12px;
  border-left: 1px solid var(--verse-divider);
}

.verse-text {
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  font-family: var(--reader-font-serif);
  color: var(--reading-surface-text);
  word-break: break-word;
  text-rendering: optimizeLegibility;
}

.single-mode .verse-text {
  font-size: calc(var(--reader-font-size) + 1px);
}

/* Responsive Bible Grid on Tablets & Mobile */
@media (max-width: 900px) {
  .parallel-column-headers {
    display: none;
  }

  .parallel-mode .verse-row {
    grid-template-columns: 36px 1fr;
    gap: 12px;
    padding: 16px 12px;
    border-bottom: 1px solid var(--verse-divider);
  }

  .parallel-mode .verse-col:nth-child(3) {
    grid-column: 2;
    padding-left: 0;
    border-left: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--verse-divider);
  }
}

/* Chapter Step Cards at Footer */
.chapter-footer-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 40px;
}

.btn-card-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px 22px;
  background: var(--reading-surface-card);
  border: 1px solid var(--reading-surface-border);
  border-radius: var(--radius-xl);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.btn-card-nav:nth-child(2) {
  align-items: flex-end;
  text-align: right;
}

.btn-card-nav:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-surface-elevated);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -6px rgba(99, 102, 241, 0.2);
}

.btn-card-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-direction {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.nav-target {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--reading-surface-text);
}

/* =============================================================================
   6. 圣经目录与书卷抽屉 (Scripture Catalog Drawer)
   ============================================================================= */

.books-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 480px;
  max-width: 92vw;
  background: var(--bg-sidebar);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-right: 1px solid var(--border-medium);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.7);
  transform: translateX(-100%);
  transition: transform var(--transition-smooth);
}

.books-drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-title-group h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.drawer-title-group svg {
  color: var(--primary);
}

/* Drawer Search & Testament Tabs */
.drawer-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.filter-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
}

.filter-input::placeholder {
  color: var(--text-muted);
}

.btn-clear-filter {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.drawer-testament-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px 20px;
  gap: 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.testament-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-sub);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.testament-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.testament-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

/* Drawer Scroll Body & Book Cards */
.drawer-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-book-item {
  flex-shrink: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.drawer-book-item.active-book {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.drawer-book-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.drawer-book-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.book-btn-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.book-code-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--primary);
}

.book-btn-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Chapter Matrix Grid */
.chapter-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  padding: 12px 14px 16px;
  background: var(--bg-surface-solid);
  border-top: 1px solid var(--border-subtle);
}

.chapter-matrix-btn {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chapter-matrix-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
}

.chapter-matrix-btn.current {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* =============================================================================
   7. 全文倒排索引检索弹窗 (Spotlight / Raycast Style Modal)
   ============================================================================= */

.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 18px 24px;
  animation: modalFadeIn 200ms ease-out;
}

.search-modal-backdrop.open {
  display: flex !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.search-modal {
  width: 720px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.modal-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-search-input-wrap .search-icon {
  color: var(--primary);
  flex-shrink: 0;
}

.modal-search-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
}

.modal-search-input::placeholder {
  color: var(--text-muted);
}

.btn-clear-search {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.modal-filter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--bg-surface-elevated);
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.esc-hint {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.search-results-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 240px;
}

.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 12px;
}

.search-empty-state svg {
  opacity: 0.4;
  color: var(--primary);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-hit-card {
  padding: 14px 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-hit-card:hover {
  background: var(--bg-surface-solid);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.hit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hit-ref {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}

.hit-score {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.hit-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-sub);
  font-family: var(--reader-font-serif);
}

/* Beautiful Highlighting for Matches */
mark, .search-match {
  background: rgba(234, 179, 8, 0.28) !important;
  color: #fbbf24 !important;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

[data-theme="light"] mark, [data-theme="light"] .search-match {
  background: rgba(234, 179, 8, 0.35) !important;
  color: #b45309 !important;
}

/* =============================================================================
   8. 私有电子书阅读器 (Private E-Book Reader Experience)
   ============================================================================= */

/* Reader Top Book Title Indicator */
.reader-book-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-book-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reader Typography Popover Card */
.popover-wrapper {
  position: relative;
}

.popover-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 330px;
  padding: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg-card);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
}

.popover-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
}

.setting-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.custom-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-surface-elevated);
  accent-color: var(--primary);
  outline: none;
  cursor: pointer;
}

/* Theme Swatches (Parchment, Day, Dark) */
.theme-swatch-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.swatch-btn {
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.swatch-btn.swatch-sepia {
  background: #f5eedb;
  color: #3e3325;
  border-color: #e3d4b6;
}

.swatch-btn.swatch-light {
  background: #ffffff;
  color: #1e293b;
  border-color: rgba(0, 0, 0, 0.12);
}

.swatch-btn.swatch-dark {
  background: #090d16;
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.15);
}

.swatch-btn:hover {
  transform: scale(1.04);
}

.swatch-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.popover-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

/* Empty Dropzone Hero Card */
.reader-empty-wrapper {
  max-width: 900px;
  margin: 20px auto 60px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.dropzone-card {
  padding: 48px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-2xl);
  transition: all var(--transition-normal);
  background: var(--bg-card);
  position: relative;
}

.dropzone-card.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
  transform: scale(1.01);
}

.dropzone-icon-glow {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 6px;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.25);
  animation: pulseIcon 4s ease-in-out infinite;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.dropzone-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.dropzone-subtitle {
  font-size: 14.5px;
  color: var(--text-sub);
  max-width: 480px;
}

.supported-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 12px;
}

.format-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
}

.privacy-guarantee-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

.privacy-guarantee-note svg {
  color: var(--color-success);
}

/* Local Recent Shelf Grid */
.recent-shelf-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shelf-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.shelf-count {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

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

.shelf-book-card {
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.shelf-book-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.shelf-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shelf-card-cover {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.shelf-card-cover-placeholder {
  width: 36px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.shelf-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shelf-book-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.shelf-progress-bar-wrap {
  height: 4px;
  background: var(--bg-surface-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.shelf-progress-bar-inner {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}

.shelf-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

/* Active Book Reading Workspace */
.reader-workspace {
  display: flex;
  gap: 24px;
  position: relative;
  max-width: 1300px;
  margin: 0 auto;
}

/* TOC Sidebar & Reading Navigation */
.toc-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 14px;
  height: calc(100vh - 120px);
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.toc-sidebar.collapsed {
  display: none;
}

/* Sidebar Top Bar (Action icons) */
.sidebar-top-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.btn-sidebar-action {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-sidebar-action:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.sidebar-top-spacer {
  flex: 1;
}

/* Sidebar Book Card */
.sidebar-book-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-cover-wrap {
  width: 44px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-hover);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-cover-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-cover-fallback {
  font-size: 24px;
  opacity: 0.6;
}

.sidebar-book-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-book-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-book-author {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-book-info {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-book-info:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

/* TOC Hierarchical Tree */
.toc-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}

.toc-item-btn {
  text-align: left;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
  white-space: normal;
  line-height: 1.4;
  word-break: break-word;
  transition: all var(--transition-fast);
  display: block;
  width: 100%;
}

.toc-item-btn.toc-depth-0 {
  font-weight: 600;
  color: var(--text-main);
  padding-left: 10px;
  margin-top: 4px;
}

.toc-item-btn.toc-depth-1 {
  padding-left: 22px;
  color: var(--text-sub);
  font-size: 12.5px;
}

.toc-item-btn.toc-depth-2 {
  padding-left: 34px;
  color: var(--text-muted);
  font-size: 12px;
}

.toc-item-btn.toc-depth-3 {
  padding-left: 46px;
  color: var(--text-muted);
  font-size: 12px;
}

.toc-item-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Active item: Rounded Pill / Capsule style matching modern e-reader */
.toc-item-btn.active {
  background: rgba(99, 102, 241, 0.16) !important;
  color: var(--primary) !important;
  font-weight: 600 !important;
  border-radius: 9999px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .toc-item-btn.active,
[data-reading-theme="light"] .toc-item-btn.active {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

/* Sidebar Bottom Tab Bar */
.sidebar-bottom-tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.sidebar-tab-btn.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

/* Modal Backdrop Generic */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 200ms ease-out;
}

.modal-backdrop[hidden] {
  display: none !important;
}

/* Book Info Modal Styling */
.book-info-modal-card {
  max-width: 500px;
  width: 90%;
  padding: 24px;
}

.book-info-body {
  display: flex;
  gap: 20px;
  margin-top: 16px;
}

.book-info-cover-wrap {
  width: 110px;
  height: 154px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-info-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-info-cover-fallback {
  font-size: 40px;
  opacity: 0.5;
}

.book-info-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-info-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.book-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-subtle);
}

.info-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.info-val {
  color: var(--text-main);
  text-align: right;
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Two-column layout and image styles in Reading Paper */
.reader-paper.columns-two {
  max-width: 1400px;
  column-count: 2;
  column-gap: 56px;
  column-rule: 1px solid var(--border-subtle);
}

.reader-paper.columns-two img {
  break-inside: avoid;
}

.reader-paper.columns-two h1,
.reader-paper.columns-two h2,
.reader-paper.columns-two h3 {
  break-after: avoid;
}

/* Crisp rendering of EPUB images (code listings, diagrams, math) */
.chapter-content-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: var(--radius-sm);
  background: #ffffff; /* keeps white code snippet bitmaps crisp */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  padding: 2px;
}

.chapter-content-body svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
}

.chapter-content-body image {
  max-width: 100%;
}

/* Main Flow & Reading Paper */
.reader-flow-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reading-progress-track {
  width: 100%;
  max-width: var(--reader-content-max-width);
  height: 3px;
  background: var(--border-subtle);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.reading-progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width 150ms ease-out;
}

.reader-paper {
  width: 100%;
  max-width: var(--reader-content-max-width);
  background: var(--reading-surface-bg);
  color: var(--reading-surface-text);
  border: 1px solid var(--reading-surface-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--reading-surface-shadow);
  padding: 48px 56px;
  min-height: 70vh;
  transition: all var(--transition-normal);
}

.book-title-heading h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--verse-divider);
  font-family: var(--reader-font-serif);
}

.chapter-content-body {
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  font-family: var(--reader-font-serif);
  word-break: break-word;
}

.chapter-content-body p {
  margin-bottom: 1.3em;
  text-indent: 2em;
}

.chapter-content-body h1,
.chapter-content-body h2,
.chapter-content-body h3 {
  margin-top: 1.6em;
  margin-bottom: 0.8em;
  font-family: var(--reader-font-serif);
  line-height: 1.3;
}

/* Reader Chapter Footer Navigation */
.reader-chapter-footer {
  width: 100%;
  max-width: var(--reader-content-max-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.reading-percentage-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

/* Mobile Responsive Adjustments */
@media (max-width: 1024px) {
  .toc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    height: 100vh;
    border-radius: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .toc-sidebar.mobile-open {
    transform: translateX(0);
  }

  .toc-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.6);
    z-index: 1099;
    display: none;
  }

  .toc-backdrop.open {
    display: block !important;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 10px 12px 40px;
  }

  .view-toolbar {
    padding: 8px 12px;
  }

  .reader-paper {
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .chapter-header-banner {
    padding: 24px 16px;
  }

  .chapter-title {
    font-size: 22px;
  }
}

/* =============================================================================
   SEO Landing Section Display Toggles (Controlled by Route & Prerender)
   ============================================================================= */
.seo-landing-section {
  display: none;
}
.seo-landing-section.active {
  display: block;
}
