*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: var(--step-0); line-height: 1.65;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; margin: 0; text-wrap: balance; font-weight: 600; }
h1 { font-size: var(--step-4); letter-spacing: -.01em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.eyebrow { font-size: var(--step--1); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 16px; }
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: var(--space-4); min-height: 60px; }
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; position: relative; }
.brand-mark::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.main-nav { display: flex; gap: var(--space-1); margin-inline-start: auto; align-items: center; flex-wrap: wrap; }
.main-nav a { text-decoration: none; color: var(--ink); padding: .4rem .7rem; border-radius: var(--radius-s); font-size: .95rem; }
.main-nav a:hover { background: var(--surface-2); }
.main-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.header-tools { display: flex; align-items: center; gap: var(--space-2); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang-switch button { border: 0; background: transparent; color: var(--ink); padding: .35rem .75rem; font: inherit; font-size: .875rem; cursor: pointer; min-height: 36px; }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; font: inherit; }
.menu-btn { display: none; }
@media (max-width: 1100px) {
  .menu-btn { display: grid; }
  .main-nav { display: none; position: absolute; inset-inline: 0; top: 100%; background: var(--surface); border-block-end: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: var(--space-3) 16px; box-shadow: var(--shadow); }
  .main-nav.open { display: flex; }
  .main-nav a { padding: .75rem; }
  .header-tools { margin-inline-start: auto; }
}
main { padding-block: var(--space-6) var(--space-7); min-height: 70vh; }
.site-footer { border-block-start: 1px solid var(--line); padding-block: var(--space-6); color: var(--muted); font-size: var(--step--1); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--step--1); color: var(--muted); margin-block-end: var(--space-4); }
.crumbs a { color: var(--muted); }

/* ---------- Building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-l { display: flex; flex-direction: column; gap: var(--space-6); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.grid-2 { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid > *, .grid-2 > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-5); min-width: 0; }
.card.flat { box-shadow: none; }
.card h3 + p { margin-block-start: var(--space-2); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3); }
.section-head p { max-width: 60ch; color: var(--muted); }
.lead { font-size: var(--step-1); color: var(--muted); max-width: 60ch; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap);
  padding: .55rem 1.1rem; border-radius: var(--radius-m); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.mark { border-color: var(--ochre); color: var(--ochre); }
.btn.mark[aria-pressed="true"] { background: var(--ochre-soft); }
.btn.sm { min-height: 34px; padding: .25rem .7rem; font-size: .875rem; font-weight: 500; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.verify, .badge.estimate, .badge.unverified { background: var(--ochre-soft); color: var(--ochre); }
.badge.official, .badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.callout { border-inline-start: 4px solid var(--ochre); background: var(--ochre-soft); padding: var(--space-3) var(--space-4); border-radius: var(--radius-s); font-size: .95rem; }
.callout.info { border-color: var(--accent); background: var(--accent-soft); }

/* forms */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .9rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: .55rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea.input { min-height: 5rem; resize: vertical; }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.choice-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.choice-row label { display: inline-flex; gap: .5rem; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-m); padding: .5rem .9rem; min-height: var(--tap); cursor: pointer; background: var(--surface); }
.choice-row input:checked + span { font-weight: 700; color: var(--accent); }
.err { color: var(--bad); font-size: .85rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .6rem .8rem; text-align: start; border-block-end: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-block-end: 0; }

/* hero */
.hero { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; padding-block: var(--space-4) var(--space-6); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }
.hero h1 em { font-style: normal; color: var(--accent); }
.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-5);
  box-shadow: var(--shadow); display: grid; gap: .55rem;
}
.sheet-row { display: grid; grid-template-columns: 2.2rem repeat(4, 1fr); align-items: center; gap: .5rem; font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.sheet-row .dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); justify-self: center; display: grid; place-items: center; font-size: .65rem; }
.sheet-row .dot.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.sheet-row .dot.flag { border-color: var(--ochre); border-style: dashed; }
.strip { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.strip > div { background: var(--surface); padding: var(--space-4); display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.strip .val { font-family: var(--font-display); font-size: var(--step-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip .lbl { font-size: var(--step--1); color: var(--muted); }
.track-card { display: flex; flex-direction: column; gap: var(--space-3); text-decoration: none; color: var(--ink); transition: border-color .15s; }
.track-card:hover { border-color: var(--accent); }
.track-card .tag { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); }

/* progress */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar.ochre > span { background: var(--ochre); }
.bar.bad > span { background: var(--bad); }
.bar.good > span { background: var(--good); }
.skill-row { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 3.5rem; gap: var(--space-3); align-items: center; font-size: .92rem; }
.skill-row .pct { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Exam ---------- */
.exam-bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--ink); color: var(--paper);
}
.exam-bar .wrap { display: flex; align-items: center; gap: var(--space-4); min-height: 58px; flex-wrap: wrap; padding-block: .4rem; }
.exam-bar .sec { font-family: var(--font-display); font-weight: 600; }
.exam-bar .sec small { opacity: .7; font-weight: 400; margin-inline-start: .4rem; }
.timer { margin-inline-start: auto; font-family: var(--font-mono); font-size: 1.35rem; font-weight: 600; letter-spacing: .04em; padding: .15rem .7rem; border-radius: var(--radius-s); background: color-mix(in srgb, var(--paper) 12%, transparent); direction: ltr; }
.timer.warn { background: var(--ochre); color: #1b1300; }
.timer.crit { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.exam-progress { height: 4px; background: color-mix(in srgb, var(--paper) 18%, transparent); }
.exam-progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: var(--space-5); align-items: start; }
@media (max-width: 900px) { .exam-layout { grid-template-columns: 1fr; } }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.q-num { font-family: var(--font-mono); font-size: .85rem; color: var(--muted); }
.q-text { font-size: var(--step-1); line-height: 1.8; white-space: pre-line; font-weight: 500; }
.passage { background: var(--surface-2); border-radius: var(--radius-m); padding: var(--space-4); line-height: 1.9; max-height: 16rem; overflow: auto; font-size: .97rem; }
.options { display: flex; flex-direction: column; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.opt {
  display: flex; gap: var(--space-3); align-items: center; width: 100%; text-align: start; min-height: 52px;
  padding: .6rem .9rem; border: 1.5px solid var(--line); border-radius: var(--radius-m); background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer; transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--accent); }
.opt .bubble { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font-family: var(--font-display); font-size: .85rem; font-weight: 600; color: var(--muted); }
.opt[aria-checked="true"] { border-color: var(--ink); background: var(--surface-2); }
.opt[aria-checked="true"] .bubble { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .bubble { background: var(--good); border-color: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .bubble { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.q-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: space-between; }
.q-actions .row { gap: var(--space-2); }
.navigator { position: sticky; top: 76px; }
.nav-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; direction: ltr; }
[dir="rtl"] .nav-grid { direction: rtl; }
.nav-cell { aspect-ratio: 1; max-width: 100%; min-height: 36px; border-radius: var(--radius-s); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-family: var(--font-mono); font-size: .85rem; cursor: pointer; position: relative; }
.nav-cell.answered { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.nav-cell.marked { border-color: var(--ochre); border-width: 2px; }
.nav-cell.marked::after { content: ""; position: absolute; top: 3px; inset-inline-end: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--ochre); }
.nav-cell.current { outline: 3px solid var(--accent); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line); display: inline-block; }
.legend i.a { background: var(--ink); border-color: var(--ink); }
.legend i.m { border-color: var(--ochre); border-width: 2px; }
.legend i.c { outline: 2px solid var(--accent); }
details.nav-toggle > summary { list-style: none; cursor: pointer; }
details.nav-toggle > summary::-webkit-details-marker { display: none; }
@media (min-width: 901px) { details.nav-toggle > summary { pointer-events: none; } }
.data-table { overflow-x: auto; }
.data-table table { font-size: .92rem; }

/* modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 16, 18, .55); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: var(--radius-l); padding: var(--space-5); width: min(100%, 34rem); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: var(--space-4); box-shadow: var(--shadow); }
.modal.wide { width: min(100%, 56rem); }
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.toasts { position: fixed; z-index: 120; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; border-radius: var(--radius-m); box-shadow: var(--shadow); max-width: 30rem; pointer-events: auto; animation: rise .25s ease-out; }
.toast.warn { background: var(--ochre); color: #1b1300; }
.toast.crit { background: var(--bad); color: #fff; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* results */
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: var(--space-6); align-items: center; }
@media (max-width: 640px) { .score-hero { grid-template-columns: 1fr; } }
.ring { width: 170px; height: 170px; }
.ring text { font-family: var(--font-display); fill: var(--ink); }
.kpis { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); }
.kpi { border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); background: var(--surface); }
.kpi .v { font-family: var(--font-display); font-size: var(--step-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: var(--step--1); color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-family: var(--font-body); font-size: 11px; }
.review-item { border-block-end: 1px solid var(--line); padding-block: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }

/* tabs & accordion */
.tabs { display: flex; gap: var(--space-1); border-block-end: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: .7rem 1rem; cursor: pointer; border-block-end: 3px solid transparent; white-space: nowrap; min-height: var(--tap); }
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.accordion details { border-block-end: 1px solid var(--line); }
.accordion summary { cursor: pointer; padding: var(--space-4) 0; font-weight: 600; font-family: var(--font-display); }
.accordion details p { padding-block-end: var(--space-4); color: var(--muted); max-width: 65ch; }
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.checklist label { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; padding: .4rem 0; }
.checklist input { width: 20px; height: 20px; margin-block-start: .2rem; accent-color: var(--accent); flex: none; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.planner td input { width: 100%; min-width: 7rem; border: 0; background: transparent; color: var(--ink); font: inherit; padding: .3rem; }
.lesson ul, .lesson ol { margin: 0; padding-inline-start: 1.25rem; display: flex; flex-direction: column; gap: .35rem; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; background: var(--surface); color: var(--ink); text-decoration: none; font-size: .9rem; cursor: pointer; font: inherit; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.empty { text-align: center; padding: var(--space-6); color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius-l); }
.disclaimer { font-size: var(--step--1); color: var(--muted); }

.formula { padding: .55rem .8rem; background: var(--surface-2); border-radius: var(--radius-s); line-height: 1.7; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- Friendly UI layer ---------- */
html[data-size="s"] { font-size: 93.75%; }
html[data-size="l"] { font-size: 112.5%; }
[lang="ar"] body, html[lang="ar"] body { line-height: 1.8; }
.ico { flex: none; display: block; }
.icon-btn { transition: background .15s, border-color .15s; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn { transition: background .15s, border-color .15s, transform .1s; }
.btn:active, .chip:active, .opt:active { transform: scale(.98); }
.chip { transition: border-color .15s, background .15s; min-height: 38px; }
.chip:hover { border-color: var(--accent); }
.card.track-card:hover { box-shadow: var(--shadow); }
.callout.good { border-color: var(--good); background: var(--good-soft); }
.callout.bad { border-color: var(--bad); background: var(--bad-soft); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-m); align-self: flex-start; }
.seg button { border: 0; background: transparent; color: var(--ink); font: inherit; padding: .45rem .9rem; border-radius: var(--radius-s); cursor: pointer; min-height: 38px; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: var(--shadow); }
.trans { border: 1px dashed var(--line); border-radius: var(--radius-m); background: var(--surface); }
.trans > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; color: var(--accent); font-weight: 600; font-size: .92rem; min-height: 44px; }
.trans > summary::-webkit-details-marker { display: none; }
.trans[open] > summary { border-block-end: 1px dashed var(--line); }
.trans-body { padding: .75rem .9rem; display: flex; flex-direction: column; gap: .5rem; text-align: start; }
.trans-q { white-space: pre-line; font-weight: 500; }
.trans-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.trans-opts li { display: flex; gap: .5rem; align-items: baseline; padding: .35rem .6rem; background: var(--surface-2); border-radius: var(--radius-s); }
.trans-opts b { color: var(--muted); font-family: var(--font-display); }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots span { flex: 1; min-width: 6px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.dots span.cur { background: var(--ink); }
.dots span.ok { background: var(--good); }
.dots span.no { background: var(--bad); }
.today { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-5); align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: var(--space-5); margin-block-end: var(--space-6); }
@media (max-width: 720px) { .today { grid-template-columns: 1fr; } }
.today h2 { font-size: var(--step-2); }
.continue { display: flex; gap: var(--space-3); align-items: center; text-decoration: none; color: var(--ink); background: var(--accent-soft); border-radius: var(--radius-m); padding: var(--space-3) var(--space-4); min-height: 56px; }
.continue > span { display: flex; flex-direction: column; min-width: 0; }
.continue .ico { color: var(--accent); }
.continue:hover { outline: 2px solid var(--accent); }
.today-stats { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.goal { display: flex; align-items: center; gap: var(--space-3); }
.goal > div { display: flex; flex-direction: column; }
.goal strong { font-family: var(--font-display); font-size: var(--step-2); }
.goal > .ico { width: 40px; height: 40px; color: var(--ochre); }
.tabbar { display: none; }
@media (max-width: 960px) {
  .hide-sm { display: none !important; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 35; background: var(--surface); border-block-start: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -4px 16px rgba(0,0,0,.05); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; font-size: .72rem; color: var(--muted); text-decoration: none; }
  .tabbar a[aria-current] { color: var(--accent); font-weight: 700; }
  body { padding-bottom: 64px; }
  body.exam-mode { padding-bottom: 0; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .lang-switch button { padding: .3rem .6rem; }
}

.main-nav a { white-space: nowrap; }
@media (min-width: 1101px) { .main-nav { flex-wrap: nowrap; } .main-nav a { padding: .4rem .6rem; } }

.tr-btn { align-self: flex-start; gap: .35rem; }
.tr-card { border-color: var(--accent); }
.tr-card h3 { display: flex; align-items: center; gap: .4rem; }
.ex-item { display: flex; gap: var(--space-3); align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-3); cursor: pointer; }
.ex-item > input { width: 20px; height: 20px; margin-top: .2rem; accent-color: var(--accent); flex: none; }
.trans-opts li.is-correct { background: var(--good-soft); outline: 1.5px solid var(--good); }

.qchart { margin: 0; background: var(--surface-2); border-radius: var(--radius-m); padding: .5rem; max-width: 30rem; width: 100%; align-self: center; }
.qchart svg { width: 100%; height: auto; display: block; }
.qchart text { fill: var(--muted); font-family: var(--font-body); font-size: 11px; }
.qchart text.t { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.qchart text.sl { fill: var(--ink); font-weight: 700; font-size: 12px; }
.qchart text.s1t { fill: var(--ochre); }
.qchart .g { stroke: var(--line); stroke-width: 1; }
.qchart .ax { stroke: var(--ink); stroke-width: 1.4; }
.qchart .s { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.qchart .s0 { stroke: var(--accent); }
.qchart .s1 { stroke: var(--ochre); }
.qchart .s.d { stroke-dasharray: 6 5; }
.qchart .p0 { fill: var(--accent); }
.qchart .p1 { fill: var(--ochre); }
.qchart .b { fill: var(--accent); opacity: .85; }
.qchart .b.hi { fill: var(--ochre); }
.qchart figcaption { text-align: center; font-size: .8rem; color: var(--muted); padding-top: .25rem; }

/* ---------- Question figures (assets/js/figures*.js) ---------- */
.qfig { margin: 0; background: var(--surface-2); border-radius: var(--radius-m); padding: .5rem; max-width: 28rem; width: 100%; align-self: center; }
.qfig.wide { max-width: 34rem; }
.qfig svg { width: 100%; height: auto; display: block; overflow: visible; }
.qfig figcaption { text-align: center; font-size: .8rem; color: var(--muted); padding-top: .25rem; }
.qfig text { fill: var(--ink); font-family: var(--font-body); font-size: 13px; }
.qfig text.b { font-weight: 700; }
.qfig text.dm { fill: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.qfig text.pl { fill: var(--surface); font-weight: 700; }
.qfig text.chem { font-family: var(--font-mono); font-weight: 600; font-size: 14px; }
.qfig .ln { stroke: var(--ink); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.qfig .lt { stroke: var(--line); stroke-width: 1; fill: none; }
.qfig .mu { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.qfig .ac { stroke: var(--accent); stroke-width: 2.4; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.qfig .oc { stroke: var(--ochre); stroke-width: 2.4; fill: none; stroke-linecap: round; }
.qfig .thick { stroke-width: 3.4; }
.qfig .thickest { stroke-width: 9; stroke-linecap: round; }
.qfig .d { stroke-dasharray: 5 4; }
.qfig .nostroke { stroke: none; }
.qfig .fa { fill: var(--accent-soft); }
.qfig .fa50 { fill: var(--accent-soft); fill-opacity: .55; }
.qfig .fo, .qfig .fo50 { fill: var(--ochre-soft); }
.qfig .fo50 { fill-opacity: .55; }
.qfig .fs { fill: var(--surface); }
.qfig .fs50 { fill: var(--surface-2); fill-opacity: .5; }
.qfig .fi { fill: var(--ink); }
.qfig .fac { fill: var(--accent); }
.qfig .foc { fill: var(--ochre); }
.qfig .fmu { fill: var(--muted); }
.qfig .fbd { fill: var(--bad-soft); }
.qfig .fgood { fill: var(--good-soft); }
.qfig .fsoft { fill: var(--accent-soft); }
.qfig .fwall { fill: var(--good-soft); }
.qfig .fvac { fill: var(--accent-soft); fill-opacity: .6; }
.qfig .sl { stroke: var(--surface-2); stroke-width: 2; }
.qfig .tagc { fill: var(--surface); stroke: var(--ink); stroke-width: 1.4; }
.opt .num-opt { direction: ltr; unicode-bidi: isolate; }
.qfig .fgd { fill: var(--good); }
.qfig .fbad { fill: var(--bad); }

/* Accessible native disclosure; keyboard and touch supported. */
.visual-expand { width:100%; }
.visual-expand summary { cursor:pointer; color:var(--accent); padding:.65rem; font-weight:600; }
.visual-expand[open] { grid-column:1 / -1; }
.visual-expand[open] > div { overflow:auto; padding:.5rem; }
.visual-expand[open] .qfig, .visual-expand[open] .qchart { max-width:60rem; width:100%; margin-inline:auto; }
.visual-expand[open] svg { min-width:32rem; }
@media print { .visual-expand { display:none; } }


/* ================= MATH & CHEMICAL TYPOGRAPHY ================= */
.math-expr {
  font-family: "STIX Two Math", "Cambria Math", "KaTeX_Main", Georgia, serif;
  direction: ltr;
  display: inline-block;
  font-size: 1.04em;
  margin: 0 1px;
}
.math-block {
  direction: ltr;
  text-align: center;
  margin: 0.85rem auto;
  font-size: 1.12em;
  font-family: "STIX Two Math", "Cambria Math", "KaTeX_Main", Georgia, serif;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: var(--radius-m);
}
.katex-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: -0.65em;
  text-align: center;
  padding: 0 3px;
  font-size: 0.88em;
  line-height: 1.05;
}
.katex-num {
  border-bottom: 1.3px solid currentColor;
  padding-bottom: 1px;
  display: block;
}
.katex-den {
  padding-top: 1px;
  display: block;
}
.katex-sqrt {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.katex-sqrt-sign {
  font-size: 1.25em;
  line-height: 1;
  margin-right: 1px;
  font-family: serif;
}
.katex-radicand {
  border-top: 1.3px solid currentColor;
  padding: 0 3px;
  display: inline-block;
}
.katex-root-index {
  font-size: 0.65em;
  margin-right: -2px;
  vertical-align: super;
}
.math-sym, .math-op {
  padding: 0 2px;
  font-style: normal;
}
.math-text {
  font-family: inherit;
  font-style: normal;
}
/* ================= MISTAKE NOTEBOOK STYLES ================= */
.mistakes-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.mistake-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: var(--space-3);
  background: var(--paper);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.mistake-card:hover {
  border-color: var(--accent);
}
.mistake-card .prev-wrong {
  color: var(--bad);
  font-weight: bold;
  background: var(--bad-soft);
  padding: 2px 8px;
  border-radius: 4px;
}
.mistake-card .correct-ans {
  color: var(--good);
  font-weight: bold;
  background: var(--good-soft);
  padding: 2px 8px;
  border-radius: 4px;
}
.nav-mistakes-btn {
  border: 1px solid var(--line) !important;
  color: var(--ink-secondary) !important;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
}
.nav-mistakes-badge {
  background: var(--bad);
  color: var(--surface);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.75rem;
  font-weight: bold;
}


/* ================= DAILY INSPIRING QUOTE BANNER ================= */
.daily-inspiration-card {
  margin: var(--space-3) 0 var(--space-4);
  padding: 1.1rem 1.35rem;
  background: var(--gold-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-m);
  box-shadow: none;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease;
}
[dir="rtl"] .daily-inspiration-card {
  border-left: 1px solid var(--line);
  border-right: 4px solid var(--gold);
}
.inspiration-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}
.inspiration-badge {
  font-weight: 700;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
}
.inspiration-date {
  color: var(--muted);
  font-size: 0.825rem;
  font-weight: 500;
}
.inspiration-quote {
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
body.theme-dark .inspiration-quote {
  color: #f8fafc;
}


/* ================= UPCOMING TRACKS SECTION ================= */
.upcoming-section {
  margin: var(--space-4) 0 var(--space-3);
}
.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.upcoming-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.upcoming-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.upcoming-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}
.upcoming-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.status-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid transparent;
}
.upcoming-title {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  color: var(--ink);
}
.upcoming-desc {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  flex-grow: 1;
}
.upcoming-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.upcoming-tag-item {
  font-size: 0.73rem;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-s);
}
.upcoming-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--line);
  font-size: 0.825rem;
}
.upcoming-action span {
  color: var(--muted);
}
.upcoming-action .btn-notify {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: all 0.15s ease;
}
.upcoming-action .btn-notify:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


/* ================= EVENT-DRIVEN THEMES, AVATARS & SUBJECT INSIGHTS ================= */
/* 1. Ramadan Theme */
body.theme-event-ramadan {
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --accent-ink: #fff;
  --surface-event: linear-gradient(135deg, rgba(30, 27, 75, 0.05), rgba(245, 158, 11, 0.08));
}
body.theme-dark.theme-event-ramadan {
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.22);
  --surface-event: linear-gradient(135deg, rgba(30, 27, 75, 0.8), rgba(67, 56, 202, 0.3));
}

/* 2. Eid Theme */
body.theme-event-eid {
  --accent: #059669;
  --accent-soft: rgba(5, 150, 105, 0.12);
  --surface-event: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(245, 158, 11, 0.08));
}
body.theme-dark.theme-event-eid {
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.22);
}

/* 3. Saudi National Day & Founding Day */
body.theme-event-saudi {
  --accent: #006C35;
  --accent-soft: rgba(0, 108, 53, 0.12);
}
body.theme-dark.theme-event-saudi {
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.22);
}

/* 4. Science, Pi & Space Days */
body.theme-event-science {
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.12);
}
body.theme-dark.theme-event-science {
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.22);
}
body.theme-event-pi {
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.12);
}

/* Dynamic Event Avatar / Face */
.event-avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-size: 1.35rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: visible;
  cursor: pointer;
}
.event-avatar-badge:hover {
  transform: scale(1.1) rotate(6deg);
}
.event-avatar-badge .event-sub-icon {
  position: absolute;
  bottom: -3px;
  right: -3px;
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--surface);
}

/* Subject Daily Milestone & Concept Card */
.subject-daily-info-card {
  margin: var(--space-4) 0;
  padding: 1.15rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: 5px solid var(--accent);
  border-radius: var(--radius-l);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
[dir="ltr"] .subject-daily-info-card {
  border-right: 1px solid var(--line);
  border-left: 5px solid var(--accent);
}
.subject-daily-info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.subject-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: 0.45rem;
}
.subject-info-pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.subject-info-event-tag {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.subject-info-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0.35rem 0;
  line-height: 1.4;
}
.subject-info-body {
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--ink-soft, var(--ink));
  margin: 0;
}
.subject-info-tip {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--line);
  font-size: 0.84rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.subject-info-tip strong {
  color: var(--accent);
}

/* Event Preview Selector Bar */
.event-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  font-size: 0.825rem;
  margin: var(--space-3) 0 var(--space-4);
  overflow-x: auto;
}
.event-preview-bar span {
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.event-preview-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.event-preview-btn:hover, .event-preview-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


/* ================= ACCOUNTS, CLOUD & TRACK SEPARATION STYLES ================= */
.track-switcher-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  margin-bottom: var(--space-3);
  font-size: var(--step--1);
}
.track-switcher-label {
  font-weight: 700;
  color: var(--ink);
}
.track-switcher-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.track-switcher-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}
.track-switcher-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.nav-track-pill {
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.nav-track-pill:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.account-page {
  padding: var(--space-4) 0;
}
.track-select-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.track-select-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all 0.2s ease;
}
.track-select-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.track-select-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}
.track-select-card input[type="radio"] {
  margin-top: 4px;
  accent-color: var(--accent);
}
.track-select-card .track-icon {
  font-size: 1.5rem;
}

.lang-radio-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}
.lang-radio-card:hover, .lang-radio-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lang-radio-card input[type="radio"] {
  accent-color: var(--accent);
}

.btn-google {
  transition: all 0.2s ease;
}
.btn-google:hover:not(:disabled) {
  background: #f8f9fa !important;
  box-shadow: 0 1px 3px rgba(60,64,67,0.3);
}
