@font-face {
  font-family: "Mizan Amiri Quran";
  src: url("assets/amiri-quran.ttf?v=17") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-2: #ece9df;
  --surface-3: #e3ece7;
  --ink: #17221f;
  --muted: #6f7773;
  --line: #dcd9cf;
  --brand: #173d35;
  --brand-2: #24594d;
  --brand-soft: #d9e9e1;
  --accent: #d89a3c;
  --accent-soft: #fae9ca;
  --coral: #c96b54;
  --coral-soft: #f6ddd6;
  --blue: #477c91;
  --blue-soft: #dbeaf0;
  --purple: #6e658d;
  --purple-soft: #e7e2f0;
  --success: #2d7d5a;
  --danger: #b7473e;
  --shadow-sm: 0 2px 10px rgba(20, 39, 33, .05);
  --shadow-md: 0 14px 35px rgba(20, 39, 33, .10);
  --shadow-lg: 0 30px 70px rgba(10, 32, 26, .18);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --sidebar: 244px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --arabic: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", "Amiri", serif;
}

[data-theme="dark"] {
  --bg: #101714;
  --surface: #17201d;
  --surface-2: #202b27;
  --surface-3: #20352e;
  --ink: #ecf1ee;
  --muted: #a1aaa6;
  --line: #2d3935;
  --brand: #d9ece4;
  --brand-2: #92c9b7;
  --brand-soft: #244338;
  --accent: #efb75e;
  --accent-soft: #4e3b20;
  --coral: #e2917b;
  --coral-soft: #4c2e29;
  --blue: #7eb3c7;
  --blue-soft: #243e48;
  --purple: #ada2ce;
  --purple-soft: #342f46;
  --success: #6cc598;
  --danger: #ef8479;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .14);
  --shadow-md: 0 14px 35px rgba(0, 0, 0, .25);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
a { color: inherit; }
p, h1, h2, h3, h4 { margin-top: 0; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.arabic { direction: rtl; font-family: var(--arabic); line-height: 1.7; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: var(--sidebar); padding: 28px 18px 20px; display: flex; flex-direction: column; color: #edf5f1; background: #102f28; background-image: radial-gradient(circle at 20% 0%, rgba(79, 142, 123, .22), transparent 34%), linear-gradient(165deg, #173d35, #0d2822 75%); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 27px; }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 14px; background: rgba(255,255,255,.08); color: #f2bd6a; font: 700 25px/1 var(--arabic); box-shadow: inset 0 1px rgba(255,255,255,.12); }
.brand-copy { display: grid; gap: 3px; }
.brand-copy strong { font-size: 19px; letter-spacing: .02em; }
.brand-copy small { color: #9fc0b5; font: 600 13px/1 var(--arabic); letter-spacing: .08em; }
.side-nav { display: grid; gap: 6px; }
.nav-item { position: relative; width: 100%; border: 0; border-radius: 13px; padding: 11px 12px; display: flex; align-items: center; gap: 11px; color: #aec4bd; background: transparent; cursor: pointer; text-align: left; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.11); box-shadow: inset 3px 0 #e4aa4f; }
.nav-item svg { width: 20px; height: 20px; }
.nav-item span { flex: 1; font-size: 14px; font-weight: 650; }
.nav-item b { min-width: 23px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 8px; color: #213128; background: #f0b85f; font-size: 11px; }
.sidebar-quote { margin-top: auto; padding: 17px 15px; border: 1px solid rgba(255,255,255,.10); border-radius: 16px; background: rgba(255,255,255,.055); }
.quote-mark { color: #e4aa4f; font: 700 28px/1 Georgia, serif; }
.sidebar-quote p { margin: -5px 0 8px; font-size: 12.5px; line-height: 1.55; }
.sidebar-quote small { color: #98afa7; font-size: 10.5px; }
.sidebar-foot { padding: 15px 4px 0; display: flex; justify-content: space-between; color: #6f9287; font-size: 9.5px; }

.main-area { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 72px; padding: 14px clamp(20px, 4vw, 48px); display: flex; align-items: center; gap: 18px; background: color-mix(in srgb, var(--bg) 86%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent); backdrop-filter: blur(18px); }
.search-trigger { width: min(470px, 50vw); padding: 11px 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; }
.search-trigger svg { width: 18px; height: 18px; }
.search-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
kbd { margin-left: auto; padding: 3px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font: 600 10px/1.4 var(--font); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mini-stat { height: 40px; padding: 0 10px; display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.mini-stat svg { width: 17px; height: 17px; color: var(--coral); }
.mini-stat.xp svg { color: var(--accent); }
.mini-stat strong { font-size: 13px; }
.mini-stat span { color: var(--muted); font-size: 10px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
.icon-btn svg { width: 19px; height: 19px; }
.mobile-menu { display: none; }
.page { width: min(1320px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 48px); padding-bottom: 70px; }

.page-head { margin-bottom: 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.eyebrow { margin-bottom: 8px; color: var(--brand-2); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.page-head h1 { margin-bottom: 8px; font-size: clamp(27px, 3vw, 39px); letter-spacing: -.04em; }
.page-head p { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.btn { min-height: 43px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; font-size: 13px; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; text-decoration: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: #1d4b40; box-shadow: 0 8px 20px rgba(29,75,64,.20); }
[data-theme="dark"] .btn-primary { color: #0d211b; background: #8ac3b0; }
.btn-secondary { border-color: var(--line); background: var(--surface); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-accent { color: #2f2413; background: var(--accent); }
.chip { padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 11px; font-weight: 700; }
.chip svg { width: 13px; height: 13px; }

/* Dashboard */
.welcome-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 20px; }
.hero-card { position: relative; min-height: 290px; overflow: hidden; padding: clamp(27px, 4vw, 43px); border-radius: var(--radius-lg); color: #eff8f4; background: #173d35; background-image: radial-gradient(circle at 88% 12%, rgba(255,255,255,.12), transparent 28%), radial-gradient(circle at 70% 110%, rgba(222,167,81,.28), transparent 38%), linear-gradient(140deg, #1b4a3f, #102d27); box-shadow: var(--shadow-md); }
.hero-card::after { content: "ض ر ب"; position: absolute; right: 28px; bottom: -45px; color: rgba(255,255,255,.055); font: 700 112px/1 var(--arabic); white-space: nowrap; transform: rotate(-7deg); }
.hero-kicker { margin-bottom: 28px; display: inline-flex; align-items: center; gap: 8px; color: #c3dcd3; font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.hero-kicker span { width: 7px; height: 7px; border-radius: 50%; background: #ebb45f; box-shadow: 0 0 0 5px rgba(235,180,95,.12); }
.hero-card h1 { position: relative; z-index: 1; max-width: 620px; margin-bottom: 14px; font-size: clamp(31px, 4vw, 50px); line-height: 1.05; letter-spacing: -.055em; }
.hero-card h1 em { color: #efbd6d; font-style: normal; }
.hero-card > p { position: relative; z-index: 1; max-width: 560px; margin-bottom: 27px; color: #bbd3ca; font-size: 14px; line-height: 1.65; }
.hero-actions { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions .btn-primary { color: #173128; background: #f1bd69; }
.hero-actions .btn-ghost { color: #e5f0ec; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.07); }
.today-card { padding: 23px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.today-head { display: flex; align-items: center; justify-content: space-between; }
.today-head h3 { margin: 0; font-size: 15px; }
.today-head span { color: var(--muted); font-size: 10px; }
.goal-ring { --p: 0; position: relative; width: 142px; height: 142px; margin: 23px auto 18px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }
.goal-ring::before { content: ""; position: absolute; inset: 11px; border-radius: inherit; background: var(--surface); }
.goal-ring div { position: relative; z-index: 1; display: grid; text-align: center; }
.goal-ring strong { font-size: 29px; letter-spacing: -.05em; }
.goal-ring span { color: var(--muted); font-size: 10px; }
.today-list { display: grid; gap: 9px; }
.today-item { padding: 9px 10px; display: flex; align-items: center; gap: 9px; border-radius: 10px; background: var(--surface-2); font-size: 11px; }
.today-item i { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-soft); color: var(--brand-2); font-style: normal; }
.today-item span { flex: 1; }
.today-item b { font-size: 10px; }
.section-row { margin: 32px 0 15px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-row h2 { margin: 0 0 5px; font-size: 20px; letter-spacing: -.02em; }
.section-row p { margin: 0; color: var(--muted); font-size: 12px; }
.text-link { border: 0; padding: 5px; color: var(--brand-2); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric-card { padding: 17px; display: flex; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric-icon { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 13px; color: var(--brand-2); background: var(--brand-soft); }
.metric-icon.gold { color: #986725; background: var(--accent-soft); }
.metric-icon.coral { color: var(--coral); background: var(--coral-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon svg { width: 19px; }
.metric-copy { min-width: 0; display: grid; gap: 2px; }
.metric-copy strong { font-size: 20px; letter-spacing: -.03em; }
.metric-copy span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.continue-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.continue-card { min-height: 202px; padding: 20px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; transition: transform .18s, box-shadow .18s; }
.continue-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.continue-top { display: flex; align-items: center; justify-content: space-between; }
.course-symbol { width: 41px; height: 41px; display: grid; place-items: center; border-radius: 13px; color: var(--brand-2); background: var(--brand-soft); font: 700 21px/1 var(--arabic); }
.continue-card.sharaf .course-symbol { color: #976727; background: var(--accent-soft); }
.continue-card.matan .course-symbol { color: var(--purple); background: var(--purple-soft); }
.course-level { padding: 5px 8px; border-radius: 7px; color: var(--muted); background: var(--surface-2); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.continue-card h3 { margin: 18px 0 5px; font-size: 15px; }
.continue-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.course-progress { margin-top: auto; padding-top: 17px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.bar { height: 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand-2); }
.continue-card.sharaf .bar span { background: var(--accent); }
.continue-card.matan .bar span { background: var(--purple); }
.course-progress b { color: var(--muted); font-size: 9px; }

/* Learning path */
.filter-bar { margin-bottom: 20px; padding: 8px; display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); width: fit-content; }
.filter-btn, .tab-btn { border: 0; padding: 9px 14px; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.filter-btn.active, .tab-btn.active { color: #fff; background: var(--brand-2); }
[data-theme="dark"] .filter-btn.active, [data-theme="dark"] .tab-btn.active { color: #10231d; background: var(--brand-2); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.module-card { position: relative; min-height: 250px; overflow: hidden; padding: 21px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: transform .2s, box-shadow .2s; }
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.module-card::before { content: ""; position: absolute; width: 90px; height: 90px; right: -30px; top: -35px; border-radius: 50%; background: var(--tint, var(--brand-soft)); opacity: .9; }
.module-meta { position: relative; display: flex; align-items: center; justify-content: space-between; }
.module-number { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--tone, var(--brand-2)); background: var(--tint, var(--brand-soft)); font-size: 12px; font-weight: 850; }
.module-meta span:last-child { color: var(--muted); font-size: 10px; }
.module-ar { margin: 21px 0 2px; color: var(--tone, var(--brand-2)); font: 700 25px/1.5 var(--arabic); }
.module-card h3 { margin-bottom: 7px; font-size: 16px; }
.module-card p { margin-bottom: 18px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.module-foot { margin-top: auto; display: flex; align-items: center; gap: 12px; }
.module-foot .bar { flex: 1; }
.module-foot .bar span { background: var(--tone, var(--brand-2)); }
.module-foot b { color: var(--muted); font-size: 9px; }
.module-action { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.module-card.locked { opacity: .62; filter: grayscale(.35); }

/* Guided course */
.course-hero { min-height: 300px; margin-bottom: 28px; padding: clamp(27px, 4vw, 44px); display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 35px; overflow: hidden; position: relative; border-radius: var(--radius-lg); color: #edf7f3; background: radial-gradient(circle at 92% 0%, rgba(240,187,101,.22), transparent 28%), linear-gradient(135deg, #173d35, #102b25); box-shadow: var(--shadow-md); }
.course-hero::after { content: "نحو  صرف"; position: absolute; right: 20px; bottom: -33px; color: rgba(255,255,255,.045); font: 700 85px/1 var(--arabic); white-space: nowrap; }
.course-hero-copy { position: relative; z-index: 1; }
.course-hero .eyebrow { color: #efbd6d; }
.course-hero h1 { max-width: 650px; margin-bottom: 12px; font-size: clamp(31px, 4vw, 48px); line-height: 1.04; letter-spacing: -.055em; }
.course-hero p { max-width: 650px; margin-bottom: 25px; color: #bcd5cc; font-size: 13px; line-height: 1.7; }
.course-hero .btn-ghost { color: #e6f1ed; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.06); }
.course-hero-progress { position: relative; z-index: 1; display: grid; justify-items: center; }
.course-ring { --p: 0; position: relative; width: 155px; height: 155px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(#efb75e calc(var(--p) * 1%), rgba(255,255,255,.12) 0); }
.course-ring::before { content: ""; position: absolute; inset: 12px; border-radius: inherit; background: #163830; }
.course-ring div { position: relative; z-index: 1; display: grid; justify-items: center; }
.course-ring strong { font-size: 28px; letter-spacing: -.05em; }
.course-ring span { color: #a9c5bb; font-size: 9px; }
.course-hero-progress p { margin: 13px 0 0; font-size: 10px; }
.course-hero-progress p b { color: #efbd6d; }
.course-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: start; gap: 22px; }
.course-overview { position: sticky; top: 94px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.course-overview-head { padding: 3px 4px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.course-overview-head > span { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: var(--brand-2); background: var(--brand-soft); }
.course-overview-head svg { width: 16px; }
.course-overview-head div { display: grid; gap: 3px; }
.course-overview-head b { font-size: 12px; }
.course-overview-head small { color: var(--muted); font-size: 9px; }
.course-unit-links { padding: 10px 0; display: grid; gap: 3px; }
.course-unit-links button { width: 100%; padding: 10px 7px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 11px; color: var(--ink); background: transparent; cursor: pointer; text-align: left; }
.course-unit-links button:hover { background: var(--surface-2); }
.course-unit-links button > span { width: 27px; height: 27px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--brand-2); background: var(--brand-soft); font-size: 9px; font-weight: 850; }
.course-unit-links button div { display: grid; gap: 2px; }
.course-unit-links button b { font-size: 10px; }
.course-unit-links button small { color: var(--muted); font-size: 8px; }
.course-review-card { margin-top: 6px; padding: 12px; display: grid; grid-template-columns: 28px 1fr; gap: 8px; border-radius: 12px; color: var(--brand-2); background: var(--brand-soft); }
.course-review-card > svg { width: 18px; }
.course-review-card div { display: grid; gap: 3px; }
.course-review-card b { font-size: 9px; }
.course-review-card span { color: color-mix(in srgb, var(--brand-2) 75%, var(--muted)); font-size: 8px; line-height: 1.4; }
.course-review-card button { grid-column: 2; width: fit-content; padding: 0; border: 0; color: var(--brand-2); background: transparent; font-size: 9px; font-weight: 800; cursor: pointer; }
.course-units { display: grid; gap: 20px; }
.course-unit { scroll-margin-top: 96px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.unit-head { padding-bottom: 18px; display: grid; grid-template-columns: 43px minmax(0, 1fr) 70px; align-items: start; gap: 13px; border-bottom: 1px solid var(--line); }
.unit-number { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: var(--brand-2); background: var(--brand-soft); font-size: 11px; font-weight: 850; }
.unit-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.unit-title-row h2 { margin: 0; font-size: 18px; }
.unit-title-row .arabic { color: var(--brand-2); font-size: 14px; }
.unit-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.unit-percent { display: grid; gap: 6px; text-align: right; }
.unit-percent b { color: var(--muted); font-size: 10px; }
.mini-progress { width: 70px; height: 4px; overflow: hidden; display: block; border-radius: 99px; background: var(--surface-2); }
.mini-progress i { height: 100%; display: block; border-radius: inherit; background: var(--brand-2); }
.course-lesson-list { padding-top: 8px; display: grid; }
.course-lesson { width: 100%; min-height: 78px; padding: 12px 10px; display: grid; grid-template-columns: 42px minmax(0, 1fr) 116px 24px; align-items: center; gap: 12px; border: 1px solid transparent; border-radius: 14px; color: var(--ink); background: transparent; cursor: pointer; text-align: left; transition: .17s ease; }
.course-lesson + .course-lesson { border-top-color: var(--line); border-top-left-radius: 0; border-top-right-radius: 0; }
.course-lesson:hover { border-color: var(--line); border-radius: 14px; background: var(--surface-2); transform: translateX(2px); }
.course-lesson.current { margin: 5px 0; border-color: color-mix(in srgb, var(--brand-2) 28%, var(--line)); background: var(--brand-soft); box-shadow: inset 3px 0 var(--brand-2); }
.course-lesson.checkpoint { margin: 6px 0; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface)); }
.course-lesson.checkpoint.current { box-shadow: inset 3px 0 var(--accent); }
.lesson-node { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--brand-2); background: var(--surface); font: 800 17px/1 var(--arabic); }
.course-lesson.done .lesson-node { color: #fff; border-color: var(--success); background: var(--success); }
.course-lesson.checkpoint .lesson-node { color: #8a6020; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--accent-soft); }
.lesson-node svg { width: 17px; }
.lesson-main { min-width: 0; display: grid; gap: 2px; }
.lesson-kicker { color: var(--brand-2); font-size: 8px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.checkpoint .lesson-kicker { color: #966824; }
.lesson-main strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lesson-main small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lesson-meta { display: grid; justify-items: end; gap: 4px; }
.lesson-meta small { color: var(--muted); font-size: 8px; }
.lesson-meta b { color: var(--brand-2); font-size: 9px; }
.course-lesson.done .lesson-meta b { color: var(--success); }
.lesson-arrow { color: var(--muted); }
.lesson-arrow svg { width: 16px; }

.lesson-drawer { display: grid; gap: 18px; }
.lesson-intro { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.lesson-intro-top { display: flex; align-items: flex-start; gap: 15px; }
.lesson-intro .module-number { flex: 0 0 auto; }
.lesson-intro h2 { margin: 0 0 4px; font-size: 20px; }
.lesson-intro p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.concept-list { display: grid; gap: 10px; }
.concept-row { padding: 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.concept-index { width: 28px; height: 28px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--muted); background: var(--surface-2); font-size: 10px; font-weight: 800; }
.concept-copy { min-width: 0; flex: 1; }
.concept-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.concept-copy small { color: var(--muted); font-size: 10px; }
.concept-row .arabic { max-width: 190px; overflow: hidden; color: var(--brand-2); font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }

/* Flashcard */
.study-setup { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .55fr); gap: 20px; }
.deck-panel, .study-summary { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.deck-panel h2, .study-summary h2 { margin-bottom: 6px; font-size: 18px; }
.deck-panel > p, .study-summary > p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.deck-options { margin: 20px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.deck-option { padding: 16px 12px; display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; text-align: left; }
.deck-option.active { border-color: var(--brand-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-2) 18%, transparent); background: var(--brand-soft); }
.deck-option b { font-size: 12px; }
.deck-option small { color: var(--muted); font-size: 9px; }
.study-config { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 10px; font-weight: 750; }
.field select, .field input { min-height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 8px 11px; color: var(--ink); background: var(--surface-2); }
.setup-actions { margin-top: 20px; display: flex; justify-content: flex-end; }
.summary-number { margin: 25px 0 15px; text-align: center; }
.summary-number strong { display: block; color: var(--brand-2); font-size: 55px; line-height: 1; letter-spacing: -.07em; }
.summary-number span { color: var(--muted); font-size: 10px; }
.summary-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.summary-split div { padding: 11px 6px; display: grid; gap: 3px; border-radius: 11px; background: var(--surface-2); text-align: center; }
.summary-split b { font-size: 14px; }
.summary-split span { color: var(--muted); font-size: 8px; }
.method-note { margin-top: 18px; padding: 13px; display: flex; gap: 9px; border-radius: 12px; color: var(--brand-2); background: var(--brand-soft); font-size: 10px; line-height: 1.45; }
.method-note svg { flex: 0 0 auto; width: 17px; }
.flash-session { max-width: 820px; margin: 0 auto; }
.session-top { margin-bottom: 17px; display: flex; align-items: center; gap: 12px; }
.session-progress { flex: 1; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.session-progress .bar { height: 7px; }
.session-progress .bar span { background: var(--accent); }
.session-progress b { color: var(--muted); font-size: 10px; }
.flashcard-scene { height: min(480px, 57vh); min-height: 390px; perspective: 1200px; }
.flashcard { position: relative; width: 100%; height: 100%; border: 0; background: transparent; transform-style: preserve-3d; transition: transform .58s cubic-bezier(.2,.7,.2,1); cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; padding: clamp(25px, 5vw, 48px); display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-md); backface-visibility: hidden; }
.card-face.back { transform: rotateY(180deg); }
.card-label { position: absolute; top: 21px; left: 23px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.card-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.speak-btn { position: absolute; top: 18px; right: 20px; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); cursor: pointer; }
.speak-btn svg { width: 17px; }
.flash-arabic { max-width: 650px; color: var(--brand-2); font: 700 clamp(31px, 5vw, 50px)/1.65 var(--arabic); text-align: center; }
.flash-prompt { margin-top: 13px; color: var(--muted); font-size: 13px; }
.flip-hint { position: absolute; bottom: 22px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.flip-hint kbd { margin: 0; }
.back h2 { margin-bottom: 12px; font-size: clamp(24px, 4vw, 35px); text-align: center; }
.back-explain { max-width: 650px; margin-bottom: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; text-align: center; }
.example-box { width: min(580px, 100%); padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); text-align: center; }
.example-box .arabic { color: var(--brand-2); font-size: 20px; }
.example-box small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.source-tag { position: absolute; bottom: 21px; color: var(--muted); font-size: 9px; }
.rating-row { min-height: 75px; margin-top: 15px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.rating-btn { padding: 11px 7px; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.rating-btn:hover { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 9%, var(--surface)); }
.rating-btn b { color: var(--tone); font-size: 11px; }
.rating-btn span { color: var(--muted); font-size: 8px; }
.rating-placeholder { grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); font-size: 10px; }
.session-done { padding: 45px 25px; border: 1px solid var(--line); border-radius: 25px; background: var(--surface); text-align: center; box-shadow: var(--shadow-md); }
.done-icon { width: 78px; height: 78px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 26px; color: #fff; background: var(--success); transform: rotate(-4deg); }
.done-icon svg { width: 35px; height: 35px; }
.session-done h2 { margin-bottom: 7px; font-size: 28px; }
.session-done p { color: var(--muted); font-size: 12px; }
.done-stats { max-width: 460px; margin: 25px auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.done-stats div { padding: 15px; border-radius: 13px; background: var(--surface-2); }
.done-stats b { display: block; font-size: 21px; }
.done-stats span { color: var(--muted); font-size: 9px; }

/* Practice */
.practice-tabs { margin-bottom: 20px; display: flex; gap: 7px; }
.practice-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, .55fr); gap: 20px; }
.practice-main, .practice-aside { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.practice-heading { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.practice-heading h2 { margin-bottom: 6px; font-size: 18px; }
.practice-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.question-count { padding: 6px 9px; border-radius: 8px; color: var(--brand-2); background: var(--brand-soft); font-size: 9px; font-weight: 800; }
.quiz-question { margin: 28px 0 18px; font-size: 18px; line-height: 1.55; }
.quiz-question.arabic { color: var(--brand-2); font-size: 28px; text-align: center; }
.answer-list { display: grid; gap: 10px; }
.answer-btn { padding: 13px 15px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; }
.answer-btn:hover { border-color: var(--brand-2); }
.answer-btn .letter { width: 27px; height: 27px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--muted); background: var(--surface-2); font-size: 10px; font-weight: 800; }
.answer-btn.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 9%, var(--surface)); }
.answer-btn.correct .letter { color: #fff; background: var(--success); }
.answer-btn.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.answer-btn.wrong .letter { color: #fff; background: var(--danger); }
.answer-btn:disabled { cursor: default; }
.answer-explain { margin-top: 14px; padding: 14px; border-radius: 12px; color: var(--muted); background: var(--surface-2); font-size: 11px; line-height: 1.55; }
.quiz-actions { margin-top: 17px; display: flex; justify-content: flex-end; }
.practice-aside h3 { margin-bottom: 14px; font-size: 14px; }
.tip-list { display: grid; gap: 12px; }
.tip-item { display: flex; gap: 10px; }
.tip-item i { width: 24px; height: 24px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--brand-2); background: var(--brand-soft); font-style: normal; font-size: 9px; font-weight: 800; }
.tip-item b { display: block; margin-bottom: 3px; font-size: 10px; }
.tip-item span { display: block; color: var(--muted); font-size: 9px; line-height: 1.45; }
.irab-sentence { margin: 28px 0; padding: 26px 18px; display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; border-radius: 16px; background: var(--surface-2); direction: rtl; }
.word-token { padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font: 700 23px/1.5 var(--arabic); cursor: pointer; }
.word-token.active { border-color: var(--accent); background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 55%, var(--ink)); }
.irab-detail { min-height: 150px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.irab-empty { height: 110px; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.irab-word-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.irab-word-head .arabic { color: var(--brand-2); font-size: 26px; }
.irab-role { padding: 5px 9px; border-radius: 8px; color: var(--brand-2); background: var(--brand-soft); font-size: 9px; font-weight: 800; }
.irab-detail p { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.sentence-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.sentence-picker button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 10px; font-weight: 750; }
.sentence-picker button.active { color: #fff; border-color: var(--brand-2); background: var(--brand-2); }
.wazan-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.wazan-controls.with-bab { grid-template-columns: .72fr 1fr 1.2fr; }
.root-input-wrap { position: relative; }
.root-input-wrap input { padding-right: 56px; direction: rtl; font: 700 23px/1 var(--arabic); text-align: center; letter-spacing: .12em; }
.root-input-wrap span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 9px; }
.wazan-result { margin-top: 22px; }
.pattern-hero { padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 17px; color: #edf6f2; background: linear-gradient(135deg, #173d35, #24594d); }
.pattern-hero small { display: block; margin-bottom: 4px; color: #aac8be; font-size: 9px; }
.pattern-hero strong { display: block; font-size: 13px; }
.pattern-hero em { margin-top: 8px; display: block; color: #c9ddd6; font-size: 12px; font-style: normal; }
.pattern-hero .arabic { color: #f1bd69; font-size: 30px; }
.pattern-hero > .arabic { flex: 0 0 auto; text-align: right; }
.wazan-status { margin-top: 12px; padding: 13px 15px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid transparent; border-radius: 13px; }
.wazan-status > svg { width: 20px; height: 20px; flex: 0 0 auto; }
.wazan-status strong, .wazan-status span { display: block; }
.wazan-status strong { margin-bottom: 3px; font-size: 10px; }
.wazan-status span { font-size: 9px; line-height: 1.55; }
.wazan-status.success { color: color-mix(in srgb, var(--success) 75%, var(--ink)); border-color: color-mix(in srgb, var(--success) 28%, var(--line)); background: color-mix(in srgb, var(--success) 9%, var(--surface)); }
.wazan-status.warning { color: #8b662b; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.wazan-status.error { color: color-mix(in srgb, var(--danger) 78%, var(--ink)); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.forms-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.form-cell { padding: 13px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; }
.form-cell span { display: block; color: var(--muted); font-size: 8px; }
.form-cell b { display: block; margin-top: 6px; color: var(--brand-2); font: 700 18px/1.5 var(--arabic); }
.form-cell.is-empty { background: var(--surface-2); }
.form-cell.is-empty b { color: var(--muted); }
.caution-note { margin-top: 13px; padding: 11px 13px; border-radius: 11px; color: #8b662b; background: var(--accent-soft); font-size: 9px; line-height: 1.5; }
[data-theme="dark"] .caution-note { color: #efc47f; }
.sample-roots button { width: auto; padding: 0 11px; }
.validation-legend { margin-top: 17px; display: grid; gap: 7px; }
.validation-legend span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 8px; font-weight: 700; }
.validation-legend i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.validation-legend .success { color: var(--success); }
.validation-legend .warning { color: var(--accent); }
.validation-legend .error { color: var(--danger); }
[data-theme="dark"] .wazan-status.warning { color: #efc47f; }

/* Kitab reader */
.reader-book-hero { min-height: 255px; padding: 27px; display: grid; grid-template-columns: 135px minmax(0, 1fr) 170px; align-items: center; gap: 25px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.reader-cover { width: 125px; height: 174px; padding: 24px 14px 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px 16px 16px 8px; color: #f7e8c9; background: linear-gradient(145deg, #785b32, #4c351e); box-shadow: inset 8px 0 rgba(0,0,0,.16), inset 0 0 0 1px rgba(255,255,255,.13), 9px 13px 25px rgba(50,35,20,.22); font-family: var(--arabic); text-align: center; transform: rotate(-1.5deg); }
.reader-cover::before { content: ""; width: 42px; height: 1px; margin-bottom: 15px; background: #d7b06e; box-shadow: 0 5px #d7b06e; }
.reader-cover span { font-size: 21px; line-height: 1.3; }
.reader-cover b { font-size: 25px; line-height: 1.35; }
.reader-cover small { margin-top: 15px; color: #d9bd8f; font-size: 10px; }
.reader-book-copy { min-width: 0; }
.reader-badge { padding: 6px 9px; display: inline-flex; border-radius: 8px; color: #8a6020; background: var(--accent-soft); font-size: 9px; font-weight: 800; }
.reader-book-copy h2 { margin: 15px 0 1px; font-size: 23px; letter-spacing: -.035em; }
.reader-book-copy > .arabic { color: var(--brand-2); font-size: 19px; }
.reader-book-copy p { max-width: 680px; margin: 9px 0 13px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.reader-method { display: flex; flex-wrap: wrap; gap: 6px; }
.reader-method span { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-2); font-size: 8px; font-weight: 700; }
.reader-book-copy a { margin-top: 13px; display: inline-block; color: var(--brand-2); font-size: 9px; font-weight: 800; text-decoration: none; }
.reader-book-progress { padding: 19px; display: grid; gap: 9px; border-radius: 17px; background: var(--surface-2); }
.reader-progress-number { display: flex; align-items: baseline; gap: 5px; }
.reader-progress-number strong { color: var(--brand-2); font-size: 38px; letter-spacing: -.06em; }
.reader-progress-number span { color: var(--muted); font-size: 9px; }
.reader-book-progress small { color: var(--muted); font-size: 9px; }
.reading-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reading-card { min-height: 142px; padding: 17px; display: grid; grid-template-columns: 39px minmax(0, 1fr) auto; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); cursor: pointer; text-align: left; transition: transform .18s, box-shadow .18s, border-color .18s; }
.reading-card:hover { border-color: color-mix(in srgb, var(--brand-2) 35%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.reading-card.done { background: color-mix(in srgb, var(--brand-soft) 34%, var(--surface)); }
.reading-order { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--brand-2); background: var(--brand-soft); font-size: 10px; font-weight: 850; }
.reading-card.done .reading-order { color: #fff; background: var(--success); }
.reading-order svg { width: 17px; }
.reading-card-copy { min-width: 0; display: grid; gap: 3px; }
.reading-card-copy > small { color: var(--brand-2); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.reading-card-copy > strong { font-size: 13px; }
.reading-card-copy > span { color: var(--muted); font-size: 9px; }
.reading-card-copy > b { margin-top: 6px; overflow: hidden; color: var(--muted); font-size: 15px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.reading-open { display: flex; align-items: center; gap: 4px; color: var(--brand-2); font-size: 9px; font-weight: 800; }
.reading-open svg { width: 14px; }
.reading-lesson-shell { width: min(980px, 100%); margin: 0 auto; }
.reading-lesson-head { margin-bottom: 16px; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 13px; }
.reading-lesson-head > div { min-width: 0; }
.reading-lesson-head span:not(.chip) { color: var(--muted); font-size: 9px; }
.reading-lesson-head h1 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.035em; }
.reader-stepper { position: relative; margin-bottom: 17px; padding: 13px 17px; display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.reader-stepper::before { content: ""; position: absolute; left: 11%; right: 11%; top: 30px; height: 2px; background: var(--surface-2); }
.reader-stepper > i { position: absolute; left: 0; bottom: 0; height: 3px; max-width: 100%; background: var(--accent); transition: width .25s ease; }
.reader-stepper > div { position: relative; z-index: 1; display: grid; justify-items: center; gap: 5px; color: var(--muted); }
.reader-stepper > div > span { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--surface-2); border-radius: 50%; background: var(--surface); font-size: 9px; font-weight: 850; }
.reader-stepper > div > span svg { width: 15px; }
.reader-stepper > div > b { font-size: 8px; }
.reader-stepper > div.active { color: var(--brand-2); }
.reader-stepper > div.active > span { color: #fff; border-color: var(--brand-2); background: var(--brand-2); box-shadow: 0 0 0 5px var(--brand-soft); }
.reader-stepper > div.done { color: var(--success); }
.reader-stepper > div.done > span { color: #fff; border-color: var(--success); background: var(--success); }
.reader-workspace { min-height: 480px; padding: clamp(22px, 4vw, 36px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.reader-workspace.compact { min-height: 455px; }
.reader-instruction { margin-bottom: 24px; display: flex; align-items: flex-start; gap: 12px; }
.reader-instruction > span { width: 36px; height: 36px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 11px; color: var(--brand-2); background: var(--brand-soft); font-size: 10px; font-weight: 850; }
.reader-instruction h2 { margin-bottom: 4px; font-size: 19px; }
.reader-instruction p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.kitab-text { min-height: 150px; padding: clamp(24px, 5vw, 43px); display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 5px 8px; border-radius: 19px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 55%, var(--surface)), var(--surface-2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, var(--line)); }
.kitab-token { padding: 2px 5px; border: 0; border-bottom: 2px solid transparent; border-radius: 7px; color: var(--ink); background: transparent; font: 600 clamp(25px, 4vw, 38px)/1.8 var(--arabic); cursor: pointer; }
.kitab-token:hover, .kitab-token.active { color: #8a6020; border-bottom-color: var(--accent); background: var(--accent-soft); }
.vocab-drawer { min-height: 72px; margin-top: 14px; padding: 16px 17px; display: flex; align-items: flex-start; gap: 14px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); background: var(--surface); font-size: 10px; }
.vocab-drawer.open { border-style: solid; border-color: color-mix(in srgb, var(--brand-2) 28%, var(--line)); background: var(--brand-soft); }
.vocab-drawer > span { display: flex; align-items: center; gap: 8px; }
.vocab-drawer svg { width: 16px; }
.vocab-ar { min-width: 105px; padding-top: 4px; color: var(--brand-2); font-size: 25px; text-align: center; }
.vocab-copy { min-width: 0; display: grid; flex: 1 1 auto; gap: 10px; }
.vocab-copy > b { color: var(--ink); font-size: 11px; }
.vocab-detail { display: grid; gap: 3px; }
.vocab-detail small { color: var(--brand-2); font-size: 8px; font-weight: 850; letter-spacing: .035em; text-transform: uppercase; }
.vocab-detail span { color: var(--muted); font-size: 9px; line-height: 1.55; }
.vocab-drawer > em { margin-left: auto; padding: 5px 8px; border-radius: 7px; color: var(--brand-2); background: var(--surface); font-size: 8px; font-style: normal; font-weight: 800; }
.reader-actions { margin-top: auto; padding-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reader-question { padding: 25px; border-radius: 17px; background: var(--surface-2); text-align: center; }
.reader-question small { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.reader-question > .arabic { margin: 5px 0; color: var(--brand-2); font-size: 38px; }
.reader-question h3 { margin: 0; font-size: 12px; }
.reader-choice-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.reader-choice { min-height: 88px; padding: 13px; display: grid; place-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; }
.reader-choice:hover { border-color: var(--brand-2); }
.reader-choice .arabic { color: var(--brand-2); font-size: 23px; }
.reader-choice b { font-size: 9px; }
.reader-choice.correct, .ending-choice.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 11%, var(--surface)); }
.reader-choice.wrong, .ending-choice.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.reader-choice:disabled, .ending-choice:disabled { cursor: default; }
.reader-feedback { margin-top: 13px; padding: 13px 15px; display: flex; align-items: flex-start; gap: 9px; border-radius: 12px; font-size: 10px; line-height: 1.55; }
.reader-feedback svg { width: 17px; flex: 0 0 auto; }
.reader-feedback.success { color: var(--success); background: color-mix(in srgb, var(--success) 11%, var(--surface)); }
.reader-feedback.retry { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.reader-feedback .arabic { font-size: 15px; }
.ending-word { display: flex; align-items: baseline; justify-content: center; gap: 5px; }
.ending-word i { color: var(--accent); font: 800 27px/1 var(--arabic); }
.ending-options { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; direction: rtl; }
.ending-choice { min-height: 78px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; }
.ending-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.ending-choice .arabic { color: var(--brand-2); font-size: 30px; }
.revealed-text { position: relative; padding: 28px clamp(20px, 5vw, 45px); border-radius: 19px; color: #edf7f3; background: linear-gradient(145deg, #173d35, #102b25); text-align: center; }
.revealed-text .speak-btn { color: #e4efe9; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }
.revealed-text > .arabic { padding: 10px 30px; color: #f2c77f; font-size: clamp(25px, 4vw, 36px); }
.revealed-text > p { max-width: 720px; margin: 10px auto 0; color: #b9d1c8; font-size: 10px; line-height: 1.65; }
.reading-analysis { margin-top: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); }
.analysis-head { display: flex; align-items: flex-start; gap: 10px; }
.analysis-head > span { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--brand-2); background: var(--brand-soft); }
.analysis-head svg { width: 15px; }
.analysis-head b { font-size: 11px; }
.analysis-head p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.reading-analysis ol { margin: 13px 0 0 41px; padding-left: 16px; color: var(--muted); font-size: 10px; line-height: 1.65; }

.reader-mode-tabs { width: min(520px, 100%); margin: -7px 0 18px; padding: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); }
.reader-mode-tabs button { min-height: 44px; padding: 9px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-size: 14px; font-weight: 800; cursor: pointer; }
.reader-mode-tabs button svg { width: 18px; }
.reader-mode-tabs button.active { color: #fff; background: var(--brand-2); box-shadow: 0 7px 17px rgba(23,61,53,.2); }
.reader-mode-tabs.three-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(620px, 100%); }
.reader-return { margin-bottom: 18px; }
.reader-chapter-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 0 0 22px; color: var(--muted); font-size: 14px; font-weight: 700; }
.reader-chapter-picker select { flex: 1; min-width: 0; max-width: 520px; min-height: 48px; padding: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font: inherit; }
.reading-chapter-group { scroll-margin-top: 96px; }
.reading-source-link { display: block; width: fit-content; margin: 0 0 18px; color: var(--brand-2); font-size: 13px; line-height: 1.5; }
.reading-chapters { display: grid; gap: 24px; }
.reading-chapter-group { scroll-margin-top: 90px; }
.reading-chapter-group > header { margin-bottom: 11px; display: flex; align-items: center; gap: 12px; }
.reading-chapter-group > header > span { width: 40px; height: 40px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 12px; color: var(--brand-2); background: var(--brand-soft); font-size: 13px; font-weight: 850; }
.reading-chapter-group h3 { margin: 0; font-size: 19px; }
.reading-chapter-group p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.kitab-token.has-vocab { border-bottom-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.reader-comprehension-grid { margin-top: 14px; display: grid; gap: 9px; }
.reader-comprehension-choice { min-height: 62px; padding: 12px 15px; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); text-align: left; cursor: pointer; }
.reader-comprehension-choice > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--brand-2); background: var(--brand-soft); font-size: 13px; font-weight: 850; }
.reader-comprehension-choice b { font-size: 14px; line-height: 1.45; }
.reader-comprehension-choice:hover { border-color: var(--brand-2); }
.reader-comprehension-choice.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 11%, var(--surface)); }
.reader-comprehension-choice.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.reader-comprehension-choice:disabled { cursor: default; }
.comprehension-question h3 { max-width: 680px; margin: 10px auto 0; font-size: 18px; line-height: 1.45; }

.matn-integrity-card { margin-bottom: 16px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid color-mix(in srgb, var(--success) 36%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.matn-integrity-card > div { display: flex; align-items: center; gap: 13px; }
.integrity-seal { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 13px; color: #fff; background: var(--success); }
.integrity-seal svg { width: 20px; }
.matn-integrity-card b { font-size: 16px; }
.matn-integrity-card p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.matn-integrity-card dl { margin: 0; display: flex; gap: 8px; }
.matn-integrity-card dl div { min-width: 72px; padding: 9px 11px; border-radius: 11px; background: var(--surface); text-align: center; }
.matn-integrity-card dt { color: var(--brand-2); font-size: 20px; font-weight: 850; }
.matn-integrity-card dd { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.matn-toc { margin-bottom: 18px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.matn-toc button { min-height: 48px; padding: 9px 11px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); font-size: 13px; font-weight: 750; cursor: pointer; }
.matn-toc button:hover { border-color: var(--brand-2); color: var(--brand-2); }
.matn-toc span { color: var(--accent-ink); font-size: 11px; }
.matn-document-meta { width: min(860px, 100%); margin: 0 auto; padding: 24px; border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; background: linear-gradient(145deg, #173d35, #102b25); text-align: center; }
.matn-document-meta .arabic { color: #f2c77f; font-size: 31px; }
.matn-document-meta p { margin: 5px 0 0; color: #bad0c8; font-size: 13px; }
.matn-document { width: min(860px, 100%); margin: 0 auto; padding: clamp(30px, 6vw, 66px); border: 1px solid #d8c9ad; border-radius: 0 0 24px 24px; color: #211d16; background: #fffaf0; box-shadow: 0 20px 50px rgba(44,35,20,.12); font-family: var(--arabic); }
.matn-chapter { scroll-margin-top: 92px; }
.matn-chapter + .matn-chapter { margin-top: 48px; padding-top: 43px; border-top: 1px solid #dfd1b8; }
.matn-chapter h2 { width: fit-content; margin: 0 auto 27px; padding: 9px 20px; border: 1px solid #cbb98f; border-radius: 999px; color: #684b22; background: #f7ecd5; font: 700 24px/1.5 var(--arabic); }
.matn-chapter p { margin: 0 0 22px; font: 500 clamp(24px, 3.1vw, 31px)/2.05 var(--arabic); text-align: right; }
.matn-chapter p:last-child { margin-bottom: 0; }
.matn-source-note { width: min(860px, 100%); margin: 16px auto 0; padding: 17px 19px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.matn-source-note > div { display: flex; align-items: flex-start; gap: 10px; }
.matn-source-note svg { width: 19px; flex: 0 0 auto; color: var(--brand-2); }
.matn-source-note p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.matn-source-note span { display: flex; flex: 0 0 auto; gap: 10px; }
.matn-source-note a { color: var(--brand-2); font-size: 12px; font-weight: 800; text-decoration: none; }

/* Reader readability: body text stays legible on desktop and mobile. */
.reader-book-picker { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 20px; }
.reader-book-picker .btn { white-space: normal; font-size: 14px; min-height: 48px; }
.reader-badge { font-size: 12px; }
.reader-book-copy p { font-size: 15px; }
.reader-method span { font-size: 12px; }
.reader-book-copy a { font-size: 13px; }
.reader-progress-number span, .reader-book-progress small { font-size: 12px; }
.reading-card-copy > small { font-size: 11px; }
.reading-card-copy > strong { font-size: 16px; }
.reading-card-copy > span { font-size: 13px; }
.reading-card-copy > b { font-size: 20px; }
.reading-open { font-size: 12px; }
.reading-lesson-head span:not(.chip) { font-size: 12px; }
.reader-stepper { grid-template-columns: repeat(5, 1fr); }
.reader-stepper::before { left: 8%; right: 8%; }
.reader-stepper > div > b { font-size: 11px; }
.reader-instruction > span { font-size: 12px; }
.reader-instruction h2 { font-size: 22px; }
.reader-instruction p { font-size: 14px; }
.vocab-drawer { font-size: 14px; }
.vocab-copy > b { font-size: 15px; }
.vocab-detail small { font-size: 10px; }
.vocab-detail span { font-size: 13px; }
.vocab-drawer > em { font-size: 11px; }
.reader-question small { font-size: 11px; }
.reader-question h3 { font-size: 17px; }
.reader-choice b { font-size: 13px; }
.reader-feedback { font-size: 14px; }
.revealed-text > p { font-size: 15px; }
.analysis-head b { font-size: 15px; }
.analysis-head p { font-size: 13px; }
.reading-analysis ol { font-size: 14px; }

/* Library */
.library-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 22px; }
.library-filters { align-self: start; padding: 17px; display: grid; gap: 5px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.library-filters h3 { margin: 2px 7px 10px; font-size: 12px; }
.source-filter { border: 0; padding: 9px 10px; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font-size: 11px; font-weight: 650; }
.source-filter.active { color: var(--brand-2); background: var(--brand-soft); }
.source-list { display: grid; gap: 13px; }
.source-card { padding: 20px; display: grid; grid-template-columns: 61px 1fr auto; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.book-cover { width: 61px; height: 78px; padding: 8px; display: grid; place-items: center; border-radius: 8px 11px 11px 8px; color: #f4e9d6; background: var(--cover, #2d584c); box-shadow: inset 5px 0 rgba(0,0,0,.14), 4px 5px 10px rgba(0,0,0,.11); font: 700 15px/1.4 var(--arabic); text-align: center; }
.source-copy h3 { margin-bottom: 3px; font-size: 14px; }
.source-copy .arabic { color: var(--brand-2); font-size: 15px; }
.source-copy p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.source-link { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--surface-2); text-decoration: none; }
.source-link svg { width: 16px; }
.method-card { margin-top: 23px; padding: 22px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--radius); background: var(--accent-soft); }
.method-card h2 { font-size: 17px; }
.method-card p { margin: 0; color: color-mix(in srgb, var(--ink) 60%, var(--muted)); font-size: 11px; line-height: 1.65; }
.method-links { margin-top: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.method-links a { font-size: 10px; font-weight: 750; }

/* Overlay, search, dialog */
.overlay { position: fixed; z-index: 100; inset: 0; padding: 8vh 20px 20px; display: flex; justify-content: center; align-items: flex-start; background: rgba(7, 20, 16, .48); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .18s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.search-modal { width: min(670px, 100%); max-height: 78vh; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); transform: translateY(-10px) scale(.985); transition: transform .18s; }
.overlay.open .search-modal, .overlay.open .dialog { transform: translateY(0) scale(1); }
.search-input-row { height: 61px; padding: 0 16px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.search-input-row svg { color: var(--muted); }
.search-input-row input { flex: 1; height: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; }
.search-input-row button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface-2); font-size: 9px; cursor: pointer; }
.search-hints { padding: 13px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); }
.search-hints span { color: var(--muted); font-size: 9px; }
.search-hints button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface); font-size: 9px; cursor: pointer; }
.search-results { max-height: 54vh; overflow-y: auto; padding: 10px; }
.search-empty { padding: 38px 20px; color: var(--muted); font-size: 11px; text-align: center; }
.search-result { width: 100%; padding: 12px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; text-align: left; }
.search-result:hover { background: var(--surface-2); }
.result-icon { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 10px; color: var(--brand-2); background: var(--brand-soft); font: 700 16px/1 var(--arabic); }
.result-copy { min-width: 0; flex: 1; }
.result-copy b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.result-copy span { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.result-type { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.dialog-overlay { align-items: center; padding-top: 20px; }
.dialog { width: min(640px, 100%); max-height: 85vh; overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--bg); box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.985); transition: transform .18s; }
.dialog-head { margin-bottom: 17px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-close { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.dialog-close svg { width: 16px; }
.toast-stack { position: fixed; z-index: 150; right: 20px; bottom: 22px; display: grid; gap: 8px; }
.toast { min-width: 245px; max-width: 340px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); animation: toastIn .25s ease; font-size: 11px; }
.toast i { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--success); font-style: normal; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
.bottom-nav { display: none; }
.empty-state { padding: 55px 25px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: var(--surface); text-align: center; }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 13px; }

@media (max-width: 1100px) {
  :root { --sidebar: 212px; }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .forms-grid { grid-template-columns: repeat(3, 1fr); }
  .continue-grid { grid-template-columns: 1fr 1fr; }
  .continue-card:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  :root { --sidebar: 244px; }
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .mobile-menu { display: grid; }
  .topbar { min-height: 64px; padding: 11px 16px; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd { display: none; }
  .mini-stat span { display: none; }
  .page { padding: 25px 18px 100px; }
  .welcome-grid, .study-setup, .practice-grid { grid-template-columns: 1fr; }
  .today-card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .today-head { grid-column: 1 / -1; }
  .goal-ring { width: 125px; height: 125px; }
  .library-layout { grid-template-columns: 1fr; }
  .library-filters { display: flex; overflow-x: auto; }
  .library-filters h3 { display: none; }
  .course-layout { grid-template-columns: 1fr; }
  .course-overview { position: static; }
  .course-unit-links { grid-template-columns: 1fr 1fr; }
  .reader-book-hero { grid-template-columns: 120px minmax(0, 1fr); }
  .reader-cover { width: 110px; height: 155px; }
  .reader-book-progress { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; align-items: center; }
  .reading-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .search-trigger span { font-size: 11px; }
  .top-actions { gap: 5px; }
  .mini-stat { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head h1 { font-size: 29px; }
  .hero-card { min-height: 330px; padding: 27px 23px; }
  .hero-card h1 { font-size: 35px; }
  .hero-card::after { right: -10px; font-size: 82px; }
  .hero-actions .btn { flex: 1; }
  .today-card { display: flex; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { padding: 12px; gap: 9px; }
  .metric-icon { width: 36px; height: 36px; }
  .metric-copy strong { font-size: 17px; }
  .continue-grid, .module-grid { grid-template-columns: 1fr; }
  .continue-card:last-child { grid-column: auto; }
  .filter-bar { width: 100%; overflow-x: auto; }
  .filter-btn { white-space: nowrap; }
  .module-card { min-height: 220px; }
  .deck-options { grid-template-columns: 1fr; }
  .deck-option { display: flex; align-items: center; justify-content: space-between; }
  .study-config, .wazan-controls, .wazan-controls.with-bab { grid-template-columns: 1fr; }
  .flashcard-scene { min-height: 380px; height: 53vh; }
  .flash-arabic { font-size: 31px; }
  .card-face { padding: 25px 20px; }
  .rating-row { gap: 5px; }
  .rating-btn { padding: 9px 3px; }
  .practice-main, .practice-aside, .deck-panel, .study-summary { padding: 18px; }
  .practice-tabs { width: 100%; overflow-x: auto; }
  .tab-btn { flex: 1 0 auto; }
  .forms-grid { grid-template-columns: 1fr 1fr; }
  .source-card { grid-template-columns: 51px 1fr auto; gap: 12px; padding: 15px; }
  .book-cover { width: 51px; height: 68px; font-size: 12px; }
  .source-copy p { display: none; }
  .course-hero { min-height: 0; grid-template-columns: 1fr; padding: 27px 23px; }
  .course-hero-progress { grid-template-columns: auto 1fr; justify-items: start; gap: 13px; }
  .course-ring { width: 92px; height: 92px; }
  .course-ring::before { inset: 8px; }
  .course-ring strong { font-size: 20px; }
  .course-hero-progress p { margin: 0; }
  .course-overview { padding: 14px; }
  .course-review-card { display: none; }
  .course-unit-links { grid-template-columns: 1fr 1fr; }
  .course-unit { padding: 17px 13px; }
  .unit-head { grid-template-columns: 38px minmax(0, 1fr); }
  .unit-number { width: 38px; height: 38px; }
  .unit-percent { grid-column: 2; grid-row: 2; grid-template-columns: auto 1fr; align-items: center; text-align: left; }
  .unit-percent .mini-progress { width: 100%; }
  .course-lesson { grid-template-columns: 38px minmax(0, 1fr) 18px; gap: 9px; }
  .lesson-node { width: 36px; height: 36px; }
  .lesson-meta { display: none; }
  .lesson-main small { font-size: 10px; }
  .reader-page-head .btn { width: 100%; }
  .reader-book-hero { padding: 20px; grid-template-columns: 83px minmax(0, 1fr); gap: 17px; }
  .reader-cover { width: 78px; height: 112px; padding: 15px 8px 9px; border-radius: 6px 11px 11px 6px; }
  .reader-cover::before { width: 28px; margin-bottom: 9px; }
  .reader-cover span { font-size: 14px; }
  .reader-cover b { font-size: 17px; }
  .reader-cover small { margin-top: 7px; font-size: 7px; }
  .reader-book-copy h2 { margin-top: 10px; font-size: 18px; }
  .reader-book-copy > .arabic { font-size: 15px; }
  .reader-book-copy p { font-size: 14px; }
  .reader-method { display: none; }
  .reader-book-progress { padding: 13px; }
  .reader-progress-number strong { font-size: 27px; }
  .reading-card { min-height: 126px; padding: 14px 12px; grid-template-columns: 35px minmax(0, 1fr); }
  .reading-order { width: 34px; height: 34px; }
  .reading-open { display: none; }
  .reading-lesson-head { grid-template-columns: 39px minmax(0, 1fr); }
  .reading-lesson-head > .chip { display: none; }
  .reading-lesson-head h1 { font-size: 20px; }
  .reader-stepper { padding: 11px 7px; }
  .reader-stepper::before { top: 27px; }
  .reader-stepper > div > span { width: 31px; height: 31px; }
  .reader-stepper > div > b { max-width: 61px; font-size: 9px; text-align: center; }
  .reader-workspace, .reader-workspace.compact { min-height: 500px; padding: 19px 16px; }
  .reader-instruction { margin-bottom: 17px; }
  .kitab-text { min-height: 185px; padding: 20px 13px; }
  .kitab-token { font-size: 27px; }
  .vocab-drawer { align-items: flex-start; flex-wrap: wrap; }
  .vocab-ar { min-width: 80px; text-align: start; }
  .vocab-copy { flex-basis: calc(100% - 100px); }
  .vocab-drawer > em { margin-left: 0; }
  .reader-choice-grid, .ending-options { gap: 6px; }
  .reader-choice { min-height: 82px; padding: 9px; }
  .reader-actions .btn { min-width: 0; padding: 10px 12px; font-size: 12px; }
  .revealed-text { padding: 22px 14px; }
  .revealed-text > .arabic { padding: 15px 24px 5px; font-size: 25px; }
  .reading-analysis ol { margin-left: 13px; }
  .reader-mode-tabs { width: 100%; margin-top: 0; }
  .reader-mode-tabs button { min-height: 46px; padding: 8px; font-size: 13px; }
  .reading-chapter-group h3 { font-size: 17px; }
  .reading-chapter-group p { font-size: 12px; }
  .matn-integrity-card { align-items: stretch; flex-direction: column; padding: 16px; }
  .matn-integrity-card dl { width: 100%; }
  .matn-integrity-card dl div { min-width: 0; flex: 1; }
  .matn-toc { grid-template-columns: 1fr 1fr; }
  .matn-toc button:first-child { grid-column: 1 / -1; }
  .matn-document-meta { padding: 20px 14px; }
  .matn-document-meta .arabic { font-size: 27px; }
  .matn-document { padding: 27px 18px; }
  .matn-chapter + .matn-chapter { margin-top: 34px; padding-top: 31px; }
  .matn-chapter h2 { margin-bottom: 20px; padding: 8px 15px; font-size: 21px; }
  .matn-chapter p { margin-bottom: 19px; font-size: 23px; line-height: 2.05; }
  .matn-source-note { align-items: stretch; flex-direction: column; }
  .matn-source-note span { flex-wrap: wrap; }
  .matn-source-note a { font-size: 13px; }
  .reader-comprehension-choice { min-height: 66px; padding: 11px; }
  .reader-comprehension-choice b { font-size: 13px; }
  .bottom-nav { position: fixed; z-index: 50; left: 10px; right: 10px; bottom: max(9px, env(safe-area-inset-bottom)); height: 62px; padding: 7px 6px; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 12px 40px rgba(16,38,31,.24); backdrop-filter: blur(16px); }
  .bottom-item { position: relative; border: 0; display: grid; place-items: center; gap: 2px; color: var(--muted); background: transparent; font-size: 8px; cursor: pointer; }
  .bottom-item svg { width: 20px; height: 20px; }
  .bottom-item.active { color: var(--brand-2); }
  .review-fab span { position: absolute; bottom: 5px; width: 50px; height: 50px; display: grid; place-items: center; border: 5px solid var(--surface); border-radius: 17px; color: #fff; background: var(--brand-2); transform: translateY(-13px); box-shadow: 0 8px 18px rgba(23,61,53,.25); }
  .review-fab em { position: absolute; top: -10px; right: 8px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; border-radius: 99px; color: #2e230f; background: var(--accent); font-size: 8px; font-style: normal; font-weight: 850; }
  .dialog { padding: 18px; }
  .toast-stack { left: 14px; right: 14px; bottom: 85px; }
  .toast { max-width: none; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
.scan-document { max-width: 900px; margin: 24px auto; }
.scan-page { margin: 0 0 28px; scroll-margin-top: 110px; }
.scan-page figcaption { padding: 12px 16px; font-weight: 700; }
.scan-page img { display: block; width: 100%; height: auto; background: white; border-radius: 8px; }
.scan-page a { display: block; }

/* Full Khulasah: paragraph reading with source-page comparison. */
.kh-word-analysis h3 { font-size: 14px; color: var(--brand-2); margin: 20px 0 8px; }
.kh-word-analysis p { font-size: 16px; line-height: 1.9; }
.kh-word-analysis p.arabic { font-size: 25px; }
.kh-word-analysis mark { background: var(--accent-soft); color: var(--ink); border-radius: 5px; padding: 3px; }
.kh-word-text { margin-bottom: 20px; }
.kh-word-text .kitab-token { font: inherit; line-height: inherit; }
.kitab-passages { display: grid; gap: 20px; margin: 24px 0; }
.kitab-passage { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface); }
.kitab-passage.active { border-color: var(--accent); }
.passage-button { display: block; width: 100%; padding: clamp(18px, 3vw, 32px); text-align: right; color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); border: 0; cursor: pointer; }
.passage-button:hover { background: var(--accent-soft); }
.passage-button .arabic { display: block; font-size: clamp(24px, 2.6vw, 32px); line-height: 2.1; font-weight: 500; }
.passage-label { display: block; direction: ltr; text-align: left; color: var(--muted); font: 600 12px/1.5 var(--font); margin-bottom: 16px; }
.passage-detail { padding: 22px clamp(18px, 3vw, 32px); background: var(--brand-soft); }
.passage-detail h3 { font-size: 13px; margin: 0 0 8px; color: var(--brand-2); }
.passage-detail p { font-size: 15px; line-height: 1.9; margin: 0 0 22px; }
.passage-detail p:last-child { margin: 0; }
.reading-original-pages { margin: 20px 0; }
.reading-original-pages img { width: 100%; height: auto; display: block; }
.reading-source-heading { margin-top: 32px; }
.ending-context { font-size: 25px; line-height: 1.8; margin: 18px 0; color: var(--muted); }
@media (max-width: 560px) { .paragraph-workspace { padding: 18px; } .passage-detail p { font-size: 14px; } }

/* Vocabulary cards grow with the text; long verse excerpts never clip on mobile. */
.vocabulary-guide { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--brand-soft); }
.vocabulary-guide > strong { color: var(--brand-2); font-size: 17px; }
.vocabulary-guide p { margin: 8px 0 14px; font-size: 14px; line-height: 1.7; }
.vocabulary-guide small { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.vocabulary-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.vocabulary-modes [aria-pressed="true"] { border-color: var(--brand-2); color: var(--brand-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--brand-2); }
.study-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.vocabulary-scene { height: auto; min-height: 0; }
.vocabulary-card { height: auto; display: grid; }
.vocabulary-card .card-face { position: relative; inset: auto; grid-area: 1 / 1; min-width: 0; min-height: 410px; padding: clamp(22px, 4vw, 36px); gap: 16px; }
.vocabulary-card .card-label, .vocabulary-card .flip-hint, .vocabulary-card .source-tag { position: static; }
.vocabulary-card .card-label { align-self: flex-start; margin-bottom: 8px; font-size: 12px; }
.vocabulary-card .flash-arabic { font-size: clamp(30px, 5vw, 44px); line-height: 1.9; overflow-wrap: anywhere; }
.vocabulary-card .flash-prompt { font-size: 15px; text-align: center; }
.vocabulary-card .flip-hint { margin-top: 16px; font-size: 12px; flex-wrap: wrap; justify-content: center; }
.vocabulary-card .back h2 { margin: 0; font-size: clamp(21px, 3vw, 28px); line-height: 1.55; overflow-wrap: anywhere; }
.vocabulary-card .back-explain { margin: 0; font-size: 15px; }
.vocabulary-card .example-box .arabic { font-size: clamp(24px, 3.5vw, 30px); line-height: 1.9; overflow-wrap: anywhere; }
.vocabulary-card .example-box small { font-size: 14px; line-height: 1.7; }
.vocabulary-card .example-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 600; }
.vocabulary-card .source-tag { font-size: 12px; text-align: center; line-height: 1.6; }
.vocabulary-keywords { width: 100%; max-width: 580px; border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface-2); }
.vocabulary-keywords > strong { color: var(--muted); font-size: 12px; }
.vocabulary-keywords dl { margin: 8px 0 0; }
.vocabulary-keywords dl > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.vocabulary-keywords dl > div:last-child { border: 0; padding-bottom: 0; }
.vocabulary-keywords dt { color: var(--brand-2); font-size: 27px; line-height: 1.8; text-align: right; overflow-wrap: anywhere; }
.vocabulary-keywords dd { margin: 0; font-size: 14px; line-height: 1.6; }
.vocabulary-reference { margin: 18px auto 0; text-align: center; }
.vocabulary-reference a { display: inline-block; padding: 8px 4px; color: var(--brand-2); font-size: 14px; text-decoration: underline; text-underline-offset: 4px; }
.vocabulary-reference small { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; }
.vocabulary-preview .example-box small { font-size: 14px; line-height: 1.7; }
.vocabulary-card .arabic, .vocabulary-preview .arabic {
  font-family: "Mizan Amiri Quran", var(--arabic);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: normal;
}
.vocabulary-card .quran-quote, .vocabulary-preview .quran-quote {
  line-height: 2.4;
  padding-block: .2em;
  overflow-wrap: normal;
  word-break: normal;
}
@media (max-width: 560px) {
  .vocabulary-card .card-face { min-height: 360px; padding: 24px 18px; }
  .vocabulary-keywords dl > div { grid-template-columns: 1fr; gap: 0; }
  .vocabulary-keywords dt { text-align: center; }
  .vocabulary-keywords dd { text-align: center; }
}
