/* ======================================================================
   Quranicpedia — Apple-inspired visual system
   Refined typography, frosted surfaces, hairline dividers, soft motion.
   All existing DOM hooks preserved (.topnav, #wrapper, .sidebars, .lists,
   .aayatPlay, #footer, .btn-warning, #sura, #topAya, #qari, #translation,
   #fonts, .words, .root-words-wrapper, .square-container, #leftside,
   #rightside, .bor, .text, .abig, .accordian, .table-images, etc.)
   ====================================================================== */

@font-face {font-family:'noorehira';src:url('noorehira.ttf');font-display:swap;}
@font-face {font-family:'saleem_quran';src:url('saleem_quran.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}
@font-face {font-family:'arabtype';src:url('arabtype.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}
@font-face {font-family:'decotype-naskh';src:url('decotype-naskh.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}
@font-face {font-family:'me_quran';src:url('me_quran.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}
@font-face {font-family:'simpo';src:url('simpo.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}
@font-face {font-family:'trado';src:url('trado.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap;}

/* ---------- Design tokens (Apple-style) ---------------------------- */
:root {
  /* surfaces */
  --surface-page:        #fbfbfd;
  --surface-elevated:    #ffffff;
  --surface-muted:       #f5f5f7;
  --surface-tinted:      #faf6ef;

  /* ink */
  --ink-primary:         #1d1d1f;
  --ink-secondary:       #424245;
  --ink-tertiary:        #6e6e73;
  --ink-quaternary:      #86868b;

  /* hairlines */
  --hairline:            rgba(0, 0, 0, 0.08);
  --hairline-strong:     rgba(0, 0, 0, 0.14);

  /* accents — refined warm gold (rooted in existing brand tan) */
  --accent:              #b8893f;
  --accent-soft:         #d6a86a;
  --accent-tint:         #f5e9d4;
  --accent-deep:         #7a4500;

  /* semantic */
  --link:                #0066cc;
  --link-hover:          #0077ed;
  --danger:              #d70015;

  /* radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 980px;

  /* shadows — Apple uses very soft, layered shadows */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 0.5px rgba(0,0,0,0.05);
  --shadow-2: 0 6px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-3: 0 24px 60px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-pop: 0 30px 80px rgba(0,0,0,0.18), 0 10px 30px rgba(0,0,0,0.08);

  /* motion */
  --ease-apple: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast:   180ms;
  --duration-normal: 320ms;
  --duration-slow:   500ms;

  /* type */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-text:    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-arabic:  'noorehira', 'saleem_quran', 'arabtype', serif;
}

/* ---------- Reset / globals --------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

body {
  padding: 0;
  margin: 0;
  background: var(--surface-page);
  color: var(--ink-primary);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -0.003em;
}

a { text-decoration: none; color: inherit; transition: color var(--duration-fast) var(--ease-apple); }
a:hover { color: var(--accent-deep); }

img { width: auto; max-width: 100%; }
iframe { border: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.clear { clear: both; }
ol { margin: 0; }
.blue { color: var(--link); }
.red  { color: var(--danger); }
.drtl { direction: rtl; }
.text-center { text-align: center !important; }

/* Selection — soft tan, Apple feel */
::selection { background: var(--accent-tint); color: var(--ink-primary); }

/* ---------- Typography preserves existing class hooks -------------- */
.sidebars h3,
#wrapper h3,
#wrapper .lists .text .abig,
#wrapper .text .abig {
  font-family: var(--font-arabic);
}

#wrapper h3#surahinfo {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* ---------- Apple translucent top navigation ----------------------- */
/* Override existing inline backgrounds with refined frosted nav */
.topnav,
#myTopnav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  height: 60px;
  background: rgba(251, 251, 253, 0.72) !important;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 4px;
  transition: background var(--duration-normal) var(--ease-apple);
}

.topnav a {
  float: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-primary);
  text-align: center;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-text);
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-apple), color var(--duration-fast) var(--ease-apple);
}

.topnav a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-primary);
}

.topnav a.active {
  background: transparent;
  color: var(--ink-primary);
}

.topnav a#selectsurah {
  color: var(--ink-secondary) !important;
}

/* Selects inside the nav — pill shaped, refined */
.topnav select,
#sura, #topAya, #tafseer, #translation, #fonts, #qari {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--surface-elevated) !important;
  color: var(--ink-primary) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: var(--radius-sm) !important;
  -webkit-border-radius: var(--radius-sm) !important;
  padding: 7px 28px 7px 12px;
  font-family: var(--font-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%231d1d1f' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px;
  box-shadow: var(--shadow-1);
  transition: border-color var(--duration-fast) var(--ease-apple), box-shadow var(--duration-fast) var(--ease-apple), transform var(--duration-fast) var(--ease-apple);
}

.topnav select:hover,
#sura:hover, #topAya:hover, #qari:hover, #translation:hover, #fonts:hover {
  border-color: var(--hairline-strong) !important;
}

.topnav select:focus,
#sura:focus, #topAya:focus, #qari:focus, #translation:focus, #fonts:focus {
  border-color: var(--accent-soft) !important;
  box-shadow: 0 0 0 3px var(--accent-tint), var(--shadow-1) !important;
}

.topnav .icon { display: none; }
.topnav .icon i.fa { font-size: 18px; color: var(--ink-primary); }

/* ---------- Login button polished ---------------------------------- */
.topnav .btn,
.topnav .btn-warning {
  background: var(--ink-primary) !important;
  color: #fff !important;
  border: none !important;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-family: var(--font-text);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: none;
  transition: background var(--duration-fast) var(--ease-apple), transform var(--duration-fast) var(--ease-apple);
}
.topnav .btn:hover,
.topnav .btn-warning:hover { background: #000 !important; transform: translateY(-1px); }

/* ---------- Sidebars ------------------------------------------------ */
.sidebars {
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
  padding: 24px 14px 60px;
  margin-top: 60px;
  position: relative;
  z-index: 999;
}

.sidebars::-webkit-scrollbar { width: 8px; }
.sidebars::-webkit-scrollbar-track { background: transparent; }
.sidebars::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: var(--radius-pill);
}
.sidebars::-webkit-scrollbar-thumb:hover { background: var(--ink-quaternary); }

.sidebars h2 {
  margin: 6px 8px 18px;
  color: var(--ink-primary);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebars ol { margin: 0; padding: 0; list-style-type: none; }

.sidebars ol > li {
  margin: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 2px 0;
}
.sidebars ol > li:last-child { border: none; }

.sidebars ol > li a {
  display: block;
  padding: 10px 12px;
  font-size: 1.6rem;
  color: var(--accent);
  line-height: 2rem;
  direction: rtl;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-apple), color var(--duration-fast) var(--ease-apple);
}

.sidebars ol > li a:hover {
  background: var(--accent-tint);
  color: var(--accent-deep);
}

.sidebars ol li ul {
  margin-left: 14px;
  list-style-type: none;
  display: none;
  padding: 4px 0 10px 12px;
  border-left: 1px solid var(--hairline);
}

.sidebars ol > li > ul > li {
  border: none;
  padding: 2px 0;
}
.sidebars ol > li > ul > li a {
  padding: 6px 10px;
  font-size: 13.5px;
  color: var(--ink-secondary);
  font-family: var(--font-text);
  font-weight: 500;
  line-height: 1.4;
  direction: ltr;
  border-radius: var(--radius-xs);
  letter-spacing: -0.005em;
}
.sidebars ol > li > ul > li a:hover {
  background: var(--surface-muted);
  color: var(--ink-primary);
}

.sidebars .lists {
  padding: 6px 0;
  display: block;
  width: 100%;
  float: left;
  overflow: hidden;
  border-bottom: 1px solid var(--hairline);
  clear: both;
}
.sidebars .lists .text { padding-left: 10px; display: none; }
.sidebars .lists .text a { display: block; padding: 3px 0; clear: both; }

#sidebar-one { left: 0; border-right: 1px solid var(--hairline); }
#sidebar-two { right: 0; border-left: 1px solid var(--hairline); }
#sidebar-two .lists .text img {
  width: 40px; float: left; height: 40px;
  margin-right: 8px; background: var(--surface-muted);
  border-radius: var(--radius-xs);
}
#sidebar-two.sidebars ol > li > ul {
  list-style-type: none;
  margin-left: 10px;
  padding: 0 0 10px 0;
}
#sidebar-two.sidebars ol > li > ul > li { padding: 6px 0; }
.sidebars ol > li > ul > li a img { width: 80%; display: block; }

/* ---------- Main content wrapper ----------------------------------- */
#wrapper {
  width: 100%;
  margin: 0 auto;
  background: var(--surface-elevated);
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 28px 36px 80px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--hairline);
}

#wrapper::-webkit-scrollbar { width: 8px; background: transparent; }
#wrapper::-webkit-scrollbar-track { background: transparent; border: none; box-shadow: none; -webkit-box-shadow: none; }
#wrapper::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: var(--radius-pill);
  -webkit-border-radius: var(--radius-pill);
  box-shadow: none;
  -webkit-box-shadow: none;
}
#wrapper::-webkit-scrollbar-thumb:hover { background: var(--ink-quaternary); }

#wrapper h2 {
  text-align: center;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink-primary);
  margin: 16px 0 24px;
}

#wrapper h3 {
  margin: 0;
  display: block;
  cursor: pointer;
  font-size: 2.2rem;
  line-height: 2.8rem;
  color: var(--ink-primary);
  text-align: center;
  font-weight: normal;
  direction: rtl;
  width: 88%;
  float: right;
  letter-spacing: 0;
  transition: color var(--duration-fast) var(--ease-apple);
}

#wrapper h3 span.h3span {
  display: block;
  font-size: 14px;
  font-family: var(--font-text);
  line-height: 1.5;
  color: var(--ink-tertiary);
  margin-top: 8px;
  font-weight: 500;
  font-style: normal;
  direction: ltr;
  text-align: center;
  letter-spacing: -0.01em;
}

/* Active ayah header — refined warm card instead of flat orange */
#wrapper h3.red {
  background: linear-gradient(180deg, var(--accent-tint) 0%, #fff 100%);
  color: var(--ink-primary);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-1);
}
#wrapper h3.red span { color: var(--ink-secondary); }

/* List rows */
#wrapper .lists {
  position: relative;
  clear: both;
  padding: 18px 0 22px;
}
#wrapper .lists::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  width: 100%;
  background: var(--hairline);
}
#wrapper .lists:last-child::after { display: none; }

#wrapper .lists .text {
  display: none;
  padding: 22px 24px 40px;
  position: relative;
  /* No z-index here on purpose: `position: relative` + `z-index: N` would
     create a stacking context that traps any descendant modal (.words). The
     modal needs to escape to root so its z-index can beat the backdrop. */
  background: var(--surface-elevated);
  width: 100%;
  clear: both;
  border-radius: var(--radius-md);
}
#wrapper .lists .text::after { display: none; }

#wrapper .lists .text p {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.65;
  text-align: justify;
  font-family: var(--font-text);
  color: var(--ink-secondary);
  letter-spacing: -0.005em;
}

#wrapper .lists .text a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--duration-fast) var(--ease-apple), border-color var(--duration-fast) var(--ease-apple);
}
#wrapper .lists .text a:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent-deep);
}

#wrapper .text h4 {
  margin: 22px 0 14px;
  font-size: 22px;
  color: var(--ink-primary);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}
#wrapper .text h5 {
  margin: 12px 0;
  color: var(--accent-deep);
  font-size: 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

#wrapper .lists .text figure img { margin-bottom: 12px; border-radius: var(--radius-sm); }
#wrapper .lists .text figure figcaption {
  font-style: italic;
  color: var(--ink-tertiary);
  font-size: 13px;
}

#wrapper .lists .text iframe.center,
#wrapper .text iframe.center {
  border: none;
  width: 100%;
  height: 400px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

#wrapper .lists .text iframe.right {
  border: none;
  width: 30%;
  height: 200px;
  float: right;
  margin: 0 0 15px 15px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

#wrapper .lists .text iframe.med-yt,
#wrapper .text iframe.med-yt {
  width: 70%;
  height: 400px;
  margin: 14px auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

#wrapper .lists .text .yt-center,
#wrapper .text .yt-center { text-align: center; }

#wrapper .text ul li {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.7;
  text-align: justify;
  clear: both;
  font-family: var(--font-text);
  color: var(--ink-secondary);
}
#wrapper .text ul li img.left { float: left; margin: 0 10px 10px 0; border-radius: var(--radius-xs); }

#wrapper .text ol { margin: 0; }
#wrapper .text ol li {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.6;
  text-align: justify;
  clear: both;
  color: var(--ink-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  transition: background var(--duration-fast) var(--ease-apple);
}
#wrapper .text ol li.active {
  background: var(--accent-tint);
  color: var(--ink-primary);
}

#wrapper .text sup {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 2px;
  transition: color var(--duration-fast) var(--ease-apple);
}
#wrapper .text sup:hover { color: var(--accent-deep); }

#wrapper .lists .text .abig,
#wrapper .text .abig {
  text-align: center;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 4.1rem;
  margin-bottom: 22px;
}
#wrapper .lists .text .abig span,
#wrapper .text .abig span {
  display: block;
  font-family: var(--font-text);
  font-size: 1rem;
  direction: ltr;
  margin-top: 8px;
  color: var(--ink-tertiary);
  font-weight: 400;
}
#wrapper .text .hlf-img { display: inline-block; width: 50%; }
#wrapper .text img.left { float: left; margin: 0 10px 10px 0; border-radius: var(--radius-xs); }
#wrapper .text img.aright { float: right; margin: 0 0 10px 10px; border-radius: var(--radius-xs); }

#wrapper td, #wrapper th {
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  border: none;
  padding: 8px 10px;
  color: var(--ink-secondary);
}
#wrapper td p, #wrapper th p { padding: 0; margin: 0; }
#wrapper tr:nth-child(even) { background-color: var(--surface-muted); }

#wrapper .lists .text img.center,
#wrapper .lists .text figure.center { margin: 0 auto; text-align: center; border-radius: var(--radius-md); }

/* ---------- Audio dock (footer) — Apple Music inspired ------------- */
#footer {
  position: fixed;
  left: 50%;
  bottom: -120px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  padding: 14px 22px 16px;
  background: rgba(251, 251, 253, 0.85);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  z-index: 9999;
  margin-bottom: 16px;
}

#samplay { width: 100%; margin: 0 auto; }

#footer progress#progress1 {
  width: 100%;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--hairline);
  cursor: pointer;
}
#footer progress#progress1::-webkit-progress-bar { background-color: var(--hairline); border-radius: var(--radius-pill); }
#footer progress#progress1::-webkit-progress-value { background-color: var(--ink-primary); border-radius: var(--radius-pill); transition: width 0.1s linear; }
#footer progress#progress1::-moz-progress-bar { background-color: var(--ink-primary); border-radius: var(--radius-pill); }

#timecode {
  margin-top: 6px;
  font-family: var(--font-text);
  font-size: 12px;
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
#timecode span { font-size: 12px !important; font-weight: 500 !important; color: var(--ink-tertiary); }

#playerControls {
  list-style-type: none;
  padding: 0;
  margin: 6px 0 0;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transform: none;
}
#playerControls li {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-primary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple), transform var(--duration-fast) var(--ease-apple);
}
#playerControls li:hover { background: rgba(0, 0, 0, 0.05); }
#playerControls li:active { transform: scale(0.94); }
#playerControls li i.fa { color: var(--ink-primary); font-size: 14px; }
#playerControls #play-bt i.fa,
#playerControls #pause-bt i.fa { font-size: 18px; }

#replay {
  width: 50px;
  height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.aayatNo {
  color: var(--ink-tertiary);
  font-size: 12px;
  text-align: center;
  font-style: normal;
  font-weight: 500;
  margin-top: 8px;
  letter-spacing: 0.01em;
}

/* ---------- Inline ayah play button (.aayatPlay) ------------------- */
.playMedia { padding: 0 10px !important; text-align: center; }
.playMedia .aayatPlay { font-size: 28px; }
.playMedia .aayatPlay .fa { padding-left: 4px; }
.playMedia button {
  width: 100%;
  margin: 8px 0;
  padding: 6px 2px;
  float: left;
}

.aayatPlay {
  height: 45px;
  margin: 4px auto;
  border-radius: 50%;
  display: block;
  color: var(--accent);
  transition: transform var(--duration-fast) var(--ease-apple);
}
.aayatPlay:hover { transform: scale(1.05); }
.aayatPlay span { font-size: 13px; }

.aayatNo { color: var(--ink-tertiary); font-size: 12px; text-align: center; }

/* ---------- Ayah row card (.bor) ----------------------------------- */
.lists h3 { width: 100% !important; float: left; }
.bor {
  border-radius: var(--radius-md);
  padding: 18px 16px;
  margin: 6px 0;
  transition: background var(--duration-normal) var(--ease-apple);
}
.lists:nth-child(odd) .bor { background: var(--surface-muted); }
.lists:nth-child(even) .bor { background: transparent; }

.bor:hover { background: var(--surface-tinted); }

/* ---------- Modal-style overlays (.words, transliteration) ---------
   Apple-style sheet: viewport-fixed, centered, scrollable, backdropped.
   The legacy JS calls $.toggle() so an inline style="display:none" is the
   hidden state and removing it (or setting display:block) is the open
   state. The CSS below assumes that contract. */

html.modal-open { overflow: hidden; }

/* No custom backdrop element — the legacy applyBlur() helper in index.php
   already blurs the page content (ul/li/h1-h6/p/span) when a modal opens,
   and the modal's own content (<h9>, <td>, <button>) is not in that
   selector list, so it stays sharp. That gives us the "page blurred,
   modal crisp" effect for free, and avoids a Chromium compositor quirk
   where a position:fixed backdrop with backdrop-filter can end up
   painting OVER a position:fixed modal even at lower z-index. */

/* Belt-and-braces: if .blurred ever leaks into a modal, neutralise it. */
.words .blurred,
.words *.blurred { filter: none !important; }

.words {
  /* Reset inline display:flex/align cruft from any leftover authoring */
  display: none;
  /* Modal positioning - force above the backdrop with !important so no
     descendant rule can accidentally lower the stack. */
  position: fixed !important;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  width: min(820px, 92vw);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-elevated);
  color: var(--ink-primary);
  padding: 28px 30px 32px;
  box-shadow: var(--shadow-pop);
  z-index: 9100 !important;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  font-family: var(--font-text);
  letter-spacing: -0.005em;
  text-align: left;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-apple),
              transform var(--duration-normal) var(--ease-apple);
}

.words.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Custom scrollbar inside the modal — quiet, Apple-like */
.words::-webkit-scrollbar { width: 8px; }
.words::-webkit-scrollbar-track { background: transparent; }
.words::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: var(--radius-pill); }
.words::-webkit-scrollbar-thumb:hover { background: var(--ink-quaternary); }

/* Modal close button (injected by JS into every .words) */
.words .modal-close {
  position: sticky;
  top: -28px;
  margin: -8px -10px 14px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  font-size: 18px;
  line-height: 1;
  transition: background var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}
.words .modal-close:hover {
  background: var(--ink-primary);
  color: #fff;
  transform: scale(1.06);
}
.words .modal-close:active { transform: scale(0.95); }

/* Share button anchor inside modals — keep absolute but tidy up the style */
.words [id^="shareButton"] {
  position: absolute !important;
  top: 14px !important;
  left: 14px !important;
  z-index: 3;
  width: 36px;
  height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted) !important;
  border: none !important;
  border-radius: 50% !important;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple), transform var(--duration-fast) var(--ease-apple);
}
.words [id^="shareButton"]:hover { background: var(--accent-tint) !important; transform: scale(1.06); }
.words [id^="shareButton"] img { height: 16px !important; width: auto; }

/* Make the Arabic text inside transliteration / root-word modals readable */
.words h9 {
  display: block;
  text-align: center;
  margin: 6px 0 14px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.6;
}
.words td {
  display: inline;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Mobile: full-screen sheet */
@media (max-width: 640px) {
  .words {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: translate(0, 0) scale(1);
    padding: 60px 18px 24px;
  }
  .words.is-open {
    transform: translate(0, 0) scale(1);
  }
  .words .modal-close {
    position: fixed;
    top: 12px;
    right: 12px;
    margin: 0;
  }
}

/* ---------- Per-ayah action column (.ayah-actions) ----------------- */
.ayah-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 0;
}
.ayah-actions .ayah-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The shared button styles above (.bookmark-toggle, .ayah-play .play-audio)
   already cover sizing/hover/active. This block remains intentionally empty. */

/* ---------- Right-side rail (#rightside) -------------------------- */
/* Show from 1200px upward (typical laptop) instead of the legacy 1400px. */
@media (min-width: 1200px) {
  #rightside { display: block !important; }
}

#rightside {
  margin-top: 76px;
  padding: 14px;
  background: transparent;
  /* Stick the rail to the viewport so all four sections stay visible
     as the reader scrolls. The card inside owns its own scroll. */
  position: sticky;
  top: 76px;
  align-self: flex-start;
}

#rightside #sidebar-one {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-1);
  /* Cap height so it never spills past the viewport; scroll inside. */
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#rightside #sidebar-one::-webkit-scrollbar { width: 6px; }
#rightside #sidebar-one::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 3px;
}

#rightside .related-videos {
  background: linear-gradient(180deg, var(--accent-tint) 0%, var(--surface-elevated) 100%) !important;
  border: 1px solid var(--accent-soft) !important;
  border-radius: var(--radius-sm) !important;
  height: auto !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px 14px !important;
  margin: 12px 0 10px !important;
}
#rightside .related-videos p {
  margin: 0 !important;
  color: var(--ink-primary) !important;
  font-family: var(--font-display);
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#rightside ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
#rightside ul li {
  margin: 4px 0;
}
#rightside ul li a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: 13.5px;
  font-weight: 500;
  background: var(--surface-muted);
  transition: background var(--duration-fast) var(--ease-apple),
              color      var(--duration-fast) var(--ease-apple),
              transform  var(--duration-fast) var(--ease-apple);
}
#rightside ul li a:hover {
  background: var(--accent-tint);
  color: var(--ink-primary);
  transform: translateX(2px);
}

/* "Showing videos for: Ayat N" label above the rail video list */
#rightside .rail-active-ayat {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  text-align: center;
  padding: 6px 8px;
  margin: -4px 0 8px;
  border-bottom: 1px solid var(--hairline);
}

/* Right-rail video cards (Related Videos) */
/* Compact list so the rail can show videos + text size + bookmarks +
   recent viewed within one viewport. Internal scroll for overflow. */
#rightside .rail-videos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}
#rightside .rail-videos::-webkit-scrollbar { width: 5px; }
#rightside .rail-videos::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 3px;
}
#rightside .rail-video { margin: 0; }
#rightside .rail-video-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}
#rightside .rail-video-btn:hover {
  background: var(--surface-muted);
  border-color: var(--accent-soft);
  transform: translateY(-1px);
}
#rightside .rail-video-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 80px;
  height: 48px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface-muted);
}
#rightside .rail-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#rightside .rail-video-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0.8;
  transition: opacity var(--duration-fast) var(--ease-apple);
}
#rightside .rail-video-btn:hover .rail-video-play { opacity: 1; }
#rightside .rail-video-play svg {
  width: 18px; height: 18px; fill: #fff;
}
#rightside .rail-video-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
#rightside .rail-video-title {
  font-family: var(--font-text);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-primary);
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
#rightside .rail-video-ayat {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-tertiary);
  letter-spacing: 0.01em;
}

/* ──────────── Right-rail cards (Bookmarks · Recent Viewed) ──────────── */
#rightside .qp-rail-section-head {
  padding: 12px 16px !important;
  margin: 16px 0 8px !important;
}
#rightside .qp-rail-section-head p {
  font-size: 12.5px !important;
  font-weight: 700 !important;
}

#rightside .qp-rail-card {
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-1);
  margin: 0 0 18px;
}
#rightside .qp-rail-scroll {
  max-height: 170px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
}
#rightside .qp-rail-scroll::-webkit-scrollbar { width: 6px; }
#rightside .qp-rail-scroll::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 3px;
}
#rightside .qp-rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#rightside .qp-rail-list li { margin: 4px 0; }
#rightside .qp-rail-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}
#rightside .qp-rail-list a:hover {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
  color: var(--ink-primary);
  transform: translateX(2px);
}
#rightside .qp-rail-list-arrow {
  color: var(--ink-quaternary);
  flex-shrink: 0;
}
#rightside .qp-rail-list a:hover .qp-rail-list-arrow {
  color: var(--accent-deep);
}
#rightside .qp-rail-empty {
  margin: 4px 6px 6px;
  padding: 12px;
  font-size: 12.5px;
  color: var(--ink-tertiary);
  text-align: center;
  line-height: 1.5;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
}

/* Recent-viewed list — same compact treatment as bookmarks */
#rightside #recent-links {
  max-height: 170px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
}
#rightside #recent-links::-webkit-scrollbar { width: 5px; }
#rightside #recent-links::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 3px;
}

/* ──────────── Video lightbox modal ──────────── */
body.qp-video-modal-locked { overflow: hidden; }

.qp-video-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.qp-video-modal[hidden] { display: none; }

.qp-video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 14, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 180ms var(--ease-apple);
}
.qp-video-modal.is-open .qp-video-modal-backdrop { opacity: 1; }

.qp-video-modal-shell {
  position: relative;
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(8px) scale(0.985);
  transition: opacity 180ms var(--ease-apple), transform 180ms var(--ease-apple);
}
.qp-video-modal.is-open .qp-video-modal-shell {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.qp-video-modal-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.qp-video-modal-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.qp-video-modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
  text-align: center;
  letter-spacing: -0.003em;
}

.qp-video-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: transform var(--duration-fast) var(--ease-apple),
              background var(--duration-fast) var(--ease-apple);
}
.qp-video-modal-close:hover {
  transform: scale(1.06) rotate(90deg);
  background: #fff;
}
.qp-video-modal-close svg { fill: currentColor; }

@media (max-width: 720px) {
  .qp-video-modal { padding: 14px; }
  .qp-video-modal-close { top: -10px; right: -10px; width: 36px; height: 36px; }
}

/* Inline player swap-in (legacy, kept in case any older surface still relies on it) */
#rightside .rail-video-btn.is-playing .rail-video-thumb iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#rightside .rail-empty,
#rightside .recent-empty {
  font-family: var(--font-text);
  font-size: 12.5px;
  color: var(--ink-tertiary);
  padding: 8px 12px;
  margin: 0;
}

#rightside .recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#rightside .recent-list li {
  margin: 4px 0;
}
#rightside .recent-list li a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--ink-secondary);
  background: var(--surface-muted);
  font-weight: 500;
  transition: background var(--duration-fast) var(--ease-apple);
}
#rightside .recent-list li a:hover {
  background: var(--accent-tint);
  color: var(--ink-primary);
}

/* Font-size control row in the right rail */
#rightside .qp-fontsize-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 12px;
}
#rightside .qp-fontsize-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  color: var(--ink-primary);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: background var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple),
              box-shadow var(--duration-fast) var(--ease-apple);
  box-shadow: var(--shadow-1);
}
#rightside .qp-fontsize-btn:hover {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
#rightside .qp-fontsize-btn:active { transform: scale(0.94); }
/* Three sizes — the visible "A" inside scales for affordance */
#rightside .qp-fontsize-btn span { display: block; line-height: 1; }
#rightside .qp-fontsize-sm span { font-size: 12px; }
#rightside .qp-fontsize-md span { font-size: 16px; }
#rightside .qp-fontsize-lg span { font-size: 20px; }

.table { margin-bottom: 0 !important; }

/* ---------- Tabs (.with-nav-tabs) ---------------------------------- */
.popover { width: 300px; border-radius: var(--radius-md); border: 1px solid var(--hairline); box-shadow: var(--shadow-2); }

.panel.with-nav-tabs .panel-heading { padding: 6px 6px 0; }
.panel.with-nav-tabs .nav-tabs { border-bottom: none; }
.panel.with-nav-tabs .nav-justified { margin-bottom: -1px; }

.with-nav-tabs.panel-success .nav-tabs > li { clear: none !important; }
.with-nav-tabs.panel-success .nav-tabs > li > a,
.with-nav-tabs.panel-success .nav-tabs > li > a:hover,
.with-nav-tabs.panel-success .nav-tabs > li > a:focus {
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-weight: 500;
}

.with-nav-tabs.panel-success .nav-tabs > .open > a,
.with-nav-tabs.panel-success .nav-tabs > .open > a:hover,
.with-nav-tabs.panel-success .nav-tabs > .open > a:focus,
.with-nav-tabs.panel-success .nav-tabs > li > a:hover,
.with-nav-tabs.panel-success .nav-tabs > li > a:focus {
  color: var(--ink-primary);
  background-color: var(--surface-muted);
  border-color: transparent;
}

.with-nav-tabs.panel-success .nav-tabs > li.active > a,
.with-nav-tabs.panel-success .nav-tabs > li.active > a:hover,
.with-nav-tabs.panel-success .nav-tabs > li.active > a:focus {
  color: #fff !important;
  background-color: var(--ink-primary);
  border-color: var(--ink-primary);
  border-bottom-color: transparent;
}

.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu {
  background-color: var(--surface-elevated);
  border-color: var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
}
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > li > a {
  color: var(--ink-primary);
}
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > li > a:hover,
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > li > a:focus {
  background-color: var(--surface-muted);
}
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > .active > a,
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > .active > a:hover,
.with-nav-tabs.panel-success .nav-tabs > li.dropdown .dropdown-menu > .active > a:focus {
  color: #fff;
  background-color: var(--ink-primary);
}

/* ---------- Bootstrap button refinement (.btn-warning) -------------
   These are used heavily inline. Map to subtle Apple pill style. */
.btn,
.btn-warning,
button.btn-warning,
.button-spacing {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: var(--ink-primary) !important;
  color: #fff !important;
  border: 1px solid transparent !important;
  border-radius: var(--radius-pill) !important;
  font-family: var(--font-text) !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  letter-spacing: -0.005em;
  padding: 8px 18px !important;
  margin: 4px 4px !important;
  text-shadow: none !important;
  box-shadow: none !important;
  transition: background var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple);
}
.btn:hover, .btn-warning:hover, button.btn-warning:hover, .button-spacing:hover {
  background: #000 !important;
  color: #fff !important;
  transform: translateY(-1px);
}
.btn:active, .btn-warning:active { transform: translateY(0); }

/* Login / register inside .col-md-8 — keep them but elevate */
.col-md-8.border.bg-light {
  border-radius: var(--radius-lg) !important;
  border: 1px solid var(--hairline) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-3);
}

/* Form controls Apple-style */
.form-control {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--hairline) !important;
  background: #fff;
  font-family: var(--font-text);
  font-size: 15px;
  padding: 10px 14px;
  transition: border-color var(--duration-fast) var(--ease-apple), box-shadow var(--duration-fast) var(--ease-apple);
}
.form-control:focus {
  border-color: var(--accent-soft) !important;
  box-shadow: 0 0 0 3px var(--accent-tint) !important;
}

/* ---------- Sticky hairline below nav for content offset ---------- */
.col-lg-8 { padding-top: 76px; }
.col-md-2 { padding-top: 0; }

/* Bookmark icon container (inline image absolute layout preserved) */
.square-container { position: relative; }
.square-container img { transition: transform var(--duration-fast) var(--ease-apple); }
.square-container a:hover img { transform: scale(1.06); }

.table-images img {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  transition: transform var(--duration-fast) var(--ease-apple);
}
.table-images a:hover img { transform: scale(1.06); }

/* ---------- Root word cards (preserves .root-words-wrapper hooks) -- */
.root-words-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  direction: rtl;
  padding: 14px;
  background: transparent;
}

.root-word-item {
  flex: 1 1 220px;
  max-width: 300px;
  background: var(--surface-elevated) !important;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-1);
  transition: transform var(--duration-fast) var(--ease-apple),
              box-shadow var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple);
}
.root-word-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--accent-soft);
}

/* ---------- Reduced motion ----------------------------------------- */
@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;
  }
}

/* ---------- Dark text on warm header preserved -------------------- */
.black-background { background-color: var(--accent-tint) !important; }

/* ---------- Mobile responsiveness — keep existing behaviour but
            make the responsive nav frosted too ---------------------- */
@media screen and (max-width: 1400px) {
  .topnav { padding: 0 14px; }
  .topnav a:not(:first-child) { display: none; }
  .topnav a.icon { float: right; display: inline-flex; }
  .nav li a { color: var(--ink-primary); }
}

@media screen and (max-width: 1400px) {
  .topnav.responsive {
    position: fixed;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: 12px 14px 16px;
    background: rgba(251, 251, 253, 0.92) !important;
  }
  .topnav.responsive .icon {
    position: absolute;
    right: 8px;
    top: 8px;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
    padding: 10px 12px;
    font-size: 15px;
  }
  .topnav.responsive select {
    width: 100%;
    margin: 4px 0;
  }
  #wrapper { padding: 22px 18px 60px; border-radius: var(--radius-md); }
  #wrapper h3 { font-size: 1.9rem; line-height: 2.5rem; }
}

@media (max-width: 800px) {
  .navbar-collapse { background: var(--surface-muted); }
  #wrapper { padding: 18px 14px 60px; }
  #footer { width: calc(100% - 16px); padding: 12px 16px 14px; }
  .words { width: calc(100% - 24px); padding: 18px; }
  #wrapper h3 { font-size: 1.7rem; line-height: 2.3rem; width: 100%; float: none; }
}

/* ---------- Old #menu legacy preserved, but neutralised ----------- */
#menu {
  display: none; /* fully replaced by .topnav above */
}

/* ---------- Active reference highlight refined --------------------- */
#wrapper .text ol li.active {
  background: var(--accent-tint);
  border-left: 2px solid var(--accent);
}

/* ---------- Blur overlay (#wrapper.blurred etc) refined ---------- */
.blurred {
  filter: blur(8px) saturate(120%);
  pointer-events: none;
  transition: filter var(--duration-normal) var(--ease-apple);
}

/* ---------- Per-ayah action buttons (shared circle pattern) ---------
   Both bookmark and play buttons share the same circular surface so they
   read as a single visual cluster. Only their inner glyph and active
   color differ. */

.bookmark-toggle,
.ayah-play .play-audio {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 !important;
  margin: 0 !important;
  background: var(--surface-elevated);
  border: 1px solid var(--hairline) !important;
  border-radius: 50% !important;
  color: var(--ink-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background var(--duration-fast) var(--ease-apple),
              color      var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple),
              transform  var(--duration-fast) var(--ease-apple),
              box-shadow var(--duration-fast) var(--ease-apple);
}

.bookmark-toggle svg,
.ayah-play .play-audio svg {
  width: 16px;
  height: 16px;
  display: block;
  transition: fill var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}

/* bookmark glyph: outline by default, filled when active */
.bookmark-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bookmark-toggle.is-active svg {
  fill: var(--accent);
  stroke: var(--accent);
}

/* play glyph: solid triangle */
.ayah-play .play-audio svg {
  fill: var(--ink-primary);
  margin-left: 2px; /* optical center of triangle */
}

/* Hover / active / focus — identical for both */
.bookmark-toggle:hover,
.ayah-play .play-audio:hover {
  background: var(--surface-muted);
  border-color: var(--hairline-strong) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.bookmark-toggle:active,
.ayah-play .play-audio:active {
  transform: scale(0.94);
}
.bookmark-toggle:focus-visible,
.ayah-play .play-audio:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bookmark-toggle.is-active {
  background: var(--accent-tint);
  border-color: var(--accent) !important;
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 137, 63, 0.18), var(--shadow-1);
}

.bookmark-toggle.is-prompt {
  text-decoration: none;
  color: var(--ink-tertiary);
}

/* Defuse the legacy table.table-images rules around the bookmark cell. */
.table.table-images { width: auto; margin: 0; padding: 0; box-shadow: none; }
.table.table-images td { background: transparent !important; padding: 4px 6px !important; vertical-align: middle; }

/* ---------- Visual polish v2 ---------------------------------------
   Targeted refinements after the modal/bookmark fixes. Keeps every DOM
   hook in place; only adjusts spacing, typography, and motion. */

/* Ayah card hover — lift slightly to feel tactile */
.lists {
  border-radius: var(--radius-md);
  transition: background var(--duration-normal) var(--ease-apple);
}
.lists .bor {
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin: 8px 0;
  /* No transform here on hover - would create a containing block and
     break position:fixed for the .words modal nested inside. */
  transition: background var(--duration-normal) var(--ease-apple),
              box-shadow  var(--duration-normal) var(--ease-apple);
}
.lists:hover .bor { box-shadow: var(--shadow-1); }

/* Action button cluster inside .text — give it breathing room */
#button-container-1, #button-container-2,
[id^="button-container-"] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 22px;
}
[id^="button-container-"] .btn,
[id^="button-container-"] .btn-warning {
  margin: 0 !important;
  padding: 9px 18px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
}

/* Refine the surah header (the giant "An-Naba" at the top).
   The header has two parts: Arabic (.surah-arabic) and Latin (.surah-latin).
   Each gets its own font so the Arabic glyphs render properly. */
#wrapper h3#surahinfo {
  font-size: clamp(2.2rem, 3.6vw, 3rem);
  line-height: 1.25;
  text-align: center;
  margin: 14px 0 22px;
  color: var(--ink-primary);
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

#wrapper h3#surahinfo .surah-arabic {
  font-family: var(--font-arabic);
  font-size: 1.15em;
  line-height: 1.2;
  direction: rtl;
  color: var(--ink-primary);
  letter-spacing: 0;
}

#wrapper h3#surahinfo .surah-divider {
  color: var(--ink-quaternary);
  font-size: 0.7em;
  font-weight: 300;
}

#wrapper h3#surahinfo .surah-latin {
  font-family: var(--font-display);
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink-secondary);
}

/* Sidebar TOC: Arabic + Latin split */
.sidebars ol > li > a.surah-toc-link {
  font-family: var(--font-text);
  color: var(--ink-primary) !important;
}
.sidebars ol > li > a.surah-toc-link .surah-arabic {
  display: block;
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  line-height: 1.3;
  direction: rtl;
  color: var(--ink-primary);
}
.sidebars ol > li > a.surah-toc-link .surah-latin {
  display: block;
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-tertiary);
  margin-top: 2px;
}

/* Connection (ayah) Arabic block */
#wrapper h3 {
  padding: 6px 0;
}
#wrapper h3 p {
  font-family: var(--font-arabic);
  font-size: clamp(2rem, 3vw, 2.6rem);
  line-height: 2.2;
  letter-spacing: 0;
  margin: 14px 0;
  color: var(--ink-primary);
}

/* Sidebar TOC — chip-like padding, English text, subtle weight.
   The `Aayat N` parent links and the `Understanding / Related Aayat / …`
   sub-links are all English copy, so they get var(--font-text), not the
   Arabic display stack. Only the `.surah-arabic` span inside the surah
   header link uses var(--font-arabic). */
.sidebars ol > li > a {
  padding: 12px 14px !important;
  font-family: var(--font-text) !important;
  font-size: 14.5px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
  line-height: 1.4 !important;
  color: var(--ink-primary) !important;
  border-radius: var(--radius-sm) !important;
  margin: 4px 0 !important;
}
.sidebars ol > li > a:hover {
  background: var(--accent-tint) !important;
  color: var(--accent-deep) !important;
}
/* Inline override for legacy "font-size: 2.2rem" set on the Aayat N anchors */
.sidebars ol > li > a[style*="2.2rem"] {
  font-size: 14.5px !important;
}
.sidebars ol > li > ul > li a {
  position: relative;
  padding-left: 18px !important;
  font-family: var(--font-text) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  color: var(--ink-tertiary) !important;
  letter-spacing: -0.005em !important;
}
.sidebars ol > li > ul > li a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  background: var(--ink-quaternary);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: background var(--duration-fast) var(--ease-apple);
}
.sidebars ol > li > ul > li a:hover::before {
  background: var(--accent);
  transform: translateY(-50%) scale(1.4);
}

/* Audio dock — give a "now playing" feel */
#footer.is-playing #playerControls #play-bt,
#footer #playerControls #play-bt.is-active {
  background: var(--ink-primary);
  color: #fff;
}
#footer.is-playing #playerControls #play-bt i.fa,
#footer #playerControls #play-bt.is-active i.fa { color: #fff; }

#footer .aayatNo {
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: -0.01em;
}

/* "Share as image" buttons — quiet circular icons */
[id^="shareButton"] {
  transition: transform var(--duration-fast) var(--ease-apple),
              background var(--duration-fast) var(--ease-apple);
}

/* Page header offset — make the body breathe under the fixed nav */
body { padding-top: 0; }
.col-lg-8 { padding-top: 84px !important; }
.col-md-2 { padding-top: 76px !important; padding-left: 12px; }

/* Refine the "Coming soon" placeholder */
#wrapper h3#surahinfo[style*="40px"] {
  font-size: 18px !important;
  font-weight: 500;
  color: var(--ink-tertiary);
  font-family: var(--font-text);
  letter-spacing: -0.005em;
  text-align: center;
  direction: ltr;
}

/* References block (numbered list inside .text ol) — give it card feel */
#wrapper .text ol {
  background: var(--surface-muted);
  padding: 14px 14px 14px 32px;
  border-radius: var(--radius-md);
  margin: 14px 0;
}
#wrapper .text ol li {
  border-radius: var(--radius-xs);
  margin: 6px 0;
}

/* Highlight the active reference link */
#wrapper .text sup {
  background: var(--accent-tint);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  vertical-align: super;
  margin-left: 2px;
}

/* Login button in topnav (when not logged in) — match the rest */
.topnav a > .btn,
.topnav a > .btn-warning { margin: 0 !important; }

/* ==================================================================
   Typography enforcement
   ------------------------------------------------------------------
   Many legacy inline styles use `font-family: system-ui` or hardcoded
   stacks. These overrides re-route every English content container to
   the project's `--font-text` variable, while leaving Arabic display
   elements on their dedicated Arabic stack. The selectors are scoped
   to content areas only so we don't accidentally restyle Bootstrap
   widgets or icon fonts.
   ================================================================== */

/* English content stacks — force the design-system font everywhere
   editorial copy lives. Use !important to win over inline styles. */
#wrapper p,
#wrapper li,
#wrapper td:not([style*="font-family"]),
#wrapper th,
#wrapper .text,
#wrapper .text p,
#wrapper .text li,
#wrapper .text td,
.words p,
.words td:not([style*="color"]),
.words .root-words-wrapper *,
.qp-term-article p,
.qp-term-article li,
.qp-term-article div,
.qp-translation-line,
#rightside p,
#rightside li,
#rightside .rail-video-title,
#rightside .rail-video-ayat,
.popover,
.popover * {
  font-family: var(--font-text) !important;
  letter-spacing: -0.005em;
}

/* English headings consistently use the display stack. */
#wrapper h2,
#wrapper h4,
#wrapper h5,
.qp-term-article h1,
.qp-term-article h2,
.qp-term-article h3,
.qp-term-article h4 {
  font-family: var(--font-display) !important;
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* =============================================================
   Arabic display enforcement — all RTL/Arabic surfaces ALWAYS use
   var(--font-arabic) (Noorehira default). Selectors are robust to
   the font-size scaler changing inline `style="font-size: …"`.
   =============================================================
   Covers:
     - Main ayah Arabic         #wrapper h3 p
     - Tafseer Arabic           p[style*="direction: rtl"]  (Tafseer panel)
     - Related Aayat Arabic     .drtl  (.abig also already styled Arabic)
     - Word/share modal         .words h9
     - Surah TOC Arabic span    .surah-arabic
     - Term modal Arabic        .qp-term-arabic
     - Anything with dir="rtl"  [dir="rtl"]
*/
#wrapper h3 p:not(.qp-translation-line),
#wrapper p[style*="direction:rtl"]:not(.qp-translation-line),
#wrapper p[style*="direction: rtl"]:not(.qp-translation-line),
#wrapper [style*="direction: rtl"]:not(.qp-translation-line):not(p.qp-translation-line),
#wrapper [style*="direction:rtl"]:not(.qp-translation-line),
#wrapper p.drtl,
#wrapper .drtl,
#wrapper .abig,
#wrapper .abig *,
.words h9,
.words [style*="direction: rtl"]:not(.qp-translation-line),
.words [style*="direction:rtl"]:not(.qp-translation-line),
.surah-arabic,
.qp-term-arabic,
[dir="rtl"]:not([data-rtl-skip]):not(.qp-translation-line),
html .drtl,
html .abig {
  font-family: var(--font-arabic) !important;
}

/* Bootstrap btn / btn-warning shouldn't pick up our text font in a way
   that breaks their look — restate explicitly. */
.btn,
.btn-warning,
button.btn,
button.btn-warning {
  font-family: var(--font-text) !important;
  letter-spacing: -0.005em;
}

/* ---------- Glossary terms (Wikipedia-style hyperlinks) -----------
   Auto-injected by lib/glossary_linker.php into translation + tafseer text.
   Click opens a modal sheet with the full article; hover shows a quick
   preview card. */

a.qp-term {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--link) 35%, transparent);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple),
              color      var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple);
  padding: 0 1px;
  border-radius: 2px;
}
a.qp-term:hover,
a.qp-term:focus-visible {
  color: var(--link-hover);
  background: rgba(0, 102, 204, 0.08);
  border-bottom-color: var(--link-hover);
  outline: none;
}

/* Hover/focus preview card */
.qp-term-preview {
  position: absolute;
  z-index: 9050;
  width: min(320px, 92vw);
  background: var(--surface-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: 14px 16px;
  font-family: var(--font-text);
  font-size: 13.5px;
  color: var(--ink-secondary);
  letter-spacing: -0.005em;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}
.qp-term-preview.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.qp-term-preview-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.qp-term-preview-head strong {
  color: var(--ink-primary);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.qp-term-preview-head .qp-term-arabic {
  font-family: var(--font-arabic);
  font-size: 18px;
  color: var(--ink-tertiary);
  direction: rtl;
}
.qp-term-preview-body .qp-term-summary {
  margin: 0 0 8px;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.qp-term-preview-body .qp-term-readmore {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}
.qp-term-preview-body .qp-term-readmore:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Term article modal (uses .words modal CSS already in place) */
.qp-term-article {
  font-family: var(--font-text);
  color: var(--ink-primary);
}
.qp-term-article .qp-term-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.qp-term-article .qp-term-head .qp-term-arabic {
  font-family: var(--font-arabic);
  font-size: 1.4em;
  color: var(--ink-secondary);
  direction: rtl;
}
.qp-term-article .qp-term-lede {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-secondary);
  margin: 0 0 14px;
}

/* "Open full article" pill at the bottom of the article header,
   in both the modal and the standalone page. */
.qp-term-article .qp-term-fullpage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
  padding: 6px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink-secondary) !important;
  font-family: var(--font-text);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple),
              transform var(--duration-fast) var(--ease-apple);
}
.qp-term-article .qp-term-fullpage:hover {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
  color: var(--ink-primary) !important;
  transform: translateY(-1px);
}
.qp-term-article .qp-term-fullpage svg { fill: currentColor; opacity: 0.8; }
.qp-term-article > .qp-term-figure,
.qp-term-article > .qp-term-body {
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
}
.qp-term-article .qp-term-figure {
  margin: 0 0 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.qp-term-article .qp-term-figure img { width: 100%; display: block; }
.qp-term-article .qp-term-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-secondary);
  letter-spacing: -0.005em;
}
.qp-term-article .qp-term-body p { margin: 0 0 12px; }
.qp-term-article .qp-term-body a.qp-term {
  /* Cross-links inside an article keep their style */
}
.qp-term-article .qp-term-video,
.qp-term-article .qp-term-map {
  margin-top: 18px;
}
.qp-term-article .qp-term-video iframe,
.qp-term-article .qp-term-map iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.qp-term-article .qp-term-map h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin: 0 0 8px;
}

/* =============================================================
   Three-column wiki layout for term articles
     ┌──────────┬───────────────┬──────────┐
     │ TOC      │ Article body  │ Media &  │
     │ Contents │               │ Facts    │
     └──────────┴───────────────┴──────────┘
   Stacks to single column on narrow viewports.
   ============================================================= */
.qp-term-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 240px;
  gap: 32px;
  align-items: flex-start;
  margin-top: 22px;
}
@media (max-width: 1100px) {
  .qp-term-shell { grid-template-columns: minmax(0, 1fr) 220px; }
  .qp-term-toc { display: none; }
}
@media (max-width: 760px) {
  .qp-term-shell { grid-template-columns: 1fr; gap: 22px; }
  .qp-term-facts { order: 2; }
}

/* Section labels for both rails */
.qp-term-railhead {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}

/* Left — Contents (TOC) */
.qp-term-toc { position: sticky; top: 100px; }
.qp-term-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.qp-term-toc-list li { margin: 0; }
.qp-term-toc-list li a {
  display: block;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: var(--radius-xs);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  text-decoration: none;
  letter-spacing: -0.005em;
  transition: background var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple);
}
.qp-term-toc-list li a:hover {
  background: var(--accent-tint);
  color: var(--ink-primary);
  border-left-color: var(--accent);
}
.qp-term-toc-l3 a { padding-left: 24px; font-size: 12.5px; color: var(--ink-tertiary); }
.qp-term-toc-empty {
  font-family: var(--font-text);
  font-size: 12.5px;
  color: var(--ink-tertiary);
  font-style: italic;
}

/* Right — Media & Facts */
.qp-term-facts { position: sticky; top: 100px; }
.qp-term-fact {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.qp-term-fact-h {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin: 0 0 8px;
}
.qp-term-fact-video iframe,
.qp-term-fact-map iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-sm);
  display: block;
}
.qp-term-fact-coords {
  margin: 8px 0 0;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  color: var(--ink-tertiary);
}
.qp-term-fact-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.qp-term-fact-related li { margin: 4px 0; }
.qp-term-fact-related a.qp-term {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-primary);
  background: var(--surface-elevated);
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple);
}
.qp-term-fact-related a.qp-term:hover {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
}
.qp-term-fact-empty {
  font-family: var(--font-text);
  font-size: 12.5px;
  color: var(--ink-tertiary);
  font-style: italic;
  padding: 6px 10px;
}

/* Article body inside the wiki shell */
.qp-term-main { min-width: 0; }
.qp-term-main .qp-term-body h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  margin: 28px 0 12px;
  scroll-margin-top: 100px;
}
.qp-term-main .qp-term-body h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink-primary);
  margin: 22px 0 10px;
  scroll-margin-top: 100px;
}

/* Stub state */
.qp-term-article.is-stub .qp-term-stub-notice {
  background: var(--accent-tint);
  border: 1px dashed var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--ink-secondary);
  margin: 0 0 18px;
}
.qp-term-article.is-stub .qp-term-body h2,
.qp-term-article.is-stub .qp-term-body h3 {
  color: var(--ink-tertiary);
}
.qp-term-article.is-stub .qp-term-body h2 + p,
.qp-term-article.is-stub .qp-term-body h3 + p {
  color: var(--ink-quaternary);
  font-style: italic;
}

/* Standalone /term.php page (non-modal) */
.qp-term-page {
  max-width: 1100px;
  margin: 36px auto 80px;
  padding: 0 22px 60px;
}
.qp-term-back {
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-apple);
}
.qp-term-back:hover { background: var(--accent-tint); color: var(--ink-primary); }

/* ──────────── Standalone-page brand chrome (term.php only) ──────────── */
.qp-brandbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 251, 253, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.qp-brandbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.qp-brand-mark {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.92;
  transition: opacity var(--duration-fast) var(--ease-apple), transform var(--duration-fast) var(--ease-apple);
}
.qp-brand-mark:hover { opacity: 1; transform: translateY(-0.5px); }
.qp-brand-mark img {
  display: block;
  height: 28px;
  width: auto;
}
.qp-brandbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qp-brandbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-apple),
              color var(--duration-fast) var(--ease-apple),
              border-color var(--duration-fast) var(--ease-apple);
}
.qp-brandbar-back svg { fill: currentColor; }
.qp-brandbar-back:hover {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
  color: var(--ink-primary);
}

.qp-brandfoot {
  margin-top: 60px;
  padding: 40px 22px 48px;
  background: var(--surface-elevated);
  border-top: 1px solid var(--hairline);
}
.qp-brandfoot-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: center;
}
@media (max-width: 720px) {
  .qp-brandfoot-inner { grid-template-columns: 1fr; gap: 18px; }
}
.qp-brandfoot-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qp-brandfoot-brand img {
  display: block;
  height: 22px;
  width: auto;
  opacity: 0.88;
}
.qp-brandfoot-tag {
  margin: 0;
  font-size: 13px;
  color: var(--ink-tertiary);
  line-height: 1.55;
  max-width: 52ch;
}
.qp-brandfoot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-tertiary);
  justify-self: end;
}
@media (max-width: 720px) { .qp-brandfoot-meta { justify-self: start; } }
.qp-brandfoot-meta a {
  color: var(--ink-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-apple);
}
.qp-brandfoot-meta a:hover { color: var(--accent-deep); }
.qp-brandfoot-meta span[aria-hidden] { opacity: 0.5; }
.qp-brandfoot-copy { color: var(--ink-quaternary); }

/* Translation lines: a "sub-font" — smaller, lighter weight, more muted
   than the surrounding tafseer body so the Arabic stays the visual hero. */
.qp-translation-line {
  font-family: var(--font-text) !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  color: var(--ink-tertiary) !important;
  margin: 0 0 6px !important;
  letter-spacing: -0.003em !important;
  font-style: italic;
}

/* ---------- Subtle entrance animation for content -----------------
   IMPORTANT: the final keyframe must use `transform: none`, not
   `translateY(0)`. A non-none transform on .lists turns it into a
   containing block for position:fixed descendants, which makes the
   modals (.words) anchor to the card instead of the viewport. */
@keyframes fadeRise {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: none; }
}

/* Sidebars only — fine to animate, no fixed-positioned descendants */
.sidebars h2,
.sidebars ol > li {
  animation: fadeRise var(--duration-normal) var(--ease-out) both;
}
.sidebars ol > li:nth-child(2)  { animation-delay: 30ms; }
.sidebars ol > li:nth-child(3)  { animation-delay: 60ms; }
.sidebars ol > li:nth-child(4)  { animation-delay: 90ms; }
.sidebars ol > li:nth-child(5)  { animation-delay: 120ms; }
.sidebars ol > li:nth-child(6)  { animation-delay: 150ms; }
.sidebars ol > li:nth-child(n+7){ animation-delay: 180ms; }

/* .lists fades in WITHOUT a transform so its modals can position:fixed. */
@keyframes fadeOnly {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
#wrapper .lists {
  animation: fadeOnly var(--duration-normal) var(--ease-out) both;
}
