/* Final phone-only polish layered after the shared Rex mobile work. */
@media (max-width:700px){
  /* Workspace header: BigRex is unmistakable, while desktop-only controls stay out of the way. */
  #workspace:not(.rex-window-active)>.workspace-head{
    row-gap:6px!important;
    padding:7px 6px 8px!important;
  }
  #workspace:not(.rex-window-active)>.workspace-head>#bigRexWorkspaceSwitch:not([hidden]){
    grid-column:1/-1!important;
    grid-row:2!important;
    width:100%!important;
    max-width:none!important;
    min-height:42px!important;
    margin:0!important;
  }
  #workspace:not(.rex-window-active)>.workspace-head #rexPhoneApprovals{
    grid-column:1/-1!important;
    grid-row:3!important;
    gap:2px!important;
  }
  #workspace:not(.rex-window-active)>.workspace-head #rexPhoneControlToggle{
    min-height:38px!important;
  }
  #workspace:not(.rex-window-active)>.workspace-head #rexPhoneApprovalMessage{
    max-height:14px!important;
    line-height:14px!important;
  }

  /* Chat header: one compact two-line control block.
     BigRex gets the entire first line; only essential navigation remains below it. */
  #chatWorkspace.rex-chat-v8 .rex-v8-header{
    display:grid!important;
    grid-template-columns:40px minmax(0,1fr)!important;
    align-items:start!important;
    gap:6px!important;
    padding:6px 8px!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-left{
    grid-column:1!important;
    grid-row:1!important;
    width:40px!important;
    min-width:40px!important;
    align-self:start!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right{
    grid-column:2!important;
    grid-row:1!important;
    display:grid!important;
    grid-template-columns:minmax(68px,1fr) auto auto!important;
    width:100%!important;
    min-width:0!important;
    gap:5px!important;
    overflow:hidden!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-bigrex-switch:not([hidden]){
    grid-column:1/-1!important;
    grid-row:1!important;
    width:100%!important;
    max-width:none!important;
    min-height:40px!important;
    margin:0!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v9-agent-select{
    grid-column:1!important;
    grid-row:2!important;
    width:100%!important;
    min-width:0!important;
    min-height:36px!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-browser-button{
    grid-column:2!important;
    grid-row:2!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-workspace-return{
    grid-column:3!important;
    grid-row:2!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v9-watch-button,
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-job-button,
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-desktop-button{
    display:none!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-main{
    grid-template-rows:auto minmax(0,1fr) auto!important;
  }

  /* Google Home: compact two-column controls/cards on normal phones. */
  #workspace .rex-v7-controls,
  #workspace .rex-v7-tiles{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
    width:100%!important;
  }
  #workspace .rex-v7-controls button{
    width:100%!important;
    max-width:none!important;
    min-width:0!important;
    min-height:42px!important;
    padding:8px 9px!important;
    font-size:10px!important;
  }
  #workspace .rex-v7-controls button:nth-child(1){grid-column:1!important;grid-row:1!important}
  #workspace .rex-v7-controls button:nth-child(2){grid-column:2!important;grid-row:1!important}
  #workspace .rex-v7-controls button:last-child{grid-column:1/-1!important;grid-row:2!important}
  #workspace .rex-v7-tile{
    width:100%!important;
    min-height:0!important;
    padding:11px!important;
  }
}

@media (max-width:380px){
  #workspace .rex-v7-controls{grid-template-columns:1fr!important}
  #workspace .rex-v7-tiles{grid-template-columns:1fr!important}
  #workspace .rex-v7-controls button:nth-child(1),
  #workspace .rex-v7-controls button:nth-child(2),
  #workspace .rex-v7-controls button:last-child{grid-column:auto!important;grid-row:auto!important}
  #chatWorkspace.rex-chat-v8 .rex-v8-header{
    grid-template-columns:38px minmax(0,1fr)!important;
    padding-left:6px!important;
    padding-right:6px!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-left{
    width:38px!important;
    min-width:38px!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right{
    grid-template-columns:minmax(62px,1fr) auto!important;
  }
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-browser-button{display:none!important}
  #chatWorkspace.rex-chat-v8 .rex-v8-header-right>.rex-v10-workspace-return{grid-column:2!important}
}