/* MAX-Cloud Suite mobile scroll contract — authenticated apps only.
   Appstead uses its own runtime and is intentionally excluded. */
@media (max-width:900px){
  html:has(.shell:not([data-app="appstead"])),
  body:has(.shell:not([data-app="appstead"])){
    width:100%!important;
    height:100%!important;
    max-height:100%!important;
    overflow:hidden!important;
    overscroll-behavior:none!important;
  }
  body:has(.shell:not([data-app="appstead"])) #app{
    width:100%!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    overflow:hidden!important;
    padding:0!important;
  }
  .shell:not([data-app="appstead"]){
    width:100%!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:minmax(0,1fr) auto!important;
    overflow:hidden!important;
    padding:0!important;
  }
  .shell:not([data-app="appstead"])>.main{
    grid-column:1!important;
    grid-row:1!important;
    min-width:0!important;
    min-height:0!important;
    max-height:100%!important;
    display:grid!important;
    grid-template-rows:auto minmax(0,1fr)!important;
    overflow:hidden!important;
  }
  .shell:not([data-app="appstead"]) .topbar{
    grid-row:1!important;
    position:relative!important;
    top:auto!important;
    inset-block-start:auto!important;
    z-index:25!important;
    flex:0 0 auto!important;
    min-width:0!important;
    max-width:100vw!important;
    overflow:visible!important;
  }
  .shell:not([data-app="appstead"]) .content{
    grid-row:2!important;
    width:100%!important;
    min-width:0!important;
    min-height:0!important;
    max-width:none!important;
    max-height:100%!important;
    margin:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;
    touch-action:pan-y!important;
    scroll-behavior:smooth!important;
    scroll-padding-block:12px calc(120px + env(safe-area-inset-bottom))!important;
    scrollbar-gutter:auto!important;
  }
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar{
    grid-column:1!important;
    grid-row:2!important;
    position:relative!important;
    inset:auto!important;
    left:auto!important;
    right:auto!important;
    bottom:auto!important;
    width:100%!important;
    height:calc(68px + env(safe-area-inset-bottom))!important;
    min-height:calc(68px + env(safe-area-inset-bottom))!important;
    max-height:calc(68px + env(safe-area-inset-bottom))!important;
    margin:0!important;
    padding:6px 7px max(6px,env(safe-area-inset-bottom))!important;
    overflow:visible!important;
    border-top:1px solid rgba(255,255,255,.14)!important;
  }
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar>.nav{
    height:56px!important;
    min-height:56px!important;
    max-height:56px!important;
    display:flex!important;
    align-items:stretch!important;
    gap:5px!important;
    padding:0!important;
    overflow-x:auto!important;
    overflow-y:visible!important;
    overscroll-behavior-x:contain!important;
    -webkit-overflow-scrolling:touch!important;
    scrollbar-width:none!important;
    touch-action:pan-x!important;
  }
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar>.nav::-webkit-scrollbar{display:none!important}
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar>.nav>button,
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar>.nav>a,
  .shell:not([data-app="appstead"]):not([data-app="max-cloud"])>.sidebar>.nav>details>summary{
    flex:0 0 auto!important;
    min-width:88px!important;
    min-height:52px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    padding:7px 10px!important;
    white-space:normal!important;
    line-height:1.12!important;
    text-align:center!important;
    touch-action:manipulation!important;
  }
  .shell:not([data-app="appstead"]) .content :is(button,a,input,select,textarea,summary){
    scroll-margin-block:12px 110px!important;
  }
  .shell:not([data-app="appstead"]) .content :is(button,a,summary){
    touch-action:manipulation!important;
  }
  .shell:not([data-app="appstead"]) .content :is(input,select,textarea){
    max-width:100%!important;
  }
  .shell:not([data-app="appstead"]) .content table{
    max-width:100%!important;
  }

  /* Teamo owns the remaining viewport; outer content must never fight chat/list scrolling. */
  .shell[data-app="teamo"] .topbar{
    min-height:54px!important;
    padding:max(7px,env(safe-area-inset-top)) 10px 7px!important;
    gap:8px!important;
  }
  .shell[data-app="teamo"] .topbar .mobile-brand{
    width:34px!important;height:34px!important;max-width:34px!important;object-fit:contain!important;
  }
  .shell[data-app="teamo"] .topbar .title-block{min-width:0!important;flex:1 1 auto!important}
  .shell[data-app="teamo"] .topbar .title-block h1{font-size:.9rem!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
  .shell[data-app="teamo"] .topbar .title-block p{display:none!important}
  .shell[data-app="teamo"] .topbar .tenant-select{min-height:40px!important;max-width:44vw!important;font-size:.75rem!important}
  .shell[data-app="teamo"] .topbar .master-preview-switch{display:none!important}
  .shell[data-app="teamo"] .content{
    padding:0!important;
    overflow:hidden!important;
    scroll-padding:0!important;
  }
  .shell[data-app="teamo"] .content>.role-preview-banner{display:none!important}
  .shell[data-app="teamo"] .tm-app{
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    border:0!important;
    border-radius:0!important;
  }
  .shell[data-app="teamo"] .tm-overview,
  .shell[data-app="teamo"] .tm-conversation-panel,
  .shell[data-app="teamo"] .tm-conversation,
  .shell[data-app="teamo"] .tm-message-surface,
  .shell[data-app="teamo"] .tm-detail-scroll{
    min-height:0!important;
    max-height:100%!important;
  }
  .shell[data-app="teamo"] .tm-overview-list,
  .shell[data-app="teamo"] .tm-message-list,
  .shell[data-app="teamo"] .tm-detail-scroll{
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;
    touch-action:pan-y!important;
  }
  .shell[data-app="teamo"] .tm-message-list{
    scroll-padding-block:16px 86px!important;
  }
  .shell[data-app="teamo"] .tm-composer{
    position:relative!important;
    inset:auto!important;
    flex:0 0 auto!important;
    padding-bottom:max(10px,env(safe-area-inset-bottom))!important;
  }

  /* Plandero/G-Log/VeLog: the shell content is the vertical scroller.
     Internal timelines/lists may still scroll horizontally. */
  .shell[data-app="plandero"] .content,
  .shell[data-app="g-log"] .content,
  .shell[data-app="velog"] .content{
    overflow-y:auto!important;
    min-height:0!important;
    -webkit-overflow-scrolling:touch!important;
    touch-action:pan-y!important;
  }
  .shell[data-app="plandero"] .pld-workspace,
  .shell[data-app="g-log"] .gl-app,
  .shell[data-app="velog"] .vl-app{
    min-height:0!important;
    height:auto!important;
    max-height:none!important;
  }
}

/* Keyboard-open / very short mobile viewport: preserve the active input and chat composer. */
@media (max-width:900px) and (max-height:560px){
  .shell:not([data-app="appstead"]) .topbar{min-height:46px!important;padding-block:5px!important}
  .shell[data-app="teamo"] .tm-navigation{padding-bottom:max(2px,env(safe-area-inset-bottom))!important}
  .shell[data-app="teamo"] .tm-nav-item{min-height:50px!important}
  .shell[data-app="teamo"] .tm-message-list{padding-block:10px!important}
}

@media(max-width:900px){
  .shell[data-app="teamo"]{grid-template-rows:minmax(0,1fr)!important}
  .shell[data-app="teamo"]>.sidebar{display:none!important}
  .teamo-mobile-app-bundle{display:block!important;position:relative!important;flex:0 0 auto!important;margin-inline-start:2px!important}
  .teamo-mobile-app-bundle>summary{display:flex!important;align-items:center!important;justify-content:center!important;min-width:52px!important;height:40px!important;padding:0 9px!important;border:1px solid rgba(255,255,255,.15)!important;border-radius:12px!important;background:rgba(0,0,0,.18)!important;color:var(--deep)!important;font:700 .68rem/1 Lexend,Arial,sans-serif!important;list-style:none!important;cursor:pointer!important}
  .teamo-mobile-app-bundle>summary::-webkit-details-marker{display:none!important}
  .teamo-mobile-app-sheet{position:fixed!important;left:10px!important;right:10px!important;top:calc(max(10px,env(safe-area-inset-top)) + 56px)!important;z-index:120!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;max-height:min(70dvh,560px)!important;padding:12px!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;border:1px solid rgba(255,255,255,.18)!important;border-radius:18px!important;background:rgba(8,8,8,.985)!important;box-shadow:0 22px 64px rgba(0,0,0,.55)!important}
  .teamo-mobile-app-sheet>strong{grid-column:1/-1!important;padding:4px 2px 8px!important;color:#fff!important;font-size:.9rem!important}
  .teamo-mobile-app-sheet>a,.teamo-mobile-app-sheet>button{min-width:0!important;min-height:50px!important;padding:10px 11px!important;border:1px solid rgba(255,255,255,.08)!important;border-radius:12px!important;background:rgba(255,255,255,.07)!important;color:#fff!important;font:650 .75rem/1.25 Lexend,Arial,sans-serif!important;text-align:left!important;text-decoration:none!important;overflow-wrap:anywhere!important}
}
@media(min-width:901px){.teamo-mobile-app-bundle{display:none!important}}
