/* ==========================================================================
   Дизайн-система сайту «Притчі царя Соломона»
   Відповідно до design.md:
   - Варіант 1: «Царська мудрість» (#FDFBF7, #1E2538, #C5A059)
   - Варіант 2: «Книга притчей»   (#F4F0E6, #3A2E2B, #8C2D19)
   - Варіант 3: «Царська ніч»     (#111622, #EAE6DF, #D4AF37)
   ========================================================================== */

:root {
  /* Варіант 1: «Царська мудрість» (За замовчуванням) */
  --bg-primary: #FDFBF7;
  --bg-secondary: #F6F1E7;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9F6EE;
  --text-primary: #1E2538;
  --text-secondary: #47536E;
  --text-muted: #79859E;
  --accent: #C5A059;
  --accent-hover: #AF8B43;
  --accent-light: rgba(197, 160, 89, 0.15);
  --accent-glow: rgba(197, 160, 89, 0.35);
  --border-color: #E7DFCE;
  --border-accent: rgba(197, 160, 89, 0.4);
  --shadow-sm: 0 2px 8px rgba(30, 37, 56, 0.05);
  --shadow-md: 0 8px 24px rgba(30, 37, 56, 0.08);
  --shadow-lg: 0 16px 40px rgba(30, 37, 56, 0.12);
  --quote-bg: linear-gradient(135deg, #1E2538 0%, #2A344E 100%);
  --quote-text: #FDFBF7;
  --quote-accent: #E5C378;
  --highlight: rgba(197, 160, 89, 0.25);
  
  --font-serif: 'EB Garamond', 'Georgia', serif;
  --font-heading: 'Cinzel', 'Playfair Display', serif;
  --font-decor: 'Cinzel Decorative', 'Cinzel', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --verse-font-size: 1.22rem;
  --verse-line-height: 1.82;
  --container-width: 860px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Варіант 2: «Книга притчей» (М'який історичний) */
[data-theme="parchment"] {
  --bg-primary: #F4F0E6;
  --bg-secondary: #EBE4D5;
  --bg-card: #FAF7F0;
  --bg-card-hover: #EFE9DC;
  --text-primary: #3A2E2B;
  --text-secondary: #5E4E49;
  --text-muted: #8A7771;
  --accent: #8C2D19;
  --accent-hover: #6E2212;
  --accent-light: rgba(140, 45, 25, 0.12);
  --accent-glow: rgba(140, 45, 25, 0.25);
  --border-color: #DDD4C0;
  --border-accent: rgba(140, 45, 25, 0.35);
  --shadow-sm: 0 2px 8px rgba(58, 46, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(58, 46, 43, 0.09);
  --shadow-lg: 0 16px 40px rgba(58, 46, 43, 0.13);
  --quote-bg: linear-gradient(135deg, #3A2E2B 0%, #4D3B37 100%);
  --quote-text: #F4F0E6;
  --quote-accent: #E07A5F;
  --highlight: rgba(140, 45, 25, 0.2);
}

/* Варіант 3: «Царська ніч» (Темна тема) */
[data-theme="dark"] {
  --bg-primary: #10141E;
  --bg-secondary: #171D2B;
  --bg-card: #1C2335;
  --bg-card-hover: #232C42;
  --text-primary: #EDE7DD;
  --text-secondary: #B4BCCB;
  --text-muted: #7E899D;
  --accent: #D4AF37;
  --accent-hover: #E5C358;
  --accent-light: rgba(212, 175, 55, 0.15);
  --accent-glow: rgba(212, 175, 55, 0.35);
  --border-color: #2A344A;
  --border-accent: rgba(212, 175, 55, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --quote-bg: linear-gradient(135deg, #0A0D14 0%, #171D2B 100%);
  --quote-text: #FBF9F5;
  --quote-accent: #E5C358;
  --highlight: rgba(212, 175, 55, 0.25);
}

/* Font Size Scales */
[data-font-size="sm"] { --verse-font-size: 1.05rem; --verse-line-height: 1.7; }
[data-font-size="md"] { --verse-font-size: 1.22rem; --verse-line-height: 1.82; }
[data-font-size="lg"] { --verse-font-size: 1.4rem; --verse-line-height: 1.9; }
[data-font-size="xl"] { --verse-font-size: 1.6rem; --verse-line-height: 2.0; }

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-serif);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  position: relative;
}

/* Subtle Ancient Texture Overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--border-color) 0.5px, transparent 0.5px);
  background-size: 32px 32px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

/* Scroll Progress Bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3.5px;
  background: linear-gradient(90deg, var(--accent), #F3D99B, var(--accent));
  width: 0%;
  z-index: 1000;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* Header & Top Bar */
.site-header {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

.brand-icon {
  width: 36px;
  height: 36px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.brand:hover .brand-icon {
  transform: rotate(15deg) scale(1.08);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  letter-spacing: 0.05em;
  display: block;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.btn-icon:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Theme Picker Dropdown */
.theme-select-wrapper {
  position: relative;
}

.theme-btn {
  padding: 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

.theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 210px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 120;
}

.theme-dropdown.show {
  display: flex;
  animation: dropIn 0.2s ease-out;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.theme-option:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.theme-option.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  display: inline-block;
}

/* Hero Section */
.hero-section {
  padding: 48px 0 32px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--accent-light);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  border-radius: 30px;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto 24px;
  font-style: italic;
}

/* Ornamental SVG Divider */
.ornament-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px auto;
  color: var(--accent);
  opacity: 0.85;
}

.ornament-line {
  flex: 1;
  max-width: 140px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.ornament-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Featured Aphorism Card (Design Recommendation: High-status quote block) */
.featured-quote-card {
  background: var(--quote-bg);
  color: var(--quote-text);
  border: 1px solid var(--border-accent);
  border-radius: 16px;
  padding: 36px 32px;
  margin: 28px 0 44px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.quote-tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--quote-accent);
  font-weight: 600;
  margin-bottom: 14px;
}

.quote-text {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  z-index: 1;
}

.quote-author {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--quote-accent);
  letter-spacing: 0.05em;
}

.quote-actions {
  display: flex;
  gap: 8px;
}

.btn-quote-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-quote-action:hover {
  background: var(--quote-accent);
  color: #1E2538;
  border-color: var(--quote-accent);
}

/* Chapter Quick Selector Ribbon */
.chapter-nav-ribbon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
}

.chapter-ribbon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.chapter-ribbon-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: 8px;
}

.btn-pill {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-pill.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.chapters-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.chapter-chip {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.chapter-chip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.chapter-chip.active {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--accent-glow);
}

[data-theme="parchment"] .chapter-chip.active {
  color: #FFF;
}

/* Reader Toolbar */
.reader-toolbar {
  position: sticky;
  top: 69px;
  background: var(--bg-primary);
  padding: 12px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 90;
  backdrop-filter: blur(10px);
}

.current-reading-label {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-size-group {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
}

.btn-font-size {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  font-size: 0.85rem;
}

.btn-font-size.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Chapter Main Content Area */
.chapter-container {
  margin-bottom: 60px;
}

.chapter-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 48px 40px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chapter-header {
  text-align: center;
  margin-bottom: 36px;
}

.chapter-number-roman {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
  display: block;
}

.chapter-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* Verses Styling */
.verses-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.verse-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  transition: background-color 0.2s ease;
  position: relative;
}

.verse-item:hover {
  background-color: var(--accent-light);
}

.verse-number {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 26px;
  text-align: right;
  flex-shrink: 0;
  user-select: none;
}

.verse-text {
  font-family: var(--font-serif);
  font-size: var(--verse-font-size);
  line-height: var(--verse-line-height);
  color: var(--text-primary);
  flex: 1;
}

/* First verse drop cap styling */
.verse-item[data-verse="1"] .verse-text::first-letter {
  font-family: var(--font-decor);
  font-size: 2.4em;
  float: left;
  line-height: 0.85;
  margin-right: 8px;
  margin-top: 4px;
  color: var(--accent);
  font-weight: 700;
}

.verse-actions-bar {
  opacity: 0;
  visibility: hidden;
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-self: center;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.verse-item:hover .verse-actions-bar {
  opacity: 1;
  visibility: visible;
}

.btn-verse-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-verse-mini:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}

.btn-verse-mini.bookmarked {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
}

/* Chapter Bottom Navigation */
.chapter-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.btn-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-page-nav:hover:not(:disabled) {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
  transform: translateY(-2px);
}

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

/* Modals & Drawers */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.modal-card-large {
  max-width: 780px;
  max-height: 88vh;
}

/* Commentary Badge on Verses */
.btn-commentary-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-light);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-family: var(--font-heading);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 8px;
  vertical-align: middle;
  text-decoration: none;
}

.btn-commentary-badge:hover {
  background: var(--accent);
  color: #FFF !important;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px var(--accent-glow);
}

.verse-item.has-commentary-item {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}

.badge-verse-ref {
  display: inline-block;
  background: var(--accent);
  color: #FFF;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.06em;
}

/* Commentary Modal Content Typography */
.commentary-modal-body {
  padding: 28px 32px;
  overflow-y: auto;
  font-family: var(--font-serif);
}

.commentary-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.35;
}

.commentary-section-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.commentary-subtitle {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.commentary-quote {
  border-left: 3px solid var(--accent);
  padding: 14px 20px;
  margin: 18px 0 22px;
  background: var(--bg-secondary);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.commentary-divider {
  height: 1px;
  background: var(--border-color);
  margin: 24px 0;
}

.commentary-p {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.commentary-list {
  margin: 10px 0 18px 24px;
  font-size: 1.08rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.commentary-list li {
  margin-bottom: 8px;
}

.commentary-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.commentary-footer-file {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Search Modal */
.search-input-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon-inside {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

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

.search-result-item {
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

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

.search-res-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.search-res-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.search-res-text mark {
  background: var(--accent-light);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0 2px;
}

/* Bookmarks Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1050;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

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

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

.drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bookmark-item {
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  position: relative;
}

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

.bookmark-ref {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.bookmark-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Share Quote Card Preview */
.share-preview-card {
  background: var(--quote-bg);
  color: var(--quote-text);
  padding: 32px;
  border-radius: 14px;
  border: 1px solid var(--border-accent);
  text-align: center;
  margin-bottom: 20px;
}

.share-preview-text {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 16px;
}

.share-preview-cite {
  font-family: var(--font-heading);
  color: var(--quote-accent);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 20px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease-out;
}

/* Site Footer */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 36px;
  margin-top: 60px;
  text-align: center;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--accent);
}

.footer-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
  font-family: var(--font-sans);
}




/* Animations */
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.bookmarks-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ==========================================================================
   Мобільна адаптація та чутливий дизайн (Mobile Responsive & Touch UX)
   ========================================================================== */

/* Базові правила для сенсорних пристроїв */
button, a, input, select {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Планшети та компактні ноутбуки (<= 900px) */
@media (max-width: 900px) {
  :root {
    --container-width: 100%;
  }

  .container {
    padding: 0 20px;
  }

  .featured-quote-card {
    padding: 28px 24px;
  }
}

/* Смартфони та планшети (<= 768px) */
@media (max-width: 768px) {
  /* Загальні налаштування розмітки */
  .container {
    padding: 0 16px;
  }

  /* Шапка сайту */
  .site-header {
    border-bottom-width: 1px;
  }

  .header-inner {
    padding: 10px 16px;
    gap: 10px;
  }

  .brand-title {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
  }

  .brand-subtitle {
    font-size: 0.7rem;
  }

  .btn-icon {
    width: 38px;
    height: 38px;
  }

  .theme-btn {
    height: 38px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  /* Панель читання (Sticky Toolbar) */
  .reader-toolbar {
    top: 59px;
    padding: 10px 0;
    margin-bottom: 18px;
  }

  .current-reading-label {
    font-size: 1rem;
  }

  /* Hero-секція */
  .hero-section {
    padding: 32px 0 20px;
  }

  .hero-title {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
  }

  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 18px;
  }

  /* Картка афоризму */
  .featured-quote-card {
    padding: 24px 18px;
    margin: 20px 0 32px;
    border-radius: 14px;
  }

  .quote-text {
    font-size: 1.2rem;
    line-height: 1.55;
    margin-bottom: 16px;
  }

  .quote-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .quote-author {
    font-size: 0.88rem;
  }

  .quote-actions {
    display: flex;
    gap: 8px;
  }

  .btn-quote-action {
    flex: 1;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  /* Стрічка вибору глав (1-31) */
  .chapter-nav-ribbon {
    padding: 14px 16px;
    margin-bottom: 24px;
    border-radius: 12px;
  }

  .chapter-chip {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  /* Текст глав та вірші */
  .chapter-section {
    padding: 28px 16px;
    border-radius: 14px;
    margin-bottom: 28px;
  }

  .chapter-header {
    margin-bottom: 24px;
  }

  .chapter-title {
    font-size: 1.8rem;
  }

  .verses-list {
    gap: 14px;
  }

  .verse-item {
    padding: 8px 10px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .verse-item.has-commentary-item {
    padding-left: 10px;
  }

  .verse-actions-bar {
    opacity: 0.85;
    visibility: visible;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 4px;
    gap: 6px;
    border-top: 1px dashed var(--border-color);
  }

  .verse-item:hover .verse-actions-bar,
  .verse-item:active .verse-actions-bar {
    opacity: 1;
  }

  .btn-verse-mini {
    width: 32px;
    height: 32px;
  }

  .btn-commentary-badge {
    margin-top: 6px;
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  /* Навігація по главах (Prev/Next) */
  .chapter-pagination {
    margin-top: 24px;
    padding-top: 18px;
    gap: 10px;
  }

  .btn-page-nav {
    flex: 1;
    justify-content: center;
    padding: 12px 14px;
    font-size: 0.85rem;
  }

  /* Модальні вікна на мобільних */
  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-card {
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    max-width: 100%;
  }

  .modal-card-large {
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }

  .modal-header {
    padding: 16px 18px;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 18px 16px;
  }

  .search-input {
    font-size: 16px; /* Запобігає авто-зуму на iOS Safari */
    padding: 12px 14px 12px 42px;
  }

  .commentary-modal-body {
    padding: 20px 18px;
  }

  .commentary-title {
    font-size: 1.25rem;
  }

  .commentary-quote {
    font-size: 1.05rem;
    padding: 12px 14px;
  }

  .commentary-modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .commentary-footer-file {
    width: 100%;
    order: 3;
    text-align: center;
    margin-top: 4px;
  }

  #btn-prev-commentary,
  #btn-next-commentary {
    flex: 1;
    justify-content: center;
  }
}

/* Компактні смартфони (<= 480px) */
@media (max-width: 480px) {
  .header-inner {
    padding: 8px 12px;
    gap: 6px;
  }

  .brand-icon svg {
    width: 24px;
    height: 24px;
  }

  .brand-title {
    font-size: 0.98rem;
  }

  .brand-subtitle {
    display: none;
  }

  .theme-name-text {
    display: none;
  }

  .theme-btn {
    padding: 0 8px;
    gap: 4px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .reader-toolbar {
    top: 53px;
  }

  .hero-section {
    padding: 24px 0 16px;
  }

  .hero-badge {
    font-size: 0.72rem;
    padding: 4px 12px;
    margin-bottom: 12px;
  }

  .hero-title {
    font-size: 1.7rem;
  }

  .hero-subtitle {
    font-size: 0.92rem;
  }

  .chapter-ribbon-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .view-mode-toggle {
    width: 100%;
    display: flex;
  }

  .btn-pill {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
  }

  .drawer {
    width: 100%;
    max-width: 100%;
  }

  .drawer-header {
    padding: 16px;
  }

  .drawer-body {
    padding: 16px;
  }

  .footer-nav {
    flex-direction: column;
    gap: 10px;
  }
}

/* Надвисокі екрани та підтримка Safe Area для вирізів/чолок (iPhone) */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .site-header {
    padding-top: env(safe-area-inset-top);
  }

  .modal-card {
    padding-bottom: env(safe-area-inset-bottom);
  }
}


