/* ===== ملف التنسيقات - المصحف ===== */

@font-face {
  font-family: 'Hafs Smart';
  src: url('hafssmart_8.woff2') format('woff2'),
       url('hafssmart_8.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0c0b09;
  --bg2: #131210;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(212,175,55,0.18);
  --border-hover: rgba(212,175,55,0.35);
  --gold: #d4af37;
  --gold-light: #f0d060;
  --gold-dim: rgba(212,175,55,0.55);
  --text: #f0ead8;
  --text-dim: rgba(240,234,216,0.55);
  --text-muted: rgba(240,234,216,0.35);
  --overlay: rgba(5,4,3,0.82);
  --radius: 18px;
  --radius-sm: 10px;
  --font: 'Hafs Smart', 'Traditional Arabic', serif;

  /* لون تعبئة أزرار السور (يُستخدم في ثيم الأوركا فقط) */
  --btn-fill: transparent;
  --btn-fill-text: var(--text);

  /* عامل تكبير/تصغير خط النص القرآني (يتحكم به المستخدم من القائمة) */
  --font-scale: 1;

  /* الحجم الموحّد لكل الأرقام العربية التي يعرضها الكود (رقم السورة/الآية/
     الصفحة وغيرها)، مطابق لحجم رقم الآية الظاهر أعلى حقل القائمة السفلية
     عند الضغط على آية. استُخدمت وحدة rem حتى يبقى الحجم ثابتاً بصرياً
     أينما استُخدم، بغض النظر عن حجم خط العنصر الأب المحيط به. */
  --code-num-size: 1.364rem;
}

body.light-mode {
  --bg: #faf7f0;
  --bg2: #f2ede2;
  --surface: rgba(0,0,0,0.04);
  --surface-hover: rgba(0,0,0,0.07);
  --border: rgba(139,100,20,0.2);
  --border-hover: rgba(139,100,20,0.4);
  --gold: #8b6414;
  --gold-light: #b08020;
  --gold-dim: rgba(139,100,20,0.5);
  --text: #1a1408;
  --text-dim: rgba(26,20,8,0.55);
  --text-muted: rgba(26,20,8,0.35);
  --overlay: rgba(240,234,216,0.85);
}

/* ===== ثيم الأوركا: خلفية سوداء قاتمة وأزرار بيضاء حليبية ===== */
body.theme-orca {
  --bg: #060608;
  --bg2: #0c0c10;
  --surface: rgba(255,255,255,0.035);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(245,242,235,0.16);
  --border-hover: rgba(245,242,235,0.32);
  --gold: #f5f2e9;
  --gold-light: #ffffff;
  --gold-dim: rgba(245,242,235,0.55);
  --text: #eeece4;
  --text-dim: rgba(238,236,228,0.55);
  --text-muted: rgba(238,236,228,0.35);
  --overlay: rgba(0,0,0,0.88);
  --btn-fill: #f5f1e6;
  --btn-fill-text: #0a0a0c;
}

body.theme-orca::before {
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(245,242,235,0.05) 0%, transparent 70%),
    radial-gradient(ellipse 45% 35% at 85% 95%, rgba(245,242,235,0.035) 0%, transparent 60%);
}

/* ===== ثيم أخضر: خلفية رمادية داكنة قليلاً ونصوص بيضاء مع لمسة خضراء باهتة ===== */
body.theme-sage {
  --bg: #202422;
  --bg2: #282d2a;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(159,216,160,0.18);
  --border-hover: rgba(159,216,160,0.35);
  --gold: #9fd8a0;
  --gold-light: #c9ecc9;
  --gold-dim: rgba(159,216,160,0.55);
  --text: #ffffff;
  --text-dim: rgba(255,255,255,0.55);
  --text-muted: rgba(255,255,255,0.35);
  --overlay: rgba(15,17,16,0.85);
}

body.theme-sage::before {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(159,216,160,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 90%, rgba(159,216,160,0.04) 0%, transparent 60%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
*:focus-visible { outline: 2px solid var(--gold-dim); outline-offset: 2px; }
*:focus:not(:focus-visible) { outline: none; }
* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 100px;
  transition: background 0.4s, color 0.4s;
  position: relative;
  overflow-x: hidden;
}

/* خلفية زخرفية */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(212,175,55,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 90%, rgba(212,175,55,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  transition: background 0.4s;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ===== رأس الصفحة ===== */
.app-header {
  text-align: center;
  padding: 48px 0 26px;
  position: relative;
}

.app-header .ornament {
  display: block;
  font-size: 1.3em;
  color: var(--gold-dim);
  letter-spacing: 10px;
  margin-bottom: 14px;
  line-height: 1.8;
}

h1 {
  font-size: clamp(2.2em, 5vw, 3.2em);
  font-weight: 400;
  color: var(--text);
  letter-spacing: 8px;
  text-shadow: 0 0 40px rgba(212,175,55,0.12);
}

.app-header .divider {
  width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 18px auto 0;
}

/* ===== مربع البحث ===== */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 18px;
  margin: 6px 0 18px;
  transition: border-color 0.25s, background 0.25s;
}

.search-box:focus-within {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.search-box svg {
  width: 19px; height: 19px;
  flex-shrink: 0;
  color: var(--gold-dim);
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 1.02em;
  min-width: 0;
}

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

.search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1em;
  padding: 2px 4px;
  display: none;
}

.search-box input:not(:placeholder-shown) ~ .search-clear { display: inline-block; }

.search-results {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
}

.search-results.open { display: flex; }

.search-result-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.25s;
  width: 100%;
}

.search-result-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.sr-ref {
  font-size: 0.82em;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.sr-text {
  font-size: 1em;
  color: var(--text);
  line-height: 1.9;
}

.search-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 0;
  font-size: 0.95em;
}

/* ===== الشاشة الرئيسية ===== */
.main-view { display: none; animation: fadeUp 0.5s ease; }
.surah-view { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleUp {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.93); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes menuSlide {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes panelSlideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes flashHighlight {
  0%, 100% { background: transparent; }
  30% { background: rgba(212,175,55,0.35); }
}

/* ===== قائمة السور: زر واحد في كل صف ===== */
.surah-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0 24px;
}

.surah-btn {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 18px 20px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  text-align: right;
}

.surah-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212,175,55,0.07), transparent);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.surah-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.surah-btn:hover::after { opacity: 1; }
.surah-btn:active { transform: translateY(0); }

.surah-btn-badge {
  flex-shrink: 0;
  min-width: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: var(--code-num-size);
  font-weight: 600;
  text-shadow: 0 0 20px rgba(212,175,55,0.15);
}

.surah-btn-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.surah-btn-name-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.surah-btn-name {
  font-size: clamp(1.3em, 3.4vw, 1.6em);
  color: var(--text);
}

.surah-btn-type {
  font-size: 0.85em;
  color: var(--gold-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-family: 'Traditional Arabic', serif;
  letter-spacing: 0.5px;
}

.surah-btn-meta {
  font-size: 1.12em;
  color: var(--text-dim);
  font-family: 'Traditional Arabic', serif;
  letter-spacing: 0.3px;
}

/* تخصيص أزرار السور في ثيم الأوركا: شارة بيضاء حليبية والنص خارجها */
body.theme-orca .surah-btn {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 4px;
}

body.theme-orca .surah-btn:hover {
  background: var(--surface);
  transform: none;
}

body.theme-orca .surah-btn::after { display: none; }

body.theme-orca .surah-btn-badge {
  color: var(--gold);
}

body.theme-orca .surah-btn-type {
  border-color: var(--border);
  color: var(--text-dim);
}

/* ===== محتوى السورة ===== */
.surah-header {
  text-align: center;
  padding: 40px 0 22px;
}

.surah-header h1 {
  font-size: clamp(1.8em, 4vw, 2.6em);
}

.surah-header .divider {
  width: 180px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 14px auto 0;
}

.bismillah {
  text-align: center;
  font-size: clamp(1.5em, 3.5vw, 1.9em);
  color: var(--gold-light);
  padding: 28px 20px 24px;
  border-bottom: 1px solid var(--border);
  line-height: 2.2;
  letter-spacing: 1px;
}

/* وضع التمرير */
.surah-content {
  text-align: justify;
  line-height: 3.6;
  font-size: calc(clamp(1.3em, 3.4vw, 1.85em) * var(--font-scale));
  padding: clamp(20px, 5vw, 40px) clamp(16px, 4vw, 36px);
  max-width: 820px;
  margin: 0 auto;
  direction: rtl;
  word-spacing: 4px;
  -webkit-touch-callout: none;
}

/* كتلة صفحة مصحف واحدة داخل وضع التمرير: content-visibility تجعل المتصفح
   يتجاهل حساب التنسيق والرسم للكتل البعيدة عن الشاشة، فيُخفَّف العبء على
   المعالج في السور الطويلة دون أي تغيير في شكل القراءة المستمر */
.scroll-page-block {
  content-visibility: auto;
  contain-intrinsic-size: auto 900px;
}

/* وضع تقليب الصفحات */
.page-flip-container {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.page-flip-container.active { display: flex; }

.page-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  min-height: 70vh;
  padding: clamp(56px, 9vw, 76px) clamp(18px, 5vw, 44px) clamp(46px, 7vw, 60px);
  direction: rtl;
  position: relative;
  animation: fadeUp 0.35s ease;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3), inset 0 1px 0 rgba(212,175,55,0.06);
}

.page-meta-top {
  position: absolute;
  top: 18px; left: 20px; right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95em;
  color: var(--gold-dim);
  letter-spacing: 0.5px;
}

.page-surah-name {
  color: var(--gold);
}

.page-surah-type {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
}

.page-body {
  font-size: calc(clamp(1.3em, 3.4vw, 1.85em) * var(--font-scale));
  line-height: 3.4;
  text-align: justify;
  word-spacing: 4px;
}

.page-num-corner {
  position: absolute;
  bottom: 16px; right: 20px;
  font-family: 'Traditional Arabic', serif;
  font-size: var(--code-num-size);
  color: var(--gold-dim);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
  margin-bottom: 10px;
}

.page-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.3s;
}

.page-nav-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: scale(1.08);
}

.page-nav-btn svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.page-indicator {
  font-family: 'Traditional Arabic', serif;
  font-size: 1.25em;
  color: var(--text-dim);
  min-width: 90px;
  text-align: center;
}

/* آية بها ملاحظة */
.aya-span {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
  padding: 0 2px;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.aya-span.has-note {
  background: rgba(212,175,55,0.12);
  border-bottom: 1.5px solid var(--gold-dim);
}

.aya-span.flash-highlight {
  animation: flashHighlight 1.8s ease;
  border-radius: 6px;
}

/* ===== الشريط السفلي (حبّة عائمة منضبطة) ===== */
.bottom-bar {
  position: fixed;
  bottom: 18px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 900;
  pointer-events: none;
}

.bottom-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px;
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 34px rgba(0,0,0,0.35);
  pointer-events: auto;
}

.bottom-bar-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 48px; height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.3s;
}

.bottom-bar-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--gold);
  transform: translateY(-2px);
}

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

.bottom-bar-btn svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ===== القائمة الجانبية ===== */
.side-menu {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 50%;
  min-width: 260px;
  max-width: 360px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 950;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.34, 0.9, 0.4, 1);
  box-shadow: -12px 0 40px rgba(0,0,0,0.4);
}

.side-menu.open {
  transform: translateX(0);
  animation: panelSlideIn 0.35s cubic-bezier(0.34, 0.9, 0.4, 1);
}

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

.side-menu-title {
  font-size: 1.2em;
  color: var(--gold);
  letter-spacing: 1px;
}

.side-menu-items {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 14px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1em;
  text-align: right;
  transition: all 0.2s;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface-hover);
  color: var(--gold);
}

.menu-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  color: var(--gold-dim);
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* ===== نوافذ منبثقة عامة ===== */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 940;
  animation: fadeIn 0.25s ease;
  backdrop-filter: blur(3px);
}

.popup-overlay.open { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  width: 92%;
  max-width: 420px;
  z-index: 1001;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal.open {
  display: block;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-title {
  font-size: 1.25em;
  color: var(--gold);
  letter-spacing: 1px;
}

.modal-close {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1em;
  transition: all 0.2s;
}

.modal-close:hover { color: var(--text); background: var(--surface-hover); }

/* ===== نافذة الملاحظات ===== */
.note-textarea {
  width: 100%;
  min-height: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1em;
  padding: 12px 14px;
  resize: vertical;
  direction: rtl;
  line-height: 1.8;
  transition: border 0.2s;
  margin-bottom: 14px;
}

.note-textarea:focus {
  border-color: var(--border-hover);
}

.note-ref {
  font-size: 0.85em;
  color: var(--gold-dim);
  margin-bottom: 14px;
  padding: 8px 12px;
  background: rgba(212,175,55,0.05);
  border-radius: 8px;
  border: 1px solid rgba(212,175,55,0.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  flex: 1;
  padding: 11px;
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.12));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-family: var(--font);
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(212,175,55,0.28), rgba(212,175,55,0.18));
}

.btn-danger {
  padding: 11px 16px;
  background: rgba(220,50,50,0.08);
  border: 1px solid rgba(220,50,50,0.25);
  border-radius: var(--radius-sm);
  color: rgba(220,120,120,0.9);
  font-family: var(--font);
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: rgba(220,50,50,0.14); }

.btn-secondary {
  padding: 11px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }

/* ===== قائمة الملاحظات ===== */
.notes-list {
  max-height: 340px;
  overflow-y: auto;
  margin-top: 4px;
}

.notes-list::-webkit-scrollbar { width: 4px; }
.notes-list::-webkit-scrollbar-track { background: transparent; }
.notes-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.note-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
}

.note-item:hover { border-color: var(--border-hover); background: var(--surface-hover); }

.note-item-ref {
  font-size: 0.78em;
  color: var(--gold-dim);
  margin-bottom: 6px;
}

.note-item-text {
  font-size: 0.92em;
  color: var(--text);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notes-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 0;
  font-size: 0.95em;
}

/* ===== نافذة العلامة المرجعية ===== */
.modal input[type="text"],
.modal input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1em;
  transition: border 0.2s;
}

.modal input:focus { border-color: var(--border-hover); }
.modal input::placeholder { color: var(--text-muted); }

.bookmark-display {
  margin-top: 14px;
  padding: 14px;
  background: rgba(212,175,55,0.05);
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: var(--radius-sm);
  display: none;
}

.bookmark-display p {
  color: var(--text);
  font-size: 0.95em;
  line-height: 1.8;
  margin-bottom: 12px;
}

.bookmark-goto-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.92em;
}

.bookmark-hint {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-bottom: 14px;
  line-height: 1.7;
}

/* ===== حقول القوائم المنسدلة (اختيار السورة / الصفحة / الآية) ===== */
.dropdown-field {
  position: relative;
  margin-bottom: 12px;
}

.dropdown-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1em;
  cursor: pointer;
  transition: border 0.2s, background 0.2s;
  text-align: right;
}

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

.dropdown-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dropdown-chevron {
  width: 16px; height: 16px;
  flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  color: var(--gold-dim);
  transition: transform 0.2s;
}

.dropdown-field.open .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-list {
  display: none;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  z-index: 20;
  padding: 6px;
}

.dropdown-list.open { display: flex; }

.dropdown-list::-webkit-scrollbar { width: 4px; }
.dropdown-list::-webkit-scrollbar-track { background: transparent; }
.dropdown-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95em;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--surface-hover);
  color: var(--gold);
}

/* ===== نافذة التعليمات ===== */
.info-section {
  margin-bottom: 16px;
}

.info-section-title {
  color: var(--gold);
  font-size: 0.95em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(212,175,55,0.15);
}

.info-list {
  list-style: none;
  padding: 0;
}

.info-list li {
  color: var(--text);
  font-size: 0.92em;
  line-height: 1.9;
  padding-right: 14px;
  position: relative;
}

.info-list li::before {
  content: '◈';
  position: absolute;
  right: 0;
  color: var(--gold-dim);
  font-size: 0.7em;
  top: 0.35em;
}

.info-scroll {
  max-height: 360px;
  overflow-y: auto;
  padding-left: 4px;
}

.info-scroll::-webkit-scrollbar { width: 3px; }
.info-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== تحسينات الشاشات الصغيرة ===== */
@media (max-width: 600px) {
  .surah-content { line-height: 3.3; }
  .page-card { line-height: 3.1; }
  .page-body { font-size: calc(clamp(1.2em, 5vw, 1.6em) * var(--font-scale)); }
  .side-menu { width: 78%; max-width: none; }
}

/* ===== صفحة البحث عن الآيات (تصفح كل الآيات) ===== */
.ayah-search-view { display: none; }

.ayah-search-view .search-box {
  position: sticky;
  top: 10px;
  z-index: 5;
  background: var(--bg2);
}

.ayah-index-surah-title {
  color: var(--gold);
  font-size: 1.1em;
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  letter-spacing: 1px;
}

.ayah-index-surah-title:first-child { margin-top: 6px; }

.ayah-index-block {
  text-align: justify;
  line-height: 3.2;
  font-size: clamp(1.05em, 2.8vw, 1.3em);
  padding: 0 4px 10px;
  direction: rtl;
}

.browse-aya {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  transition: background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.browse-aya:hover { background: var(--surface-hover); }

.index-aya-num {
  color: var(--gold-dim);
  font-size: 0.72em;
}

/* ===== عناصر إضافية في القائمة الجانبية: حجم الخط وثيمات ===== */
.menu-fontsize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

.menu-fontsize-label {
  color: var(--text);
  font-size: 1em;
}

.fontsize-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fontsize-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--gold);
  font-size: 1.15em;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.fontsize-btn:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.fontsize-btn:active { transform: scale(0.94); }

.fontsize-value {
  min-width: 46px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85em;
}

.menu-theme-section { padding: 12px 14px 14px; }

.menu-theme-label {
  display: block;
  color: var(--text);
  font-size: 1em;
  margin-bottom: 10px;
}

.theme-swatches { display: flex; gap: 12px; }

.theme-swatch {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  padding: 0;
}

.theme-swatch[data-theme="dark"]  { background: linear-gradient(135deg, #0c0b09 50%, #d4af37 50%); }
.theme-swatch[data-theme="light"] { background: linear-gradient(135deg, #faf7f0 50%, #8b6414 50%); }
.theme-swatch[data-theme="orca"]  { background: linear-gradient(135deg, #060608 50%, #f5f2e9 50%); }
.theme-swatch[data-theme="sage"]  { background: linear-gradient(135deg, #202422 50%, #9fd8a0 50%); }

.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.22);
}

/* ===== زر إنشاء ثيم مخصص ===== */
.custom-theme-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-theme-btn svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

.custom-theme-btn:hover {
  background: var(--surface-hover);
  color: var(--gold);
  border-color: var(--gold-dim);
}

.custom-theme-btn.active {
  background: var(--surface-hover);
  color: var(--gold);
  border-color: var(--gold-dim);
  border-style: solid;
}

/* ===== لوحة سرعة وضع القراءة التلقائي (التمرير الذاتي) ===== */
#autoScrollBtn.active {
  background: var(--surface-hover);
  color: var(--gold);
}

#autoScrollBtn.active svg { color: var(--gold); }

.autoscroll-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 4px 14px 16px;
}

.autoscroll-panel.open { display: flex; }

.autoscroll-speed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autoscroll-speed-label {
  color: var(--text);
  font-size: 1em;
}

.autoscroll-speed-value {
  color: var(--gold);
  font-size: var(--code-num-size);
  min-width: 24px;
  text-align: center;
}

.autoscroll-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.autoscroll-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.autoscroll-range::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.autoscroll-confirm-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.95em;
}

/* ===== القائمة السفلية لخيارات الآية (نسخ / ملاحظة) ===== */
.action-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 92%;
  max-width: 460px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 10px 18px 22px;
  z-index: 1010;
  transition: transform 0.32s cubic-bezier(0.34,0.9,0.4,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
}

.action-sheet.open { transform: translate(-50%, 0); }

.action-sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 14px;
}

.action-sheet-ref {
  text-align: center;
  color: var(--gold-dim);
  font-size: 0.88em;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.action-sheet-ref-num {
  font-size: 1.55em;
  font-weight: 600;
  color: var(--gold);
  font-family: 'Traditional Arabic', serif;
}

/* حجم موحّد لكل الأرقام التي يعرضها الكود في مواضع مختلفة من التطبيق
   (علامة الحفظ، حقول اختيار رقم الآية/الصفحة، نتائج البحث، الملاحظات...)
   ليطابق حجم رقم الآية أعلاه، دون التأثير على أي تنسيق آخر (لون/وزن) لأن
   هذه الخصائص موروثة من العنصر المحيط بكل رقم. */
.code-num {
  font-size: var(--code-num-size);
}

.action-sheet-text {
  text-align: center;
  color: var(--text);
  font-size: 1.05em;
  line-height: 1.9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.action-sheet-btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.action-sheet-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 14px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.action-sheet-btn:hover { background: var(--surface-hover); border-color: var(--border-hover); color: var(--gold); }

.action-sheet-btn svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  color: var(--gold-dim);
}

.action-sheet-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 6px;
}

.action-sheet-notes:empty { display: none; }

.action-sheet-notes::-webkit-scrollbar { width: 4px; }
.action-sheet-notes::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.action-sheet-note-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9em;
  line-height: 1.8;
  word-break: break-word;
}

.action-sheet-notes-label {
  color: var(--gold-dim);
  font-size: 0.8em;
  margin-bottom: 2px;
  letter-spacing: 0.3px;
}

.action-sheet-cancel {
  display: block;
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.95em;
  cursor: pointer;
}

.action-sheet-cancel:hover { color: var(--text); }

/* ===== نافذة نسخ نطاق آيات ===== */
.copy-range-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.copy-range-field { flex: 1; }

.copy-range-field label {
  display: block;
  font-size: 0.82em;
  color: var(--gold-dim);
  margin-bottom: 6px;
}

.copy-range-field input {
  width: 100%;
  padding: 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Traditional Arabic', serif;
  font-size: 1.9em;
  font-weight: 600;
  text-align: center;
}

.copy-range-field input:focus { border-color: var(--border-hover); }

.copy-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 220px;
  overflow-y: auto;
  color: var(--text);
  font-family: 'Traditional Arabic', serif;
  font-size: 1em;
  line-height: 2;
  white-space: pre-wrap;
  direction: rtl;
  margin-bottom: 16px;
}

.copy-preview::-webkit-scrollbar { width: 4px; }
.copy-preview::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.copy-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 0.92em;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== قائمة الملاحظات المتعددة لآية واحدة ===== */
.note-entries {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-entries::-webkit-scrollbar { width: 4px; }
.note-entries::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.note-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.note-entry-text {
  flex: 1;
  color: var(--text);
  font-size: 0.92em;
  line-height: 1.8;
  word-break: break-word;
}

.note-entry-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95em;
  flex-shrink: 0;
  padding: 2px 4px;
}

.note-entry-delete:hover { color: rgba(220,120,120,0.9); }

/* ===== نافذة مشاركة آية كصورة ===== */
.share-section { margin-bottom: 18px; }

.share-section-label {
  display: block;
  color: var(--gold-dim);
  font-size: 0.85em;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.share-range-count {
  color: var(--text-dim);
  font-size: 0.82em;
  margin-top: 8px;
  text-align: center;
}

.share-mode-row {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}

.share-mode-btn {
  flex: 1;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.88em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.share-mode-btn:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.share-mode-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: linear-gradient(135deg, rgba(212,175,55,0.16), rgba(212,175,55,0.08));
}

.share-fontsize-manual { padding: 10px 4px 0; }

/* ===== نافذة إنشاء ثيم مخصص ===== */
.custom-theme-modal { max-height: 88vh; overflow-y: auto; }

.custom-theme-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.custom-theme-preview-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.custom-theme-preview-text { font-size: 0.95em; }

.custom-field-tabs { display: flex; gap: 8px; margin-bottom: 14px; }

.custom-field-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.78em;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-field-tab:hover { background: var(--surface-hover); }

.custom-field-tab.active {
  border-color: var(--gold);
  color: var(--gold);
}

.custom-field-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  display: block;
}

.custom-color-square-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  touch-action: none;
  cursor: crosshair;
  border: 1px solid var(--border);
}

.custom-color-square { display: block; width: 100%; height: 100%; }

.custom-color-marker {
  position: absolute;
  top: 0; left: 0;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 1.1em;
  font-weight: bold;
  text-shadow: 0 0 2px #000, 0 0 4px #000;
  pointer-events: none;
}

.hue-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  margin-bottom: 12px;
  background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
}

.hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(0,0,0,0.35);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.hue-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(0,0,0,0.35);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.custom-color-hex {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85em;
  margin-bottom: 16px;
  letter-spacing: 1px;
  direction: ltr;
}

/* ===== بطاقة الصورة المُصدَّرة (تُبنى وتُلتقط خارج الشاشة، لا تظهر للمستخدم) =====
   لها متغيرات ألوان مستقلة (--ec-*) ثابتة بصيغة hex/rgba (متوافقة مع html2canvas)
   بدل الاعتماد على ثيم واجهة التطبيق الحالي، حتى يمكن اختيار ثيم للصورة مختلف
   عن ثيم التطبيق المعروض دون التأثير على أي منهما. */
.export-card-wrap {
  position: fixed;
  top: -10000px;
  left: -10000px;
  width: 720px;
  pointer-events: none;
}

.export-card {
  --ec-bg: #0c0b09;
  --ec-border: rgba(212,175,55,0.18);
  --ec-gold: #d4af37;
  --ec-gold-light: #f0d060;
  --ec-gold-dim: rgba(212,175,55,0.55);
  --ec-text: #f0ead8;
  --ec-text-dim: rgba(240,234,216,0.55);
  --ec-font-scale: 1;

  background: var(--ec-bg);
  color: var(--ec-text);
  font-family: 'Hafs Smart', 'Traditional Arabic', serif;
  border: 1px solid var(--ec-border);
  border-radius: 22px;
  padding: 46px 38px;
  direction: rtl;
}

.export-card[data-theme="light"] {
  --ec-bg: #faf7f0;
  --ec-border: rgba(139,100,20,0.2);
  --ec-gold: #8b6414;
  --ec-gold-light: #b08020;
  --ec-gold-dim: rgba(139,100,20,0.5);
  --ec-text: #1a1408;
  --ec-text-dim: rgba(26,20,8,0.55);
}

.export-card[data-theme="orca"] {
  --ec-bg: #060608;
  --ec-border: rgba(245,242,235,0.16);
  --ec-gold: #f5f2e9;
  --ec-gold-light: #ffffff;
  --ec-gold-dim: rgba(245,242,235,0.55);
  --ec-text: #eeece4;
  --ec-text-dim: rgba(238,236,228,0.55);
}

.export-card[data-theme="sage"] {
  --ec-bg: #202422;
  --ec-border: rgba(159,216,160,0.18);
  --ec-gold: #9fd8a0;
  --ec-gold-light: #c9ecc9;
  --ec-gold-dim: rgba(159,216,160,0.55);
  --ec-text: #ffffff;
  --ec-text-dim: rgba(255,255,255,0.55);
}

.export-card-header { text-align: center; margin-bottom: 22px; }

.export-card-surah {
  color: var(--ec-gold);
  font-size: 1.4em;
}

.export-card-range {
  color: var(--ec-text-dim);
  font-size: 0.85em;
  margin-top: 6px;
  font-family: 'Traditional Arabic', serif;
}

.export-card-divider {
  width: 140px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ec-gold-dim), transparent);
  margin: 16px auto 0;
}

.export-card-bismillah {
  text-align: center;
  color: var(--ec-gold-light);
  font-size: 1.35em;
  margin-bottom: 22px;
  line-height: 2;
}

.export-card-text {
  text-align: justify;
  line-height: 3;
  word-spacing: 4px;
  font-size: calc(1.55em * var(--ec-font-scale));
}

.export-card-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--ec-border);
  color: var(--ec-gold-dim);
  font-size: 0.8em;
}