/* RD NovaSphere V111 — mobile viewport reliability, effortless scroll, full NovaAI fit. */
:root{--rd-vv-height:100dvh;--rd-vv-width:100vw}
html{max-width:100%;overflow-x:clip!important;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{max-width:100%;overflow-x:clip!important}

/* Never let common layout wrappers create sideways document scrolling. */
:where(main,section,article,header,nav,footer,.shell,.container,.wrap,.grid,.card,.panel,.app-shell,.chat-main,.chat-scroll,.messages){min-width:0;max-width:100%}
:where(img,video,svg,canvas){max-width:100%}
:where(input,textarea,select,button){min-width:0;max-width:100%}

/* Full NovaAI: the composer must fit the physical phone viewport, including when the keyboard is open. */
body:has(.app-shell){width:100%!important;max-width:100%!important;overflow:hidden!important}
body:has(.app-shell) .app-shell,
body:has(.app-shell) .chat-main{width:100%!important;max-width:100%!important;min-width:0!important}
body:has(.app-shell) .composer-wrap{
  width:100%!important;max-width:100%!important;min-width:0!important;
  overflow:clip!important;box-sizing:border-box!important;
}
body:has(.app-shell) .composer{width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box!important}
body:has(.app-shell) #promptInput{width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box!important}
body:has(.app-shell) .composer-bottom{min-width:0!important;max-width:100%!important}
body:has(.app-shell) .composer-tools{min-width:0!important;max-width:100%!important}

@media(max-width:820px){
  body:has(.app-shell) .app-shell{height:var(--rd-vv-height)!important;min-height:0!important}
  body:has(.app-shell) .chat-main{height:var(--rd-vv-height)!important;min-height:0!important;grid-template-rows:auto minmax(0,1fr) auto!important}
  body:has(.app-shell) .chat-scroll{min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;overscroll-behavior-y:contain}
  body:has(.app-shell) .composer-wrap{
    padding-left:max(8px,env(safe-area-inset-left,0px))!important;
    padding-right:max(8px,env(safe-area-inset-right,0px))!important;
    padding-bottom:max(8px,env(safe-area-inset-bottom,0px))!important;
  }
  body:has(.app-shell) .composer-bottom{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) 46px!important;
    gap:8px!important;
    align-items:end!important;
  }
  body:has(.app-shell) .composer-tools{
    display:flex!important;flex-wrap:wrap!important;gap:7px!important;align-items:center!important;
    overflow:visible!important;
  }
  body:has(.app-shell) .composer-tools .tool-chip{
    flex:0 1 auto!important;max-width:100%!important;min-height:42px!important;
    padding:.58rem .72rem!important;font-size:12px!important;line-height:1.15!important;
    white-space:nowrap!important;word-break:normal!important;overflow-wrap:normal!important;
  }
  body:has(.app-shell) #voiceChatBtn{flex:1 1 145px!important}
  body:has(.app-shell) #contextInfo{flex:1 1 100%!important;min-width:0!important;font-size:11px!important;white-space:normal!important}
  body:has(.app-shell) .send-btn{grid-column:2!important;grid-row:1!important;align-self:end!important;width:46px!important;height:46px!important;min-width:46px!important;max-width:46px!important}
  body:has(.app-shell) .footer-note{max-width:100%!important;overflow-wrap:break-word!important}
}

@media(max-width:430px){
  body:has(.app-shell) .composer{padding:10px!important;border-radius:16px!important}
  body:has(.app-shell) .composer-tools{gap:6px!important}
  body:has(.app-shell) .composer-tools .tool-chip{font-size:11px!important;padding:.55rem .62rem!important}
  body:has(.app-shell) #attachBtn{flex:0 1 auto!important}
  body:has(.app-shell) #micBtn{flex:0 1 auto!important}
  body:has(.app-shell) #voiceChatBtn{flex:1 1 132px!important}
}

/* Portfolio scrolling: preserve each portfolio design, but never let effects fight finger scrolling. */
@media(max-width:820px){
  body[data-rd-individual-portfolio="1"]{
    overflow-x:clip!important;overflow-y:visible!important;
    touch-action:pan-y pinch-zoom!important;
    overscroll-behavior-x:none!important;overscroll-behavior-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
  }
  body[data-rd-individual-portfolio="1"] :where(main,section,article,.card,.panel,.hero,.grid,.shell){
    touch-action:pan-y!important;min-width:0!important;max-width:100%!important;
  }
  body[data-rd-individual-portfolio="1"] :where(canvas,.ambient-layer,body::before){pointer-events:none!important}
  body[data-rd-individual-portfolio="1"] :where(.glossary-modal:not(.open)){pointer-events:none!important}
  body[data-rd-individual-portfolio="1"] :where(p,li,h1,h2,h3,h4,.tag,.chip,.pill,.btn,button,a){
    word-break:normal!important;hyphens:none!important;
  }
  body[data-rd-individual-portfolio="1"] :where(p,li){overflow-wrap:break-word!important}
}
