/* MEH Mobile App Drawer — Icon Alignment V4.4
   Source baseline: navbar customizer V43 + sequence NavSync V4.3.1.
   Scoped to phones; no PHP, JS, data, or icon assets changed.
   Load AFTER meh-mobile-launcher.css and meh-sequence-nav-sync-v431.css.
*/
@media (max-width:767px) {
  /* A dedicated icon row + label row is the key fix: tile content cannot
     rise/fall when an icon has a different size or a label wraps. */
  #mehOsMount #mehOsMenu {
    --meh-v44-icon-slot:clamp(46px,7.65dvh,70px);
    --meh-v44-label-slot:34px;
    --meh-v44-icon-label-gap:4px;
  }

  #mehOsMount #mehOsMenu .meh-os-grid {
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    justify-items:stretch!important;
    align-items:center!important;
    justify-content:center!important;
    column-gap:clamp(4px,1.5vw,11px)!important;
    /* Keep V43 page/row distribution and the centered 10th tile. */
  }

  #mehOsMount #mehOsMenu .meh-os-app {
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:var(--meh-v44-icon-slot) var(--meh-v44-label-slot)!important;
    column-gap:0!important;
    row-gap:var(--meh-v44-icon-label-gap)!important;
    align-content:center!important;
    justify-content:stretch!important;
    justify-items:center!important;
    align-items:center!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:0 2px!important;
    overflow:visible!important;
  }

  /* Center of each square is now independent of text and other icons.
     Preserve customizer size and x/y/scale on the actual image element. */
  #mehOsMount #mehOsMenu .meh-os-app > .meh-os-icon {
    grid-column:1!important;
    grid-row:1!important;
    place-self:center!important;
    position:relative!important;
    flex:none!important;
    width:min(var(--meh-app-icon-size,var(--meh-os-icon-size,64px)),100%)!important;
    height:auto!important;
    aspect-ratio:1 / 1!important;
    margin:0!important;
    padding:0!important;
    overflow:visible!important;
  }

  #mehOsMount #mehOsMenu .meh-os-app > .meh-os-name {
    grid-column:1!important;
    grid-row:2!important;
    align-self:start!important;
    justify-self:stretch!important;
    display:block!important;
    width:100%!important;
    max-width:none!important;
    height:var(--meh-v44-label-slot)!important;
    min-height:var(--meh-v44-label-slot)!important;
    margin:0!important;
    padding:0 1px!important;
    font-size:clamp(10px,2.9vw,12px)!important;
    line-height:1.3!important;
    text-align:center!important;
    white-space:normal!important;
    text-wrap:balance;
    overflow-wrap:break-word;
    overflow:visible!important;
  }

  /* The last item (FAQ) stays centered on the second column. */
  #mehOsMount #mehOsMenu .meh-os-app.meh-os-last {
    grid-column:2!important;
  }
  /* Keep offset/scale declared by the existing admin customizer.
     No transform overrides here — V42 handles icon centering. */
}

/* On short screens, use compact slots and leave natural drawer scrolling.
   Avoid forcing 4 fractional rows that could clip the bottom icons. */
@media (max-width:767px) and (max-height:719px) {
  #mehOsMount #mehOsMenu {
    --meh-v44-icon-slot:clamp(40px,7dvh,54px);
    --meh-v44-label-slot:30px;
    --meh-v44-icon-label-gap:3px;
  }
  #mehOsMount #mehOsMenu .meh-os-grid {
    grid-template-rows:repeat(4,minmax(84px,auto))!important;
    row-gap:clamp(4px,1dvh,10px)!important;
  }
}

@media (max-width:767px) and (max-height:585px) {
  #mehOsMount #mehOsMenu {
    --meh-v44-icon-slot:40px;
    --meh-v44-label-slot:28px;
    --meh-v44-icon-label-gap:2px;
  }
  #mehOsMount #mehOsMenu .meh-os-grid {
    grid-template-rows:repeat(4,minmax(73px,auto))!important;
  }
}
