/* MAIL-048: one document scroller on phones/tablets, including standalone PWA. */
@media(max-width:950px){
  body:has(.mail-workspace){height:auto;min-height:100dvh;overflow:visible}
  .mail-workspace,.mail-workspace.inbox-workspace,.inbox-workspace.has-selection{
    display:flex;flex-direction:column;height:auto!important;min-height:0;overflow:visible;width:100%;max-width:100%
  }
  .mail-workspace .sidebar{display:none}
  .mail-workspace .mobile-folders{display:block;flex:none;max-height:none;overflow:visible;padding:0 12px}
  .mobile-folders>summary{min-height:42px;display:flex;align-items:center;font-size:13px}
  .mobile-folders>nav{max-height:55dvh;overflow:auto;overscroll-behavior-y:contain;display:flex;flex-direction:column;gap:0}
  .mobile-folders>nav>a{padding:10px 4px;overflow-wrap:anywhere;font-size:13px}
  .mail-workspace .conversation-list,.inbox-workspace .conversation-list{flex:none;display:block;overflow:visible;max-height:none;min-height:0;width:100%;border:0}
  .mail-workspace .mail-table-scroll,.inbox-workspace .mail-table-scroll.mail-columns-scroll{flex:none;max-height:none;overflow-x:auto;overflow-y:auto;scrollbar-gutter:auto}
  .inbox-workspace .mail-table-scroll,.inbox-workspace .mail-table-scroll.mail-columns-scroll{overflow:visible}
  .mail-workspace.has-selection .conversation-list{display:none}
  .mail-workspace .reader,.inbox-workspace.has-selection .reader.reader-compact{flex:none;overflow:visible;min-height:0;width:100%;padding:10px 12px 24px}
  .mail-workspace.has-selection .reader{display:block}
  .mail-workspace:not(.has-selection) .reader{display:none}
  .topbar{height:auto;min-height:0;flex-wrap:wrap;gap:8px;padding:12px 12px 0}
  .topbar .brand{gap:7px}.topbar .brand-wordmark{font-size:23px}.topbar .brand-wordmark>span{font-size:26px}.topbar .brand img{width:40px}
  .topbar .account{margin-left:auto;padding:0;border:0;font-size:12px;gap:7px}.topbar .account .avatar,.topbar .account small{display:none}
  .topbar .primary-nav{order:3;flex-basis:100%;min-width:0;width:100%;height:auto;margin:0;gap:16px;overflow-x:auto;justify-content:flex-start;align-items:center;white-space:nowrap;padding:2px 0 8px}
  .topbar .primary-nav>a,.topbar .admin-menu>summary{font-size:12px;min-height:38px;display:flex;align-items:center;flex-shrink:0}
  .topbar .admin-links{position:fixed;top:105px;right:12px;left:auto;max-width:calc(100vw - 24px);max-height:65dvh;overflow:auto;z-index:110}
  .mail-folder-nav{max-width:100%;gap:6px}.mail-folder-nav a{min-height:40px;font-size:12px;padding:8px 10px}
  .inbox-workspace .list-heading{padding:8px 12px}.inbox-workspace .list-heading h1{font-size:24px}
  .inbox-workspace .compact-searchbar{display:flex;flex-direction:column;align-items:stretch;padding:0 12px 8px;gap:8px}
  .inbox-workspace .compact-searchbar .mail-refresh{order:-1;flex:none;margin:0;width:100%;gap:6px}
  .compact-searchbar .refresh-button{min-height:42px;padding:9px 14px;font-size:13px;border-color:#b6c7bb;background:#eef4ef;color:#213e2d}
  .compact-searchbar .mail-refresh .sync-active{flex-basis:100%;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
  .compact-searchbar .mail-refresh progress{width:100%;max-width:none;height:8px}
  .compact-searchbar .mail-refresh a{font-size:12px;padding:6px 0}
  .inbox-workspace .compact-searchbar .filters{flex:none;width:100%;gap:6px;flex-wrap:wrap}
  .inbox-workspace .compact-searchbar .search-label{flex:1 1 150px;max-width:none;min-width:0}
  .inbox-workspace .search-label input{min-height:42px;font-size:16px;padding:8px}
  .compact-searchbar .filter-actions{gap:6px}.compact-searchbar .filter-actions button{min-height:42px;padding:8px;font-size:12px}
  .compact-searchbar .filter-actions>a{font-size:11px}.compact-filter-options summary{min-height:42px;display:flex;align-items:center;font-size:12px}
  .compact-filter-options .filter-grid{position:fixed;top:18%;left:12px;right:12px;width:auto;max-width:none;max-height:65dvh;overflow:auto}
  .compact-filter-options .filter-grid select,.compact-filter-options .filter-grid input{font-size:16px}
  .inbox-workspace .team-sync-line{padding:0 12px 8px;gap:8px;flex-wrap:wrap}
  .inbox-workspace .team-sync,.inbox-workspace .team-sync-line>a{font-size:10px}
  .inbox-workspace .team-sync-line .mail-columns-reset{display:none}
  .inbox-workspace .message-sender strong,.inbox-workspace .message-subject{font-size:14px}
  .inbox-workspace .message-snippet{font-size:12px}
  .inbox-workspace .inbox-trash-cell .mail-trash-icon{width:42px;min-width:42px;height:42px;min-height:42px}
  .reader-compact .reader-columns{display:flex;flex-direction:column;overflow:visible;min-height:0}
  .reader-message-pane,.reader-reply-pane,.reader-message-pane .reader-current{flex:none;overflow:visible;min-height:0}
  .reader-compact .reader-panel,.reader-compact [data-reader-draft]{flex:none;overflow:visible}
  .reader-current>.email-card>.email-body{max-height:none;overflow:visible;flex:none}
  .reader-current .message-frame{height:380px;max-height:65dvh;flex:none}
  .reader-compact .reader-alerts,.reader-compact .ai-inline-tools{max-height:none;overflow:visible}
  .reader-compact .reader-jumps{display:flex;gap:16px;font-size:13px}
  .reader-compact .mail-rich{flex:none;min-height:240px}.reader-compact .rich-surface{font-size:16px;min-height:180px;max-height:50dvh}
  .reader-compact .rich-toolbar{flex-wrap:wrap;gap:3px}.reader-compact .rich-toolbar button{min-width:30px;min-height:36px!important}
  .reader-compact .image-controls{flex-wrap:wrap}.reader-compact .draft-footer{flex-wrap:wrap}
  .reader-compact .draft-footer .primary{min-height:42px;font-size:13px}
  .reader-wide-button{display:none}
  .compact-preview .preview-paper{overflow-wrap:anywhere}.compact-preview .mail-formatted img{max-width:100%;height:auto}
}
@media(display-mode:standalone) and (max-width:950px){
  .topbar{padding-top:max(12px,env(safe-area-inset-top))}
  .mail-workspace{padding-bottom:max(16px,env(safe-area-inset-bottom))}
}

/* MAIL-049: the desktop keeps its existing controls, spacing and labels. */
.phone-menu-toggle,.phone-search-toggle,.phone-more-views,.phone-status,.phone-reader-status,.phone-dock{display:none}
.inbox-workspace .reply-state .phone-status{display:none}
@media(max-width:950px){
  .phone-enhanced .phone-menu-toggle{display:inline-flex;order:2;align-items:center;min-height:42px;padding:8px 10px;font-size:12px;border:1px solid #cdd8cf;border-radius:6px;background:white;color:#21352e}
  .phone-enhanced .topbar{padding-bottom:8px;gap:6px}
  .phone-enhanced .topbar .brand-wordmark small{display:none}
  .phone-enhanced .topbar .brand{gap:5px;min-width:0}
  .phone-enhanced .topbar .brand img{width:30px}
  .phone-enhanced .topbar .brand-wordmark{font-size:19px;white-space:nowrap}
  .phone-enhanced .topbar .brand-wordmark>span{font-size:21px}
  .phone-enhanced .topbar .account{margin-left:auto;gap:7px}
  .phone-enhanced .topbar .primary-nav{display:none}
  .phone-enhanced.phone-menu-open .topbar .primary-nav{display:flex;flex-wrap:wrap;overflow:visible;gap:3px 18px;padding:5px 0}
  .phone-enhanced .topbar .admin-links{position:static;max-height:55dvh;margin:4px 0;max-width:100%;box-shadow:none}
  .phone-enhanced .topbar .admin-menu[open]{width:100%}
  .mail-folder-nav{position:relative;overflow:visible;flex-wrap:wrap;gap:5px;white-space:normal}
  .mail-folder-nav>a:nth-of-type(n+3){display:none}
  .phone-more-views{display:block;position:relative;margin-left:auto}
  .phone-more-views>summary{font-size:12px;min-height:40px;display:flex;align-items:center;padding:8px 10px;border:1px solid #d7ded4;border-radius:5px;background:#fff;cursor:pointer}
  .phone-more-views>div{position:absolute;right:0;top:100%;z-index:35;min-width:180px;background:#fffefa;border:1px solid #cdd8cf;border-radius:6px;padding:6px;box-shadow:0 8px 20px #21352e22}
  .phone-more-views:not([open])>div{display:none}
  .phone-more-views>div>a{padding:10px;min-height:44px}
  .inbox-workspace .list-heading h1{font-size:23px}
  .phone-enhanced .inbox-workspace .compact-searchbar{flex-direction:row;flex-wrap:wrap;align-items:flex-start;gap:6px}
  .phone-enhanced .phone-search-toggle{display:inline-flex;min-height:42px;align-items:center;justify-content:center;padding:9px 12px;font-size:13px;border:1px solid #cdd8cf;background:white;border-radius:5px;color:#21352e;order:1;margin-left:auto}
  .phone-enhanced .inbox-workspace .compact-searchbar .mail-refresh{flex:1;min-width:140px;width:auto;order:0}
  .phone-enhanced .inbox-workspace .compact-searchbar .filters{display:none;order:2;flex-basis:100%}
  .phone-enhanced.phone-search-open .inbox-workspace .compact-searchbar .filters{display:flex}
  .inbox-workspace .inbox-table tr{padding:11px 12px;grid-template-columns:minmax(0,1fr) 65px;row-gap:2px}
  .inbox-workspace .inbox-table .message-content{padding-right:4px!important}
  .inbox-workspace .message-sender strong{font-size:15px;line-height:1.5}
  .inbox-workspace .message-subject{font-size:14px;line-height:1.55}
  .inbox-workspace .message-snippet{font-size:12px;margin-top:1px}
  .inbox-workspace .message-date time{font-size:10px}
  .inbox-workspace .inbox-table .message-recipient{padding:1px 0;display:flex;align-items:center}
  .inbox-workspace .message-recipient .cell-address{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}
  .inbox-workspace .message-recipient>a{min-width:0;max-width:100%}
  .inbox-workspace .inbox-table .reply-author{display:none}
  .inbox-workspace .inbox-table .reply-state{grid-column:1;padding:0;background:transparent;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
  .inbox-workspace .inbox-table .inbox-trash-cell{grid-row:2/4;align-self:end}
  .inbox-workspace .reply-state>span:first-child{display:none}
  .inbox-workspace .inbox-table .reply-state[data-reply-state]{background:transparent}
  .phone-status,.inbox-workspace .reply-state .phone-status{display:inline-flex;align-items:center;font-size:11px;font-weight:600;line-height:1.5;border-radius:5px;padding:4px 8px;background:#f8edce;color:#644c17}
  .phone-status[data-phone-status=sent],.phone-status[data-phone-status=handled]{background:#e2f1e6;color:#24573c}
  .phone-status[data-phone-status=no_reply]{background:#edf0eb;color:#57675b}
  .phone-status[data-phone-status=uncertain],.phone-status[data-phone-status=needs_review]{background:#fbe4d9;color:#843e27}
  .phone-reader-status{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:12px;margin:3px 0}
  .phone-enhanced .reader-compact{padding-bottom:calc(85px + env(safe-area-inset-bottom))!important}
  .phone-enhanced .has-selection .mobile-folders,.phone-enhanced .reader-compact>.mail-folder-nav{display:none}
  .phone-enhanced .reader-compact.phone-tools-open>.mail-folder-nav{display:flex}
  .phone-enhanced .reader-compact .back-to-list{margin:0 0 5px;min-height:40px;display:flex;align-items:center;width:fit-content}
  .phone-enhanced .reader-compact .reader-heading h1{font-size:19px;line-height:1.4;margin:3px 0 8px}
  .phone-enhanced .reader-compact .reader-crumb{font-size:11px;overflow-wrap:anywhere}
  .phone-enhanced .reader-compact:not(.phone-tools-open) .reader-workbar,
  .phone-enhanced .reader-compact:not(.phone-tools-open) .reader-jumps{display:none}
  .phone-enhanced .reader-compact.phone-tools-open .reader-workbar{display:flex;gap:8px;flex-wrap:wrap;padding:8px 0}
  .phone-enhanced .reader-compact.phone-tools-open .reader-jumps{display:flex;padding:8px 0}
  .phone-enhanced .reader-compact:not(.phone-writing) .reader-reply-pane{display:none}
  .phone-enhanced .reader-compact.phone-writing .reader-message-pane{display:none}
  .phone-enhanced .reader-compact.phone-writing .reader-reply-pane{display:block!important;width:100%;min-width:0}
  .phone-enhanced .reader-compact .reader-columns{display:block;min-width:0}
  .phone-enhanced .reader-compact .reader-reply-pane{scroll-margin-top:8px}
  .phone-enhanced .reader-compact .reader-jumps a,.phone-enhanced .reader-workbar button{min-height:42px;padding:8px;font-size:12px}
  .phone-enhanced .reader-compact .phone-dock{display:block;position:fixed;bottom:0;left:0;right:0;z-index:45;background:#fffefa;border-top:1px solid #cdd8cf;box-shadow:0 -3px 15px #21352e12;padding:8px 10px calc(8px + env(safe-area-inset-bottom));max-width:none;margin:0}
  .phone-dock>div{display:flex;gap:7px;width:100%}
  .phone-dock button,.phone-dock a{display:flex;align-items:center;justify-content:center;min-height:46px;border:1px solid #cdd8cf;border-radius:6px;padding:10px;font-size:13px;color:#21352e;background:#fff;white-space:nowrap}
  .phone-dock .primary{margin-left:auto;background:#213e32;border-color:#213e32;color:white;flex:1;font-weight:600}
  .phone-dock [data-phone-writing],.phone-writing .phone-dock [data-phone-reading]{display:none}
  .phone-writing .phone-dock [data-phone-writing]{display:flex}
  .phone-enhanced.phone-keyboard .phone-dock{display:none}
  .phone-enhanced .reader-compact:not(.phone-options-open) .rich-toolbar,
  .phone-enhanced .reader-compact:not(.phone-options-open) .reader-compose-options,
  .phone-enhanced .reader-compact:not(.phone-options-open) .draft-footer{display:none}
  .phone-enhanced .reader-compact .reader-address{padding:8px 10px;font-size:12px;gap:4px;overflow-wrap:anywhere}
  .phone-enhanced .reader-compact .reader-address>span{width:100%}
  .phone-enhanced .reader-compact .reader-address button{min-height:42px;padding:5px 0;font-size:12px}
  .phone-enhanced .reader-compact .rich-surface{min-height:180px;max-height:none;overflow:visible;line-height:1.6;padding:12px;font-size:16px}
  .phone-enhanced .reader-compact .mail-rich{min-height:180px}
  .phone-enhanced .reader-compact .ai-inline-tools{padding:6px 10px}
  .phone-enhanced .reader-compact .ai-inline-tools form{flex-wrap:wrap;gap:5px}
  .phone-enhanced .reader-compact .ai-inline-tools button{min-height:42px;padding:8px 10px;font-size:12px}
  .phone-enhanced .reader-compact .dictation-tools .dictation-start{min-width:42px;min-height:42px}
  .phone-enhanced .reader-compact .reader-signature-strip{padding:8px 10px}
  .phone-enhanced .reader-compact .reader-compose-options select,.phone-enhanced .reader-compact .reader-compose-options input{font-size:16px;min-height:42px}
  .phone-state-dialog{width:min(440px,calc(100vw - 24px));max-height:85dvh}
  .phone-state-dialog p{font-size:13px;line-height:1.6}
  .phone-state-dialog form{display:flex;gap:8px;flex-wrap:wrap}
  .phone-state-dialog form button{flex:1;min-height:46px;font-size:13px}
}
@media(max-width:380px){.phone-enhanced .topbar .brand img{display:none}.phone-enhanced .topbar .account{font-size:11px}}
