/* Use the existing conversation breakpoint. Embedded chat keeps its own layout. */
.conversation-panel {
  --chat-window-desktop: 1;
}
.conversation-panel.conversation-floating-layout {
  inset: var(--chat-window-y) auto auto var(--chat-window-x);
  width: var(--chat-window-width);
  height: var(--chat-window-height);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.conversation-floating-layout > :not(.chat-messages) {
  flex-shrink: 0;
}
.conversation-floating-layout .chat-floating-header {
  cursor: grab;
  touch-action: none;
  user-select: none;
  flex-wrap: wrap;
}
.conversation-panel:not(.conversation-docked) .chat-floating-header strong {
  flex: 1 1 90px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-floating-layout .chat-floating-header button {
  cursor: pointer;
}
.conversation-floating-layout .chat-floating-header .conversation-layout-reset {
  padding: 4px;
  min-width: 28px;
  font-size: 18px;
}
.conversation-panel .conversation-layout-reset[hidden],
.conversation-resize[hidden] {
  display: none;
}
.conversation-floating-layout .conversation-context {
  flex-wrap: wrap;
  overflow: auto;
  max-height: 112px;
}
.conversation-floating-layout .conversation-context button {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.conversation-floating-layout .chat-messages {
  flex: 1;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
}
.conversation-floating-layout .chat-message {
  max-width: 80%;
  overflow-wrap: anywhere;
}
.conversation-floating-layout .chat-composer {
  min-width: 0;
}
.conversation-floating-layout > p:not(#conversation-status) {
  margin: 6px 16px;
  font-size: 12px;
}
.conversation-floating-layout .chat-composer textarea {
  resize: none;
  max-height: 100px;
}
.conversation-floating-layout .conversation-emoji {
  max-height: 96px;
  overflow: auto;
}
.conversation-floating-layout.chat-minimized {
  height: auto;
  max-height: calc(100vh - 24px);
}
.conversation-resize {
  display: none;
  position: absolute;
  z-index: 2;
  touch-action: none;
}
.conversation-floating-layout .conversation-resize {
  display: block;
}
.conversation-resize-e {
  top: 8px;
  bottom: 12px;
  right: 0;
  width: 7px;
  cursor: ew-resize;
}
.conversation-resize-s {
  left: 8px;
  right: 12px;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
}
.conversation-resize-se {
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
}
.conversation-moving,
.conversation-moving .chat-floating-header {
  cursor: grabbing;
}
.conversation-moving *,
.conversation-resizing * {
  user-select: none;
}
@media (max-width: 760px) {
  .conversation-panel {
    --chat-window-desktop: 0;
  }
  .conversation-resize,
  .conversation-layout-reset {
    display: none;
  }
}

.conversation-panel:not(.conversation-docked) .chat-floating-header {
  flex-wrap: wrap;
}

/* One mobile viewport layout for the same conversation, whether opened from
   messages, a live workspace, or a floating task link. No new chat state. */
@media (max-width: 760px) {
  html:has(.conversation-mobile-layout:not(.chat-minimized)),
  body:has(.conversation-mobile-layout:not(.chat-minimized)) {
    overflow: hidden;
    overscroll-behavior: none;
  }
  .workspace-theme .conversation-panel.conversation-mobile-layout {
    position: fixed;
    inset: var(--chat-mobile-y, 8px) auto auto var(--chat-mobile-x, 8px);
    width: var(--chat-mobile-width, calc(100vw - 16px));
    height: var(--chat-mobile-height, calc(100dvh - 16px));
    min-height: 0;
    max-height: none;
    max-width: none;
    margin: 0;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-m);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .conversation-mobile-layout > :not(.chat-messages) {
    flex-shrink: 0;
  }
  .workspace-theme .conversation-mobile-layout .chat-floating-header {
    padding: 8px;
    gap: 6px;
    flex-wrap: wrap;
    cursor: auto;
    touch-action: auto;
  }
  .workspace-theme .conversation-mobile-layout .chat-floating-header strong {
    flex: 1 1 60px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .workspace-theme .conversation-mobile-layout .chat-floating-header button {
    min-height: 36px;
  }
  .conversation-mobile-layout .conversation-context {
    flex-wrap: wrap;
    max-height: min(80px, 15%);
    overflow: auto;
    overscroll-behavior: contain;
  }
  .conversation-mobile-layout .conversation-context button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .workspace-theme .conversation-mobile-layout .chat-messages {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-anchor: none;
    overscroll-behavior: contain;
  }
  .conversation-mobile-layout .chat-message {
    overflow-wrap: anywhere;
  }
  .conversation-mobile-layout .conversation-attachment {
    min-width: 0;
  }
  .workspace-theme .conversation-mobile-layout .chat-composer {
    min-width: 0;
    padding: 6px 12px 8px;
  }
  .workspace-theme .conversation-mobile-layout .chat-composer textarea {
    resize: none;
    height: 60px;
    min-height: 44px;
    max-height: 60px;
    font-size: 16px;
  }
  .conversation-mobile-layout .conversation-emoji {
    max-height: 64px;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .conversation-mobile-layout .conversation-upload {
    max-height: 48px;
    overflow: auto;
  }
  .conversation-mobile-layout .conversation-tools {
    flex-wrap: wrap;
  }
  .conversation-mobile-layout > p:not(#conversation-status) {
    margin: 4px 12px;
    overflow-wrap: anywhere;
  }
  .workspace-theme
    .conversation-panel.conversation-mobile-layout.chat-minimized {
    height: auto;
    max-height: var(--chat-mobile-height, calc(100dvh - 16px));
  }
}
