/* Quran Pro — one interface font (the system UI font), the Arabic font only for Arabic text.
   Colours are tokens; a theme is <html data-theme="…">, without one: light/dark like the system. */

/* Scheherazade New (SIL, OFL) renders the tafsir.one text correctly: ی, open tanween,
   ۝ + number as one ayah sign. KFGQPC fonts expect another encoding, so not used here. */
@font-face { font-family: 'QuranUz Arabic'; src: url(fonts/ScheherazadeNew-Regular.woff2?v=5) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200A, U+2060; }
@font-face { font-family: 'QuranUz Arabic'; src: url(fonts/ScheherazadeNew-Bold.woff2?v=5) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200A, U+2060; }
/* the framed ayah pictures (quote.js): the QCF surah-name font (from quran.com's open-source front end), QP Quote Serif
   and QP Quote Sans = subsets of Adobe's Source Serif 4 / Source Sans 3, renamed as the SIL OFL asks of a modified
   version (fonts/quote/OFL-*.txt); loaded only when a picture is drawn */
@font-face { font-family: 'QP Quote Names'; src: url(fonts/quote/sura_names.woff2?v=1) format('woff2'); font-display: block; }
@font-face { font-family: 'QP Quote Serif'; src: url(fonts/quote/QPQuoteSerif.woff2?v=1) format('woff2'); font-weight: 400 600; font-display: block; }
@font-face { font-family: 'QP Quote Sans'; src: url(fonts/quote/QPQuoteSans.woff2?v=1) format('woff2'); font-weight: 400 700; font-display: block; }

:root {
  --ui-font: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --ar-font: 'QuranUz Arabic', 'Scheherazade New', serif;
  --radius: 14px; --radius-s: 10px;
  /* light (default) */
  color-scheme: light;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f1f3f6; --fg: #14181f; --muted: #667085; --line: #e3e7ed;
  --accent: #0f766e; --accent-fg: #ffffff; --accent-soft: #d5f5ef; --hl: #fdf0c4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --fg: #e7e9ee; --muted: #98a2b3; --line: #2a2f3a;
    --accent: #2dd4bf; --accent-fg: #04201c; --accent-soft: #123a35; --hl: #3b3320;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
[data-theme=light] { color-scheme: light; }
[data-theme=dark] { color-scheme: dark;
  --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --fg: #e7e9ee; --muted: #98a2b3; --line: #2a2f3a;
  --accent: #2dd4bf; --accent-fg: #04201c; --accent-soft: #123a35; --hl: #3b3320;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); }
[data-theme=sepia] { color-scheme: light;
  --bg: #f3ead6; --surface: #fbf6ea; --surface-2: #f2e8d2; --fg: #3b2f22; --muted: #7a6a55; --line: #e2d5ba;
  --accent: #8b5e34; --accent-fg: #fffaf0; --accent-soft: #efdcc0; --hl: #f3d99f; }
[data-theme=ocean] { color-scheme: light;
  --bg: #eaf3fb; --surface: #ffffff; --surface-2: #eef5fc; --fg: #0b2540; --muted: #56708a; --line: #d3e2ef;
  --accent: #0369a1; --accent-fg: #ffffff; --accent-soft: #d6ebfa; --hl: #fff1b8; }
[data-theme=forest] { color-scheme: dark;
  --bg: #0c1813; --surface: #12231b; --surface-2: #183025; --fg: #e1efe7; --muted: #92ad9e; --line: #22392d;
  --accent: #4ade80; --accent-fg: #052e16; --accent-soft: #1b3a29; --hl: #3a3a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); }
[data-theme=midnight] { color-scheme: dark;
  --bg: #0a0f1e; --surface: #111a31; --surface-2: #17213d; --fg: #e5e9f5; --muted: #8b96b8; --line: #1f2a4d;
  --accent: #fbbf24; --accent-fg: #1f1300; --accent-soft: #2f2a17; --hl: #3a3215;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3); }
[data-theme=rose] { color-scheme: light;
  --bg: #fcf1f3; --surface: #ffffff; --surface-2: #fbeef1; --fg: #3a1520; --muted: #8a5b67; --line: #f1d3db;
  --accent: #be185d; --accent-fg: #ffffff; --accent-soft: #fbdbe7; --hl: #fde6c8; }
[data-theme=lavender] { color-scheme: light;
  --bg: #f4f2fe; --surface: #ffffff; --surface-2: #f1eefd; --fg: #24183f; --muted: #6f6489; --line: #e2dcf8;
  --accent: #6d28d9; --accent-fg: #ffffff; --accent-soft: #e8defd; --hl: #fdf0c4; }
[data-theme=desert] { color-scheme: light;
  --bg: #f8efe3; --surface: #fffaf3; --surface-2: #f6ead9; --fg: #3d2a1a; --muted: #8a705a; --line: #ecd8bf;
  --accent: #c2410c; --accent-fg: #ffffff; --accent-soft: #fbdcc8; --hl: #fbe5b5; }
[data-theme=graphite] { color-scheme: dark;
  --bg: #161618; --surface: #202024; --surface-2: #29292e; --fg: #ececef; --muted: #a1a1aa; --line: #34343b;
  --accent: #f97316; --accent-fg: #1c0d02; --accent-soft: #3a2614; --hl: #3f2d18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3); }
[data-theme=nord] { color-scheme: dark;
  --bg: #2e3440; --surface: #3b4252; --surface-2: #434c5e; --fg: #eceff4; --muted: #b2bacb; --line: #4c566a;
  --accent: #88c0d0; --accent-fg: #1b2230; --accent-soft: #3f5563; --hl: #5a5440;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .2); }
[data-theme=contrast] { color-scheme: dark;
  --bg: #000000; --surface: #000000; --surface-2: #111111; --fg: #ffffff; --muted: #dddddd; --line: #ffffff;
  --accent: #ffd60a; --accent-fg: #000000; --accent-soft: #3a3200; --hl: #5a4b00; --shadow: none; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--ui-font); -webkit-font-smoothing: antialiased; }
input, select, button, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; position: sticky; top: 0; z-index: 3;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 30px; height: 30px; flex: none; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

@media (max-width: 340px) { .topbar { padding-inline: 8px; gap: 2px; } .topbar .icon-btn { width: 32px; } }

/* ---------- controls ---------- */
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--fg); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; font-weight: 600; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=search], input[type=text], input[type=number], select {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-s); padding: 9px 11px; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; flex: none; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.search-box input { width: 100%; padding-inline-start: 40px; }
.small-box input { padding-top: 7px; padding-bottom: 7px; }

/* ---------- layout ---------- */
main { --main-pad: 16px; display: grid; grid-auto-flow: row dense; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 16px; padding: var(--main-pad); max-width: 1200px; margin: 0 auto; }
main > .pin, main > #found { grid-column: 1; }
main > .selection { grid-column: 2; grid-row: span 2; }
/* the cards take their width from their content (align-self: start): never wider than the column, or a long line (the ayah of
   the day's reference, which changes every day) pushes the panel out of a narrow sidebar (Google Docs: 300 px) */
main > .card { max-width: 100%; }
/* one column (Word, narrow windows): the search, the surah and the ayah numbers stay under the top bar while the rest scrolls */
body.office main, body.narrow main { --main-pad: 12px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 800px) { main { display: flex; flex-direction: column; } }
.pin { position: sticky; top: var(--topbar-h, 56px); z-index: 2; margin: calc(-1 * var(--main-pad)) calc(-1 * var(--main-pad)) 0; padding: var(--main-pad) var(--main-pad) 8px; background: var(--bg); }
.pin .card { box-shadow: 0 1px 0 var(--line), 0 6px 10px -8px rgb(0 0 0 / .25); }
@media (min-width: 801px) { body:not(.office):not(.narrow) .pin { position: static; margin: 0; padding: 0; background: none; } }
.pin-card { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; }
#found:has(#status:empty):has(#deep-note:empty):has(#results:empty):has(#marks-panel[hidden]):has(#more[hidden]) { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); align-self: start; }
.search { display: flex; flex-direction: column; gap: 10px; }
#q { font-size: 16px; padding-top: 11px; padding-bottom: 11px; }
.pick { display: flex; gap: 8px; align-items: center; }
.pick select { flex: 1; }
.range { display: flex; gap: 8px; align-items: center; }
.range-label { font-weight: 600; color: var(--muted); font-size: 13.5px; }
.range input { width: 84px; text-align: center; }
/* the arrows of the ayah numbers are our own buttons: one click = one step (the native ones kept repeating while the mouse moved) */
.range input[type=number] { -moz-appearance: textfield; appearance: textfield; padding-inline-end: 24px; }
.range input[type=number]::-webkit-inner-spin-button, .range input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.numbox { position: relative; display: inline-block; }
.numbox .arrows { position: absolute; inset-inline-end: 3px; top: 3px; bottom: 3px; width: 20px; display: flex; flex-direction: column; gap: 1px; }
.numbox .arrows button { flex: 1; min-height: 0; padding: 0; border: 0; border-radius: 5px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.numbox .arrows button:hover { background: var(--accent-soft); color: var(--accent); }
.numbox .arrows svg { width: 9px; height: 6px; stroke-width: 1.6; }
.dash { color: var(--muted); }
#status:empty { display: none; }

/* search results */
#results { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
#results:empty { display: none; }
body.office #results { max-height: 34vh; }
#results li { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
#results li:hover { border-color: var(--accent); }
#results li.active { border-color: var(--accent); background: var(--accent-soft); }
#results .ref { font-size: 12.5px; color: var(--muted); font-weight: 600; }
#results .ar { font-family: var(--ar-script, var(--ar-font)); font-size: 21px; direction: rtl; text-align: right; line-height: 1.9;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* search in every language: the fragment of the translation, the source, the progress line */
#results mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
#results .ar mark { padding: 0 2px; }
#results .hit { font-size: 13px; line-height: 1.5; margin-top: 2px; overflow-wrap: anywhere; }
#results .src { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
#results .src b { font-weight: 600; color: var(--fg); opacity: .8; }
#deep-note { margin: 0; display: flex; align-items: center; gap: 6px; }
#deep-note:empty { display: none; }
#deep-note.busy::before { content: ''; width: 10px; height: 10px; flex: none; border-radius: 50%; border: 2px solid var(--accent-soft);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #deep-note.busy::before { animation: none; } }
#more { align-self: center; margin: 2px auto 0; display: block; }
#more[hidden] { display: none; }

/* selection */
.sel-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
#sel-title { font-size: 15.5px; }
.arabic { font-family: var(--ar-script, var(--ar-font)); font-size: 27px; line-height: 2.15; text-align: justify; margin: 10px 0; }
/* words that can be chosen: the Arabic and the translations, in the panel and in the big window */
.wpick { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.wpick .w { cursor: pointer; border-radius: 6px; touch-action: none; transition: background .1s; }
.wpick .w:hover { background: var(--accent-soft); }
.wpick .w:focus { outline: none; }
.wpick .w:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wpick .w.off { opacity: .3; }
.wpick .w.start, .wpick .w.end, .wpick .w.drag { background: var(--hl); }
.wpick.dragging .w { opacity: 1; }
.wpick .num, .wpick .tnum { color: var(--accent); }
.wpick .tnum { font-size: .8em; font-weight: 600; }
.part-clear::before { content: '\00d7'; margin-inline-end: 4px; font-weight: 700; }
.pick-hint { margin: -4px 0 6px; }
.pick-hint[hidden], .preview-tr[hidden], .tr-words[hidden] { display: none; }
.tr-words { display: block; margin: -4px 0 6px; }
.preview-tr { max-height: 40vh; overflow: auto; margin: 0 0 8px; display: flex; flex-direction: column; gap: 8px; }
.trw-name { margin-bottom: 2px; }
.tr-pick { font-size: 15px; line-height: 1.75; text-align: start; overflow-wrap: break-word; }
/* the big window */
dialog.sheet.zoom { width: min(960px, calc(100% - 20px)); }
dialog.zoom .sheet-head h2 { font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
#zoom-ar { font-size: 38px; line-height: 2.3; margin: 0; }
@media (max-width: 480px) { #zoom-ar { font-size: 30px; } }
.zoom-tr { display: flex; flex-direction: column; gap: 12px; }
.zoom-tr .tr-pick { font-size: 19px; line-height: 1.8; }
.zoom-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-bottom: 12px; }
.zoom-foot .btn { min-width: 0; }
.basmala { text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
@media (max-width: 340px) { .actions .btn:not(.pic-btn) svg { display: none; } }
.actions .btn { flex: 1; min-width: 0; padding-inline: 10px; }
/* copy as a picture: an icon next to Copy */
.actions .btn.pic-btn { flex: none; padding: 9px 10px; }
/* favourite star on the ayah card */
.sel-head .star { margin-inline-start: auto; width: 34px; height: 34px; color: var(--muted); }
.sel-head .star[aria-pressed=true] { color: #e0a100; }
.sel-head .star[aria-pressed=true] svg { fill: currentColor; }
[data-theme=midnight] .sel-head .star[aria-pressed=true], [data-theme=contrast] .sel-head .star[aria-pressed=true] { color: var(--accent); }

/* history and favourites: icons in the top bar; the list opens under the search */
.topbar .icon-btn { position: relative; }
.topbar .icon-btn svg { width: 22px; height: 22px; }
.topbar .icon-btn[aria-expanded=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.topbar .icon-btn .n { position: absolute; top: 1px; inset-inline-end: 1px; min-width: 15px; padding: 0 3px; border-radius: 999px; font-size: 10px; line-height: 15px;
  font-weight: 700; text-align: center; background: var(--accent); color: var(--accent-fg); pointer-events: none; }
.topbar .icon-btn .n:empty { display: none; }
#again:disabled { opacity: .4; cursor: default; }
.marks-panel { scroll-margin-top: calc(var(--topbar-h, 56px) + var(--pin-h, 150px) + 8px); }
.marks-panel { margin-top: 8px; }
#marks-list { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
body.office #marks-list { max-height: 30vh; }
#marks-list:empty { display: none; }
#marks-list li { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
#marks-list li:hover { border-color: var(--accent); }
.mk-go { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; text-align: start; border: 0; background: none; padding: 6px 10px; cursor: pointer; border-radius: var(--radius-s); }
.mk-ref { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.mk-time { font-weight: 400; }
.mk-ar { font-family: var(--ar-font); font-size: 18px; line-height: 1.7; direction: rtl; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-del { width: 30px; height: 30px; color: var(--muted); margin-inline-end: 4px; }
.mk-del svg { width: 16px; height: 16px; }
.marks-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 2px 0; }
.marks-foot:has(#marks-empty:empty) { justify-content: flex-end; }

/* ayah of the day (top of the panel) */
.votd { grid-column: 1 / -1; padding: 12px 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface) 65%); }
.votd-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.votd-head > svg { color: var(--accent); width: 18px; height: 18px; }
.votd-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.votd-head bdi { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.votd-head .icon-btn { width: 30px; height: 30px; margin: -4px -6px -4px 0; color: var(--muted); }
.votd-head .icon-btn svg { width: 16px; height: 16px; }
.votd-ar { font-family: var(--ar-script, var(--ar-font)); font-size: 23px; line-height: 2; text-align: justify; margin: 6px 0 2px; }
.votd-tr p { margin: 4px 0; font-size: 13.5px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.votd-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; flex-wrap: wrap; }
.votd-actions .btn { padding: 6px 14px; font-size: 13.5px; }

.note { background: var(--hl); padding: 8px 10px; border-radius: var(--radius-s); margin: 8px 0; }
.author { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 10px; }
.author a { color: inherit; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 8px); background: var(--fg); color: var(--bg);
  padding: 9px 16px; border-radius: 999px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; font-weight: 600; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- dialogs (sheets) ---------- */
dialog.sheet { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--fg); padding: 0;
  width: min(560px, calc(100% - 20px)); max-height: calc(100% - 20px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog.sheet::backdrop { background: rgba(10, 12, 16, .45); backdrop-filter: blur(2px); }
dialog.sheet form { display: flex; flex-direction: column; max-height: calc(100vh - 20px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px 18px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-body { padding: 8px 18px 14px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.sheet-foot { padding: 10px 18px 4px; border-top: 1px solid var(--line); }
.sheet-foot .author { margin: 8px 0 6px; }
footer.author .app-version { white-space: nowrap; }
/* Updates window */
#updates h3 { margin: 0 0 6px; font-size: 15px; }
.upd-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.upd-status { flex: 1; margin: 0; min-width: 160px; }
.upd-status.new { font-weight: 600; color: var(--accent); }
.upd-local p { margin: 6px 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upd-local a.btn { text-decoration: none; color: inherit; }
.upd-news .rel { border-top: 1px solid var(--line); padding: 8px 0; }
.upd-news .rel:first-child { border-top: 0; padding-top: 0; }
.upd-news .rel b { display: flex; gap: 8px; align-items: baseline; }
.upd-news .ver { background: var(--accent); color: var(--accent-fg); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.upd-news .date { margin-inline-start: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.upd-news ul { margin: 6px 0 0; padding-inline-start: 18px; font-size: 13px; } .upd-news li { margin: 3px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 4px 18px 6px; background: var(--surface-2); border-radius: 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 1 auto; border: 0; background: none; color: var(--muted); padding: 7px 9px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.tab { display: flex; flex-direction: column; gap: 12px; }
.tab h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13.5px; }
.field > span { color: var(--muted); }
.field select { font-weight: 400; font-size: 15px; }

/* switches */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
[dir=rtl] .switch input:checked + i::after { transform: translateX(-16px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch bdi, .switch .muted { font-size: 13px; }
/* Insert tab: grouped rows — label, a sample of what is inserted, the switch at the end */
.opt-group { background: var(--surface-2); border-radius: var(--radius); padding: 4px 14px; margin: 0 0 12px; }
.opt-group h3 { margin: 10px 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.switch.opt { padding: 10px 0; border-top: 1px solid var(--line); }
.switch.opt:first-of-type { border-top: 0; }
.switch.opt > span:first-child { flex: 1; }
.switch.opt .sample { padding: 1px 8px; border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 13px; white-space: nowrap; }
.switch.opt .sample.ar { font-family: 'QuranUz Arabic', 'Scheherazade New', serif; font-size: 17px; line-height: 1.3; color: var(--accent); }
.switch.opt.disabled { opacity: .45; pointer-events: none; }

/* translation / tafsir lists */
.checklist { border: 1px solid var(--line); border-radius: var(--radius-s); max-height: 46vh; overflow: auto; padding: 4px; }
.checklist.off { opacity: .55; }
.checklist .grp { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 8px 4px; }
.checklist label { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.checklist label:has(input:checked) { background: var(--accent-soft); }
.checklist label span:first-of-type { flex: 1; min-width: 0; }
.checklist label .lang { color: var(--muted); font-size: 12px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* fonts tab */
.fontrow { display: flex; gap: 8px; align-items: center; }
.fontrow > span { flex: 0 1 6.2em; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.fontrow input[type=text] { flex: 1; }
.fontrow input[type=number] { width: 4.8em; text-align: center; }

/* theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme { border: 2px solid var(--line); border-radius: 12px; padding: 0; overflow: hidden; cursor: pointer; background: none; text-align: start; font-weight: 600; font-size: 12.5px; }
.theme[aria-checked=true] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme .sw { display: flex; height: 38px; }
.theme .sw b { flex: 1; }
.theme .sw b:first-child { flex: 2; }
.theme .nm { display: block; padding: 5px 8px; background: var(--surface); color: var(--fg); line-height: 1.25; overflow-wrap: anywhere; }

/* surah info */
.info-body h2, .info-body h3 { font-size: 16px; }

/* ---------- first-run welcome screen ---------- */
#welcome { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 22%, var(--bg)), var(--bg) 70%);
  opacity: 0; transition: opacity .35s ease; }
#welcome.show { opacity: 1; }
#welcome.hide { opacity: 0; pointer-events: none; }
.welcome-card { width: min(440px, 100%); text-align: center; }
.welcome-logo { animation: welcome-pop .9s cubic-bezier(.2, .9, .3, 1.3) both, welcome-glow 3s ease-in-out .9s infinite; }
.welcome-card h1 { margin: 14px 0 4px; font-size: 28px; letter-spacing: -.02em; animation: welcome-up .6s .25s both; }
@font-face { font-family: 'Reem Kufi Ink'; src: url('fonts/ReemKufiInk-Arabic.woff2') format('woff2'); font-weight: 400; font-display: swap; }   /* OFL, fonts/ReemKufiInk-OFL.txt */
.welcome-ar { font-family: 'Reem Kufi Ink', var(--ar-font); font-size: 34px; line-height: 1.35; margin: -2px 0 8px; color: var(--accent); animation: welcome-up .6s .3s both; }
.welcome-sub { color: var(--muted); margin: 0 0 18px; line-height: 1.6; animation: welcome-up .6s .35s both; }
.welcome-langs { display: grid; gap: 8px; }
.welcome-lang { font-size: 16px; padding: 12px 16px; animation: welcome-up .5s both; }
.welcome-langs .welcome-lang:nth-child(1) { animation-delay: .45s; } .welcome-langs .welcome-lang:nth-child(2) { animation-delay: .52s; }
.welcome-langs .welcome-lang:nth-child(3) { animation-delay: .59s; } .welcome-langs .welcome-lang:nth-child(4) { animation-delay: .66s; }
.welcome-langs .welcome-lang:nth-child(5) { animation-delay: .73s; }
.welcome-lang:hover { border-color: var(--accent); background: var(--accent-soft); }
.welcome-more { margin-top: 14px; animation: welcome-up .5s .8s both; }
.welcome-other { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-top: 12px; }
.small-lang { font-size: 14px; padding: 8px 10px; animation: welcome-up .3s both; }
@keyframes welcome-pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes welcome-up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes welcome-glow { 50% { filter: drop-shadow(0 0 12px color-mix(in srgb, #f2c14e 55%, transparent)); } }
@media (prefers-reduced-motion: reduce) { #welcome *, #welcome { animation: none !important; transition: none !important; } }

/* ---------- Format tab ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chips button[aria-selected=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.fmt-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.fmt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fmt-row #f-font { flex: 1 1 140px; } .fmt-row #f-size { width: 5.2em; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--fg); min-width: 38px; height: 36px; cursor: pointer; display: grid; place-items: center; font-size: 15px; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); }
.seg svg { width: 18px; height: 18px; }
.swatch { position: relative; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; cursor: pointer; flex: none; }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.swatch span { display: block; width: 100%; height: 100%; }
.swatch span.auto { background: conic-gradient(var(--fg) 0 25%, var(--surface) 0 50%, var(--fg) 0 75%, var(--surface) 0) 0 0 / 12px 12px; opacity: .35; }
.line-sel { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin-inline-start: auto; }
.fmt-preview { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 8px 12px; max-height: 220px; overflow: auto; }
.fmt-preview p { margin: 4px 0; }
.fmt-preview .arabic { font-size: 22px; margin: 0; }

/* picture background colour (settings → Insert) */
input[type=color].sample { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line, #8884); border-radius: 4px; background: none; cursor: pointer; }

/* The logo has no background of its own: on dark themes (navy on dark) it gets a thin light outline */
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .logo, :root:not([data-theme]) .welcome-logo { filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); } }
[data-theme=dark] .logo, [data-theme=forest] .logo, [data-theme=graphite] .logo, [data-theme=midnight] .logo, [data-theme=nord] .logo, [data-theme=contrast] .logo,
[data-theme=dark] .welcome-logo, [data-theme=forest] .welcome-logo, [data-theme=graphite] .welcome-logo, [data-theme=midnight] .welcome-logo,
[data-theme=nord] .welcome-logo, [data-theme=contrast] .welcome-logo { filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }

/* 3.11: toast button, translation chips, "More" menu, basket */
#toast .toast-act { margin-inline-start: 12px; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; pointer-events: auto; }
#toast.show:has(.toast-act) { pointer-events: auto; }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.tchips[hidden] { display: none; }
.tchip { max-width: 100%; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tchip.off { background: none; border-color: var(--line); color: var(--muted); text-decoration: line-through; }
.tchip.bad { border-color: #c0392b; color: #c0392b; background: color-mix(in srgb, #c0392b 10%, var(--surface)); }
.menu { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); margin: 4px 0 8px; overflow: hidden; }
.menu[hidden] { display: none; }
.menu button { text-align: start; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--fg); padding: 9px 12px; cursor: pointer; font: inherit; }
.menu button:last-child { border-bottom: 0; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button[hidden] { display: none; }
.sel-head #next, .sel-head #more-btn { width: 34px; height: 34px; }
.sel-head #next svg { transform: scaleX(var(--dir-flip, 1)); }
[dir=rtl] .sel-head #next svg { transform: scaleX(-1); }
.sel-head .star { margin-inline-start: 0; }
.sel-head strong { margin-inline-end: auto; }
.bask-acts { display: flex; gap: 8px; margin: 8px 0 0; }
.bask-acts[hidden] { display: none; }
.bask-acts .btn { flex: 1; min-width: 0; }
.actions.col { flex-direction: column; }
.actions.col .btn { flex: none; }
.sel-head { align-items: center; gap: 4px; }

.quote-in { width: 100%; box-sizing: border-box; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius-s); padding: 9px 11px; font-family: var(--ar-font); font-size: 20px; line-height: 1.8; resize: vertical; }
.quote-out { font-family: var(--ar-font); font-size: 20px; line-height: 1.9; direction: rtl; text-align: right; }
.quote-out .verdict { font-family: var(--ui-font); font-size: 14px; direction: inherit; text-align: start; margin-bottom: 6px; font-weight: 600; }
.quote-out .ok { color: var(--accent); }
.quote-out del { color: #c0392b; text-decoration: line-through; background: color-mix(in srgb, #c0392b 12%, transparent); }
.quote-out ins { text-decoration: underline wavy #d68910; background: color-mix(in srgb, #d68910 14%, transparent); }

/* live search: a button at the end of the search box */
.search-box .live-btn { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.search-box .live-btn:hover { background: var(--surface-2); }
.search-box .live-btn[aria-pressed=true] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.search-box input { padding-inline-end: 44px; }
.search-box .live-btn svg { position: static; color: inherit; }

/* the add-in's ribbon (manifest) is out of date */
.ribbon-note { display: flex; align-items: center; gap: 6px; margin: 8px 12px 0; padding: 8px 10px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--fg); border-radius: var(--radius-s); font-size: 13px; line-height: 1.4; }
.ribbon-note[hidden] { display: none; }
.ribbon-note > span { flex: 1; min-width: 0; }
.ribbon-note a { font-weight: 700; white-space: nowrap; }
.ribbon-note .icon-btn { width: 28px; height: 28px; }

/* the public counter in the footer */
.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 14px 12px 0; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.stats[hidden] { display: none; }
.stats .st { display: inline-flex; align-items: center; gap: 6px; }
.stats .st svg { width: 16px; height: 16px; color: var(--accent); }
.stats b { color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; }
.stats .sep { color: var(--line); }
@media (max-width: 420px) { .stats .sep { display: none; } .stats { gap: 4px 14px; } }

/* ---------- the picture of "Copy as a picture" (#qp-dlg): a preview, the style, the parts, the size ---------- */
/* the body scrolls on small screens: a shadow at its top / bottom edge shows that there is more (scroll shadows) */
dialog.sheet.qp .sheet-body { gap: 10px;
  background: linear-gradient(var(--surface) 30%, transparent) top / 100% 28px no-repeat local,
    linear-gradient(transparent, var(--surface) 70%) bottom / 100% 28px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgb(0 0 0 / .22), transparent) top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgb(0 0 0 / .22), transparent) bottom / 100% 12px no-repeat scroll, var(--surface); }
.qp-view { flex: none; display: grid; place-items: center; min-height: 120px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); }
.qp-view > * { grid-area: 1 / 1; }
.qp-view canvas { display: block; max-width: 100%; max-height: min(42vh, 340px); width: auto; height: auto; box-shadow: 0 1px 4px rgb(0 0 0 / .18); transition: opacity .15s; }
@media (max-height: 760px) { .qp-view canvas { max-height: 30vh; } .qp-view { min-height: 96px; } }
.qp-view.clear canvas { background: repeating-conic-gradient(#e4e4e4 0 25%, #ffffff 0 50%) 0 0 / 14px 14px; }
.qp-view[data-state=busy] canvas { opacity: .5; }
.qp-view[data-state=error] canvas { display: none; }
/* the state under / over the preview: "Loading…", or why there is no picture (read out: role=status) */
.qp-msg { margin: 0; max-width: 100%; padding: 0 6px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.qp-msg:empty { display: none; }
.qp-view[data-state=busy] .qp-msg { padding: 4px 10px; border-radius: 999px; background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / .18); }
.qp-msg.err { padding: 10px 12px; border-radius: 8px; background: var(--hl); }
.qp fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.qp legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.qp-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.qp-choices legend { grid-column: 1 / -1; }
.qp-choices label { position: relative; cursor: pointer; min-width: 0; }
.qp-choices input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.qp-choices span { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--surface); font-size: 13.5px; overflow-wrap: anywhere; }
.qp-choices b { font-weight: 600; }
.qp-choices small { color: var(--muted); font-size: 11.5px; }
.qp-choices input:checked + span small { color: var(--fg); }      /* contrast: --muted on --accent-soft is under 4.5:1 */
.qp-sizes span { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.qp-choices input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.qp-choices input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.qp-choices input:disabled + span { opacity: .45; cursor: default; }
.qp-opts .switch.off { opacity: .45; cursor: default; }
.qp-opts { display: flex; flex-direction: column; gap: 2px; }
.qp-sw { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1px solid rgb(0 0 0 / .18); }
.qp-sw.green { background: #2E8B48; box-shadow: inset 0 0 0 3px #E04B5A; }
.qp-sw.gold { background: #FAF1E2; box-shadow: inset 0 0 0 3px #8A6638; }
.qp-sw.plain { background: #ffffff; }
.qp-sw.clear { background: repeating-conic-gradient(#cccccc 0 25%, #ffffff 0 50%) 0 0 / 8px 8px; }
.qp-foot { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.qp-foot .btn { flex: 1 1 auto; min-width: 0; }
.qp-foot .btn:disabled { opacity: .45; cursor: default; filter: none; }
