/* ============================================================
   Science Lab — أنماط محرر المقالات ولوحة مفاتيح الرياضيات (v5)
   يُحمَّل في الواجهة ولوحة التحكم معًا
   ============================================================ */

:root {
  --me-red: #CC1212;
  --me-bg: #ffffff;
  --me-bg2: #f8fafc;
  --me-border: #e5e7eb;
  --me-border2: #d1d5db;
  --me-text: #111827;
  --me-muted: #6b7280;
  --me-radius: 14px;
  --me-gap: 12px;
}

/* ══════════════ الهيكل ══════════════ */

.me-editor {
  position: relative;
  border: 1.5px solid var(--me-border);
  border-radius: var(--me-radius);
  background: var(--me-bg);
  overflow: visible;
}

/* ══════════════ شريط الأدوات ══════════════ */

.me-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--me-bg2);
  border-bottom: 1px solid var(--me-border);
  border-radius: var(--me-radius) var(--me-radius) 0 0;
  overflow: visible;
}

.me-tb-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--me-border);
  border-radius: 10px;
  flex-shrink: 0;
  position: relative;
}

.me-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--me-text);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  line-height: 1;
}
.me-btn:hover { background: #f1f5f9; }
.me-btn.active { background: rgba(204, 18, 18, .1); color: var(--me-red); }
.me-btn svg { width: 17px; height: 17px; }
.me-btn-label { font-size: .8rem; }
.me-btn { white-space: nowrap; }

.me-btn-math {
  background: rgba(204, 18, 18, .08);
  color: var(--me-red);
  font-weight: 800;
  font-size: 1rem;
}
.me-btn-math:hover { background: rgba(204, 18, 18, .16); }

.me-select {
  height: 34px;
  min-width: 108px;
  padding: 0 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--me-text);
  cursor: pointer;
  outline: none;
}
.me-select:focus { background: #f1f5f9; }

/* منتقي الألوان */
.me-color-dot {
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--me-border2);
}
.me-color-pop {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 60;
  display: none;
  width: 226px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--me-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
}
.me-color-pop.open { display: block; }
.me-color-title { font-size: .78rem; font-weight: 800; color: var(--me-muted); margin-bottom: 8px; }
.me-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.me-color-sw {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 7px;
  cursor: pointer;
  padding: 0;
  transition: transform .12s;
}
.me-color-sw:hover { transform: scale(1.15); }
.me-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--me-border);
}
.me-color-wheel-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--me-text);
  cursor: pointer;
}
.me-color-wheel {
  width: 34px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--me-border2);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.me-color-clear {
  border: 1px solid var(--me-border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: .76rem;
  font-weight: 700;
  color: var(--me-muted);
  cursor: pointer;
}
.me-color-clear:hover { color: var(--me-red); border-color: #fecaca; }

/* ══════════════ جسم المحرر ══════════════ */

.me-editor .me-body {
  min-height: 260px;
  padding: 18px 20px;
  outline: none;
  font-size: 1rem;
  line-height: 2;
  color: var(--me-text);
  background: #fff;
  border-radius: 0 0 var(--me-radius) var(--me-radius);
  overflow-wrap: break-word;
}
.me-editor .me-body:focus { box-shadow: inset 0 0 0 2px rgba(204, 18, 18, .1); }
.me-editor .me-body:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}
.me-editor .me-body > *:first-child { margin-top: 0; }
.me-editor .me-body p { margin: 0 0 12px; }
.me-editor .me-body h2 { font-size: 1.35rem; font-weight: 800; margin: 20px 0 10px; }
.me-editor .me-body h3 { font-size: 1.15rem; font-weight: 700; margin: 16px 0 8px; }
.me-editor .me-body h4 { font-size: 1.02rem; font-weight: 700; margin: 14px 0 6px; }
.me-editor .me-body ul, .me-editor .me-body ol { margin: 10px 0; padding-inline-start: 26px; }
.me-editor .me-body li { margin: 4px 0; }
.me-editor .me-body blockquote {
  border-inline-start: 4px solid var(--me-red);
  background: rgba(204, 18, 18, .05);
  padding: 12px 16px;
  margin: 14px 0;
  border-radius: 0 10px 10px 0;
}
.me-editor .me-body a { color: var(--me-red); text-decoration: underline; }
.me-editor .me-body code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: .88rem; }
.me-editor .me-body hr { border: none; border-top: 2px solid var(--me-border); margin: 18px 0; }
.me-editor .me-error, .me-editor .me-body.me-error { box-shadow: inset 0 0 0 2px #f87171 !important; animation: meShake .3s; }
@keyframes meShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ══════════════ الصيغ الرياضية داخل المقال ══════════════ */

.me-editor .me-formula {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 2px;
  border: 1px dashed transparent;
  border-radius: 7px;
  background: rgba(204, 18, 18, .05);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  vertical-align: middle;
  direction: ltr;
}
.me-editor .me-formula:hover { background: rgba(204, 18, 18, .12); border-color: rgba(204, 18, 18, .4); }
.me-editor .me-formula-block { display: block; text-align: center; margin: 14px 0; padding: 10px; }
.me-raw { font-family: monospace; font-size: .82rem; color: #dc2626; background: #fef2f2; padding: 2px 5px; border-radius: 4px; }

/* الحقل الرياضي الحيّ (أثناء الكتابة) */
.me-editor .me-mf-host {
  display: inline-block;
  vertical-align: middle;
  margin: 0 3px;
  padding: 3px 6px;
  min-width: 90px;
  border: 2px solid var(--me-red);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(204, 18, 18, .12);
  direction: ltr;
}
.me-editor .me-mf-host.me-mf-block { display: block; text-align: center; margin: 14px 0; padding: 10px; }
.me-mf-host math-field,
.me-mf-host .me-mf {
  display: inline-block;
  min-width: 80px;
  border: none;
  outline: none;
  font-size: 1.08rem;
  background: transparent;
  --caret-color: #CC1212;
  --selection-background-color: rgba(204, 18, 18, .18);
  --primary: #CC1212;
}
.me-mf-host math-field::part(virtual-keyboard-toggle),
.me-mf-host math-field::part(menu-toggle) { display: none; }
.me-mf-fallback {
  border: none;
  outline: none;
  font-family: monospace;
  font-size: .95rem;
  min-width: 180px;
  direction: ltr;
}

/* لوحة MathLive الافتراضية — نلغيها لأننا نستخدم لوحتنا */
body > .ML__keyboard { display: none !important; }

/* ══════════════ الصور داخل المحرر ══════════════ */

.me-editor .me-img-wrap { position: relative; display: inline-block; margin: 8px 4px; vertical-align: middle; max-width: 100%; }
.me-editor .me-img-inner { display: block; border-radius: 10px; overflow: hidden; line-height: 0; }
.me-editor .me-img-inner img { max-width: 100%; height: auto; display: block; border-radius: 10px; cursor: nwse-resize; }
.me-editor .me-img-del {
  position: absolute;
  top: -8px;
  inset-inline-end: -8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--me-red);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.me-editor .me-img-wrap:hover .me-img-del { opacity: 1; }

/* ══════════════ المعاينة ══════════════ */

.me-editor .me-preview {
  border-top: 2px dashed var(--me-border);
  padding: 18px 20px;
  background: #fcfcfd;
  font-size: 1rem;
  line-height: 2;
  border-radius: 0 0 var(--me-radius) var(--me-radius);
}
.me-editor .me-preview[hidden] { display: none; }
.me-editor .me-preview img { max-width: 100%; height: auto; border-radius: 10px; }
.me-editor .me-preview .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ══════════════ لوحة مفاتيح الرياضيات ══════════════ */

.me-kb {
  display: none;
  border-top: 2px solid var(--me-red);
  background: #f9fafb;
  border-radius: 0 0 var(--me-radius) var(--me-radius);
  overflow: hidden;
}
.me-kb.open { display: block; animation: meKbIn .18s ease; }
@keyframes meKbIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.me-kb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid var(--me-border);
}
.me-kb-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.me-kb-tabs::-webkit-scrollbar { display: none; }
.me-kb-tab {
  flex-shrink: 0;
  min-width: 46px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--me-border);
  background: #fff;
  border-radius: 9px;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 700;
  color: var(--me-muted);
  cursor: pointer;
  transition: all .15s;
}
.me-kb-tab:hover { border-color: var(--me-border2); color: var(--me-text); }
.me-kb-tab.active { background: var(--me-red); border-color: var(--me-red); color: #fff; }

.me-kb-done {
  flex-shrink: 0;
  height: 34px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: #059669;
  color: #fff;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
}
.me-kb-done:hover { background: #047857; }

.me-kb-panes { padding: 10px; max-height: 250px; overflow-y: auto; }
.me-kb-pane { display: none; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.me-kb-pane.active { display: grid; }
.me-kb-pane-abc.active { grid-template-columns: repeat(7, minmax(0, 1fr)); }

.me-kb-key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 2px;
  border: 1px solid var(--me-border);
  border-radius: 10px;
  background: #fff;
  color: var(--me-text);
  font-family: inherit;
  font-size: .95rem;
  cursor: pointer;
  overflow: hidden;
  transition: all .12s;
  direction: ltr;
}
.me-kb-key:hover { background: rgba(204, 18, 18, .07); border-color: var(--me-red); }
.me-kb-key:active { transform: scale(.94); background: rgba(204, 18, 18, .16); }
.me-kb-key .katex { font-size: .95em; }
.me-kb-key .katex-display { margin: 0; }

.me-kb-nav {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border-top: 1px solid var(--me-border);
}
.me-kb-navbtn {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--me-border);
  border-radius: 9px;
  background: #f8fafc;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  color: var(--me-text);
  cursor: pointer;
}
.me-kb-navbtn:hover { background: #f1f5f9; border-color: var(--me-border2); }
.me-kb-navbtn:active { transform: scale(.95); }
.me-kb-mode { flex: 1.5; font-size: .82rem; color: var(--me-red); font-weight: 800; }

/* تلميح تحت المحرر */
.me-hint {
  font-size: .8rem;
  color: var(--me-muted);
  margin: 8px 2px 0;
  line-height: 1.8;
}

/* ══════════════ الهاتف ══════════════ */

@media (max-width: 820px) {
  .me-toolbar { padding: 7px 8px; gap: 6px; }
  .me-tb-group { gap: 2px; padding: 2px; }
  .me-btn { min-width: 38px; height: 38px; padding: 0 7px; }
  .me-btn-label { display: none; }
  .me-btn-math .me-btn-label { display: inline; }
  .me-select { min-width: 96px; height: 38px; font-size: .82rem; }
  .me-editor .me-body { min-height: 220px; padding: 14px; font-size: .98rem; }
  .me-editor .me-preview { padding: 14px; }

  /* لوحة المفاتيح تصبح لوحًا سفليًا ثابتًا مثل لوحة مفاتيح الهاتف.
     تُنقل إلى <body> من جافاسكربت حتى لا يقصّها أي عنصر (مشكلة iOS). */
  .me-kb.open {
    position: fixed;
    /* left/right أولًا لدعم iOS الأقدم الذي لا يعرف inset-inline */
    left: 0;
    right: 0;
    inset-inline: 0;
    bottom: 0;
    width: 100%;
    z-index: 2147483000;            /* أعلى من الشريط الجانبي والطبقات الأخرى */
    border-radius: 16px 16px 0 0;
    border-top: 3px solid var(--me-red);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, .18);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-bottom: constant(safe-area-inset-bottom, 0);  /* iOS 11 */
    -webkit-transform: translateZ(0);   /* يثبّت الطبقة في Safari */
    transform: translateZ(0);
  }
  .me-kb.open {
    max-height: 52vh;
    max-height: 52dvh;              /* يتجاوز شريط Safari المتحرك */
    display: flex;
    flex-direction: column;
  }
  .me-kb-panes {
    max-height: 32vh;
    max-height: 32dvh;
    flex: 1 1 auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .me-kb-pane { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .me-kb-pane-abc.active { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .me-kb-key { min-height: 46px; font-size: 1rem; }
  .me-kb-tab { min-width: 44px; height: 36px; padding: 0 10px; }
  .me-kb-done { height: 36px; padding: 0 14px; }
  .me-kb-navbtn { min-height: 44px; }
  .me-color-pop { width: min(260px, 78vw); }
}

@media (max-width: 400px) {
  .me-kb-pane { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .me-kb-pane-abc.active { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ══════════════ عرض الصيغ في صفحات الموقع ══════════════ */

.article-content .math-inline,
.ch-question-box .math-inline,
.ch-solution-body .math-inline {
  display: inline-block;
  vertical-align: middle;
  direction: ltr;
  margin: 0 2px;
}
.article-content .math-block,
.ch-question-box .math-block,
.ch-solution-body .math-block {
  display: block;
  text-align: center;
  margin: 16px 0;
  overflow-x: auto;
  overflow-y: hidden;
  direction: ltr;
}
.article-content .katex-display,
.ch-question-box .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ══════════════ زر «المزيد» وشريط الأدوات على الهاتف ══════════════ */

.me-more { display: none; }
.me-kb-key.pressed,
.me-kb-navbtn.pressed { background: rgba(204, 18, 18, .18); border-color: var(--me-red); transform: scale(.94); }

@media (max-width: 820px) {
  /* ── الشريط على الهاتف: شبكة ثابتة الأعمدة فلا تتزاحم الأزرار أبدًا ── */
  .me-toolbar {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    align-items: stretch;
    overflow: visible;
  }
  /* إلغاء صناديق المجموعات وجعل الأزرار عناصر مباشرة في الشبكة */
  .me-toolbar .me-tb-group { display: contents; }
  .me-toolbar .me-btn { width: 100%; height: 42px; min-width: 0; padding: 0 4px; }
  .me-toolbar .me-select {
    grid-column: span 2;
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 8px;
    border: 1px solid var(--me-border);
    background: #fff;
    border-radius: 10px;
  }
  /* الأزرار داخل الشبكة تأخذ خلفية بيضاء بدل صندوق المجموعة */
  .me-toolbar .me-btn {
    background: #fff;
    border: 1px solid var(--me-border);
    border-radius: 10px;
  }
  .me-toolbar .me-btn.active { background: rgba(204, 18, 18, .1); border-color: var(--me-red); }
  .me-toolbar .me-btn-math { background: rgba(204, 18, 18, .08); border-color: rgba(204, 18, 18, .25); }

  .me-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    order: 99;
    grid-column: 1 / -1;
    height: 40px;
    border: 1px dashed var(--me-border2);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 800;
    color: var(--me-muted);
    cursor: pointer;
  }
  .me-more:active { background: #f1f5f9; }
  .me-more-close { display: none; }
  .me-toolbar.expanded .me-more-open { display: none; }
  .me-toolbar.expanded .me-more-close { display: inline; }

  /* مطوي: صف واحد فقط بالأدوات الأساسية + زر المزيد بعرض كامل */
  .me-toolbar:not(.expanded) .me-btn:not(.me-key),
  .me-toolbar:not(.expanded) .me-btn-label { display: none; }
  .me-toolbar:not(.expanded) .me-tb-group:not(.me-tb-primary) { display: none; }

  /* موسّع: كل الأدوات بنفس الشبكة والمسافات */
  .me-toolbar.expanded .me-tb-group { display: contents; }
  .me-toolbar.expanded .me-btn-math { grid-column: span 2; }
  .me-toolbar.expanded .me-btn-math .me-btn-label { display: inline; font-size: .75rem; }
  /* فاصل بصري بين المجموعات في الوضع الموسّع */
  .me-toolbar.expanded .me-tb-group + .me-tb-group::before { content: none; }

  /* منتقي الألوان لا يخرج خارج الشاشة */
  .me-color-pop {
    position: fixed;
    inset-inline: 12px;
    inset-inline-end: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-width: none;
  }
  .me-color-grid { grid-template-columns: repeat(9, 1fr); }
}

/* ══════════════ شريط التنسيق العائم عند تحديد النص ══════════════ */

.me-bubble {
  position: absolute;
  z-index: 120;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: #1f2937;
  border-radius: 12px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .3);
  white-space: nowrap;
  max-width: calc(100% - 12px);
  overflow-x: auto;
  scrollbar-width: none;
  animation: meBubIn .14s ease;
}
.me-bubble::-webkit-scrollbar { display: none; }
.me-bubble.open { display: flex; }
@keyframes meBubIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.me-bubble-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: #f9fafb;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.me-bubble-btn:hover { background: rgba(255, 255, 255, .13); }
.me-bubble-btn:active { background: rgba(255, 255, 255, .24); }
.me-bubble-btn.active { background: var(--me-red); }
.me-bubble-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .2); margin: 0 3px; flex-shrink: 0; }
.me-bub-swatch {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #CC1212;
  border: 1.5px solid #fff;
}

.me-bubble-colors {
  position: absolute;
  top: calc(100% + 7px);
  inset-inline-start: 0;
  display: none;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  padding: 8px;
  background: #1f2937;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .3);
  width: max-content;
  max-width: 88vw;
}
.me-bubble-colors.open { display: grid; }
.me-bubble-color {
  width: 24px; height: 24px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}
.me-bubble-color:active { transform: scale(.9); }

@media (max-width: 820px) {
  .me-bubble { padding: 6px; gap: 3px; border-radius: 14px; }
  .me-bubble-btn { min-width: 40px; height: 40px; font-size: .92rem; }
  .me-bubble-color { width: 28px; height: 28px; }
}

/* منع تجاوز نص الأزرار لحدود خليتها في الشبكة */
@media (max-width: 820px) {
  .me-toolbar .me-btn { overflow: hidden; text-overflow: ellipsis; }
  .me-toolbar.expanded .me-btn-math .me-btn-label { font-size: .72rem; }
}

/* ============================================================
   إصلاحات خاصة بـ iPhone / Safari
   ============================================================ */

/* اللوحة عند نقلها إلى <body> — تبقى ثابتة أسفل الشاشة دائمًا */
.me-kb.me-kb-floating.open {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 2147483000;
}

/* منع تأخير 300ms وتكبير الصفحة بالنقر المزدوج على المفاتيح */
.me-kb-key,
.me-kb-navbtn,
.me-kb-tab,
.me-kb-done,
.me-btn,
.me-more,
.me-bubble-btn,
.me-bubble-color {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Safari يتجاهل تمرير اللوحة إذا لم يُحدَّد هذا */
.me-kb-panes,
.me-kb-tabs { -webkit-overflow-scrolling: touch; }

/* حين تكون اللوحة مفتوحة على الهاتف نمنع اهتزاز الصفحة تحتها */
body.me-kb-mobile-open { overscroll-behavior: none; }

/* الحقل الرياضي: يمنع iOS من تكبير الصفحة عند التركيز (الخط < 16px يسبّب التكبير) */
.me-mf-host math-field,
.me-mf-host .me-mf,
.me-mf-fallback { font-size: 16px; }

/* شريط التحديد العائم فوق لوحة المفاتيح */
.me-bubble { z-index: 2147483001; }
