@media print {

  /* OmicsBox brand colors for PDF */
  :root {
    --md-primary-fg-color: #0d204a; /* OmicsBox dark blue */
    --md-accent-fg-color: #0a1a3a; /* Darker blue for accents */
  }

  /* Header styling with OmicsBox dark blue and spacing */
  .md-header,
  .md-typeset h1,
  .md-typeset h2,
  .md-typeset h3,
  .md-typeset h4,
  .md-typeset h5,
  .md-typeset h6 {
    color: #0d204a !important;
    border-bottom: 2px solid #0d204a !important;
  }

  /* Add spacing above h1, h2, h3 headings */
  .md-typeset h1 {
    margin-top: 2rem !important;
    padding-top: 1rem !important;
  }

  .md-typeset h2 {
    margin-top: 1.5rem !important;
    padding-top: 0.8rem !important;
  }

  .md-typeset h3 {
    margin-top: 1.2rem !important;
    padding-top: 0.6rem !important;
  }

  /* Links in OmicsBox dark blue */
  .md-typeset a {
    color: #0d204a !important;
  }

  /* Force any red lines to be dark blue */
  *[style*="border-color: red"],
  *[style*="border-color: #ff0000"],
  *[style*="border-color: #f00"],
  *[style*="color: red"],
  *[style*="color: #ff0000"],
  *[style*="color: #f00"] {
    border-color: #0d204a !important;
    color: #0d204a !important;
  }

  /* Constrain images more aggressively for PDF output */
  img,
  .md-typeset img,
  figure img,
  .md-content img,
  .md-typeset figure > img,
  .md-typeset .admonition img,
  .md-typeset .highlight img,
  .md-typeset table img,
  .md-typeset .grid img,
  .md-typeset .tabbed img {
    width: 40% !important;
    max-width: 40% !important;
    height: auto !important;
    max-height: 50vh !important; /* much smaller max height */
    display: block !important;
    margin: 0.5rem auto !important; /* smaller margins */
    page-break-inside: avoid;
    object-fit: contain !important;
  }

  /* SVGs should also be constrained */
  svg,
  .md-typeset svg,
  figure svg,
  .md-typeset .admonition svg,
  .md-typeset .highlight svg,
  .md-typeset table svg {
    width: 40% !important;
    max-width: 40% !important;
    height: auto !important;
    max-height: 50vh !important;
    display: block !important;
    margin: 0.5rem auto !important;
    page-break-inside: avoid;
  }

  /* Override any inline styles that might force larger sizes */
  img[style*="width"],
  img[style*="height"],
  svg[style*="width"],
  svg[style*="height"] {
    width: 40% !important;
    max-width: 40% !important;
    height: auto !important;
    max-height: 50vh !important;
  }

  /* Keep figures/admonitions intact across pages */
  figure,
  .md-typeset .admonition,
  .md-typeset details {
    break-inside: avoid;
  }

  /* Page setup with increased margins */
  @page {
    size: A4;              /* or 'Letter' */
    margin: 20mm 35mm;     /* top/bottom: 20mm, left/right: 25mm (2.5cm) */
  }
}


