/* Mobile-first conversation workspace polish for Eximious Assist.
   The existing app.js toggles body.chat-open and the #mobileBack button. */
@media (max-width: 760px) {
  html, body { width: 100%; min-width: 0; min-height: 100%; overflow-x: hidden; }
  body { overscroll-behavior: none; }
  .app-shell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  .app-shell > .rail,
  .app-shell > .details-panel { min-width: 0 !important; }
  .app-shell > .inbox-panel { min-width: 0 !important; width: 100% !important; }
  body.chat-open .sidebar-mobile-trigger,
  body.chat-open #mainSidebar,
  body.chat-open .app-shell > .inbox-panel,
  body.chat-open .app-shell > .details-panel,
  body.chat-open #blankChat { display: none !important; }
  body.chat-open .app-shell {
    position: fixed !important;
    inset: 0 !important;
    z-index: 40 !important;
    display: block !important;
    background: var(--prod-bg, #f7f6f1) !important;
  }
  body.chat-open .app-shell > .chat-panel {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
  body.chat-open #chatContent {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: var(--surface, #fff) !important;
  }
  body.chat-open #chatContent.hidden { display: none !important; }
  body.chat-open .chat-heading {
    position: relative !important;
    display: flex !important;
    flex: 0 0 auto !important;
    gap: 9px !important;
    min-height: 66px !important;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px !important;
    padding-top: max(10px, env(safe-area-inset-top)) !important;
    align-items: center !important;
    z-index: 3 !important;
    box-shadow: 0 2px 12px rgba(7, 17, 31, .045) !important;
  }
  body.chat-open .mobile-back {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
    border: 1px solid var(--line, #e4e8ef) !important;
    border-radius: 12px !important;
    color: var(--brand-primary, #0b4fc7) !important;
    background: var(--surface, #fff) !important;
    font-size: 23px !important;
    line-height: 1 !important;
  }
  body.chat-open .chat-heading .avatar,
  body.chat-open #chatAvatar { flex: 0 0 38px !important; width: 38px !important; height: 38px !important; }
  body.chat-open .chat-identity { flex: 1 1 auto !important; min-width: 0 !important; }
  body.chat-open .chat-identity h2 { max-width: 42vw !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; font-size: 13px !important; }
  body.chat-open .chat-identity p { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; font-size: 10px !important; }
  body.chat-open #assignmentBadge { display: none !important; }
  body.chat-open #assignmentButton {
    flex: 0 0 auto !important;
    max-width: 96px !important;
    min-height: 34px !important;
    padding: 7px 9px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
  }
  body.chat-open .conversation-actions {
    flex: 0 0 auto !important;
    display: flex !important;
    gap: 6px !important;
    padding: 7px 10px !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  body.chat-open .conversation-actions::-webkit-scrollbar { display: none; }
  body.chat-open .handoff-note,
  body.chat-open .human-takeover-banner { flex: 0 0 auto !important; }
  body.chat-open #messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 14px 11px 18px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  body.chat-open .bubble { max-width: 88% !important; padding: 10px 12px 8px !important; }
  body.chat-open .bubble p { font-size: 13px !important; overflow-wrap: anywhere !important; }
  body.chat-open .composer {
    position: relative !important;
    flex: 0 0 auto !important;
    padding: 9px 10px max(10px, env(safe-area-inset-bottom)) !important;
    gap: 7px !important;
    background: var(--surface, #fff) !important;
    box-shadow: 0 -6px 20px rgba(7, 17, 31, .04) !important;
  }
  body.chat-open .composer-row { display: flex !important; align-items: flex-end !important; gap: 8px !important; }
  body.chat-open .composer textarea {
    flex: 1 1 auto !important;
    width: 0 !important;
    min-width: 0 !important;
    min-height: 44px !important;
    max-height: 120px !important;
    padding: 11px 12px !important;
    font-size: 16px !important;
    border-radius: 15px !important;
  }
  body.chat-open .send-button { flex: 0 0 44px !important; width: 44px !important; height: 44px !important; }
  body.chat-open .composer-tools { margin-top: 6px !important; }
  body.chat-open .composer-notice { font-size: 10px !important; line-height: 1.35 !important; }
  body.chat-open .new-messages-button { z-index: 4 !important; bottom: 120px !important; }
  body.chat-open .toast { z-index: 100 !important; }
}
@media (min-width: 761px) {
  .mobile-back { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-content, .bubble { animation: none !important; transition: none !important; }
}