/* Keep long equations inside their own scroll area on narrow screens. */
.md-typeset div.arithmatex {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.25rem;
}

.md-typeset .diagram {
  max-width: 100%;
  overflow-x: auto;
}

.md-typeset .diagram .mermaid {
  min-width: 32rem;
  text-align: center;
}

.md-typeset .mermaid svg {
  height: auto;
}

/* Long schema detail stays available without dominating the reading route. */
.md-typeset details.reference-definition {
  font-size: inherit;
  border-color: var(--md-default-fg-color--lighter);
}

.md-typeset details.reference-definition > summary {
  background-color: var(--md-default-fg-color--lightest);
}

.md-typeset table td:first-child code {
  white-space: nowrap;
}

.md-typeset .reference-definition [id] {
  scroll-margin-top: 4rem;
}

.md-typeset .reference-tables td:last-child {
  min-width: 12rem;
}

/* Result media stays readable at the article width and never starts itself. */
.md-typeset .result-motion {
  margin: 1.25rem 0;
  max-width: 100%;
}

.md-typeset .result-motion video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.3rem;
}

.md-typeset .result-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-block: 1.25rem;
}

.md-typeset .result-pair figure {
  margin: 0;
  min-width: 0;
}

.md-typeset .result-pair img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 40rem) {
  .md-typeset .result-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Keep chart labels legible; narrow readers can scroll or open the vector file. */
.md-typeset .result-chart {
  max-width: 100%;
  overflow-x: auto;
  margin-block: 1rem 0.5rem;
}

.md-typeset .result-chart img {
  display: block;
  width: 100%;
  min-width: 40rem;
  max-width: none;
  height: auto;
}

/* Wide result screenshots keep readable labels when the article becomes narrow. */
.md-typeset .console-figure {
  max-width: 100%;
  overflow-x: auto;
  margin-block: 1rem 0.5rem;
}

.md-typeset .console-figure p {
  margin: 0;
}

.md-typeset .console-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.md-typeset .console-figure--agent {
  max-width: min(100%, 30rem);
}

@media (max-width: 40rem) {
  .md-typeset .console-figure img {
    min-width: 48rem;
    max-width: none;
  }

  .md-typeset .console-figure--agent img {
    min-width: 28rem;
  }
}
