@font-face { font-family: 'Plex Arabic'; src: url(../fonts/IBMPlexSansArabic-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url(../fonts/IBMPlexSansArabic-SemiBold.ttf) format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Amiri Quran'; src: url(../fonts/AmiriQuran-Regular.ttf) format('truetype'); font-display: block; }

:root {
  --bg: #F1F3EE;
  --surface: #FFFFFF;
  --ink: #1C2A24;
  --ink-2: #5B6B63;
  --line: #DCE2DA;
  --green: #1E6B52;
  --green-ink: #1E6B52;
  --on-green: #FFFFFF;
  --gold: #B48A2C;
  --paper: #FBF6E8;
  --paper-ink: #1F1A12;
  --paper-rule: #E7DCBF;
  --hl: #F1DFA9;
  --red: #B4483A;
  --red-soft: #F7E5E1;
  --amber-soft: #FBF0D9;
  --green-soft: #E3EFE9;
  --r-s: 10px;
  --r-l: 18px;
  --fs-s: 14px;
  --fs: 17px;
  --fs-l: 21px;
  --fs-xl: 28px;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1714; --surface: #18221E; --ink: #E6ECE8; --ink-2: #9DAFA6; --line: #2A3732;
    --green: #2E8A6A; --green-ink: #6CC3A0; --gold: #D4AE57;
    --paper: #1D2520; --paper-ink: #EDE5D0; --paper-rule: #34413A; --hl: rgba(212, 174, 87, .28);
    --red: #E07B6C; --red-soft: rgba(224, 123, 108, .14); --amber-soft: rgba(212, 174, 87, .14); --green-soft: rgba(46, 138, 106, .18);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs)/1.6 'Plex Arabic', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--green-ink); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: 0 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
.app.no-tabs { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- headings and text */
.top { padding: calc(20px + env(safe-area-inset-top)) 0 12px; display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: var(--fs-xl); font-weight: 600; line-height: 1.25; margin: 0; flex: 1; }
.top .back { border: 0; background: none; padding: 8px; margin: -8px; font-size: 24px; line-height: 1; color: var(--green-ink); cursor: pointer; }
.sub { color: var(--ink-2); margin: 0 0 4px; }
.small { font-size: var(--fs-s); color: var(--ink-2); }
h2.sec { font-size: var(--fs-s); font-weight: 600; color: var(--ink-2); margin: 28px 4px 8px; }
p { margin: 0 0 12px; }

/* ---------------------------------------------------------------- lists */
.group { background: var(--surface); border-radius: var(--r-l); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 60px;
  border: 0; border-top: 1px solid var(--line); background: none; width: 100%; text-align: start; cursor: pointer;
}
.row:first-child { border-top: 0; }
a.row { color: inherit; text-decoration: none; }
.row:disabled { cursor: default; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .d { font-size: var(--fs-s); color: var(--ink-2); }
.row .chev { color: var(--ink-2); font-size: 20px; }
.row.done .t { color: var(--ink-2); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--line); }
.row .tick { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--line); }
.row.done .tick { background: var(--green); border-color: var(--green); color: var(--on-green); }
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); margin-inline-start: 6px; white-space: nowrap; }
.tag.late { background: var(--red-soft); color: var(--red); }
.tag.gold { background: var(--amber-soft); color: var(--gold); }

/* ---------------------------------------------------------------- notices and the estimate */
.estimate { padding: 4px 4px 0; font-size: var(--fs-l); line-height: 1.55; }
.estimate b { color: var(--green-ink); font-weight: 600; }
.notice { border-radius: var(--r-l); padding: 14px 16px; margin: 12px 0; background: var(--green-soft); }
.notice.warn { background: var(--amber-soft); }
.notice.bad { background: var(--red-soft); }
.notice .t { font-weight: 600; display: block; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); }

/* ---------------------------------------------------------------- buttons and forms */
.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 600; cursor: pointer;
  background: var(--green); color: var(--on-green); text-align: center; text-decoration: none;
}
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.quiet { background: var(--surface); color: var(--green-ink); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn + .btn { margin-top: 10px; }
.linkbtn { border: 0; background: none; color: var(--green-ink); padding: 8px 0; cursor: pointer; font-weight: 600; }
.dock {
  position: fixed; inset-inline: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5;
}
.dock > * { max-width: 528px; margin-inline: auto; }
.field { display: block; margin: 0 0 14px; }
.field span { display: block; font-size: var(--fs-s); color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: var(--surface);
}
.field input[type=email], .field input[type=password] { direction: ltr; text-align: right; }
.err { color: var(--red); font-size: var(--fs-s); min-height: 1.6em; }

.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.choice:first-child { border-top: 0; }
.choice input { margin-top: 6px; accent-color: var(--green); width: 20px; height: 20px; flex: none; }
.choice .t { font-weight: 600; }
.choice .d { font-size: var(--fs-s); color: var(--ink-2); }
.choice .note { color: var(--gold); font-size: var(--fs-s); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 18px 0; }
.stepper button { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--surface); font-size: 28px; cursor: pointer; color: var(--green-ink); }
.stepper output { font-size: 48px; font-weight: 600; min-width: 64px; text-align: center; }

/* ---------------------------------------------------------------- the mushaf */
.mushaf-wrap { position: relative; border-radius: 6px; margin: 8px -4px 0; }
.mpage {
  background: var(--paper); color: var(--paper-ink); container-type: inline-size;
  padding: 18px 14px 10px; border-radius: 6px; margin-bottom: 12px;
  box-shadow: inset 0 0 0 1px var(--paper-rule), inset 0 0 0 5px var(--paper), inset 0 0 0 6px var(--paper-rule);
  font-family: 'Amiri Quran', serif;
}
.mline { display: flex; justify-content: space-between; align-items: baseline; font-size: 5.2cqw; line-height: 2.15; white-space: nowrap; }
.mushaf-wrap { overflow-x: clip; }
.mpage-short .mline { justify-content: center; gap: .35em; }
.mhead {
  justify-content: center; font-family: 'Plex Arabic', sans-serif; font-size: 4.2cqw; font-weight: 600;
  border: 1px solid var(--paper-rule); border-radius: 4px; margin: 6px 4px; line-height: 2; color: var(--gold);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 10%, transparent), transparent);
}
.mbasmala { justify-content: center; }
.w { border-radius: 3px; padding: 0 .04em; transition: background-color .2s; }
.w.hl { background: var(--hl); }
.ayah-no {
  display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 .12em; margin-inline-start: .14em;
  border: 1px solid color-mix(in srgb, var(--gold) 70%, transparent); border-radius: 999px; vertical-align: .05em;
  font-family: 'Plex Arabic', sans-serif; font-size: .5em; line-height: 1; color: var(--gold);
}
.w.mk { text-decoration: underline wavy var(--red) 2px; text-underline-offset: .32em; }
.w.mk2 { background: var(--red-soft); }
.mpage-no { text-align: center; font-family: 'Plex Arabic', sans-serif; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.marking .w.hl { cursor: pointer; }
.marking .w.hl:active { background: var(--red-soft); }
.dimmed .w:not(.hl) { opacity: .38; }

/* the closed mushaf: a cover slides over the page while reciting from memory */
.cover {
  position: absolute; inset: 0; border-radius: 6px; z-index: 3; display: grid; place-items: center; text-align: center; padding: 24px;
  color: #F6EBCB; background-color: #1E5A46;
  background-image:
    radial-gradient(circle at 50% 50%, transparent 0 9px, rgba(212, 174, 87, .16) 9.5px 10.5px, transparent 11px),
    conic-gradient(from 45deg, rgba(255, 255, 255, .035) 25%, transparent 0 50%, rgba(255, 255, 255, .035) 0 75%, transparent 0);
  background-size: 36px 36px, 36px 36px;
  box-shadow: inset 0 0 0 8px #1E5A46, inset 0 0 0 9px #C9A04A, inset 0 0 0 14px #1E5A46, inset 0 0 0 15px rgba(201, 160, 74, .5);
  min-height: 320px;
}
.cover .big { font-size: var(--fs-l); font-weight: 600; display: block; margin-bottom: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .cover.closing { animation: cover-in .55s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes cover-in { from { transform: translateX(104%); } to { transform: none; } }
}
@media (prefers-reduced-motion: reduce) { .cover.closing { animation: fade .2s both; } @keyframes fade { from { opacity: 0; } } }

/* ---------------------------------------------------------------- progress */
.stat { display: flex; align-items: baseline; gap: 10px; padding: 8px 4px 0; }
.stat .n { font-size: 44px; font-weight: 600; line-height: 1.1; }
.juz { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; padding: 16px; direction: rtl; }
.juz div { height: 34px; border-radius: 6px; background: var(--line); position: relative; overflow: hidden; }
.juz div i { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--green); }
.juz div span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink); mix-blend-mode: normal; }
.legend { display: flex; gap: 14px; padding: 0 16px 14px; font-size: var(--fs-s); color: var(--ink-2); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv b { font-weight: 600; }

/* spaced repetition timeline on the welcome screen */
.timeline { position: relative; height: 92px; margin: 22px 4px 8px; }
.timeline .axis { position: absolute; inset-inline: 0; top: 34px; height: 2px; background: var(--line); }
.timeline .dot { position: absolute; top: 28px; width: 14px; height: 14px; margin-inline-start: -7px; border-radius: 50%; background: var(--green); border: 3px solid var(--bg); }
.timeline .lab { position: absolute; top: 56px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.timeline .lab.mid { transform: translateX(50%); }
.dots7 { display: flex; gap: 8px; margin: 12px 4px 4px; }
.dots7 i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.dots7 i.on { background: var(--green); }
.welcome-title { font-size: 34px; font-weight: 600; line-height: 1.2; margin: 0 0 10px; }

/* ---------------------------------------------------------------- tab bar */
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; max-width: 140px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--ink-2); font-size: 13px;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current=page] { color: var(--green-ink); font-weight: 600; }

/* ---------------------------------------------------------------- toast, sheet */
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 520px;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px; text-align: center;
}
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast .25s ease-out both; } @keyframes toast { from { opacity: 0; transform: translateY(8px); } } }
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 20, 16, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow: auto; }
.sheet h3 { margin: 0 0 8px; font-size: var(--fs-l); }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
.table th, .table td { text-align: start; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--ink-2); font-weight: 600; border-top: 0; }
.scroll-x { overflow-x: auto; }
.mt { margin-top: 16px; }
.center { text-align: center; }
