@layer app {
  .exam-calendar-page { max-width: none; padding-top: 12px; }
  .exam-calendar-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
  .exam-calendar-heading h1 { font-size: clamp(28px, 3vw, 38px); }
  .exam-calendar-heading p { margin-top: 8px; font-size: .9rem; }
  .exam-calendar-paper, .calendar-exam-list { background: white; padding: 28px; border-radius: 30px; }
  .exam-calendar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 24px; }
  .exam-calendar-controls h2 { margin-right: auto; font-size: 1.55rem; }
  .exam-calendar-controls nav { display: flex; align-items: center; gap: 8px; }
  .calendar-arrow { display: grid; place-items: center; min-width: 44px; min-height: 44px; border-radius: 50%; background: #f5f5f3; }
  .calendar-jump { display: flex; align-items: center; gap: 8px; }
  .calendar-jump input[type="submit"] { width: auto; flex-shrink: 0; }
  .calendar-jump input[type="month"] { width: 11rem; min-width: 0; padding: 10px; }
  .exam-month-grid { width: 100%; table-layout: fixed; border-collapse: collapse; }
  .exam-month-grid th { padding-bottom: 12px; color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; }
  .exam-month-grid abbr { text-decoration: none; }
  .exam-month-grid td { height: 110px; border-top: 1px solid var(--line); padding: 10px 6px; vertical-align: top; }
  .exam-month-grid td > time { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; font-size: .85rem; }
  .calendar-today > time { background: #d6fc76; font-weight: 800; }
  .calendar-outside > time { color: #868681; }
  .calendar-day-exams, .calendar-day-topics { display: flex; align-items: flex-start; gap: 6px; padding: 8px 6px; margin-top: 4px; border-radius: 10px; background: #eaf4ff; }
  .calendar-day-topics { background: #f1f5e9; }
  .calendar-exam-dot, .calendar-topic-dot { display: inline-block; flex-shrink: 0; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #126fc4; }
  .calendar-topic-dot { background: #668619; }
  .calendar-topic-count { display: none; }
  /* Clamp to two lines so a long topic title cannot stretch one week row far past its
     neighbours. The full text stays in the DOM and in the date link's accessible name. */
  .calendar-exam-preview, .calendar-topic-preview {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .calendar-exam-preview small, .calendar-topic-preview small { display: block; margin-top: 4px; color: var(--muted); font-size: .7rem; font-weight: 500; }
  .calendar-legend { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: .75rem; }
  .calendar-legend .calendar-exam-dot, .calendar-legend .calendar-topic-dot { margin-top: 0; }
  .calendar-today-key { width: 10px; height: 10px; margin-left: 12px; border-radius: 50%; background: #d6fc76; }
  .calendar-exam-list { margin-top: 24px; }
  .calendar-exam-list h2 { font-size: 1.45rem; margin-bottom: 20px; }
  .calendar-exam-list > p { margin-bottom: 16px; }
  .calendar-exam-day { scroll-margin-top: 5rem; }
  .calendar-exam-day + .calendar-exam-day { margin-top: 24px; }
  .calendar-exam-day h3 { margin-bottom: 10px; font-size: .9rem; font-weight: 600; }
  .calendar-exam-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 8px; padding: 18px; border-radius: 18px; background: #eaf4ff; overflow-wrap: anywhere; }
  .calendar-exam-row > div { min-width: 0; }
  .calendar-exam-row strong, .calendar-exam-row div > span { display: block; }
  .calendar-exam-row div > span { margin-bottom: 4px; color: var(--muted); font-size: .75rem; }
  .calendar-exam-row p { margin-top: 8px; font-size: .85rem; white-space: pre-wrap; }
  .calendar-exam-row.calendar-topic-row { background: #f1f5e9; }
  .calendar-topic-row form { flex-shrink: 0; }
  .calendar-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  /* Below this the seven-column cells are too narrow for a title to stay readable, so a cell
     shows a marker and the topic count. The date link keeps the descriptive accessible name
     and its #topics-YYYY-MM-DD anchor, so the full topic and Start lesson stay one tap away
     in the agenda below. Full previews return above the breakpoint. */
  @media (max-width: 900px) {
    /* The marker is the only target in the cell, so it carries the full 44px tap target and
       stays a comfortable size for a finger on a narrow month grid. */
    .calendar-day-exams, .calendar-day-topics { justify-content: center; align-items: center; min-height: 44px; }
    .calendar-exam-dot, .calendar-topic-dot { margin-top: 0; }
    .calendar-exam-preview, .calendar-topic-preview { display: none; }
    .calendar-topic-count { display: inline; font-size: .75rem; }
  }
  @media (max-width: 600px) {
    .exam-calendar-heading { align-items: flex-start; flex-direction: column; }
    .exam-calendar-paper, .calendar-exam-list { padding: 20px 14px; border-radius: 24px; }
    .exam-calendar-controls h2 { width: 100%; }
    .calendar-jump { width: 100%; }
    .calendar-jump input[type="month"] { flex: 1; width: 0; }
    .exam-month-grid td { height: 75px; padding: 8px 0; }
    .exam-month-grid th { text-align: center; font-size: .7rem; }
    .exam-month-grid td > time { margin: auto; }
    .calendar-day-exams, .calendar-day-topics { padding: 4px; margin: 0 1px; }
    .calendar-topic-row { flex-direction: column; align-items: stretch; gap: 12px; }
    .calendar-exam-row { padding: 16px; }
  }
}
