/* ============================================
   AI RENDER CSS — Styling for Markdown + LaTeX
   rendered inside AI bubbles and question cards.
   ============================================ */

/* ── Paragraphs ── */
.ai-bubble-content p,
.qc-rendered p {
  margin: 0 0 0.55em;
  line-height: 1.65;
}
.ai-bubble-content p:last-child,
.qc-rendered p:last-child {
  margin-bottom: 0;
}

/* ── Headings inside bubbles ── */
.ai-bubble-content h1,
.ai-bubble-content h2,
.ai-bubble-content h3,
.ai-bubble-content h4,
.qc-rendered h1,
.qc-rendered h2,
.qc-rendered h3 {
  font-family: var(--font-heading);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin: 0.8em 0 0.35em;
  line-height: 1.3;
}
.ai-bubble-content h1, .qc-rendered h1 { font-size: 1.15em; }
.ai-bubble-content h2, .qc-rendered h2 { font-size: 1.05em; }
.ai-bubble-content h3, .qc-rendered h3 { font-size: 0.97em; }

/* ── Blockquote ── */
.ai-bubble-content blockquote,
.qc-rendered blockquote {
  margin: 0.6em 0;
  padding: 8px 14px;
  border-left: 3px solid rgba(var(--primary-rgb), 0.5);
  background: rgba(var(--primary-rgb), 0.05);
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.95em;
  line-height: 1.6;
}
.ai-bubble-content blockquote p,
.qc-rendered blockquote p {
  margin: 0;
}

/* ── Inline code ── */
.ai-bubble-content code,
.qc-rendered code {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.875em;
  background: rgba(var(--primary-rgb), 0.08);
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--primary-text, var(--primary));
  word-break: break-word;
}

/* ── Code blocks ── */
.ai-bubble-content pre,
.qc-rendered pre {
  background: var(--surface-2, rgba(0,0,0,0.12));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.6em 0;
  font-size: 0.85em;
  line-height: 1.5;
}
.ai-bubble-content pre code,
.qc-rendered pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* ── Lists ── */
.ai-bubble-content ul,
.ai-bubble-content ol,
.qc-rendered ul,
.qc-rendered ol {
  padding-left: 1.4em;
  margin: 0.4em 0 0.55em;
}
.ai-bubble-content li,
.qc-rendered li {
  margin-bottom: 0.25em;
  line-height: 1.6;
}
.ai-bubble-content ul li::marker,
.qc-rendered ul li::marker {
  color: var(--primary);
}

/* ── Bold & italic ── */
.ai-bubble-content strong,
.qc-rendered strong {
  font-weight: var(--font-semibold, 600);
  color: var(--text);
}
.ai-bubble-content em,
.qc-rendered em {
  font-style: italic;
  color: var(--text);
}

/* ── Horizontal rule ── */
.ai-bubble-content hr,
.qc-rendered hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.8em 0;
}

/* ── Tables ── */
.ai-bubble-content table,
.qc-rendered table {
  border-collapse: collapse;
  font-size: 0.9em;
  width: 100%;
  margin: 0.6em 0;
  overflow-x: auto;
  display: block;
}
.ai-bubble-content th,
.ai-bubble-content td,
.qc-rendered th,
.qc-rendered td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.ai-bubble-content th,
.qc-rendered th {
  background: rgba(var(--primary-rgb), 0.07);
  font-weight: var(--font-semibold, 600);
  color: var(--text);
}

/* ── KaTeX inline ──
   Inline math (subscripts, fractions in-line) needs to read with the same
   visual weight as surrounding text. KaTeX defaults to 1.21em internally,
   we keep that scale but ensure the wrapper inherits color cleanly. ── */
.ai-bubble-content .katex,
.qc-rendered .katex {
  color: inherit;
  font-size: 1.15em;
}

/* ── KaTeX display (block) ──
   Display formulas (\\[...\\], double-$$) get a noticeable size bump so
   stacked fractions, large radicals and subscripts stay legible. ── */
.ai-bubble-content .katex-display,
.qc-rendered .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
  margin: 0.5em 0;
  text-align: center;
}
.ai-bubble-content .katex-display > .katex,
.qc-rendered .katex-display > .katex {
  font-size: 1.38em;
}

/* ── KaTeX: hide the MathML accessibility twin so it isn't shown as text ── */
.ai-bubble-content .katex-mathml,
.qc-rendered .katex-mathml,
.katex .katex-mathml {
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* ── KaTeX HTML: KEEP default nowrap so symbols stay on one line.
      Do NOT override to white-space: normal — that breaks math rendering. ── */
