/* ── KaTeX math rendering ─────────────────────────────────────────────────── */

/* Display-mode math gets its own centred block with breathing room */
.msg-assistant .katex-display,
.msg-user .katex-display {
  margin: 0.75em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* KaTeX inherits the message text colour so it matches the dark theme */
.msg-assistant .katex,
.msg-user .katex {
  color: inherit;
  font-size: 1.05em;
}

/* Fallback for math that failed to parse */
code.math-error {
  color: oklch(var(--er));
  font-size: 0.85em;
}

/* Markdown tables */
.msg-assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.9em;
  border: 1px solid oklch(var(--b3));
}

.msg-assistant th,
.msg-assistant td {
  padding: 0.5em 0.75em;
  text-align: left;
}

.msg-assistant th {
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
  border-bottom: 2px solid oklch(var(--p) / 30%);
  border-right: 1px solid oklch(var(--b3) / 40%);
}

.msg-assistant td {
  border-bottom: 1px solid oklch(var(--b3) / 30%);
  border-right: 1px solid oklch(var(--b3) / 40%);
}

.msg-assistant th:last-child {
  border-right: none;
}

.msg-assistant td:last-child {
  border-right: none;
}

.msg-assistant tr:last-child td {
  border-bottom: none;
}

.msg-assistant tr:hover td {
  background: rgba(0, 0, 0, 0.10);
}

/* Markdown tables in user messages - inherit assistant styling */
.msg-user table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.9em;
  border: 1px solid oklch(var(--b3));
}

.msg-user th,
.msg-user td {
  padding: 0.5em 0.75em;
  text-align: left;
}

.msg-user th {
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
  border-bottom: 2px solid oklch(var(--p) / 30%);
  border-right: 1px solid oklch(var(--b3) / 40%);
}

.msg-user td {
  border-bottom: 1px solid oklch(var(--b3) / 30%);
  border-right: 1px solid oklch(var(--b3) / 40%);
}

.msg-user th:last-child,
.msg-user td:last-child {
  border-right: none;
}

.msg-user tr:last-child td {
  border-bottom: none;
}

/* Inline code */
.msg-assistant :not(pre) > code {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.875em;
}
