/* Appointment detail/edit dialog: keep actions visible while its content scrolls. */
.appointment-detail-backdrop {
  --appointment-detail-safe-bottom: env(safe-area-inset-bottom, 0px);
  --appointment-detail-safe-top: env(safe-area-inset-top, 0px);
  position: fixed !important;
  inset: 0;
  box-sizing: border-box;
  display: grid !important;
  place-items: center;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  overscroll-behavior: none;
  padding: max(12px, var(--appointment-detail-safe-top)) max(12px, env(safe-area-inset-right, 0px)) max(12px, var(--appointment-detail-safe-bottom)) max(12px, env(safe-area-inset-left, 0px)) !important;
}
.appointment-detail-modal {
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column !important;
  width: min(720px, calc(100vw - 24px)) !important;
  min-width: 0;
  max-width: 100%;
  padding: 0 !important;
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px - var(--appointment-detail-safe-top) - var(--appointment-detail-safe-bottom));
  position: relative !important;
  flex: 0 1 auto !important;
  margin: 0 !important;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - var(--appointment-detail-safe-top) - var(--appointment-detail-safe-bottom)) !important;
  overflow: hidden !important;
  overscroll-behavior: contain;
}
.appointment-detail-header,
.appointment-detail-actions { flex: 0 0 auto; }
.appointment-detail-modal > .appointment-detail-body {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-bottom: 16px;
}
.appointment-detail-modal.is-editing > .appointment-detail-body { flex: 1 1 0 !important; min-height: 0 !important; overflow-y: auto !important; }
.appointment-detail-body > .appointment-detail-grid,
.appointment-detail-body > .appointment-detail-note,
.appointment-detail-body > .calendar-edit-fields,
.appointment-detail-body > .appointment-package-binding,
.appointment-detail-body > [role="alert"] {
  box-sizing: border-box;
  width: auto;
  max-width: calc(100% - 48px);
}
.appointment-detail-body > .appointment-detail-grid,
.appointment-detail-body > .appointment-detail-note,
.appointment-detail-body > .calendar-edit-fields,
.appointment-detail-body > .appointment-package-binding,
.appointment-detail-body > [role="alert"] { align-self: stretch; }
.appointment-detail-modal.is-editing > .appointment-detail-header,
.appointment-detail-modal.is-editing > .appointment-detail-actions { flex-shrink: 0; }
.appointment-detail-modal > .appointment-detail-body > :not(.appointment-detail-grid):not(.appointment-detail-note):not(.calendar-edit-fields):not(.appointment-package-binding):not([role="alert"]) { min-width: 0; max-width: 100%; }
.appointment-detail-modal > .appointment-detail-actions {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  box-sizing: border-box;
  width: 100%;
  flex: 0 0 auto !important;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  max-height: none !important;
  margin: 0 !important;
  min-height: 0;
  padding: 14px 24px max(18px, var(--appointment-detail-safe-bottom));
  overflow: visible !important;
  overscroll-behavior: contain;
  background: #fff;
  border-top: 1px solid #e2eaf0;
}
.appointment-detail-modal.is-editing > .appointment-detail-actions {
  position: sticky !important;
  bottom: 0;
  z-index: 3;
  flex: 0 0 auto !important;
  max-height: 35%;
}
@media (max-width: 760px) { .appointment-detail-backdrop { padding: max(12px, var(--appointment-detail-safe-top)) max(12px, env(safe-area-inset-right, 0px)) max(12px, var(--appointment-detail-safe-bottom)) max(12px, env(safe-area-inset-left, 0px)); } }
.appointment-detail-modal .appointment-button { min-width: 0; max-width: 100%; }
.appointment-detail-modal :focus-visible { scroll-margin-block: 12px; }
@media (max-width: 600px) {
  .appointment-detail-body > .appointment-detail-grid,
  .appointment-detail-body > .appointment-detail-note,
  .appointment-detail-body > .calendar-edit-fields,
  .appointment-detail-body > .appointment-package-binding,
  .appointment-detail-body > [role="alert"] { max-width: calc(100% - 32px); }
  .appointment-detail-modal > .appointment-detail-actions { padding: 12px 16px max(16px, var(--appointment-detail-safe-bottom)); }
  .appointment-detail-modal .appointment-detail-header { flex-shrink: 0; }
}


/* Footer controls stay outside the scroll region on narrow screens. */
@media (max-width: 600px) {
  .appointment-detail-modal > .appointment-detail-actions { display: grid !important; grid-template-columns: minmax(0, 1fr); }
}

/* Lock the underlying page only while this scoped dialog exists. */
body:has(.appointment-detail-backdrop) { overflow: hidden !important; }
