/* Mobile fit and touch targets for the existing roles. No desktop redesign,
   route changes, hidden information, or page-wide overflow suppression. */
@media (max-width: 760px) {
  :root :is(.shell,.auth,.public-site,.visitor-production,.referral-portal,.modal-bg)
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]),select,textarea) {
    min-width:0;
    max-width:100%;
    font-size:16px!important;
  }
  :root :is(.shell,.auth,.public-site,.visitor-production,.referral-portal,.modal-bg) :is(.btn,.icon-btn) {
    min-height:44px;
    min-width:44px;
    max-width:100%;
    touch-action:manipulation;
  }
  :root :is(.shell,.auth,.public-site,.visitor-production,.referral-portal,.modal-bg) .btn {
    white-space:normal;
    overflow-wrap:anywhere;
    line-height:1.35;
  }
  :root :is(.shell,.auth,.public-site,.visitor-production,.referral-portal,.modal-bg) label.row:has(input[type="checkbox"]) {
    min-height:44px;
    min-width:0;
  }
  :root :is(.shell,.auth,.modal-bg) .field {min-width:0;max-width:100%}
  :root :is(.client-shell,.admin-shell) > .main,
  :root .seller-root {min-width:0;max-width:100%}

  /* Keep existing tables scrollable inside their own region. */
  :root :is(.shell,.modal-bg) :is(.stats-table-wrap,.batch-review-list,.table-wrap,.table-scroll) {
    min-width:0;
    max-width:100%;
    overflow-x:auto;
    overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
  }
  :root :is(.shell,.modal-bg) table :is(th,td) {overflow-wrap:anywhere}

  /* Long account, label and tool names retain all their text. */
  :root .admin-panel-root .card.tight.row.between {min-width:0;flex-wrap:wrap}
  :root .admin-panel-root .card.tight.row.between > .row:first-child {min-width:0;flex:1 1 140px;flex-wrap:wrap}
  :root .admin-panel-root .card.tight.row.between .pill {max-width:100%;white-space:normal;overflow-wrap:anywhere}
  :root .admin-panel-root .card > .row.between {min-width:0;flex-wrap:wrap}
  :root .admin-panel-root .card > .row.between > :not(button):not(svg) {min-width:0;max-width:100%}
  :root .admin-panel-root .seller-admin-nav button {min-width:0;min-height:44px;white-space:normal;overflow-wrap:anywhere;line-height:1.35}
  :root .admin-panel-root .seller-admin-table article > div,
  :root .seller-root :is(.seller-profile-main,.seller-profile-stats,.commercial-record,.seller-financial-summary) > * {min-width:0;overflow-wrap:anywhere}
  :root .seller-root :is(.seller-context-shortcut,.seller-group-picker button,.seller-tag-switch button) {min-height:44px;max-width:100%;white-space:normal;overflow-wrap:anywhere}
  :root .seller-root :is(.seller-title,.seller-profile-main,.seller-hero,.seller-tag-switch) :is(h1,h2,p,small) {min-width:0;overflow-wrap:anywhere}
  :root .seller-root .seller-refresh-bar {flex-wrap:wrap}

  /* Shared modal title and close stay together even with long client names. */
  :root .modal-bg.viewport-modal > .modal > .row.between {min-width:0;align-items:flex-start}
  :root .modal-bg.viewport-modal > .modal > .row.between > h2 {flex:1;min-width:0;overflow-wrap:anywhere;line-height:1.3}
  :root .modal-bg.viewport-modal > .modal > .row.between > [data-x] {flex:0 0 44px;min-width:44px;min-height:44px}
  :root .modal-bg.viewport-modal :is(form,.stack,.row,.grid) {min-width:0;max-width:100%}
  :root .modal-bg.viewport-modal .row.wrap > * {min-width:0;max-width:100%}

  /* Client help contains administrator supplied text, links and access codes. */
  :root .feed-faq-answer {grid-template-columns:auto minmax(0,1fr);min-width:0}
  :root .feed-faq-answer p,
  :root .client-help-faq p,
  :root .client-help-link > span {min-width:0;overflow-wrap:anywhere}
  :root .shell.client-shell :is(.client-help-back,.client-support-all,.client-help-heading button,.client-post-action) {min-height:44px}
  :root .shell.client-shell .client-help-heading {flex-wrap:wrap;min-width:0}
  :root .shell.client-shell .client-support-card {grid-template-columns:38px minmax(0,1fr);min-width:0}
  :root .shell.client-shell .client-menu-panel {max-width:calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right))}

  /* Public referral labels and configurable descriptions must also fit phones. */
  :root .referral-portal :is(.referral-tag,.referral-eyebrow,.referral-hero h1,.referral-content h2,.referral-post strong,.referral-post small) {min-width:0;max-width:100%;overflow-wrap:anywhere}
  :root .referral-portal .referral-tag {white-space:normal}
  :root .referral-portal :is(.referral-tabs,.referral-grid) {min-width:0;max-width:100%}
  :root .visitor-production [data-vprod-theme] button {min-width:44px;min-height:44px}
  :root .visitor-production .vp-nav-actions {min-width:0;flex-wrap:wrap}

  /* Existing fixed navigation already supplies bottom padding. Only extend its
     inner edges for notches; chat viewport geometry remains owned by its module. */
  :root .shell .bottomnav,
  :root .admin-panel-root .admin-mobile-nav {
    padding-left:max(8px,env(safe-area-inset-left));
    padding-right:max(8px,env(safe-area-inset-right));
  }
  :root .shell:not(.client-shell):not(.chat-focus) > .topbar {padding-top:max(.6rem,env(safe-area-inset-top))}
  :root .admin-panel-root .admin-module-header {padding-top:max(5px,env(safe-area-inset-top))}
  :root .td-dashboard .td-topbar {height:auto;min-height:calc(73px + env(safe-area-inset-top));padding-top:env(safe-area-inset-top)}
  :root .visitor-production .vp-header {padding-top:max(19px,env(safe-area-inset-top))}
  :root .shell :is(.topbar,.admin-module-header) {scroll-margin-top:env(safe-area-inset-top)}
}

@media (max-width: 480px) {
  :root .admin-panel-root.admin-r17 .admin-module-heading {grid-template-columns:44px minmax(0,1fr) 44px 44px;gap:6px}
  :root .admin-panel-root.admin-r17 :is(.workspace-header-search,.admin-module-menu-button,.admin-module-controls .icon-btn) {width:44px;height:44px}
  :root .admin-panel-root.admin-r17 .workspace-header-search {grid-column:3}
  :root .admin-panel-root.admin-r17 .admin-module-menu-button {grid-column:4}
  :root .admin-panel-root .seller-person-actions .btn {min-width:0;white-space:normal}
  :root .admin-panel-root .wallet-config-row {grid-template-columns:minmax(0,1fr)}
  :root .modal-bg :is(.wq-assist,.wallet-entry-form) .field {min-width:0;max-width:100%}
  :root .modal-bg .wq-assist .field {flex-basis:100%}
  :root .shell.client-shell .client-profile-header :is(h1,h2,p,small) {overflow-wrap:anywhere}
}
