/* === Streamdown Typography ===
 * Clean, modern markdown rendering styles.
 * Applied to .streamdown-root and [data-pre-mounted] containers.
 */

.streamdown-root,
[data-pre-mounted] {
  /* Base text */
  font-size: 0.875rem;
  line-height: 1.75;
  color: hsl(var(--foreground, 224 71% 4%));
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* === Headings === */

.streamdown-root h1,
[data-pre-mounted] h1,
.streamdown-root h2,
[data-pre-mounted] h2,
.streamdown-root h3,
[data-pre-mounted] h3,
.streamdown-root h4,
[data-pre-mounted] h4,
.streamdown-root h5,
[data-pre-mounted] h5,
.streamdown-root h6,
[data-pre-mounted] h6 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground, 224 71% 4%));
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.streamdown-root h1:first-child,
[data-pre-mounted] h1:first-child,
.streamdown-root h2:first-child,
[data-pre-mounted] h2:first-child,
.streamdown-root h3:first-child,
[data-pre-mounted] h3:first-child,
.streamdown-root h4:first-child,
[data-pre-mounted] h4:first-child {
  margin-top: 0;
}

.streamdown-root h1,
[data-pre-mounted] h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.streamdown-root h2,
[data-pre-mounted] h2 {
  font-size: 1.25rem;
  font-weight: 650;
  padding-bottom: 0.25em;
  border-bottom: 1px solid hsl(var(--border, 220 13% 91%) / 0.5);
}

.streamdown-root h3,
[data-pre-mounted] h3 {
  font-size: 1.1rem;
}

.streamdown-root h4,
[data-pre-mounted] h4 {
  font-size: 1rem;
}

.streamdown-root h5,
[data-pre-mounted] h5,
.streamdown-root h6,
[data-pre-mounted] h6 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

/* === Paragraphs === */

.streamdown-root p,
[data-pre-mounted] p {
  margin: 0.625em 0;
}

.streamdown-root p:first-child,
[data-pre-mounted] p:first-child {
  margin-top: 0;
}

.streamdown-root p:last-child,
[data-pre-mounted] p:last-child {
  margin-bottom: 0;
}

/* === Links === */

.streamdown-root a,
[data-pre-mounted] a {
  color: hsl(var(--primary, 221 83% 53%));
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease;
}

.streamdown-root a:hover,
[data-pre-mounted] a:hover {
  border-bottom-color: hsl(var(--primary, 221 83% 53%) / 0.5);
}

/* === Bold / Italic === */

.streamdown-root strong,
[data-pre-mounted] strong {
  font-weight: 650;
  color: hsl(var(--foreground, 224 71% 4%));
}

.streamdown-root em,
[data-pre-mounted] em {
  font-style: italic;
}

/* === Lists === */

.streamdown-root ul,
[data-pre-mounted] ul,
.streamdown-root ol,
[data-pre-mounted] ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.streamdown-root ul,
[data-pre-mounted] ul {
  list-style-type: disc;
}

.streamdown-root ol,
[data-pre-mounted] ol {
  list-style-type: decimal;
}

.streamdown-root li,
[data-pre-mounted] li {
  margin: 0.25em 0;
  padding-left: 0.25em;
}

.streamdown-root li > p,
[data-pre-mounted] li > p {
  margin: 0.25em 0;
}

/* Nested lists */
.streamdown-root ul ul,
[data-pre-mounted] ul ul {
  list-style-type: circle;
}

.streamdown-root ul ul ul,
[data-pre-mounted] ul ul ul {
  list-style-type: square;
}

/* Task lists (GFM) */
.streamdown-root li.task-list-item,
[data-pre-mounted] li.task-list-item {
  list-style-type: none;
  margin-left: -1.25em;
}

.streamdown-root li.task-list-item input[type="checkbox"],
[data-pre-mounted] li.task-list-item input[type="checkbox"] {
  margin-right: 0.5em;
  vertical-align: middle;
  accent-color: hsl(var(--primary, 221 83% 53%));
}

/* === Blockquotes === */

.streamdown-root blockquote,
[data-pre-mounted] blockquote {
  margin: 0.75em 0;
  padding: 0.5em 1em;
  border-left: 3px solid hsl(var(--primary, 221 83% 53%) / 0.4);
  background: hsl(var(--muted, 220 14% 96%) / 0.3);
  border-radius: 0 0.375rem 0.375rem 0;
  color: hsl(var(--muted-foreground, 220 9% 46%));
}

.streamdown-root blockquote p,
[data-pre-mounted] blockquote p {
  margin: 0.25em 0;
}

.streamdown-root blockquote blockquote,
[data-pre-mounted] blockquote blockquote {
  border-left-color: hsl(var(--muted-foreground, 220 9% 46%) / 0.3);
}

/* === Horizontal Rule === */

.streamdown-root hr,
[data-pre-mounted] hr {
  margin: 1.5em 0;
  border: none;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    hsl(var(--border, 220 13% 91%)),
    transparent
  );
}

/* === Tables === */

.streamdown-root table,
[data-pre-mounted] table {
  width: 100%;
  margin: 0.75em 0;
  border-collapse: collapse;
  font-size: 0.8125rem;
  overflow-x: auto;
  display: block;
}

.streamdown-root thead,
[data-pre-mounted] thead {
  border-bottom: 2px solid hsl(var(--border, 220 13% 91%));
}

.streamdown-root th,
[data-pre-mounted] th {
  padding: 0.5em 0.75em;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground, 220 9% 46%));
}

.streamdown-root td,
[data-pre-mounted] td {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid hsl(var(--border, 220 13% 91%) / 0.5);
}

.streamdown-root tbody tr:last-child td,
[data-pre-mounted] tbody tr:last-child td {
  border-bottom: none;
}

.streamdown-root tbody tr:hover,
[data-pre-mounted] tbody tr:hover {
  background: hsl(var(--muted, 220 14% 96%) / 0.3);
}

/* === Images === */

.streamdown-root img,
[data-pre-mounted] img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.75em 0;
}

/* === KaTeX Math === */

.streamdown-root .katex-display,
[data-pre-mounted] .katex-display {
  margin: 0.75em 0;
  overflow-x: auto;
  padding: 0.5em 0;
}

.streamdown-root .katex,
[data-pre-mounted] .katex {
  font-size: 1em;
}

/* === Footnotes === */

.streamdown-root .footnotes,
[data-pre-mounted] .footnotes {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid hsl(var(--border, 220 13% 91%) / 0.5);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground, 220 9% 46%));
}

/* === Details/Summary === */

.streamdown-root details,
[data-pre-mounted] details {
  margin: 0.75em 0;
  padding: 0.5em 0.75em;
  border: 1px solid hsl(var(--border, 220 13% 91%) / 0.6);
  border-radius: 0.375rem;
  background: hsl(var(--muted, 220 14% 96%) / 0.2);
}

.streamdown-root summary,
[data-pre-mounted] summary {
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}

.streamdown-root details[open] > summary,
[data-pre-mounted] details[open] > summary {
  margin-bottom: 0.5em;
}

/* === Spacing between adjacent elements === */

.streamdown-root > * + *,
[data-pre-mounted] > * + * {
  margin-top: 0.5em;
}

.streamdown-root > * + h1,
[data-pre-mounted] > * + h1,
.streamdown-root > * + h2,
[data-pre-mounted] > * + h2,
.streamdown-root > * + h3,
[data-pre-mounted] > * + h3 {
  margin-top: 1.5em;
}
