@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body,
  #wrapper,
  #content {
    margin: 0;
    padding: 0 !important;
    width: 100%;
    box-sizing: border-box;
    background: none;
  }

  #header,
  #page-actions,
  #ad-slot,
  #about,
  #faq,
  #recommend,
  .pwa-banner,
  #share,
  #footer-nav,
  #footer,
  .modal,
  .print-page form input[type="file"],
  .print-page form label,
  .print-page form.selected label,
  .print-page form.selected:active label,
  .page-badge,
  .slot-remove {
    display: none !important;
  }

  #content {
    gap: 0 !important;
  }

  /* Each .print-page becomes an A4 page */
  .print-page {
    width: 100%;
    height: 100vh;
    max-width: none;
    aspect-ratio: auto;
    page-break-after: always;
    break-after: page;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }

  .print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  /* 2-up print: hide slots 3-4 per page */
  #content[data-layout="2"] .print-page form:nth-child(n+3) {
    display: none !important;
  }
}
