.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 5px;
  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;
}

.math-expr {
  display: inline-flex;
  align-items: center;
  gap: 8px;              /* tightened */
  line-height: 1.25;
  white-space: nowrap;
}

.op {
  display: inline-flex;
  align-items: center;
  margin: 0 8px;         /* tightened */
  line-height: 1;
}

.pow {
  display: inline-flex;
  align-items: baseline;
}

.pow-base {
  display: inline;
}

.pow-exp {
  font-size: 0.74em;
  line-height: 1;
  position: relative;
  top: -0.40em;          /* slightly tighter */
  margin-left: 2px;
}

.step-answer {
  padding: 18px 20px;    /* tightened */
  min-height: 84px;      /* tightened */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.step-answer.compact {
  padding: 14px 18px;    /* compact box for formulas/workings */
  min-height: 0;
}

.step-layout {
  display: inline-flex;
  align-items: center;
  gap: 12px;             /* tightened */
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: max-content;
  margin: 0 auto;
}

.final-answer-box {
  font-weight: bold;
  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 (now uses normal step styling, not special/yellow) */
.formula-scroll {
  width: 100%;
  max-width: 720px;      /* slightly narrower */
  margin: 0 auto;
}

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

.formula-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;             /* tightened */
  flex-wrap: wrap;
  white-space: normal;
  text-align: left;
  font-weight: 700;
  line-height: 1.55;     /* tightened */
  padding: 10px 12px;    /* tightened */
}

.formula-item .fraction-table {
  margin: 0 2px;
}

.hidden {
  display: none;
}