.calendar-main {
  background: linear-gradient(180deg, var(--brand-050), #fff 260px);
}

.calendar-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 30px;
}

.calendar-heading h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(32px, 5vw, 50px);
  font-weight: 600;
  line-height: 1.3;
}

.calendar-heading p:last-child {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--ink-600);
  font-size: 14px;
}

.calendar-print {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  color: #fff;
  background: var(--brand-700);
  cursor: pointer;
}

.calendar-print:hover {
  background: var(--brand-800);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: #fff;
}

.calendar-toolbar p {
  margin: 0;
  color: var(--ink-600);
  font-size: 13px;
}

.term-switch {
  display: flex;
  gap: 6px;
}

.term-switch button {
  min-height: 40px;
  padding: 0 22px;
  border: 1px solid var(--line);
  color: var(--ink-800);
  background: var(--brand-050);
  cursor: pointer;
}

.term-switch button.is-active {
  border-color: var(--brand-800);
  color: #fff;
  background: var(--brand-800);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 18px 0 28px;
  color: var(--ink-600);
  font-size: 12px;
}

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

.calendar-legend i {
  width: 14px;
  height: 14px;
  border: 1px solid var(--line);
}

.legend-teaching { background: #e4f3ef; }
.legend-event { border-radius: 50%; background: var(--brand-600); }
.legend-exam { background: #fff0bd; }
.legend-holiday { background: #fde6e3; }
.legend-today { border: 2px solid var(--brand-800) !important; background: #fff; }

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 30px;
  align-items: start;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.month-card {
  border: 1px solid var(--line);
  background: #fff;
}

.month-card h2 {
  margin: 0;
  padding: 13px 15px;
  color: var(--brand-900);
  border-top: 4px solid var(--brand-600);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.month-card table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.month-card th {
  height: 31px;
  color: var(--ink-600);
  background: var(--brand-050);
  font-weight: 600;
}

.month-card th:first-child {
  width: 32px;
}

.month-card th.weekend {
  color: #c64d4d;
}

.month-card td {
  position: relative;
  height: 36px;
  padding: 0;
  border-top: 1px solid #edf2f1;
  text-align: center;
}

.month-card td.week-number {
  color: var(--ink-600);
  background: #fafcfc;
  font-size: 10px;
}

.calendar-day {
  position: relative;
  display: grid;
  width: 100%;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  color: var(--ink-950);
  background: transparent;
  font-variant-numeric: tabular-nums;
}

button.calendar-day {
  cursor: pointer;
}

button.calendar-day:hover {
  box-shadow: inset 0 0 0 2px var(--brand-600);
}

.calendar-day.is-weekend {
  color: #c64d4d;
}

.calendar-day.is-teaching {
  background: #e4f3ef;
}

.calendar-day.is-exam {
  background: #fff0bd;
}

.calendar-day.is-holiday {
  color: #ad3f3f;
  background: #fde6e3;
}

.calendar-day.is-today {
  box-shadow: inset 0 0 0 2px var(--brand-800);
  font-weight: 700;
}

.calendar-day.has-event::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  content: "";
  background: var(--brand-700);
}

.selected-date-detail {
  min-height: 54px;
  margin-top: 18px;
  padding: 13px 16px;
  color: var(--ink-800);
  border-left: 4px solid var(--brand-600);
  background: var(--brand-050);
  font-size: 13px;
}

.selected-date-detail strong {
  color: var(--brand-900);
}

.term-notes {
  position: sticky;
  top: 20px;
  border-top: 5px solid var(--brand-700);
  background: var(--brand-050);
}

.term-notes-head {
  padding: 24px 24px 16px;
}

.term-notes-head span {
  color: var(--brand-600);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.term-notes h2 {
  margin: 6px 0 0;
  font-family: var(--font-serif);
  font-size: 22px;
}

.term-notes ol {
  margin: 0;
  padding: 0 24px 8px 48px;
}

.term-notes li {
  margin-bottom: 12px;
  padding-left: 3px;
  color: var(--ink-800);
  font-size: 13px;
  line-height: 1.65;
}

.term-notes time {
  display: block;
  color: var(--brand-700);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.calendar-disclaimer {
  margin: 10px 24px 24px;
  padding-top: 16px;
  color: var(--ink-600);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
}

.class-time-section {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.class-time-section summary {
  padding: 20px 4px;
  color: var(--brand-900);
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.class-time-content {
  padding: 0 4px 28px;
}

.class-time-content > p {
  margin: 0 0 20px;
  color: var(--ink-600);
  font-size: 13px;
}

.class-time-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.class-time-grid table {
  width: 100%;
  border-collapse: collapse;
  border-top: 3px solid var(--brand-600);
  background: #fff;
}

.class-time-grid caption {
  padding: 10px;
  color: var(--brand-900);
  background: var(--brand-050);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.class-time-grid th,
.class-time-grid td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
}

.class-time-grid th {
  color: var(--ink-600);
  font-weight: 600;
}

.calendar-links {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.calendar-links a {
  color: var(--brand-700);
  font-weight: 700;
}

@media (max-width: 980px) {
  .calendar-layout { grid-template-columns: 1fr; }
  .term-notes { position: static; }
}

@media (max-width: 720px) {
  .calendar-heading { align-items: stretch; flex-direction: column; }
  .calendar-print { align-self: flex-start; }
  .calendar-toolbar { align-items: stretch; flex-direction: column; }
  .term-switch button { flex: 1; padding-inline: 12px; }
  .month-grid { grid-template-columns: 1fr; }
  .class-time-grid { grid-template-columns: 1fr; }
}

@media print {
  .utility,
  .site-header,
  .page-hero,
  .breadcrumb,
  .calendar-print,
  .site-footer,
  .calendar-links,
  .class-time-section {
    display: none !important;
  }

  .page-main {
    padding: 0;
    background: #fff;
  }

  .container {
    width: 100%;
  }

  .calendar-heading {
    margin-bottom: 16px;
  }

  .calendar-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 16px;
  }

  .month-grid {
    gap: 10px;
  }

  .month-card,
  .term-notes {
    break-inside: avoid;
  }
}
