/* Embedded Fonts for Quran & Dawat Manuscripts */
@font-face {
  font-family: 'me_quran';
  src: local('me_quran'),
       local('me_quran Regular'),
       url('/static/fonts/me_quran.ttf') format('truetype'),
       url('/fonts/me_quran.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kanz-al-Marjaan';
  src: local('Kanz-al-Marjaan'),
       local('kanz-al-marjaan'),
       local('Kanz-al-Lulu'),
       local('KMforJamea'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.woff2') format('woff2'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.ttf') format('truetype'),
       url('/static/fonts/kanz-al-marjaan.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Kanz-al-Lulu';
  src: local('Kanz-al-Lulu'),
       local('Kanz-al-Marjaan'),
       local('KMforJamea'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.woff2') format('woff2'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.ttf') format('truetype'),
       url('/static/fonts/kanz-al-marjaan.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'KMforJamea';
  src: local('KMforJamea'),
       local('Kanz-al-Marjaan'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.woff2') format('woff2'),
       url('/static/fonts/Kanz-al-Marjaan-Regular.ttf') format('truetype'),
       url('/static/fonts/KMforJamea.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-primary: #f4ecd8;
  --bg-secondary: #ede4ce;
  --bg-surface: #fdfbf7;
  --card-bg: #fdfbf7;
  --card-parchment: #fdfbf7;
  --parchment-border: #d8c7a5;
  --border-color: #d8c7a5;
  --gold-primary: #d97706;
  --gold-hover: #b45309;
  --gold-light: #c59b27;
  --blue-action: #0284c7;
  --blue-action-hover: #0369a1;
  --orange-nav: #ea580c;
  --orange-nav-hover: #c2410c;
  --green-ayah: #15803d;
  --text-main: #2c1810;
  --text-muted: #7c6853;
  --input-bg: #faf6ec;
  --font-quran: 'me_quran', 'Amiri Quran', 'Scheherazade New', 'Amiri', serif;
  --font-dawat: 'Kanz-al-Marjaan', 'Kanz-al-Lulu', 'KMforJamea', 'Scheherazade New', 'Amiri', serif;
  --font-arabic-calligraphy: 'me_quran', 'Amiri Quran', serif;
  --font-content: 'Kanz-al-Marjaan', 'Kanz-al-Lulu', 'KMforJamea', 'Scheherazade New', 'Amiri', serif;
  --font-ui: 'Outfit', sans-serif;
  --user-font-size: 20px;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-ui), var(--font-content), sans-serif;
  min-height: 100vh;
  direction: ltr;
  overflow-x: hidden;
}

/* Header */
.app-header {
  background: #ede4ce;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 24px;
  box-shadow: 0 2px 8px rgba(92, 74, 48, 0.06);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
}

/* Protected Non-Downloadable Logo Styles */
.brand-logo-img, .protected-logo {
  height: 44px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -khtml-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  pointer-events: none !important; /* Disables right-click, saving, and dragging */
}

.brand-logo i {
  font-size: 1.8rem;
  color: var(--gold-primary);
}

.brand-title {
  font-family: var(--font-ui), sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.brand-badge {
  font-size: 0.72rem;
  background: rgba(217, 119, 6, 0.15);
  color: var(--gold-primary);
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
  font-weight: 600;
}

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

.btn-nav-curriculum {
  background: #fdfbf7;
  border: 1px solid var(--border-color);
  color: var(--gold-primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-nav-curriculum:hover {
  background: #e2d5bd;
  border-color: #cbb79a;
  transform: translateY(-1px);
}

.btn-nav-player {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-hover));
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
  transition: all 0.2s ease;
}

.btn-nav-player:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-signout {
  background: #fdfbf7;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-signout:hover {
  background: #ede4ce;
  border-color: #cbb79a;
  color: #b91c1c;
}

.btn-icon {
  background: #fdfbf7;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: #ede4ce;
  color: var(--text-main);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fdfbf7;
  border: 1px solid var(--border-color);
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: #ef4444;
}

/* Main Container */
.main-content {
  max-width: 1000px;
  margin: 30px auto;
  padding: 0 20px 60px;
}

/* Hero Section */
.hero-section {
  text-align: center;
  margin-bottom: 28px;
}

.hero-title {
  font-family: var(--font-ui), sans-serif;
  font-size: 2.1rem;
  color: var(--text-main);
  margin-bottom: 8px;
  font-weight: 700;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Al-Muhaffiz Banner Card */
.muhaffiz-banner-card {
  background: linear-gradient(135deg, #ede4ce 0%, #fdfbf7 100%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px 24px;
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 20px;
  box-shadow: 0 10px 25px rgba(92, 74, 48, 0.08);
}

.muhaffiz-banner-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.muhaffiz-icon {
  font-size: 2.2rem;
  color: var(--gold-primary);
}

.muhaffiz-banner-info h3 {
  font-family: var(--font-ui), sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.muhaffiz-banner-info p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.btn-launch-player {
  background: linear-gradient(135deg, var(--gold-primary), #f59e0b);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.25);
}

.btn-launch-player:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.4);
}

/* Search Portal Card */
.search-portal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 15px 35px rgba(92, 74, 48, 0.08);
  margin-bottom: 30px;
}

/* Resize Text Slider */
.resize-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.resize-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.range-slider {
  width: 180px;
  accent-color: var(--gold-primary);
  cursor: pointer;
}

/* Mode Switcher Radio Buttons */
.mode-switcher-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  background: #ede4ce;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 18px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.radio-label input[type="radio"] {
  accent-color: var(--gold-primary);
  width: 17px;
  height: 17px;
  cursor: pointer;
}

/* Module Filter Checkboxes */
.filters-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #ede4ce;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--gold-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* View 1: Standard Search */
.search-bar-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.search-bar-wrapper .search-icon {
  position: absolute;
  left: 18px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.search-input {
  width: 100%;
  padding: 14px 145px 14px 48px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
  background: #fff;
}

.btn-clear-search {
  position: absolute;
  right: 108px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(124, 104, 83, 0.12);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
}

.btn-clear-search:hover {
  background: rgba(124, 104, 83, 0.25);
  color: var(--text-main);
}

.btn-execute-search {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-hover));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  height: calc(100% - 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.btn-execute-search:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Quick Keywords */
.quick-keywords-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.keyword-chip {
  background: #ede4ce;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.keyword-chip:hover {
  background: #e2d5bd;
  border-color: var(--gold-primary);
  color: var(--gold-hover);
}

/* View 2 & 3: Surah & Ayah / Book Wise Controls */
.surah-controls-grid, .book-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 16px;
}

.surah-controls-grid {
  grid-template-columns: 2fr 1fr;
}

.control-box label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.select-control, .input-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  font-family: var(--font-ui), var(--font-content);
}

.select-control:focus, .input-control:focus {
  border-color: var(--gold-primary);
  background: #fff;
}

.btn-primary-action {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-hover));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.25);
}

.btn-primary-action:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  transform: translateY(-1px);
}

.ayah-nav-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.btn-nav-ayah {
  padding: 12px;
  background: #ede4ce;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-nav-ayah:hover {
  background: #e2d5bd;
  border-color: var(--gold-primary);
  transform: translateY(-1px);
}

/* Results Display Container */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
  color: var(--text-muted);
}

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

.empty-state h3 {
  font-size: 1.3rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

/* Result Cards - Warm Antique Parchment Style */
.bayan-card {
  background: var(--card-parchment);
  color: var(--text-main);
  border: 1px solid var(--parchment-border);
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 10px 30px rgba(92, 74, 48, 0.08);
  animation: fadeIn 0.3s ease-out;
}

.bayan-ayah-header {
  text-align: center;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px dashed #d8c7a5;
}

.bayan-ayah-text {
  font-family: var(--font-arabic-calligraphy);
  font-size: 1.7rem;
  color: var(--green-ayah);
  line-height: 1.8;
  font-weight: 700;
}

.bayan-ayah-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Mother Card Layout */
.bayan-mother-card {
  position: relative;
}

.mother-meta-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mother-ref-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(217, 119, 6, 0.12);
  border: 1px solid rgba(217, 119, 6, 0.3);
  color: var(--gold-primary);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
}

.reference-entry-item.has-divider {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px dashed rgba(216, 199, 165, 0.6);
}

.reference-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-pill {
  background: var(--gold-primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.reference-kitab-tag {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  direction: rtl;
}

.bayan-body-text {
  font-family: var(--font-content);
  font-size: var(--user-font-size);
  line-height: 2;
  color: var(--text-main);
  text-align: justify;
  margin-bottom: 22px;
}

/* In-Text Quran Citation Highlighting */
.quran-quote-highlight {
  display: inline;
  background: rgba(217, 119, 6, 0.1);
  color: #92400e;
  border-bottom: 1.5px solid rgba(217, 119, 6, 0.5);
  padding: 0 4px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 700;
  transition: all 0.2s ease;
}

.quran-quote-highlight:hover {
  background: rgba(217, 119, 6, 0.18);
  border-bottom-color: var(--gold-primary);
  color: #78350f;
}

[data-theme="dark"] .quran-quote-highlight {
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
  border-bottom-color: #f59e0b;
}

.bayan-source-footer {
  background: #ede4ce;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Eye Toggle Button & Connected Ayah Drawer */
.btn-toggle-ayah {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.28);
  color: var(--gold-hover);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-toggle-ayah:hover {
  background: rgba(217, 119, 6, 0.2);
  border-color: var(--gold-primary);
  color: #92400e;
  transform: translateY(-1px);
}

.btn-toggle-ayah.active {
  background: var(--gold-primary);
  color: #fff;
  border-color: var(--gold-hover);
}

.connected-ayah-drawer {
  background: #faf4e6;
  border: 1px solid #d8c7a5;
  border-left: 4px solid var(--green-ayah);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 14px 0 18px;
  animation: fadeIn 0.25s ease-out;
}

.connected-ayah-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.connected-ayah-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green-ayah);
  display: flex;
  align-items: center;
  gap: 6px;
}

.connected-ayah-action {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.connected-ayah-action:hover {
  color: var(--gold-hover);
  text-decoration: underline;
}

.ayah-drawer-text {
  font-family: var(--font-arabic-calligraphy);
  font-size: 1.45rem;
  color: var(--green-ayah);
  line-height: 1.8;
  font-weight: 700;
  direction: rtl;
  text-align: justify;
}

.ayah-drawer-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  direction: rtl;
}

/* Cross Reference Cards in Search */
.cross-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.cross-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 4px 12px rgba(92, 74, 48, 0.06);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.cross-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.cross-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.cross-author {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.cross-snippet {
  font-family: var(--font-content);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* Skeleton Loading */
.skeleton-card {
  background: #ede4ce;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
}

.skeleton-line {
  height: 18px;
  background: #d8c7a5;
  border-radius: 6px;
  margin-bottom: 12px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 0.8; }
  100% { opacity: 0.4; }
}

/* Curriculum Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 24, 16, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: #fdfbf7;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  width: 100%;
  max-width: 620px;
  padding: 24px;
  box-shadow: 0 25px 50px rgba(92, 74, 48, 0.25);
  animation: fadeIn 0.25s ease-out;
}

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

/* Mobile & Tablet Responsive Architecture */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
  }

  .header-container {
    padding: 10px 14px;
    gap: 8px;
  }

  .brand-logo {
    gap: 8px;
  }

  .brand-logo i {
    font-size: 1.4rem;
  }

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

  .header-actions {
    gap: 6px;
  }

  .btn-nav-player {
    padding: 7px 11px;
    font-size: 0.8rem;
    gap: 5px;
    border-radius: 6px;
  }

  .btn-signout {
    padding: 7px 11px;
    font-size: 0.8rem;
    gap: 5px;
    border-radius: 6px;
  }

  .main-content {
    margin: 14px auto;
    padding: 0 12px 60px;
  }

  .hero-section {
    margin-bottom: 18px;
  }

  .muhaffiz-banner-card {
    flex-direction: column;
    text-align: center;
    padding: 16px 14px;
    gap: 12px;
    border-radius: 14px;
  }

  .muhaffiz-banner-info {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .muhaffiz-icon {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .muhaffiz-banner-info h3 {
    font-size: 1.1rem;
  }

  .btn-launch-player {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
    min-height: 46px;
    border-radius: 8px;
  }

  .search-portal-card {
    padding: 16px 12px;
    border-radius: 14px;
    margin-bottom: 20px;
  }

  .resize-row {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .resize-label {
    font-size: 0.82rem;
  }

  .mode-switcher-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 14px;
  }

  .radio-label {
    justify-content: center;
    padding: 9px 4px;
    font-size: 0.82rem;
    border-radius: 8px;
    text-align: center;
  }

  .radio-label input[type="radio"] {
    width: 14px;
    height: 14px;
  }

  .filter-row {
    gap: 6px;
    margin-bottom: 14px;
    justify-content: center;
  }

  .checkbox-label {
    font-size: 0.78rem;
    padding: 6px 9px;
    border-radius: 6px;
  }

  .search-bar-wrapper {
    margin-bottom: 12px;
  }

  .search-bar-wrapper .search-icon {
    left: 12px;
    font-size: 0.95rem;
  }

  .search-input {
    font-size: 16px; /* Prevents auto-zoom on mobile iOS */
    padding: 12px 115px 12px 36px;
    border-radius: 10px;
  }

  .btn-clear-search {
    right: 86px;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  .btn-execute-search {
    right: 4px;
    padding: 7px 14px;
    font-size: 0.88rem;
    border-radius: 7px;
  }

  .quick-keywords-row {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 4px 0 8px;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .quick-keywords-row::-webkit-scrollbar {
    display: none;
  }

  .quick-title {
    display: none;
  }

  .keyword-chip {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 11px;
    font-size: 0.78rem;
    border-radius: 16px;
  }

  .surah-controls-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .select-control, .input-control {
    font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 11px 12px;
    border-radius: 8px;
    min-height: 46px;
  }

  .btn-primary-action {
    padding: 12px;
    font-size: 0.95rem;
    min-height: 46px;
    border-radius: 8px;
    margin-bottom: 10px;
  }

  .ayah-nav-buttons {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .btn-nav-ayah {
    padding: 10px;
    font-size: 0.85rem;
    min-height: 44px;
    border-radius: 8px;
  }

  .bayan-card {
    padding: 16px 14px;
    border-radius: 14px;
    margin-bottom: 14px;
  }

  .bayan-ayah-text {
    font-size: 1.35rem;
    line-height: 1.75;
  }

  .bayan-body-text {
    font-size: var(--user-font-size, 17px);
    line-height: 1.85;
    margin-bottom: 16px;
  }

  .bayan-source-footer {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .cross-ref-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cross-card {
    padding: 14px 14px;
    border-radius: 12px;
  }
}
