:root {
  --bg: #F1F4F9;
  --card: #FFFFFF;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --blue: #1D4ED8;
  --blue-soft: #E3EBFF;
  --red: #DC2626;
  --red-soft: #FDE7E7;
  --green: #16A34A;
  --green-soft: #DCFCE7;
  --amber: #F59E0B;
  --amber-ink: #B45309;
  --amber-soft: #FEF3C7;
  --plate: #FFFFFF;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --r: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --card: #151D2F;
    --ink: #E8EEF8;
    --ink-2: #C3CEDF;
    --muted: #8A98B1;
    --line: #26324B;
    --blue: #4F7DFF;
    --blue-soft: #1B2A52;
    --red: #F25757;
    --red-soft: #3B1C22;
    --green: #34D27B;
    --green-soft: #12301F;
    --amber: #FBBF24;
    --amber-ink: #FBBF24;
    --amber-soft: #3A2E10;
    --plate: #F5F7FB;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.i { width: 22px; height: 22px; flex: none; }
[lang="fa"], [dir="rtl"] { font-family: -apple-system, "SF Arabic", "Geeza Pro", Tahoma, sans-serif; }

#app { max-width: 680px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 16px 28px; }
body.has-tabbar #app { padding-bottom: calc(96px + var(--safe-b)); }
body.in-quiz #app { padding-bottom: calc(190px + var(--safe-b)); }

.splash { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font: 700 18px var(--round); }
.splash img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .8; } }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
section.card { padding: 16px; margin-top: 14px; }
section.card h3 { margin: 0 0 10px; font: 800 17px var(--round); }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.empty-note { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(145deg, #2C63F0 0%, #1D45B8 50%, #142E7A 100%);
  color: #fff; border-radius: 26px; padding: 18px;
  box-shadow: 0 14px 34px rgba(29, 78, 216, .28);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::before { width: 190px; height: 190px; right: -60px; top: -70px; border: 26px solid rgba(255, 255, 255, .08); }
.hero::after { width: 90px; height: 90px; right: 70px; bottom: -50px; background: rgba(255, 255, 255, .06); }
.hero-row { display: flex; align-items: center; gap: 12px; position: relative; }
.hero-logo { width: 48px; height: 48px; border-radius: 13px; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.hero-txt { min-width: 0; }
.hero h1 { margin: 0; font: 800 25px/1.1 var(--round); letter-spacing: -.01em; }
.hero p { margin: 3px 0 0; font-size: 14px; opacity: .85; }
.streak { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px 6px 8px; border-radius: 999px; background: rgba(255, 255, 255, .16); font: 800 16px var(--round); }
.streak .i { width: 18px; height: 18px; color: #FDBA74; fill: #FB923C; stroke: #FDBA74; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; position: relative; }
.hero-stats div { background: rgba(255, 255, 255, .13); border-radius: 15px; padding: 10px 11px; }
.hero-stats b { display: block; font: 800 21px/1.15 var(--round); }
.hero-stats b small { font-size: 14px; opacity: .7; }
.hero-stats span { font-size: 12px; opacity: .85; }

/* ---------- exam card ---------- */
.exam-card {
  width: 100%; margin-top: 14px; display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 0; border-radius: var(--r); padding: 16px; text-align: left; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.exam-card:active, .qa:active, .row:active, .btn:active, .theory-chip:active { transform: scale(.98); }
.exam-sign { width: 60px; height: 60px; border-radius: 50%; flex: none; display: grid; place-items: center; background: #fff; color: #111; border: 8px solid var(--red); font: 800 20px var(--round); box-shadow: 0 0 0 2px #fff, 0 3px 10px rgba(220, 38, 38, .25); }
.exam-txt { flex: 1; min-width: 0; }
.exam-txt strong { display: block; font: 800 19px var(--round); }
.exam-txt > span { display: block; color: var(--muted); font-size: 14px; }
.exam-txt em { display: inline-block; margin-top: 6px; font-style: normal; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.exam-txt em.ok { background: var(--green-soft); color: var(--green); }
.exam-txt em.no { background: var(--red-soft); color: var(--red); }
.go { width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; }

/* ---------- quick actions ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.qa { border: 0; background: var(--card); border-radius: 18px; padding: 14px 12px; text-align: left; box-shadow: var(--shadow); transition: transform .12s ease; min-width: 0; }
.qa b { display: block; font: 800 15px var(--round); margin-top: 10px; }
.qa small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa:disabled { opacity: .5; }
.qa-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.qa-ic.blue { background: var(--blue-soft); color: var(--blue); }
.qa-ic.red { background: var(--red-soft); color: var(--red); }
.qa-ic.amber { background: var(--amber-soft); color: var(--amber-ink); }

/* ---------- lists ---------- */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }
.sec-head h2 { margin: 0; font: 800 20px var(--round); }
.sec-head span { color: var(--muted); font-size: 14px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.row { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 12px 12px 14px; background: none; border: 0; text-align: left; transition: transform .12s ease; }
.row-main { min-width: 0; }
.row-main b { display: block; font-size: 15.5px; font-weight: 650; line-height: 1.28; }
.row-main small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.3; }
.kicker { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 1px; }
.row-end { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-end .i { width: 18px; height: 18px; opacity: .6; }
.thumb { width: 54px; height: 54px; border-radius: 15px; background: var(--plate); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; }
.thumb img { max-width: 84%; max-height: 84%; object-fit: contain; }
.thumb.sm { width: 46px; height: 46px; border-radius: 13px; }
.thumb.lg { width: 96px; height: 96px; border-radius: 26px; margin: 0 auto; }
.thumb.fallback { background: var(--blue-soft); border: 0; color: var(--blue); font: 800 19px var(--round); }
.thumb.lg.fallback { font-size: 34px; }
.meter { display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #16A34A, #4ADE80); transition: width .4s ease; }
.meter.blue i { background: linear-gradient(90deg, var(--blue), #60A5FA); }

/* ---------- page heads / topbar ---------- */
.page-head h1 { margin: 6px 0 2px; font: 800 32px/1.1 var(--round); letter-spacing: -.015em; }
.page-head p { margin: 0; color: var(--muted); }
.topbar {
  position: sticky; top: 0; z-index: 8; display: flex; align-items: center;
  margin: calc(-14px - var(--safe-t)) -16px 10px; padding: calc(var(--safe-t) + 6px) 16px 8px 6px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
}
.back { display: inline-flex; align-items: center; gap: 0; background: none; border: 0; color: var(--blue); font-size: 17px; padding: 8px 8px 8px 2px; }
.back .i { width: 26px; height: 26px; }
.topbar-title { flex: 1; text-align: center; font-weight: 700; margin-right: 74px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- search & segmented ---------- */
.search { display: flex; align-items: center; gap: 8px; margin: 16px 0 12px; padding: 0 14px; background: var(--card); border-radius: 15px; box-shadow: var(--shadow); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font: 16px var(--font); padding: 13px 0; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; border-radius: 14px; background: color-mix(in srgb, var(--line) 75%, transparent); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: none; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }

/* ---------- buttons ---------- */
.btn-row { display: flex; gap: 10px; margin: 14px 0; }
.btn { flex: 1; min-height: 54px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 16px; font-weight: 700; transition: transform .12s ease; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 18px rgba(29, 78, 216, .3); }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.btn .i { width: 20px; height: 20px; }
.btn .i path[d^="M7 4.5"] { fill: currentColor; }
.link { background: none; border: 0; padding: 12px 0 0; color: var(--blue); font-size: 15px; font-weight: 600; }
.link.danger { color: var(--red); }

/* ---------- chapter page ---------- */
.ch-hero { text-align: center; padding: 22px 18px 18px; }
.ch-hero h1 { margin: 14px 0 4px; font: 800 23px/1.2 var(--round); }
.ch-hero p { margin: 0; color: var(--muted); }
.ch-stats { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; text-align: left; font-size: 14px; color: var(--ink-2); }
.ch-stats b { color: var(--ink); }
.ch-stats .bad { color: var(--red); font-weight: 600; }
.ring-wrap { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.ring-wrap b { position: relative; font: 800 15px var(--round); }
.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* ---------- theory ---------- */
.gallery { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery figure { margin: 0; flex: none; width: 148px; height: 148px; border-radius: 18px; background: var(--plate); border: 1px solid var(--line); display: grid; place-items: center; scroll-snap-align: start; }
.gallery img { max-width: 86%; max-height: 86%; object-fit: contain; }
.gallery.one figure { width: 100%; height: auto; min-height: 150px; padding: 18px; }
.gallery.one img { max-height: 230px; }
.theory { padding: 20px 18px 8px; }
.theory h2 { margin: 0 0 4px; font: 800 23px/1.25 var(--round); }
.theory .it-title { margin: 0 0 14px; color: var(--muted); font-size: 14px; font-style: italic; }
.theory p, .theory li { font-size: 17px; line-height: 1.6; color: var(--ink-2); }
.theory p { margin: 0 0 14px; }
.theory ul { margin: 0 0 14px; padding-inline-start: 22px; }
.theory li { margin: 5px 0; }
.theory li::marker { color: var(--blue); }
.theory[dir="rtl"] { text-align: right; }
.theory[dir="rtl"] h2 { font-family: -apple-system, "SF Arabic", "Geeza Pro", Tahoma, sans-serif; }
.theory[dir="rtl"] p, .theory[dir="rtl"] li { line-height: 2; font-size: 17.5px; }
.note { color: var(--muted); font-size: 14px; background: var(--amber-soft); padding: 10px 12px; border-radius: 12px; }

/* ---------- quiz ---------- */
.qtop {
  position: sticky; top: 0; z-index: 8; display: flex; align-items: center; gap: 8px;
  margin: calc(-14px - var(--safe-t)) -16px 12px; padding: calc(var(--safe-t) + 8px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
}
.icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); color: var(--ink); }
.icon-btn:disabled { opacity: .35; }
.qprog { flex: 1; min-width: 0; }
.qprog-txt { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.qprog-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qprog-txt span { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.qprog .meter { margin-top: 6px; }
.star.on { color: var(--amber); }
.star.on .i { fill: currentColor; }
.timer { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; height: 44px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font: 800 16px var(--round); font-variant-numeric: tabular-nums; }
.timer .i { width: 18px; height: 18px; color: var(--muted); }
.timer.low { color: var(--red); }
.timer.low .i { color: var(--red); }

.qcard { position: relative; background: var(--card); border-radius: 24px; padding: 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease; -webkit-user-select: none; user-select: none; }
.qcard:active { transform: scale(.99); }
.qcard.open { box-shadow: var(--shadow), inset 0 0 0 2px var(--blue-soft); }
.plate { background: var(--plate); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 14px; display: grid; place-items: center; }
.plate img { max-width: 100%; max-height: 30vh; object-fit: contain; display: block; }
.plate.sm { padding: 10px; margin-bottom: 10px; }
.plate.sm img { max-height: 110px; }
.qtext { margin: 0; font-size: 21px; line-height: 1.42; font-weight: 600; letter-spacing: -.01em; }
.tap-hint { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 7px 12px 7px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 13.5px; font-weight: 650; }
.tap-hint .i { width: 17px; height: 17px; }
.qtr { margin: 14px 0 0; padding-top: 14px; border-top: 1.5px dashed var(--line); font-size: 17.5px; line-height: 1.45; color: var(--ink-2); animation: fade .2s ease-out; }
.lang-tag { display: inline-block; margin-right: 8px; padding: 1px 7px; border-radius: 6px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .05em; vertical-align: 2px; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } }

.theory-chip { width: 100%; margin-top: 12px; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--card); text-align: left; transition: transform .12s ease; }
.theory-chip > span:not(.thumb) { flex: 1; min-width: 0; }
.theory-chip small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.theory-chip b { display: block; font-size: 15.5px; line-height: 1.3; }
.theory-chip > .i { color: var(--muted); }
.theory-chip .thumb.fallback { background: var(--amber-soft); color: var(--amber-ink); }
.theory-chip.hl { border-color: var(--amber); background: color-mix(in srgb, var(--amber-soft) 55%, var(--card)); animation: nudge .5s ease .2s; }
@keyframes nudge { 30% { transform: translateY(-3px); } 60% { transform: translateY(1px); } }

.abar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.abar-in { max-width: 648px; margin: 0 auto; }
.abar .btn.block { margin-top: 0; }
.abar .submit { margin-bottom: 10px; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.tf button { min-height: 68px; border-radius: 20px; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 800 20px var(--round); letter-spacing: .05em; transition: transform .1s ease; }
.tf button:active { transform: scale(.96); }
.tf small { font: 600 12px var(--font); letter-spacing: 0; opacity: .8; }
.tf .vero { background: var(--blue); color: #fff; box-shadow: 0 6px 18px rgba(29, 78, 216, .32); }
.tf .falso { background: var(--card); color: var(--red); box-shadow: inset 0 0 0 3.5px var(--red); }
.tf .is-picked { outline: 3px solid var(--ink); outline-offset: 3px; }
.tf .falso.is-picked { background: var(--red); color: #fff; }
.exam-nav { display: flex; align-items: center; gap: 10px; }
.verdict { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 10px; border-radius: 18px; }
.verdict.ok { background: var(--green-soft); }
.verdict.no { background: var(--red-soft); }
.verdict .mark { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.verdict.ok .mark { background: var(--green); }
.verdict.no .mark { background: var(--red); }
.verdict .mark .i { stroke-width: 3; }
.verdict b { display: block; font: 800 18px var(--round); }
.verdict.ok b { color: var(--green); }
.verdict.no b { color: var(--red); }
.verdict span span { font-size: 14.5px; color: var(--ink-2); }
.pop .verdict { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.shake .verdict { animation: shake .4s ease; }
@keyframes pop { from { transform: scale(.9); opacity: .4; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- results ---------- */
.result { text-align: center; padding: 6px 0 2px; }
.result-sign { width: 156px; height: 156px; margin: 8px auto 16px; border-radius: 50%; display: grid; place-content: center; grid-auto-flow: column; align-items: baseline; font: 800 46px var(--round); }
.result-sign small { font-size: 20px; opacity: .7; }
.result.pass .result-sign { background: var(--blue); color: #fff; border: 6px solid #fff; box-shadow: 0 0 0 3px var(--blue), 0 14px 34px rgba(29, 78, 216, .32); }
.result.fail .result-sign { background: #fff; color: #111; border: 20px solid var(--red); }
.result h1 { margin: 0; font: 800 28px var(--round); }
.result p { margin: 6px auto 0; max-width: 420px; color: var(--muted); }
.review { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review li { padding: 14px; }
.rv-it { margin: 0; font-weight: 600; font-size: 16px; }
.rv-en { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; border: 0; }
.pill.no { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.theory { background: var(--amber-soft); color: var(--amber-ink); }
.pill .i { width: 15px; height: 15px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 13px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: translateX(40px) rotate(720deg); } }

/* ---------- progress ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat { padding: 14px; }
.stat b { display: block; font: 800 26px/1.1 var(--round); }
.stat span { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat .i { width: 15px; height: 15px; color: #F97316; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; border-bottom: 1px solid var(--line); }
.bars i { flex: 1; max-width: 34px; border-radius: 7px 7px 2px 2px; }
.bars i.pass { background: linear-gradient(180deg, #4ADE80, var(--green)); }
.bars i.fail { background: linear-gradient(180deg, #F87171, var(--red)); }
.pass-line { position: absolute; left: 0; right: 0; bottom: 90%; border-top: 2px dashed var(--muted); opacity: .6; }
.pass-line em { position: absolute; right: 0; top: -20px; font-size: 11px; font-style: normal; color: var(--muted); font-weight: 700; }
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: grid; grid-template-columns: 22px 1fr 70px 38px; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }
.mini .meter { margin: 0; }
.mini-n { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-p { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row b { display: block; font-weight: 650; }
.set-row small { display: block; color: var(--muted); font-size: 13px; }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row.col .seg { margin: 0; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s ease; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.footnote { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 22px 4px 0; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: center;
  padding: 6px 8px calc(4px + var(--safe-b));
  background: color-mix(in srgb, var(--card) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 3px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 650; }
.tabbar .i { width: 26px; height: 26px; }
.tabbar [aria-current="page"] { color: var(--blue); }
.tabbar [aria-current="page"] .i { stroke-width: 2.4; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, .45); animation: fadein .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 680px; max-height: 90vh; margin: 0 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--bg); border-radius: 26px 26px 0 0; padding: 6px 16px calc(20px + var(--safe-b));
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--muted); opacity: .4; margin: 6px auto 14px; cursor: pointer; }
.sheet-h { margin: 0; font: 800 22px var(--round); }
.qgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 14px 0 4px; }
.qgrid button { aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-variant-numeric: tabular-nums; }
.qgrid .done { background: var(--blue); border-color: var(--blue); color: #fff; }
.qgrid .cur { outline: 3px solid var(--amber); outline-offset: 1px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fadein { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) {
  .quick { gap: 8px; }
  .qa { padding: 12px 10px; }
  .hero-stats b { font-size: 18px; }
  .qtext { font-size: 19px; }
}

/* Mock exam: right/wrong after each answer */
.exam-nav .btn.grow { flex: 1; min-height: 50px; }
.abar .submit-after { margin-top: 10px; }
.qprog-txt em { font-style: normal; }
.qprog-txt em.over { color: var(--red); }
.qgrid .ok { background: var(--green); border-color: var(--green); color: #fff; }
.qgrid .no { background: var(--red); border-color: var(--red); color: #fff; }

/* Theory: Italian, English and Persian on one page */
.lang-jump { display: flex; gap: 8px; margin: 0 0 12px; }
.lang-jump button { flex: 1; min-height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 15px; font-weight: 600; }
.theory { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 72px); }
.sheet .theory { scroll-margin-top: 12px; }
.theory + .theory { margin-top: 14px; }
.lang-label { display: inline-block; margin-bottom: 10px; padding: 2px 9px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.theory[dir="rtl"] .lang-label { font-size: 13px; letter-spacing: 0; }
.theory .note { margin: 0 0 14px; }

/* Help button in the hero */
.hero-help { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; }
.hero-help.alone { margin-left: auto; }
.hero-help .i { width: 22px; height: 22px; }

/* Daily goal */
.goal { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin: 0 0 12px; border: 0; text-align: left; color: var(--ink); transition: transform .12s ease; }
.goal:active { transform: scale(.98); }
.goal-ic { width: 42px; height: 42px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.goal.done .goal-ic { background: var(--green-soft); color: var(--green); }
.goal-txt { flex: 1; min-width: 0; }
.goal-txt b { display: block; font: 800 17px var(--round); }
.goal-txt small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }
.goal .meter { margin-top: 7px; }
.goal .go { width: 38px; height: 38px; }
.goal .go .i path { fill: currentColor; }

/* Trap words */
mark.trap { background: none; color: inherit; font-weight: inherit; padding: 0 1px; border-radius: 3px; box-shadow: inset 0 -0.42em 0 var(--amber-soft); text-decoration: underline 2px var(--amber); text-underline-offset: 3px; }

/* Persian question translation */
.qtr.fa { margin-top: 10px; padding-top: 10px; border-top: 0; text-align: right; font-family: -apple-system, "SF Arabic", "Geeza Pro", Tahoma, sans-serif; line-height: 1.85; }
.qtr.fa .lang-tag { margin-right: 0; margin-left: 8px; }
.qtr.missing { color: var(--muted); font-size: 14.5px; }
.rv-fa { text-align: right; font-family: -apple-system, "SF Arabic", "Geeza Pro", Tahoma, sans-serif; line-height: 1.8; }

/* Install guide */
.sheet .seg { margin: 14px 0 6px; }
.steps { list-style: none; margin: 10px 0 4px; padding: 0; counter-reset: step; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); counter-increment: step; }
.steps li:last-child { border-bottom: 0; }
.step-ic { position: relative; width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.step-ic::after { content: counter(step); position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; font: 800 12px/20px var(--round); text-align: center; }
.steps b { display: block; font-weight: 650; font-size: 16.5px; }
.steps b b { display: inline; font-weight: 800; }
.steps small { display: block; margin-top: 3px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.steps small b { display: inline; font-size: inherit; color: var(--ink-2); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px; background: var(--ink); color: var(--bg); font-weight: 650; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: toast 3.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
.goal { margin-top: 14px; }
