/*
 * اتجاه التصميم: محراب السكينة
 *
 * هذا الملف يغيّر الطبقة البصرية فقط: أخضر بترولي هادئ، عاجي دافئ،
 * تخطيط mobile-first يشبه التطبيق، وحدود واضحة للنص العربي.
 * لا يحتوي على أي منطق تفاعلي أو تعديلات على وظائف الموقع.
 */

:root {
  --sanctuary-ink: #173b3a;
  --sanctuary-deep: #0f2929;
  --sanctuary-teal: #145c5b;
  --sanctuary-teal-light: #287b76;
  --sanctuary-paper: #f5f1e8;
  --sanctuary-paper-strong: #fffdf8;
  --sanctuary-paper-muted: #ebe5d8;
  --sanctuary-copper: #b58b49;
  --sanctuary-copper-light: #d2af6b;
  --sanctuary-sage: #9eb5a1;
  --sanctuary-muted: #6f766f;
  --sanctuary-line: rgba(20, 92, 91, 0.14);
  --sanctuary-shadow: 0 18px 46px rgba(25, 55, 51, 0.12);
  --sanctuary-shadow-soft: 0 8px 22px rgba(25, 55, 51, 0.08);
  --sanctuary-ease: cubic-bezier(0.23, 1, 0.32, 1);
}

html {
  background: var(--sanctuary-paper);
}

body {
  --bg: var(--sanctuary-paper);
  --panel: var(--sanctuary-paper-strong);
  --panel-light: #f0ece2;
  --text: var(--sanctuary-ink);
  --gold: var(--sanctuary-teal);
  --gold-light: var(--sanctuary-teal-light);
  --gold-glow: rgba(20, 92, 91, 0.18);
  --muted: var(--sanctuary-muted);
  --accent: var(--sanctuary-sage);
  --success: #47795f;
  --shadow: var(--sanctuary-shadow);
  --radius: 22px;
  background: var(--sanctuary-paper);
  color: var(--sanctuary-ink);
  font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', sans-serif;
  letter-spacing: -0.01em;
}

body::before {
  opacity: 0.18;
  background:
    linear-gradient(180deg, rgba(245, 241, 232, 0.82), rgba(245, 241, 232, 0.97)),
    url('/manus-storage/adhkar-reference_ced78910.png') center top / cover no-repeat;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: radial-gradient(rgba(20, 92, 91, 0.18) 0.6px, transparent 0.6px);
  background-size: 14px 14px;
  mix-blend-mode: multiply;
  z-index: -1;
}

body:not(.light) {
  --bg: #102d2d;
  --panel: #173d3c;
  --panel-light: #204d4a;
  --text: #f4efe4;
  --gold: #d2af6b;
  --gold-light: #e0c184;
  --gold-glow: rgba(210, 175, 107, 0.2);
  --muted: #adc0b7;
  --accent: #779c8d;
  --success: #7bb189;
  --shadow: 0 18px 46px rgba(4, 18, 18, 0.34);
  background: var(--bg);
}

body:not(.light)::before {
  opacity: 0.22;
  background:
    linear-gradient(180deg, rgba(16, 45, 45, 0.87), rgba(16, 45, 45, 0.97)),
    url('/manus-storage/adhkar-reference_ced78910.png') center top / cover no-repeat;
}

body:not(.light)::after {
  opacity: 0.08;
  background-image: radial-gradient(rgba(224, 193, 132, 0.28) 0.6px, transparent 0.6px);
  mix-blend-mode: screen;
}

button,
a,
.azkar-card,
.dhikr-card,
.prayer-item,
.quran-ultra-wrapper,
.secondary-btn,
.counter-btn,
.social-icon {
  transition: transform 180ms var(--sanctuary-ease), border-color 180ms ease,
    background-color 180ms ease, color 180ms ease, box-shadow 180ms ease,
    opacity 180ms ease;
}

button:active,
a:active,
.azkar-card:active,
.dhikr-card:active {
  transform: scale(0.98);
}

header {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(255, 253, 248, 0.86);
  border-bottom: 1px solid var(--sanctuary-line);
  box-shadow: 0 8px 24px rgba(25, 55, 51, 0.06);
  backdrop-filter: blur(18px) saturate(125%);
}

body:not(.light) header {
  background: rgba(16, 45, 45, 0.86);
  border-bottom-color: rgba(210, 175, 107, 0.18);
}

.logo-container {
  width: auto;
  justify-content: flex-start;
  gap: 10px;
}

.logo-symbol {
  width: 50px;
  height: 50px;
}

.logo-image,
.loader-logo-img,
.loading-logo,
.logo {
  object-fit: contain;
}

.logo-image,
.logo,
.loader-logo-img,
.loading-logo {
  filter: none !important;
  background: transparent !important;
}

nav {
  width: auto;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

nav::-webkit-scrollbar {
  display: none;
}

.nav-btn,
.theme-toggle,
.download-btn,
.secondary-btn {
  border: 1px solid var(--sanctuary-line);
  background: rgba(255, 253, 248, 0.74);
  color: var(--sanctuary-ink);
  border-radius: 13px;
  font-family: inherit;
  font-weight: 600;
  box-shadow: none;
}

body:not(.light) .nav-btn,
body:not(.light) .theme-toggle,
body:not(.light) .download-btn,
body:not(.light) .secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: rgba(210, 175, 107, 0.2);
}

.nav-btn {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 14px;
}

.nav-btn:hover,
.nav-btn.active,
.theme-toggle:hover,
.secondary-btn:hover {
  color: var(--sanctuary-teal);
  border-color: rgba(20, 92, 91, 0.45);
  background: rgba(20, 92, 91, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(20, 92, 91, 0.1);
}

body:not(.light) .nav-btn:hover,
body:not(.light) .nav-btn.active,
body:not(.light) .theme-toggle:hover,
body:not(.light) .secondary-btn:hover {
  color: var(--gold);
  border-color: rgba(210, 175, 107, 0.5);
  background: rgba(210, 175, 107, 0.1);
}

.nav-btn.active {
  box-shadow: inset 0 -2px 0 var(--sanctuary-teal), 0 8px 18px rgba(20, 92, 91, 0.08);
}

.theme-toggle {
  min-height: 42px;
  padding: 8px 13px;
}

main {
  position: relative;
  width: min(100% - 32px, 1240px);
  max-width: 1240px;
  padding: 14px 0 36px;
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 260px;
  margin: 14px 0 44px;
  padding: clamp(38px, 6vw, 76px) clamp(24px, 7vw, 90px);
  text-align: right;
  border: 1px solid var(--sanctuary-line);
  border-radius: 30px;
  background:
    linear-gradient(100deg, rgba(255, 253, 248, 0.94) 0%, rgba(255, 253, 248, 0.77) 52%, rgba(255, 253, 248, 0.42) 100%),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
  box-shadow: var(--sanctuary-shadow);
}

body:not(.light) .hero {
  background:
    linear-gradient(100deg, rgba(16, 45, 45, 0.95) 0%, rgba(16, 45, 45, 0.76) 55%, rgba(16, 45, 45, 0.5) 100%),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
}

.hero::before {
  content: '☾';
  position: absolute;
  top: -32px;
  left: 7%;
  z-index: -1;
  color: rgba(181, 139, 73, 0.14);
  font: 190px/1 'Amiri', serif;
  transform: rotate(-16deg);
}

.hero::after {
  right: 7%;
  width: 170px;
  height: 2px;
  background: linear-gradient(90deg, var(--sanctuary-copper), transparent);
}

.hero-title,
.section-title,
.quran-ultra-title,
.quran-ultra-main,
.quran-heading,
.quran-logo-text h3 {
  font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', sans-serif;
  letter-spacing: -0.045em;
}

.hero-title {
  max-width: 650px;
  margin-bottom: 12px;
  color: var(--sanctuary-teal);
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.35;
  font-weight: 700;
}

body:not(.light) .hero-title {
  color: var(--gold);
}

.hero-subtitle {
  max-width: 630px;
  margin: 0;
  color: var(--sanctuary-muted);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.9;
  font-style: normal;
  white-space: normal;
}

body:not(.light) .hero-subtitle {
  color: #c4d0c9;
}

.verse {
  margin-top: 18px;
  color: var(--sanctuary-copper);
  font-size: clamp(18px, 2.5vw, 23px);
  font-family: 'Amiri', serif;
  line-height: 1.8;
}

.section {
  padding: 18px 0 20px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  color: var(--sanctuary-teal);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.4;
}

.section-title::before {
  content: '';
  width: 42px;
  height: 2px;
  background: var(--sanctuary-copper);
  box-shadow: 12px 0 0 rgba(181, 139, 73, 0.2);
}

body:not(.light) .section-title {
  color: var(--gold);
}

.azkar-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 38px;
}

.azkar-card,
.dhikr-card,
.prayer-card,
.stat-item,
.instruction-card,
.tip-card {
  border: 1px solid var(--sanctuary-line);
  background: rgba(255, 253, 248, 0.76);
  box-shadow: var(--sanctuary-shadow-soft);
}

body:not(.light) .azkar-card,
body:not(.light) .dhikr-card,
body:not(.light) .prayer-card,
body:not(.light) .stat-item,
body:not(.light) .instruction-card,
body:not(.light) .tip-card {
  background: rgba(23, 61, 60, 0.82);
  border-color: rgba(210, 175, 107, 0.16);
}

.azkar-card {
  min-height: 176px;
  padding: 24px 18px 20px;
  border-radius: 22px;
  text-align: right;
  align-items: flex-start;
  justify-content: space-between;
}

.azkar-card::before {
  background: radial-gradient(circle at top left, rgba(181, 139, 73, 0.16), transparent 60%);
}

.azkar-card:hover,
.dhikr-card:hover,
.prayer-item:hover {
  transform: translateY(-5px);
  border-color: rgba(20, 92, 91, 0.38);
  box-shadow: 0 16px 30px rgba(20, 92, 91, 0.12);
}

.azkar-card.active {
  border-color: var(--sanctuary-copper);
  box-shadow: 0 14px 28px rgba(181, 139, 73, 0.14);
}

.azkar-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 0 18px;
  border-radius: 15px;
  background: rgba(20, 92, 91, 0.1);
  color: var(--sanctuary-teal);
  font-size: 26px;
}

body:not(.light) .azkar-icon {
  color: var(--gold);
  background: rgba(210, 175, 107, 0.11);
}

.azkar-title {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.55;
}

.azkar-count,
.dhikr-count {
  margin-top: auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(20, 92, 91, 0.08);
  color: var(--sanctuary-teal);
  font-size: 12px;
}

body:not(.light) .azkar-count,
body:not(.light) .dhikr-count {
  background: rgba(210, 175, 107, 0.12);
  color: var(--gold);
}

.tasbih-container {
  align-items: stretch;
  padding: 0;
}

.tasbih-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.tasbih-column {
  order: 2;
  gap: 18px;
  align-items: stretch;
}

.dhikr-selection {
  order: 1;
  padding: 22px;
  border: 1px solid var(--sanctuary-line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.58);
}

body:not(.light) .dhikr-selection {
  background: rgba(23, 61, 60, 0.6);
  border-color: rgba(210, 175, 107, 0.16);
}

.dhikr-selection h3 {
  color: var(--sanctuary-teal) !important;
  text-align: right !important;
  font-size: 17px;
}

body:not(.light) .dhikr-selection h3 {
  color: var(--gold) !important;
}

.dhikr-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dhikr-card {
  min-height: 105px;
  border-radius: 16px;
  padding: 16px 14px;
  text-align: right;
}

.dhikr-card.active {
  border-color: var(--sanctuary-copper);
  box-shadow: 0 9px 22px rgba(181, 139, 73, 0.14);
}

.dhikr-text {
  text-align: right;
  font-size: 16px;
  font-family: 'Noto Sans Arabic', sans-serif;
}

.tasbih-box {
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 330px;
  padding: 34px 24px;
  border: 1px solid rgba(181, 139, 73, 0.42);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.96), rgba(235, 229, 216, 0.85)),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover;
  box-shadow: var(--sanctuary-shadow);
}

body:not(.light) .tasbih-box {
  background:
    linear-gradient(145deg, rgba(23, 61, 60, 0.97), rgba(15, 41, 41, 0.96)),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover;
}

.tasbih-box::before {
  border-radius: 26px;
  border-color: rgba(181, 139, 73, 0.24);
  animation: none;
  inset: 10px;
  width: auto;
  height: auto;
}

.tasbih-count {
  margin-bottom: 6px;
  color: var(--sanctuary-teal);
  font-size: 68px;
  line-height: 1;
}

body:not(.light) .tasbih-count {
  color: var(--gold);
}

.current-dhikr {
  min-height: 0;
  margin: 8px 0 20px;
  padding: 8px 16px;
  border: 1px solid var(--sanctuary-line);
  background: rgba(20, 92, 91, 0.07);
  color: var(--sanctuary-teal);
  font-family: 'Amiri', serif;
}

body:not(.light) .current-dhikr {
  background: rgba(210, 175, 107, 0.1);
  color: var(--gold);
}

.tasbih-btn {
  width: 94px;
  height: 94px;
  border: 5px solid rgba(255, 253, 248, 0.74);
  background: var(--sanctuary-teal);
  box-shadow: 0 14px 28px rgba(20, 92, 91, 0.24), inset 0 0 0 1px rgba(210, 175, 107, 0.56);
  font-family: inherit;
  font-weight: 700;
}

body:not(.light) .tasbih-btn {
  border-color: rgba(16, 45, 45, 0.75);
  background: var(--gold);
  color: var(--sanctuary-deep);
}

.tasbih-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 18px 34px rgba(20, 92, 91, 0.3);
}

.tasbih-controls {
  max-width: none;
  gap: 9px;
  margin-top: 0;
}

.secondary-btn {
  min-width: 0;
  padding: 10px 14px;
  font-size: 13px;
  justify-content: center;
}

.tasbih-controls .secondary-btn {
  flex: 1 1 45%;
}

.tasbih-stats {
  max-width: none;
  gap: 9px;
  margin-top: 0;
  justify-content: stretch;
}

.stat-item {
  flex: 1 1 0;
  min-width: 0;
  padding: 13px 9px;
  border-radius: 16px;
}

.stat-value {
  color: var(--sanctuary-teal);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}

body:not(.light) .stat-value {
  color: var(--gold);
}

.stat-label {
  color: var(--sanctuary-muted);
  font-size: 11px;
}

.prayer-times-container {
  max-width: none;
  padding: 0;
}

.prayer-card {
  overflow: hidden;
  padding: clamp(18px, 4vw, 30px);
  border-radius: 26px;
  background:
    linear-gradient(100deg, rgba(255, 253, 248, 0.96), rgba(255, 253, 248, 0.83)),
    url('/manus-storage/prayer-ambient_a7839ae2.png') center / cover no-repeat;
}

body:not(.light) .prayer-card {
  background:
    linear-gradient(100deg, rgba(23, 61, 60, 0.96), rgba(15, 41, 41, 0.84)),
    url('/manus-storage/prayer-ambient_a7839ae2.png') center / cover no-repeat;
}

.prayer-header {
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom-color: var(--sanctuary-line);
}

.location-icon {
  color: var(--sanctuary-copper);
}

.location-text h3,
.hijri-date,
.prayer-name {
  color: var(--sanctuary-teal);
}

body:not(.light) .location-text h3,
body:not(.light) .hijri-date,
body:not(.light) .prayer-name {
  color: var(--gold);
}

.prayer-grid {
  gap: 12px;
}

.prayer-item {
  border-radius: 17px;
  background: rgba(20, 92, 91, 0.05);
}

body:not(.light) .prayer-item {
  background: rgba(210, 175, 107, 0.06);
}

.prayer-item.current {
  border-color: var(--sanctuary-copper);
  background: rgba(181, 139, 73, 0.1);
  box-shadow: 0 10px 22px rgba(181, 139, 73, 0.13);
}

.prayer-time {
  color: var(--sanctuary-ink);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}

body:not(.light) .prayer-time {
  color: var(--text);
}

.quran-ultra {
  margin-top: 16px;
}

.quran-ultra-wrapper {
  max-width: none;
  padding: clamp(42px, 7vw, 78px) clamp(22px, 7vw, 86px);
  border: 1px solid rgba(181, 139, 73, 0.35);
  border-radius: 28px;
  background:
    linear-gradient(100deg, rgba(255, 253, 248, 0.94), rgba(255, 253, 248, 0.76)),
    url('/manus-storage/quran-ambient_50222461.png') center / cover no-repeat;
  box-shadow: var(--sanctuary-shadow);
}

body:not(.light) .quran-ultra-wrapper {
  background:
    linear-gradient(100deg, rgba(23, 61, 60, 0.95), rgba(15, 41, 41, 0.76)),
    url('/manus-storage/quran-ambient_50222461.png') center / cover no-repeat;
}

.quran-ultra-wrapper:hover {
  transform: translateY(-5px);
  box-shadow: 0 24px 48px rgba(20, 92, 91, 0.16);
}

.quran-ultra-bg {
  opacity: 0.16;
}

.quran-ultra-bismillah,
.quran-ultra-main {
  color: var(--sanctuary-teal);
}

body:not(.light) .quran-ultra-bismillah,
body:not(.light) .quran-ultra-main {
  color: var(--gold);
}

.quran-ultra-ayah {
  color: var(--sanctuary-ink);
  animation: none;
}

body:not(.light) .quran-ultra-ayah {
  color: var(--text);
}

.quran-ultra-cta,
.quran-action,
.quran-enter-btn {
  border-radius: 14px;
  background: var(--sanctuary-teal);
  color: #fffdf8;
  box-shadow: 0 12px 24px rgba(20, 92, 91, 0.2);
  font-family: inherit;
}

body:not(.light) .quran-ultra-cta,
body:not(.light) .quran-action,
body:not(.light) .quran-enter-btn {
  background: var(--gold);
  color: var(--sanctuary-deep);
}

.download-bar {
  gap: 10px;
  padding: 10px 16px;
  background: rgba(20, 92, 91, 0.06);
  border-bottom-color: var(--sanctuary-line);
}

footer {
  margin-top: 34px;
  padding: 34px 20px 40px;
  border-top-color: var(--sanctuary-line);
}

.footer-verse {
  color: var(--sanctuary-teal);
}

body:not(.light) .footer-verse {
  color: var(--gold);
}

.social-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--sanctuary-line);
  background: rgba(20, 92, 91, 0.07);
}

.social-icon:hover {
  background: var(--sanctuary-teal);
  color: #fffdf8;
}

.scroll-top {
  width: 46px;
  height: 46px;
  background: var(--sanctuary-teal);
  box-shadow: 0 10px 24px rgba(20, 92, 91, 0.25);
}

body:not(.light) .scroll-top {
  background: var(--gold);
  color: var(--sanctuary-deep);
}

.azkar-modal {
  padding: 16px;
}

.modal-overlay {
  background: rgba(10, 34, 33, 0.72);
  backdrop-filter: blur(10px);
}

.modal-content {
  max-width: 820px;
  border: 1px solid rgba(181, 139, 73, 0.4);
  border-radius: 26px;
  background: var(--sanctuary-paper-strong);
  box-shadow: 0 24px 70px rgba(10, 34, 33, 0.28);
}

body:not(.light) .modal-content {
  background: var(--panel);
}

.modal-header {
  padding: 18px 22px;
  border-bottom-color: var(--sanctuary-line);
  background: rgba(20, 92, 91, 0.06);
}

.modal-title {
  color: var(--sanctuary-teal);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}

body:not(.light) .modal-title {
  color: var(--gold);
}

.modal-close {
  border: 1px solid var(--sanctuary-line);
  background: rgba(20, 92, 91, 0.08);
  color: var(--sanctuary-teal);
}

.modal-close:hover {
  background: var(--sanctuary-teal);
  color: #fffdf8;
}

.azkar-item {
  border: 1px solid var(--sanctuary-line);
  border-radius: 20px;
  background: rgba(245, 241, 232, 0.72);
}

body:not(.light) .azkar-item {
  background: rgba(32, 77, 74, 0.64);
}

.azkar-item.active {
  border-color: var(--sanctuary-copper);
  background: rgba(181, 139, 73, 0.08);
  box-shadow: 0 12px 26px rgba(181, 139, 73, 0.12);
}

.azkar-item-text {
  font-family: 'Amiri', serif;
}

.counter-buttons {
  width: 100%;
}

.counter-main-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(100%, 360px);
  min-height: 58px;
  padding: 11px 16px 11px 12px;
  border: 0;
  border-radius: 16px;
  background: var(--sanctuary-teal);
  color: #fffdf8;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(20, 92, 91, 0.2);
}

body:not(.light) .counter-main-btn {
  background: var(--gold);
  color: var(--sanctuary-deep);
}

.counter-main-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(20, 92, 91, 0.28);
}

.counter-main-btn .counter-label {
  flex: 1;
}

.counter-main-btn .counter-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 253, 248, 0.18);
  font-size: 17px;
}

.counter-reset-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: rgba(255, 253, 248, 0.18);
  color: inherit;
  cursor: pointer;
}

.counter-reset-icon:hover {
  background: rgba(255, 253, 248, 0.3);
  transform: rotate(-25deg);
}

.counter-progress {
  height: 7px;
  margin-top: 13px;
  background: rgba(20, 92, 91, 0.1);
}

.counter-progress-bar {
  background: linear-gradient(90deg, var(--sanctuary-teal), var(--sanctuary-copper));
}

body:not(.light) .counter-progress-bar {
  background: linear-gradient(90deg, var(--gold), #8fb7a0);
}

/* Pages inside the same app shell: mushaf.php and qubla.php. */
body:has(.reader-header),
body:has(.header) {
  background: var(--sanctuary-paper);
  color: var(--sanctuary-ink);
  font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', sans-serif;
}

body:has(.reader-header)::before,
body:has(.header)::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.15;
  background: linear-gradient(180deg, rgba(245, 241, 232, 0.9), rgba(245, 241, 232, 0.97)), url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
  pointer-events: none;
}

.reader-header,
.header {
  background: rgba(255, 253, 248, 0.86) !important;
  border-color: var(--sanctuary-line) !important;
  box-shadow: 0 8px 24px rgba(25, 55, 51, 0.06) !important;
  backdrop-filter: blur(18px) saturate(125%);
}

.logo-text,
.reader-title,
.page-title {
  color: var(--sanctuary-teal) !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

.home-btn,
.btn-control,
#startBtn,
.action-btn,
.control-btn {
  border-color: var(--sanctuary-line) !important;
  border-radius: 14px !important;
  background: var(--sanctuary-teal) !important;
  color: #fffdf8 !important;
  font-family: inherit !important;
}

.home-btn:hover,
.btn-control:hover,
#startBtn:hover,
.action-btn:hover,
.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(20, 92, 91, 0.18) !important;
}

.ayah-card,
.surah-card,
.reader-panel,
.compass-container,
#info,
.audio-notice,
.footer-content {
  border-color: var(--sanctuary-line) !important;
  border-radius: 22px !important;
  box-shadow: var(--sanctuary-shadow-soft) !important;
}

@media (max-width: 767px) {
  header {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 14px;
  }

  .logo-container {
    justify-content: flex-start;
  }

  .logo-symbol {
    width: 43px;
    height: 43px;
  }

  nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: flex-start;
    padding: 2px 0 1px;
  }

  .nav-btn {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
  }

  .theme-toggle {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 12px;
  }

  main {
    width: min(100% - 22px, 680px);
    padding-top: 8px;
  }

  .hero {
    min-height: 290px;
    margin: 8px 0 28px;
    padding: 34px 22px 28px;
    border-radius: 24px;
  }

  .hero-title {
    font-size: 29px;
  }

  .hero-subtitle {
    font-size: 15px;
    line-height: 1.85;
  }

  .verse {
    font-size: 18px;
  }

  .section-title {
    font-size: 25px;
    margin-bottom: 16px;
  }

  .azkar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .azkar-card {
    min-height: 146px;
    padding: 16px 13px 14px;
    border-radius: 18px;
  }

  .azkar-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    border-radius: 12px;
    font-size: 22px;
  }

  .azkar-title {
    font-size: 15px;
  }

  .tasbih-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .tasbih-column,
  .dhikr-selection {
    order: initial;
  }

  .tasbih-box {
    min-height: 286px;
    padding: 28px 18px;
    border-radius: 24px;
  }

  .tasbih-count {
    font-size: 62px;
  }

  .tasbih-btn {
    width: 86px;
    height: 86px;
  }

  .tasbih-stats {
    gap: 6px;
  }

  .stat-item {
    padding: 10px 5px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .dhikr-selection {
    padding: 16px;
    border-radius: 20px;
  }

  .dhikr-grid {
    gap: 8px;
  }

  .dhikr-card {
    min-height: 88px;
    padding: 12px 10px;
  }

  .dhikr-text {
    font-size: 14px;
  }

  .prayer-header {
    gap: 14px;
  }

  .prayer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .prayer-item {
    padding: 12px 8px;
  }

  .prayer-controls {
    gap: 8px;
  }

  .prayer-controls .secondary-btn {
    width: 100%;
    max-width: none;
  }

  .quran-ultra-wrapper {
    padding: 42px 20px;
    border-radius: 24px;
  }

  .quran-ultra-bismillah {
    font-size: 38px;
  }

  .quran-ultra-main {
    font-size: 28px;
  }

  .quran-ultra-ayah {
    font-size: 20px;
    line-height: 2;
  }

  .modal-content {
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
  }

  .azkar-modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-body {
    padding: 14px;
  }

  .azkar-item {
    padding: 20px 14px;
    border-radius: 18px;
  }

  .azkar-item-text {
    font-size: 20px;
    line-height: 1.9;
  }

  .modal-controls {
    gap: 8px;
  }

  .modal-btn {
    min-width: 0;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Style pass 2 — cross-page identity, crafted icon language, and app-shell hierarchy. */

.brand-lockup {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: max-content;
}

.brand-name {
  color: var(--sanctuary-teal);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-caption,
.page-name {
  color: var(--sanctuary-muted);
  font-family: 'Noto Sans Arabic', sans-serif;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
}

.page-name {
  color: var(--sanctuary-copper);
  font-size: 12px;
}

body:not(.light) .brand-name {
  color: var(--gold);
}

body:not(.light) .brand-caption,
body:not(.light) .page-name {
  color: #b8c8be;
}

.nav-icon,
.azkar-icon i,
.nav-link i,
.location-icon,
.prayer-name:first-letter {
  color: var(--sanctuary-teal);
}

body:not(.light) .nav-icon,
body:not(.light) .azkar-icon i,
body:not(.light) .nav-link i,
body:not(.light) .location-icon {
  color: var(--gold);
}

.nav-icon {
  font-size: 15px;
}

.azkar-icon i {
  font-size: 20px;
}

body:has(.quran-header) .quran-header .logo-container,
body:has(.header) .header .logo-container {
  gap: 10px;
}

body:has(.quran-header) .quran-header .logo-symbol,
body:has(.header) .header .logo {
  width: 46px;
  height: 46px;
}

body:has(.quran-header) .quran-header .logo-text,
body:has(.header) .header .logo-text {
  color: var(--sanctuary-teal) !important;
}

body:has(.quran-header) .quran-header .brand-name,
body:has(.header) .header .brand-name {
  color: var(--sanctuary-teal);
}

body:has(.quran-header) .quran-header .page-name,
body:has(.header) .header .page-name {
  color: var(--sanctuary-copper);
}

body:not(.light):has(.quran-header) .quran-header .brand-name,
body:not(.light):has(.header) .header .brand-name {
  color: var(--gold);
}

body:not(.light):has(.quran-header) .quran-header .page-name,
body:not(.light):has(.header) .header .page-name {
  color: #b8c8be;
}

body:has(.quran-header) .nav-link,
body:has(.header) .home-btn {
  color: var(--sanctuary-ink) !important;
  border-color: var(--sanctuary-line) !important;
  background: rgba(20, 92, 91, 0.045) !important;
  border-radius: 13px !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

body:has(.quran-header) .nav-link.active,
body:has(.quran-header) .nav-link:hover,
body:has(.header) .home-btn:hover {
  color: var(--sanctuary-teal) !important;
  border-color: rgba(20, 92, 91, 0.4) !important;
  background: rgba(20, 92, 91, 0.1) !important;
}

body:has(.quran-header) .quran-controls,
body:has(.quran-header) .quran-display,
body:has(.quran-header) .tafseer-panel,
body:has(.quran-header) .recitation-player {
  background: rgba(255, 253, 248, 0.82) !important;
  border-color: var(--sanctuary-line) !important;
  box-shadow: var(--sanctuary-shadow-soft) !important;
}

body:has(.quran-header) .control-label,
body:has(.quran-header) .surah-name,
body:has(.quran-header) .section-title,
body:has(.quran-header) .quran-green,
body:has(.quran-header) .ayah-number {
  color: var(--sanctuary-teal) !important;
}

body:has(.quran-header) .select-control {
  border-color: rgba(20, 92, 91, 0.32) !important;
  background: var(--sanctuary-paper-strong) !important;
  color: var(--sanctuary-ink) !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

body:has(.quran-header) .btn-control {
  background: var(--sanctuary-teal) !important;
  color: #fffdf8 !important;
  box-shadow: 0 10px 20px rgba(20, 92, 91, 0.17) !important;
}

body:has(.quran-header) .ayah-container {
  border-right-color: var(--sanctuary-copper) !important;
  background: rgba(20, 92, 91, 0.035) !important;
}

body:has(.quran-header) .ayah-number {
  background: var(--sanctuary-teal) !important;
  color: #fffdf8 !important;
  box-shadow: none !important;
}

body:has(.header) {
  overflow: hidden;
}

body:has(.header) .islamic-bg {
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(245, 241, 232, 0.9), rgba(245, 241, 232, 0.98)),
    url('/manus-storage/prayer-ambient_a7839ae2.png') center / cover no-repeat !important;
}

body:has(.header) .header {
  padding: 10px clamp(14px, 4vw, 42px) !important;
}

body:has(.header) .header-controls {
  gap: 8px !important;
}

body:has(.header) .ui {
  justify-content: center !important;
  gap: 24px !important;
  padding: 24px 18px 30px !important;
}

body:has(.header) .compass-container {
  width: min(78vw, 390px) !important;
  height: min(78vw, 390px) !important;
  background: rgba(255, 253, 248, 0.72) !important;
  border-color: rgba(20, 92, 91, 0.2) !important;
  box-shadow: var(--sanctuary-shadow) !important;
}

body:has(.header) #info {
  background: rgba(255, 253, 248, 0.86) !important;
  color: var(--sanctuary-ink) !important;
  border-color: var(--sanctuary-line) !important;
}

body:has(.header) #startBtn {
  min-height: 54px;
  padding-inline: 24px;
  background: var(--sanctuary-teal) !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

body:has(.header) .kaaba-icon {
  filter: sepia(0.2) saturate(0.7);
}

body:has(.header) .footer {
  border-color: var(--sanctuary-line) !important;
  color: var(--sanctuary-muted) !important;
}

@media (max-width: 767px) {
  .brand-name {
    font-size: 15px;
  }

  .brand-caption,
  .page-name {
    font-size: 9px;
  }

  body:has(.quran-header) .quran-header .logo-text,
  body:has(.header) .header .brand-lockup {
    display: inline-flex;
  }

  body:has(.quran-header) .quran-header .nav-links {
    gap: 5px;
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  body:has(.quran-header) .quran-header .header-content {
    flex-wrap: wrap;
    gap: 9px;
  }

  body:has(.header) .compass-container {
    width: min(84vw, 340px) !important;
    height: min(84vw, 340px) !important;
  }
}

/* Style pass 2 correction — force the shared palette above legacy light/day-mode tokens. */

body.light,
body.day-mode,
body.light.day-mode {
  --bg: var(--sanctuary-paper);
  --panel: var(--sanctuary-paper-strong);
  --panel-light: #f0ece2;
  --text: var(--sanctuary-ink);
  --gold: var(--sanctuary-teal);
  --gold-light: var(--sanctuary-teal-light);
  --gold-glow: rgba(20, 92, 91, 0.18);
  --muted: var(--sanctuary-muted);
  --accent: var(--sanctuary-sage);
  --success: #47795f;
  --shadow: var(--sanctuary-shadow);
}

body:has(.quran-header) .surah-header {
  border-bottom-color: var(--sanctuary-copper) !important;
}

body:has(.quran-header) .quran-display,
body:has(.quran-header) .quran-controls,
body:has(.quran-header) .tafseer-panel,
body:has(.quran-header) .recitation-player {
  color: var(--sanctuary-ink) !important;
}

body:has(.header) .compass-ring,
body:has(.header) #hoop,
body:has(.header) .arrow-guide,
body:has(.header) #startBtn {
  border-color: var(--sanctuary-teal) !important;
}

body:has(.header) .arrow-guide,
body:has(.header) .compass-degree,
body:has(.header) .direction-text {
  color: var(--sanctuary-teal) !important;
}

body:has(.header) .compass-needle,
body:has(.header) .qibla-line,
body:has(.header) .direction-line {
  background: var(--sanctuary-copper) !important;
}

body:has(.header) .compass-container::before,
body:has(.header) .compass-container::after {
  border-color: rgba(20, 92, 91, 0.18) !important;
}

body:has(.header) .theme-switch .switch-slider {
  border-color: rgba(20, 92, 91, 0.24) !important;
  background: rgba(20, 92, 91, 0.08) !important;
}

@media (max-width: 767px) {
  body:has(.quran-header) .quran-main {
    padding: 14px 12px 28px;
  }

  body:has(.quran-header) .quran-controls {
    gap: 10px;
    padding: 14px;
  }
}

/* Mobile app shell — same controls, thumb-friendly placement, no behavior changes. */
@media (max-width: 767px) {
  body {
    padding-bottom: 84px;
  }

  header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
  }

  header nav {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 1100;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    padding: 7px;
    overflow-x: auto;
    border: 1px solid rgba(20, 92, 91, 0.16);
    border-radius: 22px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 0 14px 34px rgba(15, 41, 41, 0.18);
    backdrop-filter: blur(18px) saturate(135%);
  }

  body:not(.light) header nav {
    border-color: rgba(210, 175, 107, 0.2);
    background: rgba(16, 45, 45, 0.94);
  }

  header nav .nav-btn,
  header nav .theme-toggle {
    display: inline-flex;
    flex: 1 0 58px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 6px 4px;
    border: 0;
    border-radius: 15px;
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
  }

  header nav .nav-icon {
    font-size: 15px;
  }

  header nav .nav-btn.active {
    box-shadow: inset 0 -2px 0 var(--sanctuary-teal);
  }

  header nav .theme-toggle .theme-icon {
    font-size: 15px;
    line-height: 1;
  }

  header .download-bar {
    order: 3;
    width: 100%;
    padding: 8px 0 0;
    border: 0;
    background: transparent;
  }

  header .download-bar .download-btn {
    padding: 7px 11px;
    font-size: 11px;
  }
}

/*
 * Final correction: original night palette + true mobile app shell.
 * The existing behavior, handlers, URLs, and storage logic remain untouched.
 */

/* Original night palette — kept exact by user request. */
body:not(.light):not(.day-mode) {
  --bg: #0A0F1E;
  --panel: #101730;
  --panel-light: #1A2342;
  --text: #EFEBDD;
  --gold: #D4AF37;
  --gold-light: #E6C158;
  --gold-glow: rgba(212, 175, 55, 0.3);
  --muted: #9b927f;
  --accent: #3A506B;
  --success: #2E8B57;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  background: #0A0F1E;
}

body:not(.light):not(.day-mode)::before {
  opacity: 0.16;
  background:
    radial-gradient(circle at 20% 30%, rgba(20, 30, 70, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(212, 175, 55, 0.07) 0%, transparent 30%),
    linear-gradient(180deg, rgba(10, 15, 30, 0.94), rgba(10, 15, 30, 0.98)),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
}

body:not(.light):not(.day-mode) header {
  background: rgba(10, 15, 30, 0.95);
  border-bottom-color: rgba(212, 175, 55, 0.2);
}

body:not(.light):not(.day-mode) .brand-name,
body:not(.light):not(.day-mode) .section-title,
body:not(.light):not(.day-mode) .hero-title,
body:not(.light):not(.day-mode) .nav-icon,
body:not(.light):not(.day-mode) .azkar-icon i,
body:not(.light):not(.day-mode) .footer-verse,
body:not(.light):not(.day-mode) .modal-title,
body:not(.light):not(.day-mode) .quran-ultra-main,
body:not(.light):not(.day-mode) .quran-ultra-bismillah {
  color: #D4AF37;
}

body:not(.light):not(.day-mode) .brand-caption,
body:not(.light):not(.day-mode) .page-name,
body:not(.light):not(.day-mode) .hero-subtitle,
body:not(.light):not(.day-mode) .stat-label,
body:not(.light):not(.day-mode) .footer-text {
  color: #9b927f;
}

body:not(.light):not(.day-mode) .nav-btn,
body:not(.light):not(.day-mode) .theme-toggle,
body:not(.light):not(.day-mode) .download-btn,
body:not(.light):not(.day-mode) .secondary-btn {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
  border-color: rgba(212, 175, 55, 0.2);
  color: #EFEBDD;
}

body:not(.light):not(.day-mode) .nav-btn:hover,
body:not(.light):not(.day-mode) .nav-btn.active,
body:not(.light):not(.day-mode) .theme-toggle:hover,
body:not(.light):not(.day-mode) .secondary-btn:hover {
  color: #D4AF37;
  border-color: #D4AF37;
  background: rgba(212, 175, 55, 0.2);
  box-shadow: 0 3px 10px rgba(212, 175, 55, 0.3);
}

body:not(.light):not(.day-mode) .nav-btn.active {
  box-shadow: inset 0 -2px 0 #D4AF37, 0 3px 10px rgba(212, 175, 55, 0.3);
}

body:not(.light):not(.day-mode) .hero,
body:not(.light):not(.day-mode) .tasbih-box,
body:not(.light):not(.day-mode) .quran-ultra-wrapper {
  background:
    linear-gradient(145deg, rgba(16, 23, 48, 0.96), rgba(26, 35, 66, 0.93)),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
  border-color: rgba(212, 175, 55, 0.2);
}

body:not(.light):not(.day-mode) .hero {
  background:
    linear-gradient(100deg, rgba(10, 15, 30, 0.98), rgba(10, 15, 30, 0.82)),
    url('/manus-storage/adhkar-reference_ced78910.png') center / cover no-repeat;
}

body:not(.light):not(.day-mode) .azkar-card,
body:not(.light):not(.day-mode) .dhikr-card,
body:not(.light):not(.day-mode) .prayer-card,
body:not(.light):not(.day-mode) .stat-item,
body:not(.light):not(.day-mode) .instruction-card,
body:not(.light):not(.day-mode) .tip-card,
body:not(.light):not(.day-mode) .dhikr-selection {
  background: linear-gradient(145deg, #101730, #1A2342);
  border-color: rgba(212, 175, 55, 0.15);
}

body:not(.light):not(.day-mode) .azkar-card:hover,
body:not(.light):not(.day-mode) .dhikr-card:hover,
body:not(.light):not(.day-mode) .prayer-item:hover {
  border-color: rgba(212, 175, 55, 0.3);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(212, 175, 55, 0.16);
}

body:not(.light):not(.day-mode) .azkar-icon,
body:not(.light):not(.day-mode) .current-dhikr,
body:not(.light):not(.day-mode) .azkar-count,
body:not(.light):not(.day-mode) .dhikr-count,
body:not(.light):not(.day-mode) .stat-item {
  background: rgba(212, 175, 55, 0.1);
}

body:not(.light):not(.day-mode) .azkar-count,
body:not(.light):not(.day-mode) .dhikr-count,
body:not(.light):not(.day-mode) .current-dhikr,
body:not(.light):not(.day-mode) .stat-value,
body:not(.light):not(.day-mode) .tasbih-count {
  color: #D4AF37;
}

body:not(.light):not(.day-mode) .tasbih-btn,
body:not(.light):not(.day-mode) .counter-main-btn,
body:not(.light):not(.day-mode) .quran-ultra-cta,
body:not(.light):not(.day-mode) .quran-action,
body:not(.light):not(.day-mode) .quran-enter-btn,
body:not(.light):not(.day-mode) .scroll-top {
  background: linear-gradient(135deg, #D4AF37, #E6C158);
  color: #0A0F1E;
}

body:not(.light):not(.day-mode) .prayer-card {
  background:
    linear-gradient(145deg, rgba(16, 23, 48, 0.95), rgba(26, 35, 66, 0.92)),
    url('/manus-storage/prayer-ambient_a7839ae2.png') center / cover no-repeat;
}

body:not(.light):not(.day-mode) .quran-ultra-wrapper {
  background:
    linear-gradient(145deg, rgba(16, 23, 48, 0.95), rgba(26, 35, 66, 0.92)),
    url('/manus-storage/quran-ambient_50222461.png') center / cover no-repeat;
}

body:not(.light):not(.day-mode) .modal-content,
body:not(.light):not(.day-mode) .azkar-item {
  background: linear-gradient(145deg, #101730, #1A2342);
  border-color: rgba(212, 175, 55, 0.2);
}

body:not(.light):not(.day-mode) .modal-header,
body:not(.light):not(.day-mode) .modal-close {
  background: rgba(212, 175, 55, 0.1);
  border-color: rgba(212, 175, 55, 0.3);
  color: #D4AF37;
}

/* Desktop keeps the complete information architecture; mobile gets a true app bar. */
.mobile-more,
.more-menu {
  display: none;
}

@media (max-width: 767px) {
  body:has(.mobile-more) {
    padding-bottom: calc(90px + env(safe-area-inset-bottom));
  }

  body:has(.mobile-more) header {
    display: flex;
    flex-wrap: wrap;
    min-height: 64px;
    padding: 9px 14px 10px;
  }

  body:has(.mobile-more) header > nav {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 2100;
    display: flex;
    align-items: stretch;
    gap: 4px;
    width: auto;
    padding: 7px;
    overflow: visible;
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 14px 36px rgba(10, 34, 33, 0.2);
    backdrop-filter: blur(20px) saturate(130%);
  }

  body:not(.light):not(.day-mode):has(.mobile-more) header > nav {
    border-color: rgba(212, 175, 55, 0.24);
    background: rgba(16, 23, 48, 0.97);
  }

  body:has(.mobile-more) header > nav .nav-secondary,
  body:has(.mobile-more) header > nav .theme-toggle {
    display: none !important;
  }

  body:has(.mobile-more) header > nav .nav-primary,
  body:has(.mobile-more) header > nav .mobile-more {
    display: inline-flex !important;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 6px 3px;
    border: 0;
    border-radius: 16px;
    font-size: 10px;
    line-height: 1.2;
    white-space: normal;
  }

  body:has(.mobile-more) header > nav .nav-primary.active,
  body:has(.mobile-more) header > nav .mobile-more[aria-expanded='true'] {
    background: rgba(20, 92, 91, 0.1);
    box-shadow: inset 0 -2px 0 var(--gold);
  }

  body:not(.light):not(.day-mode):has(.mobile-more) header > nav .nav-primary.active,
  body:not(.light):not(.day-mode):has(.mobile-more) header > nav .mobile-more[aria-expanded='true'] {
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 #D4AF37;
  }

  body:has(.mobile-more) header > nav .nav-icon {
    font-size: 16px;
  }

  body:has(.mobile-more) header > .download-bar {
    display: none;
  }

  body:has(.mobile-more) .more-menu {
    position: fixed;
    inset: 0;
    z-index: 2050;
    display: block;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms var(--sanctuary-ease), visibility 180ms ease;
  }

  body:has(.mobile-more) .more-menu.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  body:has(.mobile-more) .more-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 30, 0.58);
    backdrop-filter: blur(7px);
  }

  body:has(.mobile-more) .more-menu-sheet {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 28px 28px 0 0;
    background: var(--sanctuary-paper-strong);
    box-shadow: 0 -16px 44px rgba(10, 34, 33, 0.2);
    transform: translateY(22px);
    transition: transform 220ms var(--sanctuary-ease);
  }

  body:has(.mobile-more) .more-menu.active .more-menu-sheet {
    transform: translateY(0);
  }

  body:not(.light):not(.day-mode):has(.mobile-more) .more-menu-sheet {
    border-color: rgba(212, 175, 55, 0.22);
    background: #101730;
  }

  body:has(.mobile-more) .more-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  body:has(.mobile-more) .more-menu-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--sanctuary-copper);
    font-size: 11px;
  }

  body:has(.mobile-more) .more-menu-header h2 {
    margin: 0;
    color: var(--sanctuary-teal);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-size: 24px;
  }

  body:not(.light):not(.day-mode):has(.mobile-more) .more-menu-header h2 {
    color: #D4AF37;
  }

  body:has(.mobile-more) .more-menu-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--sanctuary-line);
    border-radius: 13px;
    background: rgba(20, 92, 91, 0.08);
    color: var(--sanctuary-teal);
  }

  body:has(.mobile-more) .more-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 10px 13px;
    border: 1px solid var(--sanctuary-line);
    border-radius: 15px;
    background: rgba(20, 92, 91, 0.045);
    color: var(--sanctuary-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
  }

  body:has(.mobile-more) .more-action + .more-action {
    margin-top: 8px;
  }

  body:has(.mobile-more) .more-action > i:first-child {
    width: 22px;
    color: var(--sanctuary-teal);
    text-align: center;
  }

  body:has(.mobile-more) .more-action span {
    flex: 1;
    text-align: right;
  }

  body:has(.mobile-more) .more-action-arrow {
    color: var(--sanctuary-copper);
    font-size: 12px;
  }

  body:not(.light):not(.day-mode):has(.mobile-more) .more-action {
    border-color: rgba(212, 175, 55, 0.18);
    background: rgba(212, 175, 55, 0.07);
    color: #EFEBDD;
  }

  body:not(.light):not(.day-mode):has(.mobile-more) .more-action > i:first-child {
    color: #D4AF37;
  }
}

/* Inner-page mobile app shells: concise primary actions + secondary controls in More. */
.qibla-mobile-bar,
.qibla-more {
  display: none;
}

@media (max-width: 767px) {
  body:has(.quran-header),
  body:has(.qibla-mobile-bar) {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  body:has(.quran-header) .quran-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    min-height: 58px;
  }

  body:has(.quran-header) .quran-header .header-content {
    min-height: 58px;
    padding: 8px 13px;
  }

  body:has(.quran-header) .quran-header .nav-links {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 2100;
    display: flex;
    align-items: stretch;
    gap: 4px;
    width: auto;
    padding: 7px;
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 14px 36px rgba(10, 34, 33, 0.2);
    backdrop-filter: blur(20px) saturate(130%);
  }

  body:not(.light):has(.quran-header) .quran-header .nav-links {
    border-color: rgba(212, 175, 55, 0.24);
    background: rgba(16, 23, 48, 0.97);
  }

  body:has(.quran-header) .quran-header .nav-link.nav-secondary,
  body:has(.quran-header) .quran-header .theme-toggle-btn {
    display: none !important;
  }

  body:has(.quran-header) .quran-header .nav-link.nav-primary,
  body:has(.quran-header) .quran-header .mobile-more {
    display: inline-flex !important;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 6px 3px;
    border: 0;
    border-radius: 16px;
    font-size: 10px;
    line-height: 1.2;
  }

  body:has(.quran-header) .quran-header .nav-link.nav-primary.active,
  body:has(.quran-header) .quran-header .mobile-more[aria-expanded='true'] {
    background: rgba(20, 92, 91, 0.1);
    box-shadow: inset 0 -2px 0 var(--sanctuary-teal);
  }

  body:not(.light):has(.quran-header) .quran-header .nav-link.nav-primary.active,
  body:not(.light):has(.quran-header) .quran-header .mobile-more[aria-expanded='true'] {
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 #D4AF37;
  }

  body:has(.quran-header) .inner-more-menu,
  body:has(.qibla-mobile-bar) .qibla-more {
    position: fixed;
    inset: 0;
    z-index: 2050;
    display: block;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  body:has(.quran-header) .inner-more-menu.active,
  body:has(.qibla-mobile-bar) .qibla-more.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  body:has(.quran-header) .inner-more-backdrop,
  body:has(.qibla-mobile-bar) .qibla-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 30, 0.58);
    backdrop-filter: blur(7px);
  }

  body:has(.quran-header) .inner-more-sheet,
  body:has(.qibla-mobile-bar) .qibla-more-sheet {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 28px 28px 0 0;
    background: var(--sanctuary-paper-strong);
    box-shadow: 0 -16px 44px rgba(10, 34, 33, 0.2);
    transform: translateY(22px);
    transition: transform 220ms var(--sanctuary-ease);
  }

  body:has(.quran-header) .inner-more-menu.active .inner-more-sheet,
  body:has(.qibla-mobile-bar) .qibla-more.active .qibla-more-sheet {
    transform: translateY(0);
  }

  body:not(.light):has(.quran-header) .inner-more-sheet,
  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-more-sheet {
    border-color: rgba(212, 175, 55, 0.22);
    background: #101730;
  }

  body:has(.quran-header) .inner-more-heading,
  body:has(.qibla-mobile-bar) .qibla-more-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  body:has(.quran-header) .inner-more-heading > div > span,
  body:has(.qibla-mobile-bar) .qibla-more-heading > div > span {
    color: var(--sanctuary-copper);
    font-size: 11px;
  }

  body:has(.quran-header) .inner-more-heading h2,
  body:has(.qibla-mobile-bar) .qibla-more-heading h2 {
    margin: 3px 0 0;
    color: var(--sanctuary-teal);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-size: 24px;
  }

  body:not(.light):has(.quran-header) .inner-more-heading h2,
  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-more-heading h2 {
    color: #D4AF37;
  }

  body:has(.quran-header) .inner-more-heading > button,
  body:has(.qibla-mobile-bar) .qibla-more-heading > button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--sanctuary-line);
    border-radius: 13px;
    background: rgba(20, 92, 91, 0.08);
    color: var(--sanctuary-teal);
  }

  body:has(.quran-header) .inner-more-action,
  body:has(.qibla-mobile-bar) .qibla-more-theme {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    padding: 10px 13px;
    border: 1px solid var(--sanctuary-line);
    border-radius: 15px;
    background: rgba(20, 92, 91, 0.045);
    color: var(--sanctuary-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
  }

  body:has(.quran-header) .inner-more-action + .inner-more-action {
    margin-top: 8px;
  }

  body:has(.quran-header) .inner-more-action > span,
  body:has(.qibla-mobile-bar) .qibla-more-theme > span:first-child {
    flex: 1;
    text-align: right;
  }

  body:has(.quran-header) .inner-more-action > i:first-child,
  body:has(.qibla-mobile-bar) .qibla-more-theme > span:first-child > i {
    color: var(--sanctuary-teal);
  }

  body:has(.quran-header) .inner-more-action > i:last-child {
    color: var(--sanctuary-copper);
    font-size: 12px;
  }

  body:has(.qibla-mobile-bar) .qibla-mobile-bar {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 2100;
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 7px;
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 14px 36px rgba(10, 34, 33, 0.2);
    backdrop-filter: blur(20px) saturate(130%);
  }

  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-mobile-bar {
    border-color: rgba(212, 175, 55, 0.24);
    background: rgba(16, 23, 48, 0.97);
  }

  body:has(.qibla-mobile-bar) .qibla-mobile-action {
    display: inline-flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 6px 3px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--sanctuary-teal);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
  }

  body:has(.qibla-mobile-bar) .qibla-mobile-action.active,
  body:has(.qibla-mobile-bar) .qibla-mobile-action[aria-expanded='true'] {
    background: rgba(20, 92, 91, 0.1);
    box-shadow: inset 0 -2px 0 var(--sanctuary-teal);
  }

  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-mobile-action {
    color: #D4AF37;
  }

  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-mobile-action.active,
  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-mobile-action[aria-expanded='true'] {
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 #D4AF37;
  }

  body:has(.qibla-mobile-bar) .qibla-mobile-action i {
    font-size: 16px;
  }

  body:not(.light):has(.quran-header) .inner-more-action,
  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-more-theme {
    border-color: rgba(212, 175, 55, 0.18);
    background: rgba(212, 175, 55, 0.07);
    color: #EFEBDD;
  }

  body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .qibla-more-theme > span:first-child > i,
  body:not(.light):has(.quran-header) .inner-more-action > i:first-child {
    color: #D4AF37;
  }

  body:has(.qibla-mobile-bar) .qibla-more-theme input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  body:has(.qibla-mobile-bar) .qibla-more-toggle {
    position: relative;
    width: 43px;
    height: 24px;
    border-radius: 999px;
    background: rgba(20, 92, 91, 0.18);
  }

  body:has(.qibla-mobile-bar) .qibla-more-toggle::after {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sanctuary-teal);
    content: '';
    transition: transform 180ms ease;
  }

  body:has(.qibla-mobile-bar) .qibla-more-theme input:checked + .qibla-more-toggle {
    background: rgba(212, 175, 55, 0.32);
  }

  body:has(.qibla-mobile-bar) .qibla-more-theme input:checked + .qibla-more-toggle::after {
    transform: translateX(-19px);
    background: #D4AF37;
  }
}

/* Position hardening for mobile app bars: always anchored to the viewport bottom. */
@media (max-width: 767px) {
  body:has(.mobile-more) header > nav,
  body:has(.quran-header) .quran-header .nav-links,
  body:has(.qibla-mobile-bar) .qibla-mobile-bar {
    position: fixed !important;
    top: auto !important;
    right: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
  }
}

/* Main-page app bar is independent from the sticky desktop header. */
.mobile-app-nav {
  display: none;
}

@media (max-width: 767px) {
  body:has(.mobile-app-nav) header > nav {
    display: none !important;
  }

  body:has(.mobile-app-nav) .mobile-app-nav {
    position: fixed !important;
    top: auto !important;
    right: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    z-index: 2200;
    display: flex !important;
    align-items: stretch;
    gap: 4px;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 7px;
    overflow: visible;
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.97);
    box-shadow: 0 14px 36px rgba(10, 34, 33, 0.22);
    backdrop-filter: blur(20px) saturate(135%);
  }

  body:not(.light):not(.day-mode):has(.mobile-app-nav) .mobile-app-nav {
    border-color: rgba(212, 175, 55, 0.24);
    background: rgba(16, 23, 48, 0.98);
  }

  body:has(.mobile-app-nav) .mobile-app-nav .nav-btn {
    display: inline-flex !important;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0 !important;
    min-height: 54px;
    max-width: none !important;
    margin: 0 !important;
    padding: 6px 3px !important;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--sanctuary-teal);
    font-size: 10px;
    line-height: 1.2;
    white-space: normal;
  }

  body:has(.mobile-app-nav) .mobile-app-nav .nav-btn.active,
  body:has(.mobile-app-nav) .mobile-app-nav .mobile-more[aria-expanded='true'] {
    background: rgba(20, 92, 91, 0.1);
    box-shadow: inset 0 -2px 0 var(--sanctuary-teal);
  }

  body:not(.light):not(.day-mode):has(.mobile-app-nav) .mobile-app-nav .nav-btn {
    color: #D4AF37;
  }

  body:not(.light):not(.day-mode):has(.mobile-app-nav) .mobile-app-nav .nav-btn.active,
  body:not(.light):not(.day-mode):has(.mobile-app-nav) .mobile-app-nav .mobile-more[aria-expanded='true'] {
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 #D4AF37;
  }

  body:has(.mobile-app-nav) .mobile-app-nav .nav-icon {
    margin: 0 !important;
    font-size: 16px !important;
  }
}

/* Global vertical rhythm correction — content begins immediately below each app header. */
body:has(.mobile-app-nav) main {
  padding-top: 16px !important;
}

body:has(.mobile-app-nav) .hero {
  margin-top: 0 !important;
}

body:has(.quran-header) .quran-main {
  padding-top: 16px !important;
}

body:has(.qibla-mobile-bar) .ui {
  padding-top: 18px !important;
}

@media (max-width: 767px) {
  body:has(.mobile-app-nav) main {
    padding-top: 6px !important;
  }

  body:has(.mobile-app-nav) .hero {
    margin-top: 0 !important;
  }

  body:has(.quran-header) .quran-main {
    padding-top: 8px !important;
  }

  body:has(.qibla-mobile-bar) .ui {
    padding-top: 10px !important;
  }
}

/* Cross-service contrast pass — every interactive surface stays readable in the original night theme. */
body:not(.light):not(.day-mode) .quran-header,
body:not(.light):not(.day-mode) .quran-header .header-content,
body:not(.light):not(.day-mode) .quran-main,
body:not(.light):not(.day-mode) .quran-controls,
body:not(.light):not(.day-mode) .quran-display,
body:not(.light):not(.day-mode) .tafseer-panel,
body:not(.light):not(.day-mode) .recitation-player,
body:not(.light):not(.day-mode) .quran-footer {
  color: #EFEBDD !important;
}

body:not(.light):not(.day-mode) .quran-header {
  background: rgba(10, 15, 30, 0.96) !important;
  border-bottom-color: rgba(212, 175, 55, 0.24) !important;
}

body:not(.light):not(.day-mode) .quran-header .nav-link,
body:not(.light):not(.day-mode) .quran-header .theme-toggle-btn {
  background: rgba(212, 175, 55, 0.08) !important;
  border-color: rgba(212, 175, 55, 0.2) !important;
  color: #EFEBDD !important;
}

body:not(.light):not(.day-mode) .quran-header .nav-link:hover,
body:not(.light):not(.day-mode) .quran-header .nav-link.active,
body:not(.light):not(.day-mode) .quran-header .theme-toggle-btn:hover {
  background: rgba(212, 175, 55, 0.18) !important;
  border-color: #D4AF37 !important;
  color: #D4AF37 !important;
}

body:not(.light):not(.day-mode) .quran-controls,
body:not(.light):not(.day-mode) .quran-display,
body:not(.light):not(.day-mode) .tafseer-panel,
body:not(.light):not(.day-mode) .recitation-player {
  background: linear-gradient(145deg, #101730, #1A2342) !important;
  border-color: rgba(212, 175, 55, 0.18) !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24) !important;
}

body:not(.light):not(.day-mode) .control-label,
body:not(.light):not(.day-mode) .surah-info,
body:not(.light):not(.day-mode) .surah-info span,
body:not(.light):not(.day-mode) .tafseer-ayah-info,
body:not(.light):not(.day-mode) .player-progress,
body:not(.light):not(.day-mode) .footer-text,
body:not(.light):not(.day-mode) .quran-footer .footer-text {
  color: #9B927F !important;
}

body:not(.light):not(.day-mode) .surah-name,
body:not(.light):not(.day-mode) .tafseer-title,
body:not(.light):not(.day-mode) .player-title,
body:not(.light):not(.day-mode) .footer-verse {
  color: #D4AF37 !important;
}

body:not(.light):not(.day-mode) .ayah,
body:not(.light):not(.day-mode) .ayah-translation,
body:not(.light):not(.day-mode) .tafseer-content,
body:not(.light):not(.day-mode) .tafseer-ayah-text,
body:not(.light):not(.day-mode) .quran-ultra-main,
body:not(.light):not(.day-mode) .quran-ultra-bismillah {
  color: #EFEBDD !important;
}

body:not(.light):not(.day-mode) .ayah-translation,
body:not(.light):not(.day-mode) .tafseer-ayah-text {
  color: #C8C0AE !important;
}

body:not(.light):not(.day-mode) .select-control,
body:not(.light):not(.day-mode) .select-control option {
  background: #101730 !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.28) !important;
}

body:not(.light):not(.day-mode) .btn-control.secondary,
body:not(.light):not(.day-mode) .player-btn.secondary {
  background: rgba(212, 175, 55, 0.08) !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.24) !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .header,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .home-btn,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) #info,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .audio-notice,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .instruction-card,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .tip-card {
  color: #EFEBDD !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .header {
  background: rgba(10, 15, 30, 0.96) !important;
  border-bottom-color: rgba(212, 175, 55, 0.24) !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) #info,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .audio-notice,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .instruction-card,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .tip-card {
  background: linear-gradient(145deg, #101730, #1A2342) !important;
  border-color: rgba(212, 175, 55, 0.2) !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .info-detail,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer-text,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer-separator {
  color: #9B927F !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .compass-degree,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .direction-text,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer-copyright,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .loading-main-text {
  color: #D4AF37 !important;
}

body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .home-btn,
body:not(.light):not(.day-mode):has(.qibla-mobile-bar) #startBtn {
  background: linear-gradient(135deg, #D4AF37, #E6C158) !important;
  color: #0A0F1E !important;
  border-color: #D4AF37 !important;
}

/* Original logo remains untouched; the light mode gets only contrast support. */
body.light .logo-image,
body.light .logo,
body.light .loader-logo-img,
body.day-mode .logo,
body.day-mode .loading-logo {
  filter: drop-shadow(0 2px 5px rgba(20, 92, 91, 0.24)) contrast(1.12) saturate(1.08) !important;
  background: rgba(255, 253, 248, 0.94) !important;
  border-radius: 12px;
  padding: 4px;
}

body.light .brand-name,
body.day-mode .brand-name {
  color: #145C5B !important;
  text-shadow: 0 1px 0 rgba(255, 253, 248, 0.7);
}

body.light .brand-caption,
body.day-mode .page-name {
  color: #64736D !important;
}

/* Quran page mobile app bar is independent from the desktop header nav. */
.quran-mobile-app-nav {
  display: none;
}

@media (max-width: 767px) {
  body:has(.quran-mobile-app-nav) .quran-header .nav-links {
    display: none !important;
  }

  body:has(.quran-mobile-app-nav) .quran-mobile-app-nav {
    position: fixed !important;
    top: auto !important;
    right: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    z-index: 2200;
    display: flex !important;
    align-items: stretch;
    gap: 4px;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 7px;
    overflow: visible;
    border: 1px solid rgba(20, 92, 91, 0.18);
    border-radius: 24px;
    background: rgba(255, 253, 248, 0.97);
    box-shadow: 0 14px 36px rgba(10, 34, 33, 0.22);
    backdrop-filter: blur(20px) saturate(135%);
  }

  body:not(.light):not(.day-mode):has(.quran-mobile-app-nav) .quran-mobile-app-nav {
    border-color: rgba(212, 175, 55, 0.24);
    background: rgba(16, 23, 48, 0.98);
  }

  body:has(.quran-mobile-app-nav) .quran-mobile-app-nav .nav-link {
    display: inline-flex !important;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0 !important;
    min-height: 54px;
    padding: 6px 3px !important;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--sanctuary-teal);
    font-size: 10px;
    line-height: 1.2;
    text-decoration: none;
  }

  body:has(.quran-mobile-app-nav) .quran-mobile-app-nav .nav-link.active,
  body:has(.quran-mobile-app-nav) .quran-mobile-app-nav .mobile-more[aria-expanded='true'] {
    background: rgba(20, 92, 91, 0.1);
    box-shadow: inset 0 -2px 0 var(--sanctuary-teal);
  }

  body:not(.light):not(.day-mode):has(.quran-mobile-app-nav) .quran-mobile-app-nav .nav-link {
    color: #D4AF37;
  }

  body:not(.light):not(.day-mode):has(.quran-mobile-app-nav) .quran-mobile-app-nav .nav-link.active,
  body:not(.light):not(.day-mode):has(.quran-mobile-app-nav) .quran-mobile-app-nav .mobile-more[aria-expanded='true'] {
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 #D4AF37;
  }

  body:has(.quran-mobile-app-nav) .quran-mobile-app-nav i {
    font-size: 16px;
  }
}

/* Qibla content should flow from the app header, not center itself into a tall empty viewport. */
body:has(.qibla-mobile-bar) .ui {
  height: auto !important;
  min-height: calc(100vh - 64px) !important;
  justify-content: flex-start !important;
  padding: 18px 20px 110px !important;
}

@media (max-width: 767px) {
  body:has(.qibla-mobile-bar) .ui {
    min-height: calc(100vh - 58px) !important;
    padding: 10px 14px 104px !important;
  }
}

/* Secondary bottom sheets are mobile-only and must never occupy desktop document flow. */
.inner-more-menu,
.qibla-more,
.mobile-more {
  display: none;
}

@media (max-width: 767px) {
  body:has(.quran-mobile-app-nav) .inner-more-menu,
  body:has(.mobile-more) .more-menu,
  body:has(.qibla-mobile-bar) .qibla-more {
    display: block;
  }
}

/* Direct Quran dark-mode contrast guard: the legacy page uses its own green token. */
body:not(.light) .quran-main,
body:not(.light) .quran-main .quran-display,
body:not(.light) .quran-main .ayah-container,
body:not(.light) .quran-main .ayah,
body:not(.light) .quran-main .ayah-text,
body:not(.light) .quran-main .tafseer-content,
body:not(.light) .quran-main .tafseer-ayah-text {
  color: #EFEBDD !important;
}

body:not(.light) .quran-main .ayah-translation {
  color: #C8C0AE !important;
}

body:not(.light) .quran-main .select-control,
body:not(.light) .quran-main .select-control option,
body:not(.light) .quran-main .quran-controls {
  background-color: #101730 !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.28) !important;
}

body:not(.light) .quran-main .control-label,
body:not(.light) .quran-main .surah-info,
body:not(.light) .quran-main .surah-info span,
body:not(.light) .quran-main .player-progress {
  color: #9B927F !important;
}

body:not(.light) .quran-main .surah-name,
body:not(.light) .quran-main .tafseer-title,
body:not(.light) .quran-main .player-title {
  color: #D4AF37 !important;
}

/* Highest-priority dark select guard for the Quran controls. */
html body:not(.light) .quran-main .select-control,
html body:not(.light) .quran-main .select-control option {
  background: #101730 !important;
  background-color: #101730 !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.28) !important;
}

html body:not(.light) .quran-main .ayah-text,
html body:not(.light) .quran-main .ayah-translation,
html body:not(.light) .quran-main .tafseer-ayah-text {
  color: #EFEBDD !important;
}

html body:not(.light) .quran-main .ayah-translation,
html body:not(.light) .quran-main .tafseer-ayah-text {
  color: #C8C0AE !important;
}

/* Qibla dark-mode root guard: the utility uses day-mode instead of light. */
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) {
  background: #0A0F1E !important;
  background-color: #0A0F1E !important;
  color: #EFEBDD !important;
}

html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .header,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) #info,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .instruction-card,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .tip-card,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .audio-notice {
  background: #101730 !important;
  background-color: #101730 !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.24) !important;
}

html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .info-detail,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer-text {
  color: #9B927F !important;
}

html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .footer-copyright,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .direction-text,
html body:not(.light):not(.day-mode):has(.qibla-mobile-bar) .loading-main-text {
  color: #D4AF37 !important;
}

/* Home dark-mode root guard: preserve the original night palette across every service card. */
html body:not(.light):has(.mobile-app-nav) {
  background: #0A0F1E !important;
  background-color: #0A0F1E !important;
  color: #EFEBDD !important;
}

html body:not(.light):has(.mobile-app-nav) .hero,
html body:not(.light):has(.mobile-app-nav) .dhikr-selection,
html body:not(.light):has(.mobile-app-nav) .dhikr-card,
html body:not(.light):has(.mobile-app-nav) .download-card,
html body:not(.light):has(.mobile-app-nav) .footer {
  background: #101730 !important;
  background-color: #101730 !important;
  color: #EFEBDD !important;
  border-color: rgba(212, 175, 55, 0.24) !important;
}

html body:not(.light):has(.mobile-app-nav) .hero-title,
html body:not(.light):has(.mobile-app-nav) .section-title,
html body:not(.light):has(.mobile-app-nav) .hero h1,
html body:not(.light):has(.mobile-app-nav) .dhikr-card h3,
html body:not(.light):has(.mobile-app-nav) .brand-name {
  color: #D4AF37 !important;
}

html body:not(.light):has(.mobile-app-nav) .hero-subtitle,
html body:not(.light):has(.mobile-app-nav) .hero p,
html body:not(.light):has(.mobile-app-nav) .dhikr-card p,
html body:not(.light):has(.mobile-app-nav) .dhikr-count,
html body:not(.light):has(.mobile-app-nav) .footer,
html body:not(.light):has(.mobile-app-nav) .brand-caption {
  color: #C8C0AE !important;
}

html body:not(.light):has(.mobile-app-nav) .dhikr-card .card-icon,
html body:not(.light):has(.mobile-app-nav) .dhikr-card .icon-wrap,
html body:not(.light):has(.mobile-app-nav) .dhikr-card .dhikr-icon {
  color: #D4AF37 !important;
  background: rgba(212, 175, 55, 0.12) !important;
}

html body:not(.light):has(.mobile-app-nav) .mobile-app-nav {
  background: rgba(16, 23, 48, 0.98) !important;
  border-color: rgba(212, 175, 55, 0.24) !important;
}

/* Light-logo legibility: preserve the original mark while giving its pale artwork a clear edge. */
body.light .logo-image,
body.light .logo,
body.light .loader-logo-img,
body.day-mode .logo,
body.day-mode .loading-logo {
  filter: contrast(1.48) saturate(1.2) brightness(0.94) drop-shadow(0 2px 6px rgba(20, 92, 91, 0.26)) !important;
  background: #FFFDF8 !important;
  border: 1px solid rgba(20, 92, 91, 0.12);
  box-shadow: 0 5px 16px rgba(20, 92, 91, 0.1);
}

/* Final logo contrast treatment for the original light artwork. */
body.light .logo-image,
body.light .logo,
body.light .loader-logo-img,
body.day-mode .logo,
body.day-mode .loading-logo {
  filter: brightness(0.72) contrast(1.9) saturate(1.45) drop-shadow(0 2px 6px rgba(20, 92, 91, 0.25)) !important;
  background: #FFFDF8 !important;
}

/* PWA and settings experience — calm feedback, visible installs, no logo tile. */
[data-motion='off'] *,
[data-motion='off'] *::before,
[data-motion='off'] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
}

.settings-page {
  min-height: 100vh;
  background: var(--sanctuary-paper);
  color: var(--sanctuary-ink);
  overflow-x: hidden;
}

.settings-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--sanctuary-line);
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(18px) saturate(130%);
}

.settings-brand,
.settings-back,
.settings-link-grid a {
  color: inherit;
  text-decoration: none;
}

.settings-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.settings-brand img {
  width: 52px;
  height: 44px;
  object-fit: contain;
  filter: none !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.settings-brand strong,
.settings-brand small {
  display: block;
}

.settings-brand strong { color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: 18px; }
.settings-brand small { color: var(--sanctuary-muted); font-size: 11px; margin-top: 2px; }
.settings-back { display: inline-flex; align-items: center; gap: 8px; color: var(--sanctuary-teal); font-weight: 700; }

.settings-main {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 58px 0 110px;
}

.settings-intro { max-width: 700px; margin-bottom: 28px; }
.settings-kicker { display: block; color: var(--sanctuary-copper); font-size: 12px; font-weight: 800; letter-spacing: 0.1em; margin-bottom: 10px; }
.settings-intro h1 { margin: 0 0 12px; color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: clamp(30px, 5vw, 54px); line-height: 1.1; }
.settings-intro p { margin: 0; color: var(--sanctuary-muted); font-size: 16px; line-height: 1.9; }

.settings-card {
  margin-top: 18px;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid var(--sanctuary-line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 16px 34px rgba(20, 92, 91, 0.08);
}

.settings-card-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.settings-card-heading h2 { margin: 0; color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: 21px; }
.settings-card-heading p { margin: 5px 0 0; color: var(--sanctuary-muted); font-size: 13px; }
.settings-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; color: var(--sanctuary-copper); background: rgba(176, 122, 58, 0.12); }

.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; padding: 13px 0; border-top: 1px solid rgba(20, 92, 91, 0.1); cursor: pointer; }
.settings-row > span:first-child strong, .settings-row > span:first-child small { display: block; }
.settings-row strong { color: var(--sanctuary-ink); font-size: 15px; }
.settings-row small { margin-top: 4px; color: var(--sanctuary-muted); font-size: 12px; }
.settings-row input { position: absolute; opacity: 0; pointer-events: none; }
.settings-switch { position: relative; width: 52px; height: 30px; flex: 0 0 52px; border-radius: 999px; background: #D7D9D1; transition: background 180ms ease; }
.settings-switch::after { content: ''; position: absolute; top: 4px; right: 26px; width: 22px; height: 22px; border-radius: 50%; background: #FFFDF8; box-shadow: 0 2px 7px rgba(20, 92, 91, 0.16); transition: transform 180ms cubic-bezier(.23,1,.32,1); }
.settings-row input:checked + .settings-switch { background: var(--sanctuary-teal); }
.settings-row input:checked + .settings-switch::after { transform: translateX(-22px); }

.settings-install-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 10px; padding: 12px 16px; border: 1px solid var(--sanctuary-teal); border-radius: 14px; background: var(--sanctuary-teal); color: #FFFDF8; text-decoration: none; font: inherit; font-weight: 800; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease; }
.settings-install-button:hover { transform: translateY(-2px); box-shadow: 0 9px 20px rgba(20, 92, 91, 0.18); }
.settings-install-button:active { transform: scale(0.98); }
.settings-install-button.settings-android-download { background: rgba(20, 92, 91, 0.08); color: var(--sanctuary-teal); }
.settings-install-button.settings-ios-install { border-color: var(--sanctuary-copper); background: rgba(176, 122, 58, 0.1); color: var(--sanctuary-ink); }
.settings-note { display: flex; align-items: flex-start; gap: 8px; margin: 16px 2px 0; color: var(--sanctuary-muted); font-size: 12px; line-height: 1.8; }
.settings-link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings-link-grid a { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 12px 14px; border: 1px solid var(--sanctuary-line); border-radius: 14px; color: var(--sanctuary-teal); background: rgba(20, 92, 91, 0.04); font-weight: 700; }
.settings-link-grid a i { color: var(--sanctuary-copper); }
.settings-mobile-nav { display: none; }

.pwa-install-toast { position: fixed; right: 18px; bottom: 22px; left: 18px; z-index: 5000; display: flex; align-items: center; gap: 12px; max-width: 680px; margin: auto; padding: 13px 15px; border: 1px solid rgba(212, 175, 55, 0.28); border-radius: 16px; background: #101730; color: #EFEBDD; box-shadow: 0 15px 34px rgba(0,0,0,.25); font-size: 13px; }
.pwa-install-toast span { flex: 1; line-height: 1.6; }
.pwa-install-toast button { border: 0; border-radius: 9px; padding: 8px 12px; background: #D4AF37; color: #0A0F1E; font: inherit; font-weight: 800; cursor: pointer; }
.pwa-install-toast .pwa-toast-close { padding: 2px 7px; background: transparent; color: #EFEBDD; font-size: 18px; }

.ios-install-dialog { position: fixed; inset: 0; z-index: 5100; display: grid; place-items: end center; }
.ios-install-backdrop { position: absolute; inset: 0; background: rgba(10, 15, 30, 0.58); backdrop-filter: blur(4px); }
.ios-install-sheet { position: relative; width: min(560px, calc(100% - 24px)); margin-bottom: 12px; padding: 28px; border: 1px solid rgba(212, 175, 55, 0.3); border-radius: 24px; background: #101730; color: #EFEBDD; box-shadow: 0 24px 60px rgba(0,0,0,.32); }
.ios-install-sheet h2 { margin: 4px 0 10px; color: #D4AF37; font-family: 'El Messiri', sans-serif; }
.ios-install-sheet p, .ios-install-sheet li { color: #C8C0AE; line-height: 1.9; }
.ios-install-sheet ol { padding-right: 22px; }
.ios-install-close { position: absolute; top: 12px; left: 14px; border: 0; background: transparent; color: #EFEBDD; font-size: 24px; cursor: pointer; }
.pwa-primary-action { width: 100%; margin-top: 14px; padding: 12px 16px; border: 0; border-radius: 12px; background: #D4AF37; color: #0A0F1E; font: inherit; font-weight: 800; cursor: pointer; }

html[data-motion='on'] .settings-card { animation: settings-rise 360ms cubic-bezier(.23,1,.32,1) both; }
@keyframes settings-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

body:not(.light) .settings-page,
body:not(.light) .settings-header { background: #0A0F1E; color: #EFEBDD; }
body:not(.light) .settings-header { border-bottom-color: rgba(212, 175, 55, 0.22); background: rgba(10, 15, 30, 0.9); }
body:not(.light) .settings-card { border-color: rgba(212, 175, 55, 0.2); background: #101730; }
body:not(.light) .settings-brand strong,
body:not(.light) .settings-back,
body:not(.light) .settings-card-heading h2,
body:not(.light) .settings-intro h1 { color: #D4AF37; }
body:not(.light) .settings-intro p,
body:not(.light) .settings-card-heading p,
body:not(.light) .settings-row small,
body:not(.light) .settings-note { color: #9B927F; }
body:not(.light) .settings-row strong { color: #EFEBDD; }
body:not(.light) .settings-row { border-top-color: rgba(212, 175, 55, 0.16); }
body:not(.light) .settings-link-grid a { border-color: rgba(212, 175, 55, 0.2); background: rgba(212, 175, 55, 0.08); color: #EFEBDD; }
body:not(.light) .settings-install-button.settings-android-download { color: #D4AF37; border-color: #D4AF37; background: rgba(212, 175, 55, 0.08); }

@media (max-width: 767px) {
  .settings-header { min-height: 68px; padding: 10px 16px; }
  .settings-brand img { width: 48px; height: 40px; }
  .settings-brand strong { font-size: 16px; }
  .settings-main { width: min(100% - 24px, 680px); padding-top: 30px; padding-bottom: 104px; }
  .settings-intro h1 { font-size: 32px; }
  .settings-card { border-radius: 20px; }
  .settings-link-grid { grid-template-columns: 1fr; }
  .settings-mobile-nav { position: fixed; right: 10px; bottom: 10px; left: 10px; z-index: 2200; display: flex; gap: 4px; padding: 7px; border: 1px solid rgba(20, 92, 91, 0.18); border-radius: 24px; background: rgba(255, 253, 248, 0.97); box-shadow: 0 14px 36px rgba(10, 34, 33, 0.22); backdrop-filter: blur(20px) saturate(135%); }
  .settings-mobile-nav a { display: inline-flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 16px; color: var(--sanctuary-teal); text-decoration: none; font-size: 10px; font-weight: 700; }
  .settings-mobile-nav a.active { background: rgba(20, 92, 91, 0.1); box-shadow: inset 0 -2px 0 var(--sanctuary-teal); }
  .settings-mobile-nav i { font-size: 16px; }
  body:not(.light) .settings-mobile-nav { border-color: rgba(212, 175, 55, 0.24); background: rgba(16, 23, 48, 0.98); }
  body:not(.light) .settings-mobile-nav a { color: #D4AF37; }
  body:not(.light) .settings-mobile-nav a.active { background: rgba(212, 175, 55, 0.12); box-shadow: inset 0 -2px 0 #D4AF37; }
}

/* Installation actions stay visible and consistent with the main app shell. */
.download-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.download-bar .download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--sanctuary-line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--sanctuary-teal);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.download-bar .download-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20, 92, 91, 0.12); }
.download-bar .download-btn:active { transform: scale(0.97); }
.download-bar .download-btn.android { background: var(--sanctuary-teal); border-color: var(--sanctuary-teal); color: #FFFDF8; }
.download-bar .download-btn.ios { background: rgba(176, 122, 58, 0.1); border-color: rgba(176, 122, 58, 0.38); color: var(--sanctuary-ink); }
.download-bar .download-btn.pwa-install { background: rgba(20, 92, 91, 0.08); border-color: var(--sanctuary-teal); }

body:not(.light):has(.mobile-app-nav) .download-bar .download-btn { background: #101730; border-color: rgba(212, 175, 55, 0.24); color: #EFEBDD; }
body:not(.light):has(.mobile-app-nav) .download-bar .download-btn.android { background: #D4AF37; border-color: #D4AF37; color: #0A0F1E; }
body:not(.light):has(.mobile-app-nav) .download-bar .download-btn.ios,
body:not(.light):has(.mobile-app-nav) .download-bar .download-btn.pwa-install { background: rgba(212, 175, 55, 0.1); border-color: #D4AF37; color: #D4AF37; }

@media (max-width: 767px) {
  .download-bar { gap: 6px; padding: 8px 10px; }
  .download-bar .download-btn { min-height: 36px; padding: 7px 9px; font-size: 10px; }
}

/* Main install card: visible, compact, and aligned with the app's paper-and-petroleum system. */
.install-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 0;
  padding: 18px 22px;
  border: 1px solid var(--sanctuary-line);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 14px 28px rgba(20, 92, 91, 0.07);
}
.install-card-copy { min-width: 0; }
.install-card-kicker { display: block; margin-bottom: 3px; color: var(--sanctuary-copper); font-size: 11px; font-weight: 800; }
.install-card h2 { margin: 0; color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: 20px; }
.install-card p { margin: 4px 0 0; color: var(--sanctuary-muted); font-size: 12px; line-height: 1.7; }
.install-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.install-card-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 13px; border: 1px solid var(--sanctuary-line); border-radius: 12px; background: rgba(20, 92, 91, 0.05); color: var(--sanctuary-teal); font: inherit; font-size: 11px; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease; }
.install-card-action:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20, 92, 91, 0.12); }
.install-card-action:active { transform: scale(0.97); }
.install-card-action.android { background: var(--sanctuary-teal); border-color: var(--sanctuary-teal); color: #FFFDF8; }
.install-card-action.ios { border-color: rgba(176, 122, 58, 0.4); color: var(--sanctuary-ink); background: rgba(176, 122, 58, 0.1); }
.install-card-action.pwa { border-color: var(--sanctuary-teal); }
body:not(.light):has(.install-card) .install-card { border-color: rgba(212, 175, 55, 0.22); background: #101730; }
body:not(.light):has(.install-card) .install-card h2 { color: #D4AF37; }
body:not(.light):has(.install-card) .install-card p { color: #9B927F; }
body:not(.light):has(.install-card) .install-card-action { border-color: rgba(212, 175, 55, 0.28); background: rgba(212, 175, 55, 0.08); color: #EFEBDD; }
body:not(.light):has(.install-card) .install-card-action.android { background: #D4AF37; border-color: #D4AF37; color: #0A0F1E; }
body:not(.light):has(.install-card) .install-card-action.ios { color: #D4AF37; }

@media (max-width: 767px) {
  .install-card { display: block; width: calc(100% - 24px); margin-top: 18px; padding: 16px; border-radius: 18px; }
  .install-card h2 { font-size: 17px; }
  .install-card p { font-size: 11px; }
  .install-card-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
  .install-card-action { min-height: 44px; padding: 6px 5px; font-size: 10px; text-align: center; }
  .install-card-action i { font-size: 14px; }
}

/* Final responsive guardrails: every dhikr card keeps its action visible on narrow screens. */
html, body { min-width: 0; overflow-x: hidden; }
.azkar-grid, .dhikr-grid, .azkar-list { min-width: 0; }
.dhikr-card, .azkar-item, .azkar-item-counter, .counter-buttons, .counter-main-btn { min-width: 0; }

/* The original logo keeps its artwork in light mode and becomes a single readable gold mark in dark mode. */
body:not(.light) .logo-image,
body:not(.light) .loader-logo-img,
body:not(.light) .logo-container > .logo,
body:not(.light) .settings-brand img,
body:not(.light) .loading-logo,
body:not(.light) .loading-logo-night,
body:not(.light) #loaderLogo {
  filter: brightness(0) saturate(100%) invert(73%) sepia(53%) saturate(666%) hue-rotate(4deg) brightness(92%) contrast(88%) drop-shadow(0 0 10px rgba(212, 175, 55, 0.4)) !important;
  background: transparent !important;
}

@media (max-width: 767px) {
  body:has(.mobile-app-nav), body:has(.settings-mobile-nav) { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .azkar-grid, .dhikr-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; }
  .dhikr-card { width: 100%; min-height: 148px; height: auto !important; overflow: visible !important; }
  .dhikr-card > *, .azkar-item > * { min-width: 0; max-width: 100%; }
  .dhikr-card h3, .dhikr-card p, .azkar-item-text, .azkar-item-reference, .azkar-item-benefit { overflow-wrap: anywhere; word-break: normal; }
  .azkar-item { width: 100%; min-height: 0; height: auto !important; overflow: visible !important; }
  .azkar-item-counter { position: static !important; inset: auto !important; display: flex !important; flex-direction: column; gap: 10px; width: 100%; margin-top: 14px; padding: 10px 0 0; }
  .counter-display, .counter-progress { width: 100%; max-width: 100%; }
  .counter-buttons { display: grid !important; grid-template-columns: minmax(0, 1fr) 42px !important; align-items: stretch; gap: 8px; width: 100%; }
  .counter-main-btn { position: static !important; width: 100%; min-width: 0; min-height: 48px; overflow: visible !important; }
  .counter-main-btn .counter-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .counter-reset-icon { position: static !important; inset: auto !important; display: inline-flex !important; align-items: center; justify-content: center; width: 42px !important; min-width: 42px; height: 48px; margin: 0 !important; }
  .dhikr-counter, .count-button { position: static !important; min-width: 0; width: 100%; max-width: 100%; }
}

@media (max-width: 380px) {
  .dhikr-card { padding: 14px !important; }
  .azkar-item { padding: 14px 12px !important; }
  .counter-buttons { grid-template-columns: minmax(0, 1fr) 38px !important; gap: 6px; }
  .counter-reset-icon { width: 38px !important; min-width: 38px; }
  .counter-main-btn { min-height: 46px; font-size: 11px; }
}

/* Shared install strip for inner services: only Android download and iPhone guidance. */
.inner-install-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: min(1180px, calc(100% - 40px));
  margin: 10px auto 0;
  padding: 8px 0;
}
.inner-install-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--sanctuary-line);
  border-radius: 11px;
  background: rgba(255, 253, 248, 0.86);
  color: var(--sanctuary-teal);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.inner-install-action:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20, 92, 91, 0.12); }
.inner-install-action:active { transform: scale(0.97); }
.inner-install-action.android { background: var(--sanctuary-teal); border-color: var(--sanctuary-teal); color: #FFFDF8; }
.inner-install-action.ios { border-color: rgba(176, 122, 58, 0.4); background: rgba(176, 122, 58, 0.1); color: var(--sanctuary-ink); }
body:not(.light) .inner-install-action { border-color: rgba(212, 175, 55, 0.28); background: rgba(212, 175, 55, 0.08); color: #EFEBDD; }
body:not(.light) .inner-install-action.android { background: #D4AF37; border-color: #D4AF37; color: #0A0F1E; }
body:not(.light) .inner-install-action.ios { color: #D4AF37; }

/* Settings remains readable and touchable after adding the shared theme control. */
.settings-main { min-width: 0; }
.settings-card, .settings-row, .settings-install-button, .settings-link-grid { min-width: 0; }
.settings-row strong, .settings-row small, .settings-card-heading h2, .settings-card-heading p { overflow-wrap: anywhere; }
.settings-switch { flex: 0 0 auto; }

@media (max-width: 767px) {
  .inner-install-bar { width: calc(100% - 24px); margin: 8px auto 0; padding: 6px 0; gap: 6px; }
  .inner-install-action { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 7px 6px; font-size: 10px; }
  .inner-install-action span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .settings-main { width: 100%; padding: 0 12px 104px; }
  .settings-intro { padding: 26px 6px 14px; }
  .settings-intro h1 { font-size: clamp(27px, 8vw, 38px); line-height: 1.2; }
  .settings-card { width: 100%; margin: 10px 0; padding: 16px 14px; border-radius: 18px; }
  .settings-row { min-height: 68px; padding: 12px 0; gap: 12px; }
  .settings-row strong { font-size: 14px; }
  .settings-row small { font-size: 10px; line-height: 1.6; }
  .settings-install-button { min-height: 46px; width: 100%; }
}

/* Logo lockup: never place the supplied artwork inside a competing tile. */
.logo-symbol,
.logo-symbol .logo-image,
.settings-brand img,
.logo-container > .logo,
.loader-logo-img,
.loading-logo {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
body.light .logo-symbol { filter: none !important; }
body.light .logo-symbol .logo-image { filter: drop-shadow(0 3px 7px rgba(20, 44, 62, 0.14)) !important; }
body.light .settings-brand img { filter: drop-shadow(0 2px 6px rgba(20, 44, 62, 0.12)) !important; }
body:not(.light) .logo-symbol .logo-image,
body:not(.light) .settings-brand img { filter: brightness(0) saturate(100%) invert(73%) sepia(53%) saturate(666%) hue-rotate(4deg) brightness(92%) contrast(88%) !important; }

/* On inner pages the logo remains an artwork, not a padded square icon. */
@media (max-width: 767px) {
  .logo-symbol { padding: 0 !important; border-radius: 0 !important; }
  .settings-brand img { object-fit: contain; }
}

/* Final settings correction: no browser-default white frame, and a reliable RTL switch. */
html,
body { margin: 0; }
html { min-height: 100%; }
body.settings-page { min-height: 100vh; border: 0; outline: 0; }
body:not(.light),
html:not(.light) { background: #0A0F1E !important; }
body.settings-page:not(.light) .settings-switch { background: #2A3554; }
body.settings-page:not(.light) .settings-switch::after { background: #EFEBDD; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
body.settings-page:not(.light) .settings-row input:checked + .settings-switch { background: #D4AF37; }
body.settings-page:not(.light) .settings-row input:checked + .settings-switch::after { background: #0A0F1E; }
.settings-switch::after { right: 4px; left: auto; transform: translateX(-22px); }
.settings-row input:checked + .settings-switch::after { transform: translateX(0); }
.settings-row input:focus-visible + .settings-switch { outline: 2px solid #D4AF37; outline-offset: 3px; }
@media (max-width: 767px) {
  body.settings-page::-webkit-scrollbar { width: 11px; }
  body.settings-page::-webkit-scrollbar-track { background: #0A0F1E; }
  body.settings-page::-webkit-scrollbar-thumb { background: #2A3554; border: 3px solid #0A0F1E; border-radius: 999px; }
}

/* Page Mushaf direction: a quiet Madinah-paper stage with tactile RTL page turning, never a generic card grid. */
.mushaf-mode-chooser,
.real-mushaf-shell { width: min(1180px, calc(100% - 40px)); margin: 22px auto 0; }
.mushaf-mode-chooser { display: grid; grid-template-columns: minmax(240px, .72fr) minmax(0, 1.28fr); gap: 24px; align-items: center; padding: clamp(20px, 4vw, 32px); border: 1px solid var(--sanctuary-line); border-radius: 22px; background: rgba(255, 253, 248, .78); box-shadow: var(--sanctuary-shadow-soft); }
.mushaf-mode-kicker { display: inline-block; margin-bottom: 7px; color: var(--sanctuary-copper); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.mushaf-mode-heading h2, .real-mushaf-heading h2 { margin: 0; color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: clamp(22px, 3vw, 34px); line-height: 1.35; }
.mushaf-mode-heading p, .real-mushaf-heading p { margin: 7px 0 0; color: var(--sanctuary-muted); font-size: 13px; line-height: 1.8; }
.mushaf-mode-options { display: grid; gap: 10px; }
.mushaf-mode-option { display: grid; grid-template-columns: 42px minmax(0, 1fr) 20px; align-items: center; gap: 12px; width: 100%; padding: 13px 15px; border: 1px solid var(--sanctuary-line); border-radius: 16px; background: rgba(255, 253, 248, .72); color: var(--sanctuary-ink); text-align: right; cursor: pointer; font: inherit; }
.mushaf-mode-option:hover { transform: translateY(-2px); border-color: rgba(176, 122, 58, .55); box-shadow: 0 10px 24px rgba(20, 92, 91, .1); }
.mushaf-mode-option.active { border-color: var(--sanctuary-copper); background: rgba(181, 139, 73, .11); box-shadow: inset 0 0 0 1px rgba(181, 139, 73, .16); }
.mushaf-mode-option-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: rgba(20, 92, 91, .1); color: var(--sanctuary-teal); }
.mushaf-mode-option strong, .mushaf-mode-option small { display: block; }
.mushaf-mode-option strong { color: inherit; font-size: 14px; }
.mushaf-mode-option small { margin-top: 3px; color: var(--sanctuary-muted); font-size: 10px; line-height: 1.6; }
.mushaf-mode-check { color: var(--sanctuary-copper); opacity: .35; }
.mushaf-mode-option.active .mushaf-mode-check { opacity: 1; }
.real-mushaf-shell { padding: clamp(20px, 4vw, 34px); border: 1px solid var(--sanctuary-line); border-radius: 26px; background: rgba(255, 253, 248, .76); box-shadow: var(--sanctuary-shadow); }
.real-mushaf-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--sanctuary-line); }
.real-mushaf-badge { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 8px 11px; border: 1px solid rgba(181, 139, 73, .38); border-radius: 999px; background: rgba(181, 139, 73, .1); color: var(--sanctuary-copper); font-size: 10px; font-weight: 900; }
.real-mushaf-toolbar { display: grid; grid-template-columns: 1fr minmax(170px, 240px) 1fr; gap: 10px; align-items: end; margin-top: 20px; }
.real-mushaf-tool, .real-mushaf-page-picker select { min-height: 44px; border: 1px solid var(--sanctuary-line); border-radius: 12px; background: rgba(255, 253, 248, .9); color: var(--sanctuary-teal); font: inherit; font-size: 11px; font-weight: 900; }
.real-mushaf-tool { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; cursor: pointer; }
.real-mushaf-tool:hover { transform: translateY(-2px); border-color: var(--sanctuary-copper); box-shadow: 0 8px 18px rgba(20, 92, 91, .1); }
.real-mushaf-tool:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.real-mushaf-page-picker { display: grid; gap: 5px; color: var(--sanctuary-muted); font-size: 10px; font-weight: 800; }
.real-mushaf-page-picker select { width: 100%; padding: 0 12px; cursor: pointer; }
.real-mushaf-location { min-height: 24px; margin-top: 14px; color: var(--sanctuary-muted); text-align: center; font-size: 11px; }
.real-mushaf-stage { display: grid; grid-template-columns: 42px minmax(0, 430px) 42px; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 28px); min-height: 540px; padding: 28px 0 18px; }
.real-mushaf-book { position: relative; width: min(100%, 390px); perspective: 1400px; }
.real-mushaf-book::before, .real-mushaf-book::after { content: ''; position: absolute; top: 9px; bottom: 9px; width: 13px; z-index: -1; border-radius: 4px; background: #c9b98f; box-shadow: 0 6px 14px rgba(50, 34, 14, .2); }
.real-mushaf-book::before { right: -7px; }
.real-mushaf-book::after { left: -7px; }
.real-mushaf-page { position: relative; overflow: hidden; min-height: 250px; border: 8px solid #e8ddc3; border-radius: 4px; background: #f9f2df; box-shadow: 0 18px 30px rgba(45, 30, 13, .2), inset 0 0 0 1px rgba(119, 89, 42, .3); transform-origin: center center; backface-visibility: hidden; }
.real-mushaf-page svg { display: block; width: 100%; height: auto; min-height: 230px; background: #f9f2df; }
.real-mushaf-page svg path:not(.ayahPolygon), .real-mushaf-page svg g { pointer-events: none; }
.real-mushaf-page svg .ayahPolygon { cursor: pointer; fill: transparent; pointer-events: all; transition: fill-opacity 160ms ease, fill 160ms ease; }
.real-mushaf-page svg .ayahPolygon:hover, .real-mushaf-page svg .ayahPolygon.is-selected { fill: #c99a3e; fill-opacity: .28; }
.real-mushaf-page.turn-next { animation: real-page-turn-next 430ms var(--sanctuary-ease) both; }
.real-mushaf-page.turn-previous { animation: real-page-turn-previous 430ms var(--sanctuary-ease) both; }
@keyframes real-page-turn-next { 0% { opacity: .65; transform: rotateY(8deg) translateX(12px); } 45% { opacity: .92; transform: rotateY(-5deg) translateX(-3px); } 100% { opacity: 1; transform: rotateY(0) translateX(0); } }
@keyframes real-page-turn-previous { 0% { opacity: .65; transform: rotateY(-8deg) translateX(-12px); } 45% { opacity: .92; transform: rotateY(5deg) translateX(3px); } 100% { opacity: 1; transform: rotateY(0) translateX(0); } }
.real-mushaf-arrow { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--sanctuary-line); border-radius: 50%; background: rgba(255, 253, 248, .9); color: var(--sanctuary-teal); cursor: pointer; }
.real-mushaf-arrow:hover { transform: scale(1.06); border-color: var(--sanctuary-copper); color: var(--sanctuary-copper); }
.real-mushaf-arrow:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.real-mushaf-loading { display: grid; place-items: center; gap: 10px; min-height: 360px; padding: 24px; color: var(--sanctuary-teal); text-align: center; font-size: 12px; }
.real-mushaf-page-caption { display: flex; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--sanctuary-line); color: var(--sanctuary-muted); font-size: 11px; }
.real-mushaf-page-caption span:first-child { color: var(--sanctuary-teal); font-weight: 900; }
.real-mushaf-ayah-panel { margin-top: 18px; padding: 16px 18px; border: 1px solid rgba(181, 139, 73, .35); border-radius: 16px; background: rgba(181, 139, 73, .09); }
.real-mushaf-ayah-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.real-mushaf-ayah-number { color: var(--sanctuary-copper); font-size: 12px; font-weight: 900; }
.real-mushaf-ayah-heading button { border: 0; background: transparent; color: var(--sanctuary-muted); cursor: pointer; }
.real-mushaf-ayah-panel p { margin: 9px 0 0; color: var(--sanctuary-ink); font-family: 'Amiri', 'IBM Plex Sans Arabic', serif; font-size: 20px; line-height: 2.1; }
.real-mushaf-source { margin: 20px 0 0; color: var(--sanctuary-muted); font-size: 10px; line-height: 1.8; }
.real-mushaf-source a { color: var(--sanctuary-teal); font-weight: 800; }
body:not(.light) .mushaf-mode-chooser, body:not(.light) .real-mushaf-shell { border-color: rgba(212, 175, 55, .2); background: rgba(16, 23, 48, .94); }
body:not(.light) .mushaf-mode-heading h2, body:not(.light) .real-mushaf-heading h2 { color: #D4AF37; }
body:not(.light) .mushaf-mode-heading p, body:not(.light) .real-mushaf-heading p, body:not(.light) .real-mushaf-location, body:not(.light) .real-mushaf-page-caption, body:not(.light) .real-mushaf-source { color: #9B927F; }
body:not(.light) .mushaf-mode-option, body:not(.light) .real-mushaf-tool, body:not(.light) .real-mushaf-page-picker select, body:not(.light) .real-mushaf-arrow { border-color: rgba(212, 175, 55, .22); background: rgba(10, 15, 30, .65); color: #EFEBDD; }
body:not(.light) .mushaf-mode-option.active { border-color: #D4AF37; background: rgba(212, 175, 55, .12); }
body:not(.light) .mushaf-mode-option-icon { background: rgba(212, 175, 55, .12); color: #D4AF37; }
body:not(.light) .mushaf-mode-option small { color: #9B927F; }
body:not(.light) .real-mushaf-heading, body:not(.light) .real-mushaf-toolbar, body:not(.light) .real-mushaf-page-caption { border-color: rgba(212, 175, 55, .16); }
body:not(.light) .real-mushaf-ayah-panel { border-color: rgba(212, 175, 55, .3); background: rgba(212, 175, 55, .09); }
body:not(.light) .real-mushaf-ayah-panel p { color: #EFEBDD; }
@media (prefers-reduced-motion: reduce) {
  .real-mushaf-page.turn-next, .real-mushaf-page.turn-previous { animation: none; }
}
@media (max-width: 767px) {
  .mushaf-mode-chooser, .real-mushaf-shell { width: calc(100% - 24px); }
  .mushaf-mode-chooser { grid-template-columns: 1fr; gap: 16px; margin-top: 14px; padding: 16px; }
  .mushaf-mode-heading h2, .real-mushaf-heading h2 { font-size: 23px; }
  .mushaf-mode-option { grid-template-columns: 38px minmax(0, 1fr) 18px; gap: 9px; padding: 11px; }
  .mushaf-mode-option-icon { width: 38px; height: 38px; }
  .real-mushaf-shell { margin-top: 14px; padding: 16px; border-radius: 20px; }
  .real-mushaf-heading { display: block; }
  .real-mushaf-badge { margin-top: 12px; }
  .real-mushaf-toolbar { grid-template-columns: 1fr 1.25fr 1fr; gap: 6px; margin-top: 16px; }
  .real-mushaf-tool { min-height: 42px; padding: 7px 4px; font-size: 9px; }
  .real-mushaf-tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .real-mushaf-reading-grid { grid-template-columns: 1fr; gap: 10px; }
  .real-mushaf-reading-grid .real-mushaf-ayah-panel { min-height: 0; margin-top: 0; }
  .real-mushaf-stage { grid-template-columns: 34px minmax(0, 1fr) 34px; gap: 7px; min-height: 0; padding: 18px 0 14px; }
  .real-mushaf-arrow { width: 34px; height: 34px; }
  .real-mushaf-page { border-width: 5px; }
  .real-mushaf-page svg { min-height: 0; }
  .real-mushaf-loading { min-height: 260px; }
  .real-mushaf-page-caption { font-size: 10px; }
  .real-mushaf-ayah-panel p { font-size: 17px; }
}
body.real-mushaf-active .real-mushaf-shell { animation: settings-rise 360ms var(--sanctuary-ease) both; }

/* Final responsive controls: text may shrink, but the switch always keeps its full touch target in RTL. */
.settings-main, .settings-card, .settings-row, .mushaf-mode-chooser, .real-mushaf-shell { box-sizing: border-box; }
.settings-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px; align-items: center; direction: rtl; overflow: visible; padding-inline: 4px; }
.settings-row > span:first-child { min-width: 0; }
.settings-row > .settings-switch { display: block; width: 52px; min-width: 52px; max-width: 52px; margin: 0; }

/* Dhikr cards: one quiet copper rail gives each daily entry a distinct, usable edge. */
.dhikr-card { border-inline-start: 3px solid transparent; }
.dhikr-card::after { content: ''; position: absolute; inset-inline-start: 0; top: 16px; bottom: 16px; width: 2px; border-radius: 99px; background: var(--sanctuary-copper); opacity: 0; transform: scaleY(.45); transition: opacity 180ms var(--sanctuary-ease), transform 180ms var(--sanctuary-ease); }
.dhikr-card:hover::after, .dhikr-card.active::after { opacity: 1; transform: scaleY(1); }
.dhikr-card .dhikr-count { border: 1px solid rgba(181, 139, 73, .15); }
body:not(.light) .dhikr-card::after { background: #D4AF37; }
body:not(.light) .dhikr-card .dhikr-count { border-color: rgba(212, 175, 55, .24); }

/* Switch anchor: keep the visual control inside the row while the whole label remains the hit area. */
.settings-main { width: calc(100% - 24px); max-width: 960px; }
.settings-card, .settings-row { max-width: 100%; }
.settings-row { display: flex; position: relative; justify-content: flex-start; padding-inline-start: 68px; padding-inline-end: 4px; }
.settings-row > span:first-child { display: block; min-width: 0; width: 100%; flex: 1 1 auto; }
.settings-row > .settings-switch { position: absolute; top: 50%; inset-inline-start: 4px; inset-inline-end: auto; transform: translateY(-50%); }

/* Reference-inspired Quran toolbar: navigation, search, and location controls stay above the page. */
.real-mushaf-reading-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 24px; align-items: start; margin-top: 12px; }
.real-mushaf-visual-column { min-width: 0; }
.real-mushaf-reading-grid .real-mushaf-ayah-panel { min-height: 260px; margin-top: 54px; }
.real-mushaf-stage { grid-template-columns: 42px minmax(0, 1fr) 42px; }
.real-mushaf-book { width: min(100%, 520px); }
.real-mushaf-toolbar { grid-template-columns: minmax(0, 1.1fr) minmax(220px, 1.4fr) minmax(210px, .9fr); align-items: stretch; }
.real-mushaf-control-group, .real-mushaf-page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.real-mushaf-search-wrap { display: grid; gap: 5px; align-content: start; color: var(--sanctuary-muted); font-size: 10px; font-weight: 800; }
.real-mushaf-search-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.real-mushaf-search-line input { min-width: 0; min-height: 44px; border: 1px solid var(--sanctuary-line); border-radius: 12px; padding: 0 12px; background: rgba(255, 253, 248, .9); color: var(--sanctuary-ink); font: inherit; font-size: 11px; outline: none; }
.real-mushaf-search-line input:focus { border-color: var(--sanctuary-copper); box-shadow: 0 0 0 3px rgba(181, 139, 73, .13); }
.real-mushaf-search-line .real-mushaf-tool { min-width: 66px; }
body:not(.light) .real-mushaf-search-line input { border-color: rgba(212, 175, 55, .22); background: rgba(10, 15, 30, .65); color: #EFEBDD; }
.real-mushaf-page-actions .real-mushaf-tool { width: 100%; }
.real-mushaf-page-turn-audio { display: none; }
@media (max-width: 767px) {
  .real-mushaf-toolbar { grid-template-columns: 1fr; gap: 10px; }
  .real-mushaf-control-group, .real-mushaf-page-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .real-mushaf-search-line input { min-height: 42px; }
  .real-mushaf-search-line .real-mushaf-tool { min-height: 42px; }
}


/* Haramain-inspired spread: the printed Madinah page stays the visual anchor; copper is reserved for wayfinding and active study. */
.real-mushaf-view-switcher { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding: 6px; border: 1px solid var(--sanctuary-line); border-radius: 16px; background: rgba(20, 92, 91, .055); }
.real-mushaf-view-tab { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--sanctuary-muted); font: inherit; font-size: 11px; font-weight: 900; cursor: pointer; transition: color 180ms var(--sanctuary-ease), background 180ms var(--sanctuary-ease), transform 180ms var(--sanctuary-ease); }
.real-mushaf-view-tab:hover { transform: translateY(-1px); color: var(--sanctuary-teal); }
.real-mushaf-view-tab.active { border-color: rgba(181, 139, 73, .42); background: rgba(181, 139, 73, .13); color: var(--sanctuary-teal); box-shadow: 0 5px 16px rgba(33, 44, 38, .08); }
.real-mushaf-reading-grid { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); }
.real-mushaf-stage { grid-template-columns: 42px minmax(0, 1fr) 42px; min-height: 0; padding: 26px 0 16px; }
.real-mushaf-book { display: grid; grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); align-items: stretch; width: min(100%, 840px); margin: 0 auto; perspective: 1900px; filter: drop-shadow(0 22px 23px rgba(47, 31, 12, .17)); }
.real-mushaf-book::before, .real-mushaf-book::after { top: 2%; bottom: 2%; width: 18px; z-index: -1; background: #cbb78d; }
.real-mushaf-book::before { right: -8px; }
.real-mushaf-book::after { left: -8px; }
.real-mushaf-gutter { position: relative; z-index: 2; background: linear-gradient(90deg, rgba(73, 48, 20, .28), rgba(245, 231, 197, .8) 34%, rgba(120, 83, 35, .22) 50%, rgba(245, 231, 197, .8) 66%, rgba(73, 48, 20, .28)); box-shadow: 0 0 10px rgba(73, 48, 20, .28); }
.real-mushaf-page { min-height: 0; border-width: 7px; border-radius: 3px; box-shadow: 0 17px 28px rgba(45, 30, 13, .18), inset 0 0 0 1px rgba(119, 89, 42, .3); transform-style: preserve-3d; }
.real-mushaf-page-primary { transform-origin: right center; }
.real-mushaf-page-adjacent { transform-origin: left center; }
.real-mushaf-page svg { min-height: 0; }
.real-mushaf-page.turn-next { animation: haramain-page-turn-next 520ms cubic-bezier(.23, 1, .32, 1) both; }
.real-mushaf-page.turn-previous { animation: haramain-page-turn-previous 520ms cubic-bezier(.23, 1, .32, 1) both; }
@keyframes haramain-page-turn-next { 0% { opacity: .68; transform: perspective(1900px) rotateY(-14deg) translateX(-10px) translateZ(0); } 42% { opacity: .9; transform: perspective(1900px) rotateY(76deg) translateX(8px) translateZ(22px); } 70% { opacity: .86; transform: perspective(1900px) rotateY(-7deg) translateX(-4px) translateZ(6px); } 100% { opacity: 1; transform: perspective(1900px) rotateY(0) translateX(0) translateZ(0); } }
@keyframes haramain-page-turn-previous { 0% { opacity: .68; transform: perspective(1900px) rotateY(14deg) translateX(10px) translateZ(0); } 42% { opacity: .9; transform: perspective(1900px) rotateY(-76deg) translateX(-8px) translateZ(22px); } 70% { opacity: .86; transform: perspective(1900px) rotateY(7deg) translateX(4px) translateZ(6px); } 100% { opacity: 1; transform: perspective(1900px) rotateY(0) translateX(0) translateZ(0); } }
.real-mushaf-reading-grid .real-mushaf-ayah-panel { min-height: 0; margin-top: 54px; }
.real-mushaf-ayah-tafsir { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 9px 12px; border: 1px solid rgba(181, 139, 73, .35); border-radius: 10px; background: rgba(181, 139, 73, .1); color: var(--sanctuary-teal); font: inherit; font-size: 10px; font-weight: 900; cursor: pointer; }
.real-mushaf-tafsir-panel, .real-mushaf-recitation { margin-top: 20px; padding: 20px; border: 1px solid var(--sanctuary-line); border-radius: 18px; background: rgba(20, 92, 91, .045); }
.real-mushaf-tafsir-header, .real-mushaf-recitation-heading, .real-mushaf-recitation-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.real-mushaf-tafsir-header h3, .real-mushaf-recitation-heading h3 { margin: 0; color: var(--sanctuary-teal); font-family: 'El Messiri', sans-serif; font-size: 20px; }
.real-mushaf-tafsir-picker { display: grid; gap: 5px; min-width: 220px; color: var(--sanctuary-muted); font-size: 10px; font-weight: 800; }
.real-mushaf-tafsir-picker select { min-height: 42px; padding: 0 10px; border: 1px solid var(--sanctuary-line); border-radius: 11px; background: rgba(255, 253, 248, .95); color: var(--sanctuary-ink); font: inherit; font-size: 11px; font-weight: 800; }
.real-mushaf-tafsir-meta { margin-top: 16px; color: var(--sanctuary-copper); font-size: 11px; font-weight: 900; }
.real-mushaf-tafsir-text { margin-top: 10px; color: var(--sanctuary-ink); font-family: 'Amiri', 'IBM Plex Sans Arabic', serif; font-size: 19px; line-height: 2.15; white-space: pre-line; }
.real-mushaf-recitation-heading { padding-bottom: 14px; border-bottom: 1px solid var(--sanctuary-line); }
.real-mushaf-recitation-heading > i { color: var(--sanctuary-copper); font-size: 27px; }
.real-mushaf-recitation-controls { align-items: end; margin-top: 16px; }
.real-mushaf-recitation-controls audio { width: min(100%, 360px); height: 42px; }
.real-mushaf-recitation-controls .real-mushaf-tafsir-picker { flex: 1 1 220px; }
.real-mushaf-play { min-width: 160px; background: var(--sanctuary-teal); color: #fff; }
.real-mushaf-audio-note { margin: 12px 0 0; color: var(--sanctuary-muted); font-size: 10px; line-height: 1.8; }
body:not(.light) .real-mushaf-view-switcher, body:not(.light) .real-mushaf-tafsir-panel, body:not(.light) .real-mushaf-recitation { border-color: rgba(212, 175, 55, .18); background: rgba(212, 175, 55, .055); }
body:not(.light) .real-mushaf-view-tab.active { border-color: rgba(212, 175, 55, .52); background: rgba(212, 175, 55, .13); color: #D4AF37; }
body:not(.light) .real-mushaf-view-tab:hover, body:not(.light) .real-mushaf-tafsir-header h3, body:not(.light) .real-mushaf-recitation-heading h3 { color: #D4AF37; }
body:not(.light) .real-mushaf-tafsir-picker select { border-color: rgba(212, 175, 55, .2); background: #0A0F1E; color: #EFEBDD; }
body:not(.light) .real-mushaf-tafsir-text { color: #EFEBDD; }
@media (prefers-reduced-motion: reduce) { .real-mushaf-page.turn-next, .real-mushaf-page.turn-previous { animation: none; } }
@media (max-width: 767px) {
  .real-mushaf-view-switcher { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .real-mushaf-view-tab { padding-inline: 6px; font-size: 10px; }
  .real-mushaf-reading-grid { grid-template-columns: 1fr; }
  .real-mushaf-book { grid-template-columns: minmax(0, 1fr); width: min(100%, 430px); filter: drop-shadow(0 16px 18px rgba(47, 31, 12, .16)); }
  .real-mushaf-gutter, .real-mushaf-page-adjacent { display: none; }
  .real-mushaf-page { border-width: 5px; }
  .real-mushaf-reading-grid .real-mushaf-ayah-panel { margin-top: 0; }
  .real-mushaf-tafsir-header, .real-mushaf-recitation-heading, .real-mushaf-recitation-controls { align-items: stretch; flex-direction: column; }
  .real-mushaf-tafsir-picker { min-width: 0; }
  .real-mushaf-recitation-controls audio { width: 100%; }
  .real-mushaf-play { width: 100%; }
}

/* Final mushaf interaction layer: the KSU Madinah page is the visible paper, while the SVG remains an invisible, accessible ayah hit-map. */
.real-mushaf-book { direction: rtl; touch-action: pan-y; --turn-progress: 0; }
.real-mushaf-page { position: relative; overflow: hidden; background: #f6edcf; }
.real-mushaf-page-image { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; pointer-events: none; }
.real-mushaf-ayah-overlay { position: absolute; inset: 0; opacity: 0; z-index: 2; }
.real-mushaf-ayah-overlay svg { display: block; width: 100%; height: 100%; }
.real-mushaf-ayah-overlay .ayahPolygon { pointer-events: all; cursor: pointer; }
.real-mushaf-page::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 15%; z-index: 3; pointer-events: none; opacity: .14; background: linear-gradient(90deg, rgba(88, 55, 20, .32), transparent); }
.real-mushaf-book.is-dragging .real-mushaf-page { transition: transform 90ms linear; }
.real-mushaf-book.is-dragging .real-mushaf-page-primary { transform: perspective(1900px) rotateY(calc(var(--turn-progress) * -72deg)); }
.real-mushaf-book.is-dragging .real-mushaf-page-adjacent { transform: perspective(1900px) rotateY(calc(var(--turn-progress) * 16deg)); }
.real-mushaf-page.turn-next { animation: haramain-fold-next 620ms cubic-bezier(.22,.8,.25,1) both; transform-origin: right center; z-index: 4; }
.real-mushaf-page.turn-previous { animation: haramain-fold-previous 620ms cubic-bezier(.22,.8,.25,1) both; transform-origin: left center; z-index: 4; }
@keyframes haramain-fold-next { 0% { transform: perspective(1900px) rotateY(0deg); box-shadow: 0 18px 30px rgba(45,30,13,.18); } 24% { transform: perspective(1900px) rotateY(-30deg) translateX(-2%); box-shadow: -18px 22px 32px rgba(45,30,13,.25); } 62% { transform: perspective(1900px) rotateY(-168deg) translateX(-5%); box-shadow: -32px 20px 38px rgba(45,30,13,.2); } 100% { transform: perspective(1900px) rotateY(0deg); box-shadow: 0 17px 28px rgba(45,30,13,.18); } }
@keyframes haramain-fold-previous { 0% { transform: perspective(1900px) rotateY(0deg); box-shadow: 0 18px 30px rgba(45,30,13,.18); } 24% { transform: perspective(1900px) rotateY(30deg) translateX(2%); box-shadow: 18px 22px 32px rgba(45,30,13,.25); } 62% { transform: perspective(1900px) rotateY(168deg) translateX(5%); box-shadow: 32px 20px 38px rgba(45,30,13,.2); } 100% { transform: perspective(1900px) rotateY(0deg); box-shadow: 0 17px 28px rgba(45,30,13,.18); } }
.real-mushaf-tafsir-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.real-mushaf-ayah-audio { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(181,139,73,.35); border-radius: 50%; background: rgba(181,139,73,.1); color: var(--sanctuary-copper); cursor: pointer; }
.real-mushaf-ayah-audio:disabled { opacity: .45; cursor: not-allowed; }
.real-mushaf-ayah-audio.is-playing { background: var(--sanctuary-teal); color: #fff; }
.real-mushaf-tafsir-panel { grid-column: 1; grid-row: 1; margin-top: 54px; align-self: stretch; }
.real-mushaf-visual-column { grid-column: 2; grid-row: 1; }
@media (max-width: 767px) {
  .real-mushaf-reading-grid { display: flex; flex-direction: column; gap: 14px; }
  .real-mushaf-visual-column, .real-mushaf-tafsir-panel { width: 100%; }
  .real-mushaf-visual-column { order: 1; }
  .real-mushaf-tafsir-panel { order: 2; margin-top: 0; }
  .real-mushaf-page-caption span:last-child { display: none; }
  .real-mushaf-page-image { object-fit: cover; }
}
@media (prefers-reduced-motion: reduce) {
  .real-mushaf-page.turn-next, .real-mushaf-page.turn-previous { animation: none; }
}

/* Reference-matched reading scale: ordinary mode is a large open book; tafsir mode pairs the right page with a left ayah-by-ayah study column. */
.real-mushaf-reading-grid { grid-template-columns: minmax(360px, .74fr) minmax(0, 1.6fr); gap: 28px; }
.real-mushaf-visual-column { min-width: 0; }
.real-mushaf-book { width: min(100%, 1040px); min-height: 620px; }
.real-mushaf-page { aspect-ratio: 456 / 672; min-height: 0; }
.real-mushaf-page-image { object-fit: fill; }
.real-mushaf-tafsir-panel { max-height: 760px; overflow: hidden; display: flex; flex-direction: column; }
.real-mushaf-tafsir-list { min-height: 0; overflow-y: auto; padding-inline-end: 5px; }
.real-mushaf-tafsir-ayah { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--sanctuary-line); border-inline-start: 4px solid transparent; background: rgba(255,253,248,.68); transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.real-mushaf-tafsir-ayah:first-child { margin-top: 0; }
.real-mushaf-tafsir-ayah:hover, .real-mushaf-tafsir-ayah.is-active { border-inline-start-color: var(--sanctuary-copper); background: rgba(181,139,73,.11); transform: translateX(-2px); }
.real-mushaf-tafsir-ayah-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.real-mushaf-tafsir-ayah-label { color: var(--sanctuary-copper); font-size: 11px; font-weight: 900; }
.real-mushaf-ayah-audio { flex: 0 0 auto; }
.real-mushaf-ayah-arabic { margin: 8px 0 0; color: var(--sanctuary-teal); font-family: 'Amiri', serif; font-size: 18px; line-height: 1.9; }
.real-mushaf-tafsir-ayah-text { margin-top: 7px; color: var(--sanctuary-ink); font-family: 'Amiri', serif; font-size: 15px; line-height: 1.95; white-space: pre-line; }
.real-mushaf-tafsir-empty { padding: 24px; color: var(--sanctuary-muted); text-align: center; }
body:not(.light) .real-mushaf-tafsir-ayah { border-color: rgba(212,175,55,.18); background: rgba(10,15,30,.72); }
body:not(.light) .real-mushaf-tafsir-ayah:hover, body:not(.light) .real-mushaf-tafsir-ayah.is-active { background: rgba(212,175,55,.11); }
body:not(.light) .real-mushaf-ayah-arabic, body:not(.light) .real-mushaf-tafsir-ayah-text { color: #EFEBDD; }
@media (max-width: 900px) and (min-width: 768px) { .real-mushaf-book { min-height: 500px; } .real-mushaf-reading-grid { grid-template-columns: minmax(280px,.72fr) minmax(0,1.28fr); } }
@media (max-width: 767px) {
  .real-mushaf-book { width: min(100%, 330px); min-height: 0; }
  .real-mushaf-page { width: 100%; aspect-ratio: 456 / 672; }
  .real-mushaf-tafsir-panel { max-height: none; overflow: visible; }
  .real-mushaf-tafsir-list { overflow: visible; }
  .real-mushaf-tafsir-ayah { padding: 11px 12px; }
  .real-mushaf-ayah-arabic { font-size: 16px; }
  .real-mushaf-tafsir-ayah-text { font-size: 14px; }
}

/* The reference tafsir view is one large page on the right with one ayah-by-ayah tafsir column on the left. */
.real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr); width: min(100%, 620px); min-height: 0; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-primary { grid-column: 1; }
.real-mushaf-shell.is-tafsir .real-mushaf-stage { min-height: 0; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-caption span:last-child { display: none; }
.real-mushaf-shell:not(.is-tafsir) .real-mushaf-tafsir-panel { display: none; }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-book { width: min(100%, 340px); }
  .real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { display: flex; }
}

/* A dedicated leaf sits above the new spread so the old paper visibly folds across the gutter. */
.real-mushaf-book { position: relative; isolation: isolate; }
.real-mushaf-turning-leaf { position: absolute; inset-block: 0; inset-inline-start: 50%; width: calc(50% - 7px); z-index: 12; overflow: hidden; pointer-events: none; transform-style: preserve-3d; backface-visibility: hidden; border: 7px solid #e8ddc3; border-radius: 3px; background: #f6edcf; box-shadow: 0 20px 34px rgba(45,30,13,.25); }
.real-mushaf-turning-leaf .real-mushaf-page-image { width: 100%; height: 100%; object-fit: fill; }
.real-mushaf-turning-leaf .real-mushaf-ayah-overlay { display: none; }
.real-mushaf-turning-leaf.turn-next { transform-origin: right center; animation: realistic-leaf-next 720ms cubic-bezier(.18,.78,.22,1) both; }
.real-mushaf-turning-leaf.turn-previous { inset-inline-start: 0; transform-origin: left center; animation: realistic-leaf-previous 720ms cubic-bezier(.18,.78,.22,1) both; }
@keyframes realistic-leaf-next { 0% { transform: perspective(2200px) rotateY(0deg); filter: brightness(1); } 20% { transform: perspective(2200px) rotateY(-26deg) translateX(-1%); filter: brightness(.95); } 52% { transform: perspective(2200px) rotateY(-122deg) translateX(-6%); filter: brightness(.78); } 78% { transform: perspective(2200px) rotateY(-170deg) translateX(-2%); filter: brightness(.88); } 100% { transform: perspective(2200px) rotateY(-180deg); opacity: 0; } }
@keyframes realistic-leaf-previous { 0% { transform: perspective(2200px) rotateY(0deg); filter: brightness(1); } 20% { transform: perspective(2200px) rotateY(26deg) translateX(1%); filter: brightness(.95); } 52% { transform: perspective(2200px) rotateY(122deg) translateX(6%); filter: brightness(.78); } 78% { transform: perspective(2200px) rotateY(170deg) translateX(2%); filter: brightness(.88); } 100% { transform: perspective(2200px) rotateY(180deg); opacity: 0; } }
.real-mushaf-book.is-dragging .real-mushaf-turning-leaf { display: none; }
@media (max-width: 767px) {
  .real-mushaf-turning-leaf { inset-inline-start: 0; width: 100%; border-width: 5px; }
  .real-mushaf-turning-leaf.turn-next, .real-mushaf-turning-leaf.turn-previous { transform-origin: right center; }
}
@media (prefers-reduced-motion: reduce) { .real-mushaf-turning-leaf.turn-next, .real-mushaf-turning-leaf.turn-previous { animation: none; opacity: 0; } }

/* Reference correction: desktop spread fills the reader; tafsir is a two-panel open book (Quran right, tafsir left). The center spine never moves. */
.real-mushaf-reading-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
.real-mushaf-shell:not(.is-tafsir) .real-mushaf-reading-grid { grid-template-columns: minmax(0, 1fr); }
.real-mushaf-shell:not(.is-tafsir) .real-mushaf-visual-column { grid-column: 1; }
.real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { grid-template-columns: minmax(350px, .78fr) minmax(0, 1.22fr); align-items: stretch; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { grid-column: 1; grid-row: 1; min-height: 620px; max-height: 780px; margin-top: 0; }
.real-mushaf-shell.is-tafsir .real-mushaf-visual-column { grid-column: 2; grid-row: 1; }
.real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr); width: min(100%, 700px); min-height: 620px; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none; }
.real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-caption { max-width: 700px; margin-inline: auto; }
.real-mushaf-gutter { z-index: 30; pointer-events: none; transform: none !important; }
.real-mushaf-turning-leaf { left: 50%; right: auto; inset-inline-start: auto; width: calc(50% - 7px); z-index: 12; transform: none; }
.real-mushaf-turning-leaf.turn-next { left: 50%; right: auto; transform-origin: left center; }
.real-mushaf-turning-leaf.turn-previous { left: 0; right: auto; inset-inline-start: auto; transform-origin: right center; }
.real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf { left: 0; right: auto; width: 100%; }
.real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf.turn-next { transform-origin: left center; }
.real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf.turn-previous { transform-origin: right center; }
@keyframes realistic-leaf-next { 0% { transform: perspective(2200px) rotateY(0deg); filter: brightness(1); } 20% { transform: perspective(2200px) rotateY(28deg) translateX(1%); filter: brightness(.95); } 52% { transform: perspective(2200px) rotateY(124deg) translateX(6%); filter: brightness(.78); } 78% { transform: perspective(2200px) rotateY(170deg) translateX(2%); filter: brightness(.88); } 100% { transform: perspective(2200px) rotateY(180deg); opacity: 0; } }
@keyframes realistic-leaf-previous { 0% { transform: perspective(2200px) rotateY(0deg); filter: brightness(1); } 20% { transform: perspective(2200px) rotateY(-28deg) translateX(-1%); filter: brightness(.95); } 52% { transform: perspective(2200px) rotateY(-124deg) translateX(-6%); filter: brightness(.78); } 78% { transform: perspective(2200px) rotateY(-170deg) translateX(-2%); filter: brightness(.88); } 100% { transform: perspective(2200px) rotateY(-180deg); opacity: 0; } }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { display: flex; flex-direction: column; gap: 14px; }
  .real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { min-height: 0; max-height: none; order: 2; }
  .real-mushaf-shell.is-tafsir .real-mushaf-visual-column { order: 1; }
  .real-mushaf-shell.is-tafsir .real-mushaf-book { width: min(100%, 430px); min-height: 0; }
  .real-mushaf-shell:not(.is-tafsir) .real-mushaf-book { width: min(100%, 430px); min-height: 0; }
  .real-mushaf-turning-leaf, .real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf { left: 0; right: auto; width: 100%; }
  .real-mushaf-turning-leaf.turn-next, .real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf.turn-next { transform-origin: left center; }
  .real-mushaf-turning-leaf.turn-previous, .real-mushaf-shell.is-tafsir .real-mushaf-turning-leaf.turn-previous { transform-origin: right center; }
}

/* Drag correction: only the active leaf follows the pointer; the spine and the opposite page stay fixed. */
.real-mushaf-book.is-dragging .real-mushaf-turning-leaf { display: block; animation: none; transition: none; opacity: 1; }
.real-mushaf-turning-leaf.drag-next { transform-origin: left center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * 180deg)); }
.real-mushaf-turning-leaf.drag-previous { transform-origin: right center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * -180deg)); }
.real-mushaf-turning-leaf.drag-next::after, .real-mushaf-turning-leaf.drag-previous::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(42,26,10,.32), transparent 18%, transparent 74%, rgba(255,255,255,.22)); mix-blend-mode: multiply; opacity: calc(.15 + var(--drag-progress, 0) * .5); }
.real-mushaf-turning-leaf.turn-next::after, .real-mushaf-turning-leaf.turn-previous::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(42,26,10,.35), transparent 20%, transparent 76%, rgba(255,255,255,.2)); mix-blend-mode: multiply; }
@media (max-width: 767px) {
  .real-mushaf-turning-leaf.drag-next { transform-origin: right center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * -180deg)); }
  .real-mushaf-turning-leaf.drag-previous { transform-origin: left center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * 180deg)); }
}

/* Final visibility guard: desktop tafsir has exactly one Quran page in the right reading column; the left facing panel is the tafsir page. */
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none !important; }
.real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none !important; }
.real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr) !important; }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none !important; }
}

/* Tafsir spread order: the Quran page is the visual right leaf; the Arabic tafsir page is the visual left leaf. */
.real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { direction: ltr; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel,
.real-mushaf-shell.is-tafsir .real-mushaf-visual-column { direction: rtl; }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { direction: rtl; }
}

/* Final drag completion: the active paper leaf continues from the finger position; the center spine and opposite leaf remain untouched. */
.real-mushaf-turning-leaf.drag-next { transform-origin: left center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * 180deg)); }
.real-mushaf-turning-leaf.drag-previous { transform-origin: right center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * -180deg)); }
.real-mushaf-turning-leaf.finish-next { transform-origin: left center; animation: realistic-leaf-finish-next 280ms cubic-bezier(.22,.8,.25,1) both; }
.real-mushaf-turning-leaf.finish-previous { transform-origin: right center; animation: realistic-leaf-finish-previous 280ms cubic-bezier(.22,.8,.25,1) both; }
@keyframes realistic-leaf-finish-next {
  from { transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * 180deg)); filter: brightness(1); opacity: 1; }
  to { transform: perspective(2200px) rotateY(180deg); filter: brightness(.82); opacity: 0; }
}
@keyframes realistic-leaf-finish-previous {
  from { transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * -180deg)); filter: brightness(1); opacity: 1; }
  to { transform: perspective(2200px) rotateY(-180deg); filter: brightness(.82); opacity: 0; }
}
@media (max-width: 767px) {
  .real-mushaf-turning-leaf.drag-next { transform-origin: left center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * 180deg)); }
  .real-mushaf-turning-leaf.drag-previous { transform-origin: right center; transform: perspective(2200px) rotateY(calc(var(--drag-progress, 0) * -180deg)); }
  .real-mushaf-turning-leaf.finish-next { transform-origin: left center; }
  .real-mushaf-turning-leaf.finish-previous { transform-origin: right center; }
}

/* Empty turn leaf must never cover a Quran page between interactions. */
.real-mushaf-turning-leaf { display: none; }
.real-mushaf-turning-leaf.turn-next,
.real-mushaf-turning-leaf.turn-previous,
.real-mushaf-turning-leaf.drag-next,
.real-mushaf-turning-leaf.drag-previous,
.real-mushaf-turning-leaf.finish-next,
.real-mushaf-turning-leaf.finish-previous { display: block; }

/* Islamic library / Mushaf refinement — paper-to-paper tafsir, focus reading, and slower tactile page turns. */
.real-mushaf-shell.is-tafsir .real-mushaf-reading-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  align-items: stretch;
  gap: clamp(18px, 2.4vw, 42px);
}
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel {
  display: flex !important;
  flex-direction: column;
  align-self: stretch;
  min-height: clamp(620px, 62vw, 820px);
  max-height: clamp(620px, 62vw, 820px);
  overflow: hidden;
  background: #f5edda;
  color: #3e3426;
  border: 8px solid #dfcfa7;
  border-radius: 4px;
  box-shadow: 0 22px 40px rgba(63, 43, 19, .18), inset 0 0 0 1px rgba(126, 91, 34, .28);
  position: relative;
}
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel::before {
  content: '';
  position: absolute;
  inset: 7px;
  pointer-events: none;
  border: 1px solid rgba(126, 91, 34, .2);
}
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-header,
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-meta,
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-list {
  position: relative;
  z-index: 1;
}
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-header { padding: 26px 26px 18px; border-bottom: 1px solid rgba(126,91,34,.2); }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-header h3 { color: #2d625c; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-header .mushaf-mode-kicker,
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-meta { color: #8c6b38; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-meta { padding: 14px 26px; font-size: .82rem; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 22px 28px;
  scrollbar-color: #c2a66c transparent;
}
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-list article,
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-list .real-mushaf-tafsir-card {
  background: rgba(255, 251, 238, .66);
  border-color: rgba(126,91,34,.22);
  color: #3e3426;
}
.real-mushaf-page svg .ayahPolygon.is-selected,
.real-mushaf-page svg .ayahPolygon:focus-visible {
  filter: drop-shadow(0 0 5px rgba(190, 137, 32, .68));
  fill: #c99a3e;
  fill-opacity: .34;
  stroke: #b07a1e;
  stroke-opacity: .55;
  stroke-width: 1.25;
}
.real-mushaf-book { touch-action: pan-y; }
.real-mushaf-turning-leaf.turn-next,
.real-mushaf-turning-leaf.turn-previous,
.real-mushaf-turning-leaf.finish-next,
.real-mushaf-turning-leaf.finish-previous { animation-duration: 720ms !important; }
.real-mushaf-turning-leaf.finish-next { animation-name: realistic-leaf-finish-next !important; }
.real-mushaf-turning-leaf.finish-previous { animation-name: realistic-leaf-finish-previous !important; }
.real-mushaf-shell.is-focus-mode,
.real-mushaf-shell:fullscreen {
  background: #f8f3e6;
  color: #3e3426;
  width: 100%;
  min-height: 100dvh;
  padding: clamp(12px, 3vw, 40px);
  overflow: auto;
}
.real-mushaf-shell.is-focus-mode .real-mushaf-heading,
.real-mushaf-shell:fullscreen .real-mushaf-heading,
.real-mushaf-shell.is-focus-mode > .real-mushaf-source,
.real-mushaf-shell:fullscreen > .real-mushaf-source { display: none; }
.real-mushaf-shell.is-focus-mode .real-mushaf-book,
.real-mushaf-shell:fullscreen .real-mushaf-book { width: min(92vw, 1120px); }
.real-mushaf-shell.is-focus-mode .real-mushaf-tafsir-panel,
.real-mushaf-shell:fullscreen .real-mushaf-tafsir-panel { min-height: min(78vh, 900px); max-height: min(78vh, 900px); }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 18px; }
  .real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { min-height: 520px; max-height: 70vh; border-width: 6px; }
  .real-mushaf-shell .real-mushaf-book,
  .real-mushaf-shell.is-tafsir .real-mushaf-book { width: min(96vw, 520px) !important; max-width: none; }
  .real-mushaf-page-caption { font-size: .78rem; }
  .real-mushaf-fullscreen span { display: none; }
  .real-mushaf-fullscreen { min-width: 44px; padding-inline: 12px; }
  .real-mushaf-shell.is-focus-mode .real-mushaf-book,
  .real-mushaf-shell:fullscreen .real-mushaf-book { width: min(98vw, 620px) !important; }
  .real-mushaf-shell.is-focus-mode,
  .real-mushaf-shell:fullscreen { padding: 8px; }
}

/* Primary Haramain reader: keep the mode switch available but reclaim the hero space for the page itself. */
body.real-mushaf-active .mushaf-mode-chooser { padding: 16px 22px; margin-bottom: 18px; }
body.real-mushaf-active .mushaf-mode-heading { display: none; }
body.real-mushaf-active .mushaf-mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body.real-mushaf-active .mushaf-mode-option { min-height: 56px; padding: 10px 14px; }
@media (max-width: 767px) {
  body.real-mushaf-active .mushaf-mode-chooser { padding: 10px 12px; margin-bottom: 10px; }
  body.real-mushaf-active .mushaf-mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.real-mushaf-active .mushaf-mode-option { min-height: 48px; padding: 8px 9px; font-size: .78rem; }
  body.real-mushaf-active .mushaf-mode-option small { display: none; }
  body.real-mushaf-active .mushaf-mode-option-icon { width: 30px; height: 30px; }
}

/* Corrected tafsir spread: the second paper keeps its place in the open book and hosts the tafsir page inside it. */
.real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { grid-template-columns: minmax(0, 1fr); }
.real-mushaf-shell.is-tafsir .real-mushaf-visual-column { grid-column: 1; width: 100%; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: flex; flex-direction: column; min-width: 0; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-page-surface { display: none; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-panel { display: flex; flex: 1 1 auto; min-height: 0; max-height: none; width: 100%; margin: 0; padding: 22px 20px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-header { align-items: stretch; flex-direction: column; gap: 10px; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-picker { min-width: 0; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-ayah { background: rgba(255,253,248,.42); }
body:not(.light) .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-tafsir-ayah { background: rgba(10,15,30,.26); }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none; }
  .real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { display: flex; }
}

.real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); width: min(100%, 1040px); min-height: 620px; }
.real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: block; }
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr); width: min(100%, 430px); min-height: 0; }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none; }
}

/* Last override: tafsir mode is the same two-leaf book; only the adjacent leaf content changes. */
@media (min-width: 768px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr) !important; width: min(100%, 1040px) !important; min-height: 620px; }
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: flex !important; flex-direction: column; }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: block !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-reading-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-book { grid-template-columns: minmax(0, 1fr) !important; width: min(100%, 430px) !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent { display: none !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none !important; }
}

/* Original-site fixes only: center the paper reader on mobile and make the selected ayah unmistakable. */
.ayah.active {
  box-shadow: 0 8px 22px rgba(46, 139, 87, .22), inset 0 0 0 1px rgba(181, 139, 73, .38);
}
#realMushafBook .ayahPolygon.is-selected {
  stroke: var(--sanctuary-copper, #b58b49) !important;
  stroke-width: 2.5px !important;
  filter: drop-shadow(0 0 7px rgba(181, 139, 73, .72)) drop-shadow(0 5px 9px rgba(10, 15, 30, .34));
}
@media (max-width: 767px) {
  .real-mushaf-reading-grid { display: block !important; }
  .real-mushaf-visual-column { width: 100% !important; display: flex !important; flex-direction: column; align-items: center; }
  .real-mushaf-book { width: min(100%, 360px) !important; margin-inline: auto !important; }
  .real-mushaf-stage, .real-mushaf-page-caption { width: 100%; }
  .real-mushaf-page-primary, .real-mushaf-page-adjacent { margin-inline: auto !important; }
}
@media (min-width: 1000px) {
  .quran-header .nav-links { flex-wrap: nowrap !important; gap: 5px !important; }
  .quran-header .nav-link { padding-inline: 8px !important; font-size: 13px !important; }
}

/* ============================================================
   إصلاحات نهائية — وضع التفسير، تحديد الآية، وعرض الصفحة كاملة
   (تُضاف في آخر الملف لتكون هي الطبقة الحاسمة فوق ما سبقها)
   ============================================================ */

/* 1) عرض الصفحة وتحديد الآية:
      نص الصفحة يُرسم من ملف SVG ويظهر دائمًا، وإن نجح تحميل صورة المصحف المزخرفة
      تُخفى رسوم الـ SVG ويبقى فقط تحديد الآيات فوق الصورة. */
.real-mushaf-ayah-overlay { opacity: 1 !important; z-index: 2; }
.real-mushaf-ayah-overlay svg { display: block; width: 100%; height: 100%; }
.real-mushaf-page:not(.has-page-image) .real-mushaf-page-image,
.mushaf-flip-face:not(.has-page-image) .real-mushaf-page-image { display: none; }
.real-mushaf-page.has-page-image .real-mushaf-ayah-overlay svg *:not(.ayahPolygon),
.mushaf-flip-face.has-page-image .real-mushaf-ayah-overlay svg *:not(.ayahPolygon) {
  fill: transparent !important;
  stroke: none !important;
}
/* الإطار المزخرف صار عنصرًا مستقلًا (real-mushaf-page-frame) بأنماط مضمّنة */
.real-mushaf-page-adjacent.is-tafsir-page .real-mushaf-page-frame { display: none; }
.real-mushaf-ayah-overlay svg .ayahPolygon {
  cursor: pointer;
  pointer-events: all;
  fill: #1f6f8b;
  fill-opacity: 0;
  transition: fill-opacity 150ms ease;
}
.real-mushaf-ayah-overlay svg .ayahPolygon.is-selected,
#realMushafBook .ayahPolygon.is-selected {
  fill: #2f86a6 !important;
  fill-opacity: .20 !important;
  stroke: #2f86a6 !important;
  stroke-opacity: .85 !important;
  stroke-width: 1.4px !important;
}
@media (hover: hover) {
  .real-mushaf-ayah-overlay svg .ayahPolygon:hover { fill-opacity: .1 !important; }
}
.real-mushaf-ayah-overlay svg .ayahPolygon:focus-visible { fill-opacity: .16 !important; outline: none; }

/* 2) وضع التفسير: الكتاب نفسه مفتوح على ورقتين —
      الورقة اليمنى صفحة المصحف، واليسرى تفسير نفس الصفحة.
      لوحة التفسير عنصر ثابت داخل الورقة المقابلة ولا تُنقل أبدًا. */
.real-mushaf-page-content { position: absolute; inset: 0; }
.real-mushaf-shell:not(.is-tafsir) .real-mushaf-tafsir-panel { display: none !important; }
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent .real-mushaf-page-content { display: none !important; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel {
  position: absolute;
  inset: 0;
  display: flex !important;
  flex-direction: column;
  width: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  z-index: 4;
}
.real-mushaf-shell.is-tafsir .real-mushaf-reading-grid {
  display: grid !important;
  direction: rtl !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
}
.real-mushaf-shell.is-tafsir .real-mushaf-visual-column { grid-column: 1 !important; grid-row: 1 !important; width: 100%; }

@media (min-width: 768px) {
  /* نفس هيئة المصحف: ورقتان وفاصل بينهما */
  .real-mushaf-shell.is-tafsir .real-mushaf-book {
    grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr) !important;
    width: min(100%, 1040px) !important;
    min-height: 620px;
    margin-inline: auto;
  }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: block !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent {
    display: block !important;
    aspect-ratio: 456 / 672;
    overflow: hidden;
  }
}

/* شكل ورقة التفسير من الداخل */
.real-mushaf-tafsir-panel .real-mushaf-tafsir-header {
  flex: 0 0 auto;
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(122, 90, 30, .3);
  background: rgba(240, 231, 205, .55);
}
.real-mushaf-tafsir-panel .real-mushaf-tafsir-header h3 { font-size: 17px; }
.real-mushaf-tafsir-panel .real-mushaf-tafsir-picker { min-width: 0; }
.real-mushaf-tafsir-panel .real-mushaf-tafsir-meta {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(122, 90, 30, .18);
  background: rgba(47, 134, 166, .09);
}
.real-mushaf-tafsir-panel .real-mushaf-tafsir-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 10px 12px 16px;
}
.real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah {
  border: 1px solid rgba(122, 90, 30, .18);
  border-inline-start: 3px solid transparent;
  border-radius: 7px;
  background: rgba(255, 253, 246, .8);
}
.real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah.is-active {
  border-inline-start-color: #2f86a6;
  background: rgba(47, 134, 166, .12);
  transform: none;
}
.real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah-label { color: #1f6f8b; }
/* وجه ورقة التفسير أثناء التقليب */
.real-mushaf-tafsir-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f9f2df;
}
.real-mushaf-tafsir-ghost .real-mushaf-tafsir-list { overflow: hidden; }
body:not(.light) .real-mushaf-tafsir-panel .real-mushaf-tafsir-header { background: rgba(212, 175, 55, .08); border-color: rgba(212, 175, 55, .2); }
body:not(.light) .real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah { background: rgba(10, 15, 30, .55); border-color: rgba(212, 175, 55, .16); }
body:not(.light) .real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah.is-active { background: rgba(47, 134, 166, .2); }
body:not(.light) .real-mushaf-tafsir-ghost { background: rgba(16, 23, 48, .96); }

/* 3) الجوال: ورقة المصحف أعلى وورقة التفسير أسفلها — نفس العنصر، بلا أي نقل.
      الكتاب يصبح كتلة رأسية بسيطة، والورقتان تتقاسمان الشاشة فتظهران معًا. */
@media (max-width: 767px) {
  .real-mushaf-shell.is-tafsir .real-mushaf-book {
    display: block !important;
    width: min(100%, 430px) !important;
    min-height: 0 !important;
    margin-inline: auto !important;
  }
  .real-mushaf-shell.is-tafsir .real-mushaf-gutter { display: none !important; }
  .real-mushaf-shell.is-tafsir .real-mushaf-page-primary {
    display: block !important;
    position: relative;
    aspect-ratio: auto !important;
    height: 52vh;
    min-height: 320px;
  }
  .real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent {
    display: block !important;
    position: relative;
    aspect-ratio: auto !important;
    height: 44vh;
    min-height: 280px;
    margin-top: 12px;
  }
}

/* 4) زر ونافذة عرض صورة الصفحة كاملة على الشاشة */
.real-mushaf-fullpage-btn { gap: 7px; }
@media (max-width: 767px) {
  .real-mushaf-page-actions { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .real-mushaf-fullpage-btn span { display: inline; font-size: 9px; }
}
body.mushaf-fullpage-open { overflow: hidden; }
.mushaf-fullpage {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  background: #0d1220;
}
.mushaf-fullpage.is-open { display: flex; }
.mushaf-fullpage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: rgba(10, 15, 30, .92);
  color: #EFEBDD;
}
.mushaf-fullpage-bar button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(212, 175, 55, .3);
  border-radius: 12px;
  background: rgba(212, 175, 55, .1);
  color: #EFEBDD;
  font-size: 15px;
  cursor: pointer;
}
.mushaf-fullpage-zoom { display: flex; gap: 8px; }
.mushaf-fullpage-label { font-size: 12px; font-weight: 800; color: #D4AF37; }
.mushaf-fullpage-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 6px;
  background: #f6edcf;
}
.mushaf-fullpage-stage.is-zoomed { place-items: start center; }
.mushaf-fullpage-stage img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center top;
  transition: transform 180ms ease;
  user-select: none;
}
.mushaf-fullpage-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: rgba(10, 15, 30, .92);
}
.mushaf-fullpage-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid rgba(212, 175, 55, .3);
  border-radius: 13px;
  background: rgba(212, 175, 55, .12);
  color: #EFEBDD;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.mushaf-fullpage-nav button:disabled { opacity: .35; cursor: not-allowed; }
@media (min-width: 768px) {
  .mushaf-fullpage-stage img { width: auto; max-width: min(96vw, 900px); }
}
/* عند وجود صورة الصفحة المزخرفة تُخفى أي عناصر رسومية من طبقة الـ SVG */
.has-page-image .real-mushaf-ayah-overlay svg image,
.has-page-image .real-mushaf-ayah-overlay svg text,
.has-page-image .real-mushaf-ayah-overlay svg tspan { opacity: 0 !important; }

/* ============================================================
   تقليب الأوراق: ورقة حقيقية بوجهين تُطوى مع الإصبع
   ============================================================ */
/* الكتاب نفسه ليس مجالًا ثلاثي الأبعاد: لو كان كذلك تُرتَّب الورقة المتحركة
   وأوراق الكتاب حسب العمق فتغوص الورقة تحت ورقة التفسير. المنظور صار داخل
   تحويل الورقة المتحركة نفسها، فيبقى ترتيب الطبقات (z-index) هو الحاكم. */
.real-mushaf-book { position: relative; isolation: isolate; perspective: none !important; }
.real-mushaf-page { transform-style: flat !important; }
.mushaf-flip {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 60;
  display: none;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
  transform: perspective(2200px) rotateY(var(--flip-angle, 0deg));
}
.mushaf-flip.is-active { display: block; }
.mushaf-flip-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 7px solid #e8ddc3;
  border-radius: 3px;
  background: #f9f2df;
  box-shadow: 0 20px 34px rgba(45, 30, 13, .3);
}
.mushaf-flip-back { transform: rotateY(180deg); }
.mushaf-flip-face .real-mushaf-page-image { display: block; width: 100%; height: 100%; object-fit: fill; }
.mushaf-flip-face .real-mushaf-ayah-overlay { position: absolute; inset: 0; pointer-events: none; }
.mushaf-flip-face::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: calc(.12 + var(--flip-progress, 0) * .38);
  background: linear-gradient(90deg, rgba(40, 25, 8, .45), rgba(40, 25, 8, 0) 22%, rgba(255, 255, 255, .18) 82%, rgba(255, 255, 255, .3));
}
/* وضع الصفحتين: الورقة التالية تُمسك من اليسار، والسابقة من اليمين، والمِفصل هو خط المنتصف */
.mushaf-flip.is-spread { width: calc(50% - 7px); }
.mushaf-flip.is-spread.to-next { left: 0; transform-origin: right center; }
.mushaf-flip.is-spread.to-previous { right: 0; transform-origin: left center; }
/* وضع الصفحة الواحدة (الجوال أو التفسير) */
.mushaf-flip.is-single { left: 0; width: 100%; }
.mushaf-flip.is-single.to-next { transform-origin: right center; }
.mushaf-flip.is-single.to-previous { transform-origin: left center; }
.real-mushaf-book { touch-action: pan-y; }
@media (prefers-reduced-motion: reduce) { .mushaf-flip-face::after { opacity: .12; } }
.mushaf-fullpage-svg { width: 100%; max-width: min(96vw, 900px); background: #f9f2df; padding: 8px; border-radius: 4px; }
.mushaf-fullpage-svg svg { display: block; width: 100%; height: auto; }
.mushaf-fullpage-svg .ayahPolygon { fill-opacity: 0; }
.real-mushaf-page-adjacent.is-tafsir-page::after { display: none !important; }

/* ============================================================
   تصحيحات الإصدار 20: موضع الصفحة، الوجه المعكوس، انثناء الورق،
   وصفحة النص الاحتياطية
   ============================================================ */

/* 1) كل صفحة في مكانها: الفردية يمين والزوجية شمال، والتفسير في الجهة المقابلة */
/* ترتيب الورقتين لم يعد يعتمد على خاصية order إطلاقًا:
   الترتيب يُنفَّذ بترتيب العناصر نفسها داخل الكتاب (DOM)، فيصحّ في كل الأوضاع. */
.real-mushaf-book .real-mushaf-page-primary,
.real-mushaf-book .real-mushaf-gutter,
.real-mushaf-book .real-mushaf-page-adjacent,
.real-mushaf-shell.is-tafsir .real-mushaf-page-primary,
.real-mushaf-shell.is-tafsir .real-mushaf-page-adjacent,
.real-mushaf-shell.is-tafsir .real-mushaf-visual-column,
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { order: 0 !important; }

/* 2) منع ظهور الوجه معكوسًا: نُخفي الوجه غير المرئي صراحةً بدل الاعتماد على backface فقط */
.mushaf-flip:not(.past-half) .mushaf-flip-back { visibility: hidden; }
.mushaf-flip.past-half .mushaf-flip-front { visibility: hidden; }
.mushaf-flip.past-half .mushaf-flip-back { visibility: visible; }

/* 3) انثناء الورقة أثناء التقليب مثل الورق الحقيقي */
.mushaf-flip {
  transform: perspective(2200px) rotateY(var(--flip-angle, 0deg)) scaleY(calc(1 - var(--flip-bend, 0) * .022));
}
.mushaf-flip-face {
  border-radius: 3px;
  box-shadow:
    0 calc(6px + var(--flip-bend, 0) * 26px) calc(12px + var(--flip-bend, 0) * 34px) rgba(45, 30, 13, calc(.16 + var(--flip-bend, 0) * .26)),
    inset 0 0 0 1px rgba(119, 89, 42, .28);
}
.mushaf-flip-face::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: calc(var(--flip-bend, 0) * .9);
  background: linear-gradient(
    100deg,
    rgba(60, 40, 14, .34) 0%,
    rgba(255, 255, 255, .26) 18%,
    rgba(255, 255, 255, .04) 42%,
    rgba(60, 40, 14, .12) 68%,
    rgba(60, 40, 14, .34) 100%
  );
  mix-blend-mode: multiply;
}

/* 4) صفحة النص الاحتياطية: تظهر إن تعذّر تحميل رسم الصفحة أو صورتها */
.real-mushaf-text-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 15px 26px;
  background: #f9f2df;
  color: #241f16;
  direction: rtl;
}
.real-mushaf-text-head {
  flex: 0 0 auto;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(122, 90, 30, .35);
  color: #7a5a1e;
  font-family: 'El Messiri', sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}
.real-mushaf-text-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  font-family: 'Amiri', 'Traditional Arabic', serif;
  font-size: clamp(17px, 2.1vw, 22px);
  line-height: 2.3;
  text-align: justify;
  text-justify: inter-word;
}
.real-mushaf-text-foot {
  flex: 0 0 auto;
  padding-top: 6px;
  color: #a08a5c;
  font-size: 11px;
  text-align: center;
}
.real-mushaf-text-page .ayahPolygon {
  display: inline;
  border-radius: 3px;
  cursor: pointer;
  transition: background 150ms ease;
}
.real-mushaf-text-page .ayahPolygon.is-selected { background: rgba(47, 134, 166, .22); box-shadow: 0 0 0 1px rgba(47, 134, 166, .5); }
@media (hover: hover) { .real-mushaf-text-page .ayahPolygon:hover { background: rgba(47, 134, 166, .1); } }
.real-mushaf-text-number { color: #a9761d; font-size: .86em; }
.real-mushaf-page.is-text-page::after { display: none; }

/* بصمة إصدار ملف الأنماط — تُستخدم للتشخيص من الكونسول */
:root { --jame-css-version: "29"; }

/* الورقة المتحركة فوق كل شيء داخل الكتاب — بما فيه ورقة التفسير وفاصل المنتصف */
.real-mushaf-book .mushaf-flip { z-index: 60 !important; }
.real-mushaf-shell.is-tafsir .real-mushaf-tafsir-panel { z-index: 4; }
.real-mushaf-gutter { z-index: 3 !important; }

/* الورقة المتحركة تعلو كل عناصر الكتاب دائمًا */
#mushafFlip.is-active, #paperBookFlip.is-active { z-index: 999 !important; }

/* الكتاب في وضع التفسير بلا أشرطة كعب مزخرفة تفتح عمودًا جانبيًا */
.mushaf-book-plain::before, .mushaf-book-plain::after { content: none !important; display: none !important; }
.mushaf-book-plain { perspective: none !important; }
.mushaf-book-plain .mushaf-flip { z-index: 999 !important; }

/* العناصر الوهمية للكعب والظل لا تُحسب أبدًا كعناصر شبكة:
   تُثبَّت فوق الكتاب كله بموضع مطلق فلا تزاحم الأوراق في التوزيع. */
.real-mushaf-book::before,
.real-mushaf-book::after,
.mushaf-book-plain::before,
.mushaf-book-plain::after {
  position: absolute !important;
  grid-area: 1 / 1 / 2 / 4 !important;
  pointer-events: none !important;
}

/* ============================================================
   النسخة 29: عرض الصفحة كاملة على الجوال + مساحة تفسير مريحة
   ============================================================ */
.mushaf-fullpage-stage { padding: 0 !important; align-items: start !important; }
.mushaf-fullpage-svg {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto;
  padding: 4px;
  background: #f9f2df;
  border-radius: 0;
  transition: transform 180ms ease;
}
.mushaf-fullpage-svg svg { display: block; width: 100%; height: auto; }
.mushaf-fullpage-svg svg * { fill: #231f20; }
.mushaf-fullpage-svg .ayahPolygon { fill: transparent !important; }
/* زر خروج صغير عائم فوق الصفحة */
.mushaf-fullpage-exit {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  inset-inline-start: 10px;
  z-index: 30;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(212, 175, 55, .5);
  border-radius: 50%;
  background: rgba(13, 18, 32, .82);
  color: #EFEBDD;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35);
}
@media (min-width: 768px) { .mushaf-fullpage-exit { width: 42px; height: 42px; } }

/* التفسير على الجوال: خط أوضح ومساحة قراءة أوسع */
@media (max-width: 767px) {
  .real-mushaf-tafsir-panel .real-mushaf-tafsir-list { padding: 12px 13px 20px; }
  .real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah { padding: 12px 12px 14px; margin-bottom: 12px; }
  .real-mushaf-tafsir-panel .real-mushaf-tafsir-ayah-text { font-size: 16px; line-height: 2; }
  .real-mushaf-tafsir-panel .real-mushaf-ayah-arabic { font-size: 18px; line-height: 2.1; }
  .real-mushaf-page-actions .real-mushaf-fullpage-btn { grid-column: span 2; }
}
