/* Phone / talk-mode surfaces (≤820px) — split from multi-dock.css for the 1000-line gate. */
/* T308: talk-mode chrome is injected only at ≤820px. */
.talk-mode-chrome[hidden],
.talk-mode-chrome {
  display: none;
}

@media (max-width: 820px) {
  body.multi-dock-open:not(.standalone) .tab-panel {
    visibility: hidden;
    margin-right: 0;
  }

  /* T306: the shell tab bar owns the bottom safe zone while a dock is open.
     The rail is fixed outside the shell grid, so reserve the tab-bar row here
     instead of letting the projected composer cover it.  Full-screen agent
     workspaces have no shell tab bar and retain their edge-to-edge rail. */
  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace):not(.talk-mode) .agent-dock-rail,
  body.dock-open:not(.standalone):not(.multi-agent-workspace):not(.talk-mode) .agent-dock {
    bottom: calc(58px + env(safe-area-inset-bottom));
  }

  /* T308 talk mode: hide legacy #tab-bar (T318 already replaces it on phone).
     T323: keep the frequency bar visible; rail reserves the bar row via max()
     against T307's visualViewport bottom so the keyboard overlays the bar. */
  body.talk-mode #tab-bar {
    display: none !important;
  }

  body.talk-mode.multi-dock-open:not(.standalone):not(.multi-agent-workspace) .agent-dock-rail,
  body.talk-mode.dock-open:not(.standalone):not(.multi-agent-workspace) .agent-dock {
    top: var(--agent-dock-top, calc(4rem + env(safe-area-inset-top, 0px)));
    bottom: max(
      calc(58px + env(safe-area-inset-bottom)),
      var(--cc-visual-viewport-bottom, 0px)
    );
    left: 0;
    width: 100vw;
    z-index: 45;
  }

  body.talk-mode .talk-mode-chrome:not([hidden]) {
    display: none;
  }

  body.talk-mode .agent-dock-rail .agent-dock-tabs {
    position: static;
    top: auto;
    display: flex;
    min-height: 44px;
    gap: 0.25rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--ui-line);
    padding: 0.35rem;
    background: var(--ui-panel);
  }

  body.talk-mode .agent-dock-columns {
    padding-top: 0;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.talk-mode .agent-dock-rail {
    display: flex;
    flex-direction: column;
  }

  body.talk-mode .agent-session-column__header,
  body.talk-mode [data-dock-left],
  body.talk-mode [data-dock-right],
  body.talk-mode [data-dock-add] {
    display: none !important;
  }

  /* Replace Files 52/48 split with the same talk sheet. */
  body.talk-mode.standalone-file > #files-legacy-tab {
    display: none !important;
  }

  .agent-dock-rail {
    z-index: 40;
    left: 0;
    width: 100vw;
    border-left: 0;
  }

  .agent-dock-region-resize {
    display:none;
  }

  .agent-dock-rail .agent-dock-tabs {
    position: absolute;
    z-index: 6;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    min-height: 2.75rem;
    gap: 0.25rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--ui-line);
    padding: 0.35rem;
    background: var(--ui-panel);
  }

  .agent-dock-tabs button {
    min-width: 0;
    min-height: 44px;
    flex: 0 1 auto;
    overflow: hidden;
    border: 1px solid var(--ui-line);
    border-radius: 999px;
    padding: 0.4rem 0.65rem;
    background: var(--ui-raised);
    color: var(--ui-text-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .agent-dock-tabs button[aria-selected="true"] {
    border-color: var(--ui-accent);
    background: var(--ui-accent-soft);
    color: var(--ui-accent);
  }

  /* T321: Ask Mainframe is the first conversation chip, not a topbar action. */
  body.talk-mode .agent-dock-tabs .talk-ask-chip {
    border-color: color-mix(in srgb, var(--ui-accent) 55%, var(--ui-line));
    color: var(--ui-accent);
  }

  .agent-dock-columns {
    padding-top: 2.75rem;
  }

  .agent-session-column {
    display: none;
    min-width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }

  body.multi-agent-workspace .agent-session-column {
    min-width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }

  .agent-session-column.is-active {
    display: flex;
  }

  /* T484: neutralize every property the desktop fixed-drawer rule
     (:where(body:not(.multi-agent-workspace)) .agent-launch-column in
     multi-dock.css) introduces — equal specificity + later source only
     overrides declared properties per-rule, not per-selector, so anything
     that block sets and this one doesn't (transform, inset, z-index, …)
     would otherwise leak through onto the phone sheet. */
  .agent-launch-column {
    display: flex;
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: auto;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    border-left: 0;
    box-shadow: none;
    transform: none;
    transition: none;
    will-change: auto;
  }

  /* T310/T323/T485: launch sheet — the footer (hint/routine/configure/Send)
     is now the one sticky-bottom bar, always reachable without hunting for
     it under the keyboard; the composer/tier/engine sections above it
     scroll in .__body. Previously the whole composer (incl. Send) stuck to
     the bottom; T485 moved Send into .__footer (prototype .ld-foot), so the
     footer inherits that sticky role instead. */
  .agent-launch-column__form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
  }

  .agent-launch-column__body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.75rem 0.75rem 0.5rem;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .agent-launch-column__form textarea {
    order: initial;
    width: 100%;
    max-width: 100%;
    min-height: 5.5rem;
    max-height: min(12rem, 28vh);
    height: auto;
    box-sizing: border-box;
  }

  .agent-launch-column__composer {
    width: 100%;
  }

  .agent-launch-column__toolbar {
    order: initial;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    width: 100%;
    min-width: 0;
    gap: 0.35rem;
  }

  .agent-launch-column__model {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }

  .agent-launch-model-pill {
    min-height: 44px;
  }

  .agent-launch-model-pill .model-picker-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .agent-launch-model-search {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
  }

  .agent-launch-model-popover {
    width: min(100vw - 1rem, 32rem);
    max-width: calc(100vw - 1rem);
    max-height: min(50dvh, 22rem);
  }

  .agent-launch-model-options {
    overflow: auto;
  }

  .agent-launch-model-option,
  .agent-launch-model-options [role="option"] {
    min-height: 44px;
    box-sizing: border-box;
  }

  .agent-launch-column__form [data-launch-file],
  .agent-launch-column__form .composer-attach-button {
    min-height: 44px;
    min-width: 44px;
    flex: 0 0 auto;
  }

  .agent-launch-column__footer {
    position: sticky;
    z-index: 2;
    bottom: 0;
    order: initial;
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem max(0.6rem, env(safe-area-inset-bottom, 0px));
    background: linear-gradient(
      to bottom,
      transparent 0%,
      var(--ui-panel) 20%
    );
  }

  .agent-launch-column__submit {
    min-height: 44px;
    min-width: 44px;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .agent-launch-column__form .composer-attachment-tray,
  .agent-launch-column__form .file-reference-chips {
    order: initial;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .agent-launch-column__form .file-reference-picker,
  .agent-launch-column__retry,
  .agent-launch-column__form > .visually-hidden {
    order: initial;
  }

  .agent-session-column:has(~ .agent-launch-column) {
    display: none;
  }

  .agent-session-column__resize {
    display: none;
  }

  body.multi-dock-picker-open #agent-dock.open {
    width: 100vw;
  }

  body.multi-dock-picker-open #agent-dock-rail {
    visibility: hidden;
    right: 0;
    width: 100vw;
  }

  .agent-session-column__header {
    cursor: default;
  }

  /* T306: the chip pager replaces desktop movement controls on narrow
     surfaces.  T309 will remove the remaining desktop dock chrome. */
  .agent-session-column__actions :is([data-dock-left], [data-dock-right]) {
    display: none;
  }

  .agent-session-column__actions .agent-session-column__close,
  .agent-session-column__actions [data-dock-close] {
    min-width: 44px;
    min-height: 44px;
  }
}
