.markdown {
  color: var(--chat-md-text);
  font-size: 0.95rem;
  line-height: 1.75;
  word-break: break-word;
}

.markdown p {
  margin: 0;
  white-space: pre-wrap;
}

.markdown p + p {
  margin-top: 0.75rem;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin: 0.6rem 0;
  line-height: 1.35;
  font-weight: 700;
  color: var(--chat-md-heading);
}

.markdown h1 { font-size: 1.2rem; }
.markdown h2 { font-size: 1.12rem; }
.markdown h3 { font-size: 1.04rem; }

.markdown a {
  color: var(--chat-md-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.markdown a:hover {
  color: var(--chat-md-link-hover);
}

.markdown :not(pre) > code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--chat-md-inline-code-bg);
  border: 1px solid var(--chat-md-inline-code-border);
  color: var(--chat-md-inline-code-text);
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  font-size: 0.85em;
}

.markdown pre {
  background: var(--chat-md-pre-bg);
  border: 1px solid var(--chat-md-pre-border);
  color: var(--chat-md-pre-text);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  margin: 0.9rem 0;
  font-size: 0.88em;
}

.markdown pre code {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown ul,
.markdown ol {
  padding-left: 1.4rem;
  margin: 0.5rem 0;
}

.markdown li {
  margin: 0.3rem 0;
  line-height: 1.65;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88em;
  border: 1px solid var(--chat-md-inline-code-border);
  overflow: hidden;
  border-radius: 8px;
}

.markdown th,
.markdown td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--chat-md-inline-code-border);
  text-align: left;
}

.markdown th {
  background-color: var(--chat-md-inline-code-bg);
  font-weight: 700;
  color: var(--chat-md-heading);
}

.markdown tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

.markdown blockquote {
  margin: 0.8rem 0;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid var(--chat-md-quote-border);
  background: var(--chat-md-quote-bg);
  color: var(--chat-md-quote-text);
  border-radius: 6px;
}

.streamFade {
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
