/* Keep this media query identical to app/layout.js. Loaded last; other sizes retain their existing layout. */
#tr-comms .tr-phone-navigation{display:none}
@media (max-width:650px), (max-width:950px) and (max-height:500px) and (pointer:coarse){
  #tr-comms{--tr-ink:#243247;--tr-muted:#48566b;--tr-blue:#174f9b;min-height:0;height:100dvh;color:#243247}
  #tr-comms .tr-shell{display:flex;flex-direction:column;min-height:0;height:100%;overflow:auto}
  #tr-comms .tr-nav{display:grid;grid-template-columns:auto minmax(0,1fr);grid-auto-rows:auto;align-items:center;gap:6px 10px;padding:8px 12px 10px;flex:none;overflow:visible;min-height:0;background:#2e3b50;color:#fff}
  #tr-comms .tr-nav>.tr-nav-section:not(.tr-phone-navigation),
  #tr-comms .tr-nav-bottom>:not(#tr-unmatched-open):not(#tr-settings-open),
  #tr-comms #tr-mirror-toggle,#tr-comms .tr-auto-nav,#tr-comms .tr-profile,
  #tr-comms .tr-nav-footer,#tr-comms #tr-sidebar-toggle,#tr-comms .tr-inbox-divider,
  #tr-comms #tr-automations{display:none!important}
  #tr-comms .tr-brand{grid-column:1;grid-row:1;width:auto;min-width:44px;height:44px;margin:0;padding:0;gap:0;flex-direction:row;align-items:center;--tr-brand-width:64px}
  #tr-comms .tr-logo{width:auto;max-width:80px;height:28px;padding:0}
  #tr-comms .tr-logo img{display:block;width:auto;max-width:80px;height:28px;object-fit:contain}
  #tr-comms .tr-nav-bottom{grid-column:2;grid-row:1;display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;justify-content:flex-end;gap:4px;width:auto;min-width:0;margin:0;padding:0;border:0}
  #tr-comms .tr-nav-bottom #tr-unmatched-open,#tr-comms .tr-nav-bottom #tr-settings-open{display:inline-flex;align-items:center;justify-content:center;align-self:auto;flex:0 1 auto;width:auto;min-width:44px;min-height:44px;margin:0;padding:8px 9px;gap:6px;font-size:13px;font-weight:600;color:#fff;white-space:nowrap;box-shadow:none}
  #tr-comms .tr-nav-bottom .tr-nav-text{display:inline}
  #tr-comms .tr-nav-bottom .tr-nav-icon{width:18px;height:18px}
  #tr-comms .tr-nav-bottom .tr-nav-button[aria-pressed="true"]{background:#52637c;color:#fff}
  #tr-comms .tr-phone-navigation{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;min-width:0;width:100%;margin:0;padding:0;border:0}
  #tr-comms .tr-phone-inbox-label{display:flex;align-items:center;gap:8px;min-width:0;color:#fff;font-size:13px;font-weight:600}
  #tr-comms #tr-phone-inbox{flex:1;min-width:0;min-height:44px;max-width:100%;padding:8px 10px;border:1px solid #96a5b9;border-radius:6px;background:#243247;color:#fff;font-size:16px;font-weight:600}
  #tr-comms #tr-phone-inbox option{background:#fff;color:#243247}
  #tr-comms #tr-phone-filter-toggle{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:44px;border:1px solid #96a5b9;border-radius:6px;padding:8px 12px;background:#2e3b50;color:#fff;font-size:14px;font-weight:600}
  #tr-comms #tr-phone-filter-toggle[aria-expanded="true"]{background:#52637c}
  #tr-comms #tr-phone-filter-label{white-space:nowrap}
  #tr-comms #tr-phone-filter-count{flex-shrink:0}
  #tr-comms #tr-phone-filter-count{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 5px;border-radius:4px;background:#fff;color:#243247;font-size:12px;font-weight:600}
  #tr-comms #tr-phone-filters{grid-column:1/-1;display:grid;gap:3px;padding:5px;border:1px solid #c6d1df;border-radius:6px;background:#fff;color:#243247}
  #tr-comms [data-phone-view]{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;border:0;border-radius:4px;padding:10px 12px;background:#fff;color:#243247;text-align:left;font-size:14px;font-weight:500}
  #tr-comms [data-phone-view][aria-pressed="true"]{background:#e8f0ff;color:#174f9b;font-weight:600;box-shadow:inset 3px 0 #174f9b}
  #tr-comms #tr-phone-mention-count{margin-left:auto;min-width:22px;border-radius:4px;padding:1px 5px;background:#e8f0ff;color:#174f9b;text-align:center;font-size:12px;font-weight:600}
  #tr-comms .tr-phone-navigation :focus-visible{outline:2px solid #a9ceff;outline-offset:3px}
  #tr-comms #tr-phone-filters :focus-visible{outline-color:#174f9b;outline-offset:1px}
  #tr-comms .tr-mobile-customers{display:flex;flex:none;align-items:center;justify-content:space-between;width:100%;min-height:44px;padding:10px 16px;border:0;border-bottom:1px solid var(--tr-line);background:#f8fafd;color:#243247;font-size:13px;font-weight:600}
  #tr-comms .tr-list{flex:none;width:100%;border-right:0;min-height:0}
  #tr-comms[data-show-list="false"] .tr-list{display:none}
  #tr-comms[data-show-list="true"]:not([data-settings="true"]):not([data-unmatched="true"]) .tr-list{display:block}
  #tr-comms .tr-workspace{flex:1 0 auto;width:100%;min-width:0}
  #tr-comms[data-show-list="true"]:not([data-settings="true"]):not([data-unmatched="true"]) .tr-workspace{display:none}
  #tr-comms .tr-settings,#tr-comms .tr-unmatched{flex:1;min-height:0;width:100%;grid-column:auto;grid-row:auto}
  #tr-comms .tr-list-head{padding:16px}
  #tr-comms .tr-list-title{margin-bottom:12px}
  #tr-comms .tr-search{min-height:44px;color:#48566b}
  #tr-comms .tr-search input,#tr-comms .tr-textarea,#tr-comms .ts-field input,#tr-comms .qu-field input,#tr-comms .qu-field select,#tr-comms .tr-pipeline-scripts input,#tr-comms .tr-pipeline-scripts select,#tr-comms .tr-pipeline-scripts textarea,#tr-comms #tfr-form select{font-size:16px;color:#243247}
  #tr-comms .tr-list-filter button,#tr-comms .tr-tab,#tr-comms .tr-button,#tr-comms .ts-button,#tr-comms .qu-button,#tr-comms .tr-pipeline-scripts button{min-height:44px}
  /* Darker supporting copy on light surfaces, with body text kept at regular weight. */
  #tr-comms .tr-chat-body,#tr-comms .tr-message-bubble,#tr-comms .tr-note-text,
  #tr-comms .tr-settings,#tr-comms .tr-unmatched,#tr-comms .qu-record,#tr-comms .qu-confirm{color:#243247;font-weight:400}
  #tr-comms .tr-muted,#tr-comms .tr-person time,#tr-comms .tr-person-preview,#tr-comms .tr-person-meta,
  #tr-comms .tr-identity small,#tr-comms .tr-assignment,#tr-comms .tr-private,#tr-comms .tr-day,
  #tr-comms .tr-call-event,#tr-comms .tr-chat-byline time,#tr-comms .tr-chat-status,#tr-comms .tr-message-meta,
  #tr-comms .tr-compose-label,#tr-comms .tr-draft,#tr-comms .tr-picker-label,#tr-comms .tr-pick-person small,
  #tr-comms .tr-file,#tr-comms .tr-footer,#tr-comms .tr-empty,#tr-comms .tr-note-editstatus,
  #tr-comms .tr-message-preview-notice,#tr-comms .tr-signature-example,#tr-comms .tr-history-count,#tr-comms .tr-history-description,
  #tr-comms .ts-header p,#tr-comms .ts-muted,#tr-comms .ts-intro,#tr-comms .ts-card dt,
  #tr-comms .qu-muted,#tr-comms .qu-header p,#tr-comms .qu-item span,#tr-comms .qu-record-meta,#tr-comms .qu-empty{color:#48566b;font-weight:400}
  #tr-comms .tr-person time,#tr-comms .tr-person-meta,#tr-comms .tr-day,#tr-comms .tr-chat-byline time,#tr-comms .tr-chat-status,#tr-comms .tr-message-meta,#tr-comms .tr-compose-label,#tr-comms .tr-draft,#tr-comms .tr-footer,#tr-comms .tr-note-editstatus{font-size:12px}
  #tr-comms input::placeholder,#tr-comms textarea::placeholder{color:#48566b;opacity:1}
  #tr-comms .tr-thread:empty::after,#tr-comms .tr-workspace[data-empty="true"]::before,#tr-comms .tr-identity p,#tr-comms #tr-customer-address{color:#48566b}
  #tr-comms .tr-list-title h2,#tr-comms .tr-identity h2,#tr-comms .tr-person-name,#tr-comms .tr-notes-label,
  #tr-comms .tr-tab,#tr-comms .tr-filter,#tr-comms .tr-follow,#tr-comms .ts-field,#tr-comms .qu-field,
  #tr-comms .ts-button,#tr-comms .qu-button,#tr-comms .qu-item strong{font-weight:600}
  #tr-comms .tr-filter,#tr-comms .tr-tab,#tr-comms .tr-button.tr-subtle,#tr-comms .tr-ack{color:#48566b}
  #tr-comms .tr-filter[aria-pressed="true"],#tr-comms .tr-tab[aria-pressed="true"]{color:#174f9b;background:#e8f0ff;font-weight:600}
  #tr-comms .tr-textbutton,#tr-comms .tr-deal-link,#tr-comms .ts-link{color:#174f9b}
  #tr-comms .ts-button,#tr-comms .qu-button{color:#243247}
  #tr-comms .ts-button.ts-primary,#tr-comms .qu-button.qu-primary{background:#2e3b50;border-color:#2e3b50;color:#fff}
  #tr-comms #tr-call,#tr-comms #tr-done,#tr-comms .tr-button.tr-primary{background:#174f9b;border-color:#174f9b;color:#fff}
  #tr-comms .tr-source-email{background:#edf2fb;color:#254d80}
  #tr-comms .tr-source-text{background:#edf5f1;color:#28543c}
  #tr-comms .qu-error,#tr-comms #ts-status{color:#8f2525}
  .auth-shell{color:#243247}.auth-shell .muted{color:#48566b}.auth-shell .auth-error{color:#8f2525}.auth-shell .auth-links button,.auth-shell a{color:#174f9b}
}

/* A short label above the selector preserves its usable width on the smallest phones. */
@media (max-width:380px){
  #tr-comms .tr-nav-bottom #tr-unmatched-open .tr-nav-text{display:none}
  #tr-comms .tr-nav-bottom #tr-unmatched-open{flex:none;width:44px;padding:8px}
  #tr-comms .tr-phone-navigation{align-items:end}
  #tr-comms .tr-phone-inbox-label{display:grid;gap:3px;font-size:12px}
  #tr-comms #tr-phone-filter-toggle{align-self:end;padding-left:9px;padding-right:9px}
}
