/* Member/child layout proposal. Load after the current member styles.
 * Scope is width containment and comfortable dialog gutters; preserve the
 * existing full-screen social editor, timetable scrolling and text alignment.
 */
.member-app .member-app-main,
.safety-page {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-inline: auto;
}
.member-app .member-app-main > *,
.member-app .member-person-select,
.safety-page .safety-field,
.safety-page .safety-child > h2 {
  min-width: 0;
  max-width: 100%;
}
.member-app .member-person-select select {
  min-width: 0;
  max-width: 100%;
}
.safety-page .safety-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.safety-page .safety-child {
  flex-wrap: wrap;
  align-items: flex-start;
}
.safety-page .safety-child > h2 {
  flex: 1 1 150px;
  overflow-wrap: anywhere;
}
.safety-page .safety-child > span {
  flex: 0 0 auto;
  padding-top: 4px;
}
.safety-page .safety-card,
.safety-page .safety-question,
.safety-page .safety-terms,
.safety-page .safety-check,
.safety-page .safety-choices label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.safety-page footer {
  flex-wrap: wrap;
}
.safety-page footer > * {
  min-width: 0;
  max-width: 100%;
}
/* The overlay already centres its panel; keep the panel inside its padding. */
.sah-camera .sah-camera-panel {
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  overscroll-behavior: contain;
}
@media (max-width: 720px) {
  /* Simple member forms gain even gutters, without altering the full-screen
   * composer or the booking dialog's fixed header/footer and scrolling body.
   * Do not set max-width: the photo dialog keeps its existing 480px cap.
   * These native dialogs keep their member-app ancestor in the top layer. */
  :is(.member-app, .staff-workspace) dialog.member-dialog:not(.booking-dialog):not(.social-dialog) {
    position: fixed;
    inset: 0;
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    margin: auto;
    border-radius: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
@media (max-width: 520px) {
  .safety-page .safety-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Staff layout proposal: append after active page styles; no functional changes.
   Keep each scroll owner intact. In particular, do not clip the document or
   force timetable columns to fit when they have an intentional scroll region. */

/* The desktop frame stretches its scrollable shell to the viewport. Constrain
   only its contents, so the separate full-width navigation stays undisturbed. */
html.staff-desktop-frame .shell > main#main {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  min-width: 0;
}
html.staff-desktop-frame body.finance-is-open .shell > main#main {
  max-width: 1400px;
}

/* Text-bearing children must be allowed to shrink within a flex/grid card. */
.staff-workspace :is(.tt-shell, .tt-heading-actions, .tt-section-heading > div,
  .fr-register-person, .fr-check, .fr-check > span, .fr-search-result > div,
  .tt-payment-top > div, .tt-payment-history, .tt-history-row > span),
html.staff-desktop-frame :is(.drawer-head > div, .sheet-head > div,
  .staff-rank-field, .section-head > div, .staff-pay-history-row > div) {
  min-width: 0;
}
.staff-workspace :is(.fr-check strong, .fr-check small, .fr-search-result strong,
  .tt-heading h1, .tt-section-heading h2, .tt-history-row > span),
html.staff-desktop-frame :is(.drawer-head h2, .sheet-head h2,
  .staff-pay-history-row p) {
  overflow-wrap: anywhere;
}
.staff-workspace .fr-check .fr-avatar { flex: none; }

/* Toolbars get their own row on a phone, rather than squeezing a title or
   hanging a button outside a narrow card. */
@media (max-width: 600px) {
  .staff-workspace .tt-heading { flex-wrap: wrap; }
  .staff-workspace .tt-heading > div:first-child { flex: 1 1 220px; }
  .staff-workspace .tt-heading-actions { flex: 1 1 100%; justify-content: flex-start; }
  .staff-workspace .tt-period-nav { max-width: 100%; flex-wrap: wrap; }
  .staff-workspace .fr-search-result { flex-wrap: wrap; }
  .staff-workspace .fr-search-result > div { flex: 1 1 180px; }
  .staff-workspace .fr-owner-date .field { min-width: 0; max-width: 100%; }
  html.staff-desktop-frame .section-head { flex-wrap: wrap; align-items: flex-start; }
}

/* Long staff/member names in modal headings must not push the close control
   out of view. Preserve the existing bottom-sheet placement on phones. */
html.staff-desktop-frame :is(.drawer, .sheet, .cn-dialog, .gr-dialog,
  .staff-photo-dialog, .staff-pay-history, .birthday-dialog) {
  min-width: 0;
}
.staff-workspace .tt-dialog-content { min-width: 0; }
.staff-workspace .tt-dialog-head > h2 { min-width: 0; overflow-wrap: anywhere; }
.staff-workspace .tt-dialog-head > button { flex: none; }
/* Keep the coach date controls together and balance the six phone destinations. */
@media (max-width: 600px) {
  .staff-workspace .tt-period-nav {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
  }
  .staff-workspace .tt-period-nav .tt-period-title {
    min-width: 0;
    width: auto;
    margin: 0;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
  }
  .staff-workspace .tt-period-nav .tt-icon-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}
@media (max-width: 540px) {
  .staff-workspace .staff-timetable-nav.staff-timetable-nav-coach {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
