@page { size: A4 portrait; margin: 8mm; }
@page story-a4 {
  size: A4 portrait;
  margin: 16mm;
  @bottom-right { content: counter(page); font: 10pt system-ui, sans-serif; color: #454545; }
}

html { background: #ebeaf5; font: 17px/1.55 system-ui, sans-serif; color: #1e1a35; }
body { margin: 0; }
.print-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.print-controls a { color: #462188; }
.print-controls button { border: 0; border-radius: .65rem; padding: .65rem 1rem; background: #5528a9; color: white; font: inherit; cursor: pointer; }
.print-controls :focus-visible { outline: 3px solid #c87300; outline-offset: 4px; }
.print-sheet { width: min(100% - 2rem, 194mm); box-sizing: border-box; margin: 0 auto 1rem; padding: 1rem; background: white; box-shadow: 0 4px 24px #110c4226; }
.print-sheet img { display: block; width: 100%; height: auto; object-fit: contain; }
.print-sheet img:only-child { margin: auto; }

.print-sheet--story { padding: clamp(1rem, 5vw, 18mm); }
.print-sheet--story h1 { margin: 0 0 .6em; font: 800 clamp(1.5rem, 5vw, 2.1rem)/1.18 system-ui, sans-serif; }
.print-story-illustration { max-width: 120mm; margin: 0 auto 1.35rem; }
.print-story-illustration img { width: 100%; border-radius: .4rem; }
.print-story-illustration figcaption { margin-top: .3em; text-align: center; color: #454545; font-size: .85em; }
.print-sheet--story p { margin: 0 0 .65em; font-family: Georgia, serif; }
.print-sheet--story p:last-child { margin-bottom: 0; }

@media print {
  html { background: white; color: black; font: 11pt/1.4 serif; }
  .print-controls { display: none; }
  .print-sheet { width: auto; margin: 0; padding: 0; box-shadow: none; }
  .print-sheet img { width: auto; height: auto; max-width: 100%; max-height: 280mm; break-inside: avoid; }
  .print-sheet p { orphans: 3; widows: 3; }
  .print-sheet--story { page: story-a4; max-width: 164mm; margin-inline: auto; }
  .print-sheet--story h1 { margin-bottom: 5mm; font-size: 23pt; break-after: avoid; }
  .print-story-illustration { max-width: 114mm; margin-bottom: 6mm; break-inside: avoid; }
  .print-story-illustration img { width: 100%; max-height: 76mm; border-radius: 1.5mm; }
  .print-story-illustration figcaption { font-size: 10pt; }
  .print-sheet--story p { margin-bottom: .48em; font-size: 13pt; line-height: 1.43; }
  .print-sheet--story p:nth-last-child(-n + 4):not(:last-child) { break-after: avoid; }
}
