/* GritHQ Alpha4.86 — PWA-only shell parity hotfix
   Scope: installed iOS PWA only (html.ios-standalone).
   Goal: mirror the working native WKWebView shell behavior without changing native iOS.
*/
@media (max-width:959px) {
  /* Use the same dynamic viewport shell as the native host. The older PWA-only
     100lvh fallback can make Home feel mechanically fixed on current iOS. */
  html.ios-standalone body:not(.workout-mode),
  html.ios-standalone body:not(.workout-mode) .app-shell,
  html.ios-standalone body:not(.workout-mode) .app-stage {
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    overflow:hidden!important;
  }

  html.ios-standalone body:not(.workout-mode) .app-stage {
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto minmax(0,1fr) auto!important;
  }

  /* PageViewport remains the scroll owner on every page, including Home. */
  html.ios-standalone body:not(.workout-mode) .main-content,
  html.ios-standalone body.home-mode .main-content {
    grid-row:2!important;
    min-width:0!important;
    min-height:0!important;
    width:100%!important;
    height:auto!important;
    max-height:none!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:auto!important;
    touch-action:pan-y!important;
  }

  /* Match native dock geometry, but keep the home-indicator safe area INSIDE
     the dock so there is no dead strip underneath it. */
  html.ios-standalone body:not(.workout-mode) .bottom-nav {
    grid-row:3!important;
    position:relative!important;
    inset:auto!important;
    left:auto!important;
    right:auto!important;
    top:auto!important;
    bottom:auto!important;
    width:auto!important;
    height:calc(58px + env(safe-area-inset-bottom))!important;
    min-height:calc(58px + env(safe-area-inset-bottom))!important;
    max-height:calc(58px + env(safe-area-inset-bottom))!important;
    margin:6px max(10px,env(safe-area-inset-right)) 0 max(10px,env(safe-area-inset-left))!important;
    padding:4px 4px calc(4px + env(safe-area-inset-bottom))!important;
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    align-items:stretch!important;
    transform:none!important;
    box-sizing:border-box!important;
  }

  /* Explicit cross-axis centering fixes Train / Progress / Profile alignment. */
  html.ios-standalone body:not(.workout-mode) .bottom-nav .nav-btn {
    width:100%!important;
    min-width:0!important;
    min-height:48px!important;
    margin:0!important;
    padding:3px 2px!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    text-align:center!important;
    gap:2px!important;
    box-sizing:border-box!important;
  }

  html.ios-standalone body:not(.workout-mode) .bottom-nav .nav-btn svg {
    display:block!important;
    margin:0 auto!important;
    flex:0 0 auto!important;
  }

  html.ios-standalone body:not(.workout-mode) .bottom-nav .nav-btn small {
    display:block!important;
    width:100%!important;
    margin:0!important;
    text-align:center!important;
  }
}
