/* ================================
   First Order ODE Solver Calculator
   Math + Formula + Step Layout CSS
   ================================ */

/* ---------- Fractions (proper division) ---------- */
.fraction-table {
  border-collapse: collapse;
  width: auto;
  display: inline-table;
  vertical-align: middle;
  margin: 0 2px;
  line-height: 1;
}

.fraction-table td {
  text-align: center;
  padding: 1px 6px;
  line-height: 1.05;
}

.fraction-table tr:nth-child(1) td {
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}

.fraction-table tr:nth-child(2) td {
  padding-top: 2px;
}

/* ---------- Inline math wrapper ---------- */
.math-expr {
  display: inline-flex;
  align-items: center;
  gap: 0;
  line-height: 1.25;
}

/* ---------- Exponents (e^(...), x^2 etc) ---------- */
.pow {
  display: inline-flex;
  align-items: baseline;
}

.pow-base {
  display: inline;
}

.pow-exp {
  font-size: 0.74em;
  line-height: 1;
  position: relative;
  top: -0.42em;
  margin-left: 1px;
}

/* ---------- Step answer container (scroll-safe) ---------- */
.step-answer {
  padding: 20px 18px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* The “single-line math row” used in many steps */
.step-layout {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: max-content;
  margin: 0 auto;
}

/* Final answer block (same pattern as your other calcs) */
.final-answer-box {
  font-weight: 700;
  margin-top: 12px;
  font-size: 1.1em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.final-answer-box .answer-label {
  line-height: 1;
}

/* ---------- Formula bank layout ---------- */
.step.step-formula .step-answer {
  justify-content: center;
}

.formula-scroll {
  width: 100%;
  display: flex;
  justify-content: center;
}

.formula-grid {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 12px;
}

.formula-item {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  white-space: normal;
  text-align: center;
  font-weight: 700;
  line-height: 1.55;
  min-width: 0;
}

/* Multi-line formula items (so “Linear:” is NOT one ugly sentence) */
.formula-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.formula-line {
  display: flex;
  justify-content: center;
}

/* ---------- Multi-line step layouts (THIS is what your example needs) ---------- */
/* Used by the linear ODE steps: P/Q lines, μ line, multiply lines, etc. */
.layout-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  white-space: normal; /* allow wrapping inside steps */
  text-align: center;
}

.layout-line {
  display: flex;
  justify-content: center;
}

/* Make sure long math inside layout-lines can still scroll if needed */
.layout-lines .math-expr {
  max-width: 100%;
}

/* Optional: keep “big expressions” from exploding layout on tiny screens */
@media (max-width: 520px) {
  .step-answer {
    padding: 18px 14px;
  }

  .formula-grid {
    max-width: 100%;
  }

  .fraction-table td {
    padding: 1px 5px;
  }

  .pow-exp {
    font-size: 0.72em;
    top: -0.40em;
  }
}