.math-equation {
  margin: 4px 0 16px;
  color: var(--color-primary);
  font:
    650 18px/1.5 ui-monospace,
    Consolas,
    monospace;
  overflow-wrap: anywhere;
}

.math-view-controls {
  grid-column: 1/-1;
  min-width: 0;
}

.math-view-controls > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  min-height: 30px;
}

.math-view-fields {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.math-presets {
  grid-column: 1/-1;
}

.math-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--color-muted);
  font-size: 12px;
}

.math-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.math-legend i {
  display: inline-block;
  width: 15px;
  height: 3px;
  background: var(--color-primary);
}

.math-legend .math-baseline-key {
  height: 0;
  background: none;
  border-top: 2px dashed var(--color-muted);
}

.math-legend .math-root-key {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #27815a;
}

.math-legend .math-probe-key {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d99736;
}

.math-axis {
  stroke: var(--color-muted);
  stroke-width: 1;
}

.math-root {
  fill: #27815a;
  stroke: var(--color-surface);
  stroke-width: 1.5;
}

.math-vertex {
  fill: var(--color-primary);
  stroke: var(--color-surface);
  stroke-width: 1.5;
}

.math-probe {
  fill: #d99736;
  stroke: var(--color-surface);
  stroke-width: 1.5;
}

.math-chart-caption,
.math-reference p {
  margin: 10px 0 0;
  color: var(--color-muted);
  font-size: 12px;
}

.math-comparison {
  padding: 12px;
  border-radius: 10px;
  background: var(--color-background);
  font-size: 13px;
  color: var(--color-muted);
}

.math-inspect {
  margin-top: 16px;
}

.math-inspect .live-control-head input {
  width: 140px;
}

.math-inspect input[type='range'] {
  padding: 0;
  background: transparent;
  border: 0;
  accent-color: var(--color-primary);
}

.equation-page [aria-invalid='true']:not([type='range']) {
  border-color: #d94141;
}

.math-reference summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.equation-page .simulator-save-actions {
  margin-top: 0;
}

@media (max-width: 768px) {
  .equation-page .simulator-save-actions {
    display: grid;
    width: 100%;
  }

  .equation-page {
    background: var(--color-surface);
  }

  .equation-page > .site-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  .equation-page .hero.category-hero[data-category] {
    min-height: 350px;
    margin: 0;
    padding: 78px 20px 170px;
    border: 0;
    background-color: var(--color-surface);
  }

  .equation-page .live-workspace,
  .equation-page .live-results {
    gap: 0;
  }

  .equation-page .simulator-panel {
    padding: 20px 16px;
  }

  .equation-page .live-controls {
    grid-template-columns: 1fr;
  }

  .equation-page .live-control-head {
    flex-direction: row;
    align-items: center;
  }

  .equation-page .live-control-head input[type='number'] {
    width: 116px;
    max-width: 46%;
  }

  .equation-page .simulator-button,
  .equation-page select {
    min-height: 44px;
  }

  .equation-page .math-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .equation-page .math-presets .simulator-button {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    text-align: center;
  }

  .math-view-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .math-inspect .live-control-head {
    flex-direction: row;
    align-items: center;
  }

  .math-inspect .live-control-head input {
    width: 140px;
  }
}

@media (max-width: 380px) {
  .math-view-fields {
    grid-template-columns: 1fr;
  }
}
