/* Renderer working defaults, not .manual format requirements or user settings. */
:root {
  --print-paper-width: 210mm;
  --print-paper-height: 297mm;
  --print-margin: 15mm;
  --print-content-width: calc(var(--print-paper-width) - 2 * var(--print-margin));
  --print-content-height: calc(var(--print-paper-height) - 2 * var(--print-margin));
}
@page { size: A4 portrait; margin: var(--print-margin); }

#print-view { display: none; }
body.print-preview #workspace, body.print-preview #status { display: none; }
body.print-preview #print-view {
  display: block; position: fixed; inset: 0; overflow: auto; background: #e5e5e5;
}
#print-toolbar {
  position: sticky; top: 0; z-index: 1; display: flex; gap: .5rem;
  justify-content: center; padding: .5rem; background: #fff; border-bottom: 1px solid #ccc;
}
#print-document {
  width: var(--print-paper-width); max-width: 100%; min-height: var(--print-paper-height);
  margin: 1rem auto; padding: var(--print-margin); background: #fff; color: #000;
  font-family: system-ui, "Noto Sans CJK JP", "Yu Gothic", Meiryo, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  font-size: 11pt; line-height: 1.6; overflow-wrap: anywhere;
}
/* Continuous preview of the same DOM; only the browser paginates the output. */
.print-section {
  font-size: 16pt; font-weight: 700; margin: 8mm 0 4mm; padding-bottom: 2mm;
  border-bottom: .3mm solid #000; break-after: avoid; page-break-after: avoid;
  white-space: pre-wrap;
}
.print-section:first-child { margin-top: 0; }
.print-item { margin: 0 0 6mm; break-inside: avoid; page-break-inside: avoid; }
.print-item p { margin: 0; white-space: pre-wrap; tab-size: 4; orphans: 2; widows: 2; }
.print-item img {
  display: block; width: auto; height: auto; margin: 0 auto;
  max-width: 100%; max-height: calc(var(--print-content-height) - 30mm); object-fit: contain;
}
/* Reserve room for a Section marker and short explanation, without trying to measure/paginate text. */
.print-item-with-text img { max-height: calc(var(--print-content-height) - 40mm); margin-bottom: 3mm; }

@media print {
  html, body { margin: 0; padding: 0; height: auto; overflow: visible; background: #fff; color: #000; }
  /* Hide all app chrome, composer, camera, status and controls, not just Reader. */
  body > :not(#print-view), #print-toolbar { display: none !important; }
  body #print-view, body.print-preview #print-view { display: block; position: static; overflow: visible; background: #fff; }
  #print-document {
    width: var(--print-content-width); max-width: 100%; min-height: 0;
    margin: 0; padding: 0; box-shadow: none;
  }
}
