/* Kun Talib Ilm — lapis ink and illumination gold, after the colours of manuscript muṣḥafs.
   Layout: one centred column (max 1120px), cards only where a thing is a separate object. */
:root {
  --paper: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --ink: #142033;
  --muted: #5b6779;
  --line: #d9e0ea;
  --lapis: #1d3f73;
  --lapis-2: #2f5ea3;
  --gold: #b9842c;
  --gold-soft: #f3e6cc;
  --ok: #23774a;
  --ok-bg: #e2f2e8;
  --warn: #93600b;
  --warn-bg: #fbefd6;
  --bad: #b13c33;
  --bad-bg: #f8e1df;
  --mark: #f6dfa8;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 8px 24px rgba(20, 32, 51, .06);
  --display: 'Reem Kufi', 'Figtree', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --naskh: 'Noto Naskh Arabic', 'Amiri', 'Traditional Arabic', serif;
  --quran: 'Amiri Quran', 'Noto Naskh Arabic', serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1420; --panel: #152033; --panel-2: #1b2940; --ink: #e8edf5; --muted: #9aa8bc; --line: #26354d;
    --lapis: #8fb3ec; --lapis-2: #a9c5f2; --gold: #dcae5c; --gold-soft: #3a2f1b;
    --ok: #6fcf97; --ok-bg: #173527; --warn: #e7b65a; --warn-bg: #3a2c12; --bad: #ee8a80; --bad-bg: #3d1d1b; --mark: #5a4718;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1420; --panel: #152033; --panel-2: #1b2940; --ink: #e8edf5; --muted: #9aa8bc; --line: #26354d;
  --lapis: #8fb3ec; --lapis-2: #a9c5f2; --gold: #dcae5c; --gold-soft: #3a2f1b;
  --ok: #6fcf97; --ok-bg: #173527; --warn: #e7b65a; --warn-bg: #3a2c12; --bad: #ee8a80; --bad-bg: #3d1d1b; --mark: #5a4718;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--body); padding-top: env(safe-area-inset-top, 0px); }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--lapis-2); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; margin: 0 0 .4em; }
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.3rem, 2.2vw, 1.65rem); }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .8em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
code { font: .95em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: .15em .45em; border-radius: 6px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ar { font-family: var(--naskh); }
.quran { font-family: var(--quran); }
.soft { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 700; margin-bottom: .4rem; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; justify-content: center; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* Layout */
#view { max-width: 1120px; margin: 0 auto; padding-block: 1.5rem 3rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); min-height: 70vh; }
.narrow { max-width: 720px; margin-inline: auto; }
.narrow-pad { display: block; max-width: 720px; margin: 0 auto .5rem; }

/* Header */
#top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--paper); }
.top-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding-block: .6rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); margin-inline-end: auto; }
.mark rect { fill: var(--lapis); }
.mark .core { fill: var(--gold); }
.brand-words { display: flex; flex-direction: column; line-height: 1.1; }
.b-ar { font-family: var(--naskh); font-weight: 700; font-size: 1.1rem; }
.b-en { font-family: var(--display); font-size: .78rem; letter-spacing: .08em; color: var(--muted); }
.links { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.links a { text-decoration: none; color: var(--ink); padding: .45rem .7rem; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.links a:hover { background: var(--panel-2); }
.links a.on { color: var(--lapis-2); background: var(--panel-2); }
.pill { border: 1px solid var(--line); }
.menu-btn { display: none; background: none; border: 0; width: 42px; height: 42px; padding: 10px; cursor: pointer; flex-direction: column; justify-content: space-between; }
.menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 2px; }
@media (max-width: 760px) {
  .menu-btn { display: flex; }
  .links { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--panel); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: .5rem max(16px, env(safe-area-inset-right, 0px)) 1rem max(16px, env(safe-area-inset-left, 0px)); box-shadow: var(--shadow); }
  .links.open { display: flex; }
  .links a { padding: .75rem .8rem; }
}

/* Footer */
#foot { border-top: 1px solid var(--line); background: var(--panel); }
.foot-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding-block: 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); font-size: .9rem; }
.foot-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* Buttons and chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 600 .95rem/1 var(--body); padding: .75rem 1.1rem; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--lapis-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--lapis); border-color: var(--lapis); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0d1420; } }
:root[data-theme="dark"] .btn.primary { color: #0d1420; }
.btn.primary:hover { background: var(--lapis-2); border-color: var(--lapis-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: .5rem .8rem; font-size: .85rem; }
.btn.big { padding: .95rem 1.4rem; font-size: 1.02rem; }
.btn.full { width: 100%; }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; margin-bottom: 1rem; }
.q-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1.1rem, 3vw, 1.8rem); box-shadow: var(--shadow); margin-bottom: 1rem; }
.callout { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); background: linear-gradient(0deg, var(--panel), var(--panel)) padding-box; }
.callout.good { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 3rem 0; justify-content: center; }
.loading .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; transform: scale(.8); } to { opacity: 1; transform: scale(1.1); } }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); }
#toasts { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: .5rem; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--paper); padding: .75rem 1rem; border-radius: 10px; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Forms */
.field { display: grid; gap: .3rem; margin-bottom: .9rem; min-width: 0; flex: 1 1 180px; }
.field label { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; accent-color: var(--lapis); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lapis-2); outline-offset: 0; border-color: transparent; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.inline-form .field { margin-bottom: 0; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .8rem; }

/* Auth */
.auth { display: grid; place-items: center; padding: 2rem 0; }
.auth .card { width: min(100%, 440px); padding: 2rem; box-shadow: var(--shadow); text-align: start; }
.auth .mark { margin-bottom: .6rem; }

/* Landing */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2.5rem; align-items: center; padding: 2rem 0 3rem; }
.hero-text { min-width: 0; }
.hero-ar { font-family: var(--naskh); font-weight: 700; font-size: clamp(3rem, 8vw, 5.6rem); line-height: 1.15; margin: 0; color: var(--lapis); text-align: start; }
.hero-en { font-family: var(--display); font-size: 1.15rem; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: .2rem 0 1rem; }
.lede { font-size: 1.2rem; max-width: 34ch; }
.demo { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; box-shadow: var(--shadow); position: relative; min-width: 0; }
.demo::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--gold-soft); border-radius: 11px; pointer-events: none; }
.band { padding: 2.5rem 0; border-top: 1px solid var(--line); }
.step-list { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem; counter-reset: s; }
.step-list li { counter-increment: s; padding-top: 2.6rem; position: relative; }
.step-list li::before { content: counter(s); position: absolute; top: 0; inset-inline-start: 0; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-family: var(--display); font-weight: 700; }
.path { display: grid; gap: .6rem; margin-top: 1rem; }
.path-item { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: inherit; text-decoration: none; }
.path-item.link:hover { border-color: var(--lapis-2); }
.path-item.locked { opacity: .85; }
.path-item h3 { margin: 0 0 .2rem; }
.path-item p { margin: 0; }
.path-n { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; color: var(--lapis); border: 2px solid var(--lapis); }
.path-n.done { background: var(--ok); border-color: var(--ok); color: var(--paper); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; display: flex; flex-direction: column; gap: .5rem; position: relative; }
.plan.featured { border: 2px solid var(--gold); box-shadow: var(--shadow); }
.plan .tag { position: absolute; top: -.75rem; inset-inline-start: 1.2rem; background: var(--gold); color: var(--paper); font-size: .75rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; }
.plan .price strong { font-family: var(--display); font-size: 2rem; color: var(--lapis); }
.plan ul { padding-inline-start: 1.1rem; margin: 0 0 auto; color: var(--muted); }
.plan ul li { margin-bottom: .35rem; }
.plan .btn, .plan .chip { margin-top: .8rem; align-self: flex-start; }
.notes { margin-top: 1rem; }
.note { background: var(--gold-soft); border-radius: var(--r); padding: .8rem 1rem; }
.circles { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-top: 1rem; }
.circle { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem; }
.circle dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .9rem; margin: .5rem 0 1rem; }
.circle dt { color: var(--muted); }
.circle dd { margin: 0; }
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; }
.big-ar { font-size: 1.4rem; text-align: start; }
.ijazat ul { padding-inline-start: 1.1rem; }
.cta-band { text-align: center; }
@media (max-width: 820px) { .hero, .about { grid-template-columns: 1fr; } .hero { padding-top: 1rem; } }

/* Dashboard */
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem 1rem; min-width: 110px; }
.stat strong { display: block; font-family: var(--display); font-size: 1.6rem; color: var(--lapis); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.block { margin-top: 2rem; }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.bar.thin { height: 5px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--lapis), var(--gold)); border-radius: 99px; transition: width .4s; }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; gap: .7rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.board li.me { color: var(--lapis-2); font-weight: 600; }
.rank { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.board li:nth-child(1) .rank { background: var(--gold); color: var(--paper); }
.plain { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .6rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.level-row { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.level-row h2 { margin: 0; }
.level-row p { margin: 0; }
.level-n { flex: none; width: 3.4rem; height: 3.4rem; border-radius: 12px; background: var(--lapis); color: var(--paper); display: grid; place-items: center; font-family: var(--display); font-size: 1.8rem; font-weight: 700; }

/* Exercise cards */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; margin-top: 1rem; }
.ex-card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.ex-card:hover { border-color: var(--lapis-2); transform: translateY(-2px); }
.ex-card.locked { background: var(--panel-2); }
.ex-card h3 { margin: .4rem 0 0; }
.ex-card .ar { margin: 0 0 .4rem; }
.ex-card p { margin: 0 0 .5rem; }
.ex-top { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.kind { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); font-weight: 700; margin-inline-end: auto; }
.best { font-size: .82rem; font-weight: 600; color: var(--muted); margin-top: auto !important; }
.best.good { color: var(--ok); }
.sec-head { margin-bottom: 1.2rem; }
.backlink { display: inline-block; text-decoration: none; color: var(--muted); font-size: .9rem; margin-bottom: .6rem; }
.materials { padding-inline-start: 1.1rem; }
.materials li { margin-bottom: .4rem; }

/* Player */
.play-head { margin-bottom: 1rem; }
.play-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.q-text { font-size: 1.1rem; font-weight: 600; }
.q-text.ar { font-size: 1.3rem; }
.big { font-size: clamp(2.6rem, 9vw, 4.2rem); text-align: center; padding: .6rem 0 1rem; line-height: 1.5; }
.big.ar { font-family: var(--naskh); }
.verse-box { margin: .4rem 0 1.2rem; padding: 1rem 1.2rem; background: var(--panel-2); border-radius: 12px; border-right: 3px solid var(--gold); }
.verse { font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 2.1; text-align: right; margin: 0; }
.verse mark { background: var(--mark); color: inherit; border-radius: 6px; padding: 0 .15em; }
.verse-box figcaption { margin-top: .4rem; font-family: var(--naskh); font-size: .9rem; color: var(--muted); text-align: start; }
.poem { font-size: 1.45rem; line-height: 2; text-align: center; background: var(--panel-2); padding: 1rem; border-radius: 12px; white-space: pre-wrap; }
.opts { display: grid; gap: .55rem; }
.opts.opts-ar { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.opt { display: flex; align-items: center; gap: .8rem; text-align: start; width: 100%; padding: .8rem 1rem; font: 500 1rem/1.4 var(--body); color: var(--ink); background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s; }
.opt:hover:not(:disabled) { border-color: var(--lapis-2); }
.opt .key { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); font-size: .8rem; font-weight: 700; color: var(--muted); }
.opt .ar { font-size: 1.35rem; }
.opt .quran { font-size: 1.35rem; line-height: 2; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; }
.opts.compact .opt { padding: .6rem .8rem; font-size: .92rem; }
.feedback { margin-top: 1rem; }
.verdict { font-weight: 700; margin-bottom: .3rem; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.why { color: var(--muted); }
.why.ar { font-size: 1.3rem; color: var(--ink); }
.flash { display: block; width: 100%; max-width: 440px; margin: 0 auto 1rem; min-height: 230px; background: none; border: 0; padding: 0; perspective: 1000px; cursor: pointer; position: relative; font: inherit; color: inherit; }
.face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1.2rem; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel); backface-visibility: hidden; transition: transform .45s; }
.face .ar { font-size: clamp(2rem, 7vw, 3rem); line-height: 1.5; }
.face small { color: var(--muted); }
.face strong { font-size: 1.4rem; text-align: center; }
.back.face, .face.back { transform: rotateY(180deg); background: var(--panel-2); }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0); }
.card-actions { display: flex; justify-content: center; gap: .6rem; margin-bottom: .6rem; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: .8rem; }
.col { display: grid; gap: .5rem; align-content: start; min-width: 0; }
.tile { padding: .75rem .8rem; border: 1.5px solid var(--line); background: var(--panel); border-radius: 10px; font: 500 .95rem/1.35 var(--body); color: var(--ink); cursor: pointer; text-align: center; min-height: 3.2rem; }
.tile .ar { font-size: 1.3rem; }
.tile.sel { border-color: var(--lapis-2); background: var(--panel-2); }
.tile.done { border-color: var(--ok); background: var(--ok-bg); opacity: .75; cursor: default; }
.shake { animation: shake .4s; border-color: var(--bad) !important; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.tokens { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 3.4rem; padding: .7rem; border-radius: 10px; margin-bottom: .8rem; }
.tokens.answer { border: 1.5px dashed var(--line); background: var(--panel-2); align-items: center; }
.tokens.answer.right { border-color: var(--ok); border-style: solid; }
.tokens.answer.wrong { border-color: var(--bad); border-style: solid; }
.tokens.list { flex-direction: column; align-items: stretch; }
.token { padding: .55rem .85rem; border-radius: 8px; border: 1.5px solid var(--line); background: var(--panel); font: 500 .95rem var(--body); color: var(--ink); cursor: pointer; text-align: start; }
.token.ar { font-family: var(--naskh); font-size: 1.35rem; padding: .3rem .8rem; }
.placeholder { color: var(--muted); font-size: .9rem; }
.surah-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.surah-pick .tile { display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.num { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.result { text-align: center; }
.score-ring { --p: 0; width: 140px; height: 140px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-content: center; background: radial-gradient(closest-side, var(--panel) 78%, transparent 79% 100%), conic-gradient(var(--warn) calc(var(--p) * 1%), var(--panel-2) 0); }
.score-ring.good { background: radial-gradient(closest-side, var(--panel) 78%, transparent 79% 100%), conic-gradient(var(--ok) calc(var(--p) * 1%), var(--panel-2) 0); }
.score-ring strong { font-family: var(--display); font-size: 2rem; line-height: 1; }
.score-ring span { font-size: .8rem; color: var(--muted); }
.missed { text-align: start; margin: 1rem 0; }
.missed ul { list-style: none; padding: 0; display: grid; gap: .5rem; }
.missed li { display: grid; gap: .1rem; padding: .6rem .8rem; background: var(--panel-2); border-radius: 8px; }
.missed .ar { font-size: 1.2rem; }
.result .row { justify-content: center; }

/* Hifz */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .6rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--lapis-2); border-color: var(--gold); }
.khatma { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .4rem; }
.sq { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem .3rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font: inherit; color: var(--ink); }
.sq .ar { font-size: .95rem; line-height: 1.4; }
.sq.s1, .sq-key.s1 { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.sq.s2, .sq-key.s2 { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sq-key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); }
.review, .mistakes, .recs { list-style: none; padding: 0; display: grid; gap: .6rem; }
.review li { display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.review li.done { opacity: .6; }
.review strong.ar { font-size: 1.25rem; }
.mistakes li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .8rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.mistakes li p { flex-basis: 100%; margin: 0; }
.mistakes li.resolved { opacity: .6; }
.mistakes strong.ar { font-size: 1.15rem; }
.rec { padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: grid; gap: .6rem; }
.rec-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.rec audio { width: 100%; max-width: 420px; }
.fb-box { background: var(--panel-2); border-radius: 8px; padding: .8rem 1rem; border-inline-start: 3px solid var(--gold); }
.fb-box p { margin: 0; }
.stars { color: var(--gold); letter-spacing: .1em; }
.recite audio { width: 100%; margin: .6rem 0; }

/* Certificate */
.cert-wrap { padding: 1rem 0; }
.cert { max-width: 860px; margin: 0 auto 1.2rem; background: #fffdf8; color: #142033; padding: 14px; border-radius: 6px; box-shadow: var(--shadow); }
.cert-border { border: 2px solid #b9842c; outline: 1px solid #b9842c; outline-offset: -8px; padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 3rem); text-align: center; }
.cert .mark rect { fill: #1d3f73; }
.cert .mark .core { fill: #b9842c; }
.cert .eyebrow { color: #b9842c; }
.cert .muted { color: #5b6779; }
.cert-ar { font-family: var(--naskh); font-size: 1.8rem; font-weight: 700; color: #1d3f73; margin: .3rem 0 1rem; }
.cert-name { font-family: var(--display); font-size: clamp(2rem, 6vw, 3rem); color: #1d3f73; margin: .4rem 0 .8rem; overflow-wrap: anywhere; }
.cert h2 { color: #142033; }
.cert-foot { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-top: 2.5rem; text-align: start; }
.cert-foot p { margin: 0; }
.cert-foot .line { display: block; width: 200px; max-width: 100%; border-top: 1px solid #142033; margin-bottom: .4rem; }

/* Admin */
.admin { text-align: right; }
.admin .field label, .admin h3 { text-align: right; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td input[type="date"] { width: auto; }
td .chip { margin: 0 0 .2rem .2rem; }
.qb { border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; margin: 0 0 .8rem; display: grid; gap: .5rem; }
.qb-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem; }
.qb-opts input:first-child { border-color: var(--ok); }
.review-form { display: grid; gap: .5rem; }
.admin .backlink { direction: rtl; }

@media print {
  .no-print, #top, #foot, #toasts { display: none !important; }
  body { background: #fff; }
  #view { padding: 0; }
  .cert { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Language picker */
.lang-pick { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: .9rem; flex: none; }
.lang-pick .globe { font-size: .95rem; line-height: 1; }
.lang-select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--ink); font: 500 .9rem var(--body); padding: .15rem .2rem; cursor: pointer; }
.lang-select:focus-visible { outline: none; }
.lang-pick:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Introduction video */
.intro-video h2 { margin-bottom: 1rem; }
.video-frame { position: relative; width: 100%; max-width: 860px; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; box-shadow: var(--shadow); border: 1px solid var(--line); }
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Arabic interface */
:root[lang="ar"] body { font-family: var(--naskh), var(--body); font-size: 17px; }
:root[lang="ar"] .eyebrow, :root[lang="ar"] .kind { letter-spacing: 0; font-size: .85rem; }
:root[lang="ar"] .opt, :root[lang="ar"] .token, :root[lang="ar"] .lang-select, :root[lang="ar"] .btn, :root[lang="ar"] input, :root[lang="ar"] select, :root[lang="ar"] textarea { font-family: var(--naskh), var(--body); }
.video-cover { position: absolute; inset: 0; padding: 0; border: 0; background: #000; cursor: pointer; display: block; width: 100%; height: 100%; }
.video-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s, filter .2s; }
.video-cover:hover img { transform: scale(1.02); filter: brightness(.92); }
.play-btn { position: absolute; top: 50%; left: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; background: rgba(185, 132, 44, .95); box-shadow: 0 6px 24px rgba(0,0,0,.35); transition: transform .15s; }
.play-btn::after { content: ""; position: absolute; top: 50%; left: 54%; transform: translate(-50%, -50%); border-style: solid; border-width: 14px 0 14px 23px; border-color: transparent transparent transparent #fff; }
.video-cover:hover .play-btn { transform: scale(1.08); }
@media (max-width: 600px) { .play-btn { width: 60px; height: 60px; margin: -30px 0 0 -30px; } .play-btn::after { border-width: 11px 0 11px 18px; } }
/* Text that comes from the database in another language keeps its own direction. */
:root[dir="rtl"] :is(p, li, h3, dd, dt, summary, .plan .price) { unicode-bidi: plaintext; }
:root[dir="rtl"] :is(.ijazat ul, .plan ul, .materials) { list-style-position: inside; padding-inline-start: 0; }

/* Memorisation games */
.games { max-width: 960px; margin: 0 auto; }
.games .small-h { font-size: 1.05rem; margin: 1.6rem 0 .7rem; }
.surah-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .45rem; }
.surah-grid .tile { display: flex; flex-direction: column; align-items: center; gap: .05rem; min-height: 3.6rem; padding: .45rem .3rem; }
.surah-grid .tile .num { font-size: .72rem; color: var(--muted); }
.surah-grid .tile .ar { font-size: 1.15rem; }
.surah-grid .tile.sel { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.game-card { display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.game-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.game-card h3 { margin: .3rem 0 0; }
.game-card p { margin: 0; }
.game-icon { width: 2.6rem; height: 2.6rem; border-radius: 12px; display: grid; place-items: center; background: var(--lapis); color: var(--paper); font-size: 1.25rem; font-weight: 700; }
.game-meta { margin-top: auto !important; padding-top: .5rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; color: var(--lapis-2); }
.game-q .verse { margin-bottom: .3rem; }
.blank { display: inline-block; min-width: 3.5em; border-bottom: 2px solid var(--gold); color: var(--gold); }
.big-stars { font-size: 2.2rem; color: var(--gold); letter-spacing: .15em; margin: 0 0 .4rem; }
.opts .quran { font-size: 1.35rem; line-height: 1.9; }
.games-promo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; background: var(--lapis); color: var(--paper); border-radius: 16px; padding: 1.4rem 1.6rem; border-top: 0; margin: 1rem 0; }
.games-promo h2 { color: var(--paper); margin: 0 0 .2rem; }
.games-promo p { margin: 0; opacity: .85; }
.games-promo .btn { background: var(--gold); border-color: var(--gold); color: #fff; }
.token.quran { font-family: var(--quran); font-size: 1.45rem; line-height: 1.9; padding: .15rem .8rem; }

/* Payment */
.req-wrap { display: grid; gap: .6rem; margin-top: .8rem; }
.req-wrap .chip { margin-top: 0; justify-self: start; }
.pay-box { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: .8rem; display: grid; gap: .5rem; }
.pay-box p { margin: 0; }
.pay-box .strong { font-weight: 700; }
.pay-btns { display: grid; gap: .45rem; }
.btn.pay { justify-content: center; width: 100%; color: #fff; border: 0; }
.btn.pay span { font-weight: 800; }
.btn.paypal { background: #0070ba; }
.btn.paypal:hover { background: #005ea6; }
.btn.instapay { background: #4a1f7a; }
.btn.instapay:hover { background: #3c1866; }
.pay-box .copy-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.pay-box code { overflow-wrap: anywhere; }

/* Lesson room */
.room { display: grid; gap: .8rem; }
.room-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .8rem; }
.room-head h1 { margin: 0; }
.room-head p { margin: .2rem 0 0; }
.room-tools { display: flex; flex-wrap: wrap; gap: .4rem; }
.room-frame { height: max(480px, calc(100vh - 210px)); border-radius: 14px; overflow: hidden; background: #0d1420; border: 1px solid var(--line); display: grid; }
.room-frame > .loading, .room-frame > .empty { place-self: center; color: var(--paper); }
.room-frame iframe { width: 100%; height: 100%; border: 0; }
.room-card { border-color: var(--gold); }

/* Messages */
.msg-badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; margin-inline-start: .35rem; border-radius: 999px; background: var(--bad); color: #fff; font: 700 .72rem/1 var(--body); vertical-align: middle; }
.msg-page { max-width: 820px; margin: 0 auto; }
.msg-thread { display: grid; grid-template-rows: auto 1fr auto auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; height: max(440px, calc(100vh - 300px)); }
.msg-with { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.avatar { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--lapis); color: var(--paper); font-weight: 700; }
.msg-list { overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .45rem; background: var(--paper); }
.msg { max-width: min(78%, 520px); padding: .55rem .85rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--lapis); color: var(--paper); border-color: var(--lapis); }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { display: block; font-size: .7rem; opacity: .7; margin-top: .15rem; text-align: end; }
.msg-day { align-self: center; font-size: .75rem; color: var(--muted); background: var(--panel-2); padding: .15rem .6rem; border-radius: 999px; margin: .4rem 0; }
.msg-empty { align-self: center; margin: auto; }
.msg-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--line); align-items: end; }
.msg-form textarea { flex: 1; resize: vertical; min-height: 2.8rem; max-height: 10rem; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
.msg-hint { margin: 0; padding: 0 .9rem .5rem; }
.msg-admin { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; align-items: start; }
.msg-admin aside select { width: 100%; margin-bottom: .6rem; }
.conv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; max-height: calc(100vh - 300px); overflow-y: auto; }
.conv-list a { display: flex; gap: .55rem; align-items: center; padding: .55rem; border-radius: 10px; text-decoration: none; color: inherit; }
.conv-list a:hover, .conv-list a.on { background: var(--panel-2); }
.conv-list a.unread strong { color: var(--lapis-2); }
.conv-last { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: grid; justify-items: end; gap: .2rem; }
@media (max-width: 760px) { .msg-admin { grid-template-columns: 1fr; } .msg-thread { height: calc(100vh - 230px); } }
