/* Contacts mobile phase 1: readable list and detail, no desktop impact */
@media(max-width:800px){
 #view .contacts-workspace{display:flex!important;flex-direction:column!important;grid-template-columns:none!important;height:auto!important;min-height:0!important;overflow:visible!important;gap:10px!important}
 #view .contacts-panel,#view .contacts-detail{width:100%;min-width:0;max-width:100%;height:auto;overflow:auto}
 #view .contacts-panel{max-height:48dvh;min-height:210px}
 #view .contacts-detail{min-height:200px;max-height:65dvh;overflow-y:auto}
 #view .contacts-header,#view .contacts-row{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr)!important;gap:6px!important}
 #view .contacts-header button:nth-child(n+3),#view .contacts-row span:nth-child(n+3){display:none}
 #view .contacts-header button,#view .contacts-row{min-height:44px}
 #view .contacts-edit-form{grid-template-columns:minmax(0,1fr)!important}
 #view .contacts-edit-field{min-width:0}
 #view .contacts-detail input,#view .contacts-detail textarea,#view .contacts-detail select{max-width:100%;min-width:0}
}

/* Mobile contacts: single-screen navigation */
.fc-contact-back{display:none}
@media(max-width:800px){
 #view .contacts-workspace{height:calc(100dvh - 180px)!important;min-height:300px!important;overflow:hidden!important}
 #view .contacts-workspace .contacts-panel{display:flex;flex:1;max-height:none;min-height:0;overflow:hidden}
 #view .contacts-workspace .contacts-detail{display:none;max-height:none;min-height:0;flex:1;overflow-y:auto}
 #view .contacts-workspace.fc-mobile-contact-detail .contacts-panel{display:none}
 #view .contacts-workspace.fc-mobile-contact-detail .contacts-detail{display:block}
 #view .contacts-workspace .fc-contact-back{display:block;position:sticky;top:0;z-index:3;width:100%;min-height:44px;text-align:left;border:0;border-bottom:1px solid #dce4f0;background:#fff;color:#28558f;font:inherit;font-weight:700;padding:10px 14px;cursor:pointer}
}

/* Place mobile back control beside Home in module toolbar */
#fc-mobile-contacts-toolbar-back{display:none}
@media(max-width:800px){
 #view .contacts-workspace .fc-contact-back{display:none}
 #fc-mobile-contacts-toolbar-back:not([hidden]){display:inline-flex;align-items:center;justify-content:center;min-height:40px;white-space:nowrap}
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back){flex-wrap:wrap}
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back)>[data-module="home"]{margin-left:0}
}

/* Stable right-aligned contact navigation: reserve Back space in both states */
@media(max-width:800px){
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back){justify-content:flex-start;column-gap:8px;row-gap:8px}
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back) #fc-mobile-contacts-toolbar-back{display:inline-flex!important;visibility:visible;min-height:40px;margin-left:auto;flex:0 0 auto}
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back) #fc-mobile-contacts-toolbar-back[hidden]{visibility:hidden!important;pointer-events:none}
 #view .module-toolbar:has(#fc-mobile-contacts-toolbar-back)>[data-module="home"]{flex:0 0 auto;margin-left:0!important}
}
