:root {
  --bg: #f7f6fc;
  --surface: #ffffff;
  --surface-2: #f0eefb;
  --text: #1d1a33;
  --muted: #5f5a7a;
  --line: #e3e0f2;
  --brand: #5b3df5;
  --brand-2: #8a5cff;
  --brand-ink: #ffffff;
  --good: #12936b;
  --bad: #d23f5a;
  --fig: #2a2547;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 26, 51, .06), 0 8px 24px rgba(29, 26, 51, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100e1c;
    --surface: #1a1730;
    --surface-2: #231f3d;
    --text: #efedf9;
    --muted: #a7a2c3;
    --line: #2f2a4d;
    --brand: #8b74ff;
    --brand-2: #b19cff;
    --brand-ink: #120f22;
    --good: #3fd09f;
    --bad: #ff6f8a;
    --fig: #e6e2fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: break-word;
}
html[lang="ur"] body { font-family: "Noto Nastaliq Urdu", var(--font); line-height: 2.1; }
html[lang="ar"] body { font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, var(--font); }
img, svg { max-width: 100%; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-top: 1.8em; letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.lead { font-size: 1.15em; color: var(--muted); }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.logo { flex: none; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.logo svg { width: 30px; height: 30px; }
.nav { display: flex; gap: 18px; margin-inline-start: auto; align-items: center; min-width: 0; }
.nav a { white-space: nowrap; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--brand); }
/* language menu: plain links in a <details>, no JavaScript */
.langs { position: relative; }
.langs summary { white-space: nowrap; list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: .9rem; }
.langs summary::-webkit-details-marker { display: none; }
.langs summary svg { width: 18px; height: 18px; }
.langs ul { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; list-style: none; margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 2px; width: max-content; max-width: calc(100vw - 24px); max-height: min(70vh, 560px); overflow-y: auto; }
.langs a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.langs a:hover { background: var(--surface-2); }
.langs a[aria-current] { font-weight: 800; color: var(--brand); }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 700; padding: 11px 22px; border-radius: 999px;
  cursor: pointer; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease;
  line-height: 1.3;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(91, 61, 245, .28); }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-lg { font-size: 1.15rem; padding: 15px 34px; }

/* hero */
.hero { padding: 56px 0 40px; background: radial-gradient(1200px 400px at 50% -10%, rgba(139, 116, 255, .18), transparent); }
.hero .wrap { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: center; }
.hero-sub { font-size: 1.2rem; color: var(--muted); max-width: 36em; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0 18px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.badges li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .9rem; font-weight: 600; }
.badges li::before { content: "✓ "; color: var(--good); }
.demo-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.demo-card { margin: 0 auto; width: 100%; max-width: 380px; }
.demo-card figcaption { margin: 10px 0 0; text-align: center; font-size: .95rem; }

/* sections */
.section { padding: 28px 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: .4em; }
.card p { margin: 0; color: var(--muted); }
.grid { list-style: none; padding: 0; margin: 0; }
.steps { counter-reset: step; }
.steps li { counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; margin-bottom: 10px; }
.prose { max-width: 760px; }
.prose p, .prose li { color: var(--text); }
/* safety net: a table too wide for a small phone scrolls inside its box, never the page */
.table-wrap { overflow-x: auto; margin: 0 0 1em; border-radius: var(--radius); box-shadow: var(--shadow); }
table.scale { hyphens: auto; width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); }
table.scale th, table.scale td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: start; }
table.scale th { background: var(--surface-2); }
table.scale tbody tr > :first-child { font-weight: 700; white-space: nowrap; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: var(--muted); }
.cta-band { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-radius: var(--radius); padding: 32px; text-align: center; margin: 32px 0; }
.cta-band h2 { margin-top: 0; }
.cta-band .btn { background: #fff; color: #3a22c9; border-color: #fff; }
.breadcrumbs ol { list-style: none; padding: 0; margin: 18px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; font-size: .9rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; margin-inline-end: 6px; }
.breadcrumbs a { color: var(--muted); }
.byline { color: var(--muted); font-size: .92rem; margin-top: -4px; }
.answer { font-size: 1.08em; }
section.answer { background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--brand); border-radius: 12px; padding: 16px 20px; margin: 18px 0 24px; box-shadow: var(--shadow); }
section.answer p { margin: 0; }
.toc { background: var(--surface-2); border-radius: 12px; padding: 14px 20px; margin: 20px 0; }
.toc p { margin: 0 0 6px; font-weight: 700; }
.toc ol { margin: 0; padding-inline-start: 1.2em; }
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin: 0; }
.glance div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.glance dt { color: var(--muted); font-size: .9rem; font-weight: 600; }
.glance dd { margin: 2px 0 0; font-weight: 700; }
.types div { margin-bottom: 10px; }
.types dt { font-weight: 700; }
.types dd { margin: 0; color: var(--muted); }
.cards { list-style: none; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* odd count: the first card spans the full row so no card is left alone */
.cards li:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.cards a { display: block; height: 100%; text-decoration: none; color: inherit; }
.cards .card:hover { border-color: var(--brand-2); }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
.faq-item h3 { margin: 0 0 6px; font-size: 1.05rem; }
.faq-item p { margin: 0; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.facts dt { color: var(--muted); font-size: .88rem; font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 700; }
.bellfig { margin: 0 0 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.bellfig figcaption { text-align: center; color: var(--muted); font-size: .9rem; }
tr.current { background: var(--surface-2); font-weight: 700; }
table.scale caption { text-align: start; font-weight: 700; padding: 0 0 8px; color: var(--muted); caption-side: top; }
.iq-nav { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0; font-weight: 700; }
.score-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.score-grid a { display: grid; text-align: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); }
.score-grid a:hover { border-color: var(--brand); }
.score-grid li.key a { border-color: var(--brand); font-weight: 800; }
.score-grid small { color: var(--muted); font-size: .75rem; }
.practice { list-style: none; padding: 0; }
.practice-q { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.pstim { margin: 0 0 14px; }
.pstim .matrix { max-width: 260px; }
.pstim .series { max-width: 420px; }
.popts { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; max-width: 520px; margin: 0 auto 12px; }
.popts li { position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 8px; display: grid; place-items: center; min-height: 60px; }
.practice-q details summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.notice { background: var(--surface-2); padding: 10px 14px; border-radius: 10px; }
.modes { list-style: none; padding: 0; }
.mode h3 { margin: 0 0 4px; font-size: 1.15rem; }
article.page { padding: 20px 0 40px; }

/* figures */
.fig { display: block; width: 100%; height: auto; color: var(--fig); }
.matrix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 320px; margin: 0 auto; background: var(--line); padding: 6px; border-radius: 14px; }
.mcell, .scell { background: var(--surface); border-radius: 9px; aspect-ratio: 1; display: grid; place-items: center; padding: 6%; }
.missing { background: var(--surface-2); }
.qmark { font-size: clamp(1.3rem, 6vw, 2.6rem); font-weight: 800; color: var(--brand); }
.series { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin: 0 auto; }
.scell { border: 1px solid var(--line); }
.numbers { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.num { min-width: 64px; padding: 14px 12px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.num.missing { color: var(--brand); }

/* runner */
.runner, .intro-card, .results { max-width: 760px; margin: 24px auto 48px; }
.intro-card, .runner { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 22px 0; }
.mode { border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.mode-main { border: 2px solid var(--brand); grid-column: 1 / -1; }
.modes-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mode h3 { margin: 0 0 4px; }
.mode p { margin: 0 0 10px; }
.rules { padding-inline-start: 1.2em; color: var(--muted); }
.run-top { display: flex; justify-content: space-between; font-weight: 700; color: var(--muted); }
.timer.low { color: var(--bad); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 18px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .25s ease; }
.prompt { text-align: center; font-size: 1.25rem; margin: 0 0 16px; }
.stimulus { margin-bottom: 20px; }
.options { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 400px; margin: 0 auto; }
.options.count-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 640px; }
.options.opts-sequence { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.opt { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; color: var(--text); font: inherit; transition: border-color .12s ease, transform .12s ease; aspect-ratio: 1; display: grid; place-items: center; }
.opts-sequence .opt { aspect-ratio: auto; padding: 14px 6px; }
.opt:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.opt.sel { border-color: var(--brand); background: var(--surface-2); box-shadow: 0 0 0 3px rgba(91, 61, 245, .2); }
.optl { position: absolute; top: 4px; inset-inline-start: 8px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.optnum { font-size: 1.4rem; font-weight: 800; }
.run-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* results */
.res-title { text-align: center; }
.score-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow); }
.score-label { margin: 0; color: var(--muted); font-weight: 600; }
.score { font-size: clamp(4rem, 14vw, 6.5rem); font-weight: 900; line-height: 1; margin: 6px 0; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-class { font-size: 1.3rem; font-weight: 800; margin: 0; }
.score-pct { color: var(--muted); }
.bell { margin-top: 10px; }
.bell-line { fill: none; stroke: var(--brand); stroke-width: 3; }
.bell-area { fill: var(--brand); opacity: .18; }
.axis, .tick { stroke: var(--line); stroke-width: 2; }
.ticklabel { fill: var(--muted); font-size: 13px; font-family: var(--font); }
.marker { stroke: var(--brand); stroke-width: 2; stroke-dasharray: 4 4; }
.marker-dot { fill: var(--brand); }
.marker-label { fill: var(--brand); font-weight: 800; font-size: 14px; font-family: var(--font); }
.res-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.res-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.res-stats strong { display: block; font-size: 1.4rem; }
.res-stats span { color: var(--muted); font-size: .9rem; }
.bars { display: grid; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; font-weight: 600; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.cert { display: flex; gap: 10px; flex-wrap: wrap; }
.cert input { flex: 1 1 220px; font: inherit; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.share { display: flex; flex-wrap: wrap; gap: 8px; }
.share .btn { padding: 8px 16px; font-size: .95rem; }
.disclaimer { font-size: .9rem; color: var(--muted); margin-top: 22px; }
.review-wrap summary { cursor: pointer; font-weight: 800; font-size: 1.3rem; margin: 1.6em 0 .8em; }
.review { list-style: none; padding: 0; display: grid; gap: 12px; }
.rev { background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--good); border-radius: 12px; padding: 14px; }
.rev.bad { border-inline-start-color: var(--bad); }
.rev-head { display: flex; gap: 10px; align-items: center; font-weight: 700; margin-bottom: 8px; }
.rev-n { color: var(--muted); }
.rev-mark { margin-inline-start: auto; }
.rev.ok .rev-mark { color: var(--good); }
.rev.bad .rev-mark { color: var(--bad); }
.rev-stim .matrix { max-width: 200px; }
.rev-stim .series { max-width: 300px; }
.rev-stim .num { min-width: 44px; padding: 6px; font-size: 1.1rem; }
.rev-ans { display: flex; gap: 24px; margin-top: 10px; flex-wrap: wrap; }
.rev-ans small { display: block; color: var(--muted); }
.rev-opt { width: 70px; min-height: 40px; border: 2px solid var(--line); border-radius: 10px; padding: 4px; display: grid; place-items: center; }
.rev-opt.good { border-color: var(--good); }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; margin-top: 40px; font-size: .92rem; color: var(--muted); }
.site-footer .wrap { display: grid; gap: 12px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; padding: 0; margin: 0; }
.foot-links a { color: var(--muted); }
.foot-langs { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.foot-langs a { color: var(--muted); text-decoration: none; }
.foot-langs a[aria-current] { color: var(--text); font-weight: 700; }

@media (max-width: 960px) {
  .nav a.hide-md { display: none; }
}
@media (max-width: 820px) {
  .hero { padding: 32px 0 24px; }
  .modes, .modes-3 { grid-template-columns: 1fr; }
  .nav { gap: 12px; }
  table.scale { font-size: .9rem; }
  table.scale th, table.scale td { padding: 9px 7px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .options, .options.count-5, .options.opts-sequence { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .runner, .intro-card { padding: 16px; }
  .num { min-width: 48px; font-size: 1.3rem; padding: 10px 8px; }
  .series { gap: 4px; }
  .res-stats strong { font-size: 1.15rem; }
  .nav a.hide-sm { display: none; }
  .facts { grid-template-columns: 1fr; }
  /* the bell chart is scaled down on phones: enlarge its labels in SVG units */
  .bell { overflow: visible; margin-top: 24px; }
  .ticklabel { font-size: 22px; }
  .marker-label { font-size: 30px; }
  .grid, .grid.steps, .cards { grid-template-columns: 1fr; }
  .langs ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav { gap: 12px; }
}

@media (max-width: 420px) {
  table.scale { font-size: .8rem; }
  table.scale th, table.scale td { padding: 8px 5px; }
  .langs summary span { display: none; }
  .logo { font-size: 1.05rem; }
}

/* Digits stay in the system font: Nastaliq/Naskh metrics clip large numbers. */
.score, .num, .optnum, .res-stats strong, .score-grid strong, .marker-label { font-family: var(--font); }
.score { line-height: 1.15; padding-bottom: .05em; }
.mode:target { outline: 3px solid var(--brand-2); outline-offset: 2px; }
