:root {
  --md-primary-fg-color: #1d4ed8;
  --md-accent-fg-color: #f59e0b;
  --md-code-bg-color: #0f172a;
  --md-typeset-a-color: #38bdf8;
}

/* Give cards/panels a subtle glow in dark mode */
[data-md-color-scheme="slate"] .md-typeset .admonition,
[data-md-color-scheme="slate"] .md-typeset details {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Make code blocks stand out */
.md-typeset code, .md-typeset pre {
  border-radius: 8px;
}

/* Center mermaid diagrams and add breathing room */
.mermaid {
  margin: 1.5rem auto;
  display: block;
}

/* Show table grid lines */
.md-typeset table:not(.highlighttable) {
  border-collapse: collapse;
}
.md-typeset table:not(.highlighttable) th,
.md-typeset table:not(.highlighttable) td {
  border: 1px solid var(--md-typeset-table-color, rgba(255,255,255,0.12));
}

/* Align math in nav links so it sits on the text baseline */
.md-nav__link .mjx-container {
  vertical-align: middle;
}

/* Hero text tweak on home */
.md-content h1 {
  letter-spacing: -0.5px;
}

/* Keep wide math readable on mobile without blowing out the layout */
.md-typeset mjx-container[jax="CHTML"][display="true"],
.md-typeset .MathJax_Display {
  overflow: auto;
  display: block;
  width: auto;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 0.25rem 0.5rem;
  font-size: clamp(0.95rem, 1vw + 0.6rem, 1.15rem);
}

/* Prevent SVG output from collapsing at small widths */
.md-typeset mjx-container[jax="SVG"][display="true"] {
  overflow: auto;
  display: block;
  width: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 0.25rem 0.5rem;
  font-size: clamp(0.95rem, 1vw + 0.6rem, 1.15rem);
}

.md-typeset mjx-container[jax="SVG"][display="true"] svg {
  display: inline-block;
  width: auto;
  max-width: none;
  min-width: 0;
  height: auto;
}

/* On larger screens, let SVG math fit the column instead of stretching wide */
@media (min-width: 900px) {
  .md-typeset mjx-container[jax="SVG"][display="true"] svg {
    width: auto;
    max-width: min(100%, 72ch);
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Avoid MathJax content forcing a min-width inside the scroll area */
.md-typeset mjx-container[jax="CHTML"][display="true"] > mjx-math,
.md-typeset .MathJax_Display > .MathJax {
  display: inline-block;
  min-width: 0;
}

/* Prevent MathJax internal math box from clipping content on small screens */
.md-typeset mjx-container[jax="CHTML"] mjx-math {
  overflow: visible;
}

/* Ensure arithmatex wrapper itself can scroll if present */
.md-typeset .arithmatex {
  overflow: auto;
}

/* Make other wide blocks scroll instead of causing page overflow */
.md-typeset table:not(.highlighttable),
.md-typeset pre,
.md-typeset .mermaid,
.md-typeset .admonition,
.md-typeset details {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
