/* Calm, low-contrast-glare palette for long study sessions */
:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #efeae0;
  --text: #2b2f33;
  --muted: #6a7178;
  --border: #ddd6c8;
  --accent: #3f7d78;
  --accent-strong: #2f6560;
  --accent-soft: #dcebe8;
  --good: #3b7d4f;
  --good-soft: #dfeee3;
  --bad: #b5503c;
  --bad-soft: #f5e0da;
  --warn-soft: #f6ecd0;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 4px 14px rgba(60, 50, 30, .05);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Naskh Arabic", Tahoma, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #1b1f22;
  --surface: #23282c;
  --surface-2: #2b3136;
  --text: #dfe3e6;
  --muted: #98a1a8;
  --border: #363d43;
  --accent: #6fb5ad;
  --accent-strong: #8ccbc3;
  --accent-soft: #263d3b;
  --good: #7cc394;
  --good-soft: #223529;
  --bad: #e4917d;
  --bad-soft: #3d2924;
  --warn-soft: #3a3423;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1f22; --surface: #23282c; --surface-2: #2b3136; --text: #dfe3e6; --muted: #98a1a8;
    --border: #363d43; --accent: #6fb5ad; --accent-strong: #8ccbc3; --accent-soft: #263d3b;
    --good: #7cc394; --good-soft: #223529; --bad: #e4917d; --bad-soft: #3d2924; --warn-soft: #3a3423;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
}
a { color: var(--accent-strong); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 650; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 17px; }
.search { flex: 1; max-width: 460px; margin-inline-start: auto; }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.icon-btn { border: 1px solid var(--border); background: var(--bg); border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 18px; flex: none; }
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Layout ---------- */
main { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .4em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 .3em; }
.lead { color: var(--muted); margin: 0 0 22px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
a.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0 0 2px; font-size: 1.15rem; }
.card .meta { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.subject-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.lesson-row:hover { border-color: var(--accent); }
.lesson-row .grow { flex: 1; min-width: 0; }
.lesson-row .title { font-weight: 600; }
.lesson-row .sub { font-size: 14px; color: var(--muted); }
.badge { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.done { background: var(--good-soft); color: var(--good); }
.badge.score { background: var(--accent-soft); color: var(--accent-strong); }
.badge.new { background: var(--accent); color: #fff; font-weight: 650; }

.update-banner {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 16px; background: var(--accent); color: #fff; font-size: 14px;
}
.update-banner[hidden] { display: none; }
.update-banner .btn.primary { background: #fff; color: var(--accent-strong); border-color: #fff; }
.update-banner .btn.primary:hover { background: var(--accent-soft); }
.update-banner .icon-btn.small { width: 28px; height: 28px; font-size: 16px; border-color: rgba(255,255,255,.5); background: transparent; color: #fff; }
.update-banner .icon-btn.small:hover { background: rgba(255,255,255,.15); }

.empty {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--muted);
}
code, .path { background: var(--surface-2); padding: 1px 7px; border-radius: 6px; font-size: .92em; direction: ltr; unicode-bidi: isolate; }

/* ---------- Lesson page ---------- */
.lesson-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.lesson-head > div { min-width: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 18px 0 22px; -webkit-overflow-scrolling: touch; }
.tab {
  padding: 10px 16px; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 650; }
.tab.ext { margin-inline-start: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); font-weight: 550;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.reading { max-width: 720px; }
.reading p, .reading li { margin: .5em 0; }
.reading ul { padding-inline-start: 1.3em; }
.reading h2:first-child { margin-top: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }

.kpi-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; max-width: 720px; }
.kpi-list li { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.kpi-list .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 650; font-size: 14px; }

.terms { display: grid; gap: 10px; max-width: 720px; margin: 0; }
.term { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.term dt { font-weight: 650; color: var(--accent-strong); }
.term dd { margin: 2px 0 0; }

/* RTL lessons: interface text stays LTR; only the content column moves to the right edge */
.lesson-head.rtl { flex-direction: row-reverse; }
.rtl-col .reading, .rtl-col .kpi-list, .rtl-col .terms, .rtl-col .quiz { margin-left: auto; }

/* ---------- Quiz ---------- */
.quiz { max-width: 720px; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.qtype { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); padding: 2px 10px; border-radius: 99px; }
.question { font-size: 1.2rem; font-weight: 600; line-height: 1.5; margin: 14px 0 18px; }
.options { display: grid; gap: 10px; }
.option {
  text-align: start; padding: 13px 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; display: flex; gap: 12px; align-items: flex-start;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option .key { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; font-weight: 650; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option:disabled { cursor: default; color: inherit; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback strong.head { display: block; margin-bottom: 4px; }
.answer-box { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); }
.answer-box h4 { margin: 0 0 4px; font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-strong); }
.answer-box p { margin: .3em 0; }
textarea.answer {
  width: 100%; min-height: 110px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}
.score-big { font-size: 3rem; font-weight: 700; color: var(--accent-strong); line-height: 1.1; }
.review-item { padding: 12px 0; border-top: 1px solid var(--border); }
.review-item:first-child { border-top: none; }

/* ---------- Flashcards ---------- */
.flash-wrap { max-width: 560px; margin: 0 auto; text-align: center; }
.flashcard { perspective: 1200px; width: 100%; height: 260px; background: none; border: none; padding: 0; cursor: pointer; display: block; }
.flashcard .inner { display: block; position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  overflow: auto;
}
.flashcard .back { transform: rotateY(180deg); background: var(--accent-soft); }
.flashcard .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.flashcard .term-big { font-size: 1.6rem; font-weight: 650; }
.flashcard .def { font-size: 1.1rem; }
.flash-controls { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 18px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 10px; }

/* ---------- Search ---------- */
.result { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.result:hover { border-color: var(--accent); }
.result .where { font-size: 13px; color: var(--muted); }
.result mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Lesson v2 (redesigned lesson page) ---------- */
.v2 { max-width: 760px; }
.section-nav {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border); margin: 18px 0 28px; padding-bottom: 2px;
}
.section-nav a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font-size: 14px; font-weight: 550; border: 1px solid transparent;
}
.section-nav a:hover { color: var(--text); background: var(--surface-2); }
.section-nav a.active { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent-soft); }

.v2-section { scroll-margin-top: 70px; margin-bottom: 46px; }
.v2-section > h2 { display: flex; align-items: center; gap: 10px; margin-top: 0; }
.v2-section > h2 .num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700; }

/* At a glance */
.glance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.glance-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.glance-stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 3px; }
.glance-stat .value { font-weight: 650; font-size: 1.05rem; }
.difficulty { display: inline-flex; gap: 3px; align-items: center; }
.difficulty .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.difficulty .dot.on { background: var(--accent); }
.prereq-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.prereq-list li { background: var(--surface-2); border-radius: 999px; padding: 5px 12px; font-size: 14px; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; width: 100%; cursor: pointer; }
.checklist input[type=checkbox] { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.checklist li.checked label { background: var(--good-soft); border-color: var(--good-soft); }
.checklist li.checked span.kpi-text { text-decoration: line-through; color: var(--muted); }

/* Idea in simple words */
.idea-card { border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; border: 1px solid var(--border); }
.idea-card.simple { background: var(--accent-soft); }
.idea-card.academic { background: var(--surface); }
.idea-card.analogy { background: var(--warn-soft); }
.idea-card .idea-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; font-weight: 650; }

/* Boxes and diagrams inside the full explanation */
.info-box { border-radius: 12px; padding: 14px 18px; margin: 14px 0; border-inline-start: 4px solid var(--accent); background: var(--surface); }
.info-box.formula { border-inline-start-color: var(--accent); }
.info-box.rule { border-inline-start-color: #a9863f; }
.info-box.date { border-inline-start-color: #b9645a; }
.info-box .box-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 4px; }
.diagram-box { text-align: center; margin: 16px 0; }
.diagram-box svg { max-width: 100%; height: auto; }
.diagram-box .caption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Key-term chips: tap or hover to see the definition */
.term-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.term-chip { position: relative; }
.term-chip button {
  border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; font-weight: 550;
}
.term-chip .def-pop {
  display: none; position: absolute; bottom: calc(100% + 6px); inset-inline-start: 0; z-index: 5;
  background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 10px; font-size: 13px;
  width: max-content; max-width: 260px; box-shadow: var(--shadow);
}
.term-chip:hover .def-pop, .term-chip:focus-within .def-pop, .term-chip.open .def-pop { display: block; }

/* Worked examples */
.example { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 20px; }
.example-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.example-head h3 { margin: 0; }
.diff-tag { font-size: 12px; padding: 2px 10px; border-radius: 99px; font-weight: 650; white-space: nowrap; }
.diff-tag.easy { background: var(--good-soft); color: var(--good); }
.diff-tag.medium { background: var(--warn-soft); color: #8a6a1a; }
.diff-tag.hard { background: var(--bad-soft); color: var(--bad); }
:root[data-theme="dark"] .diff-tag.medium { color: #e3c877; }
.example .problem { font-weight: 600; margin-bottom: 14px; }
.step { border-top: 1px dashed var(--border); padding: 12px 0; }
.step:first-child { border-top: none; }
.step .step-n { font-size: 12px; text-transform: uppercase; color: var(--accent-strong); font-weight: 650; letter-spacing: .04em; margin-bottom: 4px; }
.step .work { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; margin: 4px 0; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.step .why { font-size: 13px; color: var(--muted); margin-top: 6px; background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; display: inline-block; }
.example .final-answer { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--good-soft); color: var(--good); font-weight: 650; }
.mistakes-box { background: var(--bad-soft); border-radius: var(--radius); padding: 16px 20px; margin-top: 4px; }
.mistakes-box h3 { margin-top: 0; color: var(--bad); }
.mistakes-box ul { margin: 0; padding-inline-start: 1.2em; }
.mistakes-box li { margin: 8px 0; }

/* Videos */
.video-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.video-card { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px 16px; }
.video-card .channel { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.video-card .note { font-size: 14px; margin: 0 0 10px; }
.video-card .vtitle { font-weight: 650; }

/* Punnett square practice */
.pn-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 12px 0; }
.pn-controls label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.pn-controls select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.pn-cross { font-size: 18px; margin: 4px 0 8px; }
.punnett { border-collapse: collapse; margin: 4px 0; }
.punnett th, .punnett td { border: 1px solid var(--border); padding: 6px; text-align: center; }
.punnett th { background: var(--accent-soft); color: var(--accent-strong); min-width: 52px; }
.punnett th, .punnett input { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.punnett input, .pn-counts input { width: 78px; padding: 8px 6px; text-align: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; }
.punnett input.ok, .pn-counts input.ok { border-color: var(--good); background: var(--good-soft); }
.punnett input.bad, .pn-counts input.bad { border-color: var(--bad); background: var(--bad-soft); }
.pn-counts { display: grid; gap: 8px; margin: 14px 0 0; max-width: 420px; }
.pn-counts label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.my-video-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.my-video-form input { flex: 1; min-width: 180px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.my-videos-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.my-videos-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Quick recall */
.quick-recall-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.quick-recall-item .from { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* Summary card / print */
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.summary-card ul { padding-inline-start: 1.2em; }
.must-not-forget { background: var(--warn-soft); border-radius: 12px; padding: 16px 20px; margin-top: 16px; }
.must-not-forget h3 { margin-top: 0; }
.must-not-forget ol { margin: 0; padding-inline-start: 1.3em; }
.must-not-forget li { margin: 6px 0; font-weight: 550; }

.summary-card .sheet-title { margin-top: 0; }

/* ---------- Colour-coded sentence parts ({{m:…}} {{k:…}} {{n:…}} {{x:…}} in lesson text) ---------- */
:root { --hl-m: #b3362b; --hl-k: #2f7d3f; --hl-n: #2563a8; --hl-x: #8a5a00; }
:root[data-theme="dark"] { --hl-m: #f0958a; --hl-k: #86d09c; --hl-n: #8ab8f0; --hl-x: #e3c877; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --hl-m: #f0958a; --hl-k: #86d09c; --hl-n: #8ab8f0; --hl-x: #e3c877; }
}
.hl { font-weight: 650; }
.hl-m { color: var(--hl-m); }
.hl-k { color: var(--hl-k); }
.hl-n { color: var(--hl-n); }
.hl-x { color: var(--hl-x); }
.hl-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; margin-bottom: 14px; font-size: 15px; }

/* English helper line under an Arabic explanation */
.en-note { color: var(--muted); font-size: .92em; line-height: 1.55; border-inline-start: 3px solid var(--border); padding-inline-start: 12px; margin: .4em 0 .9em; text-align: left; }
.feedback .en-note { margin-bottom: 0; }

/* Comparison tables inside the full explanation */
.table-wrap { overflow-x: auto; margin: 14px 0; }
.cmp-table { border-collapse: collapse; width: 100%; background: var(--surface); font-size: .95em; }
.cmp-table th, .cmp-table td { border: 1px solid var(--border); padding: 9px 12px; text-align: start; vertical-align: top; }
.cmp-table thead th { background: var(--accent-soft); color: var(--accent-strong); }
.cmp-table tbody th { background: var(--surface-2); white-space: nowrap; }

/* RTL lessons: worked steps read right-to-left in the normal text font */
.step .work { white-space: pre-wrap; }
.rtl-col .step .work { direction: rtl; font-family: inherit; }

/* Practice ladder */
.drill-level { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 5px 14px; border-radius: 99px; display: inline-block; margin: 22px 0 10px; }
.drill-level.easy { background: var(--good-soft); color: var(--good); }
.drill-level.medium { background: var(--warn-soft); color: #8a6a1a; }
.drill-level.exam { background: var(--bad-soft); color: var(--bad); }
:root[data-theme="dark"] .drill-level.medium { color: #e3c877; }
.drill { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.drill-q { font-weight: 600; font-size: 1.08rem; margin-bottom: 12px; }
.drill .option { padding: 10px 14px; }

/* Reading text of an unseen-text lesson */
.passage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 0 0 18px; }
.passage h2 { margin-top: 0; }
.passage summary { cursor: pointer; font-weight: 650; color: var(--accent-strong); }
.passage-text { font-size: 1.12rem; line-height: 2.1; }
details.passage .passage-text { margin-top: 10px; max-height: 46vh; overflow-y: auto; }

/* Exam countdown + revision plan */
.exam-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; text-decoration: none; color: inherit; background: var(--warn-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px; }
.exam-strip:hover { border-color: var(--accent); }
.exam-strip .grow, .exam-head .grow, .checklist .grow { flex: 1; min-width: 0; }
.exam-count { background: #b9645a; color: #fff; font-weight: 700; border-radius: 99px; padding: 2px 12px; font-size: 14px; white-space: nowrap; }
.exam-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 26px; max-width: 860px; }
.exam-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.exam-head h2 { margin: 0; }
.exam-count-big { flex: none; min-width: 108px; text-align: center; background: #b9645a; color: #fff; border-radius: var(--radius); padding: 10px 14px; line-height: 1.2; }
.exam-count-big .n { display: block; font-size: 2.3rem; font-weight: 750; }
.exam-count-big .u { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.exam-date { margin: 2px 0 0; color: var(--muted); }
.exam-note { margin: 6px 0 0; font-size: .95em; }
.plan-day { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.plan-day h3 { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.plan-day .when { background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 1px 12px; font-size: 13px; font-weight: 650; }
.plan-day.is-today .when { background: var(--accent); color: #fff; }
.plan-day.is-past { opacity: .6; }
.plan-day .mins { margin-inline-start: auto; font-size: 13px; font-weight: 400; color: var(--muted); }
.task-min { color: var(--muted); font-size: 13px; white-space: nowrap; }
.task-link { flex: none; font-size: 14px; white-space: nowrap; align-self: center; }
@media (max-width: 600px) { .exam-panel .checklist label { flex-wrap: wrap; } }

@media print {
  .topbar, .crumbs, .section-nav, .update-banner, .no-print { display: none !important; }
  .v2-section:not(.print-section) { display: none !important; }
  body { font-size: 13px; background: #fff; color: #000; }
  .summary-card { box-shadow: none; border: none; padding: 0; }
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand-name { display: none; }
  h1 { font-size: 1.5rem; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .flashcard { height: 240px; }
  .tab { padding: 10px 12px; }
  .section-nav a { padding: 8px 11px; font-size: 13px; }
  .glance-grid { grid-template-columns: 1fr 1fr; }
  .example { padding: 14px 16px; }
}
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
