/* KaTeX Math Styling */
.math-display {
  margin: 1rem 0;
  text-align: center;
}

.math-inline {
  display: inline;
}

/* Error styling for math rendering failures */
.katex-error {
  color: #dc2626;
  font-family: monospace;
  font-size: 0.875em;
  padding: 0.125rem 0.25rem;
  background-color: #fef2f2;
  border-radius: 0.25rem;
  border: 1px solid #fecaca;
}

/* Fallback styling when KaTeX is not available */
.math-fallback {
  font-family: 'Computer Modern', 'Latin Modern Math', 'Times New Roman', serif;
  font-style: italic;
}

.math-display-fallback {
  display: block;
  text-align: center;
  margin: 1rem 0;
  padding: 1rem;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  font-size: 1.125em;
}

.math-inline-fallback {
  display: inline;
  padding: 0.125rem 0.25rem;
  background-color: #f3f4f6;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

/* Custom KaTeX styling overrides */
.katex-display {
  margin: 1rem 0;
  text-align: center;
}

.katex-display > .katex {
  text-align: center;
}

/* Responsive math on mobile */
@media (max-width: 640px) {
  .katex-display {
    font-size: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .katex {
    font-size: 1rem;
  }
  
  .math-display-fallback {
    font-size: 1rem;
    overflow-x: auto;
  }
}