﻿@font-face {
  font-family: "UthmanicHafs";
  src: url("assets/fonts/UthmanicHafs1Ex1Ver12.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

/* Cairo — clear, highly readable Arabic UI font (self-hosted to satisfy the strict
   CSP; variable file covers weights 400–900). Arabic + Latin subsets. */
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/cairo-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/cairo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Accent (red in dark mode, dark green in light mode) and hairline (white
     highlights in dark, dark in light) drive the whole theme via these tokens. */
  /* nooralakhirah: gold - light, not babalhawaej red */
  --accent-rgb: 176, 125, 18;
  --accent: #b07d12;
  --accent-deep: #6b4a07;
  --accent-bright-rgb: 232, 178, 52;
  --hairline-rgb: 255, 255, 255;

  --page: #161616;
  --panel: #020202;
  --ink: #ffffff;
  --muted: #d8d8d8;
  --quiet: #8f8f8f;
  --red: var(--accent);
  --red-deep: var(--accent-deep);
  --field: #101010;
  --line: rgba(var(--hairline-rgb), 0.16);
  --soft-line: rgba(var(--accent-rgb), 0.32);
  --green: #39d98a;
  --yellow: #ffd166;
  --grey: #5b6068;
  --error: #ff9c9c;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #111;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(var(--accent-rgb), 0.13), transparent 28rem),
    linear-gradient(180deg, #1b1b1b 0%, var(--page) 52%, #050505 100%);
  font-family: "Cairo", Tahoma, "Segoe UI", Arial, sans-serif;
  line-height: 1.75;
  overflow-x: hidden;
}

/* Form controls don't inherit fonts by default — force the readable UI font everywhere */
button,
input,
select,
textarea {
  font-family: inherit;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(var(--hairline-rgb), 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--hairline-rgb), 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.65;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(100%, 1000px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 54px 14px;
}

.app-card {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 92px);
  min-height: calc(100dvh - 92px);
  padding: clamp(24px, 4.4vw, 42px) clamp(14px, 3.6vw, 32px);
  border-radius: 28px;
  background: var(--panel);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(var(--hairline-rgb), 0.04);
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb), 0.22), transparent 19rem),
    linear-gradient(180deg, rgba(var(--hairline-rgb), 0.04), transparent 30%);
}

.brand-header,
.screen,
.share-button,
.toast {
  position: relative;
  z-index: 1;
}

.brand-header {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  width: min(100%, 620px);
  margin: 0 auto 24px;
  padding-top: 8px;
}

.brand-copy {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.logo-frame {
  position: relative;
  width: clamp(106px, 24vw, 150px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: visible;
  border: 2px solid rgba(var(--hairline-rgb), 0.12);
  background: #000;
  box-shadow: 0 0 36px rgba(var(--accent-rgb), 0.34);
  isolation: isolate;
  animation: logoHeartbeat 4.2s ease-in-out infinite;
}

.logo-frame::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: inherit;
  border: 2px solid rgba(var(--accent-bright-rgb), 0.34);
  opacity: 0;
  transform: scale(0.9);
  box-shadow: 0 0 22px rgba(var(--accent-bright-rgb), 0.22);
  animation: logoPulseRing 4.2s ease-out infinite;
  z-index: -1;
}

.logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 6vw, 3.1rem);
  line-height: 1.1;
}

.brand-host,
.brand-service,
.brand-code,
.brand-dedication {
  margin: 0;
  font-weight: 900;
}

.brand-host {
  color: var(--ink);
  font-size: clamp(1.02rem, 4.2vw, 1.32rem);
  line-height: 1.45;
}

.brand-service {
  color: var(--ink);
  font-size: clamp(1.12rem, 4.6vw, 1.62rem);
  line-height: 1.45;
}

.brand-identity {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: min(100%, 330px);
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.46);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(var(--hairline-rgb), 0.035), transparent),
    rgba(5, 5, 5, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.04),
    0 14px 30px rgba(0, 0, 0, 0.22);
}

.brand-identity[hidden] {
  display: none;
}

.brand-code-label {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.2;
}

.brand-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 190px);
  min-height: 38px;
  padding: 6px 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.54);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(var(--accent-rgb), 0.16);
  cursor: pointer;
  direction: ltr;
  font-family: "Cairo", Tahoma, "Segoe UI", Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(1.02rem, 4vw, 1.24rem);
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(var(--hairline-rgb), 0.06);
}

.brand-code:hover {
  color: #ffdede;
  border-color: rgba(var(--accent-bright-rgb), 0.78);
  background: rgba(var(--accent-rgb), 0.22);
}

.brand-code bdi {
  direction: ltr;
  unicode-bidi: isolate;
}

.brand-dedication {
  color: var(--ink);
  font-size: clamp(1rem, 4vw, 1.22rem);
  line-height: 1.45;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(1.35rem, 4.4vw, 2.2rem);
  line-height: 1.25;
}

.screen {
  display: none;
  width: min(100%, 620px);
  margin: 0 auto;
}

#khatma-screen {
  width: min(100%, 680px);
}

#reader-screen {
  width: min(100%, 900px);
}

.screen.is-active {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.screen-head {
  text-align: center;
  margin: 22px auto 22px;
}

.screen-head.compact {
  margin-top: 10px;
}

.screen-head p,
.progress-text {
  color: var(--muted);
  margin-bottom: 0;
}

.stacked-form {
  display: grid;
  gap: 13px;
  padding: clamp(18px, 4vw, 26px);
  border: 1px solid rgba(var(--accent-rgb), 0.52);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(var(--hairline-rgb), 0.035), transparent),
    rgba(8, 8, 8, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.04),
    0 18px 50px rgba(0, 0, 0, 0.3);
}

.field-label {
  color: var(--muted);
  text-align: center;
  font-size: 0.94rem;
  font-weight: 900;
}

.text-input,
.select-button {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: var(--field);
  padding: 12px 14px;
  text-align: center;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(var(--hairline-rgb), 0.035);
}

.text-input:focus,
.select-button:focus-visible {
  border-color: rgba(var(--accent-rgb), 0.8);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}

.code-input {
  direction: ltr;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 900;
}

.kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* `.select-button` is a 30px | 1fr | 30px grid built for a label + chevron, and
   it is declared AFTER this block — so a card must out-specify it or its text
   lands in the 30px column and reads ragged. `.kind-grid .kind-card` wins. */
.kind-grid .kind-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.35;
  padding: 14px 10px;
  min-height: 62px;
  font-weight: 900;
}

/* the chosen one is outlined, never filled: a filled card reads as a pressed
   button and this row is a CHOICE, not an action */
/* the fifth card has no partner, so it takes the row */
.kind-grid .kind-wide {
  grid-column: 1 / -1;
}

.kind-grid .kind-card.is-selected {
  border-color: rgba(var(--accent-rgb), 0.9);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.9);
  color: var(--ink);
}

[data-kind-field][hidden] {
  display: none;
}

.title-picker {
  position: relative;
}

.select-button {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 900;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--field);
  box-shadow: none;
}

.select-button span:first-child {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.chevron {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  place-self: center;
  margin: 0;
}

.chevron::before {
  content: "";
  display: block;
  width: 13px;
  height: 13px;
  margin: 0;
  border-right: 3px solid var(--muted);
  border-bottom: 3px solid var(--muted);
  transform: translateY(-3px) rotate(45deg);
}

.select-panel {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: calc(100% + 8px);
  border: 1px solid rgba(var(--accent-rgb), 0.55);
  border-radius: 18px;
  background: #0b0b0b;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.option-list {
  display: grid;
  gap: 5px;
  padding: 7px;
}

.title-option {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-align: center;
}

.title-option:hover,
.title-option.is-selected {
  background: rgba(var(--accent-rgb), 0.22);
  box-shadow: none;
}

.verify-box {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 62px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background:
    linear-gradient(#050505, #050505) padding-box,
    linear-gradient(100deg, rgba(var(--hairline-rgb), 0.1), rgba(var(--accent-rgb), 0.32), rgba(var(--hairline-rgb), 0.08)) border-box;
  padding: 10px 18px;
  cursor: pointer;
  text-align: start;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    inset 0 -6px 0 rgba(var(--accent-rgb), 0.1),
    0 12px 26px rgba(0, 0, 0, 0.22);
}

.verify-check {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(var(--hairline-rgb), 0.28);
  border-radius: 8px;
}

.verify-box.is-verified {
  background:
    linear-gradient(#06130d, #050b08) padding-box,
    linear-gradient(100deg, rgba(116, 227, 176, 0.72), rgba(var(--accent-rgb), 0.22), rgba(116, 227, 176, 0.42)) border-box;
  color: #eafff4;
}

.verify-box.is-verified .verify-check {
  border-color: var(--green);
  background: rgba(57, 217, 138, 0.18);
}

.verify-box.is-verified .verify-check::before {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 3px solid var(--green);
  border-bottom: 3px solid var(--green);
  transform: rotate(-45deg);
}

.turnstile-wrap {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.uses-turnstile .verify-box {
  display: none;
}

body:not(.uses-turnstile) .turnstile-wrap {
  display: none;
}

.primary-button,
.secondary-button,
.back-button,
.pager-button,
.status-button,
.reader-back-bottom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-inline: 18px;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  text-align: center;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.primary-button,
.secondary-button,
.pager-button,
.reader-back-bottom,
.status-button {
  width: 100%;
  min-height: 58px;
  border-radius: 999px;
  font-size: 1.02rem;
  line-height: 1.2;
}

.primary-button {
  min-height: 58px;
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.16),
    0 12px 26px rgba(var(--accent-rgb), 0.22);
}

.secondary-button,
.pager-button,
.reader-back-bottom,
.status-button {
  background: #050505;
  border: 1px solid rgba(var(--accent-rgb), 0.72);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    0 10px 22px rgba(0, 0, 0, 0.24);
}

.create-khatma-button {
  min-height: 58px;
  color: #fff;
  background: #050505;
  border-color: rgba(var(--accent-rgb), 0.82);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    0 12px 26px rgba(0, 0, 0, 0.24),
    0 0 24px rgba(var(--accent-rgb), 0.08);
}

.create-khatma-button:hover {
  background: #0b0506;
  border-color: rgba(var(--accent-bright-rgb), 0.95);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 14px 30px rgba(var(--accent-rgb), 0.16);
}

.secondary-button:hover,
.pager-button:hover,
.reader-back-bottom:hover,
.status-button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-bright-rgb), 0.82);
  background: #0a0a0a;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 26px rgba(var(--accent-rgb), 0.12);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.18),
    0 16px 32px rgba(var(--accent-rgb), 0.26);
}

.back-button {
  justify-self: end;
  min-height: 42px;
  width: auto;
  padding: 8px 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.62);
  border-radius: 999px;
  background: #070707;
  box-shadow: none;
}

.top-back-button {
  position: absolute;
  top: clamp(20px, 4vw, 30px);
  right: clamp(14px, 3vw, 24px);
  z-index: 4;
}

.site-back-button {
  position: absolute;
  top: clamp(20px, 4vw, 30px);
  right: clamp(14px, 3vw, 24px);
  z-index: 4;
  text-decoration: none;
}

.site-back-button {
  display: none;
}

body[data-screen="create"] .site-back-button {
  display: inline-flex;
}

.top-back-button[hidden] {
  display: none;
}

.back-button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-bright-rgb), 0.72);
  background: #0b0b0b;
  box-shadow: 0 10px 22px rgba(var(--accent-rgb), 0.14);
}

/* Icon-only buttons (home / back arrow): compact circle, icon follows the themed text color */
.icon-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  color: var(--ink);
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 26px 0;
  color: var(--quiet);
  font-weight: 900;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.68), transparent);
}

.message {
  min-height: 24px;
  margin: 0;
  color: var(--error);
  text-align: center;
  font-weight: 800;
}

.khatma-top,
.reader-top {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  margin-top: 8px;
}

.khatma-meta {
  min-width: 0;
}

.khatma-progress-box,
.khatma-stats,
.parts-box {
  border: 1px solid rgba(var(--hairline-rgb), 0.58);
  border-radius: 20px;
  background: rgba(var(--hairline-rgb), 0.035);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.khatma-progress-box {
  margin-top: 14px;
  padding: 14px 16px 16px;
}

.khatma-stats[hidden] + .khatma-progress-box {
  margin-top: 0;
}

.khatma-progress-box .khatma-top {
  margin-top: 0;
}

.khatma-progress-box .progress-text {
  color: var(--ink);
}

.khatma-progress-line {
  display: grid;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.khatma-progress-line span:first-child {
  direction: rtl;
  color: rgba(var(--hairline-rgb), 0.82);
  font-size: 0.95rem;
  font-weight: 800;
}

.khatma-progress-line #khatma-progress {
  direction: ltr;
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 800;
}

.parts-box {
  margin-top: 14px;
  padding: 12px;
}

.khatma-code {
  display: inline-flex;
  direction: ltr;
  margin-bottom: 8px;
  color: #ffdede;
  font-weight: 900;
  letter-spacing: 0;
}

.reader-top .progress-text {
  color: var(--ink);
}

.reader-top {
  width: min(75%, 270px);
  margin: 8px auto 0;
  padding: 10px 16px 12px;
  border: 1px solid rgba(var(--hairline-rgb), 0.58);
  border-radius: 18px;
  background: rgba(var(--hairline-rgb), 0.035);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.reader-top h2 {
  margin: 0;
  line-height: 1.25;
}

.reader-top .progress-text {
  margin-top: 2px;
}

.progress-rail {
  position: relative;
  height: 13px;
  overflow: hidden;
  margin: 14px 0 0;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(var(--hairline-rgb), 0.05), transparent 42%),
    linear-gradient(180deg, #111, #070707);
  box-shadow:
    inset 0 1px 5px rgba(0, 0, 0, 0.88),
    inset 0 -1px 0 rgba(var(--hairline-rgb), 0.04),
    0 0 0 1px rgba(var(--hairline-rgb), 0.09);
}

.progress-rail-fill {
  position: absolute;
  inset-block: 0;
  right: 0;
  display: block;
  width: 0%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  border-radius: 999px;
  background: linear-gradient(90deg, #137947 0%, #1ca662 42%, #38d889 100%);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.2),
    0 0 12px rgba(57, 217, 138, 0.2);
  transition: width 680ms cubic-bezier(0.2, 0.86, 0.22, 1);
}

.progress-rail-fill.reading {
  z-index: 2;
  background: linear-gradient(90deg, #f8d247 0%, #dfad18 56%, #a76d04 100%);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.28),
    0 0 10px rgba(255, 202, 55, 0.24);
  transition:
    right 680ms cubic-bezier(0.2, 0.86, 0.22, 1),
    width 680ms cubic-bezier(0.2, 0.86, 0.22, 1);
}

.progress-rail.has-reading .progress-rail-fill.completed {
  border-radius: 0 999px 999px 0;
}

.progress-rail.has-completed .progress-rail-fill.reading {
  border-radius: 999px 0 0 999px;
}

.progress-rail.only-completed .progress-rail-fill.completed,
.progress-rail.only-reading .progress-rail-fill.reading {
  border-radius: 999px;
}

.progress-rail-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(var(--hairline-rgb), 0.32) 48%, transparent 100%);
  opacity: 0.38;
  transform: translateX(120%);
  animation: progressSweep 2.4s ease-in-out infinite;
}

.khatma-deadline {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 14px 0 0;
  color: var(--ink);
  text-align: center;
  font-weight: 900;
  line-height: 1.35;
}

.khatma-deadline[hidden] {
  display: none;
}

.khatma-deadline span {
  color: rgba(var(--hairline-rgb), 0.76);
  font-size: 0.92rem;
  font-weight: 800;
}

.khatma-deadline strong {
  color: var(--ink);
  font-size: 1.08rem;
}

.finish-khatma-button {
  width: 100%;
  min-height: 60px;
  margin-top: 16px;
  border: 1.5px solid rgba(var(--accent-rgb), 0.72);
  border-radius: 20px;
  color: var(--ink);
  background: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    0 12px 26px rgba(0, 0, 0, 0.2);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.finish-khatma-button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-bright-rgb), 0.9);
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 14px 28px rgba(var(--accent-rgb), 0.16);
}

.finish-khatma-button.is-closed {
  cursor: default;
  color: var(--ink);
  background: #2b1f07;
  opacity: 0.8;
}

.finish-khatma-button[hidden] {
  display: none;
}

.khatma-stats {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
}

.khatma-stats[hidden] {
  display: none;
}

.khatma-stats h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.25;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(104px, max-content) minmax(0, 1fr);
  gap: 10px 14px;
  align-items: center;
  direction: rtl;
}

.stats-grid span,
.stats-grid strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.35;
}

.stats-grid span {
  grid-column: 1;
  color: rgba(var(--hairline-rgb), 0.76);
  text-align: right;
  white-space: nowrap;
}

.stats-grid strong {
  grid-column: 2;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.part-button {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  border: 1.5px solid transparent;
  border-radius: 20px;
  color: var(--ink);
  background: #090909;
  border-color: rgba(var(--hairline-rgb), 0.12);
  cursor: pointer;
  font-weight: 900;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    0 12px 26px rgba(0, 0, 0, 0.2);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.part-button::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--hairline-rgb), 0.055), transparent 72%);
}

.part-button:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.54);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 14px 28px rgba(var(--accent-rgb), 0.12);
}

.part-title,
.part-status,
.part-pages {
  position: relative;
  z-index: 1;
}

.part-title {
  font-size: 1.08rem;
  line-height: 1.2;
  white-space: nowrap;
}

/* Surah names are long and vary in length — let them wrap and shrink so they
   never clip inside the fixed-width part card. */
.part-button.mode-surah .part-title {
  white-space: normal;
  overflow-wrap: break-word;
  font-size: clamp(0.84rem, 3vw, 1.02rem);
  line-height: 1.15;
}

.part-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  color: rgba(var(--hairline-rgb), 0.94);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(var(--hairline-rgb), 0.08);
  font-size: 0.88rem;
  line-height: 1.1;
}

.part-button .part-pages {
  direction: ltr;
  color: rgba(var(--hairline-rgb), 0.8);
  font-size: 0.84rem;
}

.part-button.not-started {
  background: #0c0d0f;
  border-color: rgba(128, 133, 142, 0.36);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.07),
    0 12px 24px rgba(0, 0, 0, 0.18);
}

.part-button.in-progress {
  background: #241a06;
  border-color: rgba(255, 209, 102, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.12),
    0 12px 28px rgba(255, 209, 102, 0.08);
}

.part-button.completed {
  background: #042814;
  border-color: rgba(57, 217, 138, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.12),
    0 12px 28px rgba(57, 217, 138, 0.08);
}

.part-button.not-started .part-status {
  color: #f2f2f2;
  background: rgba(var(--hairline-rgb), 0.08);
}

.part-button.in-progress .part-status {
  color: #fff4c6;
  background: rgba(255, 209, 102, 0.14);
}

.part-button.completed .part-status {
  color: #eafff4;
  background: rgba(57, 217, 138, 0.14);
}

.part-button:disabled {
  cursor: default;
  transform: none;
}

.part-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 8px;
}

.part-actions.part-actions-secondary {
  margin: 0 0 14px;
}

.status-button {
  min-height: 56px;
  color: var(--ink);
}

.status-button.reset {
  background: #0c0d0f;
  border-color: rgba(128, 133, 142, 0.5);
}

.status-button.progress {
  background: #241a06;
  border-color: rgba(255, 209, 102, 0.76);
}

.status-button.done {
  background: #042814;
  border-color: rgba(57, 217, 138, 0.72);
}

.rename-reader-button {
  display: block;
  width: 100%;
  min-height: 46px;
  margin: 0 0 14px;
  padding: 10px 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(var(--accent-rgb), 0.14);
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.98rem;
}

.rename-reader-button:hover {
  border-color: rgba(var(--accent-bright-rgb), 0.78);
  background: rgba(var(--accent-rgb), 0.2);
}

.rename-reader-button[hidden] {
  display: none;
}

.reader-name {
  position: absolute;
  top: clamp(20px, 4vw, 30px);
  left: 102px;
  right: 102px;
  z-index: 4;
  height: 42px;
  line-height: 42px;
  margin: 0;
  padding: 0 4px;
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(1rem, 3vw, 1.45rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.reader-name:empty {
  display: none;
}

.part-reader {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(var(--hairline-rgb), 0.12);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.25;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-share-button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 220px);
  min-height: 44px;
  padding: 8px 22px;
  border: 1px solid rgba(var(--accent-rgb), 0.9);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(1.02rem, 4vw, 1.2rem);
  line-height: 1;
  box-shadow: 0 0 34px rgba(var(--accent-rgb), 0.28);
  animation: logoHeartbeat 4.2s ease-in-out infinite;
}

.brand-share-button::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(var(--accent-bright-rgb), 0.34);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9);
  box-shadow: 0 0 22px rgba(var(--accent-bright-rgb), 0.22);
  animation: logoPulseRing 4.2s ease-out infinite;
  z-index: -1;
}

.brand-share-button:hover {
  filter: brightness(1.08);
}

/* "خدمات اخرى" link — identical look to the share button, shown ONLY on the khatma parts page */
#brand-other-services {
  display: none;
  margin-top: 12px;
  text-decoration: none;
}
body[data-screen="khatma"] #brand-other-services {
  display: inline-flex;
}

.screen-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.verify-lead {
  margin: 8px 0 18px;
  color: var(--ink);
  font-size: clamp(1.05rem, 4.4vw, 1.35rem);
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
}

.quran-panel {
  margin: 12px calc(-1 * clamp(14px, 3.6vw, 32px)) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.pager-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(var(--hairline-rgb), 0.58);
  border-radius: 20px;
  background: rgba(var(--hairline-rgb), 0.035);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.page-badge {
  display: grid;
  align-items: center;
  justify-content: center;
  margin: 2px 0 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  text-align: center;
}

.pager-meta {
  display: grid;
  justify-items: center;
  text-align: center;
}

.pager-meta strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.25;
}

.quran-content {
  min-height: 0;
  overflow: visible;
  border-radius: 0;
  background: #fae8bf;
  color: #17110d;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 70px 0 64px;
  text-align: center;
  text-align-last: center;
  font-family: "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  font-feature-settings: "kern" 1, "liga" 1;
  box-shadow:
    inset 0 0 42px rgba(129, 79, 34, 0.07),
    0 24px 48px rgba(0, 0, 0, 0.22);
}

.quran-flow-sheet {
  --mushaf-page-font: "UthmanicHafs";
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px;
  color: #050403;
  direction: rtl;
  font-family: var(--mushaf-page-font), "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  animation: quran-page-in 180ms ease-out both;
}

.quran-flow-surah {
  margin: 52px 0 58px;
  color: #050403;
  font-family: var(--mushaf-page-font), "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  font-size: 2.85rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-align-last: center;
}

.quran-flow-sheet > .quran-flow-surah:first-child {
  margin-top: 0;
}

.quran-flow-basmala {
  margin: -14px 0 38px;
  color: #050403;
  font-family: var(--mushaf-page-font), "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  font-size: 2.35rem;
  font-weight: 400;
  line-height: 1.55;
  text-align: center;
  text-align-last: center;
}

.quran-flow {
  color: #050403;
  direction: rtl;
  font-family: var(--mushaf-page-font), "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  font-size: 2.28rem;
  font-weight: 400;
  line-height: 2.18;
  text-align: justify;
  text-align-last: center;
  white-space: normal;
  word-spacing: 0.04em;
}

.quran-ayah {
  display: inline;
}

.mushaf-sheet {
  --mushaf-page-font: "UthmanicHafs";
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4.5vw, 52px);
}

.mushaf-page-marker {
  display: grid;
  gap: 9px;
  align-items: center;
  justify-items: center;
  margin: clamp(32px, 6vw, 64px) auto 0;
  color: #060403;
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  font-weight: 700;
  line-height: 1;
  direction: ltr;
}

.mushaf-page-marker::before,
.mushaf-page-marker::after {
  content: "";
  width: min(100%, 735px);
  border-top: 1px solid rgba(44, 37, 27, 0.64);
}

.mushaf-lines {
  display: grid;
  gap: clamp(20px, 4vw, 38px);
  align-items: center;
  justify-items: center;
}

.mushaf-line,
.mushaf-basmala,
.mushaf-surah-title {
  width: 100%;
  font-family: var(--mushaf-page-font), "UthmanicHafs", "Traditional Arabic", "Amiri", "Scheherazade New", serif;
  text-align: center;
  text-align-last: center;
}

.mushaf-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  gap: clamp(0.14em, 0.42vw, 0.3em);
  direction: rtl;
  color: #060403;
  font-size: clamp(1.65rem, 4.9vw, 2.85rem);
  font-weight: 400;
  line-height: 1.95;
  white-space: nowrap;
  word-spacing: 0;
}

.mushaf-word {
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
}

.mushaf-sheet[data-density="short"] .mushaf-lines {
  gap: clamp(28px, 5vw, 48px);
}

.mushaf-sheet[data-density="short"] .mushaf-line {
  font-size: clamp(2rem, 6vw, 3.18rem);
  line-height: 2.05;
}

.mushaf-sheet[data-density="dense"] .mushaf-lines {
  gap: clamp(12px, 2.4vw, 24px);
}

.mushaf-sheet[data-density="dense"] .mushaf-line {
  font-size: clamp(1.18rem, 3vw, 1.74rem);
  line-height: 1.86;
}

.mushaf-surah-title {
  margin-top: 4px;
  margin-bottom: clamp(8px, 2vw, 18px);
  color: #050403;
  font-size: clamp(2.05rem, 5.7vw, 3.15rem);
  font-weight: 800;
  line-height: 1.5;
}

.mushaf-basmala {
  margin-bottom: clamp(4px, 1.3vw, 12px);
  color: #050403;
  font-size: clamp(1.45rem, 4.2vw, 2.08rem);
  font-weight: 500;
  line-height: 1.9;
}

.verse {
  display: inline;
}

.verse-key {
  display: inline-block;
  flex: 0 0 auto;
  margin: 0 0.08em;
  color: inherit;
  font-family: var(--mushaf-page-font), "Segoe UI Symbol", "Times New Roman", serif;
  font-size: 1em;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  direction: rtl;
  unicode-bidi: isolate;
  vertical-align: -0.1em;
  word-spacing: 0;
}

.loading-text,
.source-note {
  color: #6d6256;
  text-align: center;
  text-align-last: center;
  font-family: "Cairo", Tahoma, sans-serif;
  font-size: 1rem;
  line-height: 1.8;
}

.quran-preload {
  min-height: clamp(360px, 68vh, 720px);
  display: grid;
  place-content: center;
  justify-items: center;
  direction: ltr;
}

.quran-progress-ring {
  --progress: 0;
  position: relative;
  width: clamp(96px, 18vw, 138px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #fae8bf 0 58%, transparent 59%),
    conic-gradient(#17110d calc(var(--progress) * 1%), rgba(23, 17, 13, 0.16) 0);
  box-shadow:
    inset 0 0 0 1px rgba(23, 17, 13, 0.18),
    0 14px 28px rgba(23, 17, 13, 0.12);
  transition: background 160ms ease;
}

.quran-progress-ring::before {
  content: "";
  position: absolute;
  width: calc(100% - 18px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(23, 17, 13, 0.16);
}

.quran-progress-ring span {
  position: relative;
  font-family: "Cairo", Tahoma, Verdana, sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.28rem);
  font-weight: 700;
  color: #17110d;
}

@keyframes quran-page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .quran-flow-sheet {
    animation: none;
  }
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}

.pager-button {
  border-color: rgba(var(--hairline-rgb), 0.58);
  background: #050505;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.06),
    0 10px 22px rgba(0, 0, 0, 0.24);
}

.pager-button:hover {
  border-color: rgba(var(--hairline-rgb), 0.8);
  background: #090909;
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 24px rgba(var(--hairline-rgb), 0.06);
}

.complete-part-button {
  margin: 0;
  background: #042814;
  border-color: rgba(57, 217, 138, 0.72);
  color: #eafff4;
}

.complete-part-button:hover {
  background: #06361c;
  border-color: rgba(57, 217, 138, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08),
    0 12px 24px rgba(57, 217, 138, 0.1);
}

.pager-button[hidden] {
  display: none;
}

#prev-page[hidden] + #next-page {
  grid-column: 1 / -1;
}

.pager-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.reader-back-bottom {
  margin-top: 10px;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(100%, 360px);
  padding: 22px;
  border: 1px solid rgba(var(--hairline-rgb), 0.2);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(26, 19, 6, 0.98), rgba(2, 2, 2, 0.98)),
    #050505;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(var(--hairline-rgb), 0.08);
  color: var(--ink);
  text-align: center;
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 900;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.7;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.confirm-button {
  min-height: 48px;
  border: 1px solid rgba(var(--hairline-rgb), 0.26);
  border-radius: 999px;
  color: var(--ink);
  background: #080808;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.confirm-button.secondary {
  border-color: rgba(128, 133, 142, 0.56);
}

.confirm-button.danger {
  border-color: rgba(var(--accent-bright-rgb), 0.78);
  background: #241a06;
  color: #fff2f2;
}

.confirm-button:focus-visible {
  outline: 3px solid rgba(var(--hairline-rgb), 0.45);
  outline-offset: 3px;
}

.share-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  box-shadow: 0 0 34px rgba(var(--accent-rgb), 0.28);
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
  animation: logoHeartbeat 4.2s ease-in-out infinite;
}

.share-button::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px solid rgba(var(--accent-bright-rgb), 0.34);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9);
  box-shadow: 0 0 22px rgba(var(--accent-bright-rgb), 0.22);
  animation: logoPulseRing 4.2s ease-out infinite;
  z-index: -1;
}

.share-button[hidden] {
  display: none;
}

body[data-screen="reader"] .share-button {
  display: none;
}

body[data-screen="reader"] .brand-header {
  display: none;
}

body[data-screen="reader"] #reader-screen {
  padding-top: 56px;
}

body[data-screen="reader"] .part-actions {
  margin-top: 0;
}

.share-button-icon,
.share-button-text {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.share-button-icon {
  animation: shareIconCycle 20s ease-in-out infinite;
}

.share-button-text {
  width: 100%;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  opacity: 0;
  transform: scale(0.82);
  animation: shareTextCycle 20s ease-in-out infinite;
}

.share-button svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes shareIconCycle {
  0%,
  44% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  50%,
  94% {
    opacity: 0;
    transform: scale(0.82) rotate(-8deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes shareTextCycle {
  0%,
  44% {
    opacity: 0;
    transform: scale(0.82);
  }

  50%,
  94% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(0.82);
  }
}

.toast {
  position: fixed;
  inset-inline: 18px;
  bottom: 92px;
  width: fit-content;
  max-width: calc(100% - 36px);
  margin-inline: auto;
  padding: 10px 16px;
  border: 1px solid rgba(var(--hairline-rgb), 0.12);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(5, 5, 5, 0.94);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
  font-weight: 900;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

@keyframes logoHeartbeat {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 34px rgba(var(--accent-rgb), 0.28);
  }

  46% {
    transform: scale(1.022);
    box-shadow:
      0 0 46px rgba(var(--accent-rgb), 0.44),
      0 0 0 7px rgba(var(--accent-rgb), 0.08);
  }
}

@keyframes logoPulseRing {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }

  20% {
    opacity: 0.55;
  }

  78%,
  100% {
    opacity: 0;
    transform: scale(1.23);
  }
}

@keyframes progressSweep {
  0% {
    transform: translateX(120%);
  }

  52%,
  100% {
    transform: translateX(-120%);
  }
}

@media (max-width: 900px) {
  .quran-panel {
    margin-right: calc(-1 * clamp(14px, 3.6vw, 32px));
    margin-left: calc(-1 * clamp(14px, 3.6vw, 32px));
  }

  .quran-content {
    width: 100%;
    padding: 54px 0 52px;
    box-shadow: inset 0 0 36px rgba(129, 79, 34, 0.07);
  }

  .quran-flow-sheet {
    max-width: 100%;
    padding: 0 22px;
  }

  .quran-flow-surah {
    margin-bottom: 44px;
    font-size: 2.35rem;
  }

  .quran-flow-basmala {
    margin-bottom: 26px;
    font-size: 2rem;
  }

  .quran-flow {
    font-size: 2rem;
    line-height: 2.08;
  }
}

@media (max-width: 430px) {
  .quran-content {
    padding: 44px 0 46px;
  }

  .quran-flow-sheet {
    padding: 0 18px;
  }

  .quran-flow-surah {
    margin-bottom: 34px;
    font-size: 2.18rem;
  }

  .quran-flow-basmala {
    margin-bottom: 22px;
    font-size: 1.9rem;
  }

  .quran-flow {
    font-size: 1.9rem;
    line-height: 2.02;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 0;
  }

  .app-card {
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    padding: 26px 14px 90px;
  }

  .brand-header {
    gap: 10px;
  }

  .parts-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .part-button {
    min-height: 92px;
    border-radius: 16px;
  }
}

@media (max-width: 390px) {
  .parts-grid {
    gap: 8px;
  }

  .part-button {
    min-height: 84px;
  }

  .part-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* ===== Theme toggle — pill switch, top-left of every khatma screen ===== */
.theme-toggle {
  position: absolute;
  top: clamp(20px, 4vw, 30px);
  left: clamp(14px, 3vw, 24px);
  z-index: 5;
  direction: ltr;
  width: 60px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(150, 156, 166, 0.5);
  border-radius: 999px;
  background: rgba(128, 133, 142, 0.22);
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.theme-toggle:hover {
  border-color: rgba(170, 176, 186, 0.75);
}

html[data-theme="light"] .theme-toggle {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.12);
}

.theme-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #80858e;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: left 0.22s ease;
}

.theme-toggle .theme-icon {
  width: 21px;
  height: 21px;
}

.theme-icon-sun {
  display: none;
}

html[data-theme="light"] .theme-knob {
  left: 32px;
  background: var(--accent);
}

html[data-theme="light"] .theme-icon-moon {
  display: none;
}

html[data-theme="light"] .theme-icon-sun {
  display: block;
}

/* ===== Light theme — clean white surfaces, black text, dark Quran green ===== */
html[data-theme="light"] {
  --accent-rgb: 122, 92, 50;
  --accent: #6e5430;
  --accent-deep: #4d3a1f;
  --accent-bright-rgb: 150, 116, 66;
  --gold: #b88420;
  --hairline-rgb: 64, 50, 28;
  --page: #f3ecdc;
  --panel: #ffffff;
  --field: #ffffff;
  --ink: #1c1711;
  --muted: #574d3b;
  --quiet: #8a7d64;
  --green: #0f7a4d;
  --grey: #9a9079;
  --error: #c01a12;
}

html[data-theme="light"] {
  background: #f3ecdc;
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at 50% -8%, rgba(var(--accent-rgb), 0.05), transparent 26rem),
    linear-gradient(180deg, #faf4e6 0%, #f3ecdc 55%, #ece1ca 100%);
}

html[data-theme="light"] .app-card {
  box-shadow:
    0 1px 3px rgba(90, 68, 32, 0.06),
    0 30px 70px rgba(110, 84, 38, 0.12);
}

html[data-theme="light"] .app-card::before {
  background:
    radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb), 0.05), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 24%);
}

html[data-theme="light"] .logo-frame {
  background: #efe4ce;
}

/* white cards with neutral borders + soft shadow */
html[data-theme="light"] .khatma-progress-box,
html[data-theme="light"] .khatma-stats,
html[data-theme="light"] .parts-box,
html[data-theme="light"] .reader-top,
html[data-theme="light"] .brand-identity,
html[data-theme="light"] .stacked-form,
html[data-theme="light"] .confirm-dialog {
  background: #ffffff;
  border-color: rgba(100, 78, 42, 0.16);
  box-shadow:
    0 1px 2px rgba(90, 68, 32, 0.05),
    0 12px 30px rgba(110, 84, 38, 0.1);
}

/* plain surface fills */
html[data-theme="light"] .select-panel,
html[data-theme="light"] .confirm-button,
html[data-theme="light"] .back-button,
html[data-theme="light"] .create-khatma-button,
html[data-theme="light"] .pager-button,
html[data-theme="light"] .status-button,
html[data-theme="light"] .part-button,
html[data-theme="light"] .status-button.reset,
html[data-theme="light"] .part-button.not-started {
  background: #ffffff;
}

/* neutral (not green) borders on buttons + inputs */
html[data-theme="light"] .back-button,
html[data-theme="light"] .pager-button,
html[data-theme="light"] .create-khatma-button,
html[data-theme="light"] .status-button,
html[data-theme="light"] .status-button.reset,
html[data-theme="light"] .part-button,
html[data-theme="light"] .part-button.not-started,
html[data-theme="light"] .confirm-button,
html[data-theme="light"] .text-input,
html[data-theme="light"] .select-button {
  border-color: rgba(100, 78, 42, 0.2);
}

html[data-theme="light"] .create-khatma-button:hover,
html[data-theme="light"] .back-button:hover,
html[data-theme="light"] .pager-button:hover,
html[data-theme="light"] .status-button:hover,
html[data-theme="light"] .part-button:hover {
  background: #faf5ea;
  border-color: rgba(100, 78, 42, 0.32);
}

/* status pills: subtle tints, dark text */
html[data-theme="light"] .part-status {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .part-button.not-started .part-status {
  color: #5a646b;
}

html[data-theme="light"] .part-button.in-progress .part-status {
  color: #946708;
}

html[data-theme="light"] .part-button.completed .part-status {
  color: #0c6b44;
}

html[data-theme="light"] .part-reader {
  color: #2f3a34;
  border-top-color: rgba(22, 40, 32, 0.16);
}

html[data-theme="light"] .part-button.in-progress,
html[data-theme="light"] .status-button.progress {
  background: #fbf0d6;
}

html[data-theme="light"] .part-button.completed,
html[data-theme="light"] .status-button.done,
html[data-theme="light"] .complete-part-button {
  background: #daefdf;
  border-color: rgba(15, 122, 77, 0.55);
}

html[data-theme="light"] .complete-part-button:hover {
  background: #cbe9d2;
  border-color: rgba(15, 122, 77, 0.7);
}

/* brown CTAs need white text; the light-green "done" pager button needs black text */
html[data-theme="light"] .primary-button,
html[data-theme="light"] .finish-khatma-button {
  color: #ffffff;
}

html[data-theme="light"] .complete-part-button {
  color: #16130d;
}

/* "تم القراءة" now reuses the next-page slot inside .pager; this higher-specificity
   rule keeps its green fill above the white .pager-button surface rule. */
html[data-theme="light"] .pager .complete-part-button {
  background: rgb(218, 239, 223);
}

html[data-theme="light"] .pager .complete-part-button:hover {
  background: rgb(203, 233, 210);
}

html[data-theme="light"] .finish-khatma-button.is-closed {
  background: #e7e7e4;
}

html[data-theme="light"] .confirm-button.danger {
  background: #efe4ce;
  border-color: rgba(100, 78, 42, 0.32);
  color: #1c1711;
}

/* Quran reading panel keeps its warm parchment, framed against the white app */
html[data-theme="light"] .quran-content {
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    inset 0 0 42px rgba(129, 79, 34, 0.05),
    0 14px 34px rgba(20, 30, 22, 0.14);
}

/* clean progress bar */
html[data-theme="light"] .progress-rail {
  background: #e6e7e4;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.14),
    0 0 0 1px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .toast {
  background: rgba(45, 34, 22, 0.97);
  color: #fff;
}

html[data-theme="light"] .verify-box {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(100deg, rgba(0, 0, 0, 0.08), rgba(var(--accent-rgb), 0.3), rgba(0, 0, 0, 0.06)) border-box;
}

/* ===== نور الآخرة: the app strip (stores not live yet, so the badges say قريبًا and do nothing) ===== */
.get-app {
  margin: 14px auto 6px;
  max-width: 420px;
  text-align: center;
}
.get-app-lead {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.get-app-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.store-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(var(--hairline-rgb), 0.22);
  background: rgba(var(--hairline-rgb), 0.05);
  color: var(--ink);
  text-decoration: none;
  cursor: default;
}
.store-badge svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.store-badge span {
  display: grid;
  line-height: 1.15;
  text-align: start;
}
.store-badge small {
  font-size: 0.66rem;
  color: var(--quiet);
  font-weight: 700;
}
.store-badge b {
  font-size: 0.9rem;
  direction: ltr;
  unicode-bidi: isolate;
}
/* on the reading screen the strip stays, smaller, so a shared link still shows the stores */
body[data-screen="khatma"] .get-app-lead { display: none; }

/* ===== ختماتي (device list) ===== */
.my-khatmas {
  margin: 4px auto 22px;
  max-width: 560px;
}
.my-khatmas-title {
  margin: 0;
  text-align: center;
  font-size: 1.25rem;
}
.my-khatmas-note {
  margin: 2px 0 10px;
  text-align: center;
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 700;
}
.my-khatmas-list {
  display: grid;
  gap: 8px;
}
.my-khatma {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(var(--accent-rgb), 0.06);
}
.my-khatma-open {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  min-width: 0;
}
.my-khatma-open strong {
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.my-khatma-open span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.my-khatma-forget {
  border: 0;
  border-inline-start: 1px solid rgba(var(--hairline-rgb), 0.12);
  background: transparent;
  color: var(--quiet);
  font-size: 1.3rem;
  cursor: pointer;
}
