/* Readable formulas in phone-sized tutorial frames. Desktop stays unchanged. */
.formula-mobile { display: none; }
@media (max-width: 620px) {
  html.legend-formula, html.legend-formula body {
    width: 100%; height: auto; min-height: 100%; margin: 0;
    overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  html.legend-formula .apple-sheet {
    position: relative; inset: auto; display: flex; flex-direction: column;
    width: 100%; max-width: 100%; min-height: 100%; margin: 0;
    padding: 8px; gap: 12px; box-sizing: border-box; transform: none;
  }
  html.legend-formula .wrap, html.legend-formula .formula-left,
  html.legend-formula .formula-stack, html.legend-formula .stack {
    display: flex; flex-direction: column; width: 100%; min-width: 0;
    max-width: 100%; gap: 12px; box-sizing: border-box;
  }
  html.legend-formula :is(.desc-text,.formula,.formula-card,.formula-block,.block) {
    width: 100%; min-width: 0; max-width: 100%; flex: none;
    margin: 0; padding: 16px 12px; box-sizing: border-box;
  }
  html.legend-formula .desc-text h2 { font-size: 24px; line-height: 1.2; }
  html.legend-formula :is(.desc-text p,.desc-text li,.block p,.formula-card p,.formula-block p,.formula-definition) {
    font-size: 16px; line-height: 1.45; overflow-wrap: break-word;
  }
  html.legend-formula :is(.block h3,.formula-card h3,.formula-block h3) { font-size: 19px; }
  html.legend-formula .formula-caption { font-size: 16px; }
  html.legend-formula .formula { display: block; font-size: 18px; }
  html.legend-formula .formula-desktop { display: none; }
  html.legend-formula .formula-mobile { display: block; }
  html.legend-formula .formula-mobile p { margin: 12px 0 0; font-size: 15px; line-height: 1.4; }
  html.legend-formula math, html.legend-formula .formula-card math {
    font-size: 24px; max-width: 100%; margin: 12px 0;
  }
  html.legend-formula .formula-card .two-lines { grid-template-columns: minmax(0,1fr); gap: 0; }
  html.legend-formula .formula-card .two-lines math { font-size: 24px; }
  html.legend-formula .indicator-row { flex-wrap: wrap; gap: 6px; }
  html.legend-formula .indicator { min-width: 0; flex: 1 1 65px; font-size: 15px; }
  html.legend-formula .latex-formula { width: min(100%,350px); height: auto; }
  html.legend-formula .adj-row { flex-wrap: wrap; max-width: 100%; }
  html.legend-formula .rule-row { grid-template-columns: minmax(0,1fr); gap: 10px; }
}
