@media screen, print {
  body {
    --inline-title-margin-bottom: 1em;
    --heading-spacing: 2em;
    --p-spacing: 1.75rem;
    --list-spacing: 0.2em;
    --line-height-normal: 1.6;

    --file-margins-block: 32px;
    --file-margins-inline: 32px;
    --file-margins: var(--file-margins-block) var(--file-margins-inline);

    --italic-weight: var(--font-medium);

    --h1-font: var(--font-text-override), InstrumentSerif;
    --h2-font: var(--font-text-override), InstrumentSerif;
    --h3-font: var(--font-text-override), InstrumentSerif;
    --h4-font: var(--font-text-override), InstrumentSerif;
    --h5-font: var(--font-text-override), InstrumentSerif;
    --h6-font: var(--font-text-override), InstrumentSerif;

    --h5-color: var(--text-faint);
    --h6-color: var(--text-faint);

    --code-border-width: 1px;
    --code-size: var(--font-smallest);
    --code-normal: var(--text-muted);
    --code-comment: var(--text-faint);
    --code-function: var(--color-orange);
    --code-important: var(--color-orange);
    --code-keyword: var(--color-red);
    --code-property: var(--color-blue);
    --code-punctuation: var(--text-muted);
    --code-string: var(--color-cyan);
    --code-tag: var(--color-red);
    --code-value: var(--color-purple);

    --embed-padding: 0 0 0 16px;
    --embed-max-height: none;
    --embed-background: var(--background-primary-alt);
    --embed-border-start: var(--embed-border-thickness, 2px) solid var(--embed-border-color, var(--color-base-50));

    --media-radius: var(--radius-s);

    --metadata-gap: 8px;

    --tag-padding-x: 8px;
    --tag-padding-y: 4px;
    --tag-radius: 8px;
    --tag-weight: var(--font-medium);

    --link-decoration: none;
    --link-external-decoration: none;

    --indentation-guide-width: 0px;

    --file-header-border: none;
  }

  p > em,
  .cm-line > .cm-em {
    font-weight: var(--italic-weight);
  }
  .workspace-split.mod-root {
    background-color: var(--background-secondary);
    transition: var(--anim-duration-moderate);
  }

  .workspace-split.mod-root .workspace-tab-container {
    border-radius: var(--tab-radius);
    transition: var(--anim-duration-moderate);
    overflow: hidden !important;
  }

  // Readable spacing
  .readable-spacing {
    --heading-spacing: var(--p-spacing);
    --p-spacing-empty: var(--list-spacing);
    --h1-line-height: var(--line-height-normal);
    --h2-line-height: var(--line-height-normal);
    --h3-line-height: var(--line-height-normal);
    --h4-line-height: var(--line-height-normal);
    --readable-spacing-modifier: 0.25;

    .markdown-rendered div:is(.el-h1, .el-h2, .el-h3, .el-h4, .el-h5, .el-h6) > :is(h1, h2, h3, h4, h5, h6),
    .markdown-rendered div.el-p:has(+ div:is(.el-ul, .el-ol)) > p {
      margin-block-end: calc(var(--p-spacing) * var(--readable-spacing-modifier));
    }
    .markdown-rendered div.el-h1 + div > *:not(hr),
    .markdown-rendered div.el-h2 + div > *:not(hr, h1),
    .markdown-rendered div.el-h3 + div > *:not(hr, h1, h2),
    .markdown-rendered div.el-h4 + div > *:not(hr, h1, h2, h3),
    .markdown-rendered div.el-h5 + div > *:not(hr, h1, h2, h3, h4),
    .markdown-rendered div.el-h6 + div > *:not(hr, h1, h2, h3, h4, h5),
    .markdown-rendered div.el-p + div:is(.el-ul, .el-ol) > * {
      margin-block-start: calc(var(--p-spacing) * var(--readable-spacing-modifier));
    }
  }

  // Tab title bar
  .view-header {
    padding: 0 8px;
    flex-shrink: 0;
  }
  .view-header-nav-buttons,
  .view-actions {
    --icon-size: var(--icon-m);
    gap: 0 !important;
  }
  .view-header-title-container {
    height: auto !important;
  }
  .view-header-title-container > div {
    transition: var(--anim-duration-moderate) var(--anim-motion-baseline);
  }
  .view-header-title-parent {
    color: var(--text-faint);
  }
  body:not(.is-mobile, .view-header-title-always) .view-header:not(.view-header-always-show):not(:hover) .view-header-title-container > div:not(:focus-within) {
    opacity: 0 !important;
  }
  body:not(.is-mobile).view-header-title-hidden .view-header-title-container > div {
    visibility: hidden;
  }

  // Active line
  body.active-line-side .markdown-source-view .cm-line.cm-active:not(:has(.cm-fold-indicator):hover)::after {
    position: absolute;
    top: 4px;
    bottom: 4px;
    inset-inline-start: -16px;
    border-left: 4px solid var(--background-modifier-border-hover);
    border-radius: var(--input-radius);
    content: "";
  }
  body.active-line-block .markdown-source-view {
    .cm-line.cm-active:not(.cm-gutterElement, .HyperMD-callout, .HyperMD-codeblock-bg, .HyperMD-quote)::after {
      position: absolute;
      inset: -2px -4px;
      background: var(--background-secondary);
      content: "";
      z-index: -2;
      border-radius: var(--radius-s);
    }
    .cm-line.cm-active:is(.HyperMD-callout, .HyperMD-codeblock-bg, .HyperMD-quote) {
      background-color: var(--background-modifier-hover) !important;
    }
  }
  body.active-line-background .markdown-source-view {
    .cm-line.cm-active:not(.cm-gutterElement)::after {
      position: absolute;
      inset: -2px -100%;
      background: var(--background-secondary);
      content: "";
      z-index: -2;
    }
    .cm-line.cm-active:is(.HyperMD-callout, .HyperMD-codeblock-bg, .HyperMD-quote) {
      background-color: var(--background-modifier-hover) !important;

      &::after {
        inset: 0 -100%;
      }
    }
  }
  body.active-line-color-accent.active-line-side .markdown-source-view .cm-line.cm-active:not(:has(.cm-fold-indicator):hover)::after {
    border-color: var(--color-accent);
  }
  body.active-line-color-accent:is(.active-line-block, .active-line-background) .markdown-source-view .cm-line.cm-active::after {
    background-color: var(--background-modifier-active-hover);
  }

  // Codeblocks
  .markdown-rendered code {
    padding: 2px 4px;
  }

  .markdown-rendered pre code {
    white-space: var(--code-white-space);
  }

  body.code-tactile {
    .markdown-rendered pre {
      background: linear-gradient(var(--background-primary-alt), var(--background-secondary));
      box-shadow: var(--shadow-tactile);
    }
  }

  body.code-scroll {
    --code-white-space: pre;

    .HyperMD-codeblock {
      overflow-y: scroll;
      white-space: pre;
    }
  }

  body.code-line-numbers .HyperMD-codeblock-begin {
    counter-reset: codeblock-line-numbers;
  }
  body.code-line-numbers .HyperMD-codeblock:not(.HyperMD-codeblock-begin, .HyperMD-codeblock-end)::before {
    counter-increment: codeblock-line-numbers;
    content: counter(codeblock-line-numbers);
    font-size: var(--font-smallest);
    text-align: right;
    color: var(--text-muted);
    padding-right: 1em;
  }

  kbd {
    box-shadow: var(--shadow-tactile);
    border: 1px solid var(--background-modifier-border);
    background: linear-gradient(var(--background-primary), var(--background-secondary));
    padding: var(--tag-padding-y) var(--tag-padding-x);
    font-family: var(--font-text);
  }

  // Dataview
  .dataview .inline-field-standalone-value,
  body .dataview.inline-field-key,
  body .dataview.inline-field-value {
    font-family: var(--font-text);
    font-size: var(--font-smaller);
    background: transparent;
    color: var(--text-faint);
    padding: 0;
  }

  // Embeds
  .embed-strict {
    --embed-border-start: none;
    --embed-padding: 0;
  }
  .embed-block {
    --embed-background: var(--background-primary-alt);
    --embed-border-start: none;
    --embed-padding: 16px;
  }
  .embed-hide-title .embed-title {
    display: none;
  }

  .markdown-embed:not(.image-embed, .canvas-node-content) {
    display: flex;
    flex-direction: column;
    max-height: var(--embed-max-height);
    overflow: hidden;
    border-start-end-radius: var(--media-radius);
    border-end-end-radius: var(--media-radius);
  }
  .inline-embed > .markdown-embed-title {
    padding: 16px;
  }
  .inline-embed > .markdown-embed-content {
    max-height: 100%;
  }

  iframe.external-embed {
    width: -webkit-fill-available;
    aspect-ratio: 16/9;
    height: auto;
    border-radius: var(--media-radius);
  }
  .block-language-chart {
    width: 100% !important;
  }

  // Headings
  .markdown-rendered h1,
  .HyperMD-header-1,
  .HyperMD-list-line .cm-header-1 {
    text-transform: var(--h1-transform);
  }
  .markdown-rendered h2,
  .HyperMD-header-2,
  .HyperMD-list-line .cm-header-2 {
    text-transform: var(--h2-transform);
  }
  .markdown-rendered h3,
  .HyperMD-header-3,
  .HyperMD-list-line .cm-header-3 {
    text-transform: var(--h3-transform);
  }
  .markdown-rendered h4,
  .HyperMD-header-4,
  .HyperMD-list-line .cm-header-4 {
    text-transform: var(--h4-transform);
  }
  .markdown-rendered h5,
  .HyperMD-header-5,
  .HyperMD-list-line .cm-header-5 {
    text-transform: var(--h5-transform);
  }
  .markdown-rendered h6,
  .HyperMD-header-6,
  .HyperMD-list-line .cm-header-6 {
    text-transform: var(--h6-transform, uppercase);
  }

  .inline-title:not([data-level]),
  .markdown-rendered :is(h1, h2, h3, h4, h5, h6),
  .HyperMD-header-1,
  .HyperMD-header-2,
  .HyperMD-header-3,
  .HyperMD-header-4,
  .HyperMD-header-5,
  .HyperMD-header-6 {
    letter-spacing: normal !important;
  }

  // Highlights
  .markdown-reading-view mark,
  .markdown-source-view mark,
  .markdown-rendered mark {
    box-decoration-break: clone;
    border-radius: var(--radius-s);
    padding: 2px 4px;
    color: var(--text-highlight, var(--text-normal));
    font-weight: var(--font-medium);
  }

  .cm-s-obsidian span.cm-highlight {
    box-decoration-break: clone;
    padding-block: 2px;
  }
  .cm-line .cm-highlight:nth-child(1 of .cm-highlight) {
    border-top-left-radius: var(--radius-s);
    border-bottom-left-radius: var(--radius-s);
    padding-left: 4px;
  }
  .cm-line .cm-highlight:nth-last-child(1 of .cm-highlight) {
    border-top-right-radius: var(--radius-s);
    border-bottom-right-radius: var(--radius-s);
    padding-right: 4px;
  }

  // Media
  img:not(.link-favicon),
  iframe,
  video {
    border-radius: var(--media-radius);
  }

  iframe {
    aspect-ratio: 16/9;
    height: auto;
  }

  body:not(.full-width-media-off) .workspace-leaf-content[data-type="markdown"] {
    :is(img:not([width], .cm-widgetBuffer, .link-favicon, .emoji), iframe, video) {
      width: 100%;
      border-radius: var(--media-radius);
    }
  }

  body.theme-dark {
    .workspace-leaf-content[data-type="markdown"] :is(img:not([width], .cm-widgetBuffer, .link-favicon, .emoji), iframe, video),
    .workspace-leaf-content[data-type="bases"] .bases-cards-cover {
      transition: var(--anim-duration-moderate);

      &:not(:hover) {
        opacity: var(--media-muted, 1);
      }
    }
  }

  // Image grid
  .img-grid .markdown-preview-section {
    .el-p > p:has(> .image-embed),
    .el-p > p:has(> img) {
      --p-spacing: 4px;
      display: flex;
      gap: 4px;

      line-height: 0;

      br {
        display: none;
      }

      > img,
      > .image-embed {
        flex: 1;
        object-fit: cover;
      }

      img {
        height: -webkit-fill-available;
        overflow: auto;
        object-fit: cover;
      }
    }
  }

  // Tags
  body.unstyled-tags {
    --tag-background: transparent;
    --tag-background-hover: transparent;
    --tag-border-width: 0px;
    --tag-padding-x: 0;
    --tag-padding-y: 0;
    --tag-size: inherit;
    --tag-color-hover: var(--text-accent-hover);
  }

  // Tasks
  body.strike-lists-off {
    --checklist-done-decoration: none;
    --checklist-done-color: var(--text-normal);
  }
  .task-list-item {
    --indentation-guide-reading-indent: -1.05em;
  }

  // PDF Viewer
  body.pdf-seamless {
    --pdf-shadow: none;
  }
  body.theme-dark.pdf-invert-dark .pdf-container .pdfViewer .page {
    filter: invert(1) hue-rotate(180deg) contrast(0.75);
  }
  .pdf-container .pdfViewer .page {
    transition-duration: var(--anim-duration-moderate);
    transition-property: filter, opacity;
    &:not(:hover) {
      opacity: var(--pdf-muted, 1);
    }
  }
}
