/* Calendar-only interaction and mobile layout corrections. */
.calendar-template-strip,
.calendar-filter-row,
.calendar-template-editor {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.calendar-page button,
.calendar-page input,
.calendar-page select,
.calendar-page textarea,
.calendar-file-button {
  touch-action: manipulation;
}

.calendar-summary strong,
.calendar-day-number,
.calendar-entry-copy small,
.calendar-upcoming-date,
.calendar-month-control h2,
.calendar-month-picker {
  font-variant-numeric: tabular-nums;
}

.calendar-day,
.calendar-template-button,
.calendar-upcoming-item,
.calendar-entry-actions button,
.calendar-primary-button,
.calendar-secondary-button,
.calendar-add-button,
.calendar-icon-button,
.calendar-today-button,
.calendar-filter-row button {
  -webkit-tap-highlight-color: transparent;
}

/* Keep calendar-only controls at the same baseline as the rest of the site. */
.calendar-icon-button,
.calendar-task-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
}

.calendar-month-picker,
.calendar-today-button {
  min-height: 40px;
}

@media (max-width: 720px) {
  .calendar-container {
    padding-top: 22px;
    padding-bottom: 40px;
  }

  .calendar-page .site-header .brand {
    font-size: 1.75rem !important;
  }

  .calendar-page .nav-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .calendar-intro {
    gap: 16px;
    margin-bottom: 18px;
  }

  .calendar-intro h1 {
    font-size: 2rem;
    line-height: 1.2;
  }

  .calendar-intro-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .calendar-intro-actions > * {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }

  .calendar-summary {
    gap: 10px;
  }

  .calendar-summary article {
    min-height: 96px;
    border-radius: 16px;
  }

  .calendar-quick-section,
  .calendar-pattern-card,
  .calendar-card,
  .calendar-panel,
  .calendar-upcoming-card,
  .calendar-settings-card {
    padding: 16px;
    border-radius: 16px;
  }

  .calendar-template-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
    scroll-snap-type: none;
  }

  .calendar-template-button {
    min-width: 0;
    min-height: 72px;
    flex: initial;
    scroll-snap-align: none;
  }

  .calendar-pattern-form,
  .calendar-entry-form {
    gap: 14px;
  }

  .calendar-toolbar {
    gap: 10px;
  }

  .calendar-month-control {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-month-control h2 {
    min-width: 0;
    flex: 1;
  }

  .calendar-toolbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    gap: 8px;
  }

  .calendar-month-picker {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .calendar-icon-button,
  .calendar-task-toggle {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .calendar-today-button,
  .calendar-secondary-button,
  .calendar-file-button {
    min-height: 44px;
  }

  .calendar-filter-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    overflow: visible;
  }

  .calendar-filter-row button {
    min-height: 44px;
    padding: 8px 12px;
  }

  .calendar-day {
    min-height: 68px;
  }

  .calendar-form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .calendar-form-actions .calendar-add-button {
    width: 100%;
  }

  .calendar-entry-actions button {
    min-height: 44px;
  }

  .calendar-lower-grid {
    margin-top: 16px;
  }

  .calendar-template-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 16px;
  }

  .calendar-template-dialog-shell {
    padding: 16px;
  }

  .calendar-template-editor {
    max-height: 60dvh;
  }

  .calendar-template-edit-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-dialog-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-dialog-actions > * {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .calendar-template-strip {
    grid-template-columns: 1fr;
  }

  .calendar-summary {
    gap: 8px;
  }

  .calendar-summary article {
    min-height: 88px;
    padding: 12px;
  }

  .calendar-day {
    min-height: 62px;
    padding: 4px;
  }

  .calendar-filter-row button {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .calendar-page *,
  .calendar-page *::before,
  .calendar-page *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
