/* Phone-only corrections. Keep the existing desktop/tablet layout and navigation. */
@media (max-width:600px) {
  html,body,#app{width:100%;max-width:100vw;overflow-x:hidden}
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
  .workspace,.welcome-shell,main,.sidebar{width:100%;max-width:100%;min-width:0}
  .workspace{margin-left:0;padding-bottom:calc(84px + env(safe-area-inset-bottom,0px))}
  main{padding-left:max(clamp(12px,4vw,20px),env(safe-area-inset-left,0px));padding-right:max(clamp(12px,4vw,20px),env(safe-area-inset-right,0px))}
  .workspace>header,.sidebar,.welcome-header{padding-left:max(12px,env(safe-area-inset-left,0px));padding-right:max(12px,env(safe-area-inset-right,0px))}
  .workspace>header{height:auto;min-height:65px;gap:8px;padding-top:8px;padding-bottom:8px}
  .breadcrumb{min-width:0;flex:0 1 auto;font-size:11px;overflow-wrap:anywhere}
  .header-actions{min-width:0;flex:1 1 auto;justify-content:flex-end;gap:5px}
  .header-actions .language{flex:0 0 auto}
  .header-actions .bell{flex:0 0 38px;width:38px;height:38px;padding:0}
  .account-button{min-width:0;max-width:clamp(64px,23vw,110px);padding:4px 0;line-height:1.3;white-space:normal;overflow-wrap:anywhere}
  .sidebar nav{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:2px;left:0;right:0;width:100%;max-width:100vw;min-width:0;overflow:hidden;margin:0;padding:6px max(4px,env(safe-area-inset-right,0px)) calc(6px + env(safe-area-inset-bottom,0px)) max(4px,env(safe-area-inset-left,0px))}
  .sidebar nav a{width:100%;min-width:0;max-width:100%;min-height:52px;padding:7px 1px;gap:4px;justify-content:center;align-items:center;font-size:clamp(9px,2.65vw,11px);line-height:1.3;white-space:normal;overflow-wrap:anywhere;text-align:center}
  .sidebar nav a span{flex:none;width:auto;font-size:21px;line-height:1}
  .sidebar nav a:focus-visible{outline-offset:-2px}
  .page-heading,.page-heading>div,.member-welcome,.member-pass,.member-panel,.empty,.campaign-card,.stats article,.preview-strip,.setup-panel,.avatar-preview{width:100%;max-width:100%;min-width:0}
  .member-welcome,.member-panel,.empty,.campaign-card{padding:20px}
  .member-pass{padding:18px}
  .member-welcome,.dashboard-grid,.profile-grid,.campaign-grid,.invite-layout,.setup-layout,.community-grid{grid-template-columns:minmax(0,1fr)}
  .stats{grid-template-columns:repeat(3,minmax(0,1fr))}
  .stats article{padding:14px 9px}
  .stats article small,.stats article>span,.stats article a{overflow-wrap:anywhere}
  .member-welcome>*,.dashboard-grid>*,.profile-grid>*,.invite-layout>*,.setup-layout>*,.welcome-main>*,.actions>*,.avatar-preview>*,.avatar-grid>*{min-width:0;max-width:100%}
  main p,main h1,main h2,main h3,main dd,main code,dialog p{overflow-wrap:anywhere}
  .section-heading{flex-wrap:wrap;gap:8px}
  .preview-strip span{white-space:normal}
  .actions .button,.auth-tabs .button,.social-card .button{min-width:0;max-width:100%;gap:8px;white-space:normal;overflow-wrap:anywhere}
  .filters{flex-wrap:wrap;overflow:visible}
  .filters button{max-width:100%;white-space:normal}
  .referral-panel .actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .referral-qr-frame{width:100%;max-width:320px;min-height:0;aspect-ratio:1}
  .referral-qr-frame img{width:100%;max-width:100%;height:auto}
  .avatar-option span{min-width:0;overflow-wrap:anywhere}
  .avatar-preview{grid-template-columns:80px minmax(0,1fr)}
  .avatar-preview-art{width:80px}
  .auth-form{min-width:0}
  input,select,textarea{min-width:0;max-width:100%}
  /* 16px input text avoids focus-triggered magnification in iPhone Safari. */
  .auth-form input,.setup-panel input[type=text],.setup-panel select,.referral-panel input,#email{font-size:16px}
  dialog{max-width:calc(100vw - 24px);width:calc(100% - 24px);padding:32px 18px;overflow-x:hidden;overflow-wrap:anywhere}
  .workspace footer{margin-bottom:0}
  #toast{bottom:calc(84px + env(safe-area-inset-bottom,0px));max-width:calc(100vw - 24px);overflow-wrap:anywhere}
}

/* Keep the profile action accessible above the six-item phone navigation. */
@media(max-width:600px){
 .setup-layout{padding-bottom:140px}
 .profile-save-actions{position:fixed;z-index:25;left:0;right:0;bottom:calc(70px + env(safe-area-inset-bottom,0px));margin:0;padding:10px max(16px,env(safe-area-inset-left,0px));background:#131a24;border-top:1px solid #394250;box-shadow:0 -6px 18px #0003;display:flex;gap:8px}
 .profile-save-actions>.button{flex:1;justify-content:center;min-height:44px}
 .profile-save-actions #profile-feedback{flex-basis:100%;margin:0;min-height:0;font-size:13px;line-height:1.4;max-height:72px;overflow-y:auto}
 .profile-save-actions #profile-feedback:empty{display:none}
}

/* One compact mobile brand/control row; the fixed navigation is untouched. */
@media(max-width:600px){
 .sidebar.mobile-app-header{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:6px;padding-top:12px;padding-bottom:12px}
 .mobile-app-header .brand{flex:0 0 auto;gap:6px}
 .mobile-app-header .header-actions{flex:1 1 0;min-width:0;justify-content:flex-end;gap:3px}
 .mobile-app-header .language{padding:2px;flex:none}
 .mobile-app-header .language button{font-size:12px;padding:5px 3px;min-height:30px}
 .mobile-app-header .bell{width:32px;height:34px;flex:0 0 32px;padding:0}
 .mobile-app-header .account-button{flex:0 1 80px;min-width:0;max-width:80px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;padding:4px 0}
 main:has(.campaign-filters){padding-top:16px}
}
@media(max-width:340px){
 .sidebar.mobile-app-header{padding-left:8px;padding-right:8px;gap:4px}
 .mobile-app-header .header-actions{gap:2px}
 .mobile-app-header .account-button{max-width:48px}
}
