/* Mobile-only messaging polish. Desktop rendering and message handling stay intact. */
.ta-ui-rc .global-chat-mobile-back { display: none !important; }
.ta-ui-rc .ta-mobile-inbox-page { display: none !important; }
@media (min-width: 981px) {
  .ta-ui-rc .ta-desktop-message-inbox { display: block !important; }
}
@media (max-width: 980px) {
  /* The bottom Messages tab is the sole mobile chat entry point. */
  .ta-ui-rc .global-chat-widget > .global-chat-fab,
  .ta-ui-rc .global-chat-fallback-fab { display: none !important; }
  .ta-ui-rc .ta-mobile-inbox-page { display: block !important; }
  .ta-ui-rc .ta-desktop-message-inbox { display: none !important; }
  body.ta-mobile-inbox-screen .topbar,
  body.ta-mobile-inbox-screen .global-scope-notice,
  body.ta-mobile-inbox-screen .global-chat-fab,
  body.ta-mobile-inbox-screen .global-chat-fallback-fab { display: none !important; }
  .ta-ui-rc .ta-mobile-inbox-page { padding: 0 !important; }
  .ta-ui-rc .ta-message-inbox { margin: 0; padding: 0; background: #fff; min-height: calc(100dvh - var(--ta-mobile-nav-height, 76px)); }
  .ta-ui-rc .ta-message-inbox-head { display: grid; grid-template-columns: minmax(0,1fr) 44px; align-items: center; min-height: 52px; padding: 4px 16px; background: #f7f7f7; }
  .ta-ui-rc .ta-message-inbox-head h1 { margin: 0; color: #202124; font-size: 20px; font-weight: 600; text-align: center; }
  .ta-ui-rc .ta-message-new-chat { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #d3d7dc; border-radius: 50%; color: #222; font: 400 28px/1 system-ui,sans-serif; text-decoration: none; }
  .ta-ui-rc .ta-message-search { display: flex; align-items: center; gap: 8px; margin: 10px 12px; padding: 0 12px; min-height: 40px; border-radius: 9px; background: #f1f2f4; color: #8b9097; }
  .ta-ui-rc .ta-message-search>span { font-size: 24px; line-height: 1; }
  .ta-ui-rc .ta-message-search input { flex: 1 1 auto; min-width: 0; width: 100%; height: 38px; border: 0; outline: 0; box-shadow: none; background: transparent; color: #26384a; font: inherit; font-size: 14px; }
  .ta-ui-rc .ta-message-list { background: #fff; }
  .ta-ui-rc .ta-message-swipe-row { position: relative; overflow: hidden; background: #edf1f4; touch-action: pan-y; }
  .ta-ui-rc .ta-message-swipe-action { position: absolute; z-index: 0; inset-block: 0; display: grid; place-items: center; width: 76px; border: 0; color: #fff; font: 600 13px/1.2 system-ui,sans-serif; }
  .ta-ui-rc .ta-message-swipe-action.is-delete { left: 0; background: #e6534d; }
  .ta-ui-rc .ta-message-swipe-action.is-pin { right: 0; background: #537da2; }
  .ta-ui-rc .ta-message-list-row { position: relative; z-index: 1; transition: transform .18s ease; will-change: transform; }
  .ta-ui-rc .ta-message-swipe-row.is-revealed-pin .ta-message-list-row { transform: translateX(-76px); }
  .ta-ui-rc .ta-message-swipe-row.is-revealed-delete .ta-message-list-row { transform: translateX(76px); }
  .ta-ui-rc .ta-message-swipe-row.is-pinned .ta-message-list-top strong::before { content: '◆'; margin-inline-end: 6px; color: #537da2; font-size: 9px; vertical-align: 2px; }
  .ta-ui-rc .ta-message-list-row { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 76px; margin: 0; padding: 10px 14px; border: 0; border-radius: 0; border-bottom: 1px solid #eceef0; background: #fff; color: inherit; text-decoration: none; }
  .ta-ui-rc .ta-message-list-row[hidden] { display: none !important; }
  .ta-ui-rc .ta-message-list-avatar { display: grid; place-items: center; flex: 0 0 54px; width: 54px; height: 54px; overflow: hidden; border-radius: 8px; background: #eaf1f7; color: #355878; font-size: 21px; font-weight: 650; }
  .ta-ui-rc .ta-message-list-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .ta-ui-rc .ta-message-list-copy { display: grid; flex: 1 1 auto; gap: 6px; min-width: 0; }
  .ta-ui-rc .ta-message-list-top,.ta-ui-rc .ta-message-list-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
  .ta-ui-rc .ta-message-list-top strong { display: block; min-width: 0; overflow: hidden; color: #202124; font-size: 16px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
  .ta-ui-rc .ta-message-list-top time { flex: 0 0 auto; color: #a1a5aa; font-size: 11px; white-space: nowrap; }
  .ta-ui-rc .ta-message-list-bottom>span { min-width: 0; overflow: hidden; color: #9a9da2; font-size: 13px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
  .ta-ui-rc .ta-message-unread-count { display: grid; place-items: center; flex: 0 0 auto; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 10px; background: #e6534d; color: #fff; font-size: 10px; font-weight: 600; }
  .ta-ui-rc .ta-message-search-empty { margin: 0; padding: 30px 16px; color: #8c9299; text-align: center; }
  .ta-ui-rc .ta-message-pagination { margin: 12px; }

  .ta-ui-rc .global-chat-panel[data-chat-geometry="v113"] {
    left: var(--ta-chat-visual-left, 0px) !important;
    right: auto !important;
    top: var(--ta-chat-visual-top, 0px) !important;
    bottom: var(--ta-mobile-nav-height, calc(68px + env(safe-area-inset-bottom, 0px))) !important;
    width: var(--ta-chat-visual-width, 100vw) !important;
    height: calc(var(--ta-chat-visual-height, 100dvh) - var(--ta-mobile-nav-height, calc(68px + env(safe-area-inset-bottom, 0px)))) !important;
    max-height: none !important;
  }

  .ta-ui-rc .global-chat-compose {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    min-height: 0;
    max-height: 34%;
    overflow: visible;
    padding: 8px max(10px, env(safe-area-inset-right, 0px)) 8px max(10px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #e3eaf1;
    background: #fff;
  }

  .ta-ui-rc .global-chat-compose .ta-chat-input-area {
    grid-column: 1;
    min-width: 0;
    min-height: 44px;
    max-height: 130px;
    overflow-y: auto;
  }

  .ta-ui-rc .global-chat-compose textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px !important;
    height: 44px;
    max-height: 112px !important;
    padding: 11px 14px;
    border: 1px solid #d9e3ec;
    border-radius: 22px;
    background: #f4f6f8;
    font-size: 16px;
    line-height: 1.35;
    resize: none;
  }

  .ta-ui-rc .global-chat-compose .global-chat-attachment-preview {
    max-height: 82px;
    overflow: auto;
  }

  .ta-ui-rc .global-chat-compose-actions {
    grid-column: 2;
    display: flex !important;
    align-items: center;
    gap: 7px !important;
    margin: 0;
  }

  .ta-ui-rc .global-chat-mobile-attach {
    position: relative;
    flex: 0 0 44px;
  }

  .ta-ui-rc .global-chat-mobile-attach > summary {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    border: 1px solid #d8e2ec;
    border-radius: 50%;
    background: #f4f6f8;
    color: #193e66;
    font: 400 30px/1 system-ui, sans-serif;
    cursor: pointer;
    list-style: none;
  }

  .ta-ui-rc .global-chat-mobile-attach > summary::-webkit-details-marker { display: none; }

  .ta-ui-rc .global-chat-mobile-attach-menu {
    position: absolute;
    z-index: 20;
    inset-inline-end: 0;
    bottom: calc(100% + 10px);
    display: none;
    min-width: 176px;
    padding: 8px;
    border: 1px solid #d9e3ec;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 28px #1b477026;
  }

  .ta-ui-rc .global-chat-mobile-attach[open] .global-chat-mobile-attach-menu { display: grid; gap: 6px; }

  .ta-ui-rc .global-chat-compose-actions .global-chat-mobile-attach-menu > label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 9px;
    background: #f5f8fb;
    color: #193e66;
    font-size: 14px;
    line-height: 1.3;
    text-align: start;
    overflow-wrap: anywhere;
  }

  .ta-ui-rc .global-chat-mobile-attach-menu > label input[type="file"] {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
  }

  .ta-ui-rc .global-chat-compose-actions > .btn {
    flex: 0 1 auto;
    min-width: 48px;
    max-width: min(28vw, 120px);
    min-height: 44px;
    height: auto;
    margin: 0 !important;
    padding: 8px 12px;
    border-radius: 22px;
    font-size: 13px;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Keep the global mobile nav visible; the chat stops immediately above it. */
  .ta-ui-rc .global-chat-widget.is-open > .global-chat-fab,
  .ta-ui-rc .global-chat-fallback-fab { display: none !important; }
}

@media (max-width: 980px) {
  body.ta-mobile-chat-screen { overflow: hidden; }
  body.ta-mobile-chat-screen .topbar,
  body.ta-mobile-chat-screen .global-scope-notice,
  body.ta-mobile-chat-screen .ta-mobile-bottom-nav,
  body.ta-mobile-chat-screen > .foot,
  body.ta-mobile-chat-screen .back-to-top { display: none !important; }
  body.ta-mobile-chat-screen .global-chat-panel[data-chat-geometry="v113"] {
    inset: auto !important;
    left: var(--ta-chat-visual-left,0px) !important;
    top: var(--ta-chat-visual-top,0px) !important;
    right: auto !important;
    bottom: auto !important;
    width: var(--ta-chat-visual-width,100vw) !important;
    height: var(--ta-chat-visual-height,100dvh) !important;
    max-height: none !important;
    padding-bottom: env(safe-area-inset-bottom,0px) !important;
    background: #f5f5f5 !important;
  }
  body.ta-mobile-chat-screen .global-chat-window-head { display: none !important; }
  body.ta-mobile-chat-screen .global-chat-conversation { background: #f5f5f5; }
  body.ta-mobile-chat-screen .global-chat-person-head { display: grid !important; grid-template-columns: 38px minmax(0,1fr) auto !important; gap: 4px; min-height: 54px; max-height: 64px; padding: 4px 8px; border-bottom: 1px solid #e2e4e7; background: #f7f7f7; }
  body.ta-mobile-chat-screen .global-chat-mobile-back { display: grid !important; place-items: center; width: 40px; height: 44px; color: #222; font: 400 32px/1 system-ui,sans-serif; text-decoration: none; }
  body.ta-mobile-chat-screen .global-chat-person { min-width: 0; }
  body.ta-mobile-chat-screen .global-chat-person-avatar,
  body.ta-mobile-chat-screen .global-chat-person-copy>small { display: none !important; }
  body.ta-mobile-chat-screen .global-chat-person-actions { display: flex !important; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
  body.ta-mobile-chat-screen .global-chat-mobile-follow-slot { display: contents; }
  body.ta-mobile-chat-screen .global-chat-person-actions button { display: inline-flex !important; align-items: center; justify-content: center; width: 34px; min-width: 34px; height: 34px; padding: 0 6px; border: 1px solid #d8e2ec; border-radius: 18px; background: #fff; color: #315a7d; font-size: 12px; }
  body.ta-mobile-chat-screen .global-chat-person-actions .global-chat-delete-conversation { display: none !important; }
  body.ta-mobile-chat-screen .global-chat-action-icon { display: inline !important; }
  body.ta-mobile-chat-screen .global-chat-action-label { display: none !important; }
  body.ta-mobile-chat-screen .global-chat-follow-btn { max-width: 78px; min-width: 56px !important; width: auto !important; padding-inline: 9px !important; white-space: nowrap; }
  body.ta-mobile-chat-screen .global-chat-follow-btn .follow-btn-label { display: inline !important; overflow: hidden; text-overflow: ellipsis; }
  body.ta-mobile-chat-screen .global-chat-person-name strong { max-width: 100%; color: #202124; font-size: 17px; font-weight: 600; }
  body.ta-mobile-chat-screen .global-chat-thread {
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 12px 12px 8px;
    background: #f5f5f5;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    touch-action: pan-y;
  }
  body.ta-mobile-chat-screen .global-chat-message-row { gap: 8px; margin-block: 10px; }
  body.ta-mobile-chat-screen .global-chat-message-avatar { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 6px; }
  body.ta-mobile-chat-screen .global-chat-bubble { max-width: min(78vw,520px); border: 0; border-radius: 9px; padding: 10px 12px; box-shadow: none; }
  body.ta-mobile-chat-screen .global-chat-message-row.is-mine .global-chat-bubble { background: #95ec69; color: #17251b; }
  body.ta-mobile-chat-screen .global-chat-message-row.is-theirs .global-chat-bubble { background: #fff; color: #202124; }
  body.ta-mobile-chat-screen .global-chat-bubble-foot { color: #9a9da2; }
  body.ta-mobile-chat-screen .global-chat-message-avatar { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  body.ta-mobile-chat-screen .global-chat-compose { border-top: 1px solid #dedfe2; background: #f7f7f7; padding-block-end: max(8px,env(safe-area-inset-bottom,0px)); }
}

@media (max-width: 370px) {
  body.ta-mobile-chat-screen .global-chat-person-head { grid-template-columns: 34px minmax(0,1fr) auto !important; gap: 2px; padding-inline: 5px; }
  body.ta-mobile-chat-screen .global-chat-person-actions { gap: 2px; }
  body.ta-mobile-chat-screen .global-chat-person-actions button { width: 30px; min-width: 30px; height: 30px; }
  body.ta-mobile-chat-screen .global-chat-follow-btn { min-width: 50px !important; padding-inline: 5px !important; }
}

@media (min-width: 981px) {
  .ta-ui-rc .global-chat-mobile-attach { display: contents; }
  .ta-ui-rc .global-chat-mobile-attach > summary { display: none; }
  .ta-ui-rc .global-chat-mobile-attach-menu { display: contents; }
}

.message-shared-context-card[data-message-context-url],
.message-product-context-card[data-message-context-url] { cursor: pointer; }
.message-shared-context-card[data-message-context-url]:focus-visible,
.message-product-context-card[data-message-context-url]:focus-visible { outline: 3px solid #1765d1; outline-offset: 2px; }
