@font-face { font-family: 'Amiri'; src: url('../fonts/amiri-arabic-400-normal.woff2') format('woff2'); font-weight: 400; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../fonts/amiri-arabic-700-normal.woff2') format('woff2'); font-weight: 700; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../fonts/amiri-latin-400-normal.woff2') format('woff2'); font-weight: 400; unicode-range: U+0000-00FF; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('../fonts/dm-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('../fonts/dm-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('../fonts/dm-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('../fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('../fonts/cormorant-garamond-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #F6F0E2; --card: #FFFCF4; --card2: #F1EAD8; --ink: #1E2928; --muted: #6B6F66; --line: #E2D8C2;
  --teal: #1F5A43; --teal2: #2B7355; --tealsoft: #DCEBE1; --gold: #B8901F; --goldsoft: #F3E6BE;
  --ok: #2E7D4F; --oksoft: #DDEFE3; --bad: #B0432D; --badsoft: #F6DDD6; --warn: #A86B00;
  --st0: #E4DCCB; --st1: #E9D9A6; --st2: #B9D6C4; --st3: #4F9A72; --st4: #1F5A43;
  --shadow: 0 1px 2px rgba(30,41,40,.06), 0 4px 14px rgba(30,41,40,.06);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111716; --card: #19211F; --card2: #212B29; --ink: #ECE6D6; --muted: #A3A69C; --line: #2E3936;
    --teal: #6CC59A; --teal2: #86D3AE; --tealsoft: #1E3529; --gold: #D9B44A; --goldsoft: #3A3220;
    --ok: #6CC08E; --oksoft: #1E3326; --bad: #E58A74; --badsoft: #3A2420;
    --st0: #2C3533; --st1: #5B5130; --st2: #2F5240; --st3: #3F8A62; --st4: #86D3AE;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111716; --card: #19211F; --card2: #212B29; --ink: #ECE6D6; --muted: #A3A69C; --line: #2E3936;
  --teal: #6CC59A; --teal2: #86D3AE; --tealsoft: #1E3529; --gold: #D9B44A; --goldsoft: #3A3220;
  --ok: #6CC08E; --oksoft: #1E3326; --bad: #E58A74; --badsoft: #3A2420;
  --st0: #2C3533; --st1: #5B5130; --st2: #2F5240; --st3: #3F8A62; --st4: #86D3AE; --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: 'DM Sans', system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
.ar, [lang="ar"] { font-family: 'Amiri', 'Geeza Pro', serif; direction: rtl; unicode-bidi: isolate; font-size: 1.32em; line-height: 1.9; }
.ar.big { font-size: 2rem; line-height: 2.1; }
.ar.huge { font-size: 2.4rem; line-height: 2.2; }
h1, h2, h3 { font-family: 'Cormorant', Georgia, serif; font-weight: 700; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.55rem; } h3 { font-size: 1.25rem; }
a { color: var(--teal); }
small, .muted { color: var(--muted); }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
header.top .logo { font-family: 'Amiri', serif; font-size: 1.6rem; color: var(--teal); line-height: 1; }
header.top .ttl { font-family: 'Cormorant', serif; font-weight: 700; font-size: 1.25rem; flex: 1; }
.sync { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.busy { background: var(--gold); } .dot.err { background: var(--bad); }
main { padding: 16px; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs .in { display: flex; width: 100%; max-width: 760px; }
nav.tabs a { flex: 1; text-align: center; padding: 8px 2px 9px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 500; }
nav.tabs a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
nav.tabs a.on { color: var(--teal); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.hero { background: linear-gradient(160deg, var(--teal) 0%, var(--teal2) 100%); color: #FFFCF4; border: none; }
.card.hero .muted, .card.hero small { color: #D5E9E5; }
.card.gold { background: var(--goldsoft); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
.card.flat { box-shadow: none; background: var(--card2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stack > * + * { margin-top: 10px; }
.kicker { text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 700; color: var(--gold); }
.card.hero .kicker { color: #F3E6BE; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--card2); color: var(--ink); border: 1px solid var(--line); }
.pill.star { background: var(--goldsoft); color: #6E5408; border-color: transparent; }
.pill.ok { background: var(--oksoft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--badsoft); color: var(--bad); border-color: transparent; }
.st0 { background: var(--st0); } .st1 { background: var(--st1); } .st2 { background: var(--st2); } .st3 { background: var(--st3); color: #fff; } .st4 { background: var(--st4); color: #fff; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #FFFCF4; }
.card.hero .btn.primary { background: #FFFCF4; color: var(--teal); border-color: #FFFCF4; }
.card.hero .btn { background: transparent; color: #FFFCF4; border-color: rgba(255,255,255,.4); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }

.stat { background: var(--card2); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.5rem; font-family: 'Cormorant', serif; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }

.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .3s; }

/* lektion */
.step h3 { margin-bottom: .3em; }
.step p { margin: .4em 0; }
.rule { border-inline-start: 4px solid var(--gold); padding: 6px 14px; background: var(--goldsoft); border-radius: 0 12px 12px 0; }
.matn { text-align: center; }
.matn .ar.huge { color: var(--teal); }
.wfw { display: flex; flex-wrap: wrap; flex-direction: row-reverse; gap: 8px; justify-content: center; margin: 10px 0; }
.wfw button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 4px 12px 6px; cursor: pointer; color: var(--ink); }
.wfw button .ar { font-size: 1.5rem; display: block; }
.wfw button small { display: block; font-size: .72rem; max-width: 9em; line-height: 1.25; }
table.t { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: start; vertical-align: top; }
table.t th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.t td .ar { font-size: 1.25em; }
.ex { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ex:last-child { border-bottom: 0; }
.irablist { margin: 8px 0 0; padding: 0; list-style: none; }
.irablist li { padding: 6px 10px; border-radius: 10px; background: var(--card2); margin-bottom: 6px; }
.irablist li .w { font-family: 'Amiri', serif; font-size: 1.35rem; color: var(--teal); }
.irablist li .i { font-family: 'Amiri', serif; font-size: 1.12rem; direction: rtl; display: block; }
.irablist li small { display: block; }

/* frågor */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.qprompt { font-weight: 600; margin-bottom: 12px; }
.sent { display: flex; flex-wrap: wrap; flex-direction: row-reverse; justify-content: center; gap: 4px 6px; padding: 12px 6px 16px; }
.tok { font-family: 'Amiri', serif; font-size: 1.85rem; line-height: 1.8; padding: 0 8px 2px; border-radius: 10px; border: 2px solid transparent; background: none; color: var(--ink); cursor: default; }
.tok.click { cursor: pointer; background: var(--card2); }
.tok.hl { border-color: var(--gold); background: var(--goldsoft); }
.tok.ok { border-color: var(--ok); background: var(--oksoft); }
.tok.bad { border-color: var(--bad); background: var(--badsoft); }
.opts { display: grid; gap: 10px; }
.opt { text-align: start; border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 0; min-height: 54px; justify-content: center; }
.opt .ar { font-size: 1.45rem; line-height: 1.6; text-align: right; }
.opt small { color: var(--muted); }
.opt.ok { border-color: var(--ok); background: var(--oksoft); }
.opt.bad { border-color: var(--bad); background: var(--badsoft); }
.opt:disabled { cursor: default; }
.mcq { font-family: 'Amiri', serif; font-size: 1.7rem; line-height: 2; text-align: center; direction: rtl; padding: 8px 0 14px; }
.chips { display: flex; flex-wrap: wrap; flex-direction: row-reverse; gap: 8px; justify-content: center; }
.chip { font-family: 'Amiri', serif; font-size: 1.2rem; line-height: 1.5; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 6px 12px; cursor: pointer; direction: rtl; }
.chip.used { opacity: .25; pointer-events: none; }
.answerbox { min-height: 64px; border: 2px dashed var(--line); border-radius: 14px; padding: 10px; margin: 12px 0; display: flex; flex-wrap: wrap; flex-direction: row-reverse; gap: 8px; justify-content: flex-start; align-items: center; }
.answerbox .chip { background: var(--tealsoft); border-color: transparent; }
.answerbox.ok { border-color: var(--ok); background: var(--oksoft); }
.answerbox.bad { border-color: var(--bad); background: var(--badsoft); }
.fb { margin-top: 14px; border-radius: 14px; padding: 14px; }
.fb.ok { background: var(--oksoft); }
.fb.bad { background: var(--badsoft); }
.fb .irab { font-family: 'Amiri', serif; font-size: 1.25rem; direction: rtl; line-height: 1.8; display: block; margin: 6px 0; }
.timer { height: 5px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.timer > i { display: block; height: 100%; background: var(--teal); }
.ai { white-space: pre-wrap; background: var(--card2); border-radius: 12px; padding: 12px; margin-top: 10px; font-size: .95rem; }
.ai .ar { font-size: 1.2em; }

/* plan */
.slot { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.slot:last-child { border-bottom: 0; }
.slot .date { width: 52px; flex-shrink: 0; text-align: center; font-size: .75rem; color: var(--muted); line-height: 1.2; }
.slot .date b { display: block; font-size: 1.1rem; color: var(--ink); }
.slot .body { flex: 1; min-width: 0; }
.slot .body > .ar { font-size: 1.2rem; line-height: 1.5; display: block; text-align: right; }
.slot .body small { display: block; }
.slot .mark { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.slot.today { background: var(--goldsoft); border-radius: 12px; }
.slot.free { opacity: .6; }
details.phase > summary { list-style: none; cursor: pointer; }
details.phase > summary::-webkit-details-marker { display: none; }

/* tracker */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--card2); display: block; }
.heat i.h1 { background: color-mix(in srgb, var(--teal) 25%, var(--card2)); }
.heat i.h2 { background: color-mix(in srgb, var(--teal) 50%, var(--card2)); }
.heat i.h3 { background: color-mix(in srgb, var(--teal) 75%, var(--card2)); }
.heat i.h4 { background: var(--teal); }
.heat i.brk { background: repeating-linear-gradient(45deg, var(--card2), var(--card2) 2px, var(--line) 2px, var(--line) 4px); }
.heat i.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.mgrid { display: flex; flex-wrap: wrap; gap: 5px; }
.mgrid a { width: 26px; height: 26px; border-radius: 6px; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; vertical-align: -1px; margin-inline-end: 4px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { font-size: 10px; fill: var(--muted); font-family: 'DM Sans', sans-serif; }

/* penna */
.pad { position: relative; background: #FFFDF6; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; touch-action: none; }
.pad canvas { display: block; width: 100%; touch-action: none; }

input[type=text], input[type=password], textarea, select { width: 100%; font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
textarea { min-height: 120px; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem; z-index: 50; max-width: 90vw; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mb0 { margin-bottom: 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.big-number { font-family: 'Cormorant', serif; font-size: 3rem; font-weight: 700; line-height: 1; }
.steps-dots { display: flex; gap: 6px; }
.steps-dots i { flex: 1; height: 4px; border-radius: 9px; background: var(--card2); }
.steps-dots i.on { background: var(--gold); }
@media (min-width: 600px) { .opts.two { grid-template-columns: 1fr 1fr; } }

/* ---------- hifz ---------- */
.htext { direction: rtl; text-align: right; font-family: 'Amiri', serif; font-size: 1.75rem; line-height: 2.15; }
.htext.big { font-size: 2.1rem; line-height: 2.3; }
.htext.center { text-align: center; }
.w { border-radius: 8px; padding: 0 2px; transition: background .12s, color .12s; cursor: pointer; }
.w.now { background: var(--goldsoft); color: var(--teal); box-shadow: 0 0 0 2px var(--goldsoft); }
.w.isn { color: color-mix(in srgb, var(--ink) 72%, var(--bg)); }
.w.hid { color: transparent; background: var(--card2); box-shadow: inset 0 -2px 0 var(--line); }
.w.hid.rev { color: var(--gold); background: transparent; box-shadow: none; }
.w.fl { color: var(--teal); }
.w.fl i { font-style: normal; color: var(--line); }
.ctx { direction: rtl; text-align: right; font-family: 'Amiri', serif; font-size: 1.25rem; line-height: 1.9; color: var(--muted); border-inline-start: 3px solid var(--line); padding-inline-start: 10px; margin-bottom: 8px; }
.tr { color: var(--muted); font-size: .95rem; line-height: 1.45; margin-top: 4px; }
.tr .en { display: block; font-style: italic; }
.phr { padding: 8px 0 10px; border-bottom: 1px dashed var(--line); }
.phr:last-child { border-bottom: 0; }
.phr .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.phr .num { font-size: .72rem; color: var(--muted); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.phr .num i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.phr.isn .htext { font-size: 1.45rem; color: color-mix(in srgb, var(--ink) 75%, var(--bg)); }
.phr.cur { background: color-mix(in srgb, var(--goldsoft) 55%, transparent); border-radius: 12px; padding-inline: 8px; }
.gradebar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.gradebar .btn { flex-direction: column; gap: 0; min-height: 58px; }
.gradebar .btn small { font-weight: 500; font-size: .72rem; color: inherit; opacity: .8; }
.btn.g0 { background: var(--badsoft); border-color: transparent; color: var(--bad); }
.btn.g1 { background: var(--goldsoft); border-color: transparent; color: #7A5A00; }
.btn.g2 { background: var(--oksoft); border-color: transparent; color: var(--ok); }
:root[data-theme="dark"] .btn.g1 { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.g1 { color: var(--gold); } }
.player { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.player .btn.play { width: 52px; height: 52px; border-radius: 50%; padding: 0; min-height: 0; }
.rates { display: flex; gap: 4px; }
.rates button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 9px; padding: 4px 8px; font: inherit; font-size: .8rem; cursor: pointer; }
.rates button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hcard { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.hcard .no { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.hcard b { display: block; margin-top: 6px; font-size: .95rem; line-height: 1.25; }
.hcard .bar { margin-top: 8px; height: 5px; }
.map42 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.map42 a { aspect-ratio: 1; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; text-decoration: none; color: var(--ink); }
.map42 a.st3, .map42 a.st4 { color: #fff; }
.stage { display: flex; gap: 4px; margin: 4px 0 12px; }
.stage i { flex: 1; height: 5px; border-radius: 9px; background: var(--card2); }
.stage i.on { background: var(--teal); }
.stage i.cur { background: var(--gold); }
.sesshead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sesshead .bar { flex: 1; }
.sesshead .x { background: none; border: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.chip.ok { background: var(--oksoft); border-color: var(--ok); }
.chip.no { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.answerbox .chip { font-size: 1.35rem; }
.counter { font-family: 'Cormorant', serif; font-size: 2.2rem; font-weight: 700; color: var(--teal); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: 0; }
.list-row .body { flex: 1; min-width: 0; }
.ring { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Cormorant', serif; font-size: 1.5rem; }
.week { display: flex; gap: 6px; }
.week div { flex: 1; text-align: center; font-size: .7rem; color: var(--muted); }
.week i { display: block; height: 30px; border-radius: 8px; background: var(--card2); margin-bottom: 3px; }
.week i.on { background: var(--teal); }
.week i.part { background: color-mix(in srgb, var(--teal) 40%, var(--card2)); }
.week i.td { outline: 2px solid var(--gold); outline-offset: 1px; }
.nowplaying { position: sticky; top: 58px; z-index: 5; }
.map42 { max-width: 560px; }
svg.chart.small { max-width: 460px; max-height: 160px; }
