/* Markdown content styles */
.markdown-content {
  line-height: 1.6;
  color: var(--foreground);
}

/* Headings */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
}

.markdown-content h1 { font-size: 2em; }
.markdown-content h2 { font-size: 1.5em; }
.markdown-content h3 { font-size: 1.25em; }
.markdown-content h4 { font-size: 1em; }
.markdown-content h5 { font-size: 0.875em; }
.markdown-content h6 { font-size: 0.85em; }

/* Paragraphs and lists */
.markdown-content p,
.markdown-content ul,
.markdown-content ol {
  margin-bottom: 1em;
}

/* Lists */
.markdown-content ul,
.markdown-content ol {
  padding-left: 2em;
}

.markdown-content li {
  margin-bottom: 0.5em;
}

/* Blockquotes */
.markdown-content blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  margin-left: 0;
  margin-bottom: 1em;
  font-style: italic;
  color: var(--muted-foreground);
}

/* Ensure all content wraps properly */
.markdown-content * {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

/* Code blocks */
.markdown-content pre {
  background-color: var(--muted);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1em;
  white-space: pre-wrap;       /* CSS 3 */
  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
  white-space: -pre-wrap;      /* Opera 4-6 */
  white-space: -o-pre-wrap;    /* Opera 7 */
  word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

.markdown-content code {
  font-family: monospace;
  font-size: 0.9em;
  background-color: var(--muted);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  color: var(--foreground);  /* Add this line to ensure text color matches the rest of the content */
}

/* Inline code */
.markdown-content p code,
.markdown-content li code {
  background-color: var(--muted);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

/* Horizontal rule */
.markdown-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* Links */
.markdown-content a {
  color: var(--primary);
  text-decoration: underline;
}

.markdown-content a:hover {
  text-decoration: none;
}

/* Images */
.markdown-content img {
  max-width: 100%;
  height: auto;
  margin-bottom: 1em;
}

/* Tables */
.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
  table-layout: fixed;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--border);
  padding: 0.5em;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.markdown-content th {
  background-color: var(--muted);
  font-weight: bold;
}

/* LaTeX-style equations */
.markdown-content .math-inline {
  display: inline-block;
  font-family: 'KaTeX_Main', 'Times New Roman', serif;
  font-size: 1.1em;
  line-height: 1.2;
  white-space: nowrap;
  padding: 0 0.2em;
}

.markdown-content .math-display {
  display: block;
  font-family: 'KaTeX_Main', 'Times New Roman', serif;
  font-size: 1.1em;
  line-height: 1.2;
  text-align: center;
  padding: 0.5em 0;
  overflow-x: auto;
  max-width: 100%;
}

/* Brackets */
.markdown-content .math-inline .bracket,
.markdown-content .math-display .bracket {
  font-size: 1.2em;
  vertical-align: middle;
}

/* Fractions */
.markdown-content .math-inline .fraction,
.markdown-content .math-display .fraction {
  display: inline-block;
  vertical-align: middle;
  text-align: center;
}

.markdown-content .math-inline .fraction .numerator,
.markdown-content .math-display .fraction .numerator {
  display: block;
  padding-bottom: 0.15em;
  border-bottom: 1px solid;
}

.markdown-content .math-inline .fraction .denominator,
.markdown-content .math-display .fraction .denominator {
  display: block;
  padding-top: 0.15em;
}

/* Subscripts and superscripts */
.markdown-content .math-inline sub,
.markdown-content .math-display sub,
.markdown-content .math-inline sup,
.markdown-content .math-display sup {
  font-size: 0.8em;
}

/* Improve readability for inline code and math */
.markdown-content p code,
.markdown-content li code,
.markdown-content .math-inline {
  background-color: var(--muted);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

/* Ensure proper spacing for lists with equations */
.markdown-content li {
  margin-bottom: 1em;
}

/* Improve spacing for equation-heavy content */
.markdown-content p,
.markdown-content .math-display {
  margin-bottom: 1.5em;
}