'Exporting Markdown to PDF in Obsidian.md: How do I retain highlight colors in PDF?

I'm using Obsidian.md and have created a css snippet that lets me utilize a combination of **bold**, *italics* and ==highlights== to create three different colors; see image.

Markdown Colors

Markdown Colors

However, these colors are lost when I export the file to PDF, since the snippet doesn't govern that; I think it has to do with css printing, but I'm not sure. In the PDF it would look like this: PDF Colors

Would anyone here be able to help me figure out, how to have the colors appear the same in markdown and in PDF?

I'll share a part of the snippet below. This is for the red color, which is created by combining italics/asterisks and highlights/equal signs:

:root
{
  --highlight-lred: #f0a6a6;
  --highlight-dred: #c08484;

}

/* Red Highlight */


span.cm-em.cm-highlight {
    font-style: unset !important; 
    background-color: var(--highlight-red);
    color: #222;
}

body > .app-container div.markdown-preview-view em > mark {
    /*font-style: initial !important; */
    background-color: var(--highlight-red);
    color: #222;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source