/* Shared phone layout. Component rules in app.css and navigation.css provide
   the desktop values; the same controls consume these mobile tokens. */
@media (max-width: 600px), (max-height: 500px) and (max-width: 950px) and (pointer: coarse) {
  :root {
    --control-height: 44px;
    --control-radius: 6px;
    --panel-radius: 9px;
    --panel-padding: 12px;
    --form-gap: 12px;
    --page-gutter: 10px;
    --toolbar-gap: 8px;
    --mobile-dock-gap: max(10px, env(safe-area-inset-bottom));
    --mobile-dialog-height: min(calc(100dvh - 16px), var(--visible-height, 100dvh));
  }

  .app-shell .content {
    padding: var(--page-gutter) var(--page-gutter) calc(68px + var(--mobile-dock-gap));
  }
  .app-shell .content-watchbook { padding: 0 0 calc(68px + var(--mobile-dock-gap)); }

  .app-shell .mobile-nav-toggle {
    position: fixed;
    inset: auto auto var(--mobile-dock-gap) max(10px, env(safe-area-inset-left));
    width: var(--control-height);
    height: var(--control-height);
    min-height: var(--control-height);
    border-radius: 50%;
    box-shadow: 0 2px 10px #102d4b26;
  }
  .app-shell .sidebar-branding { padding-top: 4px; }
  .app-shell .sidebar-footer { padding-bottom: calc(50px + var(--mobile-dock-gap)); }
  .app-shell .sidebar :is(.sidebar-links a, .sidebar-group-toggle, .sidebar-logout button, .sidebar-footer-account) {
    min-height: var(--control-height);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .notification-dock { --notification-bottom: var(--mobile-dock-gap); }
  .app-shell .area-toolbar:not(.schedule-toolbar),
  .app-shell .watchbook-page .watchbook-heading {
    position: relative;
    min-height: 0;
    margin-bottom: 12px;
    padding: var(--panel-padding);
    border-radius: var(--panel-radius);
    gap: var(--toolbar-gap);
  }
  .app-shell .watchbook-page .watchbook-heading { margin: var(--page-gutter); }
  .area-toolbar:not(.schedule-toolbar) > :is(.button-row, .actions, .watchbook-heading-actions) {
    justify-content: flex-start;
    width: 100%;
  }
  .area-toolbar h1 {
    font-size: clamp(1.12rem, 5vw, 1.35rem);
    overflow-wrap: anywhere;
  }
  .area-toolbar :is(.button, summary), .button-row > *, .form-actions > * { max-width: 100%; }

  :is(.page-heading-row, .section-heading, .panel > header) { flex-wrap: wrap; }
  :is(.button, .action-icon, .icon-button, .password-toggle, .date-picker-trigger, .contact-row a, button.contact-channel) {
    min-height: var(--control-height);
    touch-action: manipulation;
  }
  :is(.action-icon, .icon-button, .date-picker-trigger) { min-width: var(--control-height); }
  .button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
  }
  :is(.button-row, .form-actions, .action-icons) { gap: var(--toolbar-gap); }
  :is(.form-grid, .form-grid-two, .compact-filter-grid, .instruction-toolbar, .settings-grid, .profile-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
  :is(.form-grid, .form-stack, fieldset, label, .panel, .contact-row) {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  input:not([type=hidden], [type=checkbox], [type=radio], [type=range]), select, textarea {
    min-width: 0;
    max-width: 100%;
    min-height: var(--control-height);
    font-size: 16px;
  }
  input:is([type=checkbox], [type=radio]) { flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--blue-700); }
  :is(.checkbox-row, .compact-choice-row label, .contact-project-options label) { min-height: var(--control-height); align-items: center; }
  textarea { resize: vertical; }
  .area-toolbar :is(code, p), .panel code { overflow-wrap: anywhere; }
  :is(.instruction-metrics, .round-metrics) { flex-wrap: wrap; }
  .notification-channel-settings > form { grid-template-columns: minmax(0, 1fr); padding-inline: 0; }
  .notification-channel-head { display: none; }
  .notification-channel-row {
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 6px;
  }
  .notification-channel-row > span:first-child { grid-column: 1 / -1; font-weight: 700; }
  .notification-channel-row > label { min-height: var(--control-height); align-content: center; justify-items: center; padding-inline: 2px; }
  .notification-channel-row > label .sr-only {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip: auto;
    white-space: normal;
    font-size: .72rem;
  }

  .detail-list div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .detail-list dd { overflow-wrap: anywhere; }

  .table-scroll { max-width: 100%; overflow: auto; overscroll-behavior-inline: contain; }
  .table-scroll :is(th, td) { max-width: 28ch; overflow-wrap: anywhere; }
  .table-scroll :is(td, th) > :is(pre, code) { white-space: pre-wrap; overflow-wrap: anywhere; }
  .table-scroll .table-action { max-width: none; }
  .table-scroll :is(.button, .action-icon) { min-height: var(--control-height); }
  .filter-tabs { flex-wrap: wrap; gap: 4px; }
  .filter-tabs a { display: inline-flex; align-items: center; min-height: var(--control-height); }
  .empty-state { padding: 18px 12px; border-radius: var(--panel-radius); }
  .toast { border-radius: var(--control-radius); }
  .toast-close { min-height: 40px; min-width: 40px; }
  .toast { padding-right: 48px; }

  dialog[open] {
    max-inline-size: calc(100vw - 16px);
    max-block-size: var(--mobile-dialog-height);
    border-radius: var(--panel-radius);
    overscroll-behavior: contain;
  }
  dialog::backdrop { background: var(--dialog-backdrop); }
  dialog > header, dialog > .admin-tools-header { flex-wrap: wrap; }
  dialog :is(.form-actions, .quick-shift-actions) { flex-wrap: wrap; }
  dialog :is(.dialog-close, .occurrence-dialog-close, .watchbook-compose-close, .schedule-menu-close) {
    min-height: var(--control-height);
    min-width: var(--control-height);
  }
  body[data-watchbook-layout="panel"] .watchbook-compose-dialog[open] {
    max-inline-size: 100vw;
    max-block-size: var(--mobile-dialog-height);
    border-radius: 0;
  }

  .app-shell .schedule-toolbar .schedule-heading { padding-left: 0; }
  .schedule-page .schedule-toolbar {
    position: sticky;
    top: 0;
    z-index: var(--layer-sticky);
    gap: var(--toolbar-gap);
  }
  .schedule-page .schedule-toolbar .schedule-tool { min-height: var(--control-height); min-width: var(--control-height); }
  .schedule-page .schedule-toolbar-actions { flex-wrap: wrap; }
  .schedule-page .schedule-menu-panel { max-height: min(52dvh, var(--visible-height, 52dvh)); }
  .schedule-page .schedule-card-title,
  .schedule-page .schedule-assigned-names { overflow-wrap: anywhere; }
  .schedule-page .schedule-card-tools .schedule-quick-assign,
  .schedule-page .schedule-shift-wrap > .schedule-quick-assign {
    min-height: var(--control-height);
    min-width: var(--control-height);
  }

  .watchbook-page .watchbook-heading h1 { font-size: 1.2rem; }
  .watchbook-page .watchbook-filter > label { flex: 1 1 100%; max-width: 100%; }
  .watchbook-page .entry-card { padding: var(--panel-padding); }
  :is(.watchbook-page, .watchbook-compose-dialog) .composer :is(input:not([type=checkbox]), select, textarea) { font-size: 16px; }
  .watchbook-page .watchbook-heading-actions .button { min-height: var(--control-height); }
  .time-page .time-clock-panel { padding: var(--panel-padding); }
  .time-page .time-clock-panel.is-employee .time-clock-button { min-width: 0; width: 100%; }
  .time-page .time-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .time-page .time-table .action-icon { min-height: var(--control-height); min-width: var(--control-height); }
  .time-page .time-filter-bar > label { min-width: 0; }

  .auth-content { padding: 12px; }
  .login-panel { padding: 18px; border-radius: var(--panel-radius); }
  .public-header { flex-wrap: wrap; gap: 8px; }
  .onboarding-modal { max-height: var(--mobile-dialog-height); }
}
@media (max-height: 500px) and (max-width: 950px) {
  .schedule-page .schedule-toolbar { position: relative; }
}
