/* القرآن الكريم — Ilya dev's. Palette and motif are taken from the bot cover:
   near-black ground, brick red, olive-grey, bone white, and the square-Kufic lattice. */
@font-face { font-family: QuranFont; src: url(../assets/fonts/quran-regular.woff) format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: QuranFont; src: url(../assets/fonts/quran-bold.woff) format("woff"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0c0b0c; --surface: #151314; --surface-2: #1d1a1b; --ink: #efe8d8; --muted: #a59f92; --line: #2f2a2b;
  --red: #b63a38; --red-ink: #fff4ee; --olive: #8c947b; --focus: #e9c46a; --ok: #8fb58a; --bad: #ef8a7d;
  --quran-scale: 1; --radius: 6px; --tabbar: 60px;
  --ui: "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  --quran: QuranFont, "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Traditional Arabic", serif;
  color-scheme: dark;
}
:root[data-theme="light"] { --bg: #f1ece0; --surface: #fbf8f0; --surface-2: #e9e2d1; --ink: #1b1a1a; --muted: #655f55; --line: #d6ccb6; --red: #8f1f20; --red-ink: #fff; --olive: #5d6550; --ok: #3f6d3b; --bad: #a3271f; color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { --bg: #f1ece0; --surface: #fbf8f0; --surface-2: #e9e2d1; --ink: #1b1a1a; --muted: #655f55; --line: #d6ccb6; --red: #8f1f20; --red-ink: #fff; --olive: #5d6550; --ok: #3f6d3b; --bad: #a3271f; color-scheme: light; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.75 var(--ui); min-height: 100vh; display: flex; flex-direction: column; overflow-wrap: anywhere; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; opacity: .07; pointer-events: none; background: var(--olive);
  -webkit-mask: url(../assets/pattern.svg) 0 0 / 48px 48px; mask: url(../assets/pattern.svg) 0 0 / 48px 48px; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.muted { color: var(--muted); }
.skip { position: absolute; inset-inline-start: 1rem; top: -4rem; background: var(--red); color: var(--red-ink); padding: .5rem 1rem; z-index: 100; } .skip:focus { top: .5rem; }
.offline { background: var(--red); color: var(--red-ink); text-align: center; padding: .4rem 1rem; font-size: .9rem; }
.noscript { padding: 2rem; text-align: center; }

/* ---------- header / nav ---------- */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.bar { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font: 700 1.2rem var(--quran); margin-inline-end: auto; }
.brand img { border-radius: 6px; border: 1px solid var(--line); }
.desk { display: none; gap: .25rem; }
.desk a { text-decoration: none; padding: .4rem .8rem; border-radius: var(--radius); color: var(--muted); }
.desk a:hover, .desk a[aria-current] { color: var(--ink); background: var(--surface-2); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: .5rem 0 .4rem; font-size: .72rem; text-decoration: none; color: var(--muted); min-height: var(--tabbar); align-content: center; }
.tabbar a[aria-current] { color: var(--red); } :root[data-theme="dark"] .tabbar a[aria-current], :root:not([data-theme]) .tabbar a[aria-current] { color: #e0615d; }
main { flex: 1; padding-block: 1.5rem 7rem; }
main:focus, main:focus-visible { outline: none; }
input[dir="ltr"].input { text-align: right; }
.foot { border-top: 1px solid var(--line); padding: 1.5rem 0 calc(var(--tabbar) + 1.5rem + env(safe-area-inset-bottom)); color: var(--muted); font-size: .9rem; }
.foot-in { display: grid; gap: .4rem; justify-items: center; text-align: center; }
.foot p { margin: 0; } .foot-links { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; } .foot-links a { text-decoration: none; } .foot-links a:hover { color: var(--ink); text-decoration: underline; }
.credit { display: inline-block; padding: .35rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 5%, transparent); backdrop-filter: blur(8px); text-decoration: none; color: var(--ink); font-weight: 600; }
.credit:hover { border-color: var(--red); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .45rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .95rem var(--ui); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--olive); background: var(--surface-2); }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--red-ink); } .btn.primary:hover:not(:disabled) { filter: brightness(1.12); background: var(--red); }
.btn.ghost { background: transparent; } .btn.ghost.on { color: var(--red); border-color: var(--red); }
.btn.danger { border-color: var(--bad); color: var(--bad); } .btn.icon-only { padding: 0; width: 44px; }
.btn:disabled { opacity: .55; cursor: progress; } .btn.more { margin-top: 1rem; width: 100%; }
.actions { display: flex; gap: .6rem; margin-block: 1rem; } .actions.wrap { flex-wrap: wrap; }
.input, .select { width: 100%; min-height: 46px; padding: .5rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 400 1rem var(--ui); }
.input.big { min-height: 54px; font-size: 1.15rem; } .input:focus, .select:focus { border-color: var(--olive); }
.label { display: block; font-weight: 600; margin-bottom: .35rem; padding: 0; }
.hint { color: var(--muted); font-size: .88rem; margin: .4rem 0 0; }
.status { min-height: 1.5em; font-size: .92rem; margin: .4rem 0 0; } .status.ok { color: var(--ok); } .status.bad { color: var(--bad); }
.chips { display: flex; gap: .4rem; margin-bottom: .6rem; flex-wrap: wrap; }
.chip { min-height: 38px; padding: .2rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 .9rem var(--ui); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: var(--red-ink); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; } .radio, .check { display: flex; align-items: center; gap: .6rem; min-height: 44px; cursor: pointer; }
.radio input, .check input { width: 20px; height: 20px; accent-color: var(--red); }
input[type="range"] { width: 100%; accent-color: var(--red); }
.seg { display: flex; gap: .25rem; margin: 1rem 0; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.seg-btn { flex: 1 0 auto; min-height: 42px; padding: .2rem 1rem; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: var(--radius); font: 600 .92rem var(--ui); cursor: pointer; white-space: nowrap; }
.seg-btn[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.loader { display: grid; justify-items: center; gap: 1rem; padding: 4rem 1rem; color: var(--muted); }
.spinner { width: 30px; height: 30px; border-radius: 3px; border: 2px solid var(--red); transform: rotate(45deg); animation: spin 1.1s linear infinite; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(405deg); } }
.skeleton { height: 7rem; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition: none !important; } }

/* ---------- diamond badge (cover motif) ---------- */
.badge { position: relative; flex: none; width: 2.5rem; height: 2.5rem; display: grid; place-items: center; font: 700 .9rem var(--ui); color: var(--ink); }
.badge::before { content: ""; position: absolute; inset: .42rem; border: 1.5px solid var(--red); transform: rotate(45deg); background: color-mix(in srgb, var(--red) 12%, transparent); }
.badge > span { position: relative; } .badge.big { width: 4rem; height: 4rem; font-size: 1.3rem; } .badge.big::before { inset: .7rem; border-width: 2px; } .badge.sm { width: 2.2rem; height: 2.2rem; font-size: .8rem; }

/* ---------- home ---------- */
.hero { display: grid; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }
.hero-art { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--red); }
.hero-art img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 40rem; }
.hero-search { display: flex; gap: .5rem; margin-block: 1rem; } .hero-search .btn { flex: none; }
.resume { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-inline-start: 3px solid var(--red); background: var(--surface); text-decoration: none; border-radius: var(--radius); }
.resume-k { color: var(--muted); font-size: .9rem; } .resume strong { margin-inline-end: auto; }
.verse { padding: 1.5rem; margin-block: 2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); position: relative; text-align: center; }
.verse h2 { color: var(--olive); font-size: 1rem; letter-spacing: .02em; } .verse .actions { justify-content: center; flex-wrap: wrap; }
.verse-text { text-align: center; font-size: calc(2rem * var(--quran-scale)); line-height: 2.4; } .verse-ref { color: var(--muted); }
.tracks { display: grid; gap: 1.5rem; margin-block: 2rem; } .track { border-top: 2px solid var(--red); padding-top: .8rem; } .track h3 { margin-bottom: .3rem; } .track p { color: var(--muted); margin: 0; }

/* ---------- surah grid ---------- */
.page-head { margin-bottom: 1.2rem; } .page-head h1 { margin-bottom: .2em; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-block: 1rem; }
.tile { display: grid; justify-items: center; gap: .15rem; padding: .8rem .3rem; text-align: center; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: 100%; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--red); transform: translateY(-2px); }
.tile-name { font: 700 1.05rem var(--quran); } .tile-meta { font-size: .72rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.tile-meta i { width: 4px; height: 4px; background: var(--red); transform: rotate(45deg); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: 1.2rem; }
.dots { display: none; gap: .25rem; flex-wrap: wrap; justify-content: center; }
.dot { min-width: 38px; min-height: 38px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: var(--radius); cursor: pointer; font: 600 .85rem var(--ui); } .dot[aria-current] { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.count { margin: .5rem 0 0; font-size: .9rem; }

/* ---------- surah page ---------- */
.surah-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; } .surah-head > div { flex: 1; min-width: 12rem; } .surah-head h1 { margin: 0; }
.quran-title { font-family: var(--quran); }
.surah-grid { display: grid; gap: 1.2rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem; }
.reading { min-width: 0; }
.reader-note { font-size: .9rem; margin: 0 0 .5rem; }
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1rem; }
.quran-text { font-family: var(--quran); font-size: calc(1.55rem * var(--quran-scale)); line-height: 2.5; }
.reader .flow { text-align: justify; text-align-last: right; margin: 0; hyphens: none; }
.bismillah { text-align: center; font-weight: 700; font-size: calc(1.9rem * var(--quran-scale)); margin: 0 0 .6rem; }
.ayah { border-radius: 4px; padding-inline: 2px; transition: background .2s; } .ayah.is-playing { background: color-mix(in srgb, var(--red) 24%, transparent); }
.no { display: inline-grid; place-items: center; min-width: 1.9em; height: 1.9em; margin-inline: .15em; border: 1.5px solid var(--olive); border-radius: 50%; font: 600 .58em var(--ui); text-decoration: none; color: var(--ink); vertical-align: middle; line-height: 1; padding-inline: .2em; }
.no:hover { border-color: var(--red); color: var(--red); }
.gap { display: block; text-align: center; color: var(--red); font-size: .8rem; letter-spacing: .5em; margin: .4rem 0; }
.surah-nav { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-top: 1.5rem; }
.field { margin-bottom: 1rem; } .field[hidden] { display: none; }
.picker { margin-bottom: 1rem; }
.ayah-card { margin: 1rem 0; padding: 1.5rem 1.2rem; text-align: center; font-size: calc(1.9rem * var(--quran-scale)); background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--red); border-radius: 10px; }
.sample { margin: .5rem 0 0; text-align: center; }

/* ---------- lists / prose ---------- */
.results { margin-top: .5rem; } .res-h { font-size: 1.05rem; color: var(--olive); margin: 1.5rem 0 .6rem; }
.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.res-item { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; min-height: 56px; }
.res-item:hover { border-color: var(--red); } .res-main { display: grid; gap: .1rem; flex: 1; min-width: 0; } .res-text { font-size: calc(1.25rem * var(--quran-scale)); line-height: 2; }
.fav { display: flex; gap: .5rem; align-items: stretch; } .fav .res-item { flex: 1; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.search-form { display: flex; gap: .5rem; } .search-form .btn { flex: none; }
.prose { max-width: 46rem; } .prose h2 { margin-top: 1.8rem; } .prose li { margin-bottom: .4rem; }
.acc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: .6rem; }
.acc summary { cursor: pointer; padding: .9rem 1rem; font-weight: 700; min-height: 48px; } .acc ol { margin: 0; padding: 0 2.2rem 1rem 1rem; }

/* ---------- player / toast ---------- */
.player { position: fixed; inset-inline: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 35; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(12px); border-top: 2px solid var(--red); }
.player[hidden] { display: none; }
.pl-inner { width: min(1120px, 100% - 1.2rem); margin-inline: auto; padding: .5rem 0; display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; }
.pl-info { min-width: 0; } .pl-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .pl-sub { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-controls { display: flex; gap: .25rem; align-items: center; direction: rtl; }
.pl-btn { background: none; border: 0; color: var(--ink); width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; } .pl-btn:hover { background: var(--surface-2); }
.pl-main { background: var(--red); color: var(--red-ink); width: 46px; height: 46px; } .pl-main:hover { background: var(--red); filter: brightness(1.15); }
.pl-seekrow { grid-column: 1 / -1; display: flex; align-items: center; gap: .6rem; } .pl-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-extra { grid-column: 1 / -1; display: flex; gap: .4rem; align-items: center; }
.pl-chip { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: .1rem .8rem; min-height: 34px; font: 600 .8rem var(--ui); cursor: pointer; } .pl-chip.on { color: var(--red); border-color: var(--red); }
.pl-extra .pl-btn:last-child { margin-inline-start: auto; }
body.has-player main { padding-bottom: 14rem; }
.toast-box { position: fixed; inset-inline: 0; bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom)); z-index: 60; display: grid; justify-items: center; pointer-events: none; padding-inline: 1rem; }
body.has-player .toast-box { bottom: calc(var(--tabbar) + 9rem + env(safe-area-inset-bottom)); }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: var(--radius); box-shadow: 0 6px 24px #0008; max-width: 32rem; font-weight: 600; } .toast-error { background: var(--bad); color: #fff; }
.is-hidden { display: none !important; }

/* ---------- breakpoints ---------- */
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } .tracks { grid-template-columns: repeat(3, 1fr); } .dots { display: flex; } }
@media (min-width: 900px) {
  :root { --tabbar: 0px; }
  .tabbar { display: none; } .desk { display: flex; }
  .grid { grid-template-columns: repeat(6, 1fr); }                      /* 6 surahs per row, 2 rows per page */
  .hero { grid-template-columns: 1.05fr 1fr; gap: 3rem; } .hero-art { order: 2; }
  .surah-grid { grid-template-columns: minmax(300px, 360px) 1fr; } .panel { position: sticky; top: 76px; }
  .foot { padding-bottom: 1.5rem; } .foot-in { grid-template-columns: auto 1fr auto; justify-items: start; align-items: center; } .foot-in p:nth-child(2) { justify-self: center; }
  .player { bottom: 0; } body.has-player main { padding-bottom: 9rem; } .toast-box, body.has-player .toast-box { bottom: 6.5rem; }
  .pl-inner { grid-template-columns: minmax(10rem, 1fr) auto minmax(14rem, 2fr) auto; } .pl-seekrow, .pl-extra { grid-column: auto; } .pl-extra .pl-btn:last-child { margin-inline-start: .3rem; }
}
@media (min-width: 900px) { .tabbar + * { } }
@media print { .top, .tabbar, .player, .foot, .toast-box { display: none !important; } body::before { display: none; } }
