/* Launch review 4 Dec 2026: phone layout (fix 2), scroll traps (fix 4), 16 px inputs (fix 8), 44 px touch targets.
   Loaded last so it wins over the older narrow-screen rules. Everything is inside the phone breakpoint except the two bars being hidden on computers. */
#mTop,#mBar{display:none}
body:has(#app[hidden]) #hqBell{display:none}

@media (max-width:767px){
  /* the page itself is the one scroller on a phone (body must not become a second scroll box) */
  html{overflow-x:hidden!important;overflow-y:auto!important;height:auto!important}
  body{overflow-x:clip!important;overflow-y:visible!important;height:auto!important;max-width:100%}
  body,body.pd-on{padding-top:calc(52px + env(safe-area-inset-top,0px))!important;padding-bottom:calc(64px + env(safe-area-inset-bottom,0px));-webkit-text-size-adjust:100%}
  body.pd-on #app,body.pd-on main{height:auto!important}
  body:has(#app[hidden]){padding:0!important}
  body:has(#app[hidden]) #mTop,body:has(#app[hidden]) #mBar{display:none!important}

  /* top bar */
  #mTop{display:flex;position:fixed;top:0;left:0;right:0;z-index:1150;height:calc(52px + env(safe-area-inset-top,0px));padding:env(safe-area-inset-top,0px) 8px 0 12px;align-items:center;gap:8px;background:var(--card,#fff);border-bottom:1px solid var(--line,#e6eaf0)}
  #mTop .m-logo{width:28px;height:28px;border-radius:4px;flex:none}
  #mTop .m-title{flex:1;min-width:0;font:700 16px/1.2 var(--disp,var(--sans,Inter,sans-serif));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--txt,#0f172a)}
  #mTop .m-ico{flex:none;width:44px;height:44px;display:flex;align-items:center;justify-content:center;border:0;background:none;color:var(--mut,#64748b);border-radius:4px;padding:0}
  #mTop svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
  #mTopSlot{flex:none;display:flex}
  #mTopSlot #hqBell{position:relative;top:auto;right:auto;height:auto}
  #mTopSlot #hqBell>button{height:44px;padding:0 10px;border:0;background:none}
  #mTopSlot #hqBell .lbl{display:none}
  #mTopSlot #hqBellMenu{position:fixed;top:calc(52px + env(safe-area-inset-top,0px));right:8px;left:8px;width:auto}

  /* bottom menu bar */
  #mBar{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;z-index:1150;height:calc(64px + env(safe-area-inset-bottom,0px));padding:0 4px env(safe-area-inset-bottom,0px);background:var(--card,#fff);border-top:1px solid var(--line,#e6eaf0);box-shadow:0 -4px 16px rgba(15,23,42,.05)}
  #mBar button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:56px;border:0;background:none;color:var(--mut,#64748b);font:600 12px/1 var(--sans,Inter,sans-serif);padding:6px 2px;border-radius:4px}
  #mBar button[hidden]{display:none}
  #mBar svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
  #mBar button.on{color:var(--brand,#2298dd)}
  body.m-kb #mBar{display:none}
  body.m-kb{padding-bottom:0}

  /* the desktop menu is replaced by the bars; it opens as a full sheet from More / Agents / search */
  #app{display:block!important;height:auto!important;overflow:visible!important}
  aside{display:none!important}
  body.m-sheet aside{display:flex!important;flex-direction:column!important;position:fixed;z-index:1140;top:calc(52px + env(safe-area-inset-top,0px));bottom:calc(64px + env(safe-area-inset-bottom,0px));left:0;right:0;width:auto!important;overflow:auto!important;padding:10px 12px 16px!important;gap:4px;background:var(--card,#fff);align-items:stretch!important;border:0!important;overscroll-behavior:contain}
  body.m-sheet main{visibility:hidden}
  body.m-sheet aside #navScroll,body.m-sheet aside #navFoot,body.m-sheet aside .nav-g,body.m-sheet aside .nav-b,body.m-sheet aside #roster{display:flex!important;flex-direction:column!important;align-items:stretch!important;overflow:visible!important;gap:2px!important}
  body.m-sheet aside .nav-h,body.m-sheet aside .nav-t{display:flex!important;min-height:44px;align-items:center}
  body.m-sheet aside .nav-g.closed .nav-b{display:none!important}
  body.m-sheet aside .ag{width:auto!important;white-space:normal!important;min-height:52px;margin:0!important}
  body.m-sheet aside .ag small{display:block!important}
  body.m-sheet aside #ovBtn{align-self:stretch!important;white-space:normal!important}
  body.m-sheet aside .ag[hidden]{display:none!important}
  body.m-sheet aside .brand{display:none!important}
  body.m-sheet aside .hqs{display:none}
  body.m-sheet[data-sheet=search] aside .hqs,body.m-sheet[data-sheet=all] aside .hqs{display:block;margin:0 0 8px}
  body.m-sheet aside #acct{flex-direction:column!important;align-items:stretch!important;margin:8px 0 0!important;padding-top:10px!important;border-top:1px solid var(--line,#e6eaf0)!important}
  body.m-sheet aside #acct .who small,body.m-sheet aside #acct .lnk{display:flex!important;gap:16px}
  body.m-sheet aside #acct button{min-height:44px}
  .hqs-box{z-index:1250!important;left:12px!important;right:12px;width:auto!important}

  /* one column, page headers stack the title above the controls */
  main{padding:0 12px 20px!important;height:auto!important;min-height:0!important;overflow:visible!important}
  main>header,header#agentHead{flex-direction:column!important;align-items:stretch!important;flex-wrap:wrap!important;gap:10px!important;margin:0 -12px 8px!important;padding:12px!important;height:auto!important;position:static!important}
  main>header>*{max-width:100%;min-width:0}
  main>header h1{font-size:20px!important;line-height:1.25}
  main>header .hc-hr,main>header>div:last-child:not(:first-child){display:flex;flex-wrap:wrap;gap:8px}
  .grid,.grid.atkgrid,.jt-cols,.ov-grid{display:flex!important;flex-direction:column!important;grid-template-columns:minmax(0,1fr)!important;gap:12px}
  .grid>.col{width:100%!important;min-width:0!important;max-width:100%!important}
  .card{min-width:0;max-width:100%}
  img,video,svg,canvas,iframe,table{max-width:100%}
  pre,code{white-space:pre-wrap;overflow-wrap:anywhere}
  .jt-wrap{display:block!important}
  .jt-panel:not([hidden]){position:fixed!important;inset:calc(52px + env(safe-area-inset-top,0px)) 0 0 0!important;z-index:1160!important;width:auto!important;max-width:none!important;overflow:auto!important;background:var(--card,#fff);padding:12px!important;border-radius:0!important;overscroll-behavior:contain}

  /* fix 4: no scroll boxes inside the page; panels grow to their full height so the page itself scrolls */
  #chan,#props,#works,#msgs,#feed,.hc-row1 .ov-alerts,.jt-log,.tkt-log,#chatApprovals .cal,.wa-msgs,.cu-mvl,#tkList,.card.grow,.thcard,.chcard,#utBody,#tasksBody,#csmBody,#miracleBody,#ovBody{max-height:none!important;overflow:visible!important;height:auto!important;min-height:0!important}
  #contentMain iframe{height:calc(100vh - 140px)!important}

  /* the message boxes stay on screen above the keyboard */
  #chatForm,#thForm{position:sticky;bottom:calc(64px + env(safe-area-inset-bottom,0px));z-index:6;background:var(--card,#fff);padding-top:8px;padding-bottom:8px}
  body.m-kb #chatForm,body.m-kb #thForm{bottom:0}

  /* fix 8: 16 px text in every box so iPhones stop zooming in */
  input,textarea,select,[contenteditable=true]{font-size:16px!important}

  /* 44 px touch targets */
  main button,main select,main [role=button],#mBar button,.mcard button,#paBox button,#lcBox button,#pdBox button,#laBox button,.uf-modal button,.jt-panel button{min-height:44px;min-width:44px}
  main a.link,main .chip,main .tab,main nav#tabs button{min-height:44px;display:inline-flex;align-items:center}
  input[type=checkbox],input[type=radio]{width:22px;height:22px}

  /* windows open above the bars */
  #modal,#paOverlay,#lcOverlay,#pdOverlay,#laOverlay,.uf-modal,.jt-lbox{z-index:1300!important}
  #paBox,#lcBox,#pdBox,#laBox,.mcard{max-height:calc(100vh - 32px)!important;width:calc(100vw - 16px)!important}
}
