/* ===== Disable programming ligatures in all code (JetBrains Mono turns == != >= <= -> && || into symbols) ===== */
.mono, .inline-code, code, pre, kbd, samp, textarea, .code, .codebox, .cm-editor, .cm-content, .cm-line, .hl,
[class*="code"], [style*="JetBrains"], svg text, svg text[font-family*="Mono"],
.bugcode, .tcur, .tout, .vb-out, .vb-row input, .vb-row select, .mq-opts button, .hi-body, .hi-head,
.run-head, .run-note, .output, .output .lbl, .varbox .vn, .varbox .vv, .trace-head, .trace-note, .trace-btn,
.tbtn, .explainer .lc, .kw-chips span, .flipcard .back, .flipcard .type, .tcls .code, .codebar .fname,
.copy-btn, .edit-btn, .save-btn, .cancel-btn, .reset-btn, .run-btn, .lvl, .tag, .floaty, .ubp-txt,
.exrow .ex-mark, .lesson-num, .nav a .num {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "dlig" 0;
}

:root {
    --paper: #fcfcf9;
    --paper-2: #f2efe6;
    --ink: #181818;
    --ink-soft: #4a4a44;
    --ink-faint: #8a8a80;
    --mustard: #c9971c;
    --mustard-deep: #a87e10;
    --mustard-wash: #f6ecd4;
    --line: #e3dfd2;
    --code-bg: #1d1d1a;
    --code-ink: #f0ead8;
    --code-green: #a8c686;
    --code-gray: #7d7d72;
    --ok: #4c7a3f;
    --radius: 10px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --mono: 'JetBrains Mono', monospace;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    background: var(--paper);
    color: var(--ink);
    font-family: "IBM Plex Sans Arabic", -apple-system, "Segoe UI", sans-serif;
    font-size: 17px;
    line-height: 1.85;
    /* dotted grid texture */
    background-image: radial-gradient(#d8d4c4 1px, transparent 1px);
    background-size: 26px 26px;
  }
  code, pre, .mono { font-family: "JetBrains Mono", monospace; }

  /* ============ Sidebar ============ */
  .sidebar {
    position: fixed;
    top: 0; right: 0;
    width: 300px; height: 100vh;
    border-left: 1px solid var(--line);
    background: var(--paper);
    display: flex; flex-direction: column;
    padding: 28px 26px;
    z-index: 50;
  }
  .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
  .brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mustard); flex-shrink: 0; }
  .brand b { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
  .brand small { display: block; font-size: 12px; color: var(--ink-faint); font-weight: 400; }
  .nav-label {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px; letter-spacing: .14em;
    color: var(--ink-faint);
    text-transform: uppercase;
    margin-bottom: 12px;
  }
  .nav { list-style: none; overflow-y: auto; flex: 1; }
  .nav a {
    display: flex; align-items: baseline; gap: 12px;
    padding: 10px 12px;
    color: var(--ink-soft);
    text-decoration: none;
    border-radius: 6px;
    font-size: 15px;
    transition: background .15s ease, color .15s ease;
    position: relative;
  }
  .nav a .num {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px; color: var(--ink-faint);
    min-width: 22px;
  }
  .nav a:hover { background: var(--paper-2); color: var(--ink); }
  .nav a.active { background: var(--mustard-wash); color: var(--ink); font-weight: 600; }
  .nav a.active::before {
    content: ""; position: absolute; right: -26px; top: 20%;
    width: 3px; height: 60%; background: var(--mustard); border-radius: 2px;
  }
  .nav a.active .num { color: var(--mustard-deep); }

  /* ============ Main ============ */
  .main { margin-right: 300px; }
  .wrap { max-width: 780px; margin: 0 auto; padding: 0 40px; }

  /* Hero */
  .hero { padding: 90px 0 70px; border-bottom: 1px solid var(--line); }
  .hero .kicker {
    font-family: "JetBrains Mono", monospace;
    font-size: 13px; letter-spacing: .12em;
    color: var(--mustard-deep);
    margin-bottom: 22px;
  }
  .hero h1 {
    font-size: clamp(42px, 6vw, 72px);
    line-height: 1.25; font-weight: 700; letter-spacing: -.02em;
  }
  .hero h1 .hl { position: relative; white-space: nowrap; }
  .hero h1 .hl::after {
    content: ""; position: absolute; right: 0; left: 0; bottom: 6px;
    height: 12px; background: var(--mustard-wash); z-index: -1;
  }
  .hero p.lead { font-size: 19px; color: var(--ink-soft); max-width: 560px; margin-top: 22px; }
  .tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
  .tag {
    font-family: "JetBrains Mono", monospace; font-size: 12px;
    border: 1px solid var(--line); border-radius: 999px;
    padding: 6px 16px; color: var(--ink-soft); background: var(--paper);
  }
  .tag.hot { border-color: var(--mustard); color: var(--mustard-deep); background: var(--mustard-wash); }

  /* Sections */
  section.lesson { padding: 72px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
  .lesson-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 14px; }
  .lesson-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 13px; font-weight: 700;
    color: var(--mustard-deep);
    border: 1px solid var(--mustard);
    border-radius: 6px;
    padding: 4px 10px;
    margin-top: 8px;
    flex-shrink: 0;
    background: var(--mustard-wash);
  }
  h2 { font-size: 34px; font-weight: 700; letter-spacing: -.015em; line-height: 1.4; }
  .lesson .sub { color: var(--ink-soft); font-size: 18px; margin: 6px 0 26px; }

  h3 { font-size: 21px; font-weight: 700; margin: 34px 0 10px; display: flex; align-items: center; gap: 10px; }
  h3::before { content: ""; width: 22px; height: 2px; background: var(--mustard); flex-shrink: 0; }
  p { margin-bottom: 14px; }
  ul.dots { list-style: none; margin: 0 0 16px; }
  ul.dots li { padding-right: 22px; position: relative; margin-bottom: 8px; }
  ul.dots li::before { content: ""; position: absolute; right: 2px; top: .72em; width: 7px; height: 7px; border-radius: 50%; background: var(--mustard); }
  .inline-code {
    font-family: "JetBrains Mono", monospace; font-size: .86em;
    background: var(--paper-2); border: 1px solid var(--line);
    border-radius: 5px; padding: 1px 7px;
    direction: ltr; unicode-bidi: isolate;
    color: var(--mustard-deep); font-weight: 500;
  }

  .quiz-code {
    display: block; font-family: var(--mono, "JetBrains Mono", monospace); font-size: 14px; line-height: 1.6;
    direction: ltr; text-align: left; unicode-bidi: isolate;
    background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 14px; margin: 8px 0 4px;
    white-space: pre; overflow-x: auto; color: var(--mustard-deep); font-weight: 500;
  }

  /* Code block */
  .codebox { position: relative; margin: 20px 0; border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.08); }
  .codebox > .codebar:last-child { border-top: 1px solid rgba(255,255,255,.07); }
  .codebar {
    position: relative; z-index: 2; /* فوق طبقة تظليل المحرر اللاصقة */
    display: flex; align-items: center; justify-content: space-between;
    background: #262622; padding: 9px 16px;
    direction: ltr;
  }
  .codebar .dots { display: flex; gap: 7px; }
  .codebar .dots i { width: 11px; height: 11px; border-radius: 50%; background: #4a4a42; display: block; }
  /* اسم البرنامج في الشريط العلوي — مميّز كشارة ذهبية ليربطه الطالب باسم الكلاس داخل الكود */
  .codebox > .codebar:first-child { justify-content: flex-start; gap: 12px; }
  .codebox > .codebar:first-child .fname { margin: 0 auto; }
  .codebar .fname {
    font-family: "JetBrains Mono", monospace; font-size: 12.5px; font-weight: 700;
    color: #d8b56a; background: rgba(201,151,28,.14);
    border: 1px solid rgba(201,151,28,.38); border-radius: 6px;
    padding: 3px 14px;
  }
  /* الشريط السفلي: أزرار التشغيل والتعديل — في أسفل نافذة البرنامج */
  .codebar-actions { justify-content: flex-end; }
  .copy-btn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: var(--code-gray);
    border-radius: 5px; padding: 3px 12px; cursor: pointer;
    transition: all .15s ease;
  }
  .copy-btn:hover { color: var(--code-ink); border-color: var(--mustard); }
  pre.code {
    background: var(--code-bg); color: var(--code-ink);
    padding: 20px 22px; overflow-x: auto;
    direction: ltr; text-align: left;
    font-size: 14.5px; line-height: 1.75;
    tab-size: 4;
  }
  pre.code .ln { display: block; opacity: 0; transform: translateY(6px); }
  pre.code.revealed .ln { animation: chunk-in .55s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
  @keyframes chunk-in { to { opacity: 1; transform: translateY(0); } }
  .k  { color: var(--mustard); font-weight: 500; unicode-bidi: isolate; }       /* keyword */
  .s  { color: var(--code-green); unicode-bidi: isolate; }                        /* string */
  .c  { color: var(--code-gray); font-style: italic; unicode-bidi: isolate; }     /* comment */
  .n  { color: #d8b4e2; unicode-bidi: isolate; }                                  /* number */
  .f  { color: #8fb8d8; unicode-bidi: isolate; }                                  /* method call */

  .run-btn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: #a8c686;
    border-radius: 5px; padding: 3px 12px; cursor: pointer;
    transition: all .15s ease;
  }
  .run-btn:hover { background: rgba(168, 198, 134, .12); border-color: #a8c686; }
  .codebar .actions { display: flex; gap: 8px; }
  .edit-btn, .save-btn, .cancel-btn, .reset-btn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: #d8c98a;
    border-radius: 5px; padding: 3px 12px; cursor: pointer;
    transition: all .15s ease;
  }
  .edit-btn:hover, .save-btn:hover { color: #1d1d1a; background: #a8c686; border-color: #a8c686; }
  .cancel-btn { color: #e08a8a; }
  .cancel-btn:hover { background: #e08a8a; color: #1d1d1a; border-color: #e08a8a; }
  .reset-btn { color: #8fb8d8; }
  .reset-btn:hover { background: #8fb8d8; color: #1d1d1a; border-color: #8fb8d8; }
  textarea.code-edit {
    display: block; width: 100%; box-sizing: border-box;
    background: transparent; color: transparent;
    border: 0; outline: none; padding: 20px 22px;
    font-family: "JetBrains Mono", monospace; font-size: 14.5px; line-height: 1.75;
    direction: ltr; text-align: left; min-height: 120px; resize: vertical;
    tab-size: 4; caret-color: #a8c686;
    position: relative; z-index: 1; white-space: pre; overflow: auto;
  }
  textarea.code-edit::selection { background: rgba(129, 173, 236, .28); color: transparent; }

  /* مضيف محرر CodeMirror 6 — ينمو بارتفاع المحتوى مثل pre.code */
  .cm-host { direction: ltr; text-align: left; background: var(--code-bg); }
  .cm-host .cm-editor { max-height: 420px; }
  .cm-host .cm-scroller { scrollbar-width: thin; }

  /* غلاف المحرر: يحدد ارتفاع الطبقة = ارتفاع textarea حتى تتطابق مواضع الأسطر والتمرير */
  .code-edit-wrap { position: relative; }

  /* طبقة التظليل اللاصقة خلف المحرر — نفس خط/حاشية textarea ونفس ارتفاعه (عبر الغلاف)
     حتى تتطابق الأحرف سطرًا سطرًا مع مواضع النقر؛ شريط الأزرار خارج الغلاف وفوقها بخلفيته */
  .code-edit-hl {
    position: absolute; top: 0; bottom: 0; left: 0; right: 0;
    margin: 0; padding: 20px 22px; box-sizing: border-box;
    background: var(--code-bg); color: var(--code-ink);
    font-family: "JetBrains Mono", monospace; font-size: 14.5px; line-height: 1.75;
    direction: ltr; text-align: left; white-space: pre; overflow: hidden;
    pointer-events: none;
    tab-size: 4;
  }
  /* ألوان الرموز (.k/.s/.c/.n/.f) تُورث من القواعد العامة — نفس ألوان عرض الكود تمامًا */

  .run-panel {
    margin: 0 0 20px; border-radius: var(--radius); overflow: hidden;
    border: 1px solid #2c2c27; background: #141412;
  }
  .run-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; background: #22221e;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px; letter-spacing: .08em; color: #8a8a80;
  }
  .run-head .st { margin-left: auto; }
  .run-head .ok { color: #8fc98a; }
  .run-head .bad { color: #e08a8a; }
  .run-panel pre {
    padding: 14px 18px; color: #d6e2c8;
    font-size: 14.5px; line-height: 1.75;
    direction: ltr; text-align: left; min-height: 12px;
    white-space: pre-wrap;
  }
  .run-panel .rl { opacity: 0; animation: chunk-in .3s cubic-bezier(0.16, 1, 0.3, 1) forwards; display: block; }
  .run-panel .err-line { color: #e08a8a; }
  .run-note {
    padding: 8px 18px 12px; font-size: 11px; color: #6a6a60;
    border-top: 1px dashed #33332d;
    font-family: "JetBrains Mono", monospace;
  }
  .run-head .goto-line {
    background: none; border: 1px solid #6a6a60; color: #c9971c;
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    border-radius: 6px; padding: 2px 8px; margin-inline-start: 8px;
    cursor: pointer;
  }
  .run-head .goto-line:hover { border-color: #c9971c; }
  .hint-box {
    margin: 0 18px 12px; padding: 12px 16px;
    background: rgba(201,151,28,.08);
    border: 1px dashed rgba(201,151,28,.45);
    border-radius: 10px;
    direction: rtl; text-align: right;
  }
  .hint-box .hint-title { color: #c9971c; font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
  .hint-box .hint-text { color: #d6ccb4; font-size: 13px; line-height: 1.8; }

  /* Output */
  .output {
    background: var(--paper-2); border: 1px dashed var(--ink-faint);
    border-radius: var(--radius);
    padding: 14px 20px; margin: -6px 0 20px;
  }
  .output .lbl {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    letter-spacing: .12em; color: var(--ok); font-weight: 700;
    display: block; margin-bottom: 6px;
  }
  .output pre { font-size: 14.5px; direction: ltr; text-align: left; white-space: pre-wrap; }

  /* Tip / warning strips */
  .note, .warn {
    border-radius: var(--radius);
    padding: 16px 20px; margin: 20px 0;
    font-size: 15.5px;
  }
  .note { background: var(--mustard-wash); border: 1px solid #e8d9ae; }
  .warn { background: #f9ecec; border: 1px solid #e6c9c9; }
  .note b, .warn b { display: block; margin-bottom: 4px; font-size: 14px; }
  .note b { color: var(--mustard-deep); }
  .warn b { color: #a33; }

  /* Data-type table */
  table.types { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15.5px; background: var(--paper); }
  table.types th, table.types td { border: 1px solid var(--line); padding: 11px 16px; text-align: right; }
  table.types th { background: var(--paper-2); font-weight: 700; font-size: 14.5px; }
  table.types td.mono { direction: ltr; text-align: left; color: var(--mustard-deep); font-weight: 500; }

  /* الجوال: تحويل جداول الدروس إلى بطاقات متراكبة — كل صف بطاقة وكل خلية سطر يبدأ بعنوان عمودها */
  @media (max-width: 640px) {
    .fig { padding: 12px 6px 8px; }
    .explainer li { flex-direction: column; gap: 6px; align-items: stretch; padding: 12px 14px; }
    .explainer .lc { min-width: 0; font-size: 13.5px; }
    .lesson table.types, .lesson table.types tbody, .lesson table.types tr, .lesson table.types td { display: block; width: 100%; }
    .lesson table.types { background: none; border-collapse: separate; border-spacing: 0; }
    .lesson table.types thead { display: none; }
    .lesson table.types tr { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; padding: 6px 0; overflow: hidden; }
    .lesson table.types td { border: 0; border-bottom: 1px dashed var(--line); padding: 8px 14px; font-size: 14.5px; }
    .lesson table.types tr td:last-child { border-bottom: 0; }
    .lesson table.types td::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-soft, #6b6353); margin-bottom: 2px; }
    .lesson table.types td.mono { text-align: right; }
    .lesson table.types td.mono::before { text-align: right; }
  }

  /* رسوم SVG التوضيحية داخل الدروس */
  .fig { margin: 18px 0; padding: 18px 14px 12px; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
  .fig svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
  .fig figcaption { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft, #6b6353); }

  /* شرائح الكلمات المحجوزة */
  .kw-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
  .kw-chips span {
    font-family: "JetBrains Mono", monospace; font-size: 13px; font-weight: 600;
    color: var(--mustard-deep); background: var(--mustard-wash);
    border: 1px solid #e0cf9d; border-radius: 8px; padding: 4px 12px;
  }

  /* كود مشروح بالنقر — النقر على سطر يعرض شرحه في اللوحة */
  .annotated-code .ln[data-tip] { cursor: pointer; }
  .annotated-code .ln[data-tip]:hover { background: var(--mustard-wash); }
  .annotated-code .ln.on { background: var(--mustard-wash); box-shadow: inset 3px 0 0 var(--mustard); }
  .ann-panel { margin: 10px 0 0; padding: 12px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--paper-2); font-size: 14.5px; min-height: 22px; }
  .ann-panel b { display: block; color: var(--mustard-deep); margin-bottom: 2px; }

  /* منشئ المتغير — يبني جملة التعريف ويتحقق منها فورًا */
  .var-builder { margin: 18px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
  .vb-title { font-weight: 700; margin-bottom: 10px; font-size: 15.5px; }
  .vb-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .vb-row select, .vb-row input { font-family: "JetBrains Mono", monospace; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); color: var(--ink); }
  .vb-out { margin-top: 12px; font-family: "JetBrains Mono", monospace; direction: ltr; text-align: left; background: var(--code-bg); color: var(--code-ink); padding: 10px 14px; border-radius: 8px; min-height: 22px; }
  .vb-msg { margin-top: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
  .vb-msg.err { color: #b3532e; }
  .vb-msg.ok { color: var(--ok); }

  /* تمارين مصغرة فورية التصحيح */
  .micro-quiz { margin: 14px 0; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--paper); }
  .micro-quiz .mq-q { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
  .mq-opts { display: flex; gap: 8px; flex-wrap: wrap; }
  .mq-opts button { font-family: "JetBrains Mono", monospace; font-size: 13px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); color: var(--ink); cursor: pointer; transition: all .15s ease; }
  .mq-opts button:hover { border-color: var(--mustard); }
  .mq-opts button.right { background: #e4efdd; border-color: var(--ok); color: var(--ok); font-weight: 700; }
  .mq-opts button.wrong { background: #f7e3e0; border-color: #d9a49c; color: #b3532e; }
  .mq-fb { margin-top: 8px; font-size: 13.5px; color: var(--ink-soft); display: none; }

  /* Line-by-line explainer */
  .explainer { list-style: none; margin: 18px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
  .explainer li { display: flex; gap: 16px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: baseline; }
  .explainer li:last-child { border-bottom: 0; }
  .explainer .lc {
    font-family: "JetBrains Mono", monospace; font-size: 12.5px;
    color: var(--mustard-deep); direction: ltr; text-align: left;
    min-width: 210px; flex-shrink: 0; font-weight: 500;
  }

  /* Exercises accordion */
  .exercise { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; background: var(--paper); overflow: hidden; }
  .ex-head {
    width: 100%; display: flex; align-items: center; gap: 14px;
    background: none; border: 0; cursor: pointer;
    padding: 18px 22px; text-align: right;
    font-family: inherit; font-size: 16.5px; font-weight: 600; color: var(--ink);
  }
  .ex-head:hover { background: var(--paper-2); }
  .ex-head .chev { margin-right: auto; transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1); color: var(--ink-faint); font-size: 14px; font-family: "JetBrains Mono", monospace; }
  .exercise.open .ex-head .chev { transform: rotate(180deg); }
  .ex-body { max-height: 0; overflow: hidden; transition: max-height .45s cubic-bezier(0.16, 1, 0.3, 1); }
  .ex-inner { padding: 4px 22px 22px; border-top: 1px dashed var(--line); }
  .lvl { font-family: "JetBrains Mono", monospace; font-size: 11px; border-radius: 999px; padding: 3px 12px; flex-shrink: 0; }
  .lvl.easy { background: #e4efdd; color: var(--ok); border: 1px solid #c8dcb9; }
  .lvl.mid { background: var(--mustard-wash); color: var(--mustard-deep); border: 1px solid #e8d9ae; }

  /* Trace panel */
  .trace-btn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: #8fb8d8;
    border-radius: 5px; padding: 3px 12px; cursor: pointer;
    transition: all .15s ease;
  }
  .trace-btn:hover { background: rgba(143, 184, 216, .12); border-color: #8fb8d8; }
  pre.code .ln.trace-hl { background: rgba(201, 151, 28, .22); box-shadow: inset 3px 0 0 var(--mustard); border-radius: 3px; }
  .trace-panel { margin: 0 0 20px; border: 1px solid #2c2c27; background: #141412; border-radius: var(--radius); overflow: hidden; }
  .trace-head {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; background: #22221e;
    font-family: "JetBrains Mono", monospace; font-size: 11px; color: #8a8a80;
  }
  .trace-head .tstep { color: #d8c98a; }
  .trace-head .tbtns { margin-left: auto; display: flex; gap: 6px; }
  .tbtn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: #d8c98a;
    border-radius: 5px; padding: 2px 10px; cursor: pointer; transition: all .15s ease;
  }
  .tbtn:hover { background: #a8c686; color: #1d1d1a; border-color: #a8c686; }
  .trace-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
  .tcur {
    background: #1a1a16; border-radius: 6px; padding: 8px 12px; min-height: 20px;
    display: flex; flex-direction: column; gap: 4px; direction: rtl; text-align: right;
  }
  .tcur .tlabel { font-size: 12px; color: #d8c98a; font-weight: 600; unicode-bidi: isolate; }
  .tcur .tnote { font-size: 12px; color: #8a8a80; unicode-bidi: isolate; }
  .tcur .tcode {
    font-family: "JetBrains Mono", monospace; font-size: 13px; color: #d6e2c8;
    direction: ltr; text-align: left; unicode-bidi: isolate; white-space: pre-wrap; display: block;
  }
  .tcur.tdone .tlabel { color: #a8c686; }
  .tbtn:disabled { opacity: .4; cursor: not-allowed; }
  .tbtn:disabled:hover { background: transparent; color: #d8c98a; border-color: #4a4a42; }
  pre.code .ln.trace-cur { background: rgba(201, 151, 28, .30); box-shadow: inset 3px 0 0 var(--mustard), 0 0 0 1px rgba(201, 151, 28, .5); }
  .tvars { display: flex; flex-wrap: wrap; gap: 8px; min-height: 10px; align-items: flex-start; }
  .varbox {
    display: inline-flex; flex-direction: column; align-items: center; min-width: 80px;
    background: #22221e; border: 1px solid #3a3a33; border-radius: 8px; padding: 6px 12px;
    transition: border-color .3s ease, box-shadow .3s ease;
  }
  .varbox.changed { border-color: var(--mustard); box-shadow: 0 0 0 1px var(--mustard); animation: varpulse .6s ease-out 1; }
  @keyframes varpulse { from { background: rgba(201, 151, 28, .35); } to { background: #22221e; } }
  @media (prefers-reduced-motion: reduce) { .varbox, .varbox.changed { animation: none; transition: none; } }
  .varbox .vn { font-family: "JetBrains Mono", monospace; font-size: 11px; color: #8a8a80; direction: ltr; }
  .varbox .vv { font-family: "JetBrains Mono", monospace; font-size: 14px; color: #d6e2c8; direction: ltr; }
  .tout {
    font-family: "JetBrains Mono", monospace; font-size: 14px; color: #d6e2c8;
    direction: ltr; text-align: left; background: #101010; border: 1px dashed #33332d;
    border-radius: 6px; padding: 8px 12px; min-height: 20px; white-space: pre-wrap;
  }
  .trace-note { padding: 8px 18px 12px; font-size: 11px; color: #6a6a60; font-family: "JetBrains Mono", monospace; border-top: 1px dashed #33332d; }

  /* Verdict + celebration */
  .verdict { padding: 10px 18px; font-size: 14px; font-weight: 600; }
  .verdict.pass { background: rgba(140, 200, 130, .14); color: #8fc98a; }
  .verdict.fail { background: rgba(224, 176, 112, .12); color: #e0b070; }
  .confetti-piece {
    position: fixed; top: -14px; width: 8px; height: 13px; z-index: 999;
    pointer-events: none; border-radius: 2px;
    animation: confetti-fall 2.4s ease-in forwards;
  }
  @keyframes confetti-fall {
    to { transform: translateY(108vh) rotate(680deg); opacity: .7; }
  }
  .toast {
    position: fixed; bottom: 26px; inset-inline-start: 26px;
    background: var(--ink); color: var(--paper);
    padding: 12px 20px; border-radius: 10px; font-size: 14.5px; z-index: 1000;
    opacity: 0; transform: translateY(16px);
    transition: all .35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 320px;
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast .b-ico { color: var(--mustard); font-family: "JetBrains Mono", monospace; }

  /* Achievements in sidebar */
  .badge-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
  .badge-item { display: flex; gap: 9px; align-items: center; font-size: 12.5px; color: var(--ink-faint); opacity: .45; transition: opacity .3s ease; }
  .badge-item.unlocked { opacity: 1; color: var(--ink-soft); }
  .badge-item .b-ico { width: 20px; text-align: center; font-family: "JetBrains Mono", monospace; color: var(--mustard-deep); flex-shrink: 0; }
  .badge-item .b-name { font-weight: 600; color: var(--ink); }
  .badge-item .b-desc { font-size: 11px; line-height: 1.5; }
  .nav a .done-mark { color: var(--ok); font-size: 12px; margin-right: 2px; font-weight: 700; }
  .chip-done { font-family: "JetBrains Mono", monospace; font-size: 11px; background: #e4efdd; color: var(--ok); border: 1px solid #c8dcb9; border-radius: 999px; padding: 3px 12px; }

  /* Flip cards */
  .flipgrid { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
  .flipcard { width: 128px; height: 148px; -webkit-perspective: 700px; perspective: 700px; cursor: pointer; border-radius: 10px; }
  .flipcard:focus-visible { outline: 2px solid var(--mustard); outline-offset: 3px; }
  .flipcard .inner { position: relative; width: 100%; height: 100%; transition: -webkit-transform .55s cubic-bezier(0.16, 1, 0.3, 1), transform .55s cubic-bezier(0.16, 1, 0.3, 1); -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
  .flipcard.flipped .inner { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
  .flipcard .face {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    border-radius: 10px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 8px; padding: 10px; text-align: center;
  }
  .flipcard .front { background: var(--paper-2); border: 1px solid var(--line); }
  .flipcard .front small { color: var(--ink-faint); font-size: 11px; }
  .flipcard .back { background: var(--code-bg); color: var(--code-ink); transform: rotateY(180deg); font-size: 13px; line-height: 1.6; }
  .flipcard .back code { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--code-green); direction: ltr; }
  .flipcard .type { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 19px; color: var(--mustard-deep); direction: ltr; }

  /* Bug-finding game */
  .buggame { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-bottom: 16px; overflow: hidden; }
  .buggame.solved { border-color: #c8dcb9; }
  .bugq { padding: 16px 20px 4px; font-weight: 600; font-size: 16px; }
  .bugcode {
    margin: 12px 20px; background: var(--code-bg); border-radius: 8px;
    padding: 14px 12px; direction: ltr; text-align: left;
    font-family: "JetBrains Mono", monospace; font-size: 14px; line-height: 2.1;
  }
  .bug-ln { display: block; padding: 0 10px; border-radius: 5px; cursor: pointer; transition: background .15s ease; color: var(--code-ink); }
  .bug-ln:hover { background: rgba(168, 198, 134, .15); }
  .bug-ln.good { background: rgba(140, 200, 130, .28); }
  .bug-ln.bad { background: rgba(220, 130, 130, .28); }
  .bughint-btn {
    background: none; border: 1px dashed var(--ink-faint); color: var(--ink-faint);
    border-radius: 999px; font-size: 12px; padding: 2px 14px; cursor: pointer;
    margin: 0 20px; font-family: inherit;
  }
  .bughint-btn:hover { color: var(--ink-soft); border-color: var(--ink-soft); }
  .bughint { font-size: 13.5px; color: var(--ink-faint); padding: 8px 20px 0; display: none; }
  .bug-fb { padding: 10px 20px 16px; font-size: 14.5px; min-height: 20px; font-weight: 600; }
  .bug-fb.ok { color: var(--ok); }
  .bug-fb.no { color: #a33; }

  /* Level widget (نظام النقاط والمستويات) */
  .level-widget { padding: 2px 2px 0; }
  .lw-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 7px; }
  .lw-top b { color: var(--mustard-deep); font-size: 14px; }
  .lw-top span { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-faint); }
  .lw-bar { height: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
  .lw-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--mustard), var(--mustard-deep)); border-radius: 999px; transition: width .6s cubic-bezier(0.16, 1, 0.3, 1); }
  .lw-next { font-size: 11px; color: var(--ink-faint); margin-top: 6px; }
  .cert-btn { margin-top: 14px; width: 100%; border: 1px solid var(--mustard); background: #faf3df; color: var(--mustard-deep); border-radius: 9px; padding: 9px 12px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .2s ease; }
  .cert-btn:hover { background: #f4e8c8; }

  /* Certificate (شهادة الإتمام) */
  #certificate { position: fixed; inset: 0; z-index: 90; background: rgba(24, 22, 16, .55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
  #certificate.cert-locked { display: none; }
  .cert-card { width: min(760px, 100%); }
  .cert-border { background: var(--paper); border: 2px solid var(--mustard-deep); outline: 6px double #e8d9ae; outline-offset: -14px; border-radius: 6px; padding: 44px 48px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
  .cert-head { display: flex; align-items: center; gap: 14px; justify-content: center; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
  .cert-logo { font-size: 30px; }
  .cert-titles { text-align: center; }
  .cert-titles b { display: block; font-size: 19px; }
  .cert-titles small { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-faint); letter-spacing: 2px; }
  .cert-body { text-align: center; padding: 26px 10px 8px; }
  .cert-honor { font-size: 34px; font-weight: 700; color: var(--mustard-deep); margin-bottom: 16px; }
  .cert-line { color: var(--ink-soft); font-size: 15px; line-height: 1.9; }
  .cert-name { display: block; margin: 14px auto 16px; width: min(420px, 90%); text-align: center; font-family: inherit; font-size: 26px; font-weight: 700; color: var(--ink); background: transparent; border: none; border-bottom: 2px dashed var(--mustard); padding: 6px 10px; outline: none; }
  .cert-name::placeholder { color: var(--ink-faint); font-weight: 400; font-size: 18px; }
  .cert-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 30px; padding: 0 12px; }
  .cert-meta { text-align: center; font-size: 14px; }
  .cert-meta small { display: block; color: var(--ink-faint); font-size: 11px; margin-top: 3px; }
  .cert-seal { width: 74px; height: 74px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e0b845, var(--mustard-deep)); color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; font-weight: 700; line-height: 1.3; box-shadow: 0 4px 14px rgba(168, 126, 16, .45); transform: rotate(-8deg); }
  .cert-name-fixed { border-bottom-style: solid; cursor: default; }
  .cert-details { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
  .cert-details i { font-style: normal; color: var(--mustard); }
  .cert-verify { text-align: center; margin-top: 16px; font-size: 12px; color: var(--ink-faint); }
  .cert-verify b { font-family: "JetBrains Mono", monospace; font-weight: 500; letter-spacing: 1px; font-variant-ligatures: none; unicode-bidi: isolate; }
  .cert-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
  .cert-actions .tbtn { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 9px 18px; font-family: inherit; font-size: 13.5px; cursor: pointer; color: var(--ink); transition: background .2s ease; }
  .cert-actions .tbtn:hover { background: var(--paper-2); }

  @media print {
    /* إخفاء كل شيء إلا الشهادة — إلا في صفحة الغشاشة التي تُطبع محتواها كاملًا */
    body:not(.cheat-page) > *:not(#certificate) { display: none !important; }
    #certificate { position: static; background: #fff; padding: 0; display: block !important; }
    .cert-border { box-shadow: none; outline-color: #d8c98e; background: #fff; color: #1d1b1a; padding: 30px 40px 20px; border-color: #a87e10; page-break-inside: avoid; }
    .cert-card { width: 100%; page-break-inside: avoid; }
    .cert-honor { color: #a87e10; }
    .cert-line, .cert-details { color: #4a4232; }
    .cert-name { color: #1d1b1a; border-bottom-color: #c9971c; }
    .cert-titles small, .cert-meta small, .cert-verify { color: #6b6353; }
    .cert-head { border-bottom-color: #d9d2c0; }
    .cert-seal { background: #c9971c; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .no-print { display: none !important; }
  }

  /* ===== واجهة البطل التفاعلية ===== */
  .hero { position: relative; }
  .hero-ide { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; border: 1px solid rgba(29, 27, 26, .18); box-shadow: 0 22px 48px rgba(29, 27, 26, .16); max-width: 660px; margin: 40px auto 0; text-align: left; }
  .hi-head { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); font-family: var(--mono); font-size: 12px; color: #9a917c; }
  .hi-head .dot { width: 10px; height: 10px; border-radius: 50%; background: #e0c060; }
  .hi-head .dot:nth-child(2) { background: #a8c686; }
  .hi-head .dot:nth-child(3) { background: #d8a0b8; }
  .hi-head b { margin-inline-start: auto; color: #c9c2ae; font-weight: 600; }
  .hi-body { padding: 16px; font-family: var(--mono); font-size: 13px; line-height: 1.95; color: #f4f1e8; }
  .hi-line { white-space: pre; }
  .hi-out { margin-top: 12px; padding-top: 10px; border-top: 1px dashed rgba(255, 255, 255, .15); color: #9a917c; font-size: 12.5px; min-height: 20px; text-align: right; }
  .hi-out code { color: #a8c686; }
  .hi-foot { padding: 12px 16px 16px; }
  #heroRun { font-family: inherit; font-size: 15px; font-weight: 700; padding: 10px 22px; border-radius: 999px; border: none; cursor: pointer; background: var(--mustard); color: #fff; box-shadow: 0 6px 16px rgba(201, 151, 28, .4); transition: transform .2s ease, box-shadow .2s ease; }
  #heroRun:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(201, 151, 28, .5); }
  #heroRun:active { transform: translateY(0); }

  .floaty { position: absolute; font-family: var(--mono); color: var(--mustard); opacity: .35; animation: floaty 6s ease-in-out infinite alternate; pointer-events: none; user-select: none; }
  .f1 { top: 12%; inset-inline-start: 3%; font-size: 34px; animation-delay: 0s; }
  .f2 { top: 68%; inset-inline-start: 8%; font-size: 24px; animation-delay: 1.2s; opacity: .28; }
  .f3 { top: 16%; inset-inline-end: 4%; font-size: 30px; animation-delay: .6s; opacity: .3; }
  .f4 { top: 86%; inset-inline-end: 2.5%; font-size: 30px; animation-delay: 1.8s; }
  .f5 { top: 88%; inset-inline-start: 3%; font-size: 20px; animation-delay: .9s; opacity: .22; }
  @keyframes floaty { to { transform: translateY(-14px) rotate(7deg); } }

  /* بطاقات اختبر نفسك */
  .quiz { margin: 30px 0; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
  .quiz-tag { display: inline-block; font-size: 12px; font-weight: 700; color: #7a5c07; background: var(--mustard-wash); border-radius: 999px; padding: 3px 12px; margin-bottom: 10px; }
  .quiz-q { font-weight: 700; margin-bottom: 12px; font-size: 15.5px; }
  .quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .quiz-opts button { font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fcfcf9; cursor: pointer; text-align: right; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
  .quiz-opts button:hover:not(:disabled) { border-color: var(--mustard); background: var(--mustard-wash); transform: translateY(-1px); }
  .quiz-opts button.ok { border-color: #7a9e5c; background: #edf3e2; color: #3f6b23; font-weight: 700; }
  .quiz-opts button.no { border-color: #c96a4a; background: #f9ece6; color: #9a3b1e; text-decoration: line-through; }
  .quiz-opts button.dim { opacity: .55; }
  .quiz-opts button:disabled { cursor: default; }
  /* خيارات كود (dir=ltr): خط الكود ويسار-إلى-يمين */
  .quiz-opts[dir="ltr"] button, .quiz-opts button[dir="ltr"] { font-family: var(--mono); font-size: 13.5px; direction: ltr; text-align: left; unicode-bidi: isolate; min-width: 0; }
  /* خيار طويل: عمود واحد وسطر واحد على الشاشات الواسعة */
  .quiz-opts[dir="ltr"] button.opt-ar, .quiz-opts.long[dir="ltr"] button.opt-ar { font-family: inherit; font-size: inherit; direction: rtl; text-align: right; white-space: normal; overflow-x: visible; }
  .quiz-opts.long { grid-template-columns: 1fr; }
  .quiz-opts.long button { min-width: 0; }
  .quiz-opts.long[dir="ltr"] button, .quiz-opts.long button[dir="ltr"] { white-space: nowrap; overflow-x: auto; }
  @media (max-width: 600px) {
    .quiz-opts.long[dir="ltr"] button, .quiz-opts.long button[dir="ltr"] { white-space: normal; overflow-wrap: anywhere; overflow-x: visible; }
  }
  .quiz-fb { display: none; margin-top: 12px; font-size: 13.5px; background: var(--mustard-wash); border-radius: 10px; padding: 10px 12px; color: #5c430c; }
  .quiz-fb.show { display: block; }

  /* ظهور العناصر عند التمرير */
  .reveal { opacity: 0; transform: translateY(22px); transition: opacity .6s cubic-bezier(0.16, 1, 0.3, 1), transform .6s cubic-bezier(0.16, 1, 0.3, 1); }
  .reveal.in { opacity: 1; transform: none; }

  /* لمسات حِرفية */
  ::selection { background: var(--mustard); color: #fff; }
  button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }
  .nav a { position: relative; }
  .nav a::after { content: ''; position: absolute; bottom: 6px; inset-inline-start: 14px; inset-inline-end: 14px; height: 2px; background: var(--mustard); border-radius: 2px; transform: scaleX(0); transition: transform .25s ease; }
  .nav a:hover::after, .nav a.active::after { transform: scaleX(1); }
  html { scrollbar-color: #d9d2b8 #f4f0e2; scrollbar-width: thin; }
  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-track { background: #f4f0e2; }
  ::-webkit-scrollbar-thumb { background: #d9d2b8; border-radius: 8px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--mustard); }

  @media (max-width: 900px) {
    .floaty { display: none; }
    .hero-ide { margin-top: 30px; }
    .quiz-opts { grid-template-columns: 1fr; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .reveal { opacity: 1 !important; transform: none !important; }
    .floaty { display: none; }
  }

  /* ===== الوحدات ===== */
  .nav-unit { margin-bottom: 4px; }
  .nav-unit .unit-title { display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%; background: none; border: 0; font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--mustard-deep); padding: 10px 12px 6px; cursor: pointer; border-radius: 8px; text-align: right; transition: background .15s ease; }
  .nav-unit .unit-title:hover { background: var(--paper-2); }
  .nav-unit .unit-title small { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--ink-faint); font-weight: 400; margin-inline-start: auto; }
  .nav-unit .unit-title .chev { font-size: 10px; color: var(--ink-faint); transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1); }
  .nav-unit.open .unit-title .chev { transform: rotate(-90deg); }
  .unit-lessons { display: none; list-style: none; margin: 0 0 8px; padding: 0; border-inline-start: 2px solid var(--line); margin-inline-start: 10px; }
  .nav-unit.open .unit-lessons { display: block; }
  .unit-lessons a { padding: 8px 10px; font-size: 13.5px; gap: 8px; }
  .unit-lessons a .num { min-width: 26px; }
  .nav-extra { margin-top: 4px; border-top: 1px dashed var(--line); padding-top: 6px; }

  .unit-band { padding: 64px 0 10px; scroll-margin-top: 20px; }
  .ub-card { position: relative; background: linear-gradient(135deg, #fffdf5, #f9f1da); border: 1px solid #e8d9a8; border-radius: 14px; padding: 26px 30px 22px; overflow: hidden; }
  .ub-card::after { content: "{ }"; position: absolute; left: 22px; bottom: 2px; font-family: var(--mono); font-size: 58px; font-weight: 700; color: rgba(201, 151, 28, .13); pointer-events: none; }
  .ub-num { display: inline-block; font-size: 12.5px; font-weight: 700; color: #7a5c07; background: var(--mustard-wash); border: 1px solid #e8d9a8; padding: 3px 14px; border-radius: 999px; margin-bottom: 10px; }
  .ub-card h2 { font-size: 26px; margin-bottom: 8px; }
  .ub-card p { color: var(--ink-soft); font-size: 14.5px; max-width: 620px; }
  .ub-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; max-width: 560px; }
  .ub-chip { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; transition: background .3s ease, color .3s ease, border-color .3s ease; }
  .ub-chip.on { background: #e4efdd; color: #3f6b23; border-color: #c8dcb9; }
  .ub-progress { position: absolute; inset-inline-end: 28px; top: 26px; width: 150px; }
  .ubp-track { height: 5px; background: #ece4c8; border-radius: 3px; overflow: hidden; }
  .ubp-fill { display: block; height: 100%; width: 0%; background: var(--mustard); border-radius: 3px; transition: width .5s cubic-bezier(0.16, 1, 0.3, 1); }
  .ubp-txt { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--ink-faint); margin-top: 6px; display: block; text-align: end; }

  @media (max-width: 900px) {
    .ub-progress { position: static; width: 100%; margin-top: 14px; }
    .ubp-txt { text-align: start; }
    .ub-card::after { display: none; }
  }

  /* Footer */
  footer { padding: 60px 0 80px; text-align: center; }
  footer .big { font-size: 26px; font-weight: 700; margin-bottom: 10px; }
  footer p { color: var(--ink-faint); font-size: 14.5px; }
  .cursor { display: inline-block; width: 9px; height: 1.1em; background: var(--mustard); vertical-align: text-bottom; margin-right: 6px; animation: blink 1.1s step-start infinite; }
  @keyframes blink { 50% { opacity: 0; } }

  /* ===== الجوال: شريط تنقّل علوي + قائمة جانبية منزلقة ===== */
  .nav-toggle {
    display: none; /* يظهر فقط تحت 900px */
    position: fixed; top: 12px; right: 12px; z-index: 80;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--paper); border: 1px solid var(--line);
    box-shadow: 0 2px 10px rgba(0,0,0,.10);
    font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink);
  }
  .nav-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 60;
    background: rgba(24, 24, 20, .45);
    opacity: 0; transition: opacity .3s ease;
  }

  @media (max-width: 900px) {
    .nav-toggle { display: block; }
    .main { margin-right: 0; padding-top: 64px; } /* مساحة لزر القائمة */
    .wrap { padding: 0 22px; }
    .hero { padding: 60px 0 50px; }

    /* القائمة الجانبية تصبح درجًا منزلقًا من اليمين (اتجاه RTL) */
    .sidebar {
      display: flex;
      transform: translateX(105%);
      transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1);
      width: min(320px, 86vw);
      box-shadow: -8px 0 30px rgba(0,0,0,.18);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    body.nav-open .sidebar { transform: translateX(0); z-index: 70; } /* فوق الخلفية المعتمة (60) */
    body.nav-open { overflow: hidden; }
    body.nav-open .nav-backdrop { display: block; opacity: 1; }

    /* منع تقريب iOS التلقائي عند التركيز: خط المحرر 16px والطبقة بنفسه */
    textarea.code-edit, .code-edit-hl { font-size: 16px; }

    /* أزرار صناديق الكود تلتف على الشاشات الضيقة */
    .codebar { flex-wrap: wrap; row-gap: 6px; }

    /* جداول لوحة المدرس تتمرر أفقيًا بدل الكسر */
    .tcard { overflow-x: auto; }
    .ttable { min-width: 560px; }
  }
  @media (max-width: 480px) {
    .quiz-opts button { font-size: 15px; }
    .bugcode { font-size: 12px; }
  }
/* ===== الصفحة الرئيسية: بطاقات الوحدات ===== */
.brand a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.nav-ex a { color: var(--mustard-deep); font-weight: 600; }
.nav-game a { color: #b34a17; font-weight: 700; }
.units-overview { padding: 74px 0 20px; }
.uo-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 8px; }
@media (min-width: 760px) { .uo-grid { grid-template-columns: 1fr 1fr; } }
.uo-card { display: block; position: relative; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 20px; text-decoration: none; color: inherit; transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), border-color .25s ease, box-shadow .25s ease; }
.uo-card:hover { transform: translateY(-4px); border-color: var(--mustard); box-shadow: 0 14px 34px rgba(24, 24, 24, .08); }
.uo-num { position: absolute; top: 6px; inset-inline-end: 16px; font-family: 'JetBrains Mono', monospace; font-size: 52px; font-weight: 700; color: rgba(201, 151, 28, .16); direction: ltr; pointer-events: none; }
.uo-tag { display: inline-block; font-size: 12px; font-weight: 700; color: #7a5c07; background: var(--mustard-wash); border-radius: 999px; padding: 3px 12px; margin-bottom: 12px; }
.uo-card h3 { font-size: 21px; margin-bottom: 8px; }
.uo-card > p { color: var(--ink-soft); font-size: 14.5px; line-height: 1.8; margin-bottom: 18px; }
.uo-progress { height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.uo-progress i { display: block; height: 100%; width: 0; background: var(--mustard); border-radius: 999px; transition: width .5s cubic-bezier(0.16, 1, 0.3, 1); }
.uo-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-faint); margin-bottom: 4px; }
.uo-meta b { color: var(--ink); font-weight: 600; }
.uo-go { color: var(--mustard-deep); font-weight: 700; }
.uo-done { display: none; color: var(--ok); font-weight: 700; font-size: 13px; }
.uo-card.uo-alt { background: linear-gradient(135deg, #fffdf5, #f9f1da); border-color: #e8d9a8; }
/* Footer داخل صفحات الوحدات */
.main > footer:first-of-type { margin-top: 40px; }

  /* ===== تقدم الوحدات في الشريط الجانبي ===== */
  .uprog { display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }
  .uprog-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; text-decoration: none; }
  .uprog-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
  .uprog-bar { height: 6px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
  .uprog-bar i { display: block; height: 100%; background: var(--mustard); border-radius: 99px; transition: width .5s ease; }
  .uprog-txt { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
  .uprog-row:hover .uprog-name { color: var(--mustard-deep); }

  /* ===== لوحة التقدّم في الرئيسية ===== */
  .dash { padding: 64px 0; background: linear-gradient(180deg, transparent, rgba(176,141,44,.05) 30%, transparent); }
  .dash-head { text-align: center; margin-bottom: 32px; }
  .dash-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: stretch; }
  .dash-overall { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
  .do-ring { width: 150px; height: 150px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: conic-gradient(var(--mustard) 0deg, var(--paper-2) 0deg); position: relative; }
  .do-ring::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--paper); }
  .do-ring b { position: relative; font-size: 30px; color: var(--ink); }
  .do-ring span { position: relative; font-size: 12px; color: var(--ink-faint); }
  .do-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
  .do-stat { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px; text-align: center; }
  .do-stat b { display: block; font-size: 17px; color: var(--mustard-deep); }
  .do-stat span { font-size: 11.5px; color: var(--ink-faint); }
  .dash-units { display: flex; flex-direction: column; gap: 14px; }
  .du-row { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; }
  .du-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .du-name { font-weight: 700; font-size: 16.5px; }
  .du-pct { font-weight: 700; color: var(--mustard-deep); font-size: 15px; }
  .du-bar { height: 9px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
  .du-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mustard), var(--mustard-deep)); border-radius: 99px; transition: width .5s ease; }
  .du-meta { display: flex; gap: 18px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--ink-faint); flex-wrap: wrap; }
  .du-go { margin-inline-start: auto; color: var(--mustard-deep); font-weight: 700; text-decoration: none; }
  .du-go:hover { text-decoration: underline; }
  @media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
  }

  /* ============ ويدجت الحساب السحابي (الشريط الجانبي) ============ */
  .auth-widget { margin: -22px 0 20px; }
  .aw-head { display: flex; align-items: center; gap: 9px; background: var(--mustard-wash); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; }
  .aw-head .aw-ico { color: var(--mustard-deep); }
  .aw-head b { display: block; font-size: 13.5px; line-height: 1.4; }
  .aw-head small { display: block; font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }
  .aw-btn { width: 100%; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-soft); border-radius: 9px; padding: 8px 12px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .2s ease; }
  .aw-btn:hover { background: var(--mustard-wash); color: var(--ink); }
  .aw-out { margin-top: 7px; font-weight: 400; }
  .aw-go { background: var(--mustard); border-color: var(--mustard); color: #fff; margin-top: 12px; }
  .aw-go:hover { background: var(--mustard-deep); }
  .nav-lock { margin: 0 0 20px; padding: 14px 13px; background: var(--mustard-wash); border: 1px dashed var(--line); border-radius: 10px; }
  .nav-lock p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); }
  .aw-tlink { color: var(--mustard-deep); text-decoration: underline; }
  .teacher-preview-note { margin: 10px auto; max-width: 960px; padding: 8px 14px; font-size: 13px; line-height: 1.7; text-align: center; color: var(--ink-soft, #6b6353); background: var(--paper-2, #fbf7ef); border: 1px dashed var(--line, #ddd3bf); border-radius: 10px; }
  .aw-hint { display: block; text-align: center; color: var(--ink-faint); font-size: 11px; margin-top: 5px; }
  .auth-hint { text-align: center; }

  /* نافذة تسجيل الدخول — بنمط نافذة الشهادة (overlay + بطاقة) */
  .auth-modal { position: fixed; inset: 0; background: rgba(24, 24, 24, .55); z-index: 900; display: none; align-items: center; justify-content: center; padding: 20px; }
  .auth-modal.open { display: flex; }
  .auth-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 400px; padding: 22px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.3); animation: none; }
  .auth-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .auth-top b { font-size: 16px; }
  .auth-x { border: none; background: none; cursor: pointer; color: var(--ink-faint); font-size: 15px; }
  .auth-x:hover { color: var(--ink); }
  .auth-note { background: var(--mustard-wash); border: 1px solid var(--mustard); border-radius: 9px; padding: 10px 13px; font-size: 13px; line-height: 1.8; color: var(--ink-soft); margin-bottom: 14px; }
  .auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
  .auth-tab { flex: 1; border: 1px solid var(--line); background: var(--paper-2); border-radius: 8px; padding: 7px; font-family: inherit; font-size: 13.5px; cursor: pointer; color: var(--ink-soft); }
  .auth-tab.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .auth-pane label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 9px 0 4px; }
  .auth-pane input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 15px; background: #fff; color: var(--ink); }
  .auth-pane input:focus { outline: 2px solid var(--mustard); outline-offset: 1px; }
  .auth-err { display: none; background: #f7e3e0; border: 1px solid #d9a49c; color: #8c3a2e; border-radius: 8px; padding: 7px 12px; font-size: 13px; margin-top: 10px; }
  .auth-err.show { display: block; }
  .auth-roster { display: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; margin-top: 8px; line-height: 1.7; }
  .auth-roster.ok, .auth-roster.bad { display: block; }
  .auth-roster.ok { background: #e4efdd; border: 1px solid #c8dcb9; color: var(--ok); font-weight: 600; }
  .auth-roster.bad { background: #f7e3e0; border: 1px solid #d9a49c; color: #8c3a2e; }
  #authNameWrap[hidden] { display: none; }
  .auth-pane.hidden { display: none; }
  .auth-tea-txt { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 4px; }

  /* ============ لوحة المدرس (teacher.html — تخطيط مستقل بلا شريط جانبي) ============ */
  .tpage { max-width: 1000px; margin: 0 auto; padding: 30px 24px 80px; }
  .tbar { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 26px; }
  .tbar .brand { margin: 0; }
  .tcard { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 24px 26px; margin-bottom: 20px; }
  .tcard h2 { font-size: 19px; margin-bottom: 6px; }
  .tcard .tsub { color: var(--ink-faint); font-size: 13.5px; margin-bottom: 14px; }
  .trow { display: flex; gap: 10px; flex-wrap: wrap; }
  .trow input { flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 15px; background: #fff; color: var(--ink); }
  .tbtn2 { border: 1px solid var(--mustard); background: var(--mustard); color: #fff; border-radius: 8px; padding: 9px 20px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
  .tbtn2:hover { background: var(--mustard-deep); }
  .tbtn2.ghost { background: var(--paper); color: var(--ink-soft); border-color: var(--line); }
  .tbtn2.ghost:hover { background: var(--paper-2); }
  .terr { display: none; background: #f7e3e0; border: 1px solid #d9a49c; color: #8c3a2e; border-radius: 8px; padding: 7px 12px; font-size: 13px; margin-top: 10px; }
  .terr.show { display: block; }
  .tnote { background: var(--mustard-wash); border: 1px solid var(--mustard); border-radius: 9px; padding: 10px 13px; font-size: 13px; line-height: 1.8; color: var(--ink-soft); margin-bottom: 14px; }
  .tcls { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 9px; cursor: pointer; transition: background .15s ease; }
  .tcls:hover { background: var(--paper-2); }
  .tcls.on { border-color: var(--mustard); background: var(--mustard-wash); }
  .tcls b { font-size: 15px; }
  .tcls .code { font-family: var(--mono); font-size: 12.5px; color: var(--mustard-deep); direction: ltr; display: inline-block; }
  .tcls .cnt { font-size: 12.5px; color: var(--ink-faint); }
  table.ttable { width: 100%; border-collapse: collapse; font-size: 14px; }
  .ttable th { text-align: right; font-size: 12px; color: var(--ink-faint); border-bottom: 1px solid var(--line); padding: 8px 10px; }
  .ttable td { border-bottom: 1px solid var(--line); padding: 10px; }
  .ttable tr.srow { cursor: pointer; }
  .ttable tr.srow:hover { background: var(--paper-2); }
  .tbar2 { height: 8px; background: var(--paper-2); border-radius: 99px; overflow: hidden; width: 110px; display: inline-block; vertical-align: middle; }
  .tbar2 i { display: block; height: 100%; background: var(--mustard); border-radius: 99px; }
  .tchip { display: inline-block; background: #e4efdd; color: var(--ok); border: 1px solid #c8dcb9; border-radius: 999px; padding: 2px 11px; font-size: 12px; margin: 2px 3px; }
  .tchip.b { background: var(--mustard-wash); color: var(--mustard-deep); border-color: var(--mustard); }
  .tdet { display: none; }
  .tdet.open { display: block; }
  .tdet h3 { font-size: 17px; margin-bottom: 2px; }
  .tdet .tmeta { color: var(--ink-faint); font-size: 13px; margin-bottom: 14px; }
  .tgrid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .tstat { flex: 1; min-width: 140px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 15px; }
  .tstat b { display: block; font-size: 20px; }
  .tstat small { color: var(--ink-faint); font-size: 12px; }
  .tunit { border: 1px solid var(--line); border-radius: 10px; padding: 11px 15px; margin-bottom: 8px; }
  .tunit .tu-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
  .track { height: 7px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
  .track i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

  /* ============ إعدادات الفصل في لوحة المدرس: الوحدات + قائمة الطلاب ============ */
  .tcls { display: block; cursor: default; padding: 14px 16px; }
  .tcls-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
  .tcls-lbl { font-size: 12px; color: var(--ink-faint); margin: 12px 0 6px; }
  .tu-chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .tu-chip { border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-soft); border-radius: 999px; padding: 5px 14px; font-family: inherit; font-size: 13px; cursor: pointer; transition: all .15s ease; }
  .tu-chip.on { background: #e4efdd; border-color: #c8dcb9; color: var(--ok); font-weight: 600; }
  .tu-chip:not(.on) { background: #f7e3e0; border-color: #d9a49c; color: #8c3a2e; }
  .tro { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
  .tro-head { font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .tro .trow { margin-bottom: 8px; }
  .tro-file { display: inline-block; cursor: pointer; }
  .tro-paste { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-family: inherit; font-size: 13.5px; background: #fff; color: var(--ink); resize: vertical; }
  .tro-actions { align-items: center; margin-top: 8px; }
  .tro-count { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
  .tro-msg { font-size: 12.5px; color: var(--ink-faint); min-height: 4px; margin-top: 4px; }
  .tro-msg.err { color: #8c3a2e; }

  /* تفصيل الإنجاز لكل وحدة (تفصيل الطالب) */
  .exrow { display: flex; align-items: baseline; gap: 8px; font-size: 13px; padding: 3px 0; color: var(--ink-faint); }
  .exrow.ok { color: var(--ink-soft); }
  .exrow .ex-mark { font-family: var(--mono); width: 16px; text-align: center; color: var(--ink-faint); flex-shrink: 0; }
  .exrow.ok .ex-mark { color: var(--ok); font-weight: 700; }
  .exrow .ex-lbl { flex: 1; }
  .exrow .ex-kind { font-size: 11px; color: var(--ink-faint); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }

  /* زر حذف طالب من لوحة المدرس */
  .stu-del { background: none; border: 1px solid var(--line); color: var(--ink-faint); border-radius: 8px; width: 28px; height: 28px; cursor: pointer; font-size: 13px; line-height: 1; transition: all .2s; }
  .stu-del:hover { color: #a33; border-color: #d9a0a0; background: #fdf3f3; }

  /* حقل الاسم المعبأ تلقائيًا من قائمة الفصل */
  #authName[data-roster] { border-color: #7fae6e; background: #f4faf1; }

  /* ===== لوحة المدرس: تحسينات المراجعة ===== */
  /* تمرير أفقي لجدول الطلاب بدل كسره على الشاشات الضيقة */
  .tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tscroll .ttable { min-width: 620px; }
  /* آخر نشاط قديم (أكثر من أسبوع) */
  .tinactive { color: #b3532e; font-weight: 600; }
  /* تمرين حاوله الطالب وأخطأ (لم ينجزه بعد) */
  .exrow.fail { color: #b3532e; }
  .exrow.fail .ex-mark { color: #b3532e; font-weight: 700; }
  .exrow.fail .ex-lbl { text-decoration: none; opacity: .85; }
  /* تلميح تحت منطقة اللصق (أصفار الأرقام في إكسل) */
  .tro-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; line-height: 1.6; }
  /* زر إعادة تسمية الفصل */
  .cls-ren { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--ink-faint); padding: 2px 5px; border-radius: 6px; }
  .cls-ren:hover { color: var(--mustard-deep); background: var(--mustard-wash); }
  /* صف البحث والتصدير فوق جدول الطلاب */
  .stu-tools { margin-bottom: 10px; align-items: center; }

  /* جوال: لوحة المدرس على الشاشات الصغيرة */
  @media (max-width: 640px) {
    .tpage { padding: 16px 12px 60px; }
    .tcard { padding: 16px; }
    #adminCard .trow { flex-direction: column; }
    #adminCard .trow input, #adminCard .trow button { width: 100%; min-width: 0; flex: none; }
    .tcls-head { flex-direction: column; align-items: stretch; gap: 8px; }
    .tstat { min-width: 110px; }
    .stu-tools { flex-direction: column; align-items: stretch; }
    .stu-tools input, .stu-tools button { width: 100%; min-width: 0; flex: none; }
    #clsCreate { width: 100%; }
    /* بطاقة الدخول: الحقول بعرض كامل */
    #loginCard .trow { flex-direction: column; }
    #loginCard input, #loginCard button { width: 100%; }
  }
  .aw-head small { display: block; }
  .aw-head b { display: block; margin-top: 2px; }

  /* ===== إعادة تنظيم الأوسمة: مصغّر في الشريط الجانبي + كاملة في لوحة التقدم ===== */
  .badge-mini { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 2px; }
  .badge-mini .b-chip { width: 34px; height: 34px; border-radius: 10px; background: var(--mustard-wash); border: 1px solid #e8d9ae; display: flex; align-items: center; justify-content: center; font-size: 17px; cursor: help; animation: bpop .45s cubic-bezier(0.16,1,0.3,1); }
  @keyframes bpop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  .badge-mini .b-empty { font-size: 11px; color: var(--ink-faint); padding: 2px 4px; line-height: 1.6; }
  .dash-badges { margin-top: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; }
  .dash-badges-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .dash-badges-head h3 { font-size: 18px; }
  .toast-award { background: #2c2c26; color: #ffe9a8; font-weight: 700; font-size: 15px; }

  /* ===== زر «سؤال آخر» في بنك الأسئلة البديلة ===== */
  .quiz-alt-btn { float: left; font-family: inherit; font-size: 12px; font-weight: 700; color: var(--mustard-deep); background: var(--paper); border: 1px solid #e8d9ae; border-radius: 999px; padding: 3px 12px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
  .quiz-alt-btn:hover { background: var(--mustard-wash); border-color: var(--mustard); }

  /* ===== صفحة الغشاشة الورقية (cheat.html) ===== */
  .cheat-hint { display: inline-block; font-size: 13px; color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; margin: 4px 0 8px; }
  .cheat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .cheat-grid table.types { font-size: 14px; }
  .cheat-grid table.types th, .cheat-grid table.types td { padding: 7px 12px; }
  .cheat-main h3 { margin-top: 22px; }
  .cheat-main .lesson { padding: 44px 0; }
  /* الجوال: قاعدة واحدة تأتي بعد التعريف الأساسي حتى لا تُلغى بالترتيب */
  @media (max-width: 768px) {
    .cheat-grid { grid-template-columns: 1fr; gap: 0; }
    .cheat-grid table.types { font-size: 13px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .cheat-grid table.types th, .cheat-grid table.types td { white-space: nowrap; }
    .cheat-grid table.types td[colspan], .cheat-grid table.types tr td:last-child { white-space: normal; }
    .cheat-main .lesson { padding: 30px 0; }
    .cheat-hint { font-size: 12px; padding: 6px 12px; border-radius: 10px; }
  }
  @media (max-width: 480px) {
    .cheat-grid table.types { font-size: 12px; }
    .cheat-grid table.types th, .cheat-grid table.types td { padding: 6px 8px; }
    .cheat-main h3 { font-size: 16.5px; }
  }
  @media print {
    body.cheat-page .sidebar { display: none !important; }
    body.cheat-page .main { margin-right: 0 !important; }
    body.cheat-page .cheat-main .wrap { max-width: 100% !important; }
    body.cheat-page section.lesson { padding: 12px 0; }
    body.cheat-page footer { display: none !important; }
    body.cheat-page .cheat-grid { grid-template-columns: 1fr 1fr; }
    .cheat-grid table.types { font-size: 12px; }
    body.cheat-page { background: #fff; }
  }

  /* محرر إعادة تسمية الفصل المضمّن */
  .cls-ren-inp { font-family: inherit; font-size: 14.5px; font-weight: 700; color: var(--ink); background: #fff; border: 1px solid var(--mustard); border-radius: 8px; padding: 5px 10px; width: 180px; }
  .cls-ren-ok, .cls-ren-no { padding: 5px 12px; font-size: 12px; }

/* ===== A1: سطر سلسلة النشاط */
#strkLine { color: #b0603a; }

/* ===== A2: احتفال إتمام الوحدة */
.unit-celebr {
  position: fixed; inset: 0; z-index: 950;
  background: rgba(24, 24, 24, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.uc-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 40px; text-align: center; max-width: 420px; width: 100%;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
.uc-ico { font-size: 46px; }
.uc-card h2 { margin: 10px 0 6px; font-size: 24px; }
.uc-card p { color: var(--ink-soft); margin: 0 0 18px; }
.uc-go { min-width: 140px; }

/* ===== A4: لوحة صدارة الفصل */
.dash-board {
  grid-column: 1 / -1;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px;
}
.dash-board h3 { margin: 0 0 12px; font-size: 17px; }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; font-size: 14px;
}
.board-row + .board-row { margin-top: 4px; }
.board-row.me { background: var(--mustard-wash); border: 1px solid #e8d9ae; font-weight: 700; }
.board-rank {
  width: 24px; height: 24px; border-radius: 50%; background: var(--paper-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: none;
}
.board-row:nth-child(1) .board-rank { background: #e8c25a; }
.board-row:nth-child(2) .board-rank { background: #d8d8d0; }
.board-row:nth-child(3) .board-rank { background: #dfa06a; }
.board-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-xp { color: var(--ink-faint); font-size: 12.5px; }
.board-note { display: block; margin-top: 10px; color: var(--ink-faint); font-size: 11.5px; }

/* ===== A5: شريط العودة بعد غياب */
.comeback-bnr {
  margin: 14px auto 0; max-width: 900px;
  background: var(--mustard-wash); border: 1px solid #e8d9ae; border-radius: 12px;
  padding: 12px 16px; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.comeback-bnr a { color: var(--mustard-deep); font-weight: 700; }
.cb-x { margin-inline-start: auto; border: none; background: none; cursor: pointer; font-size: 14px; color: var(--ink-faint); }

/* ===== زر «تابع من حيث توقفت» (أعلى الشريط الجانبي + بطل الرئيسية) */
.continue-cta {
  display: block; width: 100%; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--mustard); color: #1a1710; border: 1px solid var(--mustard-deep);
  font-family: inherit; font-size: 13.5px; font-weight: 700; line-height: 1.6; text-align: center;
  text-decoration: none; box-shadow: 0 4px 12px rgba(201, 151, 28, .28);
  transition: transform .2s ease, box-shadow .2s ease;
}
.continue-cta:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(201, 151, 28, .38); }
.continue-cta:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.continue-cta.cta-done { background: var(--mustard-wash); color: var(--mustard-deep); box-shadow: none; }
.continue-cta.hero-cta { display: inline-block; width: auto; max-width: 100%; margin: 20px 0 0; padding: 11px 24px; font-size: 15.5px; border-radius: 999px; }

/* ===== B3: عدّاد الموعد النهائي */
.dl-bnr {
  margin: 14px auto 0; max-width: 900px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600; text-align: center;
}
.dl-bnr.urgent { background: #b0402a; border-color: #b0402a; color: #fff; }

/* ===== A7: شريط التعافي بعد 4 محاولات */
.recover-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 4px; font-size: 13.5px;
}
.recover-btn { flex: none; }

/* ===== A6: ومضة النجمة الذهبية */
@keyframes luckyGlow {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px #e8c25a, 0 0 26px rgba(232, 194, 90, .85); }
}
.exercise.lucky-spark { border-radius: 12px; animation: luckyGlow .4s ease-in-out 4; }

  /* مواءمة bidi مع الـ textarea: اتجاه textarea ثابت LTR على كل أسطره (قاعدة HTML للـ form controls —
     الفقرات لا تأخذ اتجاهها من أول حرف قوي)، فالطبقة يجب أن تحاكي ذلك حرفيًا: سطر block باتجاه موروث LTR
     والخوارزمية تعيد ترتيب المقطع العربي داخله — نفس ما يراه textarea. plaintext كان يجعل السطر العربي
     فقرة RTL كاملة فينقلب ترتيبه عن textarea ويختلف موضع النقر */
  .code-edit-hl .hl-ln { display: block; }
  .code-edit-hl .hl-ln .k, .code-edit-hl .hl-ln .s, .code-edit-hl .hl-ln .c,
  .code-edit-hl .hl-ln .n, .code-edit-hl .hl-ln .f { unicode-bidi: normal; }

/* ===== [طالب] إعدادات الشريط الجانبي + التلميحات + استعادة الأصل (يضيفها وكيل واجهة الطالب) ===== */
  .sb-settings { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 10px; }
  .sb-settings > summary { cursor: pointer; font-size: 12.5px; color: var(--ink-faint); list-style: none; padding: 4px 2px; }
  .sb-settings > summary::-webkit-details-marker { display: none; }
  .sb-settings > summary:hover { color: var(--ink-soft); }
  .sb-settings-note { margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--ink-soft); }

  /* ===== الشريط الجانبي: ترتيب وأرقام ===== */
  /* السبب: .nav كان flex:1 فيتمدد ويدفع «تقدم الوحدات» إلى أسفل الشريط. الآن يتكدّس كل شيء طبيعيًا والشريط كله يتمرّر. */
  .sidebar { overflow-y: auto; overflow-x: hidden; }
  .sidebar > * { flex-shrink: 0; }
  .sidebar .nav { flex: 0 0 auto; overflow: visible; }
  .sidebar .nav-label { margin-top: 20px !important; margin-bottom: 10px; }
  .sidebar .brand + .nav-label { margin-top: 0 !important; }
  .sidebar .sb-settings { margin-top: 20px; }
  .sidebar .cert-btn { margin-top: 14px; }
  .sidebar .badge-mini { margin-bottom: 8px; }
  .level-widget .lw-top { margin-bottom: 8px; }
  .level-widget .lw-top b { font-size: 15px; }
  .level-widget .lw-top span { font-family: inherit; font-size: 12px; color: var(--ink-faint); }
  .level-widget #lvlNext { font-size: 12.5px; line-height: 1.6; color: var(--ink-soft); margin-top: 8px; }
  .level-widget #lvlEx { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
  .cert-btn.armed { border-color: #c0553f; background: #fbe9e4; color: #a03a26; }
  .note.hint-hidden { display: none; }
  .hint-btn { margin: 8px 0; }
  .codebox .restore-btn {
    font-family: "JetBrains Mono", monospace; font-size: 11px;
    background: transparent; border: 1px solid #4a4a42; color: #8fb8d8;
    border-radius: 5px; padding: 3px 12px; cursor: pointer; transition: all .15s ease;
  }
  .codebox .restore-btn:hover { background: #8fb8d8; color: #1d1d1a; border-color: #8fb8d8; }
/* ===== نهاية كتلة واجهة الطالب ===== */

/* ===== [لوحة المدرس] تحسينات لوحة المتابعة (teacher.js / teacher.html) ===== */
.tpage .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* إدارة المدرسين: بطاقة مطوية افتراضيًا أسفل الصفحة */
.tadmin > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tadmin > summary::-webkit-details-marker { display: none; }
.tadmin > summary h2 { margin: 0; display: inline-block; }
.tadmin > summary::before { content: '▸'; color: var(--ink-faint); font-size: 14px; }
.tadmin[open] > summary::before { content: '▾'; }
.tadmin-hint { font-size: 12.5px; color: var(--ink-faint); }
.tadmin[open] > summary { margin-bottom: 8px; }
/* بطاقة الفصل: صف ملخص مضغوط + إعدادات قابلة للطي */
.tcls-title { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cls-open { background: none; border: none; padding: 0; margin: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; text-align: start; }
.cls-open:hover { color: var(--mustard-deep); text-decoration: underline; }
.tcls-sum { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; cursor: pointer; }
.tcls-pill { font-size: 12.5px; color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.tcls-pill small { color: var(--ink-faint); font-size: 11px; }
/* معاينة الدروس (وضع المدرس) — رابط صغير في ملخص البطاقة + روابط الوحدات في رأس الفصل */
.tprev-link { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--mustard-deep); background: var(--mustard-wash); border: 1px solid #e8d9ae; border-radius: 999px; padding: 3px 12px; text-decoration: none; }
.tprev-link:hover { background: var(--paper-2); text-decoration: underline; }
.tprev-units { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 4px 0 10px; font-size: 12.5px; color: var(--ink-faint); }
.tprev-units .tprev-link.off { color: var(--ink-faint); background: var(--paper-2); border-color: var(--line); font-weight: 500; }
.cls-stuck.is-warn { color: #b3532e; }
.cls-stuck.is-good { color: var(--ok); }
.tcls-settings { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.tcls-settings > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 4px 0; }
.tcls-set-body { padding-top: 4px; }
.tcls-danger { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tdanger:hover { color: #a33; border-color: #d9a0a0; background: #fdf3f3; }
/* لافتة الانتباه */
.att-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.att-line { margin-top: 4px; }
.att-go { background: none; border: none; padding: 0; font: inherit; font-weight: 700; color: var(--mustard-deep); cursor: pointer; text-decoration: underline; }
/* وسوم أسباب التعثر في صف الطالب */
.stu-tag { display: inline-block; font-size: 11px; border-radius: 999px; padding: 1px 9px; margin: 2px 2px; border: 1px solid; white-space: nowrap; }
.stu-tag.stuck { background: #f7e3e0; color: #8c3a2e; border-color: #d9a49c; }
.stu-tag.absent { background: #f7e8d8; color: #a06a2c; border-color: #e3c39a; }
.stu-tag.zero { background: var(--paper-2); color: var(--ink-soft); border-color: var(--line); }
.stu-open { background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: start; }
.stu-open:hover b { color: var(--mustard-deep); }
.stu-num-m { display: none; color: var(--ink-faint); margin-inline-end: 6px; }
.th-sub { display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-faint); }
#stuFilterNote { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--mustard-wash); border: 1px solid var(--mustard); border-radius: 9px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
#stuFilterNote .tbtn2 { padding: 4px 12px; font-size: 12.5px; }
.ex-fails { color: #b3532e; font-size: 11.5px; margin-inline-start: 6px; }
.exrow.ok .ex-fails { color: var(--ink-faint); }
/* أكثر ما يحتاج إعادة شرح */
.treteach { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 6px 0 12px; background: var(--paper-2); }
.rt-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.rt-cols { display: flex; gap: 24px; flex-wrap: wrap; }
.rt-col { flex: 1; min-width: 220px; font-size: 13px; }
.rt-h { font-weight: 700; color: var(--ink-soft); margin-bottom: 2px; }
.rt-col ol { margin: 2px 0; padding-inline-start: 20px; line-height: 1.8; }
.rt-none { color: var(--ink-faint); margin: 2px 0; }
.hm-legend { font-size: 12px; color: var(--ink-faint); margin-top: 8px; line-height: 1.7; }
/* جوال: جدول الطلاب يتمرر أفقيًا داخل بطاقته مع بقاء عمود الاسم ظاهرًا */
@media (max-width: 700px) {
  .att-banner { flex-direction: column; }
  .tcls-sum { gap: 6px; }
}

/* ===== الملخص العام (cheat) ===== */
/* [hidden] يتقدّم على أي display صريح (وحدات عطّلها المدرس) */
.cheat-unit[hidden], .cheat-jump a[hidden] { display: none !important; }
.cheat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* شريط القفز + زر «اختبر نفسك» — لاصق على الشاشات الواسعة فقط حتى لا يغطي زر القائمة في الجوال */
.cheat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 4px; padding: 10px 0; background: var(--paper); border-bottom: 1px solid var(--line); }
@media (min-width: 901px) { .cheat-bar { position: sticky; top: 0; z-index: 20; } }
.cheat-jump { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; }
.cheat-jump a, .cheat-quiz-btn { font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; text-decoration: none; cursor: pointer; line-height: 1.5; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.cheat-jump a:hover, .cheat-quiz-btn:hover { background: var(--mustard-wash); border-color: var(--mustard); color: var(--ink); }
.cheat-jump a:focus-visible, .cheat-quiz-btn:focus-visible, .cheat-main td.ans:focus-visible, .lesson-link:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }
.cheat-quiz-btn[aria-pressed="true"] { background: var(--mustard-wash); border-color: var(--mustard); color: var(--ink); }

/* كل وحدة قسم مستقل بمرساة؛ الهامش العلوي يمنع تغطية الشريط اللاصق للعنوان عند القفز */
.cheat-unit { scroll-margin-top: 70px; }
.cheat-unit > h3 { flex-wrap: wrap; }
.cheat-status { margin-inline-start: auto; font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 2px 12px; border: 1px solid var(--line); color: var(--ink-faint); background: var(--paper-2); }
.cheat-status:empty { display: none; }
.cheat-status.is-done { color: var(--ok); border-color: var(--ok); background: transparent; }
.cheat-status.is-part { color: var(--ink-soft); }

/* الكود: يسار-إلى-يمين ومحاذى لليسار دائمًا؛ الشرح العربي يمين. الكود بلون الحبر العادي */
.cheat-main td.mono, .cheat-main .lesson table.types td.mono { direction: ltr; text-align: left; color: var(--ink); font-weight: 400; unicode-bidi: isolate; }
.cheat-main .inline-code { direction: ltr; unicode-bidi: isolate; color: var(--ink); font-weight: 400; }
.cheat-main .cheat-grid table.types td.codeblock { white-space: pre; font-size: .95em; line-height: 1.6; }
/* التلوين فقط للرمز الحرج في الصف */
.cheat-main .key { color: var(--mustard-deep); font-weight: 700; }

/* رابط «درس N·M» إلى الدرس الذي يشرح الصف — حبّة صغيرة خافتة، بلا خط افتراضي */
.lesson-link { display: inline-block; font-size: 11.5px; font-weight: 600; font-family: inherit; line-height: 1.6; color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 9px; text-decoration: none; white-space: nowrap; margin-inline-start: 8px; direction: rtl; unicode-bidi: isolate; }
.lesson-link:hover, .lesson-link:focus-visible { color: var(--ink); border-color: var(--mustard); text-decoration: underline; }
.cheat-main th .lesson-link { float: left; margin: 0 0 0 6px; }

/* الكود لا يلتف؛ الجدول يتمرر أفقيًا داخل غلافه عند الضيق */
.cheat-main td.mono { white-space: nowrap; }
.cheat-main .cheat-grid > div { min-width: 0; }
/* الجدول يملأ عمود الشبكة بعرض كامل؛ التمرير الأفقي على غلاف العمود نفسه ولا يظهر إلا عند فيض المحتوى (الجوال له قواعده أعلاه) */
@media (min-width: 769px) {
  .cheat-main .cheat-grid > div { overflow-x: auto; }
  .cheat-main .cheat-grid table.types { display: table; width: 100%; }
}
/* عمودان فقط حين يتسع عمود المحتوى؛ غير ذلك عمود واحد */
.cheat-unit { container-type: inline-size; }
@container (max-width: 1000px) { .cheat-grid { grid-template-columns: 1fr; gap: 0; } }
@supports not (container-type: inline-size) { @media (max-width: 1400px) { .cheat-grid { grid-template-columns: 1fr; gap: 0; } } }
/* الشاشات العريضة: عمود محتوى أوسع ليتسع عمودان لكل وحدة */
@media screen and (min-width: 1400px) { body.cheat-page .cheat-main .wrap { max-width: 1240px; } }
/* الكود العربي داخل التعليقات: كل سطر يحافظ على ترتيبه يسار-إلى-يمين */
.cheat-main .cheat-code, .cheat-main .codeblock, .cheat-main .mono { unicode-bidi: isolate; }
/* «باختصار» — سطر ملخص تحت عنوان كل وحدة */
.cheat-tldr { margin: 4px 0 14px; padding: 6px 14px; padding-inline-start: 14px; border-inline-start: 4px solid var(--mustard); font-size: 16px; line-height: 1.9; color: var(--ink-soft); background: transparent; break-inside: avoid; page-break-inside: avoid; }
.cheat-tldr b { color: var(--ink); font-weight: 700; margin-inline-end: 4px; }

/* صندوق الفخاخ في آخر كل وحدة */
.cheat-traps { margin: 6px 0 14px; padding: 12px 18px; border-radius: var(--radius); background: #f9ecec; border: 1px solid #e6c9c9; break-inside: avoid; page-break-inside: avoid; }
.cheat-traps-h { font-weight: 700; font-size: 14.5px; color: #a33; margin-bottom: 6px; }
.cheat-traps ul { list-style: none; margin: 0; }
.cheat-traps li { position: relative; padding-right: 18px; margin-bottom: 6px; font-size: 14px; line-height: 1.8; }
.cheat-traps li::before { content: ""; position: absolute; right: 2px; top: .85em; width: 6px; height: 6px; border-radius: 50%; background: #c06a5a; }
.cheat-traps li:last-child { margin-bottom: 0; }

/* وضع «اختبر نفسك»: خلايا الإجابة معتّمة حتى تُنقر */
.cheat-quiz-on td.ans { filter: blur(7px); cursor: pointer; user-select: none; -webkit-user-select: none; transition: filter .15s ease; }
.cheat-quiz-on td.ans.shown { filter: none; cursor: auto; user-select: text; -webkit-user-select: text; }
@media (prefers-reduced-motion: reduce) { .cheat-quiz-on td.ans { transition: none; } }

/* الجوال: الكود يبقى يسارًا حتى لو قاعدة الجداول العامة تجعله يمينًا */
@media (max-width: 768px) {
  .cheat-main .lesson table.types td.mono, .cheat-main .lesson table.types td.mono::before { text-align: left; }
  .cheat-bar { gap: 8px; }
  .cheat-jump a, .cheat-quiz-btn { font-size: 12.5px; padding: 5px 12px; }
  .cheat-unit { scroll-margin-top: 12px; }
}

/* الطباعة: ألوان فاتحة قسرًا، كل وحدة بصفحة (عدا الأولى)، بلا عناصر تفاعلية */
@media print {
  .cheat-bar, .cheat-quiz-btn, .cheat-jump, .lesson-link, .cheat-sr { display: none !important; }
  .cheat-unit + .cheat-unit { break-before: page; page-break-before: always; }
  .cheat-unit.cheat-first { break-before: auto; page-break-before: auto; }
  .cheat-main table.types, .cheat-main table.types tr { break-inside: avoid; page-break-inside: avoid; }
  .cheat-quiz-on td.ans, .cheat-quiz-on td.ans.shown { filter: none !important; user-select: auto !important; }
  .cheat-main .cheat-status { display: none; }
}

/* ===== الرسوم خطوة بخطوة (stepfig) ===== */
/* بلا JS يبقى كل شيء ظاهرًا؛ الصنف sf-off يضيفه JS فقط */
.stepfig .sf-off { opacity: 0; visibility: hidden; }
.stepfig [data-show] { transition: opacity .25s ease, visibility .25s; }
.stepfig:focus-visible { outline: 2px solid var(--mustard); outline-offset: 3px; }
.stepfig .sf-ctrl { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.stepfig .sf-btn { font: inherit; font-size: 14px; padding: 6px 14px; border: 1px solid var(--mustard); border-radius: 999px; background: var(--mustard-wash); color: var(--ink); cursor: pointer; }
.stepfig .sf-btn:hover:not(:disabled) { background: var(--mustard); color: #fff; }
.stepfig .sf-btn:focus-visible, .stepfig .sf-reset:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 2px; }
.stepfig .sf-btn:disabled { opacity: .45; cursor: not-allowed; }
.stepfig .sf-status { font-size: 13.5px; color: var(--ink-soft); min-width: 7.5em; text-align: center; }
.stepfig .sf-reset { font: inherit; font-size: 12.5px; background: none; border: 0; color: var(--ink-faint); text-decoration: underline; cursor: pointer; padding: 4px 6px; }
.stepfig .sf-reset:hover { color: var(--ink); }
/* نص شرح الخطوة */
.stepfig figcaption { margin-top: 10px; padding: 10px 14px; font-size: 15px; line-height: 1.8; color: var(--ink); background: var(--paper-2); border-inline-start: 4px solid var(--mustard); border-radius: var(--radius); min-height: 5.6em; }
/* سؤال التوقّع */
.stepfig p.step-q, p.step-q { margin: 10px 0 0; padding: 8px 12px; background: var(--mustard-wash); border: 1px dashed var(--mustard); border-radius: var(--radius); font-size: 14px; color: var(--ink); }
p.step-q::before { content: "🤔 توقّع: "; font-weight: 700; color: var(--mustard-deep); }
p.step-q.sf-off { display: none; }
@media (prefers-reduced-motion: reduce) {
  .stepfig [data-show] { transition: none; }
}

/* ===== رأس سؤال «اختبر نفسك» ===== */
.quiz-tag.quiz-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: none; border-radius: 0; padding: 0; margin-bottom: 12px; font-size: 13px; color: var(--ink-soft); }
.quiz-head-main { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.quiz-head .quiz-pill { font-size: 13px; font-weight: 800; color: #7a5c07; background: var(--mustard-wash); border-radius: 999px; padding: 3px 12px; }
.quiz-head .quiz-num { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.quiz-head .quiz-pts { flex-basis: 100%; order: 3; font-size: 12.5px; font-weight: 500; color: var(--ink-faint); }
.quiz-head .quiz-pts.done { color: #2f7a3e; font-weight: 700; }
.quiz-head .quiz-alt-btn { float: none; order: 2; margin-inline-start: auto; min-height: 32px; font-size: 13px; padding: 4px 14px; }
.quiz-head .quiz-alt-btn:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }
@media (max-width: 520px) {
  .quiz-head .quiz-alt-btn { flex-basis: 100%; margin-inline-start: 0; justify-content: center; }
  .quiz-head .quiz-pts { order: 2; }
  .quiz-head .quiz-alt-btn { order: 3; }
}

/* ===== عدّادات أسئلة «اختبر نفسك»: شارة القائمة الجانبية، سطر الوحدات، رابط إعادة التدرّب ===== */
.nav a .nav-qbadge { margin-inline-start: auto; font-size: 10.5px; font-weight: 700; color: var(--ink-faint); background: var(--paper-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; line-height: 18px; white-space: nowrap; }
.nav a .nav-qbadge.full { color: var(--ok); border-color: var(--ok); }
.uprog-q { grid-column: 1 / -1; font-size: 11px; color: var(--ink-faint); margin-top: -3px; }
.ubp-q, .uo-q { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; }
.quiz-retry-row { margin-top: 8px; }
.quiz-retry { background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--mustard-deep); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.quiz-retry:hover { color: var(--ink); }

/* ===== ميزان المقارنة (cmp-scale) ===== */
.cmp-scale.cmp-ready { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 14px 0; padding: 16px 18px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.cmp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; direction: ltr; }
.cmp-num, .cmp-op { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; text-align: center; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.cmp-num { width: 5.5em; }
.cmp-op { min-width: 4.5em; cursor: pointer; }
.cmp-num:focus-visible, .cmp-op:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 2px; }
.cmp-line { align-self: stretch; text-align: left; white-space: nowrap; overflow-x: auto; }
.cmp-sentence { margin: 0; }
.cmp-pill { display: inline-block; min-width: 4.5em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 16px; padding: 4px 16px; border-radius: 999px; border: 1px solid transparent; }
.cmp-pill.cmp-true { background: #e4f1de; color: #2f6b25; border-color: #9cc78f; }
.cmp-pill.cmp-false { background: #f9e4e1; color: #a33a2a; border-color: #e2aaa1; }
.cmp-pill.cmp-na { background: var(--paper); color: var(--ink-soft); border-color: var(--line); font-family: inherit; font-weight: 600; }
.cheat-code { direction: ltr; text-align: left; white-space: pre; overflow-x: auto; margin: 6px 0 12px; padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.7; }

/* ===== [لوحة المدرس] إعادة التصميم: رأس الفصل + تبويبات + مخطط الجلوس + لوحة الطالب (td-*) ===== */
.tpage { max-width: 1180px; }
/* اللون = الحالة فقط: متعثر (طين) · يتقدّم (ورق أخضر) · أتمّ الورشة (خردلي) · لم ينضم (باهت بحدود متقطعة) */
.tpage {
  --td-stuck-fg: #a64a24; --td-stuck-bg: #f7e3e0; --td-stuck-bd: #d9a49c; --td-stuck-dot: #b3532e;
  --td-ok-fg: #3c5c31; --td-ok-bg: #e4efdd; --td-ok-bd: #c8dcb9; --td-ok-dot: #5d8a4e;
  --td-done-fg: #7a5a10; --td-done-bg: var(--mustard-wash); --td-done-bd: var(--mustard); --td-done-dot: #c9971c;
}
.td-st-stuck { --st-fg: var(--td-stuck-fg); --st-bg: var(--td-stuck-bg); --st-bd: var(--td-stuck-bd); --st-dot: var(--td-stuck-dot); }
.td-st-ok { --st-fg: var(--td-ok-fg); --st-bg: var(--td-ok-bg); --st-bd: var(--td-ok-bd); --st-dot: var(--td-ok-dot); }
.td-st-done { --st-fg: var(--td-done-fg); --st-bg: var(--td-done-bg); --st-bd: var(--td-done-bd); --st-dot: var(--td-done-dot); }
.td-st-none { --st-fg: var(--ink-faint); --st-bg: transparent; --st-bd: var(--ink-faint); --st-dot: transparent; }
.td-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--st-dot); margin-inline-end: 7px; vertical-align: baseline; flex-shrink: 0; }
.td-dot.td-st-none { border: 1.5px dashed var(--ink-faint); width: 11px; height: 11px; box-sizing: border-box; }

/* «فصولي»: بطاقة كاملة بلا فصل محدد، وسطر مطوي عند فتح فصل */
.td-clscard > details > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-soft); list-style: none; }
.td-clscard > details > summary::-webkit-details-marker { display: none; }
.td-clscard > details > summary::before { content: '▸'; color: var(--ink-faint); margin-inline-end: 8px; }
.td-clscard > details[open] > summary::before { content: '▾'; }
.td-clscard > details[open] > summary { margin-bottom: 10px; }
.td-clscard > details > summary:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 3px; border-radius: 4px; }
.td-clscard:not(.td-nocls) { padding: 12px 20px; }
.td-clsh { font-size: 19px; margin-bottom: 6px; }
.td-clscard.td-nocls > details > summary { display: none; }
.td-clscard.td-nocls > details > .td-clsh { margin-top: 0; }

/* رأس الفصل */
.td-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.td-sel { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13.5px; background: var(--paper); color: var(--ink); }
.td-clssel { font-size: 18px; font-weight: 700; padding: 6px 12px; max-width: 100%; }
.td-codelbl { font-size: 12.5px; color: var(--ink-faint); }
.td-code { font-family: var(--mono); font-size: 13px; color: var(--mustard-deep); direction: ltr; font-variant-ligatures: none; background: var(--mustard-wash); border: 1px solid var(--mustard); border-radius: 6px; padding: 1px 8px; }
.td-loading { font-size: 12.5px; color: var(--ink-faint); }
.td-class.is-loading .td-tabpanel { opacity: .55; pointer-events: none; transition: opacity .15s ease; }
.td-sel:focus-visible, .td-search:focus-visible, .td-chk input:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 2px; }

/* التبويبات */
.td-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 12px 0 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.td-tab { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 10px 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.td-tab:hover { color: var(--ink); background: var(--paper-2); }
.td-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--mustard); }
.td-tab:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: -2px; border-radius: 6px; }
.td-tabpanel[hidden] { display: none; }

/* مخطط الجلوس */
.td-seat { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 820px; }
@media (min-width: 640px) { .td-seat { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.td-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 4px; border-radius: 10px; border: 1.5px solid var(--st-bd); background: var(--st-bg); color: var(--st-fg); font-family: inherit; cursor: pointer; min-width: 0; transition: opacity .15s ease, box-shadow .15s ease; }
.td-cell.td-st-none { border-style: dashed; }
.td-cn { font-size: 13.5px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-cp { font-size: 12px; }
.td-cell:hover { filter: brightness(.97); }
.td-cell.dim { opacity: .32; }
.td-cell.is-sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.td-cell:focus-visible, .td-lg:focus-visible, .td-need-row:focus-visible, .stu-open:focus-visible, .td-x:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 2px; }
.td-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 4px; }
.td-lg { display: inline-flex; align-items: center; background: none; border: 1px solid transparent; border-radius: 999px; padding: 4px 11px; font-family: inherit; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.td-lg:hover { background: var(--paper-2); }
.td-lg.on { background: var(--st-bg); border-color: var(--st-bd); color: var(--st-fg); font-weight: 700; }
.td-lg-sep { color: var(--ink-faint); }

/* شريط الأدوات: صف واحد */
.td-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.td-search { flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 14px; background: var(--paper); color: var(--ink); }
.td-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.td-menuwrap { position: relative; margin-inline-start: auto; }
.td-menubtn { padding: 7px 14px; font-size: 18px; line-height: 1; }
.td-menu { position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; min-width: 220px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 22px rgba(0,0,0,.14); padding: 4px; }
.td-menu[hidden] { display: none; }
.td-menu button { display: block; width: 100%; text-align: start; background: none; border: 0; border-radius: 7px; padding: 9px 12px; font-family: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.td-menu button:hover, .td-menu button:focus-visible { background: var(--paper-2); outline: none; }
.td-menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--mustard-deep); }

/* القائمة + لوحة الطالب */
.td-split { display: block; }
.td-list .ttable { min-width: 0; }
.td-list .ttable td { vertical-align: top; }
.stu-table tr.srow.is-sel td { background: var(--mustard-wash); }
.stu-table tr.spend td { background: transparent; }
.td-c-name { min-width: 150px; }
.td-num { display: block; text-align: right; color: var(--ink-faint); font-size: 11.5px; }
.td-c-xp small { display: block; color: var(--ink-faint); font-size: 11.5px; }
.td-c-pct { white-space: nowrap; }
.td-list .tbar2 { width: 70px; }
.td-pane { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: var(--paper); min-width: 0; }
.td-pane:not(.has-sel) { display: none; }
.td-pane-empty { color: var(--ink-faint); font-size: 14px; line-height: 1.9; margin: 0; padding: 18px 6px; text-align: center; }
.td-pbody.td-anim { animation: tdPaneIn .2s ease; }
@keyframes tdPaneIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.td-ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.td-ph-t { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.td-ph h3 { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.td-stl { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 11px; border: 1px solid var(--st-bd); background: var(--st-bg); color: var(--st-fg); white-space: nowrap; }
.td-stl.td-st-none { border-style: dashed; }
.td-x { background: none; border: 1px solid var(--line); color: var(--ink-faint); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; flex-shrink: 0; }
.td-x:hover { background: var(--paper-2); color: var(--ink); }
.td-meta { font-size: 12.5px; color: var(--ink-faint); margin: 6px 0 10px; }
.td-sum { font-size: 14.5px; line-height: 1.95; margin: 0 0 4px; color: var(--ink); }
.td-sum2 { font-size: 12.5px; line-height: 1.8; margin: 0 0 10px; color: var(--ink-faint); }
.td-callout { border-radius: 9px; padding: 9px 12px; font-size: 13.5px; line-height: 1.8; margin: 8px 0; border: 1px solid var(--st-bd); background: var(--st-bg); color: var(--st-fg); font-weight: 600; }
.td-co-stuck { --st-fg: var(--td-stuck-fg); --st-bg: var(--td-stuck-bg); --st-bd: var(--td-stuck-bd); }
.td-co-done { --st-fg: var(--td-done-fg); --st-bg: var(--td-done-bg); --st-bd: var(--td-done-bd); }
.td-mono { font-family: var(--mono); font-variant-ligatures: none; letter-spacing: .5px; }
.td-tags { margin: 4px 0; }
.td-h { font-size: 14px; margin: 16px 0 8px; }
.td-h2 { font-size: 13.5px; }
.td-faint { color: var(--ink-faint); font-size: 11px; }

/* وحدات قابلة للطي */
.td-unit { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--paper); }
.td-usum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 14px; cursor: pointer; list-style: none; font-size: 13.5px; }
.td-usum::-webkit-details-marker { display: none; }
.td-usum:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: -2px; border-radius: 10px; }
.td-ucount { color: var(--ink-soft); }
.td-unote { color: var(--td-stuck-fg); font-weight: 700; font-size: 12.5px; }
.td-chev { margin-inline-start: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-faint); border-bottom: 2px solid var(--ink-faint); transform: rotate(45deg); transition: transform .15s ease; }
.td-unit[open] .td-chev { transform: rotate(-135deg); }
.td-ubar { flex: 1 0 100%; height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.td-ubar i { display: block; height: 100%; background: var(--mustard); border-radius: 99px; }
.td-unit.is-stuck .td-ubar i { background: var(--td-stuck-dot); }
.td-unit.is-done .td-ubar i { background: var(--td-ok-dot); }
.td-ubody { padding: 0 14px 10px; }
.td-sub { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin: 10px 0 3px; }
.td-ubody .exrow { padding: 3px 6px; border-radius: 6px; }
.td-ubody .exrow.stuck { background: var(--td-stuck-bg); color: var(--td-stuck-fg); font-weight: 600; }
.td-ubody .exrow.stuck .ex-mark { color: var(--td-stuck-fg); }
.exrow .ex-fails { color: var(--td-stuck-fg); font-size: 11.5px; }
.td-clips { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-faint); }
.td-clip b { font-family: var(--mono); }
.td-clip.ok { color: var(--ink-soft); }
.td-clip.ok b { color: var(--td-ok-dot); }

/* الرمز السري + التنقل + منطقة خطرة */
.td-pin { margin-top: 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); }
.td-pin-cur { margin-top: 6px; font-size: 13.5px; }
.td-pin-val { font-family: var(--mono); font-size: 17px; letter-spacing: 3px; font-variant-ligatures: none; }
.td-pin-tg { padding: 3px 12px; font-size: 12px; }
.td-pin-btns { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.td-pin-btns .tbtn2 { padding: 6px 12px; font-size: 12.5px; }
.td-pin-form { margin-top: 10px; align-items: center; gap: 8px; flex-wrap: wrap; }
.td-pin-form:not([hidden]) { display: flex; }
.td-pin-form input { width: 120px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-family: var(--mono); font-size: 16px; letter-spacing: 3px; text-align: center; font-variant-ligatures: none; }
.td-pin-msg { margin-top: 8px; font-size: 13px; }
.td-pin-big { font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: 5px; margin: 6px 0; font-variant-ligatures: none; }
.td-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.td-nav .tbtn2:disabled { opacity: .45; cursor: default; }
.td-danger { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 10px; }
.td-danger > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); }
.td-danger > summary:focus-visible { outline: 2px solid var(--mustard-deep); outline-offset: 3px; border-radius: 4px; }
.td-danger-body { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.td-danger-body .tbtn2 { padding: 7px 14px; font-size: 13px; }
.tbtn2.tdanger, .tbtn2.ghost.tdanger { color: var(--td-stuck-fg); }
.td-pin-err { color: var(--td-stuck-fg); }

/* تبويب «من يحتاجني اليوم» + الأدوات */
.td-empty { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 26px 8px; margin: 0; }
.td-need { display: flex; flex-direction: column; gap: 6px; }
.td-need-row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-family: inherit; font-size: 14px; color: var(--ink); cursor: pointer; flex-wrap: wrap; }
.td-need-row:hover { background: var(--paper-2); }
.td-need-main { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.td-need-why { font-size: 12.5px; color: var(--ink-soft); }
.td-need-last { font-size: 12px; color: var(--ink-faint); }
.td-toolgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.td-tool { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--paper-2); min-width: 0; }
.td-tool h3 { font-size: 14px; margin: 0 0 8px; }

@media (min-width: 900px) {
  .td-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 18px; align-items: start; }
  .td-pane { margin-top: 0; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; display: block !important; }
}
/* أقل من ٩٠٠: القائمة بطاقات متراصة واللوحة أسفلها */
@media (max-width: 899px) {
  .stu-table thead { display: none; }
  .stu-table, .stu-table tbody { display: block; }
  .stu-table tr.srow { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--paper); cursor: pointer; }
  .stu-table tr.srow td { display: block; border: 0; padding: 0; }
  .stu-table td.td-c-name { flex: 1 0 100%; }
  .stu-table tr.srow.is-sel { border-color: var(--mustard); }
  .stu-table tr.srow:hover td { background: transparent; }
  .stu-table tr.srow.is-sel td { background: transparent; }
  .stu-table tr.srow.is-sel { background: var(--mustard-wash); }
}
@media (max-width: 640px) {
  .td-clscard:not(.td-nocls) { padding: 10px 14px; }
  .td-tools .td-search { flex: 1 0 100%; }
  .td-tab { padding: 10px 11px; font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .td-pbody.td-anim { animation: none; }
  .td-chev, .td-cell, .td-class.is-loading .td-tabpanel { transition: none; }
}
/* h3 العام له خط زخرفي قبله — نلغيه داخل لوحة الطالب وبطاقات الأدوات */
.td-ph h3, .td-tool h3 { display: block; }
.td-ph h3::before, .td-tool h3::before { display: none; }

/* حالة «متوقف»: لم يبدأ أو غائب — محايدة بحدود متصلة (تختلف عن «لم ينضم» المتقطعة) */
.td-st-idle { --st-fg: var(--ink-soft); --st-bg: var(--paper-2); --st-bd: var(--ink-faint); --st-dot: var(--ink-faint); }
/* سطر أسئلة الدرس في لوحة الطالب: محاولة كل سؤال */
.td-qline { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; font-size: 12px; color: var(--ink-faint); }
.td-q b { margin-left: 3px; }
.td-q.ok { color: var(--ink-soft); }
.td-q.ok b { color: var(--td-ok-dot); }
.td-q.late { color: var(--ink-soft); }
.td-q.late b { color: var(--mustard); }
