/* Fonts are bundled (SIL Open Font License, see fonts/): the app works offline and loads nothing from third parties. */
@font-face { font-family: "Scheherazade New"; font-weight: 400; font-display: swap; src: url(fonts/scheherazade-new-arabic-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Scheherazade New"; font-weight: 700; font-display: swap; src: url(fonts/scheherazade-new-arabic-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/newsreader-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/newsreader-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/newsreader-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 400; font-display: swap; src: url(fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-display: swap; src: url(fonts/instrument-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-display: swap; src: url(fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); }

/* Layout: one narrow reading column; the verse is the hero of every screen, actions sit in a bottom bar under the thumb. */
:root {
  --bg: #F4F6F3; --surface: #FFFFFF; --sunk: #E9EEEA; --ink: #17221E; --muted: #5C6A64; --line: #D5DDD8;
  --accent: #0F6B5D; --accent-ink: #FFFFFF; --accent-soft: #DCEDE8;
  --miss: #B4462F; --miss-soft: #F6E1DA; --good: #2D7A4D; --good-soft: #DDEFE3; --gold: #A8741E;
  --f-ar: "Scheherazade New", "Amiri", "Noto Naskh Arabic", "Geeza Pro", serif;
  --f-read: "Newsreader", Georgia, "Times New Roman", serif;
  --f-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1412; --surface: #16201D; --sunk: #1D2925; --ink: #E5ECE8; --muted: #98A7A0; --line: #2A3833;
  --accent: #4DBBA4; --accent-ink: #0B1513; --accent-soft: #1C3530;
  --miss: #E5826A; --miss-soft: #3A2620; --good: #6CC28D; --good-soft: #1D3326; --gold: #D9A54A; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1412; --surface: #16201D; --sunk: #1D2925; --ink: #E5ECE8; --muted: #98A7A0; --line: #2A3833;
  --accent: #4DBBA4; --accent-ink: #0B1513; --accent-soft: #1C3530;
  --miss: #E5826A; --miss-soft: #3A2620; --good: #6CC28D; --good-soft: #1D3326; --gold: #D9A54A; color-scheme: dark }

[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 18px 120px; display: flex; flex-direction: column; gap: 22px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .chunk:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 11px 18px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; }
.iconbtn { border: 0; background: transparent; padding: 8px; border-radius: 999px; font-size: 20px; line-height: 1; color: var(--muted); }

/* home */
.top { display: flex; align-items: baseline; gap: 12px; }
.brand { font-family: var(--f-read); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.brand-ar { font-family: var(--f-ar); font-size: 26px; color: var(--accent); margin-inline-start: auto; }
.today { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; font-family: var(--f-read); font-weight: 600; }
.stat span { font-size: 12.5px; color: var(--muted); }
.preview { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.preview .ar { font-family: var(--f-ar); font-size: 24px; direction: rtl; text-align: right; line-height: 1.9; }
.preview .fr { font-family: var(--f-read); font-style: italic; color: var(--muted); }
.sync { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); }

.surahs { display: flex; flex-direction: column; }
.surah { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.surah .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; text-align: right; }
.surah .names { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.surah .nm { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.surah .tr { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah .frn { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.surah .arn { font-family: var(--f-ar); font-size: 20px; margin-inline-start: auto; flex: none; }
.bar { height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .m { background: var(--accent); }
.bar .l { background: var(--accent-soft); }
.surah .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.surah.current .num { color: var(--accent); font-weight: 600; }

.settings { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* session */
.sbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding-block: 6px; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.prog { flex: 1; height: 4px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kind { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.kind.new { background: var(--accent-soft); color: var(--accent); }
.kind.fix { background: var(--miss-soft); color: var(--miss); }
.ref { font-size: 13px; color: var(--muted); }

.prev { font-family: var(--f-ar); font-size: 19px; direction: rtl; text-align: right; color: var(--muted); opacity: .7; line-height: 1.8; }
.verse { direction: rtl; display: flex; flex-wrap: wrap; gap: 8px 6px; align-items: flex-start; justify-content: flex-start; }
.chunk { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 8px 6px; border-radius: 10px; border: 1px solid transparent; background: transparent; max-width: 100%; }
.chunk .a { font-family: var(--f-ar); font-size: 30px; line-height: 1.6; }
.chunk .g { direction: ltr; font-family: var(--f-read); font-size: 14px; color: var(--muted); text-align: center; line-height: 1.25; max-width: 15em; }
.verse.hideg .chunk .g { display: none; }
.chunk.tap { border-color: var(--line); background: var(--surface); }
.chunk.tap:hover { border-color: var(--accent); }
.chunk.target { border-color: var(--accent); background: var(--accent-soft); }
.chunk.missed { border-color: var(--miss); background: var(--miss-soft); }
.chunk.missed .g { color: var(--miss); }
.chunk.right { border-color: var(--good); background: var(--good-soft); }
.chunk.known .g::after { content: " ✓"; color: var(--good); }
.vnum { font-family: var(--f-ar); color: var(--gold); font-size: 24px; align-self: center; }
.trans { font-family: var(--f-read); font-size: 18px; line-height: 1.55; border-inline-start: 3px solid var(--accent-soft); padding-inline-start: 14px; }
.hint { font-size: 14px; color: var(--muted); }
.question { font-family: var(--f-read); font-size: 17px; }
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 13px 15px; font-family: var(--f-read); font-size: 16.5px; display: flex; gap: 12px; align-items: baseline; }
.opt kbd { font-family: var(--f-ui); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; flex: none; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--miss); background: var(--miss-soft); }
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.actions .in { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.actions .in .note { margin-inline-end: auto; font-size: 13px; color: var(--muted); }

/* reading */
.rhead { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding-block: 8px 4px; }
.rhead .arn { font-family: var(--f-ar); font-size: 40px; color: var(--accent); line-height: 1.4; }
.rhead .tr { font-family: var(--f-read); font-size: 20px; font-weight: 600; }
.rverse { display: flex; flex-direction: column; gap: 8px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.rverse .tools { display: flex; gap: 8px; justify-content: flex-start; }
.rverse .chunk.hes { box-shadow: inset 0 -2px 0 var(--gold); }

.done { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; padding-top: 30px; }
.done .big { font-family: var(--f-read); font-size: 30px; font-weight: 600; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 420px) { .chunk .a { font-size: 27px; } .brand { font-size: 22px; } }

/* standalone page shell */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; }
body { margin: 0; -webkit-text-size-adjust: 100%; }
.langbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; }
.top .langbtn { margin-inline-start: 8px; align-self: center; }

/* sign-in, licence, loading */
.gate { max-width: 440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 40px 60px; display: flex; flex-direction: column; gap: 18px; }
.gate .mark { display: flex; align-items: center; gap: 12px; }
.gate .mark img { width: 44px; height: 44px; border-radius: 11px; }
.gate h1 { font-family: var(--f-read); font-size: 28px; font-weight: 600; }
.gate .lead { font-family: var(--f-read); font-size: 17px; color: var(--muted); margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input { font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field input.code { letter-spacing: .4em; font-variant-numeric: tabular-nums; text-align: center; font-size: 22px; }
.field input.key { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .03em; }
.msg { font-size: 14px; padding: 10px 12px; border-radius: 10px; }
.msg.err { background: var(--miss-soft); color: var(--miss); }
.msg.ok { background: var(--good-soft); color: var(--good); }
.linkbtn { border: 0; background: transparent; color: var(--accent); padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.gate .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--sunk); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.acct { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct .em { font-weight: 600; overflow-wrap: anywhere; }
