/* ==========================================================================
   سفینۂ نعت - دیوان و بیاضِ نعت (Naat Book Design System)
   ========================================================================== */

:root {
  /* Default: Royal Emerald & Gold (زمرد سلطانی) */
  --bg-primary: #071e16;
  --bg-secondary: #0c2b20;
  --bg-card: #0f3527;
  --bg-card-hover: #144332;
  --bg-elevated: #174d39;
  --bg-overlay: rgba(5, 20, 15, 0.82);

  --text-primary: #f5f4ed;
  --text-secondary: #cfd8d2;
  --text-muted: #8fa599;

  --gold-primary: #d4af37;
  --gold-light: #f3e29f;
  --gold-dark: #aa8522;
  --gold-border: rgba(212, 175, 55, 0.35);
  --gold-glow: rgba(212, 175, 55, 0.18);

  --accent-ruby: #e63946;
  --accent-teal: #2a9d8f;

  --book-page-bg: #0e3325;
  --book-page-border: #d4af37;
  --book-text: #fdfbf7;
  --book-shadow: 0 22px 55px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(212, 175, 55, 0.25);

  --font-urdu: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaliq', 'Urdu Typesetting', serif;
  --font-arabic: 'Amiri', 'Scheherazade New', serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --reader-font-size: 24px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Theme 2: Vintage Parchment Book (قرطاسِ کہن) */
[data-theme="parchment"] {
  --bg-primary: #f3ede2;
  --bg-secondary: #e9e0ce;
  --bg-card: #ffffff;
  --bg-card-hover: #faf6ee;
  --bg-elevated: #efe5d4;
  --bg-overlay: rgba(64, 48, 30, 0.65);

  --text-primary: #271a0c;
  --text-secondary: #4a3622;
  --text-muted: #7d6851;

  --gold-primary: #9b722b;
  --gold-light: #cfa858;
  --gold-dark: #6e4e16;
  --gold-border: rgba(155, 114, 43, 0.35);
  --gold-glow: rgba(155, 114, 43, 0.12);

  --book-page-bg: #fffcf5;
  --book-page-border: #aa853c;
  --book-text: #23160a;
  --book-shadow: 0 18px 45px rgba(70, 50, 25, 0.18), 0 0 0 1px rgba(155, 114, 43, 0.3);
}

/* Theme 3: Midnight Dark Slate (شبینہ) */
[data-theme="midnight"] {
  --bg-primary: #090c14;
  --bg-secondary: #0f1523;
  --bg-card: #141b2d;
  --bg-card-hover: #1b243b;
  --bg-elevated: #222d4a;
  --bg-overlay: rgba(4, 7, 13, 0.88);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #7d8ea6;

  --gold-primary: #eab308;
  --gold-light: #fef08a;
  --gold-dark: #ca8a04;
  --gold-border: rgba(234, 179, 8, 0.3);
  --gold-glow: rgba(234, 179, 8, 0.18);

  --book-page-bg: #111726;
  --book-page-border: #eab308;
  --book-text: #ffffff;
  --book-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(234, 179, 8, 0.2);
}

/* Theme 4: Crisp Modern White (بیاضِ ناصع) */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #eef2f6;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --bg-overlay: rgba(15, 23, 42, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --gold-primary: #b45309;
  --gold-light: #d97706;
  --gold-dark: #78350f;
  --gold-border: rgba(180, 83, 9, 0.28);
  --gold-glow: rgba(180, 83, 9, 0.12);

  --book-page-bg: #ffffff;
  --book-page-border: #b45309;
  --book-text: #09101d;
  --book-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Urdu Font Variants (خطوطِ اردو کا تنوع)
   ========================================================================== */
html[data-font="nastaliq"],
[data-font="nastaliq"] {
  --font-urdu: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaliq', 'Urdu Typesetting', serif;
}

html[data-font="gulzar"],
[data-font="gulzar"] {
  --font-urdu: 'Gulzar', 'Noto Nastaliq Urdu', 'Jameel Noori Nastaliq', serif;
}

html[data-font="amiri"],
[data-font="amiri"] {
  --font-urdu: 'Amiri', 'Scheherazade New', serif;
}

html[data-font="scheherazade"],
[data-font="scheherazade"] {
  --font-urdu: 'Scheherazade New', 'Amiri', serif;
}

html[data-font="jameel"],
[data-font="jameel"] {
  --font-urdu: 'Jameel Noori Nastaliq', 'Alvi Nastaleeq', 'Noto Nastaliq Urdu', serif;
}

html[data-font="system"],
[data-font="system"] {
  --font-urdu: system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* Base Reset & Fonts */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: var(--font-urdu);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  line-height: 1.8;
  scroll-behavior: smooth;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 50% 0%, var(--gold-glow) 0%, transparent 60%),
    radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(212, 175, 55, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-primary);
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--gold-border);
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.logo-area:hover {
  transform: translateY(-1px);
}

.logo-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #121212;
  font-size: 24px;
  box-shadow: 0 4px 15px var(--gold-glow);
  border: 1px solid var(--gold-light);
}

.brand-titles h1 {
  font-family: var(--font-urdu);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--gold-primary);
  line-height: 1.6;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles .brand-subtitle {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Header Urdu Font Picker */
.header-font-control {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 3px 10px 3px 6px;
  gap: 6px;
  transition: all var(--transition-fast);
}

.header-font-control:hover {
  border-color: var(--gold-primary);
  background: var(--bg-card-hover);
  box-shadow: 0 0 12px var(--gold-glow);
}

.header-font-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.header-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-urdu);
  font-size: 0.94rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1.6;
}

.header-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-urdu);
  padding: 6px;
}

/* Buttons */
.btn {
  font-family: var(--font-urdu);
  font-size: 1.02rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.5;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  color: #102117;
  border-color: var(--gold-light);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px var(--gold-glow);
  filter: brightness(1.08);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--gold-border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-primary);
  color: var(--gold-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--gold-primary);
}

.btn-sm {
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Main Layout Container
   ========================================================================== */
.main-wrapper {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 60px;
  flex: 1;
}

/* View Switcher Containers */
.view-panel {
  display: none;
  animation: fadeIn 0.28s ease;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Book Hero & Quick Stats
   ========================================================================== */
.book-hero {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.book-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -10%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-bismillah {
  font-family: var(--font-arabic);
  font-size: 2.1rem;
  line-height: 1.4;
  color: var(--gold-primary);
  margin-bottom: 8px;
  text-shadow: 0 0 10px var(--gold-glow);
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 2.1;
  margin-bottom: 12px;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 2.3;
  max-width: 720px;
}

.hero-stats {
  display: flex;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.stat-chip {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  text-align: center;
  min-width: 105px;
}

.stat-chip-fav {
  cursor: pointer;
  transition: all var(--transition-fast);
  border-color: rgba(230, 57, 70, 0.35);
}

.stat-chip-fav:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-ruby);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.25);
}

.stat-chip-fav.active {
  background: rgba(230, 57, 70, 0.15);
  border-color: var(--accent-ruby);
  box-shadow: 0 0 12px rgba(230, 57, 70, 0.35);
}

.stat-value {
  font-family: var(--font-urdu);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold-primary);
  line-height: 1.1;
}

.stat-label {
  font-family: var(--font-urdu);
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Index Toolbar & Filters
   ========================================================================== */
.index-controls {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

.search-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: var(--gold-primary);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 12px 46px 12px 16px;
  font-family: var(--font-urdu);
  font-size: 1.1rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

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

.clear-search-btn {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
}

.clear-search-btn.active {
  display: block;
}

.filter-categories {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.category-pill {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: 30px;
  font-family: var(--font-urdu);
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.category-pill:hover {
  background: var(--bg-card-hover);
  color: var(--gold-primary);
  border-color: var(--gold-primary);
}

.category-pill.active {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  color: #0c2016;
  border-color: var(--gold-light);
  font-weight: 700;
  box-shadow: 0 2px 10px var(--gold-glow);
}

.category-pill-fav {
  border-color: rgba(230, 57, 70, 0.45);
  color: #ff9aa2;
}

.category-pill-fav:hover {
  border-color: var(--accent-ruby);
  color: #ffb4ba;
  background: rgba(230, 57, 70, 0.12);
}

.category-pill-fav.active {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #ffffff;
  border-color: #f87171;
  box-shadow: 0 2px 14px rgba(220, 38, 38, 0.45);
}

/* Favorite Heart Buttons (Cards & List items) */
.fav-btn {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

.fav-btn:hover {
  transform: scale(1.15);
  border-color: var(--accent-ruby);
  background: rgba(230, 57, 70, 0.12);
}

.fav-btn.is-fav {
  border-color: rgba(230, 57, 70, 0.6);
  background: rgba(230, 57, 70, 0.16);
  box-shadow: 0 0 10px rgba(230, 57, 70, 0.3);
}

.fav-btn:active {
  transform: scale(0.9);
}

.list-fav-btn {
  width: 28px;
  height: 28px;
  font-size: 0.88rem;
}

#headerFavBtn.active {
  background: rgba(230, 57, 70, 0.2);
  border-color: var(--accent-ruby);
  color: #ff8a93;
}

#favoriteCurrentNaatBtn.is-fav {
  border-color: var(--accent-ruby);
  color: #ff8a93;
  background: rgba(230, 57, 70, 0.15);
  box-shadow: 0 0 10px rgba(230, 57, 70, 0.25);
}

/* ==========================================================================
   Book Index Grid / Table of Contents
   ========================================================================== */
.index-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.index-section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.index-section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.index-section-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* View Mode Switcher Toggle */
.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.view-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-urdu);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  line-height: 1.5;
}
.view-toggle-btn:hover {
  color: var(--gold-primary);
}
.view-toggle-btn.active {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  color: #0c2016;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--gold-glow);
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

/* Book Index List View (صرف عنوانات کی کتابی فہرست) */
.index-grid.view-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-list-item {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.book-list-item::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: var(--gold-primary);
  transition: width var(--transition-fast);
}

.book-list-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-primary);
  transform: translateX(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 10px var(--gold-glow);
}
.book-list-item:hover::before {
  width: 7px;
}

.list-item-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.list-item-page {
  font-family: var(--font-urdu);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold-primary);
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  padding: 2px 10px;
  border-radius: 16px;
  white-space: nowrap;
}

.list-item-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.7;
  transition: color var(--transition-fast);
}
.book-list-item:hover .list-item-title {
  color: var(--gold-light);
}

.list-item-dots {
  flex: 1;
  border-bottom: 2px dotted rgba(212, 175, 55, 0.3);
  margin: 0 14px;
  min-width: 20px;
  height: 1px;
}

.list-item-action {
  color: var(--gold-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.book-list-item:hover .list-item-action {
  color: var(--gold-light);
  transform: translateX(-3px);
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.book-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--gold-primary), var(--gold-dark));
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: width var(--transition-fast);
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-primary);
  background: var(--bg-card-hover);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 15px var(--gold-glow);
}

.book-card:hover::before {
  width: 8px;
}

.card-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.card-page-badge {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  color: var(--gold-primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.card-category-badge {
  background: rgba(42, 157, 143, 0.18);
  color: #0a0a0a;
  border: 1px solid rgba(42, 157, 143, 0.35);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.85;
  margin-bottom: 8px;
  transition: color var(--transition-fast);
}

.book-card:hover .card-title {
  color: var(--gold-light);
}

.card-poet {
  font-size: 0.98rem;
  color: var(--gold-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
}

.card-excerpt {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 2.15;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--gold-dark);
  margin-bottom: 14px;
  white-space: pre-line;
  opacity: 0.92;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(212, 175, 55, 0.15);
  padding-top: 12px;
  margin-top: auto;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.card-verse-count {
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 1rem;
  transition: color var(--transition-fast);
}

.card-action-btn:hover {
  color: var(--gold-primary);
}

.card-action-btn.delete:hover {
  color: var(--accent-ruby);
}

/* Empty State */
.empty-index-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--gold-border);
  border-radius: var(--radius-lg);
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 3.5rem;
  color: var(--gold-primary);
  margin-bottom: 14px;
}

.empty-state-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--text-muted);
  margin-bottom: 18px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Naat Reader View (دیوان / ورقِ مطالعہ)
   ========================================================================== */
.reader-container {
  max-width: 900px;
  margin: 0 auto;
}

/* Reader Navigation Top Bar */
.reader-top-bar {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.reader-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-indicator-pill {
  font-family: var(--font-urdu);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-primary);
  background: var(--bg-primary);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--gold-border);
  white-space: nowrap;
}

.reader-tools-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.font-size-control {
  display: inline-flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.font-size-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-urdu);
  font-size: 0.95rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.font-size-btn:hover {
  background: var(--bg-card-hover);
  color: var(--gold-primary);
}

.font-family-select {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  color: var(--text-primary);
  font-family: var(--font-urdu);
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

/* ==========================================================================
   The Book Page (ورقِ بیاض)
   ========================================================================== */
.book-page-canvas {
  background: var(--book-page-bg);
  border: 2px solid var(--book-page-border);
  border-radius: var(--radius-lg);
  padding: 45px 50px 60px;
  box-shadow: var(--book-shadow);
  position: relative;
  overflow: hidden;
  color: var(--book-text);
  min-height: 600px;
  transition: background var(--transition-normal), color var(--transition-normal);
}

/* Illuminated Book Corner Ornaments */
.corner-ornament {
  position: absolute;
  width: 48px;
  height: 48px;
  pointer-events: none;
  opacity: 0.8;
}

.corner-ornament svg {
  width: 100%;
  height: 100%;
  fill: var(--gold-primary);
}

.corner-top-right {
  top: 10px;
  right: 10px;
}

.corner-top-left {
  top: 10px;
  left: 10px;
  transform: rotate(-90deg);
}

.corner-bottom-right {
  bottom: 10px;
  right: 10px;
  transform: rotate(90deg);
}

.corner-bottom-left {
  bottom: 10px;
  left: 10px;
  transform: rotate(180deg);
}

/* Inner decorative frame line */
.book-page-canvas::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  bottom: 14px;
  border: 1px solid var(--gold-border);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}

/* Page Header */
.page-bismillah {
  font-family: var(--font-arabic);
  font-size: 2.6rem;
  line-height: 1.35;
  color: var(--gold-primary);
  text-align: center;
  margin-bottom: 16px;
  text-shadow: 0 0 16px var(--gold-glow);
}

.page-header-block {
  text-align: center;
  margin-bottom: 34px;
  position: relative;
  padding-bottom: 24px;
}

.page-header-block::after {
  content: "✤ ❦ ✤";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold-primary);
  font-size: 1.1rem;
  letter-spacing: 6px;
}

.reader-naat-title {
  font-family: var(--font-urdu);
  font-size: 2.15rem;
  font-weight: 700;
  color: var(--gold-primary);
  line-height: 1.45;
  margin-bottom: 10px;
}

.reader-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.reader-poet-badge {
  font-size: 1.15rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reader-poet-badge span {
  color: var(--gold-light);
  font-weight: 700;
}

.reader-category-pill {
  font-size: 0.9rem;
  padding: 3px 12px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold-border);
  color: var(--gold-primary);
  border-radius: 20px;
}

/* Audio Player Embed if available */
.reader-audio-section {
  max-width: 520px;
  margin: 0 auto 28px;
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-audio-section audio {
  width: 100%;
  height: 36px;
}

/* Lyrics Verses Display */
.lyrics-body {
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
  font-size: var(--reader-font-size);
  line-height: 2.2;
}

/* Poetic Sher (Couplet) Layout */
.verse-couplet {
  padding: 16px 14px;
  margin-bottom: 20px;
  position: relative;
  transition: transform var(--transition-fast), background var(--transition-fast);
  border-radius: var(--radius-md);
}

.verse-couplet:hover {
  background: rgba(212, 175, 55, 0.05);
}

.misra-line {
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 4px 0;
  display: block;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.verse-separator {
  color: var(--gold-primary);
  font-size: 0.95rem;
  opacity: 0.65;
  margin: 16px auto 4px;
  user-select: none;
}

/* Page Footer Finish */
.page-finisher {
  text-align: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px dashed var(--gold-border);
  color: var(--gold-primary);
  font-size: 1.1rem;
}

/* Reader Bottom Turn-Page Bar */
.reader-bottom-nav {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-turn-btn {
  flex: 1;
  max-width: 240px;
  padding: 12px 20px;
  font-size: 1.05rem;
}

/* ==========================================================================
   Modals (Add Naat / Edit Naat / Backup)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.22s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--gold-border);
  overflow: hidden;
  position: relative;
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gold-border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overscroll-behavior: contain;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-helper {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-input,
.form-select {
  width: 100%;
  min-height: 48px;
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font-urdu);
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.form-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-urdu);
  font-size: 1.15rem;
  line-height: 2.3;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.quick-poet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.quick-tag-chip {
  background: var(--bg-primary);
  border: 1px solid var(--gold-border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-tag-chip:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: var(--bg-card);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gold-border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.28);
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  color: var(--text-primary);
  font-family: var(--font-urdu);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: slideInUp 0.25s ease, fadeOut 0.3s ease 3.2s forwards;
  max-width: 380px;
}

.toast.toast-success {
  border-color: #10b981;
}

.toast.toast-error {
  border-color: #ef4444;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ==========================================================================
   Fullscreen Mehfil Mode
   ========================================================================== */
body.fullscreen-reading .site-header,
body.fullscreen-reading .book-hero,
body.fullscreen-reading .reader-bottom-nav,
body.fullscreen-reading .site-footer {
  display: none !important;
}

body.fullscreen-reading .main-wrapper {
  max-width: 100%;
  padding: 10px;
}

body.fullscreen-reading .book-page-canvas {
  min-height: 94vh;
  box-shadow: none;
  border-radius: 0;
}

/* ==========================================================================
   Print Stylesheet
   ========================================================================== */
@media print {

  .site-header,
  .reader-top-bar,
  .reader-bottom-nav,
  .site-footer,
  .book-hero,
  .index-controls,
  .toast-container {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .main-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .book-page-canvas {
    border: 2px solid #000000 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 20px !important;
  }

  .lyrics-body {
    font-size: 20pt !important;
    line-height: 2.2 !important;
  }

  .misra-line {
    color: #000000 !important;
  }
}

/* ==========================================================================
   Mobile-Friendly & Responsive Design System
   ========================================================================== */

/* Touch Ergonomics & Tap Enhancements */
button, input, select, textarea, .book-card, .book-list-item, .category-pill, .quick-tag-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile Swipe Hint */
.mobile-swipe-hint {
  display: none;
  text-align: center;
  font-family: var(--font-urdu);
  font-size: 0.82rem;
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.08);
  border: 1px dashed var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  margin-bottom: 12px;
  animation: pulseSubtle 3s infinite;
}

@keyframes pulseSubtle {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.01); }
}

/* Mobile Circular Floating Action Button (FAB) */
.mobile-fab-btn {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 18px;
  z-index: 95;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  color: #0c2016;
  border: 2px solid var(--gold-light);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5), 0 0 16px var(--gold-glow);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.mobile-fab-btn:hover {
  transform: translateY(-2px) scale(1.05);
  filter: brightness(1.1);
}

.mobile-fab-btn:active {
  transform: scale(0.92);
}

.mobile-fab-btn .fab-plus {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  margin-top: -3px;
}

.mobile-fab-btn .fab-label {
  display: none;
}

/* Page Turn Swipe Animations */
.page-turn-anim-left {
  animation: pageTurnLeft 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.page-turn-anim-right {
  animation: pageTurnRight 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes pageTurnLeft {
  0% { opacity: 0.25; transform: translateX(-20px) scale(0.98); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes pageTurnRight {
  0% { opacity: 0.25; transform: translateX(20px) scale(0.98); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* --------------------------------------------------------------------------
   Tablet & Medium Screens (<= 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .header-container {
    padding: 10px 18px;
  }

  .main-wrapper {
    padding: 20px 16px 50px;
  }

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

  .book-hero {
    padding: 22px 24px;
    gap: 20px;
  }

  .hero-title {
    font-size: 1.75rem;
    line-height: 1.9;
  }
}

/* --------------------------------------------------------------------------
   Mobile Viewports (<= 768px & <= 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .mobile-swipe-hint {
    display: block;
  }

  .mobile-fab-btn {
    display: flex;
  }

  body.reader-mode .mobile-fab-btn,
  #readerView.active ~ .mobile-fab-btn {
    display: none !important;
  }

  .hide-on-mobile {
    display: none !important;
  }

  /* Header */
  .site-header {
    padding-top: max(0px, env(safe-area-inset-top));
  }

  .header-container {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: hidden;
  }

  .logo-area {
    gap: 8px;
    flex-shrink: 0;
  }

  .logo-icon-wrap {
    width: 36px;
    height: 36px;
    font-size: 19px;
    border-radius: 9px;
  }

  .brand-titles h1 {
    font-size: 1.2rem;
    line-height: 1.35;
  }

  .brand-titles .brand-subtitle {
    display: none;
  }

  .header-actions {
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
  }

  /* Hide verbose text labels in mobile header buttons */
  .header-action-btn .btn-text,
  .header-add-btn .btn-text {
    display: none;
  }

  .header-action-btn,
  .header-add-btn {
    padding: 6px 9px;
    min-height: 34px;
    font-size: 0.88rem;
    gap: 3px;
  }

  /* Main Wrapper */
  .main-wrapper {
    padding: 12px 10px 60px;
  }

  /* Hero Section */
  .book-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 14px;
    margin-bottom: 14px;
    gap: 12px;
    border-radius: var(--radius-md);
  }

  .hero-bismillah {
    font-size: 1.5rem;
    margin-bottom: 3px;
    text-align: center;
  }

  .hero-title {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 6px;
    text-align: center;
  }

  .hero-desc {
    font-size: 0.88rem;
    line-height: 1.8;
    text-align: center;
    opacity: 0.9;
    margin-bottom: 4px;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
  }

  .stat-chip {
    min-width: auto;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
  }

  .stat-value {
    font-size: 1.35rem;
    line-height: 1.15;
  }

  .stat-label {
    font-size: 0.74rem;
    white-space: nowrap;
  }

  /* Search & Category Toolbar */
  .index-controls {
    padding: 12px 12px;
    margin-bottom: 14px;
    gap: 10px;
    border-radius: var(--radius-md);
  }

  .search-bar-row {
    gap: 8px;
    width: 100%;
  }

  .search-input-wrap {
    width: 100%;
  }

  .search-input {
    font-size: 0.98rem;
    padding: 9px 38px 9px 12px;
    min-height: 42px;
    border-radius: var(--radius-sm);
  }

  .search-icon {
    font-size: 0.95rem;
    right: 12px;
  }

  .filter-categories {
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-categories::-webkit-scrollbar {
    display: none;
  }

  .category-pill {
    font-size: 0.85rem;
    padding: 5px 12px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
  }

  /* Section Title & View Toggle */
  .index-section-header {
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .index-section-title {
    font-size: 1.12rem;
    white-space: nowrap;
  }

  .index-section-subtitle {
    display: none;
  }

  .view-mode-toggle {
    flex-shrink: 0;
    padding: 2px;
  }

  .view-toggle-btn {
    font-size: 0.8rem;
    padding: 3px 8px;
  }

  /* Cards Grid */
  .index-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .book-card {
    padding: 14px 12px;
    border-radius: var(--radius-md);
  }

  .card-title {
    font-size: 1.2rem;
    line-height: 1.6;
  }

  .card-poet {
    font-size: 0.88rem;
    margin-bottom: 6px;
  }

  .card-excerpt {
    font-size: 0.95rem;
    line-height: 1.95;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  .card-footer {
    padding-top: 8px;
  }

  .card-actions {
    gap: 6px;
  }

  .card-action-btn {
    padding: 5px 8px;
    min-height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(212, 175, 55, 0.08);
  }

  /* List of Titles View on Mobile */
  .book-list-item {
    padding: 10px 12px;
    gap: 8px;
  }

  .list-item-title {
    font-size: 1.1rem;
    line-height: 1.5;
  }

  .list-item-dots {
    display: none;
  }

  .list-item-page {
    font-size: 0.8rem;
    padding: 2px 7px;
  }

  /* Reader View Top Bar */
  .reader-top-bar {
    padding: 8px 10px;
    margin-bottom: 12px;
    gap: 8px;
    border-radius: var(--radius-md);
  }

  .reader-nav-group {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  .reader-nav-group .btn {
    padding: 5px 9px;
    min-height: 34px;
    font-size: 0.85rem;
  }

  .page-indicator-pill {
    font-size: 0.82rem;
    padding: 3px 9px;
  }

  .reader-tools-group {
    width: 100%;
    justify-content: space-between;
    gap: 5px;
    padding-top: 7px;
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .reader-tools-group::-webkit-scrollbar {
    display: none;
  }

  .reader-tools-group .btn-text {
    display: none;
  }

  .reader-tools-group .btn {
    padding: 5px 8px;
    min-height: 32px;
    font-size: 0.85rem;
  }

  .font-size-btn {
    padding: 4px 7px;
    font-size: 0.85rem;
  }

  .font-family-select {
    padding: 4px 6px;
    font-size: 0.8rem;
    max-width: 95px;
  }

  /* Book Page Canvas on Mobile */
  .book-page-canvas {
    padding: 22px 12px 30px;
    border-radius: 12px;
    min-height: 420px;
    border-width: 1.5px;
  }

  .corner-ornament {
    width: 22px;
    height: 22px;
  }

  .corner-top-right,
  .corner-top-left {
    top: 6px;
  }
  .corner-top-right { right: 6px; }
  .corner-top-left { left: 6px; }

  .corner-bottom-right,
  .corner-bottom-left {
    bottom: 6px;
  }
  .corner-bottom-right { right: 6px; }
  .corner-bottom-left { left: 6px; }

  .book-page-canvas::before {
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 8px;
  }

  .page-bismillah {
    font-size: 1.7rem;
    margin-bottom: 8px;
  }

  .page-header-block {
    margin-bottom: 18px;
    padding-bottom: 14px;
  }

  .reader-naat-title {
    font-size: 1.35rem;
    line-height: 1.5;
    margin-bottom: 6px;
  }

  .reader-meta-row {
    gap: 6px;
  }

  .reader-poet-badge {
    font-size: 0.9rem;
  }

  .reader-category-pill {
    font-size: 0.78rem;
    padding: 2px 7px;
  }

  .lyrics-body {
    max-width: 100%;
    font-size: 20px;
    line-height: 2.15;
  }

  .verse-couplet {
    padding: 8px 2px;
    margin-bottom: 12px;
  }

  .misra-line {
    word-break: normal;
    overflow-wrap: break-word;
    margin: 3px 0;
  }

  .verse-separator {
    font-size: 0.78rem;
    margin: 8px auto 2px;
  }

  .page-finisher {
    margin-top: 22px;
    padding-top: 14px;
    font-size: 0.92rem;
  }

  /* Audio player */
  .reader-audio-section {
    padding: 8px 10px;
    margin-bottom: 16px;
  }

  /* Reader Bottom Turn-Page Bar */
  .reader-bottom-nav {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
  }

  .page-turn-btn {
    flex: 1;
    min-width: 110px;
    max-width: none;
    padding: 9px 10px;
    font-size: 0.9rem;
  }

  .reader-bottom-nav .btn-primary {
    width: 100%;
    order: 3;
    margin-top: 4px;
    padding: 9px;
    font-size: 0.9rem;
  }

  /* Modals as Mobile Bottom-Sheet */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
  }

  .modal-header {
    padding: 12px 14px;
  }

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

  .modal-body {
    padding: 12px 14px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent iOS zoom on inputs */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important;
    min-height: 42px;
    padding: 8px 10px;
  }

  .form-textarea {
    min-height: 115px;
  }

  .quick-poet-tags {
    gap: 4px;
  }

  .quick-tag-chip {
    font-size: 0.78rem;
    padding: 3px 7px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
  }

  .modal-footer {
    padding: 10px 14px;
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1;
    min-height: 42px;
    padding: 7px 12px;
    font-size: 0.95rem;
  }

  /* Toasts */
  .toast-container {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    font-size: 0.92rem;
    padding: 9px 12px;
  }
}

/* --------------------------------------------------------------------------
   Narrow Mobile Screens (<= 640px) - Specifically Addressing the 638px issue
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Hide Font Control in header on mobile (already present in reader view) */
  .header-font-control {
    display: none !important;
  }

  /* Hide redundant "+ نیا کلام" inside search bar row (FAB provides primary thumb action) */
  .search-add-btn {
    display: none !important;
  }

  /* Hide header '+' button on mobile screens (circular FAB at bottom-left provides this) */
  .header-add-btn {
    display: none !important;
  }

  /* Hide English sub-label and long subtitle on mobile */
  .index-title-en,
  .index-section-subtitle {
    display: none !important;
  }

  /* Ensure header actions never overflow */
  .header-actions {
    gap: 4px;
  }

  .header-action-btn {
    padding: 5px 8px;
    min-height: 32px;
    font-size: 0.85rem;
  }

  .logo-icon-wrap {
    width: 32px;
    height: 32px;
    font-size: 17px;
    border-radius: 8px;
  }

  .brand-titles h1 {
    font-size: 1.12rem;
  }

  .reader-nav-group .btn-text {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Extra Small Phones & Ultra-Narrow Viewports (<= 360px, down to 300px)
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .header-container {
    padding: 6px 8px;
    gap: 4px;
  }

  .logo-icon-wrap {
    width: 28px;
    height: 28px;
    font-size: 15px;
    border-radius: 7px;
  }

  .brand-titles h1 {
    font-size: 1.05rem;
  }

  .header-actions {
    gap: 3px;
  }

  .header-action-btn {
    padding: 4px 6px;
    min-height: 28px;
    font-size: 0.8rem;
  }

  /* Main wrapper */
  .main-wrapper {
    padding: 8px 6px 70px;
  }

  /* Hero Section */
  .book-hero {
    padding: 12px 8px;
    margin-bottom: 10px;
    border-radius: 10px;
  }

  .hero-bismillah {
    font-size: 1.35rem;
    margin-bottom: 2px;
  }

  .hero-title {
    font-size: 1.08rem;
    line-height: 1.45;
    margin-bottom: 4px;
  }

  .hero-desc {
    font-size: 0.8rem;
    line-height: 1.6;
    margin-bottom: 8px;
  }

  .hero-stats {
    gap: 3px;
  }

  .stat-chip {
    padding: 4px 2px;
    border-radius: 6px;
  }

  .stat-value {
    font-size: 1.15rem;
    line-height: 1.1;
  }

  .stat-label {
    font-size: 0.66rem;
    letter-spacing: -0.2px;
  }

  /* Search & Filters */
  .index-controls {
    padding: 10px 8px;
    margin-bottom: 12px;
  }

  .search-input {
    font-size: 0.88rem;
    padding: 8px 30px 8px 8px;
    min-height: 38px;
  }

  .search-icon {
    font-size: 0.82rem;
    right: 8px;
  }

  .category-pill {
    font-size: 0.78rem;
    padding: 4px 9px;
    min-height: 28px;
  }

  /* Index Section Header: Stack into 2 clean rows */
  .index-section-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    margin-bottom: 10px !important;
  }

  .index-section-title-wrap {
    text-align: center;
    align-items: center;
  }

  .index-section-title {
    font-size: 1.05rem !important;
    justify-content: center !important;
  }

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

  .view-toggle-btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 4px 6px !important;
    font-size: 0.78rem !important;
  }

  /* Cards */
  .book-card {
    padding: 10px 8px;
    border-radius: 10px;
  }

  .card-title {
    font-size: 1.1rem;
    line-height: 1.5;
  }

  .card-poet {
    font-size: 0.82rem;
  }

  .card-excerpt {
    font-size: 0.86rem;
    line-height: 1.85;
    padding: 6px 8px;
  }

  .card-action-btn {
    padding: 4px 6px;
    min-height: 28px;
    font-size: 0.8rem;
  }

  /* Circular FAB */
  .mobile-fab-btn {
    width: 42px;
    height: 42px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 10px;
  }

  .mobile-fab-btn .fab-plus {
    font-size: 1.4rem;
  }

  /* Reader View Top Bar */
  .reader-top-bar {
    padding: 6px 6px;
    gap: 5px;
  }

  .reader-nav-group .btn {
    padding: 4px 6px;
    min-height: 28px;
    font-size: 0.78rem;
  }

  .page-indicator-pill {
    font-size: 0.74rem;
    padding: 2px 6px;
  }

  .reader-tools-group {
    gap: 3px;
    padding-top: 5px;
  }

  .reader-tools-group .btn {
    padding: 4px 5px;
    min-height: 26px;
    font-size: 0.78rem;
  }

  .font-size-btn {
    padding: 3px 5px;
    font-size: 0.76rem;
  }

  .font-family-select {
    padding: 2px 4px;
    font-size: 0.72rem;
    max-width: 75px;
  }

  /* Canvas */
  .book-page-canvas {
    padding: 16px 6px 22px;
    border-radius: 8px;
    min-height: 380px;
  }

  .corner-ornament {
    width: 16px;
    height: 16px;
  }

  .book-page-canvas::before {
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border-radius: 6px;
  }

  .page-bismillah {
    font-size: 1.4rem;
    margin-bottom: 4px;
  }

  .reader-naat-title {
    font-size: 1.15rem;
    line-height: 1.45;
  }

  .reader-poet-badge {
    font-size: 0.82rem;
  }

  .reader-category-pill {
    font-size: 0.72rem;
    padding: 1px 6px;
  }

  .lyrics-body {
    font-size: 16px;
    line-height: 2;
  }

  .verse-couplet {
    padding: 5px 2px;
    margin-bottom: 8px;
  }

  .verse-separator {
    font-size: 0.7rem;
    margin: 6px auto 1px;
  }

  .mobile-swipe-hint {
    font-size: 0.72rem;
    padding: 3px 6px;
    margin-bottom: 8px;
  }

  .page-turn-btn {
    min-width: 90px;
    padding: 7px 6px;
    font-size: 0.82rem;
  }

  .reader-bottom-nav .btn-primary {
    padding: 7px;
    font-size: 0.82rem;
  }

  /* Modals */
  .modal-dialog {
    max-height: 94vh;
    border-radius: 12px 12px 0 0;
  }

  .modal-header {
    padding: 8px 10px;
  }

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

  .modal-body {
    padding: 8px 10px;
    gap: 8px;
  }

  .form-textarea {
    min-height: 90px;
  }
}

/* Footer Safe Area */
.site-footer {
  border-top: 1px solid var(--gold-border);
  background: var(--bg-secondary);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: auto;
}

.site-footer a {
  color: var(--gold-primary);
  text-decoration: none;
}