/* Phones use a single bottom-sheet pattern; tablet and desktop keep anchored popovers. */
@media (max-width:650px) {
 html { --sheet-max-height:calc(var(--sheet-height,100dvh) - max(var(--surface-gap,16px),env(safe-area-inset-top),var(--preview-safe-top,0px))); }
 html.mobile-sheet-open,html.mobile-sheet-open body { overflow:hidden; overscroll-behavior:none; }
 html[data-theme] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet) {
  position:fixed!important; inset:auto 0 var(--sheet-keyboard-offset,0px)!important;
  width:100%!important; min-width:0!important; max-width:100%!important;
  height:auto; max-height:var(--sheet-max-height)!important;
  margin:0!important; box-sizing:border-box; border-radius:var(--sheet-corner,52px) var(--sheet-corner,52px) 0 0!important;
  padding:24px 16px max(16px,env(safe-area-inset-bottom),var(--preview-safe-bottom,0px))!important;
  background:var(--surface)!important; color:var(--ink); border:0!important;
  box-shadow:0 -12px 48px rgb(0 0 0 / .18)!important;
  overflow:auto!important; overscroll-behavior:contain; scroll-padding-block:24px;
  animation:none!important; transform:none; filter:none;
  opacity:1; translate:none; pointer-events:auto; transition:none!important;
 }
 html[data-theme] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet)::before {
  content:''; display:block; position:absolute; top:10px; left:calc(50% - 18px);
  width:36px; height:4px; border-radius:4px; background:var(--muted); opacity:.35;
 }
 html[data-theme] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet)::backdrop {  background:rgb(0 0 0 / .38); backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px); }
 html[data-theme='dark'] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet)::backdrop { background:rgb(0 0 0 / .55); }
 html[data-theme] .mobile-sheet.custom-select-popover { padding:20px 8px max(12px,env(safe-area-inset-bottom),var(--preview-safe-bottom,0px))!important; overflow:hidden!important; }
 html[data-theme] .mobile-sheet .custom-select-option { min-height:48px; text-align:left; }
 html[data-theme] .mobile-sheet.profile-dropdown > :is(button,a) { width:100%; min-height:48px; justify-content:flex-start; text-align:left; }
 html[data-theme] .mobile-sheet.profile-dropdown .profile-dropdown-heading { padding:4px 14px 16px; }
 html[data-theme] body .mobile-sheet.notification-dropdown:popover-open { padding:24px var(--page-surface-inset) max(16px,env(safe-area-inset-bottom),var(--preview-safe-bottom,0px))!important; }
 html[data-theme] .mobile-sheet.notification-dropdown .notification-list { max-height:none; overflow:visible; }
 html[data-theme] .mobile-sheet.date-popover { padding-left:max(16px,calc((100vw - 420px)/2))!important; padding-right:max(16px,calc((100vw - 420px)/2))!important; }
 html[data-theme] dialog.account-dialog { overflow-x:hidden!important; }
 html[data-theme] dialog.account-dialog :is(.account-person-card,.account-avatar-choice,.employment-fields,.custom-select) { min-width:0; max-width:100%; }
 html[data-theme] dialog .modal-head { margin-bottom:var(--surface-gap); }
 html[data-theme] dialog .modal-head h2 { padding-right:8px; }
}
@media (prefers-reduced-motion:reduce) { html[data-theme] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet),html[data-theme] :is(dialog:not(.onboarding-tour):not(.employee-profile-drawer),.mobile-sheet)::backdrop { animation:none!important; transition:none!important; } }

/* Desktop action menus use the top layer, independent of card stacking/clipping. */
@media(min-width:651px) {
 html[data-theme] body :is(#modal,#owner-modal):not(.employee-profile-drawer,.onboarding-tour,.plan-access-dialog,.support-conversation-dialog) { --dialog-inset:20px; padding:var(--dialog-inset); }
 html[data-theme] .directory-menu>.profile-dropdown.desktop-action-popover:popover-open {
  position:fixed; inset:auto; top:var(--action-menu-top); left:var(--action-menu-left); right:auto; bottom:auto; margin:0;
  box-sizing:border-box; max-height:calc(100dvh - 24px); overflow:auto; overscroll-behavior:contain;
 }
 html[data-theme] .desktop-action-popover::backdrop { background:transparent; backdrop-filter:none; -webkit-backdrop-filter:none; pointer-events:none; }
}
