/* Muddakir. Styles copied from the viewer (mushaf/template.html), reading parts only.
   Ornaments are files under img/, not data: URLs, so the page runs under default-src 'self'. */

@font-face { font-family: "Amiri Quran Local"; src: url(fonts/AmiriQuran-Regular.ttf) format("truetype"); font-display: swap; }
@font-face { font-family: "Reem Kufi Local"; src: url(fonts/ReemKufi.ttf) format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Gentium Book Plus Local"; src: url(fonts/GentiumBookPlus-Regular.ttf) format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Gentium Book Plus Local"; src: url(fonts/GentiumBookPlus-Bold.ttf) format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic Local"; src: url(fonts/IBMPlexSansArabic-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic Local"; src: url(fonts/IBMPlexSansArabic-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Gentium Book Plus Local"; src: url(fonts/GentiumBookPlus-Italic.ttf) format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --paper: #f5efdf;      /* vellum */
  --page: #fbf7ec;       /* inside the frame */
  --ink: #1d1912;
  --muted: #6c6350;
  --gold: #a5792a;
  --gold-soft: #d9bd7c;
  --lapis: #1d3567;
  --lapis-ink: #f3e3b3;  /* gold-cream text on the lapis band */
  --red: #9a2d1f;        /* rubric red for verse numerals */
  --hover: rgba(165, 121, 42, .14);
  --ornament: rgba(29, 53, 103, .07);
  --accent: var(--lapis); /* headings and the name: lapis by day, gold by night */
  --quran: "Amiri Quran Local", "Amiri Quran", "Amiri", serif;
  --kufi: "Reem Kufi Local", "Reem Kufi", sans-serif;
  --ui-ar: "IBM Plex Sans Arabic Local", "IBM Plex Sans Arabic", "Gentium Book Plus Local", sans-serif;   /* the Arabic interface: plain and clear */
  --latin: "Gentium Book Plus Local", "Gentium Plus", Georgia, "Times New Roman", serif;
  --qsize: 1.9rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0b1222; --page: #111b31; --ink: #ece2c6; --muted: #a59d88;
  --gold: #d4ab5a; --gold-soft: #7d6634; --lapis: #213f7a; --lapis-ink: #f1dca4;
  --red: #e8846c; --hover: rgba(212, 171, 90, .13); --ornament: rgba(212, 171, 90, .06);
  --accent: var(--gold);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --paper: #0b1222; --page: #111b31; --ink: #ece2c6; --muted: #a59d88;
  --gold: #d4ab5a; --gold-soft: #7d6634; --lapis: #213f7a; --lapis-ink: #f1dca4;
  --red: #e8846c; --hover: rgba(212, 171, 90, .13); --ornament: rgba(212, 171, 90, .06);
  --accent: var(--gold);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--latin); font-size: 1rem; line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 4rem; position: relative;
}
/* eight-pointed star lattice, tinted by token through a mask */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--ornament);
  -webkit-mask: url(img/lattice.svg) repeat; mask: url(img/lattice.svg) repeat;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
/* Interface Arabic is set in a plain sans (IBM Plex Sans Arabic), the owner's choice of
   2026-11-17: clear on a phone, and never mistaken for verse text. The decorative Kufi is kept for
   the themes' names and the surah headband; only the text of the Book uses the Qur'an font.
   English inside an Arabic page (the translation) is set in the Latin font (build step 6). */
[lang="ar"] { font-family: var(--ui-ar); }
[lang="en"] { font-family: var(--latin); }
:root[lang="ar"] body { font-family: var(--ui-ar); }
.mushaf, .basmala, .qname, .result .ra { font-family: var(--quran); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 3px; }
[hidden] { display: none !important; }

.wrap { max-width: 50rem; margin: 0 auto; display: grid; gap: 3rem; }

/* ---------- opening (unwān) ---------- */
.opening { text-align: center; padding-top: 2.4rem; display: grid; gap: .7rem; justify-items: center; }
.opening .medallion { width: 4rem; height: 4rem; color: var(--gold); }
.opening h1 { margin: 0; font-family: var(--kufi); font-weight: 600; font-size: clamp(2.2rem, 7vw, 3.4rem); color: var(--accent); line-height: 1.3; }
.opening h1.qname { font-family: var(--quran); font-weight: 400; font-size: clamp(2.6rem, 9vw, 3.8rem); line-height: 1.6; padding-bottom: .3rem; }
.opening .sub { margin: 0; font-size: 1.05rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.opening .lede { margin: .2rem 0 0; max-width: 36rem; color: var(--muted); font-style: italic; text-wrap: balance; }
.savedin { text-align: center; font-size: .85rem; color: var(--muted); margin: 0; }
.savedin b { color: var(--ink); }

/* ---------- toolbar ---------- */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; padding: .6rem; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid var(--gold-soft); margin-top: 1.6rem; }
.bar button { font: inherit; font-size: .9rem; color: var(--ink); background: var(--page); border: 1px solid var(--gold-soft); border-radius: 999px; padding: .3rem .85rem; cursor: pointer; min-height: 2.2rem; }
.bar button[aria-pressed="true"] { background: var(--lapis); color: var(--lapis-ink); border-color: var(--lapis); }
.bar button:hover { border-color: var(--gold); }
.bar .grp { display: inline-flex; gap: .25rem; align-items: center; }
.bar .lbl { font-size: .8rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-inline: .2rem; }
@media (max-width: 30rem) { .bar .lbl { display: none; } .bar button { padding: .3rem .7rem; } }
@media (max-width: 44rem) { .bar { gap: .4rem; padding: .5rem 0; } .bar .tabs { flex: 1 0 100%; justify-content: center; border: 0; } .bar .tabs button { flex: 1; border: 1px solid var(--gold); } .bar .tabs button:first-child { border-radius: 0; border-start-start-radius: 999px; border-end-start-radius: 999px; } .bar .tabs button:last-child { border-radius: 0; border-start-end-radius: 999px; border-end-end-radius: 999px; border-inline-start: 0; } }

/* ---------- tabs ---------- */
.tabs { display: inline-flex; gap: 0; border: 1px solid var(--gold); border-radius: 999px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; min-height: 2.2rem; white-space: nowrap; }
.tabs button + button { border-inline-start: 1px solid var(--gold); }
.tabs button[aria-selected="true"] { background: var(--lapis); color: var(--lapis-ink); }
.tabs .count { font-family: var(--kufi); font-size: .78rem; margin-inline-start: .35rem; opacity: .85; }

.wide { max-width: 78rem; margin: 2rem auto 0; display: grid; gap: 1.6rem; }
.wide .wide { margin-top: 0; }
.panel-head { text-align: center; display: grid; gap: .5rem; justify-items: center; }
.panel-head h2 { margin: 0; font-family: var(--kufi); font-weight: 600; font-size: clamp(1.5rem, 5vw, 2.1rem); color: var(--gold); }
.panel-head p { margin: 0; color: var(--muted); max-width: 40rem; text-wrap: balance; }
.btn { font: inherit; font-size: .92rem; border-radius: 999px; padding: .4rem 1rem; cursor: pointer; min-height: 2.3rem; border: 1px solid var(--gold); background: var(--page); color: var(--ink); }
.btn.primary { background: var(--lapis); color: var(--lapis-ink); border-color: var(--lapis); font-weight: 700; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- page ---------- */
.page { scroll-margin-top: 4.5rem; }
.frame {
  position: relative; background: var(--page); padding: 2.2rem clamp(1rem, 4vw, 2.6rem) 1.4rem;
  border: 3px double var(--gold); outline: 1px solid var(--gold-soft); outline-offset: 6px; margin: 7px;
  box-shadow: inset 0 0 0 6px var(--page), inset 0 0 0 7px var(--gold-soft);
  display: grid; gap: 1.1rem;
}
.frame::before, .frame::after { /* corner rosettes */
  content: ""; position: absolute; width: 26px; height: 26px; background: var(--gold);
  -webkit-mask: url(img/corner.svg) center/contain no-repeat; mask: url(img/corner.svg) center/contain no-repeat;
}
.frame::before { top: -14px; inset-inline-start: -14px; }
.frame::after { bottom: -14px; inset-inline-end: -14px; }

.sarlawh {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem;
  background: var(--lapis); color: var(--lapis-ink); padding: .55rem 1rem; border-radius: 3px;
  border: 1px solid var(--gold); box-shadow: 0 0 0 3px var(--page), 0 0 0 4px var(--gold);
  background-image: radial-gradient(circle at 50% 50%, rgba(255,255,255,.08), transparent 60%);
  direction: rtl;
}
.sw-title { margin: 0; font-family: var(--kufi); font-weight: 600; font-size: clamp(1.25rem, 4.2vw, 1.75rem); padding: .1rem 1.4rem; text-align: center; border-inline: 1px solid color-mix(in srgb, var(--lapis-ink) 45%, transparent); white-space: nowrap; }
.sw-side { font-family: var(--kufi); font-size: .95rem; opacity: .9; }
.sw-side:first-child { text-align: right; }
.sw-side:last-child { text-align: left; }
@media (max-width: 26rem) { .sw-title { padding-inline: .7rem; } .sw-side { font-size: .82rem; } }
.loc { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.1rem; font-size: .85rem; color: var(--muted); letter-spacing: .03em; }
.loc span + span::before { content: "◆"; color: var(--gold); font-size: .55rem; margin-inline-end: 1.1rem; vertical-align: .2em; }

.basmala { margin: .2rem 0 0; text-align: center; font-size: calc(var(--qsize) * 1.05); color: var(--accent); line-height: 2; }

.mushaf { font-size: var(--qsize); line-height: 2.35; text-align: justify; text-align-last: center; word-spacing: .04em; overflow-wrap: normal; }
.am { /* verse rosette */
  display: inline-grid; place-items: center; width: 2.3em; height: 2.3em; margin-inline: .1em; vertical-align: -.25em;
  font-family: var(--quran); font-size: .6em; font-weight: 700; line-height: 1; color: var(--red); position: relative; white-space: nowrap;
}
.am3 { font-size: .55em; width: 2.75em; height: 2.75em; }
.am::before {
  content: ""; position: absolute; inset: 0; background: var(--gold);
  -webkit-mask: url(img/rosette.svg) center/contain no-repeat; mask: url(img/rosette.svg) center/contain no-repeat;
}
/* verse rosette: centre the numerals optically (Amiri's digits sit low); --am-dy is measured in the browser */
.am > i { font-style: normal; display: block; line-height: 1; transform: translateY(var(--am-dy, -.3em)); position: relative; }
.am3 > i { font-size: .84em; letter-spacing: -.04em; }

.below { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.4rem; border-top: 1px solid var(--gold-soft); padding-top: 1.1rem; }
.below.solo { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 44rem) { .below { grid-template-columns: minmax(0, 1fr); } }
.trans { margin: 0; padding: 0; list-style: none; display: grid; gap: .55rem; font-size: .96rem; }
.vn { font-family: var(--kufi); font-size: .78rem; color: var(--red); letter-spacing: .03em; margin-inline-end: .25rem; font-variant-numeric: tabular-nums; }
.hashiya { font-size: .92rem; color: var(--ink); border-inline-start: 2px solid var(--gold); padding-inline-start: 1rem; align-self: start; }
.hashiya h3 { margin: 0 0 .5rem; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.hashiya p { margin: 0 0 .65rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.hashiya .member + .member { margin-top: 1rem; padding-top: .9rem; border-top: 1px dashed var(--gold-soft); }
.hashiya .empty { color: var(--muted); font-style: italic; }

.folio { margin: 0; display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); }
.folio a { text-decoration: none; font-family: var(--kufi); }
.folio span { font-size: 1.3rem; color: var(--gold); }

.colophon { text-align: center; font-size: .82rem; color: var(--muted); max-width: 38rem; margin: 0 auto; text-wrap: balance; }
.credits { max-width: 38rem; margin: 0 auto; font-size: .85rem; color: var(--muted); }
.credits summary { cursor: pointer; text-align: center; color: var(--ink); }
.credits ul { padding-inline-start: 1.1rem; display: grid; gap: .4rem; }
.kbd { font-size: .78rem; color: var(--muted); text-align: center; margin: 0; }

body.no-trans .trans { display: none; }
body.no-trans .below { grid-template-columns: minmax(0, 1fr); }
body.no-trans .below.solo { display: none; }

/* ---------- navigator: index beside a one-passage reader ---------- */
.navigator { display: grid; grid-template-columns: minmax(0, 21rem) minmax(0, 1fr); gap: 1.6rem; align-items: start; }
@media (max-width: 62rem) { .navigator { grid-template-columns: minmax(0, 1fr); } }
.index { background: var(--page); border: 1px solid var(--gold-soft); border-radius: 8px; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 3.8rem); max-height: calc(100vh - env(safe-area-inset-top, 0px) - 4.6rem); }
@media (max-width: 62rem) { .index { position: static; max-height: none; } .index.collapsed .index-list { display: none; } }
.index-head { display: grid; gap: .55rem; padding: .8rem; border-bottom: 1px solid var(--gold-soft); }
.index-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.index-title h3 { margin: 0; font-family: var(--kufi); font-weight: 600; color: var(--gold); font-size: 1.15rem; }
.index-title .n { font-size: .82rem; color: var(--muted); }
.index-toggle { display: none; font: inherit; font-size: .85rem; border: 1px solid var(--gold-soft); background: none; color: var(--ink); border-radius: 999px; padding: .2rem .7rem; cursor: pointer; }
@media (max-width: 62rem) { .index-toggle { display: inline-block; } }
.index-head input[type="search"] { font: inherit; font-size: 1rem; width: 100%; min-width: 0; padding: .45rem .6rem; border: 1px solid var(--gold-soft); border-radius: 6px; background: var(--paper); color: var(--ink); }
.index-list { overflow-y: auto; overscroll-behavior: contain; padding: .3rem 0 .6rem; }
@media (max-width: 62rem) { .index-list { max-height: 60vh; } }
.grp-h { position: sticky; top: 0; z-index: 1; background: var(--page); display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .45rem .8rem .25rem; border-bottom: 1px solid color-mix(in srgb, var(--gold-soft) 60%, transparent); font-size: .8rem; color: var(--muted); }
.grp-h b { color: var(--ink); font-weight: 700; }
.grp-h span[lang="ar"] { font-size: .95rem; color: var(--gold); }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .2rem .55rem; align-items: center; width: 100%; text-align: start; font: inherit; color: inherit; background: none; border: 0; border-inline-start: 3px solid transparent; padding: .45rem .8rem; cursor: pointer; }
.row:hover { background: var(--hover); }
.row[aria-current="true"] { background: var(--hover); border-inline-start-color: var(--gold); }
.row .rref { font-family: var(--kufi); font-size: .8rem; color: var(--red); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .rt { font-size: .88rem; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.index-empty { padding: 1rem .8rem; color: var(--muted); font-size: .9rem; margin: 0; }

.reader { display: grid; gap: 1rem; min-width: 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.pager .pos { font-size: .88rem; color: var(--muted); text-align: center; flex: 1 1 auto; }
.pager .pos b { color: var(--ink); }

/* strip above each page */
.keepbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin: 0 7px -.6rem; padding: .55rem .9rem; background: var(--lapis); color: var(--lapis-ink); border: 1px solid var(--gold); border-radius: 6px 6px 0 0; position: relative; z-index: 1; }
.keepbar .ref { font-size: .88rem; letter-spacing: .03em; opacity: .9; }
.bar-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: flex-end; }
.barbtn, .rm { font: inherit; font-size: .85rem; color: var(--lapis-ink); background: transparent; border: 1px solid color-mix(in srgb, var(--lapis-ink) 55%, transparent); border-radius: 999px; padding: .25rem .8rem; cursor: pointer; }
a.barbtn { text-decoration: none; display: inline-block; }
.barbtn:hover, .rm:hover { background: color-mix(in srgb, var(--lapis-ink) 14%, transparent); }
.rm.armed { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.rm:disabled { opacity: .5; cursor: progress; }
.merged-tag { font-size: .8rem; color: var(--muted); text-align: center; margin: -.4rem 0 0; }

/* +/− at the two edges of the text */
.edge { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
/* the start of the Arabic text is always at the right, whichever way the page runs */
.edge.start { justify-content: flex-end; margin-bottom: -.4rem; }
.edge.end { justify-content: flex-start; margin-top: -.4rem; }
[dir="rtl"] .edge.start { justify-content: flex-start; }
[dir="rtl"] .edge.end { justify-content: flex-end; }
.edge .rbtn { font-variant-numeric: tabular-nums; min-width: 3.2rem; }
.rlabel { font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.rbtn { font: inherit; font-size: .8rem; border: 1px solid var(--gold-soft); background: var(--paper); color: var(--ink); border-radius: 999px; padding: .2rem .65rem; cursor: pointer; min-height: 2.1rem; }
.rbtn:hover:not(:disabled) { border-color: var(--gold); }
.rbtn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- add a passage ---------- */
.addcard { background: var(--page); border: 3px double var(--gold); outline: 1px solid var(--gold-soft); outline-offset: 5px; margin: 6px auto; padding: 1.3rem clamp(1rem, 4vw, 2rem); display: grid; gap: 1rem; max-width: 50rem; width: calc(100% - 12px); }
.fields { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: .8rem; }
.fields .wide-f { grid-column: 1 / -1; }
@media (max-width: 34rem) { .fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .fields .surah-f { grid-column: 1 / -1; } }
.field { display: grid; gap: .3rem; min-width: 0; }
.field label, .lk-label { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.field label small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: inherit; }
.field input, .field select, .field textarea { font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper); border: 1px solid var(--gold-soft); border-radius: 6px; padding: .5rem .6rem; min-width: 0; width: 100%; }
.field textarea { min-height: 4.5rem; resize: vertical; }
.preview { border-top: 1px solid var(--gold-soft); padding-top: .9rem; display: grid; gap: .5rem; }
.preview .pv-ref { text-align: center; font-size: .85rem; color: var(--muted); letter-spacing: .03em; margin: 0; }
.preview .mushaf { font-size: calc(var(--qsize) * .85); }
.preview .trans { font-size: .9rem; }
.form-err { color: var(--red); font-weight: 700; margin: 0; text-align: center; min-height: 1.2em; }
.confirm { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.lookup { display: grid; gap: .6rem; }
.lookup-row { display: flex; gap: .5rem; }
.lookup-row input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper); border: 1px solid var(--gold-soft); border-radius: 6px; padding: .55rem .7rem; }
.lookup .hint { font-size: .85rem; color: var(--muted); margin: 0; }
.results { display: grid; gap: .1rem; max-height: 22rem; overflow-y: auto; border: 1px solid var(--gold-soft); border-radius: 6px; background: var(--paper); }
.result { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .6rem; text-align: start; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--gold-soft) 50%, transparent); padding: .5rem .7rem; cursor: pointer; }
.result:hover, .result:focus-visible { background: var(--hover); }
.result .rref { font-family: var(--kufi); color: var(--red); font-size: .85rem; white-space: nowrap; }
.result .ra { grid-column: 2; font-size: 1.15rem; direction: rtl; text-align: start; line-height: 1.9; }
.result .re { grid-column: 2; font-size: .85rem; color: var(--muted); }
.result mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 2px; }

.state { text-align: center; padding: 2.4rem 1rem; color: var(--muted); border: 1px dashed var(--gold-soft); border-radius: 8px; display: grid; gap: .5rem; justify-items: center; }
.state strong { color: var(--ink); font-size: 1.05rem; }
.state .glyph { font-size: 2rem; color: var(--gold); }

.toast { position: fixed; inset-inline: 0; margin-inline: auto; width: fit-content; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); background: var(--lapis); color: var(--lapis-ink); border: 1px solid var(--gold); padding: .6rem 1rem; border-radius: 8px; max-width: min(28rem, calc(100vw - 32px)); font-size: .92rem; z-index: 20; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast a { color: inherit; font-weight: 700; }

/* ---- sign-in, join and the admin's page (build step 2) ---- */
.who { text-align: center; font-size: .85rem; color: var(--muted); margin: .4rem 0 0; display: flex; gap: .5rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.btn.small { font-size: .8rem; min-height: 1.9rem; padding: .2rem .8rem; text-decoration: none; display: inline-flex; align-items: center; }
.devmark { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--red); border: 1px solid var(--red); border-radius: 4px; padding: 0 .35rem; }
.authpage main { padding-top: .5rem; }
.authcard { max-width: 26rem; }
.authcard h2, .addcard h3 { margin: 0; font-family: var(--kufi); font-weight: 600; color: var(--gold); text-align: center; }
.authcard h2 { font-size: 1.5rem; }
.addcard h3 { font-size: 1.2rem; text-align: start; }
.authcard .btn.primary { justify-self: center; min-width: 10rem; }
.authcard .hint, .addcard .hint { margin: 0; color: var(--muted); font-size: .88rem; text-align: center; }
.addcard .hint { text-align: start; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.adminpage { display: grid; gap: 1.2rem; padding-top: 1.5rem; }
.adminpage .addcard { max-width: 50rem; }
.inline-form { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 14rem; }
.newlink { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.newlink p { grid-column: 1 / -1; margin: 0; }
.newlink input { font: inherit; font-size: .85rem; color: var(--ink); background: var(--paper); border: 1px solid var(--gold); border-radius: 6px; padding: .5rem .6rem; min-width: 0; }
.tablewrap { overflow-x: auto; }
.adminpage table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.adminpage th { text-align: start; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .3rem .4rem; border-bottom: 1px solid var(--gold-soft); }
.adminpage td { padding: .45rem .4rem; border-bottom: 1px solid var(--hover); vertical-align: middle; overflow-wrap: anywhere; }
.adminpage td.acts { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.adminpage td .btn { font-size: .8rem; min-height: 1.9rem; padding: .2rem .7rem; }
.adminpage td .btn { white-space: nowrap; }
@media (max-width: 600px) {
  .adminpage thead { display: none; }
  .adminpage tr { display: grid; grid-template-columns: minmax(0, 1fr); padding: .5rem 0; border-bottom: 1px solid var(--gold-soft); }
  .adminpage td { border: 0; padding: .15rem 0; display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .5rem; }
  .adminpage td[data-label]::before { content: attr(data-label); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: .2rem; }
  .adminpage td.acts { display: flex; justify-content: flex-start; padding-top: .4rem; }
}

/* ---- the personal store (build step 3): the learn mark, themes, notes edited in place, archive ---- */
.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chip { font: inherit; font-size: .8rem; border: 1px solid var(--gold-soft); background: none; color: var(--ink); border-radius: 999px; padding: .15rem .6rem; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.chip[aria-pressed="true"] { background: var(--lapis); color: var(--lapis-ink); border-color: var(--lapis); }
.clabel { font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); align-self: center; min-width: 3.9rem; }
.ltag { font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; border: 1px solid var(--gold-soft); border-radius: 3px; padding: 0 .3rem; color: var(--muted); white-space: nowrap; line-height: 1.5; }
.ltag.learning { border-color: var(--lapis); color: var(--ink); }
.ltag.learned { background: var(--lapis); color: var(--lapis-ink); border-color: var(--lapis); }
.rm-meta { display: inline-flex; gap: .3rem; align-items: center; }
.range { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; align-items: center; margin: .2rem 0 .6rem; }
.range .rlabel { font-size: .8rem; letter-spacing: .06em; }
.range .rbtn[aria-pressed="true"] { background: var(--lapis); color: var(--lapis-ink); border-color: var(--lapis); }
.hint-inline { font-size: .85rem; color: var(--muted); }
.barbtn.solid { background: var(--lapis-ink); color: var(--lapis); font-weight: 700; }
.barbtn:disabled { opacity: .5; cursor: progress; }
.linkbtn { font: inherit; font-size: .85rem; background: none; border: 0; padding: .2rem 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.member.editing { display: grid; gap: .35rem; }
.ed-l { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ed-title, .ed-note, .th-name, #theme-new { font: inherit; font-size: 1rem; width: 100%; min-width: 0; padding: .45rem .6rem; border: 1px solid var(--gold-soft); border-radius: 6px; background: var(--paper); color: var(--ink); box-sizing: border-box; }
.ed-note { min-height: 8rem; resize: vertical; }
.ed-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.savedin.failed { color: var(--red); }
.savedin .notsaved { color: var(--red); }
.mythemes { max-width: 46rem; margin: 1rem auto; border: 1px solid var(--gold-soft); border-radius: 8px; background: var(--page); padding: .2rem .9rem; }
.mythemes > summary { cursor: pointer; padding: .55rem 0; font-weight: 700; color: var(--ink); }
.mythemes[open] { padding-bottom: .9rem; }
.theme-list { list-style: none; margin: .4rem 0 .9rem; padding: 0; display: grid; gap: .4rem; }
.th { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .4rem 0; border-bottom: 1px dashed var(--gold-soft); }
.th-label { font-weight: 700; overflow-wrap: anywhere; }
.th-n { font-size: .8rem; color: var(--muted); }
.th-actions { display: inline-flex; gap: .3rem; margin-inline-start: auto; flex-wrap: wrap; }
.th .th-name { flex: 1 1 12rem; width: auto; }
.theme-form { display: grid; gap: .35rem; }
.th .rm { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, transparent); min-height: 2.1rem; }
.th .rm:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
.th .rm.armed { color: #fff; }
#archive-link { gap: .3rem; }

/* ---- starter themes (build step 4). Theme names are our own headings: heading font, never the
   Qur'an font. A passage's Arabic title is a span of the verse: the Qur'an font, like the text. ---- */
/* flex, not an auto-fill grid: the grid's column count followed max-width and widened the phone page */
.theme-cards { display: flex; flex-wrap: wrap; gap: .7rem; max-width: 60rem; margin: 1.2rem auto; }
.tcard { flex: 1 1 15rem; min-width: 0; }
.tcard { font: inherit; text-align: center; display: grid; gap: .25rem; justify-items: center; padding: .9rem .8rem; border: 1px solid var(--gold-soft); border-radius: 10px; background: var(--page); color: var(--ink); cursor: pointer; }
.tcard:hover { border-color: var(--gold); background: var(--hover); }
.tc-ar { font-family: var(--kufi); font-weight: 600; font-size: 1.3rem; color: var(--accent); line-height: 1.5; }
.tc-en { font-weight: 700; }
.tc-n { font-size: .8rem; color: var(--muted); }
.theme-open-head { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.theme-open-head h3 { margin: 0; display: flex; gap: .2rem .7rem; flex-wrap: wrap; align-items: baseline; justify-content: center; }
.qtitle { margin: .3rem 0 .2rem; text-align: center; font-family: var(--quran); font-size: calc(var(--qsize) * .95); color: var(--accent); line-height: 1.9; }
.row .qt { font-family: var(--quran); font-size: 1.1rem; line-height: 1.6; text-align: start; }
.welcome { max-width: 40rem; margin: 1rem auto 0; padding: 1rem 1.2rem; border: 1px solid var(--gold); border-radius: 10px; background: var(--page); }
.welcome h2 { margin: 0 0 .4rem; font-family: var(--kufi); font-weight: 600; color: var(--gold); }
.welcome p { margin: .4rem 0; }
.draft { font-size: .85rem; color: var(--red); border: 1px dashed var(--red); border-radius: 6px; padding: .2rem .7rem; }

/* ---- backup and account (build step 5) ---- */
.acct { max-width: 40rem; margin: 0 auto; display: grid; gap: 1rem; }
.acct-part { border: 1px solid var(--gold-soft); border-radius: 10px; background: var(--page); padding: .9rem 1.1rem; display: grid; gap: .5rem; justify-items: start; }
.acct-part h3 { margin: 0; font-family: var(--kufi); font-weight: 600; color: var(--gold); font-size: 1.2rem; }
.acct-part p { margin: 0; }
.acct-part .theme-form, .acct-part .lookup-row { width: 100%; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.btn.danger { border-color: var(--red); color: var(--red); background: var(--page); font-weight: 700; }
.btn.danger.armed { background: var(--red); color: #fff; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
#account-link { gap: .3rem; }

/* ---- your themes on the Themes tab; a starter passage adjusted before keeping ---- */
.mine { max-width: 60rem; margin: 1rem auto 0; display: grid; gap: .6rem; }
.mine h3, .starter-h { margin: 0; text-align: center; font-family: var(--kufi); font-weight: 600; color: var(--gold); font-size: 1.25rem; }
.starter-h { margin-top: 1.4rem; }
.mine .theme-cards { margin: 0; }
.mine-card { border-style: dashed; }
.adjusted { text-align: center; font-size: .85rem; color: var(--muted); margin: .2rem 0; }

/* ---- the recitation player (build step 8; copied from the viewer). The verse being recited is
   marked with a class, not an inline style element, which the page's policy would refuse. ---- */
.player { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem max(16px, env(safe-area-inset-right, 0px)) calc(.5rem + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--lapis); color: var(--lapis-ink); border-top: 1px solid var(--gold); font-size: .88rem; }
.player .now { min-width: 0; margin-inline: .4rem; font-variant-numeric: tabular-nums; }
.player .barbtn { min-width: 2.4rem; }
body.playing { padding-bottom: 5.5rem; }
body.playing .toast { bottom: calc(5.8rem + env(safe-area-inset-bottom, 0px)); }
.mushaf .reciting { background: color-mix(in srgb, var(--gold) 30%, transparent); border-radius: 4px; }

/* ---- two languages (build step 6). The Arabic interface mirrors the layout (dir="rtl" on the
   page; the rules above use logical sides: inline-start and inline-end). The safe-area padding
   stays physical, because a phone's notch is on a physical side. The Qur'an text is always right
   to left, the translation always left to right; what a person typed (.user) takes its own
   direction. Arabic labels are in the heading font: no letter-spacing, capitals or italics,
   which break or mean nothing in Arabic script. ---- */
:root[lang="ar"] .opening .sub { display: none; }        /* the Latin name under the Arabic one */
:root[lang="ar"] body * { letter-spacing: normal; }
:root[lang="ar"] .opening .lede, :root[lang="ar"] .hashiya .empty { font-style: normal; }
:root[lang="ar"] .field label, :root[lang="ar"] .lk-label, :root[lang="ar"] .ed-l, :root[lang="ar"] .rlabel,
:root[lang="ar"] .clabel, :root[lang="ar"] .ltag, :root[lang="ar"] .bar .lbl, :root[lang="ar"] .hashiya h3 { text-transform: none; }
:root[lang="ar"] .field label, :root[lang="ar"] .lk-label, :root[lang="ar"] .ed-l { font-size: .85rem; }
:root[lang="ar"] .rlabel, :root[lang="ar"] .clabel, :root[lang="ar"] .ltag { font-size: .8rem; }
.lang-row { margin: .9rem 0 0; }
#lang-switch { gap: .3rem; }
.ar-draft { margin: .2rem auto 0; max-width: 32rem; }
.trans, .user { unicode-bidi: isolate; }
/* the matching words of the translation in a search result: inline, hidden with the translation in
   Arabic; in English they always showed, and still do */
.result .trans { display: inline; font-size: inherit; gap: 0; }
:root[lang="en"] body.no-trans .result .trans { display: inline; }
:root[lang="ar"] .am3 > i { letter-spacing: -.04em; }    /* the rosette's three-digit numbers, as in English */
/* references alone in their element (the index, search results, the translation's verse numbers):
   left to right in an Arabic page too */
.rref, .vn { direction: ltr; unicode-bidi: isolate; }
.edge .rbtn { direction: ltr; unicode-bidi: isolate; }   /* "+ 254" as written, in either direction */

/* ---- phones (build step 7): the tabs sit at the bottom, within thumb's reach, above the
   home indicator; the player and the messages sit above them. A blurred bar would make the
   fixed tabs follow it, so on phones the top bar is plain. ---- */
@media (max-width: 44rem) {
  .bar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
  .bar .tabs { position: fixed; inset-inline: 0; bottom: 0; z-index: 40; margin: 0; border-radius: 0; border: 0;
    border-top: 1px solid var(--gold); background: var(--page); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bar .tabs button, .bar .tabs button:first-child, .bar .tabs button:last-child { border: 0; border-radius: 0; min-height: 3.2rem; font-size: .95rem; background: var(--page); }
  .bar .tabs button + button { border-inline-start: 1px solid var(--gold-soft); }
  .bar .tabs button[aria-selected="true"] { background: var(--lapis); color: var(--lapis-ink); }
  body { padding-bottom: calc(3.4rem + env(safe-area-inset-bottom, 0px)); }
  .player { bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px)); }
  body.playing { padding-bottom: calc(8.8rem + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); }
  body.playing .toast { bottom: calc(9.2rem + env(safe-area-inset-bottom, 0px)); }
}
/* opened from the home screen: no browser bar above, so leave room for the status bar */
@media (display-mode: standalone) { .wrap { padding-top: env(safe-area-inset-top, 0px); } }

/* ---- the Arabic interface: headings and small numbers in the plain font too (the owner's choice
   of 2026-11-17); the Kufi stays only on the themes' names (.tc-ar) and the surah headband ---- */
:root[lang="ar"] :is(.opening h1:not(.qname), .panel-head h2, .index-title h3, .authcard h2, .addcard h3, .welcome h2,
  .acct-part h3, .mine h3, .starter-h, .tabs .count, .vn, .row .rref, .result .rref, .folio a) { font-family: var(--ui-ar); font-weight: 700; }
:root[lang="ar"] :is(.vn, .row .rref, .result .rref, .folio a, .tabs .count) { font-weight: 400; }
@media (max-width: 44rem) {
  .bar .tabs { display: flex; }
  .bar .tabs button { flex: 1 1 0; min-width: 0; padding-inline: .35rem; overflow: hidden; text-overflow: ellipsis; }
}
.mine { grid-template-columns: minmax(0, 1fr); }   /* its items never widen the phone page (seen in Arabic, 2026-11-17) */
/* an input beside its button takes the room that is left, never its own idea of a width (the
   Arabic font's wider letters made "New theme" overflow a phone, 2026-11-17) */
.theme-form { grid-template-columns: minmax(0, 1fr); }
.lookup-row input { width: 0; flex: 1 1 auto; }

/* ---- the Discussion tab (version 2, build step 13a): each post is read like a kept passage; the
   author's words and every reply are the people's own (.user), in the plain fonts ---- */
.disc-list { display: grid; gap: 2.4rem; }
.disc-status:empty { display: none; }
.disc-status { text-align: center; }
.disc-more { text-align: center; margin-top: 1.2rem; }
.post .byline { margin: 0 0 .45rem; font-size: .85rem; color: var(--muted); }
.post .edited { font-style: italic; }
.disc-title { font-weight: 700; margin: 0 0 .45rem; overflow-wrap: anywhere; }
.replies { border-top: 1px solid var(--gold-soft); padding-top: .9rem; display: grid; gap: .9rem; }
.replies h4 { margin: 0; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.reply { border-inline-start: 2px solid var(--gold-soft); padding-inline-start: .8rem; display: grid; gap: .2rem; min-width: 0; }
.reply .byline { margin: 0; }
.reply p.user { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin: .2rem 0 0; }
.reply .rm { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.reply .rm:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
.reply .rm.armed { color: #fff; }
.reply-form { display: grid; gap: .35rem; min-width: 0; }
.ed-note.reply-text { min-height: 4.5rem; }
.barbtn.armed { background: var(--lapis-ink); color: var(--lapis); font-weight: 700; }
:root[lang="ar"] .replies h4 { text-transform: none; }
:root[lang="ar"] .post .edited { font-style: normal; }
/* four tabs on a phone: a long name takes two lines rather than being cut */
@media (max-width: 44rem) { .bar .tabs button { white-space: normal; line-height: 1.15; } }
/* ---- the Discussion tab, part 13b: the count on the tab, the "new" marks, the order switch, the
   first-time notice. The count says only what is new since the person's previous look: no measure ---- */
.tabs .count.fresh:not(:empty) { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; border-radius: 999px; background: var(--red); color: var(--page); opacity: 1; line-height: 1.35; text-align: center; }
.newmark { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 3px; padding: 0 .35rem; background: var(--lapis); color: var(--lapis-ink); letter-spacing: .04em; line-height: 1.5; }
:root[lang="ar"] .newmark { letter-spacing: 0; font-size: .8rem; }
.disc-order { justify-content: center; margin: 0 0 .8rem; flex-wrap: wrap; }
.disc-book-note { text-align: center; margin: 0 0 .8rem; }
.disc-new { text-align: center; margin: 0 0 1rem; font-weight: 700; }
dialog.notice { max-width: min(30rem, calc(100vw - 2rem)); box-sizing: border-box; border: 1px solid var(--gold); border-radius: 10px; background: var(--page); color: var(--ink); padding: 1rem 1.2rem; }
dialog.notice::backdrop { background: rgb(0 0 0 / .45); }
dialog.notice h3 { margin: 0 0 .5rem; color: var(--gold); font-size: 1.15rem; }
dialog.notice p { margin: 0 0 .9rem; overflow-wrap: anywhere; }
:root[lang="ar"] dialog.notice h3 { font-family: var(--ui-ar); font-weight: 700; }
