/* V4.14.1 — emergency UI cleanup pass.
   Goal: eliminate remaining search clipping, visible rail scrollbars, and residual layout collisions.
*/

/* --- Universal overflow safety --- */
html,body{overflow-x:hidden!important}
body.sp-ui-v4140,body.sp-ui-v4130{overflow-x:hidden!important}
body.sp-ui-v4140 :is(.sp-shell,.sp-feed,.sp-app-page,.sp-profile-page,.sp-settings-page,.sp-messages-page,.sp-live-page,.sp-notifications-page,.sp-friends-page,.sp-search-page,.sp-group-page,.sp-page-profile,.sp-dv-workspace,.sp-messenger-thread,.sp-messenger-sidebar),
body.sp-ui-v4130 :is(.sp-shell,.sp-feed,.sp-app-page,.sp-profile-page,.sp-settings-page,.sp-messages-page,.sp-live-page,.sp-notifications-page,.sp-friends-page,.sp-search-page,.sp-group-page,.sp-page-profile,.sp-dv-workspace,.sp-messenger-thread,.sp-messenger-sidebar){min-width:0!important;max-width:100%!important}
body.sp-ui-v4140 :is(.sp-post-card,.sp-composer,.sp-widget,.sp-comments-card,.sp-profile-card,.sp-profile-wide-card,.sp-person-card,.sp-friend-result,.sp-page-card,.sp-group-card,.sp-dv-card,.sp-fbpd-card,.sp-pd-card,.sp-settings-card,.sp-notifications-page-card,.sp-chat-head,.sp-chat-compose,.sp-messenger-shell),
body.sp-ui-v4130 :is(.sp-post-card,.sp-composer,.sp-widget,.sp-comments-card,.sp-profile-card,.sp-profile-wide-card,.sp-person-card,.sp-friend-result,.sp-page-card,.sp-group-card,.sp-dv-card,.sp-fbpd-card,.sp-pd-card,.sp-settings-card,.sp-notifications-page-card,.sp-chat-head,.sp-chat-compose,.sp-messenger-shell){min-width:0!important;max-width:100%!important}
body.sp-ui-v4140 :is(img,video,canvas,iframe,svg),
body.sp-ui-v4130 :is(img,video,canvas,iframe,svg){max-width:100%!important}
body.sp-ui-v4140 :is(.sp-post-text,.sp-chat-bubble,.sp-right-chat-copy,.sp-person-copy,.sp-profile-name-block,.sp-widget-title,.sp-request-main,.sp-mobile-menu-grid a,.sp-settings-mobile-list a,.sp-settings-mobile-list button,.sp-call-push-copy,.sp-notification-setting-row > span),
body.sp-ui-v4130 :is(.sp-post-text,.sp-chat-bubble,.sp-right-chat-copy,.sp-person-copy,.sp-profile-name-block,.sp-widget-title,.sp-request-main,.sp-mobile-menu-grid a,.sp-settings-mobile-list a,.sp-settings-mobile-list button,.sp-call-push-copy,.sp-notification-setting-row > span){overflow-wrap:anywhere!important}

/* --- Search bar fix --- */
body.sp-ui-v4140 .sp-topbar-inner,
body.sp-ui-v4130 .sp-topbar-inner{overflow:hidden!important}
body.sp-ui-v4140 .sp-search,
body.sp-ui-v4130 .sp-search{
  display:grid!important;
  grid-template-columns:20px minmax(0,1fr)!important;
  align-items:center!important;
  column-gap:10px!important;
  min-width:0!important;
  max-width:100%!important;
  overflow:hidden!important;
}
body.sp-ui-v4140 .sp-search > *,
body.sp-ui-v4130 .sp-search > *{min-width:0!important;max-width:100%!important}
body.sp-ui-v4140 .sp-search .sp-search-svg,
body.sp-ui-v4140 .sp-search .sp-icon,
body.sp-ui-v4130 .sp-search .sp-search-svg,
body.sp-ui-v4130 .sp-search .sp-icon{display:block!important;justify-self:start!important;align-self:center!important;margin:0!important;flex:none!important}
body.sp-ui-v4140 .sp-search input,
body.sp-ui-v4130 .sp-search input{
  display:block!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  margin:0!important;
  line-height:1.25!important;
  -webkit-appearance:none!important;
  appearance:none!important;
  border:0!important;
  outline:0!important;
  background:transparent!important;
  box-shadow:none!important;
}
body.sp-ui-v4140 .sp-search input::-webkit-search-decoration,
body.sp-ui-v4140 .sp-search input::-webkit-search-cancel-button,
body.sp-ui-v4140 .sp-search input::-webkit-search-results-button,
body.sp-ui-v4140 .sp-search input::-webkit-search-results-decoration,
body.sp-ui-v4130 .sp-search input::-webkit-search-decoration,
body.sp-ui-v4130 .sp-search input::-webkit-search-cancel-button,
body.sp-ui-v4130 .sp-search input::-webkit-search-results-button,
body.sp-ui-v4130 .sp-search input::-webkit-search-results-decoration{display:none!important;-webkit-appearance:none!important}

/* --- Right rail / contacts scrollbar removal --- */
body.sp-ui-v4140 :is(.sp-right,.sp-right .sp-sticky,.sp-right-chat-widget,.sp-right-chat-panel,.sp-right-chat-list,.sp-contacts-widget),
body.sp-ui-v4130 :is(.sp-right,.sp-right .sp-sticky,.sp-right-chat-widget,.sp-right-chat-panel,.sp-right-chat-list,.sp-contacts-widget){scrollbar-width:none!important;-ms-overflow-style:none!important}
body.sp-ui-v4140 :is(.sp-right,.sp-right .sp-sticky,.sp-right-chat-widget,.sp-right-chat-panel,.sp-right-chat-list,.sp-contacts-widget)::-webkit-scrollbar,
body.sp-ui-v4130 :is(.sp-right,.sp-right .sp-sticky,.sp-right-chat-widget,.sp-right-chat-panel,.sp-right-chat-list,.sp-contacts-widget)::-webkit-scrollbar{display:none!important;width:0!important;height:0!important;background:transparent!important}
body.sp-ui-v4140 .sp-right .sp-sticky,
body.sp-ui-v4130 .sp-right .sp-sticky{padding-right:0!important;margin-right:0!important}
body.sp-ui-v4140 .sp-right-chat-list,
body.sp-ui-v4130 .sp-right-chat-list{padding-right:0!important}

/* --- Residual widget / action cleanup --- */
body.sp-ui-v4140 .sp-call-push-actions,
body.sp-ui-v4130 .sp-call-push-actions{align-items:stretch!important}
body.sp-ui-v4140 .sp-call-push-actions :is(button,a),
body.sp-ui-v4130 .sp-call-push-actions :is(button,a){word-break:break-word!important}
body.sp-ui-v4140 .sp-notification-setting-row,
body.sp-ui-v4130 .sp-notification-setting-row{gap:14px!important}
body.sp-ui-v4140 .sp-notification-setting-row > span,
body.sp-ui-v4130 .sp-notification-setting-row > span{padding-right:4px!important}

/* --- Mobile-specific refinements --- */
@media (max-width:800px){
  body.sp-ui-v4140 .sp-shell,
  body.sp-ui-v4130 .sp-shell{padding-left:8px!important;padding-right:8px!important}
  body.sp-ui-v4140 .sp-topbar-inner,
  body.sp-ui-v4130 .sp-topbar-inner{grid-template-columns:50px 46px minmax(0,1fr)!important;gap:8px!important;padding-left:8px!important;padding-right:8px!important}
  body.sp-ui-v4140 .sp-brand,
  body.sp-ui-v4130 .sp-brand{width:50px!important;min-width:50px!important}
  body.sp-ui-v4140 .sp-brand-mark,
  body.sp-ui-v4130 .sp-brand-mark{width:42px!important;height:42px!important;min-width:42px!important}
  body.sp-ui-v4140 .sp-mobile-menu-toggle,
  body.sp-ui-v4130 .sp-mobile-menu-toggle{width:46px!important;height:46px!important;min-width:46px!important;min-height:46px!important}
  body.sp-ui-v4140 .sp-search,
  body.sp-ui-v4130 .sp-search{height:46px!important;padding:0 12px!important;border-radius:17px!important}
  body.sp-ui-v4140 .sp-search input,
  body.sp-ui-v4130 .sp-search input{height:42px!important;font-size:15px!important}

  body.sp-ui-v4140 .sp-mobile-nav,
  body.sp-ui-v4130 .sp-mobile-nav{left:10px!important;right:10px!important;bottom:8px!important}
  body.sp-ui-v4140.sp-chat-focus .sp-mobile-nav,
  body.sp-ui-v4130.sp-chat-focus .sp-mobile-nav{display:none!important}

  body.sp-ui-v4140 .sp-profile-tabs,
  body.sp-ui-v4130 .sp-profile-tabs{padding-bottom:10px!important}
  body.sp-ui-v4140 .sp-profile-tabs a,
  body.sp-ui-v4130 .sp-profile-tabs a{min-height:42px!important}

  body.sp-ui-v4140 .sp-settings-card,
  body.sp-ui-v4130 .sp-settings-card,
  body.sp-ui-v4140 .sp-notifications-page-card,
  body.sp-ui-v4130 .sp-notifications-page-card{padding-left:16px!important;padding-right:16px!important}
}
