/* Math owns its font metrics; narrow cards scroll rather than clip equations. */
.tech-card,
.math-appendix-card,
.tech-grid,
.appendix-grid {
  min-width: 0;
}
.math-expression {
  min-width: 0;
  max-width: 100%;
  color: inherit;
}
.math-expression[data-display="inline"] {
  display: inline;
}
.math-expression[data-display="block"] {
  display: block;
  width: 100%;
  padding: 0.3em 0.15em;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  font-size: 0.95rem;
}
.math-expression .katex-display {
  margin: 0.3em 0;
}
.math-expression .katex-display > .katex {
  width: max-content;
  min-width: 100%;
}
.math-expression .katex {
  color: inherit;
  font-style: normal;
}
/* Use upright glyphs while preserving LaTeX sources and structural fonts. */
.math-expression .katex-html .mathnormal,
.math-expression .katex-html .mathit,
.math-expression .katex-html .boldsymbol {
  font-family: KaTeX_Main, "Times New Roman", serif;
  font-style: normal;
}
.math-expression .katex-html .boldsymbol {
  font-weight: 700;
}
.math-expression .katex math {
  font-size: inherit;
  font-style: normal;
  overflow: visible;
}
.formula:has(.math-expression),
.appendix-formula:has(.math-expression) {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}
.formula-text:has(.math-expression) {
  text-align: left;
}
.appendix-list li:has(.math-expression),
.knowledge-result:has(.math-expression) {
  min-width: 0;
  max-width: 100%;
}
.appendix-list .math-expression[data-display="block"] {
  font-size: 0.84rem;
}
.math-source {
  width: 100%;
  min-width: 0;
  margin-top: 0.35rem;
  color: #49605b;
  font-size: 0.72rem;
  font-style: normal;
  line-height: 1.5;
  text-align: left;
}
.math-source > summary {
  width: fit-content;
  padding: 0.1rem 0.25rem;
  cursor: pointer;
}
.math-source > .math-source-code {
  display: block;
  margin: 0.5rem 0;
  padding: 0.65rem;
  border: 1px solid #d4ded8;
  border-radius: 0.3rem;
  background: #fff;
  color: #243d38;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.math-copy {
  padding: 0.35rem 0.6rem;
  border: 1px solid #c5d4cb;
  border-radius: 0.3rem;
  background: #f4f8f5;
  color: #243d38;
  font: inherit;
  cursor: pointer;
}
.math-copy-status {
  margin-left: 0.45rem;
}
.math-context {
  display: block;
  margin-top: 0.4rem;
  color: #49605b;
  font-size: 0.75rem;
  line-height: 1.5;
}
[data-math-error] {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .math-expression[data-display="block"] { font-size: 0.88rem; }
  .appendix-list .math-expression[data-display="block"] { font-size: 0.8rem; }
  .math-expression[data-display="inline"] .katex { font-size: 1em; }
}
@media print {
  .math-source { display: none; }
  .math-expression[data-display="block"] { overflow: visible; }
}
