@page {
  size: A4 portrait;
  margin: 14mm 15mm 15mm;
}

@media print {
  html,
  body,
  main {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #172b2a;
  }

  .no-print,
  #setup,
  .program-actions,
  #result .lanes,
  #result button {
    display: none !important;
  }

  #result:not([hidden]) {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    font-size: 10pt;
    line-height: 1.35;
  }

  #result .program-header,
  #result .program-intro,
  #result .program-weeks,
  #result details.week,
  #result .week-sessions {
    display: block;
    position: static;
    width: auto;
    max-width: none;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    margin: 0;
    padding: 0;
    background: #fff;
    color: inherit;
    box-shadow: none;
    border: 0;
  }

  #result .program-header { margin-bottom: 4mm; }
  #result .brand,
  #result .program-facts { color: #21332d; }
  #result .program-facts { font-size: 10pt; }
  #result .program-intro { margin-bottom: 3mm; }
  #result .program-calendar { margin: 2mm 0 0; }
  #result h1 { font-size: 21pt; line-height: 1.1; margin: 0 0 2mm; }
  #result h2 { font-size: 14pt; line-height: 1.2; margin: 0 0 1mm; }
  #result h3 { font-size: 11pt; line-height: 1.2; margin: 0 0 1mm; }
  #result h4 { font-size: 10pt; margin: 0; }
  #result p { margin: 0 0 1mm; orphans: 2; widows: 2; }
  #result h1, #result h2, #result h3 { break-after: avoid-page; }

  /* Let long weeks span pages while keeping the heading with the first run. */
  #result details.week { break-inside: auto; margin-top: 4mm; }
  #result details.week:not(:has(.session:nth-child(4))) { break-inside: avoid-page; }
  #result details.week > summary {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    min-height: 0;
    gap: 1mm 3mm;
    padding: 2mm 0 1mm;
    border-top: 1.25pt solid #172b2a;
    font-size: 12pt;
    font-weight: 700;
    list-style: none;
    break-after: avoid-page;
  }
  #result details.week > summary::marker { content: ""; }
  #result details.week > summary::-webkit-details-marker { display: none; }
  #result details.week > summary::after { display: none; }
  #result .week-number,
  #result .week-meta { font-size: 9pt; }
  #result .week-phase { font-size: 12pt; }
  #result .week-focus { padding: 1mm 0; font-size: 9pt; break-after: avoid-page; }
  #result details.week::details-content {
    display: block;
    content-visibility: visible;
    height: auto;
    overflow: visible;
  }
  #result .week-sessions > .session {
    display: grid;
    grid-template-columns: 19mm minmax(0, 1fr) 21mm;
    column-gap: 3mm;
    align-items: baseline;
    margin: 0;
    padding: 1.8mm 0;
    border: 0;
    border-top: .45pt solid #bbc5be;
    background: #fff;
    color: inherit;
    box-shadow: none;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }
  #result .session-day { grid-area: 1 / 1; font-size: 9pt; }
  #result .session-main { grid-area: 1 / 2; min-width: 0; }
  #result .session-meta { font-size: 9pt; }
  #result .session > .session-meta { grid-area: 1 / 3; }
}
