@layer base {
  [data-slot="prose"] > :where(* + *) {
    margin-block-start: var(--destack-space-4);
  }

  [data-slot="prose"] > :where(* + h1, * + h2, * + h3, * + h4) {
    margin-block-start: var(--destack-space-7);
  }

  [data-slot="prose"] :where(h1, h2, h3, h4) {
    color: var(--destack-color-foreground);
    text-wrap: balance;
    margin-block-end: 0;
  }

  [data-slot="prose"] :where(h1) {
    font-family: var(--destack-text-2xl-font-family);
    font-size: var(--destack-text-2xl-font-size);
    font-weight: var(--destack-text-2xl-font-weight);
    line-height: var(--destack-text-2xl-line-height);
    letter-spacing: var(--destack-text-2xl-letter-spacing);
  }

  [data-slot="prose"] :where(h2) {
    font-family: var(--destack-text-xl-font-family);
    font-size: var(--destack-text-xl-font-size);
    font-weight: var(--destack-text-xl-font-weight);
    line-height: var(--destack-text-xl-line-height);
    letter-spacing: var(--destack-text-xl-letter-spacing);
  }

  [data-slot="prose"] :where(h3) {
    font-family: var(--destack-text-lg-font-family);
    font-size: var(--destack-text-lg-font-size);
    font-weight: var(--destack-text-lg-font-weight);
    line-height: var(--destack-text-lg-line-height);
    letter-spacing: var(--destack-text-lg-letter-spacing);
  }

  [data-slot="prose"] :where(h4) {
    font-family: var(--destack-text-base-font-family);
    font-size: var(--destack-text-base-font-size);
    font-weight: var(--destack-text-base-font-weight);
    line-height: var(--destack-text-base-line-height);
    letter-spacing: var(--destack-text-base-letter-spacing);
  }

  [data-slot="prose"][data-lead] > :where(p:first-of-type) {
    color: var(--destack-color-muted-foreground);
    font-size: var(--destack-text-lg-font-size);
    line-height: var(--destack-text-lg-line-height);
  }

  [data-slot="prose"] :where(p, li, blockquote, td, th) {
    overflow-wrap: anywhere;
  }

  [data-slot="prose"] :where(a) {
    text-decoration-line: underline;
    -webkit-text-decoration-color: var(--destack-color-primary);
    text-decoration-color: var(--destack-color-primary);
    text-underline-offset: .2em;
    text-decoration-thickness: 1px;
  }

  [data-slot="prose"] :where(a:hover) {
    color: var(--destack-color-primary);
  }

  [data-slot="prose"] :where(ul, ol) {
    gap: var(--destack-space-2);
    margin-block-end: 0;
    padding-inline-start: var(--destack-space-6);
    display: grid;
  }

  [data-slot="prose"] :where(ul) {
    list-style-type: disc;
  }

  [data-slot="prose"] :where(ol) {
    list-style-type: decimal;
  }

  [data-slot="prose"] :where(li)::marker {
    color: var(--destack-color-muted-foreground);
  }

  [data-slot="prose"] :where(li > ul, li > ol), [data-slot="prose"] :where(li > p + p) {
    margin-block-start: var(--destack-space-2);
  }

  [data-slot="prose"] :where(li > input[type="checkbox"]) {
    accent-color: var(--destack-color-primary);
    margin-inline-end: var(--destack-space-2);
  }

  [data-slot="prose"] :where(:not(pre) > code) {
    border-radius: var(--destack-radius-1);
    background-color: var(--destack-color-muted);
    font-family: var(--destack-font-code);
    padding: .1em .35em;
    font-size: .875em;
  }

  [data-slot="prose"] :where(pre) {
    padding: var(--destack-space-4);
    border: var(--destack-stroke-border) solid var(--destack-color-border);
    border-radius: var(--destack-radius-3);
    background-color: var(--destack-color-muted);
    font-family: var(--destack-font-code);
    font-size: var(--destack-text-xs-font-size);
    line-height: var(--destack-text-xs-line-height);
    margin-block-end: 0;
    overflow-x: auto;
  }

  [data-slot="prose"] :where(pre > code) {
    font: inherit;
  }

  [data-slot="prose"] :where(blockquote) {
    border-inline-start: 2px solid var(--destack-color-primary);
    margin-inline: 0;
    padding-inline-start: var(--destack-space-5);
  }

  [data-slot="prose"] :where(blockquote > * + *) {
    margin-block-start: var(--destack-space-3);
  }

  [data-slot="prose"] :where(hr) {
    border: 0;
    border-block-start: var(--destack-stroke-border) solid var(--destack-color-border);
  }

  [data-slot="prose"] :where(table) {
    border-collapse: collapse;
    max-inline-size: 100%;
    font-size: var(--destack-text-sm-font-size);
    line-height: var(--destack-text-sm-line-height);
    display: block;
    overflow-x: auto;
  }

  [data-slot="prose"] :where(th, td) {
    padding: var(--destack-space-2) var(--destack-space-3);
    border-block-end: var(--destack-stroke-border) solid var(--destack-color-border);
    text-align: start;
    vertical-align: top;
  }

  [data-slot="prose"] :where(th) {
    background-color: var(--destack-color-muted);
    font-weight: var(--destack-weight-semibold);
  }

  [data-slot="prose"] :where(img, video) {
    block-size: auto;
    max-inline-size: 100%;
  }

  [data-slot="prose"] :where(figure) {
    margin-inline: 0;
  }

  [data-slot="prose"] :where(figcaption) {
    color: var(--destack-color-muted-foreground);
    font-size: var(--destack-text-xs-font-size);
    line-height: var(--destack-text-xs-line-height);
    margin-block-start: var(--destack-space-3);
  }

  [data-slot="prose"] :where(sup) {
    font-size: .75em;
    line-height: 0;
  }

  [data-slot="prose"] :where(a[data-footnote-ref]) {
    color: var(--destack-color-primary);
    text-decoration-line: none;
  }

  [data-slot="prose"] :where(section[data-footnotes]) {
    border-block-start: var(--destack-stroke-border) solid var(--destack-color-border);
    font-size: var(--destack-text-xs-font-size);
    line-height: var(--destack-text-xs-line-height);
    padding-block-start: var(--destack-space-4);
  }

  [data-slot="prose"] :where(section[data-footnotes] li:target) {
    color: var(--destack-color-primary);
  }

  [data-slot="prose"] :where(.markdown-alert) {
    --prose-alert: var(--destack-color-info);
    padding: var(--destack-space-3) var(--destack-space-4);
    border-inline-start: 3px solid var(--prose-alert);
    border-radius: var(--destack-radius-2);
    background-color: color-mix(in oklab, var(--prose-alert) 8%, transparent);
  }

  [data-slot="prose"] :where(.markdown-alert > * + *) {
    margin-block-start: var(--destack-space-2);
  }

  [data-slot="prose"] :where(.markdown-alert-title) {
    align-items: center;
    gap: var(--destack-space-2);
    color: var(--prose-alert);
    font-weight: var(--destack-weight-semibold);
    display: flex;
  }

  [data-slot="prose"] :where(.markdown-alert-tip) {
    --prose-alert: var(--destack-color-success);
  }

  [data-slot="prose"] :where(.markdown-alert-important) {
    --prose-alert: var(--destack-color-primary);
  }

  [data-slot="prose"] :where(.markdown-alert-warning) {
    --prose-alert: var(--destack-color-warning);
  }

  [data-slot="prose"] :where(.markdown-alert-caution) {
    --prose-alert: var(--destack-color-destructive);
  }

  [data-slot="code-block-content"] :where(.hljs-keyword, .hljs-selector-tag, .hljs-meta) {
    color: var(--destack-color-primary);
  }

  [data-slot="code-block-content"] :where(.hljs-string, .hljs-regexp, .hljs-addition) {
    color: var(--destack-color-success);
  }

  [data-slot="code-block-content"] :where(.hljs-number, .hljs-literal, .hljs-symbol) {
    color: var(--destack-color-warning);
  }

  [data-slot="code-block-content"] :where(.hljs-title, .hljs-type, .hljs-attr, .hljs-variable) {
    color: var(--destack-color-info);
  }

  [data-slot="code-block-content"] :where(.hljs-built_in, .hljs-deletion) {
    color: var(--destack-color-destructive);
  }

  [data-slot="code-block-content"] :where(.hljs-comment, .hljs-quote) {
    color: var(--destack-color-muted-foreground);
    font-style: italic;
  }
}

@view-transition {
  navigation: auto;
}

[data-publication="journal"] [data-slot="prose"] :where(h2) {
  font-family: var(--destack-text-2xl-font-family);
  font-size: var(--destack-text-2xl-font-size);
  font-weight: var(--destack-text-2xl-font-weight);
  line-height: var(--destack-text-2xl-line-height);
  letter-spacing: var(--destack-text-2xl-letter-spacing);
}

[data-publication="journal"] [data-slot="prose"] :where(h3) {
  font-family: var(--destack-text-xl-font-family);
  font-size: var(--destack-text-xl-font-size);
  font-weight: var(--destack-text-xl-font-weight);
  line-height: var(--destack-text-xl-line-height);
  letter-spacing: var(--destack-text-xl-letter-spacing);
}

[data-publication="journal"] [data-slot="prose"] :where(h4) {
  font-family: var(--destack-text-lg-font-family);
  font-size: var(--destack-text-lg-font-size);
  font-weight: var(--destack-text-lg-font-weight);
  line-height: var(--destack-text-lg-line-height);
  letter-spacing: var(--destack-text-lg-letter-spacing);
}
