/* Quantrex practice chrome — clean icon toolbar + footer */
.eg-test-root > .eg-top {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-height: 48px !important;
  padding: 4px 8px 4px 6px !important;
  background: #1565C0 !important;
  color: #fff !important;
}
.eg-test-root .eg-back {
  width: 36px !important;
  height: 36px !important;
  border-radius: 10px !important;
  border: 0 !important;
  background: rgba(255,255,255,.16) !important;
  color: #fff !important;
  font-size: 22px !important;
  line-height: 1 !important;
  cursor: pointer !important;
}
.eg-test-root .eg-top-title {
  flex: 0 1 auto !important;
  min-width: 0 !important;
  max-width: min(42vw, 280px) !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  color: #fff !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.eg-test-root .eg-mode-pill {
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .04em !important;
  background: rgba(255,255,255,.2) !important;
  color: #fff !important;
  border-radius: 999px !important;
  padding: 2px 7px !important;
  margin-left: 6px !important;
}
.eg-test-root .eg-top-tools,
.eg-test-root[data-eg-mode="practice"] .eg-top-tools,
.eg-test-root.eg-qxmd219 .eg-top-tools,
.eg-test-root.eg-qxmd218 .eg-top-tools {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  margin-left: auto !important;
  flex-shrink: 0 !important;
  flex-wrap: wrap !important;
  overflow: visible !important;
  max-width: none !important;
  -webkit-overflow-scrolling: touch !important;
}
.eg-test-root .eg-top-tools .eg-tool-btn,
.eg-test-root .eg-top-tools .eg-ico,
.eg-test-root[data-eg-mode="practice"] .eg-top-tools .eg-tool-btn,
.eg-test-root[data-eg-mode="practice"] .eg-top-tools .eg-tool-hid,
.eg-test-root.eg-qxmd219[data-eg-mode="practice"] .eg-top-tools .eg-tool-btn,
.eg-test-root.eg-qxmd218[data-eg-mode="practice"] .eg-top-tools .eg-tool-btn:not(.eg-settings-gear) {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  border: 0 !important;
  background: rgba(255,255,255,.14) !important;
  color: #ffffff !important;
  fill: #ffffff !important;
  cursor: pointer !important;
  position: relative !important;
  left: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
.eg-test-root .eg-top-tools .eg-tool-btn:hover,
.eg-test-root .eg-top-tools .eg-ico:hover,
.eg-test-root .eg-top-tools .eg-tool-btn.on {
  background: rgba(255,255,255,.28) !important;
}
.eg-test-root .eg-top-tools svg {
  width: 20px !important;
  height: 20px !important;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 1.8 !important;
}
.eg-test-root .eg-top-tools .star.on svg,
.eg-test-root .eg-top-tools .star svg[fill="currentColor"] {
  fill: #fff !important;
  stroke: none !important;
}
.eg-test-root .eg-top-tools .eg-tip {
  display: block !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  background: transparent !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  white-space: nowrap !important;
  z-index: auto !important;
  pointer-events: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}
.eg-test-root .eg-top-tools .eg-tool-btn:hover > .eg-tip {
  display: block !important;
}

.eg-test-root #egFoot,
.eg-test-root .eg-foot-practice {
  background: #ffffff !important;
  border-top: 1px solid #e5e7eb !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot,
.eg-test-root[data-test-theme="dark"] .eg-foot-practice,
.eg-test-root[data-test-theme="dark"] .eg-foot {
  background: #0f172a !important;
  border-top-color: #334155 !important;
}

/* LIGHT — ink on white */
.eg-test-root[data-test-theme="light"] .eg-body,
.eg-test-root[data-test-theme="light"] .eg-main,
.eg-test-root[data-test-theme="light"] .eg-q-card {
  background: #f8fafc !important;
  color: #0f172a !important;
}
.eg-test-root[data-test-theme="light"] .eg-q-card {
  background: #ffffff !important;
}
.eg-test-root[data-test-theme="light"] #egQArea,
.eg-test-root[data-test-theme="light"] .eg-q-stem,
.eg-test-root[data-test-theme="light"] .mtk-opt-text,
.eg-test-root[data-test-theme="light"] .eg-sol,
.eg-test-root[data-test-theme="light"] .eg-info-strip {
  color: #0f172a !important;
}
.eg-test-root[data-test-theme="light"] .mtk-opt,
.eg-test-root[data-test-theme="light"] .eg-opt {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
.eg-test-root[data-test-theme="light"] #egFoot #qxPrevBtn {
  background: #ffffff !important;
  color: #1565C0 !important;
  border: 2px solid #1565C0 !important;
}
.eg-test-root[data-test-theme="light"] #egFoot #qxNextBtn,
.eg-test-root[data-test-theme="light"] #egFoot #egCheckBtn {
  background: #1565C0 !important;
  color: #ffffff !important;
}

/* DARK — light ink on slate */
.eg-test-root[data-test-theme="dark"] .eg-body,
.eg-test-root[data-test-theme="dark"] .eg-main {
  background: #0b1220 !important;
  color: #f1f5f9 !important;
}
.eg-test-root[data-test-theme="dark"] .eg-q-card,
.eg-test-root[data-test-theme="dark"] .eg-sol-panel,
.eg-test-root[data-test-theme="dark"] .eg-sol {
  background: #111827 !important;
  color: #f1f5f9 !important;
}
.eg-test-root[data-test-theme="dark"] #egQArea,
.eg-test-root[data-test-theme="dark"] .eg-q-stem,
.eg-test-root[data-test-theme="dark"] .mtk-opt-text,
.eg-test-root[data-test-theme="dark"] .eg-info-strip,
.eg-test-root[data-test-theme="dark"] .eg-type,
.eg-test-root[data-test-theme="dark"] .eg-paper-line {
  color: #f1f5f9 !important;
}
.eg-test-root[data-test-theme="dark"] .mtk-opt,
.eg-test-root[data-test-theme="dark"] .eg-opt {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}
.eg-test-root[data-test-theme="dark"] .mtk-opt.correct,
.eg-test-root[data-test-theme="dark"] .mtk-opt.eg-opt-right {
  background: #14532d !important;
  color: #dcfce7 !important;
}
.eg-test-root[data-test-theme="dark"] .mtk-opt.wrong,
.eg-test-root[data-test-theme="dark"] .mtk-opt.eg-opt-wrong {
  background: #7f1d1d !important;
  color: #fecaca !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot #qxPrevBtn {
  background: #1e293b !important;
  color: #93c5fd !important;
  border: 2px solid #3b82f6 !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot #qxNextBtn,
.eg-test-root[data-test-theme="dark"] #egFoot #egCheckBtn {
  background: #2563eb !important;
  color: #ffffff !important;
  border: 2px solid #2563eb !important;
}
.eg-test-root .mtk-opt-letter,
.eg-test-root .eg-opt-letter {
  background: #1565C0 !important;
  color: #ffffff !important;
}
#qxRfcPrev, #qxRfcNext, #qxRfcZoomOut, #qxRfcZoomIn, #qxRfcClose,
#qxFcPrev, #qxFcNext, #qxFcClose {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  min-height: 44px !important;
  z-index: 2147483001 !important;
}

.eg-test-root #egFoot,
.eg-test-root .eg-foot,
.eg-test-root .eg-foot-practice,
.eg-test-root .eg-foot-marks {
  display: grid !important;
  grid-template-columns: 1fr 1.2fr 1fr !important;
  align-items: center !important;
  gap: 8px !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 2147483646 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
  min-height: 56px !important;
  padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  background: #ffffff !important;
  border-top: 1px solid #e5e7eb !important;
  box-shadow: 0 -8px 24px rgba(15,23,42,.12) !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot,
.eg-test-root[data-test-theme="dark"] .eg-foot {
  background: #0f172a !important;
  border-top-color: #334155 !important;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4) !important;
}
.eg-test-root #egFoot #qxPrevBtn,
.eg-test-root #egFoot #qxNextBtn,
.eg-test-root #egFoot #egCheckBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 48px !important;
  height: 48px !important;
  border-radius: 999px !important;
  font-weight: 800 !important;
  font-size: 14px !important;
}
.eg-test-root[data-test-theme="light"] #egFoot #qxPrevBtn,
.eg-test-root:not([data-test-theme="dark"]) #egFoot #qxPrevBtn {
  background: #ffffff !important;
  color: #1565C0 !important;
  border: 2px solid #1565C0 !important;
}
.eg-test-root[data-test-theme="light"] #egFoot #qxNextBtn,
.eg-test-root[data-test-theme="light"] #egFoot #egCheckBtn,
.eg-test-root:not([data-test-theme="dark"]) #egFoot #qxNextBtn,
.eg-test-root:not([data-test-theme="dark"]) #egFoot #egCheckBtn {
  background: #1565C0 !important;
  color: #ffffff !important;
  border: 2px solid #1565C0 !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot #qxPrevBtn {
  background: #1e293b !important;
  color: #93c5fd !important;
  border: 2px solid #3b82f6 !important;
}
.eg-test-root[data-test-theme="dark"] #egFoot #qxNextBtn,
.eg-test-root[data-test-theme="dark"] #egFoot #egCheckBtn {
  background: #2563eb !important;
  color: #ffffff !important;
  border: 2px solid #2563eb !important;
}
.eg-test-root .eg-main,
.eg-test-root .eg-q-card,
.eg-test-root #app-main,
#app-main.eg-test-root,
.eg-test-root.eg-body {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Settings sheet — light + dark */
.eg-fmt-scrim {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(15,23,42,.45) !important;
  z-index: 2147483600 !important;
}
.eg-fmt-pop.eg-vs-marks {
  position: fixed !important;
  left: 50% !important;
  top: 56px !important;
  transform: translateX(-50%) !important;
  width: min(420px, 94vw) !important;
  max-height: min(78vh, 640px) !important;
  overflow: auto !important;
  z-index: 2147483601 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 48px rgba(15,23,42,.28) !important;
  padding: 14px 16px 18px !important;
}
.eg-test-root[data-test-theme="dark"] .eg-fmt-pop.eg-vs-marks,
html[data-theme="dark"] .eg-fmt-pop.eg-vs-marks {
  background: #111827 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}
.eg-vs-sec {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: inherit !important;
}
.eg-test-root[data-test-theme="dark"] .eg-vs-sec,
html[data-theme="dark"] .eg-vs-sec {
  background: #0b1220 !important;
  border-color: #1e293b !important;
}
.eg-vs-lab-t { color: inherit !important; }
.eg-vs-hint { color: #64748b !important; }
.eg-test-root[data-test-theme="dark"] .eg-vs-hint { color: #94a3b8 !important; }

/* Solution card — exams + digital books, both themes */
.eg-sol-panel {
  display: block !important;
  margin: 14px 0 88px !important;
  border-radius: 14px !important;
  overflow: visible !important;
  border: 1px solid #cbd5e1 !important;
}
.eg-test-root .eg-subs:has(.eg-sub:only-child) {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}
.eg-test-root #egSol,
.eg-test-root .eg-sol-inline,
.eg-test-root .qx-sol-flow {
  min-height: 48px !important;
  overflow: visible !important;
  display: block !important;
  visibility: visible !important;
}
.qx-tex-fallback,
.qx-tex-code.qx-tex-fallback {
  font-family: inherit !important;
  font-size: inherit !important;
  background: transparent !important;
  color: inherit !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  padding: 0 !important;
}
.eg-sol-panel-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: #1565C0 !important;
  color: #ffffff !important;
  padding: 10px 14px !important;
  font-weight: 800 !important;
}
.eg-sol-panel-close { color: #fff !important; background: transparent !important; border: 0 !important; font-size: 18px !important; }
.eg-test-root[data-test-theme="light"] .eg-sol,
.eg-test-root[data-test-theme="light"] .qx-sol-card,
.eg-test-root[data-test-theme="light"] .sol-body,
.eg-test-root[data-test-theme="light"] .qx-sol-flow {
  background: #ffffff !important;
  color: #0f172a !important;
  letter-spacing: normal !important;
  line-height: 1.65 !important;
  font-size: 16px !important;
}
.eg-test-root[data-test-theme="dark"] .eg-sol,
.eg-test-root[data-test-theme="dark"] .qx-sol-card,
.eg-test-root[data-test-theme="dark"] .sol-body,
.eg-test-root[data-test-theme="dark"] .qx-sol-flow,
.eg-test-root[data-test-theme="dark"] .eg-sol-panel {
  background: #111827 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
  letter-spacing: normal !important;
  line-height: 1.65 !important;
  font-size: 16px !important;
}
.eg-sol img, .qx-sol-flow img, #egSol img, .sol-body img {
  display: block !important;
  visibility: visible !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 10px auto !important;
  background: #fff !important;
}
.katex-error { display: none !important; }

/* Solution after Check Answer — always in-flow under options */
.eg-test-root.eg-qxmd182 .eg-q-card,
.eg-test-root.qx-sol-showing .eg-q-card {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
}
.eg-test-root #egSolPanel,
.eg-test-root.qx-sol-showing #egSolPanel,
.eg-test-root .eg-sol-panel {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  margin: 18px 0 28px !important;
  scroll-margin-top: 12px;
  scroll-margin-bottom: 96px;
}

@media (max-width: 900px) {
  .eg-test-root #egFoot,
  .eg-test-root .eg-foot-practice,
  .eg-test-root .eg-foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: 64px !important;
    display: grid !important;
    grid-template-columns: 1fr 1.2fr 1fr !important;
  }
  .eg-test-root #egFoot #qxPrevBtn,
  .eg-test-root #egFoot #qxNextBtn,
  .eg-test-root #egFoot #egCheckBtn {
    display: inline-flex !important;
    visibility: visible !important;
    min-height: 48px !important;
  }
}

/* Digital book covers — always paint (Medical + Engineering) */
.qx-book-card,
.book-card,
.qx-book-photo,
.qx-book-photo-frame,
.qx-book-cover {
  content-visibility: visible !important;
  contain: none !important;
  overflow: visible;
}
.qx-book-photo {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  aspect-ratio: 3 / 4;
  min-height: 200px !important;
  width: 100% !important;
  transform: none !important;
  perspective: none !important;
}
.qx-book-photo-frame {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 200px !important;
  transform: none !important;
  overflow: hidden !important;
  border-radius: 10px !important;
}
.qx-book-photo-img {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  content-visibility: visible !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 200px !important;
  object-fit: cover !important;
  object-position: center top !important;
}
.qx-book-cover-empty {
  min-height: 200px;
  background: linear-gradient(145deg, #1e3a8a, #3b82f6);
}
.books-grid .qx-book-card,
.books-scroll .qx-book-card {
  overflow: visible !important;
}

/* Question + solution figures always paint, Storage-first */
.mtk-q-text img,
.eg-q img,
#egQArea img,
#egSol img,
.eg-sol img,
#egSolPanel img,
.qx-sol-flow img,
.sol-body img,
.qx-prac-q img,
.qx-prac-opt img,
.mtk-opt-text img,
img.qx-pool-fig,
img.qx-sol-fig,
img.qx-no-wm {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  content-visibility: visible !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 32px;
  object-fit: contain !important;
  background: #fff !important;
}

/* qxmd237: beat .eg-qxmd217 :not(#egFmtBtn) hide (ID specificity) */
html body .eg-test-root .eg-top-tools .eg-tool-btn:not(#egFmtBtn),
html body .eg-test-root.eg-qxmd217 .eg-top-tools .eg-tool-btn:not(#egFmtBtn),
html body .eg-test-root .eg-top-tools #mtkThemeBtn,
html body .eg-test-root .eg-top-tools #egAllQBtn,
html body .eg-test-root .eg-top-tools #egMenuBtn,
html body .eg-test-root .eg-top-tools #egStarBtn,
html body .eg-test-root .eg-top-tools #egPlusBtn,
html body .eg-test-root .eg-top-tools #egFullBtn,
html body .eg-test-root .eg-top-tools #mtkReportBtn,
html body .eg-test-root .eg-top-tools #egFmtBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  width: auto !important;
  height: auto !important;
  min-width: 36px !important;
  min-height: 40px !important;
  flex-direction: column !important;
  color: #ffffff !important;
}

/* qxmd238: solid Prev|Check|Next + full toolbar (last file wins) */
html body .eg-test-root #egFoot,
html body .eg-test-root .eg-foot,
html body .eg-test-root .eg-foot.eg-foot-marks,
html body .eg-test-root .eg-foot.eg-foot-practice,
html body .eg-test-root.eg-qxtool8 #egFoot,
html body .eg-test-root.eg-qxtool8 .eg-foot,
html body .eg-test-root.eg-qxtool8[data-test-theme="light"] .eg-foot,
html body .eg-test-root.eg-qxtool8[data-test-theme="dark"] .eg-foot,
html body .eg-test-root.eg-qxtool8[data-test-theme="dark"] #egFoot.eg-foot.eg-foot-marks,
html body .allen-practice #egFoot,
html body .allen-practice .eg-foot,
html body #egFoot.eg-foot.eg-foot-marks {
  display: grid !important;
  grid-template-columns: 1fr 1.2fr 1fr !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  min-height: 56px !important;
  height: auto !important;
  max-height: none !important;
  z-index: 2147483646 !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  border-top: 1px solid #e5e7eb !important;
  box-shadow: 0 -8px 24px rgba(15,23,42,.12) !important;
}
html body .eg-test-root[data-test-theme="dark"] #egFoot,
html body .eg-test-root[data-test-theme="dark"] .eg-foot,
html body .eg-test-root.eg-qxtool8[data-test-theme="dark"] #egFoot,
html body .eg-test-root.eg-qxtool8[data-test-theme="dark"] .eg-foot,
html body .eg-test-root.eg-qxtool8[data-test-theme="dark"] #egFoot.eg-foot.eg-foot-marks,
html body .allen-practice[data-test-theme="dark"] #egFoot,
html[data-theme="dark"] body .eg-test-root[data-test-theme="dark"] #egFoot {
  background: #0f172a !important;
  background-color: #0f172a !important;
  border-top: 1px solid #334155 !important;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4) !important;
}
html body .eg-test-root #egFoot #qxPrevBtn,
html body .eg-test-root #egFoot #qxNextBtn,
html body .eg-test-root #egFoot #egCheckBtn,
html body #egFoot #qxPrevBtn,
html body #egFoot #qxNextBtn,
html body #egFoot #egCheckBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  min-height: 48px !important;
  height: 48px !important;
}
html body .eg-test-root .eg-top,
html body .eg-test-root.eg-qxtool8 .eg-top,
html body .eg-test-root.eg-qxmd182 .eg-top {
  max-height: none !important;
  overflow: visible !important;
  flex-wrap: wrap !important;
}
html body .eg-test-root .eg-top-tools,
html body .eg-test-root.eg-qxmd167 .eg-top-tools {
  display: flex !important;
  flex-wrap: wrap !important;
  overflow: visible !important;
  max-width: none !important;
}
html body .eg-test-root .eg-top-tools .eg-tool-btn,
html body .eg-test-root[data-eg-mode="practice"] .eg-top-tools .eg-tool-btn,
html body .eg-test-root.eg-qxmd167[data-eg-mode="practice"] .eg-top-tools .eg-tool-sec,
html body .eg-test-root.eg-qxmd167[data-eg-mode="practice"] .eg-top-tools .eg-tool-sec:not(.eg-tool-reach) {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
