/* Keep each fraction or term intact while allowing long lists to wrap. */
#questionHtml { overflow-wrap:anywhere; }
#questionHtml .inlineChoice.hasFormulaChoice > .choiceFormulaSet,
#questionHtml .notation-sum {
  flex-wrap:wrap;
  white-space:normal;
  overflow:visible;
  box-sizing:border-box;
  gap:.45em .65em;
}
#questionHtml .notation-sum { display:inline-flex; align-items:center; max-width:100%; }
#questionHtml .choiceFormulaSet > .formulaTerm,
#questionHtml .notation-term { display:inline-block; white-space:nowrap; overflow-wrap:normal; }
#questionHtml :is(.mathFrac,.mathMatrix,.mathIsotope,.chem-formula) { overflow-wrap:normal; }
#questionHtml .mathFrac :is(.num,.den) { white-space:nowrap; }
#questionHtml .h19FormulaLine { white-space:normal; line-height:1.8; }

/* Limits share a column beside the integral, not the parent flex baseline. */
#questionHtml .notation-integral {
  display:inline-grid;
  grid-template-columns:auto auto;
  grid-template-rows:1fr 1fr;
  vertical-align:middle;
  margin-right:.2em;
  line-height:1;
}
#questionHtml .notation-integral-sign {
  grid-column:1;
  grid-row:1 / 3;
  align-self:center;
  font-size:1.8em;
}
#questionHtml .notation-integral > :is(sup,sub) {
  position:static;
  display:block;
  font-size:.65em;
  line-height:1;
  margin:0;
  padding:0;
  transform:none;
  grid-column:2;
}
#questionHtml .notation-integral > sup { grid-row:1; align-self:start; }
#questionHtml .notation-integral > sub { grid-row:2; align-self:end; }

/* Shared table columns keep every row aligned, even with unequal entry widths. */
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .mathMatrix {
  display:inline-table;
  position:relative;
  border-collapse:separate;
  border-spacing:0;
  border-left:1.5px solid currentColor;
  border-right:1.5px solid currentColor;
  border-radius:0;
  padding:.16em .2em;
  margin:.1em .15em;
  width:auto;
  vertical-align:middle;
  line-height:1.3;
  white-space:nowrap;
  font-family:"Cambria Math","Times New Roman",serif;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .mathMatrix > .matrixRow {
  display:table-row;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .mathMatrix > .matrixRow > span {
  display:table-cell;
  padding:.16em .38em;
  min-width:1em;
  text-align:center;
  vertical-align:middle;
  white-space:nowrap;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .mathVector {
  position:relative;
  border-radius:0;
  gap:0;
  padding:.16em .2em;
  margin:.1em .15em;
  line-height:1.3;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .mathVector > span {
  padding:.16em .38em;
  white-space:nowrap;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) :is(.mathMatrix,.mathVector)::before,
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) :is(.mathMatrix,.mathVector)::after {
  content:"";
  position:absolute;
  top:0;
  bottom:0;
  width:.28em;
  border-top:1.5px solid currentColor;
  border-bottom:1.5px solid currentColor;
  pointer-events:none;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) :is(.mathMatrix,.mathVector)::before { left:0; }
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) :is(.mathMatrix,.mathVector)::after { right:0; }
#questionHtml .inlineChoice.hasFormulaChoice > .mathChoice:has(.mathMatrix) {
  overflow:visible;
  max-width:calc(100% - 2.4em);
}

/* One label style for formulas in stems, choices and explanations. */
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label,
#questionHtml .inlineChoice.hasFormulaChoice > .formula-label {
  display:inline-block;
  box-sizing:border-box;
  max-width:100%;
  min-width:0;
  margin:.15em .12em;
  padding:.28em .5em;
  border:1px solid #b9d6e1;
  border-radius:6px;
  background:#eef8fb;
  color:#22566b;
  box-shadow:none;
  font-family:"Cambria Math","Times New Roman",serif;
  font-size:1em;
  font-weight:500;
  line-height:1.65;
  vertical-align:middle;
  white-space:normal;
  overflow:visible;
  overflow-wrap:normal;
  word-break:normal;
  letter-spacing:0;
}
#questionHtml .inlineChoice.hasFormulaChoice > .formula-label {
  max-width:calc(100% - 2em);
}
#questionHtml .inlineChoice.hasFormulaChoice {
  overflow-wrap:anywhere;
}
@media (max-width:600px) {
  #questionHtml .inlineChoice .formula-separator {
    display:block;
    height:4px;
    font-size:0;
    line-height:0;
  }
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) :is(.formulaDisplay,.formula).formula-label {
  display:block;
  width:fit-content;
  margin:.55em 0;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label :is(.mathChoice,.mathEquation,.choiceFormulaSet) {
  display:inline;
  padding:0;
  margin:0;
  border:0;
  background:transparent;
  color:inherit;
  box-shadow:none;
  font-size:1em;
  font-weight:inherit;
  line-height:inherit;
  white-space:normal;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label :is(.notation-term,.formulaTerm) {
  display:inline-block;
  white-space:nowrap;
  margin:.08em .18em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label :is(sup,sub) {
  display:inline;
  position:static;
  transform:none;
  margin:0;
  padding:0;
  font-size:.72em;
  line-height:0;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label sup { vertical-align:super; }
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label sub { vertical-align:sub; }
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .mathFrac {
  white-space:nowrap;
  flex-shrink:0;
  line-height:1.2;
  margin:.12em .1em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .mathFrac > .num {
  padding:.08em .22em .14em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .mathFrac > .den {
  padding:.14em .22em .08em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .formulaLine {
  display:block;
  width:auto;
  max-width:100%;
  white-space:normal;
  line-height:1.8;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .caseRow { white-space:normal; }
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .formulaTerm:has(.notation-bits) {
  max-width:100%;
  white-space:normal;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .notation-bits {
  white-space:normal;
  font-family:ui-monospace,Consolas,monospace;
  font-size:.9em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .mathIsotope :is(sup,sub) {
  display:block;
  line-height:1;
  font-size:.68em;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .mathNthRoot > sup {
  position:absolute;
  left:-.18em;
  top:-.28em;
  line-height:1;
  font-size:.55em;
  vertical-align:baseline;
}
:is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label .notation-integral > :is(sup,sub) {
  display:block;
  font-size:.65em;
  line-height:1;
}
html[data-color-mode="dark"] :is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label {
  background:#18252d !important;
  color:#f5faff !important;
  border-color:#597a8b !important;
  box-shadow:none !important;
}
html[data-color-mode="dark"] :is(#questionHtml,#modalBody,#oneQuestionStatement,#oneQuestionFeedback) .formula-label :is(.mathChoice,.mathEquation,.choiceFormulaSet) {
  background:transparent !important;
  color:inherit !important;
}
