/* Both device orientations are supported. Existing landscape rules keep
   their geometry; only narrow portrait sheets need a different arrangement. */
@layer pkw-unite-shell {
  html.pkw-orientation-flexible :is(#orient-warning,#pkwRotatePrompt,#pkwLandscapeGate) {display:none!important}
}

@media (orientation:portrait) and (max-width:760px) {
  html.pkw-orientation-flexible body.unite-login .masthead {top:max(24px,env(safe-area-inset-top));left:20px;right:20px}
  html.pkw-orientation-flexible body.unite-login .brand {width:clamp(190px,58vw,300px)}
  html.pkw-orientation-flexible body.unite-login .masthead-tools {top:0}
  html.pkw-orientation-flexible body.unite-login .entry-actions {width:calc(100% - 40px);max-width:440px;bottom:calc(max(18px,env(safe-area-inset-bottom)) + 62px);gap:12px;flex-direction:column;align-items:stretch}
  html.pkw-orientation-flexible body.unite-login .entry-actions>#starter-card {flex:none;width:100%}
  html.pkw-orientation-flexible body.unite-login .entry-open-login,
  html.pkw-orientation-flexible body.unite-login .guest-button {min-height:50px;flex:none;width:100%;font-size:19px}
  html.pkw-orientation-flexible body.unite-login .utility-rail {top:auto;bottom:calc(max(18px,env(safe-area-inset-bottom)) + 184px);right:20px;flex-direction:row;gap:10px}
  html.pkw-orientation-flexible body.unite-login .entry-secondary-links {left:20px;right:20px;bottom:max(10px,env(safe-area-inset-bottom));justify-content:center;flex-wrap:wrap;gap:4px 12px}
  html.pkw-orientation-flexible body.unite-login .entry-secondary-links button {min-height:44px;font-size:12px}
  html.pkw-orientation-flexible body.unite-login :is(.entry-dialog,.recovery-dialog) {width:calc(100vw - 24px);min-width:0;max-width:480px;max-height:calc(100dvh - 24px);padding-inline:20px}
  html.pkw-orientation-flexible body.unite-login .entry-dialog .login-heading,
  html.pkw-orientation-flexible body.unite-login .entry-dialog>h2 {margin-inline:-20px}
  html.pkw-orientation-flexible body.unite-login .entry-dialog .login-heading h2,
  html.pkw-orientation-flexible body.unite-login .entry-dialog>h2 {font-size:22px}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-inner {padding-top:max(60px,10vh);padding-bottom:max(20px,env(safe-area-inset-bottom))}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-title {height:auto;min-height:64px}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-title h2 {width:100%;min-height:64px;padding:10px 18px 10px 92px;font-size:20px;line-height:1.3}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-title .entry-crest {left:14px;top:-12px;width:66px;height:70px}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-content {min-height:0;padding:26px 22px}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-intro {font-size:16px;margin-bottom:22px}
  html.pkw-orientation-flexible body.unite-login .entry-legal-columns {width:100%;grid-template-columns:minmax(0,1fr);gap:22px}
  html.pkw-orientation-flexible body.unite-login .entry-legal-column {gap:10px}
  html.pkw-orientation-flexible body.unite-login :is(.entry-legal-link,.entry-agreement) {font-size:17px;min-height:44px}
  html.pkw-orientation-flexible body.unite-login .entry-sheet-actions {width:calc(100% - 40px);gap:12px;margin-top:22px}
  html.pkw-orientation-flexible body.unite-login .entry-round-button {min-width:0;min-height:46px;padding:9px 12px;font-size:18px}
  html.pkw-orientation-flexible body.unite-login .entry-editions {width:100%;grid-template-columns:minmax(0,1fr);gap:12px}
  html.pkw-orientation-flexible body.unite-login .entry-edition {min-height:58px}
  html.pkw-orientation-flexible body.unite-login .entry-confirm-copy {padding:24px 8px;font-size:17px}
  html.pkw-orientation-flexible body.unite-login .entry-confirm-actions {gap:12px}
  html.pkw-orientation-flexible body.unite-login #cookieConsent {width:calc(100% - 24px);padding:14px}
  html.pkw-orientation-flexible body.unite-login .cc-actions {flex-wrap:wrap}
  html.pkw-orientation-flexible body:not(.unite-login)>.card {width:calc(100vw - 24px)!important;max-width:640px!important}
}

@layer pkw-unite-pages {
  @media (orientation:portrait) and (max-width:760px) {
    html.pkw-orientation-flexible #pml .pml-window {grid-template-columns:minmax(0,1fr)!important;grid-template-rows:auto auto minmax(0,1fr)!important;padding:0 max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left))!important;gap:0!important}
    html.pkw-orientation-flexible #pml .pml-topbar {grid-column:1!important;grid-row:1!important;min-height:64px!important;padding:10px 0!important;margin:0!important;gap:8px!important;flex-wrap:wrap!important}
    html.pkw-orientation-flexible #pml .pml-topbar-title {font-size:23px!important;line-height:1.2!important;min-width:0!important;overflow-wrap:anywhere!important}
    html.pkw-orientation-flexible #pml .pml-back {min-width:48px!important;height:44px!important}
    html.pkw-orientation-flexible #pml .pml-wallet {min-width:120px!important;height:44px!important;font-size:15px!important}
    html.pkw-orientation-flexible #pml .pml-rail {grid-column:1!important;grid-row:2!important;display:flex!important;flex-direction:row!important;align-items:stretch!important;position:static!important;gap:8px!important;padding:8px 0 12px!important;margin:0!important;width:100%!important;max-height:none!important;overflow-x:auto!important;overflow-y:hidden!important;overscroll-behavior-x:contain!important;scrollbar-width:thin!important}
    html.pkw-orientation-flexible #pml .pml-rail button {flex:0 0 auto!important;width:auto!important;min-width:88px!important;min-height:46px!important;padding:10px 14px!important;white-space:nowrap!important;clip-path:none!important}
    html.pkw-orientation-flexible #pml .pml-rail button>span:not(.pml-dot) {font-size:14px!important;line-height:1.3!important;white-space:nowrap!important}
    html.pkw-orientation-flexible #pml .pml-sheet {grid-column:1!important;grid-row:3!important;width:100%!important;min-width:0!important;min-height:0!important;height:100%!important;margin:0!important;padding:12px!important;overflow:auto!important}
    html.pkw-orientation-flexible #pml.no-rail .pml-window {grid-template-rows:auto minmax(0,1fr)!important}
    html.pkw-orientation-flexible #pml.no-rail .pml-sheet {grid-row:2!important}
    html.pkw-orientation-flexible #pml[data-embedded="1"] .pml-window {grid-template-rows:auto minmax(0,1fr)!important;padding-top:6px!important}
    html.pkw-orientation-flexible #pml[data-embedded="1"] .pml-rail {grid-row:1!important}
    html.pkw-orientation-flexible #pml[data-embedded="1"] .pml-sheet {grid-row:2!important}
    html.pkw-orientation-flexible #pml.no-rail[data-embedded="1"] .pml-window {grid-template-rows:minmax(0,1fr)!important}
    html.pkw-orientation-flexible #pml.no-rail[data-embedded="1"] .pml-sheet {grid-row:1!important}
    html.pkw-orientation-flexible #pml[data-page="profile"] .rp-layout {grid-template-columns:minmax(0,1fr)!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] .inv-body {grid-template-columns:minmax(0,1fr)!important;gap:16px!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] .item-area {grid-column:1!important;grid-row:auto!important;min-width:0!important;width:100%!important;padding:0!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] #bagDetailV2 {grid-column:1!important;grid-row:auto!important;position:static!important;min-width:0!important;width:100%!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] .area-header {display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:10px!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] .search-row {display:flex!important;flex-wrap:wrap!important;width:100%!important;gap:8px!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] :is(.inv-sort,.inv-search) {flex:1 1 140px!important;width:100%!important;min-width:0!important;max-width:100%!important;min-height:44px!important}
    html.pkw-orientation-flexible #pml[data-page="inventory"] .item-grid {grid-template-columns:repeat(auto-fill,minmax(100px,1fr))!important}
  }
}

@layer pkw-unite-map {
  @media (orientation:portrait) and (max-width:760px) {
    html.pkw-orientation-flexible.pkw-handheld #pkwMobileHUD .pm-button {order:0!important}
    html.pkw-orientation-flexible.pkw-handheld body:not(.pkw-interior-active) #pkwMobileHUD .pm-actions {display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;grid-auto-rows:72px!important;gap:6px!important;width:min(216px,calc(100vw - 136px))!important;height:auto!important;padding:0!important;right:max(8px,env(safe-area-inset-right))!important;bottom:max(18px,env(safe-area-inset-bottom))!important;transform:none!important}
    html.pkw-orientation-flexible.pkw-handheld #pkwMobileHUD .pm-actions>.pm-button {position:relative!important;inset:auto!important;transform:none!important;width:100%!important;min-width:44px!important;height:72px!important;min-height:72px!important;grid-template-rows:44px 28px!important}
    html.pkw-orientation-flexible.pkw-handheld #pkwMobileHUD .pm-actions>.pm-button>span {height:auto!important;min-height:28px!important;line-height:13px!important;white-space:normal!important;overflow-wrap:normal!important}
  }
}

@layer tamerra-content {
  @media (orientation:portrait) and (max-width:760px) {
    html.pkw-orientation-flexible #pml[data-page="inventory"] :is(.inv-sort,.inv-search) {height:44px!important;min-height:44px!important;max-height:none!important}
  }
}
