code: function maxZIndexInUse() {
    const elements = document.body.querySelectorAll('*');
    const zIndices = Array.from(elements, element => {
      const style = getComputedStyle(element);
      let zIndex = 0;
      if (style.position !== 'static' && style.zIndex !== 'auto') {
        const parsed = style.zIndex ? parseInt(style.zIndex) : 0;
        zIndex = !isNaN(parsed) ? parsed : 0;
      }
      return zIndex;
    });
    return Math.max(...zIndices);
  }
docs: /*
  Return the highest z-index currently in use in the document's light DOM.
  
  This calculation looks at all light DOM elements, so is theoretically
  expensive. That said, it only runs when an overlay is opening, and is only used
  if an overlay doesn't have a z-index already. In cases where performance is
  an issue, this calculation can be completely circumvented by manually
  applying a z-index to an overlay.