/* Phone conversation and page views share the same browser window. In the chat view the
   tab strip keeps the window controls, the sample groups and "Open tabs"; the side panel
   fills the rest. In the tabs view the page fills the window under its address bar. */
@media (max-width: 760px),
  (max-width: 850px) and (orientation: portrait),
  (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  #session .handset-tools {
    display: flex;
    align-items: center;
  }
  #session :is(#swap-view, #demo-swap) {
    min-height: 33px;
    padding-inline: 9px;
    border: 0;
    border-radius: 6px;
    background: #e8edf4;
    color: var(--brand-action);
    font: 600 0.78rem/1.1 var(--ui);
    white-space: nowrap;
  }
  #session[data-demo="dinner"] #demo-swap,
  #session:not([data-demo="dinner"]) #swap-view,
  #session[data-drafting="true"] :is(#swap-view, #demo-swap) {
    display: none;
  }
  #session .extension-toggle {
    display: none;
  }

  /* Tabs view: the page alone. */
  #session[data-view="browser"] .working-area {
    grid-template: "source" minmax(0, 1fr) / minmax(0, 1fr);
  }
  #session[data-view="browser"] .workspace:not([hidden]) {
    display: grid;
    grid-area: source;
  }
  #session[data-view="browser"] #extension-panel {
    display: none;
  }

  /* Chat view: one row of browser chrome, then the side panel. */
  #session[data-view="chat"] .browser-window:not([hidden]) {
    grid-template:
      "window tabs swap" 34px
      "panel panel panel" minmax(0, 1fr) / auto minmax(0, 1fr) auto;
  }
  #session[data-view="chat"] :is(.scout-tabs, .document-bar, .browser-body, .working-area) {
    display: contents;
  }
  #session[data-view="chat"] :is(.history, .omnibox, .extension-toggle, .workspace, .tab-group, #agent-cursor) {
    display: none;
  }
  #session[data-view="chat"] .window-controls {
    grid-area: window;
    align-self: center;
    padding-inline: 4px 2px;
  }
  #session[data-view="chat"] .demo-groups {
    grid-area: tabs;
    display: flex;
    align-items: center;
    min-width: 0;
    padding-inline: 2px;
  }
  #session[data-view="chat"] .handset-tools {
    grid-area: swap;
    align-self: center;
    padding-inline: 3px 6px;
  }
  #session[data-view="chat"] #extension-panel {
    grid-area: panel;
    display: block;
    border-left: 0;
    border-top: 1px solid var(--rail-edge);
  }
}

@media (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  #session[data-view="chat"] .browser-window:not([hidden]) {
    grid-template-rows: 29px minmax(0, 1fr);
  }
}

/* Give touch tabs their own thumb-height rail wherever the handset has the room. */
@media (max-width: 850px) and (min-height: 660px) and (orientation: portrait) {
  #session[data-window][data-view="chat"] .browser-window:not([hidden]) {
    grid-template-rows: 42px minmax(0, 1fr);
  }
  #session[data-window][data-view="browser"] .browser-window:not([hidden]) {
    grid-template-rows: 42px 36px minmax(0, 1fr);
  }
  #session .window-controls button { width: 27px; height: 38px; }
}

/* The mobile chat tab strip can be shallower than the desktop control target. */
@media (max-width: 760px), (max-width: 850px) and (orientation: portrait),
       (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  #session[data-window="fullscreen"][data-view="chat"] .window-controls {
    align-self: stretch;
  }
  #session[data-window="fullscreen"][data-view="chat"] .window-controls button {
    max-height: 100%;
  }
}
