/* ترجمان — design system */
@font-face { font-family: "PlexAr"; src: url(../fonts/plex-ar-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "PlexAr"; src: url(../fonts/plex-ar-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "PlexAr"; src: url(../fonts/plex-ar-600.woff2) format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "PlexAr"; src: url(../fonts/plex-ar-700.woff2) format("woff2"); font-weight: 700 800; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "InterV"; src: url(../fonts/inter-latin.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Serif4"; src: url(../fonts/serif-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Serif4"; src: url(../fonts/serif-400i.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Serif4"; src: url(../fonts/serif-600.woff2) format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #f6f4ee; --surface: #ffffff; --surface-2: #f0ede4; --surface-3: #e8e3d6;
  --ink: #161b2e; --ink-2: #2f3650; --muted: #5f667b; --line: #e2ddcf; --line-2: #d3ccb9;
  --brand: #1d3a8a; --brand-2: #2f55c8; --brand-soft: #e7ecfb; --on-brand: #ffffff;
  --accent: #b9831f; --accent-soft: #f8eed7;
  --ok: #18794e; --ok-soft: #e3f4eb; --warn: #a15c07; --warn-soft: #fdf0dc; --bad: #b42318; --bad-soft: #fde8e6;
  --shadow-1: 0 1px 2px rgba(22, 27, 46, .06), 0 1px 3px rgba(22, 27, 46, .05);
  --shadow-2: 0 6px 24px -8px rgba(22, 27, 46, .18), 0 2px 6px rgba(22, 27, 46, .05);
  --radius: 16px; --radius-s: 11px;
  --font: "InterV", "PlexAr", system-ui, "Segoe UI", Tahoma, sans-serif;
  --font-en: "Serif4", Georgia, "Times New Roman", serif;
  --top-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d111d; --surface: #141a2b; --surface-2: #1a2136; --surface-3: #232b44;
  --ink: #e9ecf5; --ink-2: #cbd1e3; --muted: #97a0b8; --line: #262f4a; --line-2: #333d5e;
  --brand: #93abff; --brand-2: #b5c5ff; --brand-soft: #1d2848; --on-brand: #0d111d;
  --accent: #e5b65c; --accent-soft: #2e2615;
  --ok: #4cc38a; --ok-soft: #12291f; --warn: #f0a94b; --warn-soft: #2d2213; --bad: #ff8a80; --bad-soft: #2f1716;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111d; --surface: #141a2b; --surface-2: #1a2136; --surface-3: #232b44;
    --ink: #e9ecf5; --ink-2: #cbd1e3; --muted: #97a0b8; --line: #262f4a; --line-2: #333d5e;
    --brand: #93abff; --brand-2: #b5c5ff; --brand-soft: #1d2848; --on-brand: #0d111d;
    --accent: #e5b65c; --accent-soft: #2e2615;
    --ok: #4cc38a; --ok-soft: #12291f; --warn: #f0a94b; --warn-soft: #2d2213; --bad: #ff8a80; --bad-soft: #2f1716;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 64px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16.5px/1.75 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; outline: none; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 18px 40px; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.005em; }
h1 { font-size: clamp(1.55rem, 1.2rem + 1.6vw, 2.2rem); }
h2 { font-size: 1.35rem; } h3 { font-size: 1.12rem; } h4 { font-size: 1rem; }
p { margin: 0 0 .9em; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 1.15em; height: 1.15em; flex: none; }
.lat, [lang="en"] { font-family: var(--font); }
bdi.lat { unicode-bidi: isolate; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--brand); color: var(--on-brand); padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { inset-inline-start: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-2) 55%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; gap: 18px; padding: 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-1); }
.brand-t { display: flex; flex-direction: column; line-height: 1.15; }
.brand-t b { font-size: 1.12rem; letter-spacing: -.01em; }
.brand-t small { font-size: .74rem; color: var(--muted); }
.topnav { display: flex; gap: 4px; margin-inline-start: 8px; }
.topnav a { padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: .95rem; text-decoration: none; }
.topnav a:hover { background: var(--surface-2); }
.topnav a.on { background: var(--brand-soft); color: var(--brand); }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn svg { width: 20px; height: 20px; }
.ask-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 600; color: #fff; background: linear-gradient(135deg, #2f55c8, #6d3fd0); box-shadow: 0 6px 18px -8px #4b47c9; }
.ask-btn:hover { filter: brightness(1.07); }
.ask-btn svg { width: 18px; height: 18px; }

.bottomnav { display: none; }
@media (max-width: 760px) {
  :root { --top-h: 56px; }
  body { font-size: 16px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topnav, .ask-btn span { display: none; }
  .ask-btn { display: none; }
  .brand-t small { display: none; }
  main { padding: 16px 14px 32px; }
  .bottomnav { display: flex; position: fixed; z-index: 45; inset-inline: 0; bottom: 0; height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  .bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
  .bottomnav svg { width: 22px; height: 22px; }
  .bottomnav a.on { color: var(--brand); font-weight: 600; }
  .bottomnav #bn-ask svg { color: #fff; background: linear-gradient(135deg, #2f55c8, #6d3fd0); width: 40px; height: 40px; padding: 9px; border-radius: 14px; margin-top: -14px; box-shadow: 0 6px 16px -6px #4b47c9; }
}

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; text-align: center; padding: 22px 18px 28px; }
.foot p { max-width: 760px; margin: 0 auto .4em; }

/* ---------- generic ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.pad { padding: 18px 20px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .95rem; color: var(--ink); text-decoration: none !important; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 10px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.now { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.next { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.chip.oral { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.bdot { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; color: var(--muted); background: var(--surface-2); border-radius: 7px; padding: 1px 7px; }
.bdot svg { width: 12px; height: 12px; }
.input, textarea.input, select.input { width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 22%, transparent); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.7; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.sec-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 30px 0 14px; }
.sec-head h2 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 16px; }
.boot { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--brand-2)); width: 0; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
#toast { position: fixed; z-index: 90; bottom: 24px; inset-inline-start: 50%; transform: translate(50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow-2); transition: opacity .2s, transform .2s; max-width: 90vw; }
[dir="rtl"] #toast { transform: translate(50%, 20px); }
#toast.show { opacity: 1; transform: translate(50%, 0); }
@media (max-width: 760px) { #toast { bottom: 84px; } }

/* ---------- home ---------- */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 28px 28px 24px; color: #fff; background: radial-gradient(1200px 400px at 110% -40%, #6d3fd0 0%, transparent 55%), radial-gradient(900px 380px at -10% 120%, #c0841a 0%, transparent 50%), linear-gradient(135deg, #142a6b, #1d3a8a 55%, #27449c); box-shadow: var(--shadow-2); }
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px); background-size: 18px 18px; mask-image: linear-gradient(to left, #000, transparent 70%); pointer-events: none; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.25rem); }
.hero p { margin: 0; opacity: .88; max-width: 640px; }
.hero .hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; position: relative; z-index: 1; }
.hero .pill { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; padding: 10px 14px; min-width: 150px; }
.hero .pill b { display: block; font-size: 1.35rem; line-height: 1.2; }
.hero .pill small { opacity: .8; font-size: .8rem; }
.announce { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.announce svg { color: var(--accent); width: 22px; height: 22px; margin-top: 3px; }
.announce p { margin: 0; white-space: pre-line; }
.term-tabs { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.term-tabs button { border: 0; background: transparent; padding: 7px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); }
.term-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.subj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.subj { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 14px; color: var(--ink); text-decoration: none !important; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden; }
.subj::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 4px; background: var(--c); }
.subj:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.subj-top { display: flex; align-items: center; gap: 12px; }
.subj-ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: var(--c); }
.subj-ic svg { width: 23px; height: 23px; }
.subj h3 { margin: 0; font-size: 1.05rem; }
.subj .en { color: var(--muted); font-size: .82rem; direction: ltr; text-align: end; }
.subj-foot { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: auto; }
.subj-foot .progress { flex: 1; height: 6px; }
.week-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .week-grid { grid-template-columns: 1fr; } }
.wk-list { list-style: none; margin: 0; padding: 0; }
.wk-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.wk-list li:last-child { border-bottom: 0; }
.wk-list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.wk-list a { color: var(--ink); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.fact { display: flex; gap: 12px; padding: 14px 16px; }
.fact .ic { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand); flex: none; }
.fact h4 { margin: 0 0 3px; font-size: .97rem; }
.fact p { margin: 0; font-size: .87rem; color: var(--muted); line-height: 1.65; }
.tools-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tool { display: flex; gap: 12px; align-items: center; padding: 14px 16px; color: var(--ink); text-decoration: none !important; cursor: pointer; text-align: start; }
.tool:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.tool .ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.tool b { display: block; font-size: .97rem; }
.tool small { color: var(--muted); font-size: .8rem; line-height: 1.4; display: block; }

/* ---------- subject page ---------- */
.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .86rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs svg { width: 14px; height: 14px; }
.subj-hero { display: flex; gap: 16px; align-items: flex-start; padding: 22px; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, var(--surface)), var(--surface) 70%); border: 1px solid color-mix(in srgb, var(--c) 25%, var(--line)); }
.subj-hero .subj-ic { width: 56px; height: 56px; border-radius: 16px; }
.subj-hero .subj-ic svg { width: 28px; height: 28px; }
.subj-hero h1 { margin: 0; }
.subj-hero .en { color: var(--muted); direction: ltr; text-align: end; font-size: .95rem; }
.subj-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; margin-top: 18px; }
@media (max-width: 920px) { .subj-cols { grid-template-columns: 1fr; } }
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lrow { display: flex; gap: 14px; align-items: center; padding: 13px 15px; color: var(--ink); text-decoration: none !important; }
.lrow:hover { border-color: color-mix(in srgb, var(--c) 40%, var(--line)); box-shadow: var(--shadow-2); }
.lrow.dim { opacity: .62; }
.lrow .num { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); flex: none; }
.lrow .num.done { background: var(--ok); color: #fff; }
.lrow h3 { margin: 0; font-size: 1rem; }
.lrow .en { color: var(--muted); font-size: .8rem; direction: ltr; text-align: end; }
.lrow .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.side-box h3 { display: flex; align-items: center; gap: 8px; }
.side-box ul { padding-inline-start: 1.1em; margin: 0; }
.side-box li { margin-bottom: 6px; }
.prov { font-size: .84rem; color: var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; display: flex; gap: 8px; }
.prov svg { margin-top: 4px; }

/* ---------- lesson page ---------- */
.lesson-head { margin-bottom: 8px; }
.lesson-head h1 { margin-bottom: 2px; }
.lesson-head .en-title { direction: ltr; text-align: end; color: var(--muted); font-size: 1.05rem; font-family: var(--font-en); font-style: italic; }
.lesson-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.secnav { position: sticky; top: var(--top-h); z-index: 30; margin: 10px -18px 16px; padding: 8px 18px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.secnav::-webkit-scrollbar { display: none; }
.secnav a { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .86rem; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.secnav a svg { width: 15px; height: 15px; }
.secnav a.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
@media (max-width: 760px) { .secnav { margin: 8px -14px 14px; padding: 8px 14px; } }
.lesson-wrap { max-width: 820px; margin: 0 auto; }
.lsec { margin-bottom: 18px; padding: 20px 22px; scroll-margin-top: calc(var(--top-h) + 60px); }
@media (max-width: 760px) { .lsec { padding: 16px 15px; border-radius: 14px; } }
.lsec > h2 { display: flex; align-items: center; gap: 10px; font-size: 1.18rem; margin-bottom: 14px; }
.lsec > h2 .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.lsec > h2 .ic svg { width: 18px; height: 18px; }
.lsec > h2 .tools { margin-inline-start: auto; display: flex; gap: 4px; }
.lsec.gist { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 75%); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.lsec.gist > h2 .ic { background: var(--accent); color: #fff; }
.prose { font-size: 1.04rem; }
.prose h3 { margin-top: 1.3em; font-size: 1.08rem; }
.prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose li::marker { color: var(--brand-2); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.prose blockquote { margin: 0 0 1em; padding: 10px 16px; border-inline-start: 4px solid var(--line-2); background: var(--surface-2); border-radius: 10px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.prose mark { background: var(--accent-soft); color: inherit; padding: 0 3px; border-radius: 4px; }
.prose[dir="ltr"] { font-family: var(--font-en); font-size: 1.12rem; line-height: 1.7; text-align: left; }
.prose[dir="rtl"] [dir="ltr"][lang="en"] { font-family: var(--font-en); font-size: 1.08rem; text-align: left; }
bdi.lat { font-family: var(--font); }
.prose[dir="ltr"] h3, .prose[dir="ltr"] h4 { font-family: var(--font); }
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table-wrap th, .table-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.table-wrap th { background: var(--surface-2); font-weight: 700; font-size: .88rem; }
.table-wrap tr:last-child td { border-bottom: 0; }
.callout { margin: 0 0 1em; padding: 12px 16px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.callout-t { font-weight: 700; font-size: .85rem; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.callout.exam { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.callout.exam .callout-t { color: var(--bad); }
.callout.exam .callout-t::before { content: "★"; }
.callout.tip { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.callout.tip .callout-t { color: var(--ok); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout.warn .callout-t { color: var(--warn); }
.callout.remember { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand-2) 25%, transparent); }
.callout.remember .callout-t { color: var(--brand); }
.callout.example .callout-t { color: var(--accent); }
.prose[dir="ltr"] .callout { font-family: var(--font); font-size: 1rem; }

/* terms */
.terms { display: grid; gap: 8px; }
.term { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 4px 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.term .t-en { direction: ltr; text-align: left; font-weight: 700; color: var(--brand); font-family: var(--font-en); font-size: 1.08rem; grid-row: span 2; align-self: center; }
.term .t-ar { font-weight: 700; }
.term .t-def { font-size: .92rem; color: var(--muted); }
@media (max-width: 560px) { .term { grid-template-columns: 1fr; } .term .t-en { grid-row: auto; } }

/* mind map */
.mm-box { position: relative; height: 440px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; direction: ltr; }
.mm-box .markmap-foreign div { unicode-bidi: plaintext; }
@media (max-width: 760px) { .mm-box { height: 380px; } }
.mm-box svg.markmap { width: 100%; height: 100%; display: block; }
.mm-box .mm-tools { position: absolute; top: 8px; inset-inline-end: 8px; display: flex; gap: 4px; z-index: 2; }
.mm-box .mm-tools .icon-btn { background: var(--surface); border-color: var(--line); width: 36px; height: 36px; }
.mm-box:fullscreen { height: 100vh; border-radius: 0; }
.mm-box .markmap-foreign { font-family: var(--font) !important; }
:root[data-theme="dark"] .mm-box .markmap { --markmap-text-color: #e9ecf5; }
.mm-hint { font-size: .82rem; color: var(--muted); margin-top: 8px; }

/* syntax tree */
.tj-tree { margin: 0 0 1.2em; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; direction: ltr; }
.tj-tree figcaption { font-size: .86rem; color: var(--muted); margin-bottom: 8px; direction: rtl; }
.tj-tree > svg { display: block; margin: 0 auto; width: 100%; height: auto; max-height: 420px; overflow: visible; }
.tj-tree .tn text { font-family: var(--font); font-size: 15px; fill: var(--ink); }
.tj-tree .tn.cat text { font-weight: 700; fill: var(--brand); }
.tj-tree .tn.leaf text { font-family: var(--font-en); font-style: italic; font-size: 16px; }
.tj-tree .tn, .tj-tree .te { transition: opacity .45s ease, transform .45s ease; }
.tj-tree .te { stroke: var(--line-2); stroke-width: 1.6; fill: none; }
.tj-tree .hide { opacity: 0; }
.tj-tree .tree-ctl { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 10px; direction: rtl; flex-wrap: wrap; }
.tj-tree .tree-cap { font-size: .9rem; color: var(--ink-2); min-height: 1.6em; direction: rtl; margin-top: 6px; }

/* steps (animation) */
.tj-steps { margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.tj-steps .st-stage { position: relative; min-height: 190px; padding: 18px 20px 6px; }
.tj-steps .step { display: none; animation: stepIn .45s cubic-bezier(.2, .8, .2, 1); }
.tj-steps .step.on { display: block; }
.tj-steps .step h4 { color: var(--brand); font-size: 1.05rem; }
@keyframes stepIn { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .tj-steps .step { animation-name: stepInR; }
@keyframes stepInR { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.tj-steps .st-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.tj-steps .st-dots { display: flex; gap: 6px; flex: 1; justify-content: center; }
.tj-steps .st-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); cursor: pointer; transition: background .2s, width .2s; }
.tj-steps .st-dots i.on { background: var(--brand-2); width: 22px; border-radius: 6px; }
.tj-steps .st-cap { font-size: .8rem; color: var(--muted); padding: 10px 20px 0; }
.tj-steps .st-prog { height: 3px; background: var(--surface-3); }
.tj-steps .st-prog i { display: block; height: 100%; background: var(--brand-2); width: 0; }
.tj-steps.playing .st-prog i { transition: width linear; }

/* quiz */
.quiz { display: flex; flex-direction: column; gap: 14px; }
.qz-top { display: flex; align-items: center; gap: 12px; }
.qz-top .progress { flex: 1; }
.qz-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.qz-q { font-weight: 600; font-size: 1.06rem; margin-bottom: 12px; direction: ltr; text-align: left; font-family: var(--font-en); font-size: 1.14rem; }
.qz-q.ar { direction: rtl; text-align: right; font-family: var(--font); font-size: 1.06rem; }
.qz-opts { display: grid; gap: 8px; }
.qz-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; text-align: left; direction: ltr; font-size: 1rem; transition: border-color .15s, background .15s; }
.qz-opt:hover:not([disabled]) { border-color: var(--brand-2); background: var(--brand-soft); }
.qz-opt .k { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: .82rem; flex: none; }
.qz-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.qz-opt.right .k { background: var(--ok); color: #fff; }
.qz-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.qz-opt.wrong .k { background: var(--bad); color: #fff; }
.qz-opt[disabled] { cursor: default; }
.qz-why { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: .95rem; animation: fadeUp .3s ease; }
.qz-why.ok { background: var(--ok-soft); } .qz-why.bad { background: var(--bad-soft); }
.qz-why b { display: block; margin-bottom: 2px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.qz-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: 14px; }
.qz-result { text-align: center; padding: 22px; }
.qz-result .score { font-size: 2.6rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.essay { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin-bottom: 12px; }
.essay .qz-q { margin-bottom: 10px; }
.essay textarea { direction: ltr; text-align: left; font-family: var(--font-en); font-size: 1.05rem; }
.essay .model { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); direction: ltr; text-align: left; font-family: var(--font-en); font-size: 1.07rem; animation: fadeUp .3s ease; }
.essay .model h5 { font-family: var(--font); margin: 0 0 6px; font-size: .85rem; color: var(--brand); direction: rtl; text-align: right; }
.essay .points { margin: 10px 0 0; padding-inline-start: 1.2em; direction: ltr; text-align: left; font-family: var(--font); font-size: .9rem; }
.essay .ai-fb { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line-2); animation: fadeUp .3s ease; }

/* flashcards */
.fc-stage { perspective: 1200px; max-width: 520px; margin: 0 auto; }
.fc { position: relative; height: 250px; cursor: pointer; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.2, .8, .2, 1); }
.fc.flip { transform: rotateY(180deg); }
.fc .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 22px; border: 1px solid var(--line); box-shadow: var(--shadow-2); }
.fc .front { background: linear-gradient(160deg, var(--surface), var(--surface-2)); }
.fc .front b { direction: ltr; font-family: var(--font-en); font-size: 1.7rem; color: var(--brand); line-height: 1.3; }
.fc .back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--brand-soft), var(--surface)); }
.fc .back b { font-size: 1.35rem; margin-bottom: 8px; }
.fc .back p { margin: 0; color: var(--muted); font-size: .95rem; }
.fc .tap { position: absolute; bottom: 12px; font-size: .75rem; color: var(--muted); }
.fc-ctl { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.fc-ctl .btn.bad { border-color: var(--bad); color: var(--bad); }
.fc-ctl .btn.good { border-color: var(--ok); color: var(--ok); }
.fc-meta { text-align: center; margin-top: 10px; font-size: .86rem; color: var(--muted); }
.boxes { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0 18px; }
.boxes .bx { text-align: center; min-width: 74px; padding: 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.boxes .bx b { display: block; font-size: 1.25rem; }
.boxes .bx small { color: var(--muted); font-size: .74rem; }

/* video */
.video-box { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.video-box iframe, .video-box video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-soon { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-2); }
.video-soon svg { width: 34px; height: 34px; color: var(--muted); }

/* notes */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.note.doctor { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.note.pinned { box-shadow: inset 4px 0 0 var(--accent); }
.note .n-head { display: flex; gap: 8px; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.note .n-text { white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.note-form { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.kinds { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.kinds label { cursor: pointer; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: .85rem; font-weight: 600; background: var(--surface); }
.kinds input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.hp { position: absolute !important; inset-inline-start: -5000px; width: 1px; height: 1px; overflow: hidden; }

/* lesson footer nav */
.lesson-pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.lesson-pn a { padding: 14px 16px; color: var(--ink); text-decoration: none !important; }
.lesson-pn a small { display: block; color: var(--muted); font-size: .8rem; }
.lesson-pn a.next { text-align: end; }
.done-bar { display: flex; align-items: center; gap: 12px; padding: 16px 18px; margin-top: 18px; border-radius: 16px; background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.done-bar .grow b { display: block; }

/* ---------- search ---------- */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(8, 11, 20, .48); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 14px 14px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.search-box { width: 100%; max-width: 640px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-2); overflow: hidden; border: 1px solid var(--line); }
.search-box .s-in { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.search-box .s-in input { flex: 1; border: 0; outline: none; background: transparent; height: 50px; font-size: 1.05rem; }
.search-box .s-res { max-height: 60vh; overflow: auto; padding: 6px; }
.s-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; color: var(--ink); text-decoration: none !important; }
.s-item:hover, .s-item.on { background: var(--surface-2); }
.s-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.s-item small { display: block; color: var(--muted); font-size: .8rem; }

/* ---------- chat drawer ---------- */
.drawer { position: fixed; z-index: 80; inset-block: 0; inset-inline-end: 0; width: min(460px, 100vw); background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: var(--shadow-2); display: flex; flex-direction: column; transform: translateX(-105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
[dir="rtl"] .drawer { inset-inline-end: 0; transform: translateX(-105%); }
.drawer.open { transform: none !important; }
.drawer-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(8, 11, 20, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.dr-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dr-head .av { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2f55c8, #6d3fd0); }
.dr-head .av svg { width: 20px; height: 20px; }
.dr-head b { display: block; line-height: 1.2; }
.dr-head small { color: var(--muted); font-size: .78rem; }
.dr-ctx { margin: 10px 14px 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: .84rem; font-weight: 600; }
.dr-ctx button { margin-inline-start: auto; border: 0; background: none; cursor: pointer; color: inherit; display: grid; place-items: center; }
.dr-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; line-height: 1.7; font-size: .97rem; overflow-wrap: anywhere; unicode-bidi: plaintext; animation: fadeUp .25s ease; }
.msg.me { align-self: flex-start; background: var(--brand); color: var(--on-brand); border-end-start-radius: 6px; white-space: pre-wrap; }
.msg.ai { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--line); border-end-end-radius: 6px; }
.msg.ai p:last-child, .msg.ai ul:last-child, .msg.ai ol:last-child { margin-bottom: 0; }
.msg.ai ul, .msg.ai ol { padding-inline-start: 1.3em; margin: .3em 0 .7em; }
.msg.ai h4 { margin: .4em 0 .3em; font-size: 1rem; }
.msg.ai code { background: var(--surface-3); padding: 0 5px; border-radius: 5px; }
.msg.err { align-self: center; background: var(--bad-soft); color: var(--bad); font-size: .88rem; }
.msg .src { display: block; margin-top: 6px; font-size: .72rem; color: var(--muted); }
.typing { align-self: flex-end; display: flex; gap: 4px; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.dr-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
.dr-quick button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: .82rem; cursor: pointer; }
.dr-quick button:hover { border-color: var(--brand-2); color: var(--brand); }
.dr-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.dr-form textarea { flex: 1; min-height: 46px; max-height: 160px; resize: none; padding: 11px 13px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); outline: none; unicode-bidi: plaintext; }
.dr-form textarea:focus { border-color: var(--brand-2); }
.dr-form .btn { min-height: 46px; width: 46px; padding: 0; border-radius: 14px; }
.dr-note { font-size: .72rem; color: var(--muted); text-align: center; padding: 0 14px 6px; }
.welcome-ai { text-align: center; color: var(--muted); padding: 18px 8px; }
.welcome-ai b { color: var(--ink); display: block; font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- admin ---------- */
.admin-grid { display: grid; gap: 16px; }
.admin-grid .card h2 { font-size: 1.1rem; display: flex; gap: 8px; align-items: center; }
.st-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.st-row:last-child { border-bottom: 0; }
.st-row .t { flex: 1; min-width: 180px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font-size: .8rem; cursor: pointer; border-inline-start: 1px solid var(--line); }
.seg button:first-child { border-inline-start: 0; }
.seg button.on { background: var(--brand); color: var(--on-brand); }
.prov-row { display: grid; grid-template-columns: 1.1fr 1.4fr 1.6fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 760px) { .prov-row { grid-template-columns: 1fr; padding-bottom: 10px; border-bottom: 1px dashed var(--line); } }

/* ---------- glossary / review ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { max-width: 320px; }
.gl-list { display: grid; gap: 8px; }

/* print */
@media print {
  .topbar, .bottomnav, .foot, .secnav, .lesson-tools, .drawer, .drawer-scrim, #toast, .note-form, .mm-tools, .qz-nav, .tree-ctl, .st-bar, [data-noprint] { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .tj-steps .step { display: block !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
