/* WEPAL LMS — mathematical expressions. Neutral to the Arabic page direction.
 * MathJax adds assistive MathML alongside SVG for screen readers. A reset in
 * the host theme must never display the assistive copy as a second formula.
 */
.lms-math-surface{overflow-wrap:anywhere;white-space:pre-wrap}
.lms-math-surface mjx-container[jax="SVG"]{direction:ltr!important;unicode-bidi:isolate;display:inline-block;max-width:100%;vertical-align:middle;overflow:visible!important}
.lms-math-surface mjx-container[display="true"]{display:block!important;text-align:center;margin:.65em 0!important;max-width:100%;overflow:visible!important}
.lms-math-surface mjx-container svg{max-width:100%;height:auto;overflow:visible}

/* Keep assistive MathML reachable by screen readers, but not visibly duplicated.
 * Robust against host global CSS resetting position, overflow and whitespace. */
html body .lms-math-surface mjx-container[jax="SVG"] mjx-assistive-mml,
html body mjx-container[jax="SVG"] mjx-assistive-mml{
  position:absolute!important;
  top:0!important;
  left:0!important;
  width:1px!important;
  height:1px!important;
  min-width:0!important;
  min-height:0!important;
  max-width:1px!important;
  max-height:1px!important;
  padding:0!important;
  margin:0!important;
  border:0!important;
  overflow:hidden!important;
  clip:rect(0,0,0,0)!important;
  clip-path:inset(50%)!important;
  white-space:nowrap!important;
  pointer-events:none!important;
  transform:none!important;
}
/* Emergency fallback if MathJax was loaded by another module before ours:
 * assistive MathML is never rendered visually; JS supplies aria-label. */
html body .lms-math-surface mjx-container[jax="SVG"] > mjx-assistive-mml,
html body mjx-container[jax="SVG"] > mjx-assistive-mml{display:none!important}
html body .lms-math-surface mjx-container[jax="SVG"]{
  position:relative;
  direction:ltr!important;
  unicode-bidi:isolate!important;
  text-align:left;
}
.lms-math-field-wrap{width:100%;min-width:0}.lms-math-field-wrap>input,.lms-math-field-wrap>textarea{width:100%;box-sizing:border-box}
.lms-math-toolbar{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin:5px 0}
.lms-math-tool{display:inline-flex;align-items:center;gap:5px;padding:5px 9px;font-size:12px;line-height:1.4;border:1px solid #c9d9e7;background:#f7fbff;color:#155b80;font-weight:800;border-radius:7px;cursor:pointer}
.lms-math-tool:hover{background:#e9f5ff;border-color:#8db9d6}
.lms-math-hint{font-size:11px;color:#64748b;margin:3px 0 7px}
.lms-math-live{display:none;border:1px solid #d1e4f2;border-radius:9px;background:#fff;padding:10px;margin:7px 0;min-height:42px;line-height:1.9;text-align:initial;max-width:100%;overflow-x:auto;white-space:pre-wrap}
.lms-math-live.is-open{display:block}
.lms-math-dialog{position:fixed;inset:0;z-index:199999;background:rgba(14,31,49,.62);display:flex;align-items:center;justify-content:center;padding:12px}
.lms-math-dialog[hidden]{display:none!important}
.lms-math-dialog-box{width:min(610px,100%);max-height:96vh;overflow:auto;display:grid;gap:10px;padding:18px;background:#fff;border-radius:14px;border:1px solid #dbe8f2;box-shadow:0 14px 45px rgba(0,0,0,.22);direction:rtl;color:#183449}
.lms-math-dialog-box h3{margin:0;font-size:18px;font-weight:900}
.lms-math-dialog-box label{font-size:13px;font-weight:800}
.lms-math-dialog-box textarea{width:100%;min-height:100px;font:15px/1.7 Consolas,monospace;direction:ltr;text-align:left;resize:vertical;border:1px solid #bfd2e2;border-radius:8px;padding:10px;background:#fff;color:#132d45}
.lms-math-dialog-box select{max-width:100%;border:1px solid #bfd2e2;border-radius:8px;padding:8px;background:#fff;color:#132d45}
.lms-math-dialog-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:9px}
.lms-math-dialog-actions button{border:1px solid #c6d4df;border-radius:8px;padding:8px 13px;cursor:pointer;background:#fff;font-weight:800;color:#17344d}
.lms-math-dialog-actions button.lms-math-confirm{color:white;background:#146e9c;border-color:#146e9c}
.lms-math-error{color:#a62626;font-size:12px}
@media print{.lms-math-toolbar,.lms-math-dialog,.lms-math-live{display:none!important}.lms-math-surface mjx-container{break-inside:avoid;page-break-inside:avoid}.lms-math-surface mjx-container svg{max-width:100%}}
