/* =====================================================================
   مُسمِّع — Mobile-first luxury Islamic UI (430px shell)
   ===================================================================== */
/* =====================================================================
   Interface typeface — Readex Pro (SIL Open Font License)
   Bundled locally so the whole app, not only the Quran text, works
   without a network connection. Arabic and Latin subsets are enough for
   the supported interface languages; other scripts fall back naturally.
   ===================================================================== */
@font-face {
  font-family: 'Readex Pro';
  src: url('../assets/fonts/ReadexPro-arabic.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Readex Pro';
  src: url('../assets/fonts/ReadexPro-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =====================================================================
   Authentic Quran typeface — King Fahd Complex Uthmanic Hafs (KFGQPC)
   The font is bundled locally and always takes precedence over every
   system font. Amiri / Scheherazade are deliberately NOT loaded or used
   as fallbacks for Quranic text.
   ===================================================================== */
@font-face {
  font-family: 'KFGQPC Uthmanic Hafs';
  src: url('../assets/fonts/UthmanicHafs1Ver18.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/* The classical Madani Mushaf family name is aliased to the same bundled
   KFGQPC file. This keeps legacy selectors authentic and guarantees that
   no system Naskh or generic serif is ever substituted for Quran text. */
@font-face {
  font-family: 'KFGQPC Uthman Taha Naskh';
  src: url('../assets/fonts/UthmanicHafs1Ver18.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  color-scheme: light;

  /* Warm parchment canvas, olive-gold accents and deep ink. */
  --bg-base: #f1e7d4;
  --bg-surface: #fbf5e9;
  --bg-card: rgba(255, 251, 243, 0.9);
  --bg-elevated: #fffaf0;
  --border-color: rgba(116, 92, 48, 0.16);
  --border-strong: rgba(116, 92, 48, 0.3);
  --border-focus: #5f6b2f;

  --ink-primary: #241f16;
  --ink-secondary: #5d5342;
  --ink-muted: #8e8069;

  --accent-primary: #5f6b2f;
  --accent-deep: #47521f;
  --accent-light: rgba(95, 107, 47, 0.1);
  --accent-glow: rgba(95, 107, 47, 0.2);
  --gold: #a97f2f;
  --gold-soft: rgba(169, 127, 47, 0.1);

  --status-ok: #2e7d32;
  --status-ok-bg: rgba(46, 125, 50, 0.12);
  --status-bad: #c62828;
  --status-bad-bg: rgba(198, 40, 40, 0.1);
  --status-skip: #b8600a;
  --status-skip-bg: rgba(184, 96, 10, 0.12);

  --shadow-sm: 0 2px 10px rgba(80, 58, 25, 0.08);
  --shadow-md: 0 10px 30px rgba(80, 58, 25, 0.12);
  --shadow-lg: 0 20px 50px rgba(80, 58, 25, 0.18);
  --topbar-bg: rgba(244, 234, 216, 0.9);
  --nav-bg: rgba(255, 250, 240, 0.94);
  --btn-primary-ink: #ffffff;

  --nav-height: 72px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-mushaf: 'KFGQPC Uthmanic Hafs', 'KFGQPC Uthman Taha Naskh';
  --font-ui: 'Readex Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  --quran-features: "kern" 1, "liga" 1, "calt" 1, "mark" 1, "mkmk" 1;
  /* Persisted reader preference (0.8 = 80%, 1 = 100%, 1.6 = 160%). */
  --quran-font-scale: 1;
  --mushaf-highlight: rgba(15, 59, 46, 0.13);
  --mushaf-highlight-line: rgba(15, 59, 46, 0.72);
  --mushaf-highlight-gold: rgba(184, 137, 60, 0.22);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-base: #0e120c;
  --bg-surface: #171d14;
  --bg-card: rgba(24, 31, 23, 0.88);
  --bg-elevated: #20291d;
  --border-color: rgba(216, 181, 106, 0.17);
  --border-strong: rgba(216, 181, 106, 0.34);
  --border-focus: #b8cf72;

  --ink-primary: #f6efdf;
  --ink-secondary: #cdc4ae;
  --ink-muted: #938b77;

  --accent-primary: #a9bd6b;
  --accent-deep: #748c3d;
  --accent-light: rgba(169, 189, 107, 0.14);
  --accent-glow: rgba(169, 189, 107, 0.28);
  --gold: #d8b56a;
  --gold-soft: rgba(216, 181, 106, 0.13);

  --status-ok: #84d38c;
  --status-ok-bg: rgba(132, 211, 140, 0.15);
  --status-bad: #f07b7b;
  --status-bad-bg: rgba(240, 123, 123, 0.16);
  --status-skip: #e8b35d;
  --status-skip-bg: rgba(232, 179, 93, 0.16);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --topbar-bg: rgba(14, 18, 12, 0.92);
  --nav-bg: rgba(23, 29, 20, 0.92);
  --btn-primary-ink: #141810;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-base: #0e120c;
    --bg-surface: #171d14;
    --bg-card: rgba(24, 31, 23, 0.88);
    --bg-elevated: #20291d;
    --border-color: rgba(216, 181, 106, 0.17);
    --border-strong: rgba(216, 181, 106, 0.34);
    --border-focus: #b8cf72;
    --ink-primary: #f6efdf;
    --ink-secondary: #cdc4ae;
    --ink-muted: #938b77;
    --accent-primary: #a9bd6b;
    --accent-deep: #748c3d;
    --accent-light: rgba(169, 189, 107, 0.14);
    --accent-glow: rgba(169, 189, 107, 0.28);
    --gold: #d8b56a;
    --gold-soft: rgba(216, 181, 106, 0.13);
    --status-ok: #84d38c;
    --status-ok-bg: rgba(132, 211, 140, 0.15);
    --status-bad: #f07b7b;
    --status-bad-bg: rgba(240, 123, 123, 0.16);
    --status-skip: #e8b35d;
    --status-skip-bg: rgba(232, 179, 93, 0.16);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
    --topbar-bg: rgba(14, 18, 12, 0.92);
    --nav-bg: rgba(23, 29, 20, 0.92);
    --btn-primary-ink: #141810;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(216, 181, 106, 0.1), transparent 65%),
    radial-gradient(700px 480px at 90% 110%, rgba(108, 140, 62, 0.12), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.ambient-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ambient-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.32; animation: floatOrb 26s ease-in-out infinite alternate; }
.orb-1 { width: 380px; height: 380px; top: -120px; inset-inline-start: -120px; background: radial-gradient(circle, rgba(216, 181, 106, 0.4), transparent 70%); }
.orb-2 { width: 340px; height: 340px; bottom: -80px; inset-inline-end: -100px; background: radial-gradient(circle, rgba(137, 170, 73, 0.34), transparent 70%); animation-delay: -9s; }
.orb-3 { width: 260px; height: 260px; top: 48%; inset-inline-start: 42%; background: radial-gradient(circle, rgba(202, 170, 98, 0.18), transparent 70%); animation-delay: -16s; }
@keyframes floatOrb { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(26px, -30px, 0) scale(1.14); } }

.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  height: 100%;
  height: 100dvh;
  margin-inline: auto;
  overflow: hidden;
  background: var(--bg-base);
  border-inline: 1px solid transparent;
  padding-top: env(safe-area-inset-top, 0px);
}

.main-viewport {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  min-height: 60px;
  padding: 9px clamp(14px, 4vw, 18px) 10px;
  border-bottom: 1px solid var(--border-color);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  z-index: 10;
}

.app-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.brand-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 13px;
  display: grid; place-items: center; color: #161a10;
  background: linear-gradient(140deg, var(--gold), var(--accent-primary) 62%, #5c6d31);
  box-shadow: 0 5px 14px rgba(169, 127, 47, 0.18), 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}
.brand-icon svg { width: 21px; height: 21px; }
.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.brand-title {
  font-size: 15.5px;
  font-weight: 700;
  /* The Arabic diacritics need a little more room than the old 1.12
     line-height, which let the title brush the subtitle underneath. */
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--ink-primary);
  text-rendering: optimizeLegibility;
}
.brand-sub {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--gold);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0;
  min-height: 32px;
  font-size: 10px; font-weight: 700; line-height: 1; color: var(--ink-secondary);
  border: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--gold-soft), rgba(255, 255, 255, 0.16));
  border-radius: 999px; padding: 0 11px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 2px 7px rgba(80, 58, 25, 0.06);
}
.topbar-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-light); }

.views-container { position: relative; flex: 1; min-height: 0; overflow: hidden; }

.view-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: clamp(10px, 2.8vw, 16px);
  padding-inline: clamp(10px, 3.2vw, 16px);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  scroll-padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 8px, 0);
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.view-panel.active { opacity: 1; visibility: visible; transform: none; }
.view-panel::-webkit-scrollbar { width: 5px; }
.view-panel::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.split-view-grid { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.equal-split { gap: 14px; }

.mobile-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 7px);
  transform: translateX(-50%) translateZ(0);
  width: min(calc(100% - 16px), 408px);
  height: var(--nav-height);
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 6px;
  z-index: 100;
  border: 1px solid var(--border-strong);
  border-radius: 25px;
  background: var(--nav-bg);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255, 255, 255, 0.42) inset;
}

.mobile-bottom-nav-pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  border-radius: 19px;
  background: linear-gradient(180deg, var(--accent-light), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--accent-primary);
  box-shadow: 0 3px 11px var(--accent-glow), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1), width 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, width;
  pointer-events: none;
}
.mobile-nav-btn {
  position: relative; z-index: 2; flex: 1; min-width: 44px; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 3px 2px 2px;
  border: none; border-radius: 19px; background: transparent; color: var(--ink-muted);
  font-family: inherit; font-size: 10px; font-weight: 700; line-height: 1.05; cursor: pointer;
  transition: color 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-btn.active { color: var(--accent-primary); }
.mobile-nav-btn.active span { font-weight: 800; }
.mobile-nav-btn:active { transform: scale(0.96); }
.mobile-nav-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.mobile-nav-btn svg {
  width: 21px; height: 21px; stroke: currentColor; stroke-width: 1.7; fill: none;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-nav-btn.active svg { transform: translateY(-1px) scale(1.05); }
.mobile-nav-btn span { display: block; white-space: nowrap; }

/* ─── cards ─────────────────────────────────────────────────────────── */
.glass-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  min-width: 0;
}
.glass-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; min-width: 0; }
.card-header.center-header { justify-content: center; }
.card-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.card-title { font-size: 14.5px; font-weight: 800; color: var(--ink-primary); display: flex; align-items: center; gap: 7px; min-width: 0; line-height: 1.35; }
.card-title svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }
.mode-badge, .fixed-badge, .sync-quality {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 5px 8px; border-radius: 999px;
  color: var(--gold); background: var(--gold-soft);
  border: 1px solid var(--border-color); white-space: nowrap;
}
.mode-badge.is-test { color: var(--status-bad); background: var(--status-bad-bg); border-color: rgba(240, 113, 113, 0.3); }
.sync-quality.is-exact { color: var(--status-ok); background: var(--status-ok-bg); border-color: rgba(121, 201, 130, 0.3); }

/* ─── fields / forms ────────────────────────────────────────────────── */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.field-grid .field-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 11px; font-weight: 700; color: var(--ink-muted); line-height: 1.3; }
.field-compact { max-width: 100%; }

.form-select, .form-input {
  width: 100%; min-width: 0; height: 46px; padding: 0 13px;
  border-radius: 13px; border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--ink-primary);
  font-family: inherit; font-size: 13.5px; font-weight: 600; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d8b56a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 13px center; background-size: 15px;
  padding-left: 36px;
}
.form-select:focus, .form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-light); }
.form-input::placeholder { color: var(--ink-muted); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="time"] { color-scheme: inherit; }

html[dir="ltr"] .form-select { background-position: right 13px center; padding-left: 13px; padding-right: 36px; }
html[dir="ltr"] .field label,
html[dir="ltr"] .card-title,
html[dir="ltr"] .settings-note { text-align: left; }

.toggle-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 44px; margin-top: 4px; padding: 4px 2px;
  font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--ink-secondary);
  cursor: pointer; touch-action: manipulation;
}
.toggle-row input {
  width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ─── buttons ───────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px;
  font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  touch-action: manipulation;
}
.btn-primary { border: none; color: var(--btn-primary-ink); background: linear-gradient(135deg, var(--gold), var(--accent-primary)); box-shadow: 0 6px 18px var(--accent-glow); }
.btn-secondary { border: 1px solid var(--border-color); color: var(--ink-primary); background: var(--bg-surface); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-secondary:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: var(--accent-light); }
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }
.full-width { width: 100%; }
.danger-outline { color: var(--status-bad); border-color: rgba(240, 113, 113, 0.3); }

.btn-icon {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  border-radius: 12px; border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--ink-primary);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  touch-action: manipulation;
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent-primary); border-color: var(--accent-primary); }
.btn-icon svg { width: 19px; height: 19px; }
.btn-icon.active { color: var(--accent-primary); border-color: var(--accent-primary); background: var(--accent-light); }

/* ─── mushaf / Quranic text ─────────────────────────────────────────── */
.mushaf-card {
  position: relative;
  padding: 12px 11px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(216, 181, 106, 0.06), transparent 40%),
    var(--bg-card);
  box-shadow: var(--shadow-md);
  min-width: 0;
}
.surah-header-ornament {
  position: relative; text-align: center; padding: 9px 12px; margin-bottom: 8px;
  border: 1px solid var(--border-color); outline: 3px double var(--border-color);
  outline-offset: -4px; border-radius: 14px;
  background: linear-gradient(135deg, var(--gold-soft), transparent 70%);
}
.surah-title-arabic {
  font-family: var(--font-mushaf); font-size: 23px; font-weight: 400; line-height: 1.5;
  direction: rtl; color: var(--ink-primary);
  font-synthesis: none;
  font-feature-settings: var(--quran-features);
  -webkit-font-feature-settings: var(--quran-features);
}
.surah-meta-badges { display: flex; justify-content: center; gap: 8px; margin-top: 2px; font-size: 10.5px; font-weight: 600; color: var(--gold); }
.bismillah-banner {
  text-align: center; font-family: var(--font-mushaf); font-size: 24px; font-weight: 400; line-height: 1.9;
  direction: rtl; color: var(--ink-secondary); margin-bottom: 4px;
  overflow-wrap: break-word;
  font-synthesis: none;
  font-variant-ligatures: common-ligatures contextual;
  font-feature-settings: var(--quran-features);
  -webkit-font-feature-settings: var(--quran-features);
  text-rendering: optimizeLegibility;
}
.mushaf-wajh-container { width: 100%; min-width: 0; }
.mushaf-wajh-text {
  font-family: var(--font-mushaf);
  font-size: calc(clamp(17px, 4.4vw, 20px) * var(--quran-font-scale, 1));
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.9;
  /* Canonical Mushaf line flow: all soft-wrapped lines are justified
     edge-to-edge in RTL with the same rule used by the ornamental sheet,
     while the closing line always keeps its natural width. */
  text-align: justify;
  text-align-last: right;
  text-justify: inter-word;
  text-justify: kashida;
  text-indent: 0;
  word-spacing: normal;
  direction: rtl;
  color: var(--ink-primary);
  padding: 0;
  min-height: 140px;
  hyphens: none;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-ligatures: common-ligatures contextual;
  text-rendering: optimizeLegibility;
  -webkit-font-feature-settings: var(--quran-features);
  font-feature-settings: var(--quran-features);
  animation: fadeIn 0.25s ease;
}
/* The final line of a complete surah keeps its natural length. */
.mushaf-wajh-text.is-surah-end { text-align-last: right; }
.mushaf-wajh-text .loading, .mushaf-wajh-text .load-error {
  display: block; font-family: var(--font-ui); font-size: 13px; line-height: 1.7;
  text-align: center; color: var(--ink-muted); padding: 34px 10px;
}
.mushaf-wajh-text .load-error { color: var(--status-bad); }

.w {
  display: inline; padding: 0 0.09em; border-radius: 0.18em;
  transition: color 0.18s ease, background-color 0.18s ease;
  position: relative;
}
.w.ok { color: var(--status-ok); background: var(--status-ok-bg); font-weight: 700; }
.w.bad { color: #fff; background: var(--status-bad); animation: shake 0.32s ease; }
.w.missing { color: var(--status-skip); background: var(--status-skip-bg); border-bottom: 2px dashed var(--status-skip); }
.w.current {
  /* A soft inline fill only — never a bottom rule or underline. */
  background: var(--mushaf-highlight, var(--accent-light));
  border-bottom: 0;
  box-shadow: none;
  animation: none;
}
.mushaf-ayah {
  display: inline; padding: 1px 3px; border-radius: 8px; cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.mushaf-ayah:hover { background: var(--accent-light); }
.mushaf-ayah.playing-ayah {
  color: var(--ink-primary);
  /* A single calm band, matching the canonical Mushaf sheet. No inset
     ring, underline, bottom rule or pulsing halo. */
  background-color: transparent;
  background-image: linear-gradient(180deg, var(--gold-soft), var(--accent-light));
  background-repeat: no-repeat;
  background-size: 100% 0.94em;
  background-position: 50% 0.3em;
  border-bottom: 0;
  text-decoration: none;
  box-shadow: none;
  animation: none;
}
.mushaf-ayah.playing-ayah .ayah-marker { border-color: var(--gold); background: var(--gold); color: #141810; }

.num, .ayah-marker {
  display: inline-block; font-family: var(--font-ui); font-size: 11px; font-weight: 800;
  color: var(--gold); background: var(--gold-soft); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 2px 6px; margin: 0 3px; direction: ltr;
  vertical-align: middle; line-height: 1.35; white-space: nowrap;
}
.mushaf-hidden .w:not(.ok):not(.bad) {
  color: transparent !important; background: rgba(15, 59, 46, 0.08);
  text-shadow: 0 0 9px rgba(25, 21, 16, 0.5); filter: blur(5px);
  opacity: 0.45; user-select: none;
}
.mushaf-hidden .w.current {
  filter: blur(4px) !important;
  opacity: 0.78 !important;
  /* The position cue is the translucent band alone; no underline. */
  background: var(--mushaf-highlight, var(--accent-light)) !important;
  text-decoration: none !important;
}
.mushaf-hidden .ayah-medallion, .mushaf-hidden .num, .mushaf-hidden .ayah-marker { filter: none !important; opacity: 1 !important; color: var(--gold) !important; }

/* ─── canonical Mushaf sheet reused by Listening & Recitation ─────── */
/* Highlights are painted as relative-sized bands instead of filling the
   inline box. The font's ascent/descent are much taller than the visible
   glyphs, so a full-box background or bottom border looks bloated and
   collides with the Waqf marks of the following line. */
.mushaf-sheet .w {
  padding: 0 0.09em;
  border-radius: 0.18em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.mushaf-sheet .w.ok {
  color: #14663f;
  background-image: linear-gradient(180deg, rgba(20, 102, 63, 0.14), rgba(20, 102, 63, 0.14));
  background-repeat: no-repeat;
  background-size: 100% 0.88em;
  background-position: 50% 0.36em;
  font-weight: 700;
}
.mushaf-sheet .w.bad {
  color: #8d1f1f;
  background-image: linear-gradient(180deg, rgba(180, 40, 40, 0.18), rgba(180, 40, 40, 0.18));
  background-repeat: no-repeat;
  background-size: 100% 0.88em;
  background-position: 50% 0.36em;
}
.mushaf-sheet .w.missing {
  color: #8a5a00;
  background-image: linear-gradient(180deg, rgba(176, 118, 20, 0.18), rgba(176, 118, 20, 0.18));
  background-repeat: no-repeat;
  background-size: 100% 0.88em;
  background-position: 50% 0.36em;
  text-decoration: underline dashed rgba(138, 90, 0, 0.7);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
}
.mushaf-sheet .w.current {
  color: var(--mushaf-emerald, #0f3b2e);
  background-color: transparent;
  /* Compact relative band that hugs the glyphs. No bottom line, border,
     underline or animated halo: only one calm semi-transparent fill. */
  background-image: linear-gradient(180deg, var(--mushaf-highlight), var(--mushaf-highlight));
  background-repeat: no-repeat;
  background-size: 100% 0.9em;
  background-position: 50% 0.34em;
  border-radius: 0.2em;
  border-bottom: 0;
  text-decoration: none;
  box-shadow: none;
  animation: none;
}
.mushaf-verse {
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.mushaf-verse[role="button"] { cursor: pointer; }
.mushaf-verse[role="button"]:not(.playing-ayah):hover {
  background-image: linear-gradient(180deg, rgba(184, 137, 60, 0.16), rgba(184, 137, 60, 0.16));
  background-repeat: no-repeat;
  background-size: 100% 0.92em;
  background-position: 50% 0.32em;
}
.mushaf-verse[role="button"]:focus-visible {
  outline: 2px solid rgba(184, 137, 60, 0.8);
  outline-offset: 2px;
}
.mushaf-verse.playing-ayah {
  background-color: transparent;
  /* Active-ayah highlight: one soft gold wash, never an underline layer. */
  background-image: linear-gradient(180deg, var(--mushaf-highlight-gold), var(--mushaf-highlight));
  background-repeat: no-repeat;
  background-size: 100% 0.94em;
  background-position: 50% 0.3em;
  border-bottom: 0;
  text-decoration: none;
  box-shadow: none;
}
.tasmie-footer-card { display: flex; flex-direction: column; gap: 2px; padding: 11px 12px 6px; }
.tasmie-footer-card .tasmie-progress { margin: 0 2px 7px; }
.tasmie-footer-card .mushaf-pagination-bar { margin-top: 0; }

.tasmie-progress { margin: 10px 0 4px; padding: 0 2px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--ink-muted); margin-bottom: 6px; }
.progress-meta b { color: var(--accent-primary); }
.progress-track { height: 7px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-color); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-primary), var(--gold)); transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.mushaf-pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--border-color);
}
.btn-wajh-nav {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: 0 8px; border-radius: 11px;
  border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--ink-secondary); font-family: inherit; font-size: 10.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.btn-wajh-nav span { overflow: hidden; text-overflow: ellipsis; }
.btn-wajh-nav:hover { background: var(--accent-light); color: var(--accent-primary); }
.btn-wajh-nav:disabled { opacity: 0.3; pointer-events: none; }
.wajh-indicator { min-width: 0; flex: 1; text-align: center; overflow: hidden; }
.wajh-indicator-number { font-size: 11px; font-weight: 800; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wajh-indicator-surah-range { font-size: 9.5px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* ─── listening ayah search ────────────────────────────────────────── */
.ayah-search-card {
  position: relative;
  z-index: 30;
  margin-bottom: 12px;
  padding: 12px 14px 11px;
  background:
    linear-gradient(135deg, var(--gold-soft), transparent 55%),
    var(--bg-card);
}
.ayah-search-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px; min-width: 0;
}
.ayah-search-head .card-title { font-size: 12.5px; gap: 6px; }
.ayah-search-head .card-title svg { width: 16px; height: 16px; }
.ayah-search-count { font-size: 9.5px; }
.ayah-search-count[hidden] { display: none; }
.ayah-search-row { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.ayah-search-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.ayah-search-glyph {
  position: absolute; inset-inline-start: 13px; width: 17px; height: 17px;
  color: var(--ink-muted); pointer-events: none;
}
.ayah-search-input {
  height: 46px; padding-inline-start: 38px; padding-inline-end: 40px;
  font-size: 13px; font-weight: 600; text-align: start;
}
.ayah-search-input::-webkit-search-cancel-button,
.ayah-search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.ayah-search-clear {
  position: absolute; inset-inline-end: 6px; width: 32px; height: 32px;
  display: grid; place-items: center; border: none; border-radius: 50%;
  background: transparent; color: var(--ink-muted); cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.ayah-search-clear:hover { color: var(--status-bad); background: var(--status-bad-bg); }
.ayah-search-clear[hidden] { display: none; }
.ayah-search-clear svg { width: 15px; height: 15px; }
.ayah-search-go { flex-shrink: 0; min-height: 46px; padding-inline: 16px; }
.ayah-search-hint {
  margin-top: 6px; font-size: 10.5px; line-height: 1.45;
  color: var(--ink-muted); min-height: 15px;
}
.ayah-search-results {
  position: absolute; z-index: 60; top: calc(100% + 6px); inset-inline: 0;
  max-height: min(54vh, 430px); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px; border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
}
.ayah-search-results[hidden] { display: none; }
.search-result {
  display: block; width: 100%; padding: 9px 10px;
  border: none; border-radius: 13px; background: transparent;
  color: var(--ink-primary); font-family: inherit; text-align: start;
  cursor: pointer; transition: background 0.18s ease;
}
.search-result:hover,
.search-result.is-active { background: var(--accent-light); }
.search-result + .search-result { margin-top: 2px; }
.search-result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 3px; min-width: 0; flex-wrap: wrap;
}
.search-result-surah {
  font-size: 12px; font-weight: 800; color: var(--accent-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.search-result-meta span {
  padding: 2px 6px; border-radius: 999px;
  font-size: 9px; font-weight: 700; color: var(--gold);
  background: var(--gold-soft); border: 1px solid var(--border-color);
  white-space: nowrap;
}
.search-result-snippet {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; direction: rtl; text-align: right;
  font-family: var(--font-mushaf); font-size: 18px; font-weight: 400;
  line-height: 1.95; color: var(--ink-primary);
  font-synthesis: none; font-feature-settings: var(--quran-features);
  -webkit-font-feature-settings: var(--quran-features);
  overflow-wrap: break-word;
}
.search-result-snippet mark {
  color: inherit; background: rgba(169, 127, 47, 0.26);
  border-radius: 4px; padding: 0 1px;
  box-shadow: inset 0 -0.38em 0 rgba(169, 127, 47, 0.14);
}
.search-result-empty { padding: 14px 10px; }

/* ─── tasmee companion ─────────────────────────────────────────────── */
.companion-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.teacher-speech-bubble {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px;
  border-radius: 18px; border: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--gold-soft), var(--bg-card));
  box-shadow: var(--shadow-sm);
}
.teacher-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #151a10;
  background: linear-gradient(140deg, var(--gold), var(--accent-primary));
  box-shadow: 0 4px 14px var(--accent-glow);
}
.teacher-avatar svg { width: 21px; height: 21px; }
.teacher-content { min-width: 0; }
.teacher-name { font-size: 11px; font-weight: 800; color: var(--gold); margin-bottom: 3px; }
.teacher-message { font-size: 12.5px; font-weight: 600; line-height: 1.55; color: var(--ink-primary); overflow-wrap: break-word; }
.teacher-message.success { color: var(--status-ok); font-weight: 700; }
.teacher-message.error { color: var(--status-bad); font-weight: 700; }
.teacher-message.warning { color: var(--status-skip); font-weight: 700; }
.teacher-message.encouragement { color: var(--accent-primary); }

.mic-action-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 12px 14px; }
.mic-hero-btn {
  position: relative;
  width: 84px; height: 84px; border-radius: 50%; border: none;
  display: grid; place-items: center; cursor: pointer; color: #141810;
  background: linear-gradient(140deg, var(--gold), var(--accent-primary) 65%, var(--accent-deep));
  box-shadow: 0 10px 28px var(--accent-glow);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), filter 0.22s ease;
  touch-action: manipulation;
}
.mic-hero-btn:hover { transform: scale(1.04); }
.mic-hero-btn:active { transform: scale(0.94); }
.mic-hero-btn.recording { background: linear-gradient(140deg, #f07171, #a52222); color: #fff; animation: pulseRecording 1.5s infinite; }
.mic-hero-btn svg { width: 34px; height: 34px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.rec-live-dot {
  display: none; position: absolute; top: 5px; inset-inline-end: 5px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ff4d4d; border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.65);
}
.mic-hero-btn.recording .rec-live-dot { display: block; animation: recDotPulse 1.1s ease-out infinite; }
@keyframes recDotPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(255, 77, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}
@keyframes pulseRecording {
  0% { box-shadow: 0 0 0 0 rgba(240, 113, 113, 0.5); }
  70% { box-shadow: 0 0 0 22px rgba(240, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 113, 113, 0); }
}
.mic-status-label { font-size: 12px; font-weight: 700; color: var(--ink-secondary); text-align: center; line-height: 1.45; min-height: 34px; display: flex; align-items: center; }
.btn-skip-word {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--ink-secondary); font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
}
.btn-skip-word:hover { color: var(--accent-primary); border-color: var(--accent-primary); background: var(--accent-light); }

.stats-grid-card {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 11px 8px;
  border-radius: 18px; border: 1px solid var(--border-color); background: var(--bg-surface); text-align: center;
}
.stat-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-number { font-size: 20px; font-weight: 800; color: var(--ink-primary); line-height: 1.2; }
.stat-number.ok { color: var(--status-ok); }
.stat-number.bad { color: var(--status-bad); }
.stat-title { font-size: 9.5px; font-weight: 600; color: var(--ink-muted); line-height: 1.3; }

.mistakes-drawer { max-height: 190px; overflow-y: auto; border-radius: 13px; border: 1px solid var(--border-color); background: var(--bg-surface); padding: 6px; scrollbar-width: thin; }
.empty-state { text-align: center; padding: 12px 8px; color: var(--ink-muted); font-size: 11.5px; line-height: 1.5; }
.mistake-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border-bottom: 1px solid var(--border-color); animation: fadeIn 0.25s ease; }
.mistake-row:last-child { border-bottom: none; }
.mistake-expected {
  font-family: var(--font-mushaf);
  font-size: 18px;
  font-weight: 400;
  color: var(--status-bad);
  direction: rtl;
  font-synthesis: none;
  font-feature-settings: var(--quran-features);
  -webkit-font-feature-settings: var(--quran-features);
}
.mistake-heard { font-size: 10.5px; color: var(--ink-muted); line-height: 1.4; }
.mistake-badge { flex-shrink: 0; font-size: 9px; padding: 3px 6px; border-radius: 6px; background: var(--status-bad-bg); color: var(--status-bad); font-weight: 700; white-space: nowrap; }

/* ─── listening / player ───────────────────────────────────────────── */
.player-console { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.reciter-card { display: flex; flex-direction: column; gap: 11px; }
.reciter-lock {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: 15px; border: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--gold-soft), var(--accent-light));
}
.reciter-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: var(--gold);
  border: 1px solid var(--border-strong); background: var(--bg-surface);
}
.reciter-avatar svg { width: 22px; height: 22px; }
.reciter-copy { min-width: 0; }
.reciter-name { font-size: 13.5px; font-weight: 800; line-height: 1.35; }
.reciter-riwayah { font-size: 10.5px; font-weight: 600; color: var(--gold); margin-top: 2px; line-height: 1.4; }
.now-reciting {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 12px; border: 1px dashed var(--border-color);
  background: var(--bg-surface); min-height: 44px;
}
.now-reciting-label { font-size: 10px; font-weight: 700; color: var(--ink-muted); }
.now-reciting-value { font-size: 12px; font-weight: 800; color: var(--accent-primary); line-height: 1.35; }
.sync-quality { margin-inline-start: auto; font-size: 9px; }
.sync-quality.is-estimated { color: var(--status-skip); background: var(--status-skip-bg); }

.player-card { display: flex; flex-direction: column; gap: 14px; }
.ayah-jump-field { gap: 6px; }
.ayah-jump-row { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.ayah-jump-row .form-input { flex: 1; min-width: 0; text-align: center; }
.ayah-jump-btn { flex-shrink: 0; min-height: 46px; padding-inline: 16px; }
.player-track-info { text-align: center; }
.player-track-surah { font-size: 16px; font-weight: 800; line-height: 1.4; }
.player-track-reciter { font-size: 10.5px; font-weight: 600; color: var(--gold); margin-top: 3px; line-height: 1.4; }
.player-scrubber-container { display: flex; flex-direction: column; gap: 6px; }
.player-progress-bar { height: 7px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-color); position: relative; cursor: pointer; overflow: hidden; }
.player-progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-primary), var(--gold)); transition: width 0.12s linear; }
.player-time-row { display: flex; align-items: center; justify-content: space-between; font-size: 10px; font-weight: 600; color: var(--ink-muted); min-height: 20px; }
.buffering-spinner { width: 16px; height: 16px; border: 2px solid var(--accent-light); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-controls-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-player-play {
  width: 56px; height: 56px; border-radius: 50%; border: none;
  display: grid; place-items: center; cursor: pointer; color: #141810;
  background: linear-gradient(140deg, var(--gold), var(--accent-primary));
  box-shadow: 0 7px 20px var(--accent-glow); transition: transform 0.2s ease;
  touch-action: manipulation;
}
.btn-player-play:hover { transform: scale(1.05); }
.btn-player-play:active { transform: scale(0.95); }
.btn-player-play svg { width: 25px; height: 25px; }

/* ─── khatmah / wird ───────────────────────────────────────────────── */
.khatma-progress-ring-card { text-align: center; }
.progress-big-number { font-size: 40px; font-weight: 800; color: var(--accent-primary); line-height: 1.1; margin: 6px 0 4px; letter-spacing: -1px; }
.khatma-bar-container { height: 10px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-color); overflow: hidden; margin: 10px 0 12px; }
.khatma-bar-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-deep), var(--accent-primary) 55%, var(--gold)); transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.scope-pill {
  display: inline-block; margin: 2px 0 14px; padding: 6px 10px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; color: var(--gold);
  background: var(--gold-soft); border: 1px solid var(--border-color); line-height: 1.4;
}
.wird-card { display: flex; flex-direction: column; }
.wird-progress { padding: 2px 0 8px; }
.wird-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-secondary); }
.wird-count { flex-shrink: 0; color: var(--accent-primary); font-size: 14px; font-weight: 800; direction: ltr; }
.wird-count b { font-weight: 800; }
.wird-form { display: flex; flex-direction: column; gap: 10px; width: 100%; min-width: 0; }
.wird-form .field-grid { width: 100%; }
.wird-form .form-input, .wird-form .form-select { height: 46px; font-size: 13px; }
.save-status { min-height: 18px; font-size: 11px; font-weight: 600; color: var(--status-ok); text-align: center; line-height: 1.4; }
.save-status.error { color: var(--status-bad); }

/* ─── settings ─────────────────────────────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.settings-note { font-size: 11.5px; line-height: 1.65; color: var(--ink-muted); margin-top: 8px; overflow-wrap: break-word; }
.language-card { border-color: var(--border-strong); background: linear-gradient(150deg, var(--gold-soft), var(--bg-card) 55%); }

.font-size-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  direction: ltr; /* keep − on the min end and + on the max end of the LTR slider */
}
.font-size-control .btn-icon {
  font-size: 21px;
  font-weight: 500;
  line-height: 1;
}
.font-size-control input[type="range"] {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  direction: ltr;
  accent-color: var(--accent-primary);
  cursor: pointer;
  touch-action: manipulation;
}
.font-size-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  margin-top: 1px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-muted);
  direction: ltr;
}
.font-size-preview {
  margin-top: 10px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px dashed var(--border-color);
  background: var(--bg-surface);
  font-family: var(--font-mushaf);
  font-size: calc(1.15rem * var(--quran-font-scale, 1));
  font-weight: 400;
  line-height: 1.9;
  text-align: center;
  direction: rtl;
  color: var(--ink-primary);
  font-synthesis: none;
  font-variant-ligatures: common-ligatures contextual;
  font-feature-settings: var(--quran-features);
  -webkit-font-feature-settings: var(--quran-features);
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
.diagnostics-report { margin-top: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-surface); font-size: 11px; line-height: 1.8; color: var(--ink-secondary); overflow-wrap: break-word; }

/* ─── modals ───────────────────────────────────────────────────────── */
.modal-scrim {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4, 6, 4, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s;
}
.modal-scrim.open { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-box {
  position: fixed; top: 50%; left: 50%; z-index: 201;
  width: min(calc(100% - 28px), 402px); max-height: 84dvh; overflow-y: auto;
  padding: 18px; border-radius: 24px; border: 1px solid var(--border-strong);
  background: var(--bg-surface); box-shadow: var(--shadow-lg);
  transform: translate(-50%, -46%) scale(0.96);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, visibility 0.22s;
}
.modal-box.open { transform: translate(-50%, -50%) scale(1); opacity: 1; visibility: visible; pointer-events: auto; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { flex: 1; }
.shortcuts-table { width: 100%; border-collapse: collapse; }
.shortcuts-table td { padding: 9px 6px; border-bottom: 1px solid var(--border-color); font-size: 11.5px; line-height: 1.5; vertical-align: middle; }
.shortcuts-table tr:last-child td { border-bottom: none; }
.shortcuts-table td:first-child { white-space: nowrap; width: 1%; }
kbd { font-family: min(1em, monospace); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; padding: 2px 6px; font-size: 10px; color: var(--gold); }

/* ─── toast ────────────────────────────────────────────────────────── */
.toast-banner {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 50%;
  z-index: 300; width: max-content; max-width: min(calc(100% - 28px), 400px);
  padding: 10px 16px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--bg-elevated); color: var(--ink-primary); box-shadow: var(--shadow-lg);
  font-size: 11.5px; font-weight: 700; line-height: 1.5; text-align: center;
  pointer-events: none; opacity: 0;
  transform: translate3d(-50%, -20px, 0);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  white-space: normal;
}
.toast-banner.show { opacity: 1; transform: translate3d(-50%, 0, 0); }

@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ─── direction adjustments ────────────────────────────────────────── */
html[dir="ltr"] .teacher-name,
html[dir="ltr"] .reciter-name,
html[dir="ltr"] .reciter-riwayah,
html[dir="ltr"] .player-track-info,
html[dir="ltr"] .intro-text { text-align: left; }
html[dir="ltr"] .mushaf-pagination-bar { flex-direction: row; }
html[dir="ltr"] .wird-progress-head { flex-direction: row; }
html[dir="ltr"] .brand-sub { text-align: left; }
html[dir="ltr"] .topbar-badge { direction: ltr; }

/* ─── small phones ─────────────────────────────────────────────────── */
@media (max-width: 359.98px) {
  .app-topbar { padding-inline: 12px; }
  .brand-icon { width: 34px; height: 34px; border-radius: 11px; }
  .brand-title { font-size: 14.5px; }
  .brand-sub { font-size: 9.5px; }
  .topbar-badge { font-size: 9.5px; padding-inline: 8px; }
  .view-panel { padding-inline: 10px; }
  .mushaf-wajh-text { font-size: calc(17px * var(--quran-font-scale, 1)); line-height: 1.9; }
  .surah-title-arabic { font-size: 19px; }
  .bismillah-banner { font-size: 19.5px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .field-full { grid-column: auto; }
  .mobile-bottom-nav { width: calc(100% - 16px); border-radius: 22px; }
  .mobile-bottom-nav-pill { border-radius: 17px; }
  .mobile-nav-btn { font-size: 9.5px; gap: 2px; border-radius: 17px; }
  .mobile-nav-btn svg { width: 19px; height: 19px; }
  .player-controls-row { gap: 6px; }
  .btn-wajh-nav span { font-size: 9.5px; }
  .ayah-search-card { padding: 11px 12px 10px; }
  .ayah-search-row { gap: 6px; }
  .ayah-search-go { padding-inline: 12px; }
}

/* ─── desktop: centered phone shell ────────────────────────────────── */
@media (min-width: 768px) {
  .app-container {
    border-inline: 1px solid var(--border-color);
    box-shadow: 0 0 0 1px rgba(216, 181, 106, 0.05), 0 30px 80px rgba(0, 0, 0, 0.55);
  }
  .mobile-bottom-nav { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5); }
}

/* ─── dedicated desktop experience (>= 1024px) ─────────────────────── */
/* Phones keep the exact 430px shell above. From 1024px the app becomes a
   full reading workspace: a proportioned Mushaf column, structured side
   panels, and a vertical navigation rail instead of a stretched phone. */
@media (min-width: 1024px) {
  .app-container {
    max-width: 1600px;
    border-inline: 1px solid var(--border-color);
    box-shadow:
      0 0 0 1px rgba(216, 181, 106, 0.05),
      0 30px 90px rgba(0, 0, 0, 0.5);
  }

  .app-topbar {
    min-height: 72px;
    padding: 13px clamp(26px, 2.8vw, 46px);
  }
  .brand-icon { width: 44px; height: 44px; border-radius: 14px; }
  .brand-copy { gap: 4px; }
  .brand-title { font-size: 18px; line-height: 1.3; }
  .brand-sub { font-size: 10.5px; line-height: 1.4; }
  .topbar-badge { min-height: 36px; font-size: 11px; padding-inline: 14px; }

  .view-panel {
    padding-block: clamp(20px, 2.2vw, 32px);
    /* The navigation rail lives on the inline-start edge: the right in
       Arabic (RTL) and the left in every LTR interface. Reserving the
       matching logical padding keeps it clear of the content. */
    padding-inline-start: 126px;
    padding-inline-end: clamp(26px, 3vw, 46px);
    padding-bottom: clamp(20px, 2.2vw, 32px);
    scroll-padding-bottom: 28px;
  }

  /* Convert the mobile dock into a calm desktop side rail. */
  .mobile-bottom-nav {
    top: 50%;
    bottom: auto;
    left: auto;
    right: auto;
    inset-inline-start: max(22px, calc((100vw - 1600px) / 2 + 22px));
    inset-inline-end: auto;
    transform: translateY(-50%) translateZ(0);
    width: 86px;
    height: auto;
    flex-direction: column;
    gap: 6px;
    padding: 10px 8px;
    border-radius: 26px;
  }
  .mobile-bottom-nav-pill { display: none; }
  .mobile-nav-btn {
    flex: 0 0 auto;
    width: 100%;
    min-height: 58px;
    padding: 8px 4px 6px;
    border-radius: 17px;
    font-size: 10.5px;
  }
  .mobile-nav-btn:hover { background: var(--bg-card); color: var(--accent-primary); }
  .mobile-nav-btn.active { background: var(--accent-light); }
  .mobile-nav-btn svg { width: 22px; height: 22px; }

  /* Two-column reading workspaces; the Mushaf stays a bounded canvas.
     The narrow control column comes first and the wide Mushaf column
     second: grid columns follow the document direction, so with the
     sidebar ordered into the first column it lands on the right in
     Arabic (RTL) and on the left in every LTR interface, while the
     Mushaf keeps the larger column on the opposite side. */
  .split-view-grid {
    display: grid;
    grid-template-columns: minmax(310px, 0.85fr) minmax(0, 1.5fr);
    gap: clamp(18px, 2vw, 28px);
    align-items: start;
  }
  .equal-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .split-view-grid > .companion-card,
  .split-view-grid > .player-console { order: -1; }

  #v1 .mushaf-reader,
  #v2 .mushaf-reader,
  #v5 .mushaf-reader { width: 100%; max-width: 900px; margin-inline: auto; }
  #v5 .mushaf-reader { max-width: 980px; }
  #v5 .mushaf-pager { width: 100%; max-width: 980px; margin-inline: auto; }

  .player-console { position: sticky; top: 2px; }
  .player-card, .reciter-card { padding: 20px; }
  .player-controls-row { gap: 14px; }
  .ayah-search-card { margin-bottom: clamp(18px, 2vw, 28px); }
  .ayah-search-input { font-size: 14px; }

  #v5 .mushaf-toolbar .field-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  .modal-box { width: min(calc(100% - 40px), 520px); }
  .toast-banner { max-width: 520px; }
}

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