.atom-quiz-engine {
  --atom-primary: #4f46e5;
  --atom-accent: #0ea5e9;
  --atom-bg: #f8fafc;
  --atom-card-bg: #ffffff;
  --atom-text: #1e293b;
  --atom-muted: #64748b;
  --atom-border: #e2e8f0;
  --atom-selected-bg: #d4eeec;
  --atom-selected-border: #4c9e9b;
  --atom-selected-text: #163f42;
  --atom-selected-badge-bg: #9ed8d3;
  --atom-answered-bg: var(--atom-selected-bg);
  --atom-answered-border: var(--atom-selected-border);
  --atom-answered-text: var(--atom-selected-text);
  --atom-correct-bg: #177346;
  --atom-correct-border: #0d5934;
  --atom-correct-text: #ffffff;
  --atom-incorrect-bg: #b63843;
  --atom-incorrect-border: #912b34;
  --atom-incorrect-text: #ffffff;
  --atom-unanswered-bg: #fff0ce;
  --atom-unanswered-border: #ba8627;
  --atom-unanswered-text: #694c17;
  --atom-review-correct-bg: var(--atom-correct-bg);
  --atom-review-correct-border: var(--atom-correct-border);
  --atom-review-wrong-bg: var(--atom-incorrect-bg);
  --atom-review-wrong-border: var(--atom-incorrect-border);
  --atom-border-radius: 8px;
  --atom-font-family: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  --atom-question-font-size: 1.35rem;
  color: var(--atom-text);
  direction: rtl;
  font-family: var(--atom-font-family);
  line-height: 1.75;
  max-width: 100%;
}

.atom-quiz-engine [hidden] { display: none !important; }
.atom-quiz-engine { container-type: inline-size; }
.atom-quiz-engine [data-role="timer"], .atom-quiz-engine [data-role="progress-text"] { direction: ltr; unicode-bidi: isolate; }
.atom-quiz-engine button:focus-visible, .atom-quiz-engine select:focus-visible { outline: 3px solid #007f76; outline-offset: 3px; }
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content span { display: inline; width: auto; height: auto; background: none; border-radius: 0; color: inherit; }
.atom-quiz-engine .atom-quiz-image-transparent { background: transparent; }
.atom-quiz-engine .atom-quiz-image-dark-safe { background: #202427; }
.atom-quiz-engine img { filter: none; object-fit: contain; }
.atom-quiz-engine .atom-quiz-dialog { border: 1px solid var(--atom-border); border-radius: 8px; max-width: min(460px, calc(100vw - 32px)); color: var(--atom-text); background: var(--atom-card-bg); }
.atom-quiz-engine .atom-quiz-dialog::backdrop { background: #0008; }
.atom-quiz-engine .atom-quiz-shell { border: 0; border-radius: 0; }
.atom-quiz-engine .atom-quiz-card { width: 100%; min-width: 0; box-shadow: none; }
.atom-quiz-engine .atom-quiz-choice, .atom-quiz-engine .atom-quiz-btn, .atom-quiz-engine .atom-quiz-nav-number { border-radius: 8px; }
.atom-quiz-engine .atom-quiz-nav-number { min-width: 0; font-size: .85rem; }
.atom-quiz-engine .atom-quiz-results { border: 0; box-shadow: none; border-radius: 0; }
.atom-quiz-engine .atom-quiz-content [dir="ltr"], .atom-quiz-engine .atom-quiz-content .ltr { display: inline; direction: ltr; unicode-bidi: isolate; }
.atom-quiz-engine mjx-container:not([display="true"]) { direction: ltr; unicode-bidi: isolate; display: inline-block; max-width: 100%; }

.atom-quiz-engine *,
.atom-quiz-engine *::before,
.atom-quiz-engine *::after {
  box-sizing: border-box;
}

.atom-quiz-shell {
  background: var(--atom-bg);
  border: 1px solid var(--atom-border);
  border-radius: var(--atom-border-radius);
  padding: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.atom-quiz-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.atom-quiz-kicker {
  color: var(--atom-primary);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 2px;
}

.atom-quiz-header h2 {
  color: var(--atom-text);
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 0;
}

.atom-quiz-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.atom-quiz-meta span {
  background: #fff;
  border: 1px solid var(--atom-border);
  border-radius: 999px;
  color: var(--atom-muted);
  display: inline-flex;
  font-weight: 700;
  min-height: 34px;
  padding: 4px 12px;
}

.atom-quiz-progress {
  background: #e9eef8;
  border-radius: 999px;
  height: 8px;
  margin-bottom: 18px;
  overflow: hidden;
}

.atom-quiz-progress span {
  background: linear-gradient(135deg, var(--atom-primary), var(--atom-accent));
  display: block;
  height: 100%;
  transition: width .18s ease;
}

.atom-quiz-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 244px;
}

.atom-quiz-card,
.atom-quiz-results,
.atom-quiz-empty {
  background: var(--atom-card-bg);
  border: 1px solid var(--atom-border);
  border-radius: var(--atom-border-radius);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
  padding: clamp(18px, 3vw, 30px);
}

.atom-quiz-question-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.atom-quiz-topic {
  color: var(--atom-primary);
  font-size: .9rem;
  font-weight: 800;
  margin: 0 0 8px;
}

.atom-quiz-bookmark {
  align-items: center;
  background: #fff;
  border: 1px solid var(--atom-border);
  border-radius: 999px;
  color: #f59e0b;
  display: inline-flex;
  font-size: 1.35rem;
  height: 42px;
  justify-content: center;
  line-height: 1;
  width: 42px;
}

.atom-quiz-question-number {
  color: var(--atom-muted);
  font-weight: 700;
  margin: 0;
}

.atom-quiz-question-text {
  font-size: var(--atom-question-font-size);
  font-weight: 800;
  margin: 0 0 18px;
}

.atom-quiz-content {
  overflow-wrap: anywhere;
}

.atom-quiz-content .ltr,
.atom-quiz-content [dir="ltr"],
.atom-quiz-ltr {
  direction: ltr;
  display: inline-block;
  unicode-bidi: isolate;
}

.atom-quiz-image-wrap {
  background: #fff;
  border: 1px solid var(--atom-border);
  border-radius: 10px;
  margin: 0 0 18px;
  padding: 12px;
  text-align: center;
}

.atom-quiz-image-wrap img {
  display: block;
  margin-inline: auto;
  height: auto;
  max-width: 100%;
}

.atom-quiz-formula {
  background: #f8fafc;
  border: 1px solid var(--atom-border);
  border-radius: 10px;
  margin: 14px 0;
  padding: 12px 14px;
}

.atom-quiz-choices {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.atom-quiz-choice {
  align-items: center;
  background: #fff;
  border: 2px solid var(--atom-border);
  border-radius: 13px;
  color: var(--atom-text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 12px;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  min-height: 58px;
  padding: 12px 14px;
  text-align: right;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  width: 100%;
}

@media (hover: hover) {
  .atom-quiz-choice:hover:not(:disabled):not(.is-selected) {
    border-color: var(--atom-primary);
  }
}

.atom-quiz-choice > .atom-quiz-choice-badge {
  align-items: center;
  background: #eef2ff;
  border-radius: 999px;
  color: var(--atom-primary);
  display: inline-flex;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.atom-quiz-choice b {
  font-weight: 700;
}

.atom-quiz-choice-image {
  background: #fff;
  border: 1px solid var(--atom-border);
  border-radius: 8px;
  display: block;
  height: auto;
  margin-top: 8px;
  max-width: min(100%, 420px);
  padding: 8px;
}

.atom-quiz-choice.is-correct {
  background: var(--atom-correct-bg);
  border-color: var(--atom-correct-border);
  color: var(--atom-correct-text);
}

.atom-quiz-choice.is-incorrect {
  background: var(--atom-incorrect-bg);
  border-color: var(--atom-incorrect-border);
  color: var(--atom-incorrect-text);
}

.atom-quiz-engine .atom-quiz-choice.is-selected {
  background: var(--atom-selected-bg);
  border-color: var(--atom-selected-border);
  color: var(--atom-selected-text);
}

.atom-quiz-choice.is-selected > .atom-quiz-choice-badge {
  background: var(--atom-selected-badge-bg);
  color: var(--atom-selected-text);
}

.atom-quiz-choice.is-correct > .atom-quiz-choice-badge {
  background: var(--atom-correct-border);
  color: var(--atom-correct-text);
}

.atom-quiz-choice.is-incorrect > .atom-quiz-choice-badge {
  background: var(--atom-incorrect-border);
  color: var(--atom-incorrect-text);
}

.atom-quiz-choice:disabled { opacity: 1; cursor: default; }
.atom-quiz-choice-indicator { width: 20px; text-align: center; font-weight: 800; }
.atom-quiz-engine .atom-quiz-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.atom-quiz-engine .atom-quiz-content span.atom-quiz-phase {
  font-size: .68em; font-weight: 700; vertical-align: sub; line-height: 0;
}
.atom-quiz-engine .atom-quiz-content span.atom-quiz-blank {
  display: inline-block; unicode-bidi: isolate; white-space: nowrap; min-inline-size: 3em;
}
.atom-quiz-chemical { unicode-bidi: isolate; }
.atom-quiz-answer-status { font-weight: 700; margin-block: 8px; }
.atom-quiz-answer-status.is-unanswered {
  background: var(--atom-unanswered-bg); color: var(--atom-unanswered-text); padding: 8px;
}

.atom-quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 20px;
}

.atom-quiz-btn {
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 10px 18px;
}

.atom-quiz-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.atom-quiz-btn-primary {
  background: linear-gradient(135deg, var(--atom-primary), var(--atom-accent));
  color: #fff;
}

.atom-quiz-btn-secondary {
  background: #fff;
  border: 1px solid var(--atom-border);
  color: var(--atom-primary);
}

.atom-quiz-navigator {
  position: sticky;
  top: 24px;
}

.atom-quiz-nav-toggle {
  display: none;
}

.atom-quiz-nav-grid {
  background: #fff;
  border: 1px solid var(--atom-border);
  border-radius: var(--atom-border-radius);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, 1fr);
  padding: 14px;
}

.atom-quiz-nav-number {
  aspect-ratio: 1;
  background: #f8fafc;
  border: 1px solid var(--atom-border);
  border-radius: 9px;
  color: var(--atom-text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.atom-quiz-nav-number.is-current {
  background: var(--atom-primary);
  border-color: var(--atom-primary);
  color: #fff;
}

.atom-quiz-nav-number.is-answered:not(.is-current) {
  background: var(--atom-answered-bg);
  border-color: var(--atom-answered-border);
  color: var(--atom-answered-text);
}

.atom-quiz-nav-number.is-bookmarked {
  box-shadow: inset 0 -4px 0 #f59e0b;
}

.atom-quiz-nav-number.is-correct {
  background: var(--atom-correct-bg);
  border-color: var(--atom-correct-border);
  color: var(--atom-correct-text);
}

.atom-quiz-nav-number.is-incorrect {
  background: var(--atom-incorrect-bg);
  border-color: var(--atom-incorrect-border);
  color: var(--atom-incorrect-text);
}

.atom-quiz-engine.is-submitted .atom-quiz-nav-number.is-current {
  outline: 3px solid var(--atom-primary); outline-offset: 2px;
}
.atom-quiz-engine.is-submitted .atom-quiz-nav-number.is-unanswered {
  background: var(--atom-unanswered-bg); border-color: var(--atom-unanswered-border); color: var(--atom-unanswered-text);
}
.atom-quiz-review-item .atom-quiz-choice.is-correct {
  background: var(--atom-review-correct-bg); border-color: var(--atom-review-correct-border);
}
.atom-quiz-review-item .atom-quiz-choice.is-incorrect {
  background: var(--atom-review-wrong-bg); border-color: var(--atom-review-wrong-border);
}
.atom-quiz-review-number { margin-block: 0 12px; font-size: 1.1rem; }
.atom-quiz-review-filter { display: flex; gap: 8px; align-items: center; margin-block: 12px; }

.atom-quiz-results {
  margin-top: 18px;
}

.atom-quiz-result-card h3,
.atom-quiz-review h3 {
  margin-top: 0;
}

.atom-quiz-score {
  color: var(--atom-primary);
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.atom-quiz-result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.atom-quiz-result-grid span {
  background: #f8fafc;
  border: 1px solid var(--atom-border);
  border-radius: 10px;
  padding: 8px 12px;
}

.atom-quiz-review-item {
  border-top: 1px solid var(--atom-border);
  margin-top: 16px;
  padding-top: 16px;
}

.atom-quiz-review-question {
  font-weight: 900;
  margin-bottom: 10px;
}

.atom-quiz-explanation {
  background: #f8fafc;
  border-right: 4px solid var(--atom-primary);
  border-radius: 10px;
  margin-top: 10px;
  padding: 12px;
}

@media (max-width: 820px) {
  .atom-quiz-shell {
    padding: 12px;
  }

  .atom-quiz-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .atom-quiz-layout {
    display: flex;
    flex-direction: column-reverse;
  }

  .atom-quiz-navigator {
    position: static;
    width: 100%;
  }

  .atom-quiz-nav-toggle {
    background: #fff;
    border: 1px solid var(--atom-border);
    border-radius: 10px;
    color: var(--atom-primary);
    display: block;
    font: inherit;
    font-weight: 800;
    padding: 10px 14px;
    width: 100%;
  }

  .atom-quiz-nav-grid {
    display: none;
    grid-template-columns: repeat(8, 1fr);
    margin-top: 8px;
  }

  .atom-nav-open .atom-quiz-nav-grid {
    display: grid;
  }

  .atom-quiz-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .atom-quiz-actions [data-action="submit"] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .atom-quiz-card,
  .atom-quiz-results,
  .atom-quiz-empty {
    padding: 16px;
  }

  .atom-quiz-question-text {
    font-size: 1.12rem;
  }

  .atom-quiz-nav-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@container (max-width: 760px) {
  .atom-quiz-layout { display: flex; flex-direction: column-reverse; }
  .atom-quiz-navigator { position: static; width: 100%; }
  .atom-quiz-nav-toggle { display: block; width: 100%; padding: 10px; background: white; color: var(--atom-primary); border: 1px solid var(--atom-border); border-radius: 8px; font: inherit; }
  .atom-quiz-nav-grid { display: none; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 8px; }
  .atom-nav-open .atom-quiz-nav-grid { display: grid; }
  .atom-quiz-header { flex-wrap: wrap; }
}

/* === ATOM v2.1.1: reusable inline scientific diagrams =====================
 * These styles intentionally use currentColor and no fixed background so
 * imported HTML diagrams adapt to light/dark themes. The HTML sanitizer
 * already permits the required <span class="..." dir="ltr"> markup.
 */

/* Lewis dot structures (e.g. Be, B, N, O). */
.atom-quiz-engine .atom-quiz-content span.atom-lewis {
  direction: ltr;
  display: inline-grid;
  grid-template-columns: .72em auto .72em;
  grid-template-rows: .64em auto .64em;
  align-items: center;
  justify-items: center;
  column-gap: .12em;
  row-gap: .04em;
  line-height: 1;
  min-inline-size: 3.05em;
  margin-inline: .18em;
  unicode-bidi: isolate;
  vertical-align: middle;
}
.atom-quiz-engine .atom-quiz-content .atom-lewis > span {
  color: currentColor;
  background: none;
  border: 0;
  border-radius: 0;
  height: auto;
  width: auto;
  line-height: 1;
  margin: 0;
  padding: 0;
}
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-symbol {
  display: inline-block;
  grid-column: 2;
  grid-row: 2;
  font-family: "Times New Roman", "STIX Two Text", serif;
  font-size: 1.32em;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-dot {
  display: inline-block;
  font-family: Arial, sans-serif;
  font-size: .76em;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
}
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-top    { grid-column: 2; grid-row: 1; align-self: end; }
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-right  { grid-column: 3; grid-row: 2; justify-self: start; transform: translateX(.03em); }
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-bottom { grid-column: 2; grid-row: 3; align-self: start; }
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-left   { grid-column: 1; grid-row: 2; justify-self: end; transform: translateX(-.03em); }

/* Orbital-box diagrams for Aufbau/Hund questions. */
.atom-quiz-engine .atom-quiz-content span.atom-orbitals {
  direction: ltr;
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: .22em;
  line-height: 1;
  margin-inline: .15em;
  unicode-bidi: isolate;
  vertical-align: middle;
}
.atom-quiz-engine .atom-quiz-content .atom-orbitals > .atom-orbital-box {
  align-items: center;
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 0;
  color: currentColor;
  display: inline-flex;
  font-family: "Times New Roman", "STIX Two Text", serif;
  font-size: 1em;
  font-weight: 700;
  height: 1.55em;
  justify-content: center;
  line-height: 1;
  min-width: 1.55em;
  padding: 0 .08em;
  width: 1.55em;
}
.atom-quiz-engine .atom-quiz-content .atom-orbitals > .atom-orbital-group {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1.55em;
  gap: .08em;
  justify-items: center;
  position: relative;
  padding-bottom: 1.05em;
}
.atom-quiz-engine .atom-quiz-content .atom-orbital-group > .atom-orbital-box {
  align-items: center;
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 0;
  color: currentColor;
  display: inline-flex;
  font-family: "Times New Roman", "STIX Two Text", serif;
  font-size: 1em;
  font-weight: 700;
  height: 1.55em;
  justify-content: center;
  line-height: 1;
  min-width: 1.55em;
  padding: 0 .08em;
  width: 1.55em;
}
.atom-quiz-engine .atom-quiz-content .atom-orbital-group > .atom-orbital-label {
  bottom: 0;
  color: currentColor;
  display: block;
  font-family: "Times New Roman", "STIX Two Text", serif;
  font-size: .78em;
  font-weight: 700;
  left: 50%;
  line-height: 1;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Keep inline visual choices compact and centered without image-sized cards. */
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content:has(.atom-lewis),
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content:has(.atom-orbitals) {
  text-align: center;
}
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content .atom-lewis,
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content .atom-orbitals {
  font-size: 1.08em;
}

@media (max-width: 560px) {
  .atom-quiz-engine .atom-quiz-choice .atom-quiz-content .atom-lewis,
  .atom-quiz-engine .atom-quiz-choice .atom-quiz-content .atom-orbitals {
    font-size: 1em;
  }
}


/* === ATOM v2.1.2: Lewis pairs + compact periodic-table columns ========== */

/* A paired Lewis-dot side can be vertical (e.g. oxygen's left pair). */
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-pair-v {
  align-items: center;
  display: inline-flex;
  flex-direction: column;
  gap: .02em;
  justify-content: center;
  letter-spacing: 0;
  line-height: .52;
}
.atom-quiz-engine .atom-quiz-content .atom-lewis > .atom-lewis-pair-v > span {
  background: none;
  border: 0;
  border-radius: 0;
  color: currentColor;
  display: block;
  font: inherit;
  height: auto;
  line-height: .52;
  margin: 0;
  padding: 0;
  width: auto;
}

/* Small table-column diagrams used for periodic-group questions. */
.atom-quiz-engine .atom-quiz-content .atom-periodic-wrap {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: .55em 0 .18em;
  width: 100%;
}
.atom-quiz-engine .atom-quiz-content span.atom-periodic-column {
  border: 1.5px solid currentColor;
  color: currentColor;
  direction: ltr;
  display: inline-grid !important;
  font-family: "Times New Roman", "STIX Two Text", serif;
  font-size: .86em;
  font-weight: 700;
  grid-auto-flow: row;
  grid-template-columns: minmax(2.35em, auto);
  line-height: 1;
  margin: 0;
  min-width: 2.35em;
  unicode-bidi: isolate;
  vertical-align: middle;
}
.atom-quiz-engine .atom-quiz-content .atom-periodic-column > .atom-periodic-cell {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid currentColor;
  border-radius: 0;
  color: currentColor;
  display: flex;
  justify-content: center;
  min-height: 1.72em;
  min-width: 2.35em;
  padding: .12em .25em;
  white-space: nowrap;
}
.atom-quiz-engine .atom-quiz-content .atom-periodic-column > .atom-periodic-cell:last-child {
  border-bottom: 0;
}
.atom-quiz-engine .atom-quiz-content .atom-periodic-cell.atom-periodic-unknown {
  font-family: Arial, sans-serif;
  font-size: 1.05em;
  font-weight: 800;
}

/* Atomic-number + symbol token without an image or SVG. */
.atom-quiz-engine .atom-quiz-content span.atom-element-token {
  align-items: baseline;
  color: currentColor;
  direction: ltr;
  display: inline-flex !important;
  font-family: "Times New Roman", "STIX Two Text", serif;
  gap: .02em;
  line-height: 1;
  unicode-bidi: isolate;
  white-space: nowrap;
}
.atom-quiz-engine .atom-quiz-content .atom-element-token > sub {
  color: currentColor;
  font-size: .52em;
  font-weight: 700;
  line-height: 1;
  margin: 0 -.03em 0 0;
  position: relative;
  top: .27em;
  vertical-align: baseline;
}
.atom-quiz-engine .atom-quiz-content .atom-element-token > .atom-element-symbol {
  color: currentColor;
  font-size: 1em;
  font-weight: 700;
  line-height: 1;
}

@media (max-width: 560px) {
  .atom-quiz-engine .atom-quiz-content span.atom-periodic-column {
    font-size: .8em;
  }
}

/* === ATOM v2.2.0 beta 2: quiz typography ==================================
 * Keep typography scoped to ATOM Quiz Engine only. MathJax retains its own
 * mathematical fonts. The primary Arabic UI font is loaded by the plugin.
 */
.atom-quiz-engine {
  --atom-font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  --atom-question-font-size: clamp(1.08rem, 0.28vw + 1.02rem, 1.20rem);
  font-family: var(--atom-font-family);
  font-weight: 400;
  line-height: 1.7;
}

.atom-quiz-engine .atom-quiz-header h2 {
  font-weight: 600;
}

.atom-quiz-engine .atom-quiz-kicker,
.atom-quiz-engine .atom-quiz-topic,
.atom-quiz-engine .atom-quiz-question-text,
.atom-quiz-engine .atom-quiz-btn,
.atom-quiz-engine .atom-quiz-nav-toggle,
.atom-quiz-engine .atom-quiz-choice > .atom-quiz-choice-badge,
.atom-quiz-engine .atom-quiz-choice-indicator,
.atom-quiz-engine .atom-quiz-answer-status {
  font-weight: 600;
}

.atom-quiz-engine .atom-quiz-meta span,
.atom-quiz-engine .atom-quiz-question-number,
.atom-quiz-engine .atom-quiz-choice b,
.atom-quiz-engine .atom-quiz-explanation,
.atom-quiz-engine .atom-quiz-answer-summary {
  font-weight: 500;
}

.atom-quiz-engine .atom-quiz-question-text {
  font-size: var(--atom-question-font-size);
  line-height: 1.72;
}

.atom-quiz-engine .atom-quiz-choice {
  font-size: clamp(.98rem, .18vw + .94rem, 1.06rem);
  font-weight: 400;
  line-height: 1.65;
}

.atom-quiz-engine .atom-quiz-btn {
  font-size: clamp(.94rem, .12vw + .91rem, 1rem);
}

/* === ATOM v2.2.0 beta 2: QuizMaker-compatible dark image treatment =======
 * Intentionally mirrors the proven QuizMaker rule supplied by the site:
 * light mode stays untouched; in dark system mode every quiz image receives
 * the same inversion + hue rotation. No per-image exceptions are applied.
 */
@media (prefers-color-scheme: dark) {
  .atom-quiz-engine img {
    filter: invert(0.85) hue-rotate(180deg) !important;
  }
}


/* === ATOM v2.2.0 beta 2: keep rendered MathJax from inheriting the
 * semibold question weight. Explicit bold TeX still uses MathJax's own styles. */
.atom-quiz-engine mjx-container {
  font-weight: 400;
}


/* === ATOM v2.2.0 beta 3: compact mobile quiz cards =========================
 * Keep desktop/tablet proportions unchanged. On phones, reduce vertical
 * space used by answer cards while retaining comfortable touch targets.
 */
@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-card,
  .atom-quiz-engine .atom-quiz-results,
  .atom-quiz-engine .atom-quiz-empty {
    padding: 14px;
  }

  .atom-quiz-engine .atom-quiz-question-heading {
    margin-bottom: 4px;
  }

  .atom-quiz-engine .atom-quiz-bookmark {
    font-size: 1.2rem;
    height: 36px;
    width: 36px;
  }

  .atom-quiz-engine .atom-quiz-question-text {
    font-size: 1.06rem;
    line-height: 1.62;
    margin-bottom: 13px;
  }

  .atom-quiz-engine .atom-quiz-image-wrap {
    margin-bottom: 13px;
    padding: 9px;
  }

  .atom-quiz-engine .atom-quiz-choices {
    gap: 8px;
    margin-top: 12px;
  }

  .atom-quiz-engine .atom-quiz-choice {
    font-size: .96rem;
    line-height: 1.55;
    gap: 8px;
    grid-template-columns: 32px minmax(0, 1fr) 16px;
    min-height: 50px;
    padding: 8px 10px;
  }

  .atom-quiz-engine .atom-quiz-choice > .atom-quiz-choice-badge {
    height: 30px;
    width: 30px;
  }

  .atom-quiz-engine .atom-quiz-choice-indicator {
    width: 16px;
  }

  .atom-quiz-engine .atom-quiz-actions {
    gap: 8px;
    margin-top: 14px;
  }

  .atom-quiz-engine .atom-quiz-btn {
    font-size: .94rem;
    min-height: 40px;
    padding: 8px 12px;
  }
}

@media (max-width: 390px) {
  .atom-quiz-engine .atom-quiz-card,
  .atom-quiz-engine .atom-quiz-results,
  .atom-quiz-engine .atom-quiz-empty {
    padding: 12px;
  }

  .atom-quiz-engine .atom-quiz-question-text {
    font-size: 1.02rem;
  }

  .atom-quiz-engine .atom-quiz-choice {
    font-size: .92rem;
    grid-template-columns: 30px minmax(0, 1fr) 14px;
    min-height: 46px;
    padding: 7px 9px;
  }

  .atom-quiz-engine .atom-quiz-choice > .atom-quiz-choice-badge {
    height: 28px;
    width: 28px;
  }
}


/* === ATOM v2.2.0 beta 6: compact question header ===========================
 * Taxonomy is hidden while answering to save vertical space. It is shown only
 * after submission/review. Bookmark stays beside the question number.
 */
.atom-quiz-engine .atom-quiz-review-taxonomy {
  color: var(--atom-primary);
  font-size: .86rem;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 4px;
}


/* === ATOM v2.2.0 beta 7: compact touch navigator ==========================
 * The mobile/tablet question panel is opt-in, so keep it dense when opened.
 * State remains visible through button colors and bookmark underline; compact
 * layouts hide the redundant text glyphs while aria-labels keep full status.
 */
.atom-quiz-engine .atom-quiz-nav-number {
  align-items: center;
  display: inline-flex;
  gap: 2px;
  justify-content: center;
  line-height: 1;
}

.atom-quiz-engine .atom-quiz-nav-marks {
  font-size: .72em;
  letter-spacing: -1px;
}

@media (max-width: 820px) {
  .atom-quiz-engine .atom-quiz-nav-toggle {
    font-size: .94rem;
    min-height: 40px;
    padding: 8px 12px;
  }

  .atom-quiz-engine .atom-quiz-nav-grid {
    gap: 6px;
    grid-template-columns: repeat(auto-fill, 44px);
    justify-content: center;
    max-height: min(40vh, 300px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 9px;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }

  .atom-quiz-engine .atom-quiz-nav-number {
    aspect-ratio: auto;
    font-size: .8rem;
    height: 44px;
    min-height: 44px;
    padding: 0;
    width: 44px;
  }

  .atom-quiz-engine .atom-quiz-nav-marks {
    display: none;
  }
}

@media (max-width: 520px) {
  .atom-quiz-engine .atom-quiz-nav-grid {
    gap: 5px;
    grid-template-columns: repeat(auto-fill, 42px);
    max-height: min(38vh, 260px);
    padding: 8px;
  }

  .atom-quiz-engine .atom-quiz-nav-number {
    height: 42px;
    min-height: 42px;
    width: 42px;
  }
}

/* === ATOM v2.2.0 beta 8: optional per-question hint =======================
 * Hints are intentionally lightweight: they recall a definition/idea without
 * revealing the answer. They are shown only while the attempt is in progress.
 */
.atom-quiz-engine .atom-quiz-hint {
  margin: 4px 0 14px;
}

.atom-quiz-engine .atom-quiz-hint > summary {
  align-items: center;
  background: color-mix(in srgb, var(--atom-primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--atom-primary) 25%, var(--atom-border));
  border-radius: 999px;
  color: var(--atom-primary);
  cursor: pointer;
  display: inline-flex;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.3;
  list-style: none;
  min-height: 36px;
  padding: 7px 13px;
}

.atom-quiz-engine .atom-quiz-hint > summary::-webkit-details-marker {
  display: none;
}

.atom-quiz-engine .atom-quiz-hint > summary::before {
  content: '💡';
  font-size: .95em;
  margin-inline-end: 6px;
}

.atom-quiz-engine .atom-quiz-hint-content {
  background: color-mix(in srgb, var(--atom-primary) 5%, var(--atom-card-bg));
  border-inline-start: 3px solid var(--atom-primary);
  border-radius: 9px;
  font-size: .96rem;
  line-height: 1.7;
  margin-top: 8px;
  padding: 10px 12px;
}

@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-hint {
    margin-bottom: 11px;
  }
  .atom-quiz-engine .atom-quiz-hint > summary {
    font-size: .88rem;
    min-height: 34px;
    padding: 6px 11px;
  }
  .atom-quiz-engine .atom-quiz-hint-content {
    font-size: .92rem;
    padding: 8px 10px;
  }
}


/* === ATOM v2.2.0 beta 9: legacy iOS Safari button-paint compatibility ====
 * iOS 16 WebKit can retain native button painting in ways that suppress the
 * custom selected/answered backgrounds even though the state classes exist.
 * Keep ATOM buttons fully CSS-painted and reinforce only the two live-answer
 * states. This is scoped to the quiz and does not change state logic.
 */
.atom-quiz-engine button.atom-quiz-choice,
.atom-quiz-engine button.atom-quiz-nav-number {
  -webkit-appearance: none;
  appearance: none;
  background-image: none;
}

.atom-quiz-engine button.atom-quiz-choice.is-selected {
  background-color: var(--atom-selected-bg) !important;
  border-color: var(--atom-selected-border) !important;
  color: var(--atom-selected-text) !important;
  -webkit-text-fill-color: var(--atom-selected-text);
}

.atom-quiz-engine button.atom-quiz-choice.is-selected > .atom-quiz-choice-badge {
  background-color: var(--atom-selected-badge-bg) !important;
  color: var(--atom-selected-text) !important;
  -webkit-text-fill-color: var(--atom-selected-text);
}

.atom-quiz-engine button.atom-quiz-nav-number.is-answered:not(.is-current) {
  background-color: var(--atom-answered-bg) !important;
  border-color: var(--atom-answered-border) !important;
  color: var(--atom-answered-text) !important;
  -webkit-text-fill-color: var(--atom-answered-text);
}

/* === ATOM v2.2.0 beta 10: structured organic-formula renderer ============
 * Reusable, theme-native renderer for condensed/branched organic structures.
 * Branch bonds are anchored to the actual atom token rather than to a whole
 * MathJax array cell, so CH3/Cl/OH branches stay attached to the intended C.
 */
.atom-quiz-engine .atom-chem-structure {
  color: inherit;
  direction: ltr;
  display: flex;
  justify-content: center;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  text-align: center;
  unicode-bidi: isolate;
  -webkit-overflow-scrolling: touch;
}

.atom-quiz-engine .atom-chem-structure.is-question {
  font-size: clamp(1.12rem, 2.1vw, 1.45rem);
  margin: -3px 0 16px;
  padding: 1.45em .35em 1.1em;
}

.atom-quiz-engine .atom-chem-structure.is-choice {
  font-size: 1.12em;
  margin: 0 auto;
  padding: 1.35em .25em 1.1em;
  width: 100%;
}

.atom-quiz-engine .atom-chem-structure.is-summary {
  display: inline-flex;
  font-size: 1em;
  margin-inline: .25em;
  overflow: visible;
  padding: 1.15em .2em .9em;
  vertical-align: middle;
  width: auto;
}

.atom-quiz-engine .atom-branched-formula,
.atom-quiz-engine .atom-formula-row,
.atom-quiz-engine .atom-molecular-formula,
.atom-quiz-engine .atom-condensed-formula,
.atom-quiz-engine .atom-bond-pair {
  align-items: baseline;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

.atom-quiz-engine .atom-branched-formula {
  align-items: baseline;
}

.atom-quiz-engine .atom-structure-node {
  align-items: baseline;
  display: inline-flex;
  flex: 0 0 auto;
  position: relative;
}

.atom-quiz-engine .atom-structure-anchor {
  display: inline-block;
  position: relative;
}

.atom-quiz-engine .atom-structure-main-bond {
  align-self: center;
  display: inline-block;
  flex: 0 0 auto;
  line-height: 1;
  margin-inline: .03em;
  min-width: .03em;
  text-align: center;
}

.atom-quiz-engine .atom-structure-main-bond.is-single { min-width: .62em; }
.atom-quiz-engine .atom-structure-main-bond.is-double { min-width: .7em; }
.atom-quiz-engine .atom-structure-main-bond.is-triple { min-width: .78em; }
.atom-quiz-engine .atom-structure-main-bond.is-none { margin-inline: 0; min-width: 0; width: 0; }

.atom-quiz-engine .atom-structure-prefix,
.atom-quiz-engine .atom-structure-suffix,
.atom-quiz-engine .atom-structure-branch-prefix,
.atom-quiz-engine .atom-structure-branch-suffix {
  display: inline;
}

.atom-quiz-engine .atom-chem-structure sub,
.atom-quiz-engine .atom-chem-structure sup {
  font-size: .66em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
.atom-quiz-engine .atom-chem-structure sub { bottom: -.28em; }
.atom-quiz-engine .atom-chem-structure sup { top: -.52em; }

.atom-quiz-engine .atom-structure-branch {
  color: inherit;
  left: 50%;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  width: 0;
  z-index: 1;
}

.atom-quiz-engine .atom-structure-branch.is-up {
  bottom: calc(100% + .08em);
  height: 1.24em;
}

.atom-quiz-engine .atom-structure-branch.is-down {
  height: 1.24em;
  top: calc(100% + .05em);
}

.atom-quiz-engine .atom-structure-branch-bond {
  display: block;
  left: 0;
  position: absolute;
  width: 0;
}

.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond {
  bottom: 0;
  height: .8em;
}

.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond {
  height: .8em;
  top: 0;
}

.atom-quiz-engine .atom-structure-branch.is-single .atom-structure-branch-bond {
  border-left: 1.6px solid currentColor;
}

.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::before,
.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::after {
  background: currentColor;
  content: "";
  height: 100%;
  position: absolute;
  top: 0;
  width: 1.4px;
}
.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::before { left: -2.2px; }
.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::after { left: 2.2px; }

/* The branch label is anchored by its first chemically meaningful atom.
 * That keeps the vertical bond under C in CH3/C2H5, under O in OH, etc. */
.atom-quiz-engine .atom-structure-branch-label {
  display: block;
  left: 0;
  position: absolute;
  width: 0;
}
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: .86em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .87em; }

.atom-quiz-engine .atom-structure-branch-formula {
  display: block;
  position: relative;
  width: 0;
  white-space: nowrap;
}
.atom-quiz-engine .atom-structure-branch-core {
  left: 0;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.atom-quiz-engine .atom-structure-branch-prefix {
  position: absolute;
  right: .34em;
  white-space: nowrap;
}
.atom-quiz-engine .atom-structure-branch-suffix {
  left: .34em;
  position: absolute;
  white-space: nowrap;
}

.atom-quiz-engine .atom-molecular-formula sub,
.atom-quiz-engine .atom-molecular-formula sup {
  font-size: .68em;
}

.atom-quiz-engine .atom-formula-row {
  align-items: center;
  gap: .7em;
}
.atom-quiz-engine .atom-formula-row-text {
  font-family: var(--atom-font-family);
  font-weight: 600;
}

/* Two-carbon bond sketches used by introductory saturation questions. */
.atom-quiz-engine .atom-bond-pair {
  align-items: center;
  min-height: 2.7em;
  padding-inline: 1.1em;
  position: relative;
}
.atom-quiz-engine .atom-bond-carbon {
  display: inline-block;
  min-width: .72em;
  position: relative;
  text-align: center;
}
.atom-quiz-engine .atom-bond-center {
  display: inline-block;
  margin-inline: .05em;
  min-width: .62em;
}
.atom-quiz-engine .atom-bond-pair.is-saturated .atom-bond-carbon::before,
.atom-quiz-engine .atom-bond-pair.is-saturated .atom-bond-carbon::after {
  background: currentColor;
  content: "";
  height: .75em;
  left: 50%;
  position: absolute;
  width: 1.5px;
}
.atom-quiz-engine .atom-bond-pair.is-saturated .atom-bond-carbon::before { bottom: calc(100% + .08em); }
.atom-quiz-engine .atom-bond-pair.is-saturated .atom-bond-carbon::after { top: calc(100% + .08em); }
.atom-quiz-engine .atom-bond-pair.is-saturated::before,
.atom-quiz-engine .atom-bond-pair.is-saturated::after,
.atom-quiz-engine .atom-bond-pair.is-alkyne::before,
.atom-quiz-engine .atom-bond-pair.is-alkyne::after {
  background: currentColor;
  content: "";
  height: 1.5px;
  position: absolute;
  top: 50%;
  width: .75em;
}
.atom-quiz-engine .atom-bond-pair.is-saturated::before,
.atom-quiz-engine .atom-bond-pair.is-alkyne::before { left: .12em; }
.atom-quiz-engine .atom-bond-pair.is-saturated::after,
.atom-quiz-engine .atom-bond-pair.is-alkyne::after { right: .12em; }
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon::before,
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon::after {
  background: currentColor;
  content: "";
  height: 1.4px;
  position: absolute;
  width: .8em;
}
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon.is-left::before { right: .48em; top: -.28em; transform: rotate(42deg); }
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon.is-left::after { right: .48em; bottom: -.28em; transform: rotate(-42deg); }
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon.is-right::before { left: .48em; top: -.28em; transform: rotate(-42deg); }
.atom-quiz-engine .atom-bond-pair.is-alkene .atom-bond-carbon.is-right::after { left: .48em; bottom: -.28em; transform: rotate(42deg); }

/* Choice images must stay much smaller than question illustrations. */
.atom-quiz-engine .atom-quiz-choice-image-wrap {
  background: transparent;
  border: 0;
  margin: 2px auto;
  padding: 4px;
}
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
  height: auto;
  max-height: 150px;
  max-width: min(100%, 280px);
  object-fit: contain;
  width: auto;
}

@media (max-width: 640px) {
  .atom-quiz-engine .atom-chem-structure.is-question {
    font-size: clamp(1rem, 4.6vw, 1.28rem);
    margin-bottom: 12px;
    padding-block: 1.35em 1em;
  }
  .atom-quiz-engine .atom-chem-structure.is-choice {
    font-size: 1.02em;
    padding-block: 1.25em .98em;
  }
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
    max-height: 108px;
    max-width: min(100%, 220px);
  }
}

/* === ATOM v2.2.0 beta 11: structured chemistry hardening ================
 * Choice illustrations are artwork, not cards-within-cards. Keep the outer
 * answer button as the only visual container and let dark-mode filtering act
 * on the image pixels themselves.
 */
.atom-quiz-engine .atom-quiz-choice-image-wrap,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-light,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-transparent,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-dark-safe {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 auto !important;
  padding: 0 !important;
}

.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: block;
  height: auto;
  margin: 0 auto !important;
  max-height: 112px;
  max-width: min(100%, 190px);
  object-fit: contain;
  padding: 0 !important;
  width: auto;
}

/* Give a structured answer enough vertical breathing room for an upper/lower
 * branch, while keeping ordinary text answers compact. */
.atom-quiz-engine .atom-quiz-choice:has(.atom-chem-structure) {
  min-height: 82px;
}
.atom-quiz-engine .atom-quiz-choice .atom-chem-structure.is-choice {
  overflow: visible;
  padding-block: 1.55em 1.4em;
}

/* The actual atom (C/O/N/...) is the anchor. Branch bonds are centered on it,
 * not on the complete CH/CH2/CH3 token. */
.atom-quiz-engine .atom-structure-anchor {
  display: inline-block;
  isolation: isolate;
  position: relative;
  text-align: center;
}
.atom-quiz-engine .atom-structure-branch {
  left: 50%;
  transform: translateX(-50%);
}
.atom-quiz-engine .atom-structure-branch-bond {
  left: 50%;
  transform: translateX(-50%);
}
.atom-quiz-engine .atom-structure-branch-label {
  left: 50%;
  transform: translateX(-50%);
}
.atom-quiz-engine .atom-structure-branch-formula {
  left: 0;
  position: relative;
  width: 0;
}
.atom-quiz-engine .atom-structure-branch-core {
  left: 0;
  position: absolute;
  transform: translateX(-50%);
}
.atom-quiz-engine .atom-structure-branch-prefix { right: .38em; }
.atom-quiz-engine .atom-structure-branch-suffix { left: .38em; }

@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
    max-height: 88px;
    max-width: min(100%, 150px);
  }
  .atom-quiz-engine .atom-quiz-choice:has(.atom-chem-structure) {
    min-height: 76px;
  }
}

/* Explicit bond spokes for the two-carbon sketches. Avoid pseudo-element
 * differences between browser engines and keep every visible bond intentional. */
.atom-quiz-engine .atom-bond-pair {
  gap: 0;
  padding-inline: .15em;
}
.atom-quiz-engine .atom-bond-carbon-label {
  display: inline-block;
  position: relative;
  z-index: 2;
}
.atom-quiz-engine .atom-bond-side {
  background: currentColor;
  display: inline-block;
  flex: 0 0 .72em;
  height: 1.6px;
  margin-inline: .04em;
  vertical-align: middle;
}
.atom-quiz-engine .atom-bond-spoke {
  background: currentColor;
  display: block;
  position: absolute;
  z-index: 1;
}
.atom-quiz-engine .atom-bond-spoke.is-up,
.atom-quiz-engine .atom-bond-spoke.is-down {
  height: .72em;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
}
.atom-quiz-engine .atom-bond-spoke.is-up { bottom: calc(100% + .08em); }
.atom-quiz-engine .atom-bond-spoke.is-down { top: calc(100% + .08em); }
.atom-quiz-engine .atom-bond-spoke.is-diag-up,
.atom-quiz-engine .atom-bond-spoke.is-diag-down {
  height: 1.5px;
  top: 50%;
  width: .78em;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-up {
  right: 62%; transform: rotate(42deg); transform-origin: right center;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-down {
  right: 62%; transform: rotate(-42deg); transform-origin: right center;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-up {
  left: 62%; transform: rotate(-42deg); transform-origin: left center;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-down {
  left: 62%; transform: rotate(42deg); transform-origin: left center;
}
/* Disable beta10 pseudo spokes now that beta11 emits real elements. */
.atom-quiz-engine .atom-bond-pair::before,
.atom-quiz-engine .atom-bond-pair::after,
.atom-quiz-engine .atom-bond-pair .atom-bond-carbon::before,
.atom-quiz-engine .atom-bond-pair .atom-bond-carbon::after { content: none !important; }

/* === ATOM v2.2.0 beta 12: branch-spacing + smaller choice images ===== */
.atom-quiz-engine .atom-chem-structure.is-question {
  padding-block: 1.7em 1.2em;
}
.atom-quiz-engine .atom-chem-structure.is-choice {
  padding-block: 1.7em 1.45em;
}
.atom-quiz-engine .atom-structure-node.has-branch {
  padding-inline: .18em;
}
.atom-quiz-engine .atom-structure-node.has-multi-branch {
  padding-inline: .28em;
}
.atom-quiz-engine .atom-structure-node.has-up-branch .atom-structure-anchor,
.atom-quiz-engine .atom-structure-node.has-down-branch .atom-structure-anchor {
  isolation: isolate;
}
.atom-quiz-engine .atom-structure-main-bond {
  margin-inline: .08em;
}
.atom-quiz-engine .atom-structure-branch.is-up {
  bottom: calc(100% + .18em);
  height: 1.72em;
}
.atom-quiz-engine .atom-structure-branch.is-down {
  top: calc(100% + .18em);
  height: 1.72em;
}
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond,
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond {
  height: 1.02em;
}
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label {
  bottom: 1.12em;
}
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label {
  top: 1.12em;
}
.atom-quiz-engine .atom-structure-branch-prefix { right: .46em; }
.atom-quiz-engine .atom-structure-branch-suffix { left: .46em; }

/* Make option artwork feel like answer content, not large central figures. */
.atom-quiz-engine .atom-quiz-choice-image-wrap,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-light,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-transparent,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-dark-safe {
  margin-inline-start: 0 !important;
  margin-inline-end: auto !important;
}
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
  max-height: 90px;
  max-width: min(100%, 150px);
}

/* Q8-style two-carbon sketches: keep the side strokes visible and pull the
   diagonal alkene strokes away from the carbon letters a little more. */
.atom-quiz-engine .atom-bond-pair {
  padding-inline: .32em;
}
.atom-quiz-engine .atom-bond-side {
  flex-basis: .92em;
  height: 1.7px;
  margin-inline: .10em;
}
.atom-quiz-engine .atom-bond-center {
  min-width: .72em;
}
.atom-quiz-engine .atom-bond-carbon {
  min-width: .84em;
}
.atom-quiz-engine .atom-bond-spoke.is-diag-up,
.atom-quiz-engine .atom-bond-spoke.is-diag-down {
  width: .64em;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-up {
  right: 74%; top: -.18em;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-down {
  right: 74%; bottom: -.18em; top: auto;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-up {
  left: 74%; top: -.18em;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-down {
  left: 74%; bottom: -.18em; top: auto;
}

@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
    max-height: 76px;
    max-width: min(100%, 126px);
  }
  .atom-quiz-engine .atom-structure-node.has-branch {
    padding-inline: .12em;
  }
  .atom-quiz-engine .atom-structure-node.has-multi-branch {
    padding-inline: .18em;
  }
  .atom-quiz-engine .atom-structure-branch.is-up,
  .atom-quiz-engine .atom-structure-branch.is-down {
    height: 1.6em;
  }
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label,
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label {
    transform: translateX(-50%) scale(.98);
    transform-origin: center;
  }
}

/* === ATOM v2.2.0 beta 13: chemically anchored three-layer structures ==== */
/* Branches are rendered as three visibly separate layers:
 * label -> vertical bond -> main-chain atom.  The branch container is still
 * anchored at 50% of the actual atom span, so CH/CH2/CH3 suffixes do not move
 * the bond away from C. */
.atom-quiz-engine .atom-chem-structure.is-question {
  padding-block: 2.05em 1.32em;
}
.atom-quiz-engine .atom-chem-structure.is-choice {
  padding-block: 2em 1.55em;
}
.atom-quiz-engine .atom-structure-node.has-branch {
  padding-inline: .24em;
}
.atom-quiz-engine .atom-structure-node.has-multi-branch {
  padding-inline: .34em;
}
.atom-quiz-engine .atom-structure-main-bond {
  margin-inline: .10em;
}
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes {
  margin-inline: .42em;
  min-width: .78em;
}
.atom-quiz-engine .atom-structure-branch.is-up {
  bottom: calc(100% + .18em);
  height: 1.98em;
}
.atom-quiz-engine .atom-structure-branch.is-down {
  top: calc(100% + .18em);
  height: 1.98em;
}
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond,
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond {
  height: .92em;
}
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label {
  bottom: 1.28em;
}
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label {
  top: 1.28em;
}
/* Double vertical bonds are a little wider and remain centered over carbon. */
.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::before { left: -2.5px; }
.atom-quiz-engine .atom-structure-branch.is-double .atom-structure-branch-bond::after  { left:  2.5px; }

/* Keep every chemical option on the same RTL content edge.  This applies to
 * both structured HTML and artwork, so Q8 A no longer floats at center while
 * B/C/D sit on the answer-content side. */
.atom-quiz-engine .atom-quiz-choice > .atom-quiz-content {
  text-align: right;
}
.atom-quiz-engine .atom-quiz-choice .atom-chem-structure.is-choice {
  display: inline-flex;
  margin-inline-start: 0;
  margin-inline-end: auto;
}
.atom-quiz-engine .atom-quiz-choice-image-wrap,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-light,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-transparent,
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-image-dark-safe {
  margin-inline-start: 0 !important;
  margin-inline-end: auto !important;
}

/* Choice illustrations: one additional, modest reduction from beta12.
 * Question illustrations intentionally keep their existing dimensions. */
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
  max-height: 82px;
  max-width: min(100%, 138px);
}

/* Q8 bond-pair details.  Saturated and alkyne styles keep explicit external
 * horizontal bonds; alkene diagonal bonds are pushed clear of each C glyph. */
.atom-quiz-engine .atom-bond-pair {
  padding-inline: .36em;
}
.atom-quiz-engine .atom-bond-side {
  flex-basis: .98em;
  margin-inline: .12em;
}
.atom-quiz-engine .atom-bond-carbon {
  min-width: .88em;
}
.atom-quiz-engine .atom-bond-spoke.is-up,
.atom-quiz-engine .atom-bond-spoke.is-down {
  height: .76em;
}
.atom-quiz-engine .atom-bond-spoke.is-diag-up,
.atom-quiz-engine .atom-bond-spoke.is-diag-down {
  width: .68em;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-up {
  right: 82%; top: -.20em;
}
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-down {
  right: 82%; bottom: -.20em; top: auto;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-up {
  left: 82%; top: -.20em;
}
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-down {
  left: 82%; bottom: -.20em; top: auto;
}

@media (max-width: 640px) {
  .atom-quiz-engine .atom-chem-structure.is-question {
    padding-block: 1.9em 1.2em;
  }
  .atom-quiz-engine .atom-chem-structure.is-choice {
    padding-block: 1.85em 1.42em;
  }
  .atom-quiz-engine .atom-structure-node.has-branch {
    padding-inline: .18em;
  }
  .atom-quiz-engine .atom-structure-node.has-multi-branch {
    padding-inline: .26em;
  }
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes {
    margin-inline: .30em;
  }
  .atom-quiz-engine .atom-structure-branch.is-up,
  .atom-quiz-engine .atom-structure-branch.is-down {
    height: 1.84em;
  }
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label {
    bottom: 1.20em;
  }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label {
    top: 1.20em;
  }
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
    max-height: 70px;
    max-width: min(100%, 116px);
  }
}

/* Downward branches must fit inside the structure scroller; overflow-y cannot
 * remain truly visible when overflow-x is auto, so reserve only the needed
 * space on structures that actually contain a lower branch. */
.atom-quiz-engine .atom-chem-structure.is-question.has-down-branch {
  padding-bottom: 2.55em;
}
.atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch {
  padding-bottom: 2.45em;
}
@media (max-width: 640px) {
  .atom-quiz-engine .atom-chem-structure.is-question.has-down-branch {
    padding-bottom: 2.42em;
  }
  .atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch {
    padding-bottom: 2.32em;
  }
}
/* The figure is full-width inside the answer column, so align the image pixels
 * themselves as well as the wrapper. */
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image {
  margin-inline-start: 0 !important;
  margin-inline-end: auto !important;
}


/* === ATOM v2.2.0 beta 14: targeted chemistry micro-adjustments ===== */
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula),
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) { min-height: 82px; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-bond-pair),
.atom-quiz-engine .atom-quiz-choice:has(.atom-molecular-formula),
.atom-quiz-engine .atom-quiz-choice:has(.atom-condensed-formula) { min-height: 58px; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-bond-pair) .atom-chem-structure.is-choice,
.atom-quiz-engine .atom-quiz-choice:has(.atom-molecular-formula) .atom-chem-structure.is-choice,
.atom-quiz-engine .atom-quiz-choice:has(.atom-condensed-formula) .atom-chem-structure.is-choice { padding-block: .56em .50em; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 2.08em 1.58em; }
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .50em; min-width: .84em; }
.atom-quiz-engine .atom-structure-branch.is-up { bottom: calc(100% + .20em); height: 2.12em; }
.atom-quiz-engine .atom-structure-branch.is-down { top: calc(100% + .20em); height: 2.12em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond,
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .78em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.46em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.46em; }
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image { max-height: 76px; max-width: min(100%, 128px); }
.atom-quiz-engine .atom-bond-pair { padding-inline: .42em; }
.atom-quiz-engine .atom-bond-side {
  background: currentColor;
  display: inline-block;
  flex: 0 0 1.08em;
  height: 1.8px;
  margin-inline: .14em;
  vertical-align: middle;
}
.atom-quiz-engine .atom-bond-carbon { min-width: .92em; }
.atom-quiz-engine .atom-bond-spoke.is-up,
.atom-quiz-engine .atom-bond-spoke.is-down { height: .82em; }
.atom-quiz-engine .atom-bond-spoke.is-diag-up,
.atom-quiz-engine .atom-bond-spoke.is-diag-down { width: .72em; }
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-up { right: 88%; top: -.24em; }
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-down { right: 88%; bottom: -.24em; top: auto; }
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-up { left: 88%; top: -.24em; }
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-down { left: 88%; bottom: -.24em; top: auto; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-choice:has(.atom-bond-pair),
  .atom-quiz-engine .atom-quiz-choice:has(.atom-molecular-formula),
  .atom-quiz-engine .atom-quiz-choice:has(.atom-condensed-formula) { min-height: 50px; }
  .atom-quiz-engine .atom-quiz-choice:has(.atom-bond-pair) .atom-chem-structure.is-choice,
  .atom-quiz-engine .atom-quiz-choice:has(.atom-molecular-formula) .atom-chem-structure.is-choice,
  .atom-quiz-engine .atom-quiz-choice:has(.atom-condensed-formula) .atom-chem-structure.is-choice { padding-block: .48em .44em; }
  .atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
  .atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 1.96em 1.48em; }
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .36em; }
  .atom-quiz-engine .atom-structure-branch.is-up,
  .atom-quiz-engine .atom-structure-branch.is-down { height: 1.96em; }
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.34em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.34em; }
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image { max-height: 66px; max-width: min(100%, 112px); }
}


/* === ATOM v2.2.0 beta 15: final micro-fixes from visual QA ===== */
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content:has(.atom-branched-formula),
.atom-quiz-engine .atom-quiz-choice .atom-quiz-content:has(.atom-formula-row) { align-self: start; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula),
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) { min-height: 86px; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 1.88em 1.76em; margin-top: -.12em; }
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .54em; min-width: .88em; }
.atom-quiz-engine .atom-structure-branch.is-up { bottom: calc(100% + .16em); height: 2.04em; }
.atom-quiz-engine .atom-structure-branch.is-down { top: calc(100% + .16em); height: 2.04em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond,
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .64em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.52em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.52em; }
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image { max-height: 72px; max-width: min(100%, 122px); }
.atom-quiz-engine .atom-bond-pair { padding-inline: .46em; gap: 0; }
.atom-quiz-engine .atom-bond-side { background: none !important; color: currentColor; display: inline-block; flex: 0 0 auto; font-family: "Cambria Math", "Times New Roman", serif; font-size: 1.03em; font-weight: 700; height: auto; line-height: 1; margin-inline: .16em; min-width: .62em; text-align: center; vertical-align: middle; }
.atom-quiz-engine .atom-bond-carbon { min-width: .92em; }
.atom-quiz-engine .atom-bond-center { min-width: .76em; }
.atom-quiz-engine .atom-bond-spoke.is-up,
.atom-quiz-engine .atom-bond-spoke.is-down { height: .80em; }
.atom-quiz-engine .atom-bond-spoke.is-diag-up,
.atom-quiz-engine .atom-bond-spoke.is-diag-down { width: .74em; }
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-up { right: 92%; top: -.24em; }
.atom-quiz-engine .atom-bond-carbon.is-left .atom-bond-spoke.is-diag-down { right: 92%; bottom: -.24em; top: auto; }
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-up { left: 92%; top: -.24em; }
.atom-quiz-engine .atom-bond-carbon.is-right .atom-bond-spoke.is-diag-down { left: 92%; bottom: -.24em; top: auto; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula),
  .atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) { min-height: 80px; }
  .atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
  .atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 1.76em 1.60em; }
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .40em; }
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.42em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.42em; }
  .atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image { max-height: 62px; max-width: min(100%, 106px); }
}


/* === ATOM v2.2.0 beta 16: final branch-only finishing pass ===== */
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula),
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) { min-height: 88px; }
.atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
.atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 1.84em 1.70em; margin-top: -.14em; }
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .56em; min-width: .90em; }
.atom-quiz-engine .atom-structure-branch.is-up { bottom: calc(100% + .14em); height: 2.00em; }
.atom-quiz-engine .atom-structure-branch.is-down { top: calc(100% + .14em); height: 1.90em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond { height: .60em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .62em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.62em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.24em; }
.atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 2.18em; }
.atom-quiz-engine .atom-chem-structure.is-question.has-down-branch { padding-bottom: 2.26em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula),
  .atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) { min-height: 82px; }
  .atom-quiz-engine .atom-quiz-choice:has(.atom-branched-formula) .atom-chem-structure.is-choice,
  .atom-quiz-engine .atom-quiz-choice:has(.atom-formula-row) .atom-chem-structure.is-choice { padding-block: 1.72em 1.54em; }
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .42em; }
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.50em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.18em; }
}


/* === ATOM v2.2.0 beta 17: final branch spacing polish ===== */
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.74em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: 1.02em; }
.atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-bond { height: .56em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .58em; }
.atom-quiz-engine .atom-structure-branch.is-down { height: 1.78em; }
.atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.96em; }
.atom-quiz-engine .atom-chem-structure.is-question.has-down-branch { padding-bottom: 2.08em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-structure-branch.is-up .atom-structure-branch-label { bottom: 1.60em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .98em; }
  .atom-quiz-engine .atom-structure-branch.is-down { height: 1.72em; }
  .atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.84em; }
}


/* === ATOM v2.2.0 beta 18: final lower-branch lift ===== */
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .80em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .54em; }
.atom-quiz-engine .atom-structure-branch.is-down { height: 1.58em; }
.atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.74em; }
.atom-quiz-engine .atom-chem-structure.is-question.has-down-branch { padding-bottom: 1.92em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .76em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .52em; }
  .atom-quiz-engine .atom-structure-branch.is-down { height: 1.52em; }
  .atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.64em; }
}


/* === ATOM v2.2.0 beta 19: one more lower-branch lift ===== */
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .64em; }
.atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .50em; }
.atom-quiz-engine .atom-structure-branch.is-down { height: 1.42em; }
.atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.58em; }
.atom-quiz-engine .atom-chem-structure.is-question.has-down-branch { padding-bottom: 1.76em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-label { top: .62em; }
  .atom-quiz-engine .atom-structure-branch.is-down .atom-structure-branch-bond { height: .48em; }
  .atom-quiz-engine .atom-structure-branch.is-down { height: 1.38em; }
  .atom-quiz-engine .atom-chem-structure.is-choice.has-down-branch { padding-bottom: 1.50em; }
}


/* === ATOM v2.2.0 beta 20: tighten adjacent branched nodes ===== */
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .22em; min-width: .48em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .18em; min-width: .42em; }
}


/* === ATOM v2.2.0 beta 21: Q60/Q61 + Q111 finishing pass ===== */
.atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .10em; min-width: .34em; }
.atom-quiz-engine .atom-formula-row { gap: 1.15em; }
@media (max-width: 640px) {
  .atom-quiz-engine .atom-structure-main-bond.is-between-branched-nodes { margin-inline: .08em; min-width: .30em; }
  .atom-quiz-engine .atom-formula-row { gap: .95em; }
}


/* === ATOM v2.2.0 beta26: deterministic SVG presentation ===== */
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-svg-wrap:not(.atom-quiz-choice-image-wrap) { background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 8px 0 18px; overflow: visible; }
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-svg-wrap:not(.atom-quiz-choice-image-wrap) img.atom-quiz-question-image { background: transparent !important; border: 0 !important; box-shadow: none !important; display: block; height: auto; margin-inline: auto; max-width: 100%; max-height: none !important; padding: 0 !important; }
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image.atom-quiz-svg-image { max-height: none !important; max-width: 100% !important; }

/* === ATOM v2.2.0 beta28: quiz intro + background image preload === */
.atom-quiz-intro {
  background: var(--atom-card-bg);
  border: 1px solid var(--atom-border);
  border-radius: 14px;
  margin: 6px auto 18px;
  max-width: 760px;
  padding: clamp(28px, 6vw, 56px) clamp(22px, 6vw, 54px);
  text-align: center;
}
.atom-quiz-intro-mark {
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--atom-primary) 45%, var(--atom-border));
  border-radius: 999px;
  color: #f59e0b;
  display: inline-flex;
  font-size: 1.55rem;
  height: 54px;
  justify-content: center;
  margin-bottom: 14px;
  width: 54px;
}
.atom-quiz-intro-basmala {
  color: var(--atom-muted);
  font-size: .96rem;
  font-weight: 600;
  margin: 0 0 8px;
}
.atom-quiz-intro h2 {
  color: var(--atom-text);
  font-size: clamp(1.55rem, 4vw, 2rem);
  line-height: 1.45;
  margin: 0;
}
.atom-quiz-intro-taxonomy {
  color: var(--atom-primary);
  font-size: .98rem;
  font-weight: 700;
  margin: 8px 0 0;
}
.atom-quiz-intro-count,
.atom-quiz-intro-resume {
  color: var(--atom-muted);
  font-size: .92rem;
  margin: 8px 0 0;
}
.atom-quiz-intro-resume {
  background: color-mix(in srgb, var(--atom-primary) 8%, transparent);
  border-radius: 999px;
  display: inline-block;
  padding: 5px 12px;
}
.atom-quiz-intro-chooser {
  align-items: center;
  color: var(--atom-muted);
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 18px 0 0;
}
.atom-quiz-intro-chooser select {
  background: var(--atom-card-bg);
  border: 1px solid var(--atom-border);
  border-radius: 8px;
  color: var(--atom-text);
  min-height: 40px;
  padding: 4px 12px;
}
.atom-quiz-intro-start {
  display: inline-flex;
  font-size: 1.05rem;
  justify-content: center;
  margin-top: 22px;
  min-width: min(100%, 220px);
  padding: 11px 28px;
}
.atom-quiz-intro-note {
  color: var(--atom-muted);
  font-size: .82rem;
  margin: 14px 0 0;
}
@media (max-width: 600px) {
  .atom-quiz-intro { border-radius: 10px; padding: 30px 18px; }
  .atom-quiz-intro-start { width: 100%; }
}

/* v2.4.2: Camera action beside bookmark; no changes to question or choice themes. */
.atom-quiz-engine .atom-quiz-heading-tools {display:inline-flex;align-items:center;gap:9px;flex-shrink:0;}
.atom-quiz-engine .atom-quiz-camera {display:inline-flex;align-items:center;justify-content:center;width:39px;height:39px;font-size:19px;border:1px solid var(--atom-border);border-radius:10px;color:var(--atom-text);background:transparent;cursor:pointer;line-height:1;}
.atom-quiz-engine .atom-quiz-camera:focus-visible {outline:3px solid var(--atom-accent);outline-offset:2px;}
.atom-quiz-engine .atom-quiz-camera:disabled {opacity:.6;cursor:wait;}
.atom-capture-overlay {position:fixed;inset:0;z-index:2147483000;display:grid;place-items:center;padding:calc(env(safe-area-inset-top, 0px) + 12px) 14px calc(env(safe-area-inset-bottom, 0px) + 12px);background:rgba(0,0,0,.82);overscroll-behavior:contain;}
.atom-capture-dialog {width:min(600px,100%);max-height:95%;display:flex;flex-direction:column;gap:12px;overflow:auto;background:#21272c;color:#f8fafc;border:1px solid #59606a;border-radius:14px;padding:15px;direction:rtl;font-family:Arial,sans-serif;box-shadow:0 15px 40px rgba(0,0,0,.45);}
.atom-capture-preview {width:100%;max-height:58vh;object-fit:contain;border-radius:9px;background:#fff;}
.atom-capture-dialog .atom-capture-actions {display:flex;flex-wrap:wrap;gap:8px;}
.atom-capture-dialog button,.atom-capture-dialog a {min-height:40px;padding:9px 14px;border-radius:8px;border:1px solid #64748b;background:#34454e;color:#fff;font-size:14px;font-weight:700;text-decoration:none;cursor:pointer;}
.atom-capture-dialog .atom-capture-primary {background:#e67e16;border-color:#e67e16;color:#fff;}
.atom-capture-dialog small {opacity:.8;line-height:1.6;}

/* v2.4.4: Keep native save fallback hidden until a bridge error makes it available. */
.atom-capture-dialog .atom-capture-actions [hidden] {display:none !important;}
.atom-capture-dialog .atom-capture-actions [aria-disabled="true"] {opacity:.65;cursor:wait;}

/* === ATOM v2.4.6: Native RTL question tables ===============================
 * Style with existing quiz theme variables; no hardcoded white/black palette.
 * Table only renders for questions with structured question_table metadata.
 */
.atom-quiz-engine .atom-quiz-table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 18px;
  border-radius: 8px;
  outline-offset: 2px;
}
.atom-quiz-engine .atom-quiz-native-table {
  width: 100%;
  min-width: 260px;
  border-collapse: collapse;
  table-layout: fixed;
  direction: rtl;
  color: inherit;
  background: transparent;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  font-family: inherit;
  font-size: clamp(.84rem, 1.9vw, 1rem);
  font-weight: 600;
  line-height: 1.45;
}
.atom-quiz-engine .atom-quiz-native-table :is(th, td) {
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  padding: 9px 7px;
  color: inherit;
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
  white-space: normal;
}
.atom-quiz-engine .atom-quiz-native-table th {
  background: color-mix(in srgb, currentColor 8%, transparent);
  font-weight: 800;
}
.atom-quiz-engine .atom-quiz-native-table .atom-quiz-table-head-label {
  direction: rtl;
  unicode-bidi: isolate;
}
.atom-quiz-engine .atom-quiz-native-table :is(bdi, .atom-quiz-table-unit) {
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.atom-quiz-engine .atom-quiz-native-table td bdi[dir="ltr"] {
  direction: ltr;
}
@media (max-width: 520px) {
  .atom-quiz-engine .atom-quiz-native-table :is(th, td) { padding: 7px 5px; }
}


/* ATOM v2.4.7: Native responsive Canvas plots (no generated SVGs). */
.atom-quiz-engine .atom-quiz-graph-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  width:100%;max-width:100%;
  margin:12px 0 20px;
}
.atom-quiz-engine .atom-quiz-graph-panel {
  min-width:0;
  margin:0;
  padding:9px;
  border:1px solid var(--atom-border);
  border-radius:8px;
  background:color-mix(in srgb, var(--atom-card-bg) 95%, var(--atom-text) 5%);
  color:var(--atom-text);
}
.atom-quiz-engine .atom-quiz-graph-label {
  color:var(--atom-text);
  font-family:inherit;
  font-size:1.03rem;
  font-weight:800;
  text-align:right;
  line-height:1.2;
}
.atom-quiz-engine canvas.atom-quiz-graph-canvas {
  display:block;
  width:100%;height:auto;
  max-width:100%;
  color:var(--atom-text);
  --atom-graph-line:#cf3038;
}
@container (max-width: 520px) {
  .atom-quiz-engine .atom-quiz-graph-grid {grid-template-columns:1fr;gap:10px;}
  .atom-quiz-engine .atom-quiz-graph-panel {padding:8px 10px;}
}


/* Reusable native Canvas sizes for ALL single-question graphs.
   medium is a compact default; banks may select small/medium/large by metadata.
   Existing four-panel question/choice graphs are unaffected. */
.atom-quiz-engine .atom-quiz-graph-grid.atom-quiz-graph-single {
  grid-template-columns:minmax(0,1fr);
  width:100%;
  max-width:270px;
  margin:10px auto 14px;
}
.atom-quiz-engine .atom-quiz-graph-grid.atom-quiz-graph-single.atom-quiz-graph-size-small { max-width:210px; }
.atom-quiz-engine .atom-quiz-graph-grid.atom-quiz-graph-single.atom-quiz-graph-size-medium { max-width:270px; }
.atom-quiz-engine .atom-quiz-graph-grid.atom-quiz-graph-single.atom-quiz-graph-size-large { max-width:380px; }

/* ATOM v2.4.8 — each Canvas plot belongs to its actual clickable option. */
.atom-quiz-engine .atom-quiz-choice.has-choice-graph > .atom-quiz-content {
  display:block;
  min-width:0;
  width:100%;
}
.atom-quiz-engine .atom-quiz-choice .atom-quiz-choice-graph {
  display:block;
  margin:0;
  width:min(100%, 252px);
  max-width:100%;
  padding:3px;
  background:color-mix(in srgb, var(--atom-card-bg) 95%, var(--atom-text) 5%);
  color:var(--atom-text);
  border:1px solid var(--atom-border);
  text-align:center;
  pointer-events:none;
}
.atom-quiz-engine .atom-quiz-choice .atom-quiz-choice-graph .atom-quiz-graph-canvas {
  display:block;
  width:100%;
  height:auto;
  max-width:100%;
}
@container (max-width:520px) {
  .atom-quiz-engine .atom-quiz-choice.has-choice-graph { gap:8px; padding:9px 8px; }
  .atom-quiz-engine .atom-quiz-choice .atom-quiz-choice-graph { width:min(100%, 224px); padding:2px; }
}

/* ATOM v2.4.10: distinct graph curve, smaller cards on tablet/phone.
 * CSS media / explicit theme selectors both supported (no external image source).
 * Leave axes bound to --atom-text for high contrast in either theme. */
@media (prefers-color-scheme: dark) {
  .atom-quiz-engine canvas.atom-quiz-graph-canvas { --atom-graph-line: #ff7373; }
}
html[data-theme="dark"] .atom-quiz-engine canvas.atom-quiz-graph-canvas,
body[data-theme="dark"] .atom-quiz-engine canvas.atom-quiz-graph-canvas,
html.dark .atom-quiz-engine canvas.atom-quiz-graph-canvas,
body.dark .atom-quiz-engine canvas.atom-quiz-graph-canvas,
.dark-mode .atom-quiz-engine canvas.atom-quiz-graph-canvas {
  --atom-graph-line: #ff7373;
}
html[data-theme="light"] .atom-quiz-engine canvas.atom-quiz-graph-canvas,
body[data-theme="light"] .atom-quiz-engine canvas.atom-quiz-graph-canvas,
html.light .atom-quiz-engine canvas.atom-quiz-graph-canvas,
body.light .atom-quiz-engine canvas.atom-quiz-graph-canvas {
  --atom-graph-line: #cf3038;
}
.atom-quiz-engine .atom-quiz-choice.has-choice-graph { touch-action:pan-y; }
.atom-quiz-engine .atom-quiz-choice .atom-quiz-choice-graph,
.atom-quiz-engine .atom-quiz-choice .atom-quiz-choice-graph canvas { pointer-events:none; }

/* v2.4.10 — opt-in impact limited to MathJax inside answer choices.
   Numeric options no longer look smaller than the surrounding Arabic choice UI. */
.atom-quiz-engine .atom-quiz-choice > .atom-quiz-content mjx-container:not([display="true"]) {
  font-size: 1.25em !important;
  vertical-align: middle;
}


/* ATOM v2.4.12: constrain ONLY original PNG question illustrations.
 * SVG question diagrams keep their pre-v2.4.11 presentation and dimensions.
 * No restrictions apply to choice images, Canvas graphs, or JPG/WebP files.
 */
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-png-wrap:not(.atom-quiz-choice-image-wrap) {
  width: min(100%, 395px);
  max-width: 100%;
  margin: 8px auto 15px;
  padding: 8px;
  box-sizing: border-box;
}
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-png-wrap:not(.atom-quiz-choice-image-wrap) img.atom-quiz-question-image {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 215px !important;
  object-fit: contain !important;
  margin: 0 auto !important;
}
@media (max-width: 640px) {
  .atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-png-wrap:not(.atom-quiz-choice-image-wrap) {
    width: min(100%, 340px);
  }
  .atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-png-wrap:not(.atom-quiz-choice-image-wrap) img.atom-quiz-question-image {
    max-height: 170px !important;
  }
}
/* MathJax in structured RTL data tables: isolate complete left-to-right equations. */
.atom-quiz-engine .atom-quiz-native-table td bdi:has(mjx-container) { direction:ltr; unicode-bidi:isolate; }
.atom-quiz-engine .atom-quiz-native-table td mjx-container { font-size:1.09em !important; }


/* ATOM v2.5.22.7: responsive SVG dimensions for user-provided assets.
 * Control how SVG files look independently of their intrinsic width/height.
 * object-fit: contain keeps the entire diagram, without stretching or cropping.
 * Only image SVGs participate: PNG/JPG/WebP and question Canvas are unchanged.
 * Four global tokens; choice SVG only has MAXIMUM size, never minimum.
 */
.atom-quiz-engine {
  --atom-svg-question-width: 320px;
  --atom-svg-question-height: 220px;
  --atom-svg-choice-width: 160px;
  --atom-svg-choice-height: 110px;
}
/* v2.5.22.6: NO fixed vertical SVG question frame. The image is sized
 * using its actual aspect ratio, with the existing 320px by 220px maxima.
 * This removes 100px+ of unnecessary blank space for short, wide diagrams
 * throughout ALL quiz questions, without touching question assets or choices. */
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-svg-wrap:not(.atom-quiz-choice-image-wrap) {
  box-sizing: border-box;
  display: block;
  width: min(100%, var(--atom-svg-question-width)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 6px auto 9px !important;
}
.atom-quiz-engine .atom-quiz-image-wrap.atom-quiz-svg-wrap:not(.atom-quiz-choice-image-wrap) img.atom-quiz-question-image.atom-quiz-svg-image {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: var(--atom-svg-question-height) !important;
  object-fit: contain !important;
  padding: 0 !important;
  margin: 0 auto !important;
}
/* ATOM v2.5.22.7: SVG answers have a maximum size, never a minimum.
 * SVGs smaller than 160x110 stay at their intrinsic dimensions; larger
 * SVGs are proportionally reduced to fit both maximum dimensions.
 * No fixed-size frames or img width:100%, so small organic chemistry
 * structures are not involuntarily enlarged.  The answer button, RTL
 * positioning and answer labels are unchanged.
 */
.atom-quiz-engine .atom-quiz-choice-image-wrap.atom-quiz-svg-wrap {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: fit-content !important;
  min-width: 0 !important;
  max-width: min(100%, var(--atom-svg-choice-width)) !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin-inline-start: 0 !important;
  margin-inline-end: auto !important;
}
.atom-quiz-engine .atom-quiz-choice-image-wrap img.atom-quiz-choice-image.atom-quiz-svg-image {
  display: block;
  box-sizing: border-box;
  width: auto !important;
  min-width: 0 !important;
  max-width: min(100%, var(--atom-svg-choice-width)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: var(--atom-svg-choice-height) !important;
  object-fit: contain !important;
  padding: 0 !important;
  margin: 0 !important;
}
