/* Applied last. Mobile usability only, preserving data and action handlers. */
@media screen and (max-width:799px) {
  :root { --mobile-nav-clearance:calc(104px + env(safe-area-inset-bottom,0px)); }
  :is(.view-section,.staff-accounts,.athlete-viewport) { min-width:0; overflow-wrap:anywhere; }
  :is(.view-section,.staff-accounts,.athlete-viewport) :is(button,a,input,select,textarea) { touch-action:manipulation; }
  :is(.view-section,.staff-accounts,.athlete-viewport) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]),select,textarea) { font-size:16px!important; min-width:0; max-width:100%; scroll-margin-block:100px; }
  :is(.view-section,.staff-accounts) :is(.form-group,.panel,.panel-header,.panel-actions-group,.trainer-toolbar,.staff-client-identity) { min-width:0; max-width:100%; }
  :is(.view-section,.staff-accounts) :is(.btn,button:not(.nav-tab)) { white-space:normal; overflow-wrap:anywhere; min-height:44px; line-height:1.4; }
  #main-portal-header .nav-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; min-width:0; overflow:visible; }
  #main-portal-header .nav-tab { min-width:0; white-space:normal; padding:10px 5px; font-size:13px; line-height:1.35; }
  #main-portal-header .header-actions { position:relative; }
  #main-portal-header #trainer-actions-menu { max-height:calc(100dvh - 100px - env(safe-area-inset-top,0px)); overscroll-behavior:contain; }
  .trainer-page-heading p { font-size:14px; }
  #generator-view :is(.form-group > label,.preset-tags-title,.cst-subtitle,.inj-subtitle,.fmt-subtitle) { font-size:13px; line-height:1.5; }
  #generator-view :is(.preset-tags-hint,.preset-tag-btn) { font-size:12px; line-height:1.5; }
  #generator-view .generator-layout, #generator-view .form-grid { grid-template-columns:minmax(0,1fr); }
  #database-view :is(.database-filters,.exercise-grid) { grid-template-columns:minmax(0,1fr); }
  #database-view .exercise-actions { display:flex; flex-wrap:wrap; }
  #database-view .exercise-actions > * { flex:1 1 100%; width:100%; min-width:0; }
  .staff-assignment-controls__fields { grid-template-columns:minmax(0,1fr)!important; }
  .staff-accounts :is(.staff-client-card__top,.staff-assignment-controls,.staff-client-actions) { flex-wrap:wrap; gap:10px; }
  .staff-accounts :is(button,input,select) { max-width:100%; }
  #editor-view #sheet-editor-container { overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
  :is(#gym-news-editor,#gym-courses-editor,#coach-recovery-panel) { padding:10px!important; overscroll-behavior:contain; }
  :is(#gym-news-editor,#gym-courses-editor) form,#coach-recovery-panel>div { width:100%!important; max-width:100%!important; min-width:0; max-height:calc(100dvh - 20px)!important; overflow-y:auto; padding:16px!important; }
  :is(#gym-news-editor,#gym-courses-editor,#coach-recovery-panel) :is(input,textarea,select) { font-size:16px!important; max-width:100%; min-width:0; }
  :is(#gym-news-editor,#gym-courses-editor) button { min-height:44px; white-space:normal; }
  .athlete-subpage { padding-bottom:var(--mobile-nav-clearance); }
  .athlete-ex-actions button,.athlete-day-btn,.athlete-set-btn,.athlete-rest-pill,.athlete-carousel-controls button { min-height:44px; min-width:44px; }
  .athlete-ex-actions button { font-size:13px; white-space:normal; }
  .athlete-detail-label,.athlete-sets-label { font-size:12px; letter-spacing:.02em; line-height:1.5; }
  .athlete-detail-val { font-size:17px; }
  .athlete-ex-notes,.athlete-session-sub-stats { font-size:14px; line-height:1.55; }
  #athlete-bottom-nav .abn-label { font-size:11px; line-height:1.2; }
  #athlete-bottom-nav .abn-item { min-height:52px; }
  .carousel-fullscreen .athlete-day-content { padding-bottom:12px; }
  .carousel-fullscreen .athlete-exercise-list.is-carousel > .athlete-ex-card { overflow-y:auto; overscroll-behavior-y:contain; scroll-padding-bottom:90px; }
  .athlete-weight-modal-title { font-size:18px; line-height:1.35; }
  .athlete-weight-modal-subtitle { font-size:14px; line-height:1.5; }
  .calorie-diary .diary-week { gap:3px; grid-template-columns:repeat(7,minmax(44px,1fr)); overflow-x:auto; overscroll-behavior-x:contain; padding-bottom:6px; }
  .calorie-diary .diary-week button { min-height:54px; }
  .calorie-diary .diary-week span { font-size:11px; }
  .calorie-diary :is(.diary-macros span,[data-results-count]),.fz-ranking p { font-size:14px; line-height:1.5; }
  .calorie-diary .diary-actions { display:flex; gap:8px; }
  .calorie-diary .diary-actions button { flex:1 1 120px; }
  .calorie-diary .diary-catalog { width:calc(100% - 16px); max-height:calc(var(--client-visual-height,100dvh) - 16px); }
  .fz-ranking form label { font-size:15px; line-height:1.55; }
  .fz-ranking input[type=checkbox] { width:22px; height:22px; margin:8px 6px 8px 0; }
  .fz-ranking li { padding:12px 8px; gap:8px; }
  .client-access-shell .ca-choices span { font-size:12px; line-height:1.45; }
  .client-access-shell .ca-intro { font-size:14px; }
}
@media screen and (max-width:360px) {
  #main-portal-header .nav-tabs { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .athlete-weight-inputs-grid { grid-template-columns:minmax(0,1fr); }
  .athlete-ex-details { gap:8px; }
  .calorie-diary .diary-macros { gap:4px; }
  .calorie-diary .diary-macros > div { padding:12px 3px; }
  .calorie-diary .diary-macros span { font-size:12px; }
}
@media screen and (max-height:500px) and (orientation:landscape) {
  #main-portal-header #trainer-actions-menu { max-height:calc(100dvh - 80px); }
  .athlete-weight-modal-card { max-height:calc(100dvh - 16px); overflow-y:auto; }
  .carousel-fullscreen .athlete-ex-thumb-wrap { height:140px; min-height:140px; }
}
