/* apps/quran/static/quran/css/quran.css */

:root {
  --wird-brand: #1A843A;
  --wird-brand-hover: #156832;
  --wird-brand-soft: #e6f4eb;
  --wird-brand-border: #b8dfc4;
  --wird-brand-light: #44BA82;
  --wird-brand-light-hover: #3da775;
  --wird-brand-light-soft: #e8f7f0;
  --wird-brand-light-border: #b8e4d0;
}

#quranBadgeChip {
  display: none !important;
}

.stf__wrapper {
  gap: 0 !important;
}

.stf__block {
  margin: 0 !important;
  padding: 0 !important;
}

.stf__shadow {
  display: none !important;
}

.st-page-flip .stf__block {
  box-shadow: none !important;
}

.st-page-flip {
  position: relative;
}

.st-page-flip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #e5e7eb;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5;
}

.st-page-flip.is-portrait::after {
  display: none;
}

.quran-index-modal {
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quran-index-modal > div:last-child {
  min-height: 0;
}

.quran-index-tab {
  letter-spacing: 0;
}

/* ===== CORE LAYOUT (CONFIG DRIVEN) ===== */

#mushafFlipContainer {
  width: 100%;
  overflow: hidden;
}

#mushafArea:not(.mushaf-fullscreen):not(.reading-mode) #mushafFlipContainer {
  margin-top: -1.35rem;
}

#mushafZoomWrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

#mushafFlipBook {
  width: 100%;
  max-width: var(--mushaf-max-width);
  margin-inline: auto;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#mushafFlipBook.mushaf-ready {
  opacity: 1;
}

#mushafFlipBook .page {
  background: #fff;
}

/* واجهة عادية (ليس التكبير): هامش أبيض أوسع حول المصحف لإبراز حدود الزخرفة والإطار */
#mushafArea:not(.mushaf-fullscreen) #mushafZoomWrapper {
  padding-inline: clamp(1rem, 3.8vw, 2.75rem);
  padding-block: clamp(0.75rem, 2.2vw, 1.75rem);
  box-sizing: border-box;
}

#mushafArea:not(.mushaf-fullscreen) #mushafFlipBook .page-content > div {
  padding: clamp(1.35rem, 4vw, 2.35rem) !important;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) {
  #mushafArea {
    padding-inline: 0.5rem;
  }

  #mushafFlipBook {
    border-radius: 1.25rem;
  }

  .quran-index-modal {
    max-height: 90vh;
    border-radius: 1.25rem !important;
  }
}

@media (max-width: 640px) {
  #mushafArea {
    padding-inline: 0.25rem;
  }

  #mushafFlipBook {
    border-radius: 0.9rem;
  }

  #mushafArea:not(.mushaf-fullscreen) #mushafFlipBook .page-content > div {
    padding: clamp(0.65rem, 4.5vw, 1.15rem) !important;
  }

  .quran-index-modal {
    max-height: 92vh;
  }
}

@media (max-width: 1200px) {
  #quranPlaybackToolsPanel {
    display: none !important;
  }

  .wd-quran-playback-dock #quranPlaybackToolsPanel {
    display: flex !important;
  }

  #quranTopToolbar {
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    gap: 0.35rem !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding-inline: 0.1rem;
    margin-top: 0.35rem !important;
    margin-bottom: 0 !important;
  }

  #quranTopToolbar::-webkit-scrollbar {
    display: none;
  }

  #quranTopToolbar {
    scrollbar-width: none;
  }

  #quranTopToolbar .quran-sel-trigger,
  #quranTopToolbar #readingModeToggle,
  #quranTopToolbar .quran-tool-toggle,
  #quranTopToolbar .quran-tool-chip {
    height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1f2937;
    gap: 0.55rem;
  }

  #quranTopToolbar .quran-sel-trigger > i:not(.quran-sel-trigger-icon) {
    font-size: 0.78rem !important;
  }

  #quranMobilePlaybackIcons {
    display: inline-flex !important;
    margin: 1.55rem auto 0 !important;
    gap: 0.45rem !important;
    position: relative;
    z-index: 5;
  }

  #quranMobilePlaybackIcons > button:first-child {
    display: none !important;
  }

  #readingModeToggle,
  #tafsirReadingModeToggle,
  .quran-toolbar-edge-start:has(#readingModeToggle),
  .quran-toolbar-edge-start:has(#tafsirReadingModeToggle) {
    display: none !important;
  }

  body.quran-reading-mode-active #readingModeToggle,
  body.quran-reading-mode-active .quran-toolbar-edge-start:has(#readingModeToggle) {
    display: inline-flex !important;
  }

  body.quran-reading-mode-active .wd-quran-tools-top {
    position: fixed;
    top: 12px;
    inset-inline-start: 12px;
    inset-inline-end: auto;
    z-index: 220;
    width: auto;
    padding: 0 !important;
    padding-inline-start: 0 !important;
    padding-inline-end: 0 !important;
    pointer-events: none;
  }

  body.quran-reading-mode-active .wd-quran-tools-nav {
    pointer-events: auto;
  }

  .wd-quran-viewport .wd-quran-fullscreen-dock,
  .wd-quran-viewport #mushafFullscreenBtn {
    display: none !important;
  }

  #mushafFlipContainer {
    margin-top: 0 !important;
  }

  #mushafArea:not(.mushaf-fullscreen):not(.reading-mode) #mushafFlipContainer {
    margin-top: 0 !important;
  }

  #quranMobilePlaybackIcons button {
    width: 1.85rem !important;
    height: 1.85rem !important;
    min-width: 1.85rem !important;
    min-height: 1.85rem !important;
    border-radius: 9999px !important;
  }

  #quranMobilePlaybackIcons button i {
    font-size: 0.68rem !important;
    line-height: 1 !important;
  }

  #quranMobilePlaybackIcons #quranMobileVolume {
    width: 2.5rem !important;
  }

  #currentReciterCard,
  #currentMushafCard,
  #quranPlaybackFeatureToggles,
  #quranThematicCard,
  #wordMeaningsCard {
    display: none !important;
  }
}

/* ===== FULLSCREEN (CONFIG DRIVEN) ===== */

#mushafArea.mushaf-fullscreen {
  /* !important يتفوق على #mushafArea.reading-mode (خلفية بيضاء) عند التكبير */
  background: #000 !important;
  padding: 0 !important;
  margin: 0 !important;
  width: calc(var(--mushaf-fullscreen-width-vw) * 1vw);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

#mushafArea.mushaf-fullscreen > #mushafFlipContainer {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
}

#mushafArea.mushaf-fullscreen #mushafFlipContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

#mushafArea.mushaf-fullscreen #mushafZoomWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}

#mushafArea.mushaf-fullscreen #quranFloatingControls.wd-quran-floating-controls.is-visible {
  position: absolute;
  top: 0;
  right: calc(100% + 28px);
  left: auto;
  inset-inline-end: calc(100% + 28px);
  inset-inline-start: auto;
  z-index: 120;
  margin: 0;
  transform: none;
}

#mushafArea.mushaf-fullscreen #mushafFlipBook {
  margin: 0 auto !important;
  max-width: calc(var(--mushaf-fullscreen-max-width-vw) * 1vw);
  /* ورق الصفحة أبيض كالطباعة؛ الهوامش السوداء تبقى على الحاويات الخارجية فقط */
  background-color: #fff !important;
}

#mushafArea.mushaf-fullscreen #mushafFlipContainer,
#mushafArea.mushaf-fullscreen #mushafZoomWrapper {
  background: #000 !important;
}

#mushafArea.mushaf-fullscreen #mushafFlipBook .page {
  background: #fff !important;
}

#mushafArea.mushaf-fullscreen #mushafFlipBook .page-content,
#mushafArea.mushaf-fullscreen #mushafFlipBook .page-content > div {
  background: #fff;
}

/*
 * تكبير: هامش أبيض حول الزخرفة ومكان السورة/الجزء/الرقم (كتب مطبوعة).
 * القيم تقارب الوضع العادي مع تقوية معتدلة للشاشة الكاملة (~5–7٪ بحسب viewport).
 */
#mushafArea.mushaf-fullscreen #mushafFlipBook .page-content > div {
  padding: clamp(1.25rem, 5.5vw, 2.9rem) !important;
}

@media (max-width: 640px) {
  #mushafArea.mushaf-fullscreen #mushafFlipBook .page-content > div {
    padding: clamp(0.65rem, 5vw, 1.35rem) !important;
  }
}

#mushafArea.mushaf-fullscreen .st-page-flip > .stf__parent {
  background: #fff !important;
}

#mushafArea.mushaf-fullscreen #quranTopToolbar {
  display: none !important;
}

#mushafArea.mushaf-fullscreen .tools-panel {
  display: none !important;
}

#mushafArea:fullscreen {
  background: #000 !important;
}

/* خلفية شريط المتصفح خلف عنصر fullscreen (كثيرًا ما تكون بيضاء افتراضيًا) */
#mushafArea:fullscreen::backdrop {
  background: #000 !important;
}

/* ===== PAGE CONTENT ===== */

.page-content {
  position: relative;
}

/* ===== AYAH LAYER ===== */

.ayah-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.ayah-box {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: transparent;
  transform: scaleY(0.7);
  transform-origin: center;
}

.ayah-box:hover {
  background: transparent;
}

.ayah-polygon {
  fill: transparent;
  transition: fill 0.25s ease, filter 0.25s ease;
  pointer-events: none;
}

.ayah-polygon.ayah-hover {
  fill: transparent !important;
}

.ayah-polygon.ayah-active {
  fill: rgba(255, 235, 59, 0.14) !important;
  filter: drop-shadow(0 0 6px rgba(255, 193, 7, 0.45));
}

#mushafArea.quran-thematic-mode .ayah-polygon.ayah-active {
  fill: var(--quran-topic-fill, rgba(255, 235, 59, 0.14)) !important;
  filter: drop-shadow(0 0 6px var(--quran-topic-shadow, rgba(255, 193, 7, 0.45)));
}

/* ===== HOVER ===== */

.ayah-hover-unified-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.ayah-hover-piece {
  position: absolute;
  pointer-events: none;
  background: rgba(110, 110, 110, 0.15);
  filter: drop-shadow(0 0 6px rgba(110, 110, 110, 0.35));
}

/* ===== READING MODE ===== */

body.quran-reading-mode-active .wd-app {
  grid-template-columns: minmax(0, 1fr);
}

body.quran-reading-mode-active .wd-sidebar,
body.quran-reading-mode-active .wd-sidebar-toggle,
body.quran-reading-mode-active .wd-sidebar-overlay {
  display: none !important;
}

body.quran-reading-mode-active .wd-main,
body.quran-reading-mode-active .wd-content-quran,
body.quran-reading-mode-active .wd-quran-layout {
  width: 100%;
  max-width: 100%;
}

body.quran-reading-mode-active .wd-content-quran {
  padding: 0 !important;
}

body.quran-reading-mode-active .wd-quran-tools-top {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  inset-inline-end: auto;
  z-index: 220;
  width: auto;
  min-height: 0;
  padding: 0 !important;
  margin: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

body.quran-reading-mode-active .wd-quran-tools-nav {
  width: auto;
  pointer-events: auto;
}

body.quran-reading-mode-active #quranTopToolbar {
  display: flex;
  width: auto;
  grid-template-columns: auto;
  justify-content: flex-start;
}

body.quran-reading-mode-active #quranTopToolbar .quran-toolbar-main {
  display: none !important;
}

body.quran-reading-mode-active #readingModeToggle {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
}

body.quran-reading-mode-active .wd-quran-tools-toggle,
body.quran-reading-mode-active .wd-quran-tools-backdrop,
body.quran-reading-mode-active #quranMobilePlaybackIcons,
body.quran-reading-mode-active #quranPanelBackdrop,
body.quran-reading-mode-active .wd-quran-playback-dock,
body.quran-reading-mode-active .quran-word-meanings-rail,
body.quran-reading-mode-active .quran-thematic-rail,
body.quran-reading-mode-active .wd-quran-fullscreen-dock,
body.quran-reading-mode-active #quranToolsPanels,
body.quran-reading-mode-active #quranToolsSecondary,
body.quran-reading-mode-active #quranFloatingControls,
body.quran-reading-mode-active #quranFloatExitDock {
  display: none !important;
}

body.quran-reading-mode-active .wd-quran-viewport {
  padding-top: 0 !important;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

body.quran-reading-mode-active .wd-quran-center {
  width: 100%;
  max-width: 100%;
  justify-content: center;
}

#mushafArea.reading-mode:not(.mushaf-fullscreen) {
  width: 100%;
  min-height: calc(100vh - 56px);
  justify-content: center;
  align-items: center;
}

#mushafArea.reading-mode #quranFloatingControls,
#mushafArea.reading-mode #quranFloatExitDock {
  display: none !important;
}

#mushafArea.reading-mode {
  background: #ffffff !important;
}

#mushafArea.reading-mode #mushafFlipBook {
  max-width: var(--mushaf-max-width) !important;
}

#mushafArea.reading-mode #mushafFlipContainer {
  margin-top: 0 !important;
}

#mushafArea.reading-mode .ayah-layer {
  pointer-events: none !important;
}

#mushafArea.reading-mode .ayah-box {
  cursor: default !important;
}

#mushafArea.reading-mode .ayah-polygon,
#mushafArea.reading-mode .ayah-polygon.ayah-hover,
#mushafArea.reading-mode .ayah-polygon.ayah-active {
  fill: transparent !important;
  transition: none !important;
}

#mushafArea.reading-mode .ayah-hover-unified-layer,
#mushafArea.reading-mode .ayah-hover-piece {
  display: none !important;
}

#mushafArea.reading-mode #ayahMenu {
  display: none !important;
}

/* Ayah action menu: compact icon-only mode on small screens */
@media (max-width: 640px) {
  #ayahMenu.ayah-menu {
    top: 0;
    left: 0;
    transform: translateX(-50%);
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.45rem;
    border-radius: 9999px;
    max-width: calc(100vw - 20px);
    z-index: 10060;
  }

  #ayahMenu.ayah-menu:not(.hidden) {
    display: inline-flex;
    transform: translate(-50%, -50%);
  }

  #ayahMenu.ayah-menu .ayah-menu-action {
    width: auto !important;
    min-width: 2.15rem;
    height: 2.15rem;
    border-radius: 9999px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  #ayahMenu.ayah-menu .ayah-menu-label {
    display: none !important;
  }

  #ayahMenu.ayah-menu .ayah-menu-action i {
    font-size: 1rem;
    line-height: 1;
    margin: 0 !important;
  }
}

/* ===== VOLUME SLIDER ===== */

.mushaf-volume-range {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  background: transparent;
  outline: none;
  cursor: pointer;
}

.mushaf-volume-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 9999px;
  background: linear-gradient(to left, #a6ce39 var(--fill, 100%), #374151 var(--fill, 100%));
}

.mushaf-volume-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: #a6ce39;
  border: none;
}

.mushaf-volume-range::-moz-range-track {
  height: 6px;
  border-radius: 9999px;
  background: linear-gradient(to left, #a6ce39 var(--fill, 100%), #374151 var(--fill, 100%));
}

.mushaf-volume-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a6ce39;
  border: none;
}

/* ===== SAVED ===== */

.ayah-saved {
  background-color: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 6px;
}

.ayah-polygon.ayah-saved {
  fill: rgba(220, 38, 38, 0.22) !important;
}

.ayah-polygon.ayah-saved:hover {
  fill: rgba(220, 38, 38, 0.28) !important;
}

/* ===== BOOKMARK ===== */

#ayahBookmarkIcon {
  transition: color 0.2s ease, transform 0.2s ease;
}

#ayahBookmarkIcon.is-saved {
  color: #b91c1c !important;
}

/* ===== RESUME ===== */

.ayah-resume-unified-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.ayah-resume-piece {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
  background: rgba(26, 132, 58, 0.1);
  border: 1.5px solid rgba(26, 132, 58, 0.42);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(26, 132, 58, 0.08),
    0 4px 14px rgba(26, 132, 58, 0.16);
  animation: resumeAyahPieceReveal 2.2s ease;
}

.ayah-resume-unified-layer.is-from-search .ayah-resume-piece {
  background: rgba(255, 235, 59, 0.14);
  border: none;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 0 6px rgba(255, 193, 7, 0.45));
  animation: none;
  opacity: 1;
}

@keyframes resumeAyahPieceReveal {
  0% {
    opacity: 0;
    transform: scale(0.992);
  }
  35% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 1;
  }
}

.resume-ayah-target {
  outline: none !important;
  border-radius: 0;
  animation: none;
}

.resume-ayah-target path,
.resume-ayah-target polygon,
.resume-ayah-target rect,
.resume-ayah-target polyline {
  stroke-width: 0 !important;
  fill: transparent !important;
  filter: none !important;
}



/* ── Quran toolbar selector shared styles (mirrors hifz panel design) ── */
.quran-sel-field {
  position: relative;
  flex: 0 0 auto;
  min-width: clamp(10rem, 14vw, 12.5rem);
}

#quranFihrisField,
#tafsirFihrisField,
#hifzSurahField {
  min-width: clamp(11rem, 16vw, 14rem);
}

.quran-sel-trigger {
  width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  height: 2rem;
  padding: 0 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  text-align: start;
  box-shadow: none;
  transition: background 0.15s;
}

.quran-sel-trigger:not(.quran-qari-trigger) {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 0.5rem;
}

.quran-sel-trigger > span[id$="TriggerText"],
.quran-sel-trigger .truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.quran-sel-trigger > i:not(.quran-sel-trigger-icon),
.quran-sel-trigger .quran-sel-trigger-leading-icon {
  font-size: 0.78rem;
  color: #6b7280;
  flex: 0 0 auto;
}

.quran-sel-trigger.hidden { display: none !important; }
.quran-sel-trigger:hover { background: #f9fafb; color: #1f2937; }
.quran-sel-trigger-icon { font-size: 0.7rem; color: #6b7280; flex: 0 0 auto; }

.quran-qari-trigger .inline-flex {
  gap: 0.5rem;
  min-width: 0;
}

.quran-sel-panel {
  position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 400;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 18px;
  box-shadow: 0 16px 38px rgba(15,23,42,0.14); padding: 0.8rem;
  animation: quranSelIn 0.18s ease;
}
@keyframes quranSelIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.quran-sel-panel.hidden { display: none !important; }

.quran-sel-panel-mushaf { width: min(92vw, 240px); }
.quran-sel-panel-qari   { width: min(92vw, 260px); }
.quran-sel-panel-surah  {
  position: fixed;
  top: clamp(5.25rem, 14vh, 7.25rem);
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 720px);
  max-height: min(82vh, 660px);
  overflow: hidden;
  z-index: 10002;
  animation: quranFihrisIn 0.18s ease;
}

@keyframes quranFihrisIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .quran-sel-panel-surah {
    top: clamp(5rem, 12vh, 6.5rem);
    left: 50%;
    transform: translateX(-50%);
    width: min(94vw, 400px);
  }
}

.quran-sel-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.8rem;
}
.quran-sel-panel-title { font-size: 0.88rem; font-weight: 700; color: var(--wird-brand); }
.quran-sel-close {
  width: 2.1rem; height: 2.1rem; border: none; border-radius: 9999px;
  background: var(--wird-brand-soft); color: var(--wird-brand);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto; font-size: 0.75rem;
}

.quran-sel-search-wrap { margin-bottom: 0.8rem; }
.quran-sel-search {
  width: 100%; height: 2.2rem; border: 1px solid #e5e7eb; border-radius: 12px;
  background: #fff; padding: 0 0.85rem; outline: none;
  font-size: 0.82rem; font-weight: 600;
}
.quran-sel-search:focus { border-color: var(--wird-brand); box-shadow: 0 0 0 3px rgba(26, 132, 58, 0.14); }

.quran-fihris-tabs {
  display: flex;
  gap: 0.25rem;
  background: #f3f4f6;
  border-radius: 14px;
  padding: 0.25rem;
  margin-bottom: 0.8rem;
}

.quran-fihris-tab {
  flex: 1 1 0;
  min-height: 2.1rem;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  transition: all 0.16s ease;
}

.quran-fihris-tab.is-active {
  background: #fff;
  color: var(--wird-brand);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
}

.quran-fihris-panel.hidden {
  display: none !important;
}

.quran-sel-list { display: flex; flex-direction: column; gap: 0.45rem; }
.quran-sel-list-scroll { max-height: 300px; overflow-y: auto; padding-inline-end: 0.2rem; }

.quran-sel-list-item {
  width: 100%; min-height: 2.4rem; border: 1px solid var(--wird-brand-border); border-radius: 13px;
  background: #fff; padding: 0.35rem 0.65rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.7rem;
  text-align: start; font-size: 0.82rem; font-weight: 600; color: #3f3f46;
  cursor: pointer; transition: all 0.18s ease; text-decoration: none;
}
.quran-sel-list-item:hover, .quran-sel-list-item.is-active {
  border-color: var(--wird-brand-border); background: var(--wird-brand-soft); color: var(--wird-brand-hover);
}
.quran-sel-check { opacity: 0; color: var(--wird-brand); flex: 0 0 auto; }
.quran-sel-list-item.is-active .quran-sel-check { opacity: 1; }

/* Surah grid */
.quran-sel-surah-scroll { max-height: 420px; overflow-y: auto; padding-inline-end: 0.2rem; }
.quran-sel-surah-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 0.6rem;
}
@media (max-width: 640px) { .quran-sel-surah-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }

.quran-sel-juz-item {
  padding-inline: 0.45rem;
  min-width: 4.75rem;
}

.quran-sel-juz-item .quran-sel-surah-name {
  font-size: 0.78rem;
  white-space: nowrap;
  line-height: 1.15;
}

/* ── Mobile (≤640px): 3+2 toolbar rows + centered overlay panels ── */
@media (max-width: 640px) {
  #quranTopToolbar {
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    padding-bottom: 0.25rem !important;
  }

  /* Centered modal overlay for all panels */
  .quran-sel-panel {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 10002 !important;
    max-height: 75vh !important;
    overflow-y: auto !important;
    animation: quranSelInCenter 0.2s ease !important;
  }

  @keyframes quranSelInCenter {
    from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }

  .quran-sel-panel-mushaf { width: min(88vw, 300px) !important; }
  .quran-sel-panel-qari   { width: min(88vw, 300px) !important; }
  .quran-sel-panel-surah  {
    width: min(96vw, 360px) !important;
    top: clamp(5rem, 12vh, 6.5rem) !important;
    transform: translateX(-50%) !important;
  }

  .quran-sel-surah-scroll { max-height: 55vh !important; }
  .quran-sel-list-scroll  { max-height: 50vh !important; }
}

/* Backdrop overlay behind centered panels */
#quranPanelBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10001;
}
#quranPanelBackdrop.active { display: block; }

.wd-body-hifz #hifzSurahPanel.quran-sel-panel-surah {
  z-index: 10003;
}

.wd-body-hifz:has(#quranPanelBackdrop.active) #hifzSurahPanel.quran-sel-panel-surah:not(.hidden) {
  z-index: 10003 !important;
}

.wd-body-translation #translationFihrisPanel.quran-sel-panel-surah {
  z-index: 10003;
}

.wd-body-translation:has(#quranPanelBackdrop.active) #translationFihrisPanel.quran-sel-panel-surah:not(.hidden) {
  z-index: 10003 !important;
}

.wd-body-translation:has(#quranPanelBackdrop.active) .wd-quran-tools-top {
  z-index: 10100;
}

.wd-body-translation:has(#quranPanelBackdrop.active) .wd-translation-viewport .wd-quran-fullscreen-dock {
  visibility: hidden !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

/* الفهرس/اللوحات: فوق مشغّل الصوت والتكبير ومعاني الكلمات */
.wd-body-quran:has(#quranPanelBackdrop.active) .wd-quran-tools-top,
.wd-body-hifz:has(#quranPanelBackdrop.active) .wd-quran-tools-top,
.wd-body-hifz:has(#quranPanelBackdrop.active) .wd-hifz-tools-top {
  z-index: 10100;
}

.wd-body-quran:has(#quranPanelBackdrop.active) .wd-quran-viewport .wd-quran-playback-dock,
.wd-body-quran:has(#quranPanelBackdrop.active) .wd-quran-viewport .wd-quran-fullscreen-dock,
.wd-body-quran:has(#quranPanelBackdrop.active) .wd-quran-viewport > .quran-word-meanings-rail,
.wd-body-quran:has(#quranPanelBackdrop.active) .wd-quran-viewport > .quran-thematic-rail,
.wd-body-quran:has(#quranPanelBackdrop.active) #quranMobilePlaybackIcons,
.wd-body-hifz:has(#quranPanelBackdrop.active) .wd-hifz-viewport .wd-quran-fullscreen-dock,
.wd-body-hifz:has(#quranPanelBackdrop.active) .wd-hifz-viewport .hifz-thematic-rail,
.wd-body-hifz:has(#quranPanelBackdrop.active) .wd-hifz-viewport .hifz-recitation-rail {
  visibility: hidden !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

.quran-sel-surah-item {
  border: 1px solid var(--wird-brand-border); border-radius: 13px; background: #fff;
  min-height: 2.5rem; padding: 0.3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.05rem; text-align: center; cursor: pointer; transition: all 0.18s ease;
}
.quran-sel-surah-item:hover, .quran-sel-surah-item.is-active {
  border-color: var(--wird-brand-border); background: var(--wird-brand-soft);
}
.quran-sel-surah-num  { font-size: 0.65rem; font-weight: 700; color: #7b7b84; }
.quran-sel-surah-name { font-size: 0.75rem; font-weight: 700; color: var(--wird-brand); }

/* Short tafsir — full-screen overlay modal */
.short-tafsir-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.short-tafsir-overlay.hidden {
  display: none !important;
}

.short-tafsir-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
}

.short-tafsir-modal {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(92vw, 640px);
  max-height: min(88vh, 760px);
  border-radius: 16px;
  border: 1px solid var(--wird-brand-border);
  background: #fff;
  box-shadow: 0 28px 56px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  animation: shortTafsirIn 0.2s ease;
}

@keyframes shortTafsirIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.short-tafsir-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--wird-brand-border);
  background: var(--wird-brand-soft);
}

.short-tafsir-modal-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--wird-brand);
}

.short-tafsir-modal-meta {
  font-size: 0.7rem;
  color: #5f6761;
  margin-top: 0.2rem;
}

.short-tafsir-modal-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 9999px;
  background: #fff;
  color: var(--wird-brand);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.short-tafsir-modal-close:hover {
  background: var(--wird-brand);
  color: #fff;
}

.short-tafsir-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1.15rem 1.15rem;
}

.short-tafsir-modal-ayah {
  font-size: 0.95rem;
  line-height: 1.85;
  font-weight: 700;
  color: var(--wird-brand);
  margin-bottom: 0.85rem;
}

.short-tafsir-modal-text {
  font-size: 0.9rem;
  line-height: 1.75;
  color: #1a1f1c;
  text-align: justify;
}

.short-tafsir-modal-status {
  padding: 1.5rem 1.15rem;
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
}

.short-tafsir-modal-status.is-error {
  color: #b91c1c;
}

body.short-tafsir-open {
  overflow: hidden;
}

/* Official brand (#1A843A) — buttons & accent text (Quran + Hifz) */
.bg-emerald-500,
.bg-emerald-600 {
  background-color: var(--wird-brand) !important;
}

.hover\:bg-emerald-600:hover,
.hover\:bg-emerald-700:hover,
.active\:bg-emerald-700:active {
  background-color: var(--wird-brand-hover) !important;
}

.text-emerald-500,
.text-emerald-600,
.text-emerald-700,
.text-emerald-800,
.text-sky-600,
.text-blue-600,
.text-blue-700 {
  color: var(--wird-brand) !important;
}

.bg-emerald-50,
.bg-sky-50,
.hover\:bg-emerald-50:hover,
.hover\:bg-blue-50:hover {
  background-color: var(--wird-brand-soft) !important;
}

.border-emerald-100,
.border-emerald-200,
.border-emerald-400,
.border-sky-100 {
  border-color: var(--wird-brand-border) !important;
}

.focus\:ring-emerald-500:focus,
.focus\:border-emerald-500:focus {
  --tw-ring-color: var(--wird-brand) !important;
  border-color: var(--wird-brand) !important;
}

.group-hover\:text-emerald-700:hover,
.group-hover\:text-emerald-800:hover,
.hover\:text-emerald-700:hover {
  color: var(--wird-brand) !important;
}

.group-hover\:border-emerald-400:hover {
  border-color: var(--wird-brand) !important;
}

.accent-emerald-600 {
  accent-color: var(--wird-brand) !important;
}
