:root {
  color: #172033;
  background: #eef3f2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  border-top: 7px solid #176f64;
  border-radius: 14px;
  padding: 28px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgb(23 32 51 / 8%);
}

.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #176f64;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.intro {
  max-width: 820px;
  margin: 12px 0 0;
  color: #536171;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

button,
.actions a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid #b8cfca;
  border-radius: 8px;
  padding: 9px 13px;
  color: #176f64;
  background: #f4faf8;
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

button {
  border-color: #176f64;
  color: #ffffff;
  background: #176f64;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0 0 18px;
  border-top: 1px solid #dce3e5;
  border-bottom: 1px solid #dce3e5;
  padding: 12px 0;
  color: #536171;
  font-size: 0.83rem;
  font-weight: 750;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  display: inline-block;
  width: 25px;
  height: 18px;
  border-radius: 999px;
}

.legend .ferien { background: #f6c5da; }
.legend .frei { background: #ddd3f4; }
.legend .feiertag { background: #f6df7b; }
.legend .verbunden {
  border: 2px solid #278577;
  background: #eef8f5;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.month {
  border: 1px solid #d9e1e4;
  border-radius: 11px;
  padding: 12px;
  break-inside: avoid;
}

.month h2 {
  margin: 0 0 9px;
  font-size: 1.05rem;
}

.weekday-row,
.calendar-row {
  display: grid;
  grid-template-columns: 28px repeat(7, minmax(0, 1fr));
  align-items: center;
  text-align: center;
}

.weekday-row {
  margin-bottom: 4px;
  color: #76818d;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.weekday-row span:nth-child(7) { color: #3f6eb5; }
.weekday-row span:nth-child(8) { color: #c95763; }

.calendar-row { min-height: 29px; }

.week-number {
  color: #a0a8b0;
  font-size: 0.63rem;
  font-weight: 700;
}

.day {
  position: relative;
  display: inline-flex;
  width: 29px;
  height: 23px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.calendar-row .day:nth-child(7) { color: #3f6eb5; }
.calendar-row .day:nth-child(8) { color: #c95763; }
.day.holiday { background: #f6c5da; }
.day.school-free { background: #ddd3f4; }
.day.public-holiday { background: #f6df7b; }
.day.connected {
  border: 2px solid #278577;
  background: #eef8f5;
}

.day.also-public-holiday::after {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d7a91f;
  content: "";
}

.empty { visibility: hidden; }

.source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  margin-top: 18px;
  border-top: 1px solid #dce3e5;
  padding-top: 13px;
  color: #697581;
  font-size: 0.78rem;
  line-height: 1.45;
}

@page {
  size: 297mm 210mm;
  margin: 6mm;
}

@media print {
  :root,
  body { background: #ffffff; }
  body { padding: 0; }
  main {
    width: auto;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .actions { display: none; }
  h1 { font-size: 25pt; }
  .top { margin-bottom: 8pt; }
  .intro {
    margin-top: 5pt;
    font-size: 8pt;
  }
  .legend {
    margin-bottom: 7pt;
    padding: 5pt 0;
    font-size: 7pt;
  }
  .year-grid { gap: 5pt; }
  .month {
    border-radius: 5pt;
    padding: 5pt;
  }
  .month h2 {
    margin-bottom: 3pt;
    font-size: 9pt;
  }
  .weekday-row {
    margin-bottom: 1pt;
    font-size: 5.5pt;
  }
  .calendar-row { min-height: 14pt; }
  .week-number { font-size: 5pt; }
  .day {
    width: 15pt;
    height: 12pt;
    font-size: 6pt;
  }
  .source {
    margin-top: 6pt;
    padding-top: 5pt;
    font-size: 6pt;
  }
}

@media screen and (max-width: 1000px) {
  .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 620px) {
  body { padding: 12px; }
  main { padding: 18px 14px; }
  .top {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .actions { justify-content: start; }
  .actions > * { flex: 1 1 170px; }
  .year-grid { grid-template-columns: 1fr; }
  .source { grid-template-columns: 1fr; }
}


/* Print layout lock: A4 landscape, 4 x 3 months */

.print-hint {
  flex-basis: 100%;
  color: #697581;
  font-size: 0.75rem;
  font-weight: 650;
  text-align: right;
}

@media print {
  html,
  body {
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    margin: 0 !important;
    padding: 0 !important;
  }

  main {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    border-top-width: 4pt;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .top {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    margin-bottom: 5pt !important;
  }

  .eyebrow {
    margin-bottom: 2pt;
    font-size: 6pt;
  }

  h1 {
    font-size: 22pt !important;
  }

  .intro {
    max-width: none;
    margin-top: 3pt !important;
    font-size: 6.5pt !important;
    line-height: 1.25;
  }

  .actions,
  .print-hint {
    display: none !important;
  }

  .legend {
    gap: 4pt 9pt;
    margin: 0 0 4pt !important;
    padding: 3pt 0 !important;
    font-size: 5.8pt !important;
  }

  .legend span {
    gap: 3pt;
  }

  .legend i {
    width: 12pt;
    height: 8pt;
  }

  .year-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 4pt !important;
    width: 100% !important;
  }

  .month {
    min-width: 0 !important;
    border-radius: 4pt !important;
    padding: 4pt !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .month h2 {
    margin-bottom: 2pt !important;
    font-size: 8pt !important;
  }

  .weekday-row,
  .calendar-row {
    grid-template-columns: 15pt repeat(7, minmax(0, 1fr)) !important;
  }

  .weekday-row {
    margin-bottom: 0 !important;
    font-size: 4.5pt !important;
  }

  .calendar-row {
    min-height: 12pt !important;
  }

  .week-number {
    font-size: 4.3pt !important;
  }

  .day {
    width: 13pt !important;
    height: 10pt !important;
    font-size: 5.2pt !important;
  }

  .day.also-public-holiday::after {
    top: 0;
    right: 0;
    width: 2.5pt;
    height: 2.5pt;
  }

  .source {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 5pt !important;
    margin-top: 4pt !important;
    padding-top: 3pt !important;
    font-size: 5pt !important;
    line-height: 1.25;
  }
}
