#page-reader-panel {
  --mushaf-text-size: 36px;
  --page-ink: #17251f;
  --page-green: #155c45;
  --page-gold: #aa8735;
  --page-paper: #fffdf3;
  margin-inline: calc(clamp(20px, 6vw, 90px) * -1);
  padding: 0 clamp(14px, 4vw, 55px) 42px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(210, 177, 102, .2), transparent 34%),
    repeating-linear-gradient(90deg, transparent 0 74px, rgba(91, 71, 36, .018) 75px),
    #eee9dc;
}

#page-reader-panel[hidden] { display: none; }

.mushaf-reading,
.mushaf-reading body { height: 100%; overflow: hidden; }
.mushaf-reading .content-view { max-width: none; padding-top: 0; padding-bottom: 0; }
.mushaf-reading .quran-view-switch { display: none; }
.mushaf-reading #page-reader-panel {
  height: calc(100dvh - 76px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mushaf-reader-top {
  max-width: 1030px;
  margin: auto;
  min-height: 48px;
  padding: 7px 2px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.mushaf-reader-top .back-link { margin: 0; }

.reading-preferences {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(23, 53, 44, .12);
  border-radius: 999px;
  background: rgba(255, 253, 248, .8);
  box-shadow: 0 4px 18px rgba(29, 42, 35, .06);
  backdrop-filter: blur(12px);
}
.reading-preferences > span {
  padding: 0 8px 0 11px;
  color: #6d766f;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.reading-preferences button {
  min-width: 38px;
  height: 35px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #315a4c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.reading-preferences button:hover,
.reading-preferences button[aria-pressed="true"] { background: #e5eee8; color: #124f3c; }

.page-reader-toolbar {
  max-width: 690px;
  margin: 0 auto 10px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 18px;
  text-align: center;
}
.page-reader-toolbar button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(23, 53, 44, .13);
  border-radius: 50%;
  background: rgba(255, 253, 248, .72);
  color: #155c45;
  box-shadow: 0 7px 20px rgba(24, 53, 44, .07);
  cursor: pointer;
  font-size: 19px;
}
.page-reader-toolbar button:hover { transform: translateY(-2px); background: #fffdf8; box-shadow: 0 10px 24px rgba(24, 53, 44, .12); }
.page-reader-toolbar h2 { margin: 0; color: #263c34; font: 400 28px/1.1 Georgia, serif; }
.page-reader-toolbar h2 small { color: #7a827e; font: 10px Inter, "Segoe UI", sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.page-reader-toolbar .eyebrow { margin: 0 0 4px; color: #8a7138; font: 700 18px/1.2 "Traditional Arabic", "Amiri", serif; letter-spacing: 0; text-transform: none; }

.mushaf-book-stage {
  max-width: 1020px;
  margin: auto;
  padding: 13px 18px 17px;
  width: min(1020px, 100%);
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  border-radius: 18px 18px 25px 25px;
  background: linear-gradient(90deg, rgba(255,255,255,.03), transparent 7% 93%, rgba(0,0,0,.11)), linear-gradient(145deg, #174d3d, #0a2e23 72%);
  box-shadow: 0 38px 70px rgba(25, 35, 30, .27), 0 10px 18px rgba(25, 35, 30, .16), inset 0 0 0 2px rgba(211, 177, 89, .3), inset 0 0 0 7px rgba(7, 31, 24, .45);
}
.mushaf-book-stage::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(211, 177, 89, .2); border-radius: 10px 10px 17px 17px; pointer-events: none; }
.mushaf-book-stage::after { content: ""; position: absolute; z-index: -1; left: 5%; right: 5%; bottom: -14px; height: 32px; border-radius: 50%; background: rgba(13, 30, 24, .28); filter: blur(16px); }
.book-ribbon { position: absolute; z-index: 4; top: 10px; right: 8.5%; width: 18px; height: 58px; background: linear-gradient(90deg, #713a34, #9b4d43 48%, #6a302d); box-shadow: 0 5px 8px rgba(52, 20, 15, .24); }
.book-ribbon::after { content: ""; position: absolute; bottom: -10px; border-left: 11px solid transparent; border-right: 11px solid transparent; border-top: 10px solid #713a34; }

.mushaf-cover { position: relative; height: 100%; padding: 7px 10px 9px 18px; border-radius: 7px 7px 12px 12px; background: linear-gradient(90deg, #b7a980 0, #e8dfc5 2.3%, #f8f2df 4.2%, #eee4c9 96%, #b0a175 100%); box-shadow: inset 12px 0 18px rgba(64, 44, 16, .17), inset -6px 0 10px rgba(64, 44, 16, .1); }
.mushaf-page-stack { position: absolute; inset: 5px 5px 4px 16px; border-right: 4px double rgba(105, 83, 43, .28); border-bottom: 5px double rgba(105, 83, 43, .24); border-radius: 3px 3px 8px 5px; pointer-events: none; }
.mushaf-leaf { position: relative; height: 100%; overflow: hidden; border-radius: 2px 2px 7px 4px; }
.mushaf-leaf::before { content: ""; position: absolute; z-index: 3; inset: 0 auto 0 0; width: 38px; pointer-events: none; background: linear-gradient(90deg, rgba(72, 50, 19, .17), rgba(122, 92, 38, .035) 55%, transparent); }

.mushaf-page {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 22px clamp(34px, 6vw, 76px) 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--page-ink);
  border: 1px solid #b5964b;
  outline: 4px double rgba(170, 135, 53, .68);
  outline-offset: -13px;
  background: radial-gradient(ellipse at 50% 28%, rgba(255,255,255,.9), transparent 54%), radial-gradient(circle at 12% 8%, rgba(178, 139, 58, .035) 0 1px, transparent 2px), radial-gradient(circle at 82% 65%, rgba(178, 139, 58, .028) 0 1px, transparent 2px), linear-gradient(90deg, rgba(177, 139, 58, .055), transparent 8% 92%, rgba(177, 139, 58, .045)), var(--page-paper);
  background-size: auto, 11px 11px, 13px 13px, auto, auto;
  box-shadow: inset 0 0 44px rgba(125, 91, 28, .09), inset 0 0 0 8px rgba(255,255,255,.34);
}
.mushaf-page::before,
.mushaf-page::after { content: "✦"; position: absolute; top: 15px; color: rgba(154, 119, 39, .78); font-size: 10px; }
.mushaf-page::before { left: 18px; }
.mushaf-page::after { right: 18px; }
.mushaf-page.page-entering { animation: pageReveal .34s ease-out; }
@keyframes pageReveal { from { opacity: .55; transform: translateX(8px); } to { opacity: 1; transform: none; } }

.mushaf-folio { min-height: 29px; margin: 0 1px 10px; padding: 0 17px 6px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; direction: rtl; border-bottom: 1px solid rgba(170, 135, 53, .42); color: #6e5b2d; font: 16px/1.15 "Traditional Arabic", "Amiri", serif; }
.mushaf-folio span:first-child { text-align: right; }
.mushaf-folio span:last-child { text-align: left; }
.mushaf-folio .folio-ornament { color: var(--page-gold); font-size: 18px; }
.mushaf-surah { margin-bottom: 8px; }
.mushaf-surah-header { width: min(680px, 94%); min-height: 48px; margin: 8px auto 10px; padding: 3px 24px; display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 10px; text-align: center; border: 1px solid #aa8735; outline: 1px solid rgba(170, 135, 53, .48); outline-offset: -5px; border-radius: 2px; background: linear-gradient(135deg, transparent 13px, rgba(213, 187, 116, .15) 0) top left, linear-gradient(-135deg, transparent 13px, rgba(213, 187, 116, .15) 0) top right, linear-gradient(45deg, transparent 13px, rgba(213, 187, 116, .15) 0) bottom left, linear-gradient(-45deg, transparent 13px, rgba(213, 187, 116, .15) 0) bottom right, #fbf4df; background-size: 51% 51%; background-repeat: no-repeat; color: var(--page-gold); }
.mushaf-folio + .mushaf-surah .mushaf-surah-header { margin-top: 0; }
.mushaf-surah-header h3 { margin: 0; color: #174c3b; font: 700 28px/1.2 "Traditional Arabic", "Amiri", "Scheherazade New", serif; }
.mushaf-surah-header > span { font-size: 15px; }

.mushaf-arabic { margin: 0; direction: rtl; color: var(--page-ink); font-family: "Traditional Arabic", "Arabic Typesetting", "Amiri", "Scheherazade New", serif; font-size: var(--page-fitted-size, var(--mushaf-text-size)); font-weight: 400; line-height: 1.88; text-align: justify; text-align-last: center; word-spacing: .035em; text-rendering: optimizeLegibility; font-kerning: normal; }
.mushaf-ayah { display: inline; }
.mushaf-ayah-number { min-width: 1.72em; height: 1.72em; margin: 0 .15em; display: inline-grid; place-items: center; position: relative; top: -.05em; border: 1px solid rgba(151, 116, 37, .85); border-radius: 50%; background: rgba(255, 249, 228, .8); color: #155c45; font-family: "Traditional Arabic", "Amiri", serif; font-size: .39em; font-weight: 700; line-height: 1; vertical-align: middle; }

.mushaf-folio-end { margin-top: auto; padding: 9px 13px 1px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; direction: rtl; border: 0; background: transparent; color: #806a34; font: 13px/1 "Traditional Arabic", "Amiri", serif; }
.mushaf-folio-end span:first-child { text-align: right; }
.mushaf-folio-end span:last-child { text-align: left; }
.mushaf-folio-end strong { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid #aa8735; outline: 1px solid rgba(170, 135, 53, .48); outline-offset: 3px; border-radius: 50%; color: #155c45; background: #fffaf0; font-weight: 700; }

.mushaf-reading-hint { display: none; }
.page-reader-bottom { z-index: 8; width: min(680px, 100%); flex: 0 0 48px; margin: 6px auto 0; padding: 4px 7px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(23, 53, 44, .12); border-radius: 999px; background: rgba(255, 253, 248, .88); box-shadow: 0 8px 24px rgba(24, 53, 44, .1); backdrop-filter: blur(16px); color: #737c77; font-size: 10px; }
.page-reader-bottom button { min-height: 40px; padding: 8px 17px; border: 0; border-radius: 999px; background: transparent; color: #155c45; cursor: pointer; font-weight: 750; }
.page-reader-bottom button:hover { background: #e8efe9; }
.page-reader-toolbar button:disabled,
.page-reader-bottom button:disabled { opacity: .32; cursor: not-allowed; }
.mushaf-font-small { --mushaf-text-size: 31px !important; }
.mushaf-font-large { --mushaf-text-size: 41px !important; }
.mushaf-focus .topbar,
.mushaf-focus body > footer { display: none; }
.mushaf-focus #quran-view { max-width: none; padding-top: 0; }
.mushaf-focus #page-reader-panel { margin-top: 0; }
.mushaf-reading.mushaf-focus #page-reader-panel { height: 100dvh; }
.mushaf-focus .mushaf-reader-top { padding-top: 12px; }

@media (prefers-reduced-motion: reduce) { .mushaf-page.page-entering { animation: none; } }

@media (max-width: 750px) {
  .mushaf-reading body { width: 100vw; overflow: hidden; }
  .mushaf-reading .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .mushaf-reading .topbar .brand-mark { width: 34px; height: 34px; }
  .mushaf-reading .topbar nav,
  .mushaf-reading .topbar .menu-toggle,
  .mushaf-reading .topbar .nav-actions { display: none; }
  .mushaf-reading .content-view { width: 100vw; padding-inline: 0; }
  .mushaf-reading #page-reader-panel { height: calc(100dvh - 52px); }
  #page-reader-panel { width: 100%; margin-inline: 0; padding: 0 0 10px; background: #f3efe4; }
  .mushaf-reader-top { padding: 10px 13px 7px; }
  .reading-preferences > span { display: none; }
  .reading-preferences button { min-width: 38px; height: 38px; padding-inline: 8px; }
  .reading-preferences button span { display: none; }
  .page-reader-toolbar { grid-template-columns: 42px 1fr 42px; margin: 0 11px 10px; gap: 9px; }
  .page-reader-toolbar button { width: 40px; height: 40px; }
  .page-reader-toolbar h2 { font-size: 22px; }
  .page-reader-toolbar .eyebrow { font-size: 16px; }
  .mushaf-book-stage { padding: 0; border-radius: 0; background: transparent; box-shadow: 0 12px 30px rgba(44, 37, 25, .12); }
  .mushaf-book-stage::before,
  .mushaf-book-stage::after,
  .book-ribbon,
  .mushaf-page-stack { display: none; }
  .mushaf-cover { padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .mushaf-leaf { border-radius: 0; }
  .mushaf-leaf::before { width: 12px; opacity: .45; }
  .mushaf-page { height: 100%; min-height: 0; padding: 14px 22px 10px; border: 0; border-top: 1px solid rgba(170, 135, 53, .5); border-bottom: 1px solid rgba(170, 135, 53, .5); outline-width: 3px; outline-offset: -8px; box-shadow: inset 0 0 24px rgba(125, 91, 28, .06); }
  .mushaf-page::before { left: 11px; top: 10px; }
  .mushaf-page::after { right: 11px; top: 10px; }
  .mushaf-folio { min-height: 26px; margin-bottom: 8px; padding: 0 8px 5px; gap: 8px; font-size: 14px; }
  .mushaf-surah-header { width: 96%; min-height: 42px; margin: 6px auto 8px; padding: 3px 12px; grid-template-columns: 22px 1fr 22px; }
  .mushaf-surah-header h3 { font-size: 23px; }
  .mushaf-surah-header > span { font-size: 11px; }
  .mushaf-arabic { font-size: var(--page-fitted-size, var(--mushaf-text-size)); line-height: 1.78; word-spacing: 0; }
  .mushaf-folio-end { padding: 6px 4px 1px; }
  .mushaf-folio-end strong { width: 34px; height: 34px; }
  .mushaf-reading-hint { display: none; }
  .page-reader-bottom { width: calc(100% - 20px); bottom: 7px; margin: 7px 10px 0; overflow: hidden; }
  .page-reader-bottom span { display: none; }
  .page-reader-bottom button { min-width: 0; flex: 1; padding-inline: 5px; font-size: 10px; white-space: nowrap; }
}

@media (max-width: 390px) {
  .mushaf-reader-top .back-link { font-size: 12px; }
  .reading-preferences button { min-width: 34px; padding-inline: 6px; }
  .mushaf-page { padding-inline: 18px; }
  .mushaf-arabic { font-size: clamp(24px, var(--mushaf-text-size), 30px); line-height: 2.12; }
}

/* Mobile reading mode keeps every Quran line visible and scrollable. */
@media (max-width: 750px) {
  .mushaf-reading body { padding-bottom: 0; }
  .mushaf-reading .mobile-tabbar { display: none; }
  .mushaf-reading #page-reader-panel {
    --mushaf-text-size: clamp(28px, 7.7vw, 31px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  .mushaf-book-stage {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .mushaf-cover,
  .mushaf-leaf {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .mushaf-page {
    height: auto;
    min-height: calc(100dvh - 210px);
    overflow: visible;
    padding-bottom: 22px;
  }
  .mushaf-arabic {
    font-size: var(--mushaf-text-size);
    line-height: 2.05;
    text-align: right;
    text-align-last: right;
  }
  .mushaf-folio-end { margin-top: 18px; padding-bottom: 8px; }
  .mushaf-reading-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 10px 16px 3px;
    color: #67766f;
    font-size: 10px;
    font-weight: 750;
    text-align: center;
  }
  .mushaf-reading-hint span { color: #aa8735; font-size: 14px; }
  .page-reader-bottom { flex: 0 0 auto; margin-bottom: 12px; }
  .mushaf-font-small { --mushaf-text-size: 25px !important; }
  .mushaf-font-large { --mushaf-text-size: 35px !important; }
}

@media (max-width: 390px) {
  .mushaf-reading #page-reader-panel { --mushaf-text-size: 29px; }
  .mushaf-page { padding: 14px 17px 22px; }
  .mushaf-arabic { line-height: 2.08; }
}
