/*
 * Messages (conversations#index and #show). The list and the thread side by side;
 * Stay safe sits under the thread.
 *
 * Shares tokens and the page wrapper with the other redesigned pages. Same
 * rules, with one exception the handoff makes: the other person's bubbles carry
 * a soft shadow, so they lift off the grey message area. Values are the
 * Messages handoff's.
 */

.mx-page ::selection { background: var(--cm-blue-light); }
.mx-page a { text-decoration: none; }

.mx-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
}

/* main supplies the handoff's 20px under the header. */
.mx-sponsored { padding-top: 0; }

.mx-title {
  margin: 22px 0 0;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.05;
  color: var(--cm-ink);
}

/* ----------------------------------------------------------------- columns */

/* Phone: one column. The inbox is the list; a conversation is its thread. */
.mx-split {
  margin-top: 16px;
  display: grid;
  gap: 20px;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
}

.mx-page--thread .mx-list { display: none; }
.mx-page:not(.mx-page--thread) .mx-empty { display: none; }

/* From 760px: the list beside the thread. Stay safe is part of the thread's
   column (under the composer) rather than a column of its own, so the thread
   gets the width. */
@media (min-width: 760px) {
  .mx-split { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
  .mx-page--thread .mx-list { display: flex; }
  .mx-page:not(.mx-page--thread) .mx-empty { display: flex; }
  .mx-page .mx-back { display: none; }   /* the list is beside the thread */
}

/* Wide enough, Stay safe lays out in two columns: advice on the left, meetup
   spots and the report / block links on the right. */
@media (min-width: 1020px) {
  .mx-thread .mx-safe {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
  }

  .mx-safe__head,
  .mx-safe__list,
  .mx-safe__partners { grid-column: 1; }

  .mx-safe__meet { grid-column: 2; grid-row: 1 / span 2; }
  .mx-safe__foot { grid-column: 2; grid-row: 3; }

  /* Service conversations have no meetup spots: one column. */
  .mx-thread .mx-safe:not(:has(.mx-safe__meet)) { display: flex; }
}

/* -------------------------------------------------------------------- list */

.mx-list {
  display: flex;
  flex-direction: column;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: 14px;
  overflow: hidden;
  height: calc(100vh - 150px);
  min-height: 480px;
}

@media (min-width: 760px) {
  .mx-list {
    height: calc(100vh - 230px);
    min-height: 520px;
    position: sticky;
    top: 120px;
  }
}

@media (min-width: 1020px) {
  .mx-list { top: 76px; }
}

.mx-list__head {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--cm-divider);
}

.mx-tabs {
  display: flex;
  gap: 2px;
  background: var(--cm-band);
  border: 1px solid var(--cm-border-band);
  border-radius: 10px;
  padding: 3px;
}

.mx-tab {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cm-ink-muted);
}

.mx-tab:hover { color: var(--cm-ink); }
.mx-tab--on, .mx-tab--on:hover { background: var(--cm-ink); color: var(--cm-ground); }

.mx-tab__count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--cm-divider);
  color: var(--cm-ink);
}

.mx-tab--on .mx-tab__count { background: var(--cm-yellow); }

.mx-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--pf-surface-warm);
  border: 1px solid var(--cm-border-band);
}

.mx-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;   /* keeps iOS from zooming on focus */
  color: var(--cm-ink);
  -webkit-appearance: none;
  appearance: none;
}

.mx-search input::-webkit-search-cancel-button { display: none; }
.mx-search:has(input:focus-visible) { outline: 2px solid var(--cm-blue); outline-offset: 2px; }
.mx-page .mx-search input:focus-visible { outline: none; }

.mx-roles { display: flex; flex-wrap: wrap; gap: 6px; }

.mx-role {
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1.5px solid var(--cm-border);
  background: var(--cm-surface);
  color: var(--cm-ink);
  cursor: pointer;
}

.mx-role[aria-pressed="true"] { border-color: var(--cm-ink); background: var(--cm-ground); }

.mx-list__rows { flex: 1; min-height: 0; overflow-y: auto; }

.mx-list__none {
  margin: 0;
  padding: 22px 16px;
  font-size: 14px;
  color: var(--cm-ink-muted);
}

.mx-list__none[hidden] { display: none; }

.mx-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--cm-divider);
  background: var(--cm-surface);
  color: var(--cm-ink);
}

.mx-row[hidden] { display: none; }
.mx-row:hover { background: var(--cm-ground); color: var(--cm-ink); }
.mx-row--unread { background: var(--pf-surface-warm); }
.mx-row[aria-current="page"], .mx-row[aria-current="page"]:hover { background: var(--cm-yellow); }

.mx-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mx-row__top { display: flex; align-items: center; gap: 8px; }

.mx-row__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mx-row--unread .mx-row__name { font-weight: 800; }
.mx-row__spacer { flex: 1; }

.mx-row__date {
  font-size: 11.5px;
  color: var(--cm-ink-muted);
  white-space: nowrap;
}

.mx-row__subject {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cm-link);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mx-row__preview {
  font-size: 13px;
  line-height: 1.35;
  color: var(--cm-ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.mx-row--unread .mx-row__preview { color: var(--cm-ink); font-weight: 600; }

.mx-row__dot {
  width: 9px;
  height: 9px;
  flex: none;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--cm-orange);
}

.mx-tag {
  flex: none;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.mx-tag--service { background: var(--cm-blue-light); color: var(--cm-blue-ink); }
.mx-tag--sold { background: var(--cm-orange); color: #FFFFFF; }
.mx-tag--muted { background: var(--cm-divider); color: var(--cm-ink-muted); }
.mx-tag--archived { background: var(--cm-ink); color: var(--cm-ground); }

/* ------------------------------------------------------------------ thread */

.mx-empty {
  flex-direction: column;
  gap: 6px;
  padding: 28px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: 14px;
}

.mx-empty__title { margin: 0; font-size: 16px; font-weight: 700; color: var(--cm-ink); }
.mx-empty__body { margin: 0; max-width: 40ch; font-size: 14px; color: var(--cm-ink-muted); }

.mx-thread {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mx-thread__head { display: flex; align-items: flex-start; gap: 12px; }

.mx-back {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cm-ink);
}

.mx-back:hover { background: var(--cm-band); color: var(--cm-ink); }

.mx-thumb {
  width: 56px;
  height: 44px;
  flex: none;
  border-radius: 9px;
  background: var(--pf-placeholder);
  border: 1px solid var(--cm-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mx-thumb:hover { border-color: var(--cm-ink); }
.mx-thumb img { width: 100%; height: 100%; object-fit: cover; }

.mx-thread__who { flex: 1; min-width: 0; }

.mx-thread__subject {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.mx-thread__item {
  font-size: clamp(20px, 2.6vw, 24px);
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.15;
  color: var(--cm-ink);
  overflow-wrap: anywhere;
}

.mx-thread__item:hover { color: var(--cm-link); }
.mx-thread__item--gone { color: var(--cm-ink-muted); }
.mx-thread__price { font-size: 15px; font-weight: 700; color: var(--cm-ink); }

.mx-thread__with {
  margin: 3px 0 0;
  font-size: 15px;
  color: var(--cm-ink-muted);
}

.mx-thread__with a { color: var(--cm-orange); font-weight: 600; }
.mx-thread__with a:hover { color: var(--pf-danger); }

.mx-ghost {
  flex: none;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 10px;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #444444;
  cursor: pointer;
}

.mx-ghost:hover { background: var(--cm-band); color: var(--cm-ink); }

@media (max-width: 480px) {
  .mx-ghost span { display: none; }
}

.mx-messages {
  height: min(56vh, 480px);
  min-height: 280px;
  overflow-y: auto;
  background: #FAFAFA;
  border: 2px solid var(--cm-ink);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mx-msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}

.mx-msg--mine { align-items: flex-end; }

.mx-bubble {
  max-width: min(80%, 560px);
  padding: 12px 18px 11px;
  border-radius: 16px;
  background: #FFFFFF;
  color: var(--cm-ink);
  border: 1px solid #ECECEC;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.mx-msg--mine .mx-bubble {
  background: var(--cm-blue);
  color: var(--cm-blue-ink);
  border-color: var(--cm-blue);
  box-shadow: none;
}

.mx-bubble__text { font-size: 15.5px; line-height: 1.4; }

.mx-bubble__meta {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--cm-ink-muted);
}

.mx-msg--mine .mx-bubble__meta { color: #0F4A60; }

.mx-offer { min-width: 220px; }
.mx-offer, .mx-msg--mine .mx-offer { background: #FFF6BF; border: 2px solid var(--fd-under-border); color: var(--cm-ink); box-shadow: none; }
.mx-offer--accepted, .mx-msg--mine .mx-offer--accepted { background: #EDF2D8; border-color: #9CC27A; }

.mx-offer__label {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--cm-yellow-ink);
}

.mx-offer--accepted .mx-offer__label { color: #3E6B1F; }

.mx-offer__amount { margin: 4px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
.mx-offer__note { margin: 8px 0 0; font-size: 14.5px; line-height: 1.4; }
.mx-msg--mine .mx-offer .mx-bubble__meta { color: var(--cm-ink-muted); }

.mx-offer__btn {
  margin-top: 10px;
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  border: 1.5px solid var(--cm-ink);
  background: var(--cm-blue);
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-blue-ink);
  cursor: pointer;
}

.mx-offer__btn--ink, .mx-offer__btn--ink:hover { background: var(--cm-ink); color: var(--cm-ground); }

.mx-receipt {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: #0E9BD6;
}

.mx-receipt[hidden] { display: none; }

.mx-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 1px solid #ECECEC;
  font-size: 12.5px;
  color: var(--cm-ink-muted);
}

.mx-typing.hidden { display: none; }
.mx-typing__dots { display: flex; gap: 3px; }
.mx-typing__dots span { width: 6px; height: 6px; border-radius: 999px; background: var(--cm-blue); }

/* Nudge */

.mx-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 12px 12px 18px;
  border-radius: 16px;
  background: #FFE7C4;
  border: 2px solid var(--cm-orange);
}

.mx-nudge__text { flex: 1 1 180px; min-width: 0; font-size: 16px; font-weight: 600; color: var(--cm-ink); }

.mx-nudge__btn {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 20px 0 16px;
  border-radius: 12px;
  background: var(--cm-orange);
  border: 2px solid var(--cm-ink);
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  cursor: pointer;
}

.mx-nudge__btn:hover { background: #E0521B; }

.mx-nudged {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--pf-danger-soft);
  border: 2px solid #F9B79B;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--pf-danger);
}

.mx-note { margin: 0; padding: 0 6px; font-size: 13px; color: var(--cm-ink-muted); }

.mx-closed {
  padding: 14px 18px;
  border-radius: 16px;
  border: 2px solid var(--cm-ink);
  background: var(--cm-surface);
  font-size: 14px;
  color: var(--cm-ink);
}

.mx-closed p { margin: 0; }
.mx-closed__title { font-weight: 700; margin-bottom: 4px !important; }
.mx-closed__link { display: inline-block; margin-top: 8px; font-weight: 700; color: var(--cm-link); }

/* Quick replies and composer */

.mx-quick { display: flex; flex-wrap: wrap; gap: 6px; }

.mx-quick__chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--cm-surface);
  border: 1.5px solid var(--cm-border-band);
  font-size: 13px;
  font-weight: 600;
  color: var(--cm-ink);
  cursor: pointer;
}

.mx-quick__chip:hover { border-color: var(--cm-ink); }

.mx-composer { display: flex; align-items: flex-end; gap: 10px; }

.mx-composer__field {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  resize: none;
  border: 2px solid var(--cm-ink);
  border-radius: 27px;
  padding: 14px 22px;
  font-size: 17px;
  line-height: 1.3;
  color: var(--cm-ink);
  background: #FAFAFA;
}

.mx-composer__field:focus-visible { outline: 2px solid var(--cm-blue); outline-offset: 2px; }

.mx-composer__send {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cm-ink);
  background: var(--cm-blue);
  color: var(--cm-blue-ink);
  cursor: pointer;
}

.mx-composer__send:disabled {
  border-color: #A9C2BF;
  background: #B3E3EA;
  color: #6E8F8C;
  cursor: not-allowed;
}

/* Tip */

.mx-tip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 16px;
  border: 2px dashed var(--fd-under-border);
  background: #FFF6BF;
}

.mx-tip svg { flex: none; }
.mx-tip__text { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; color: var(--cm-ink); }

.mx-tip__close {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cm-ink-muted);
  cursor: pointer;
}

.mx-tip__close:hover { background: var(--cm-yellow); color: var(--cm-ink); }

/* --------------------------------------------------------------- Stay safe */

.mx-safe {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-radius: 16px;
  background: #EDF2D8;
  border: 2px solid var(--cm-blue);
}

.mx-safe__head { display: flex; align-items: center; gap: 12px; }
.mx-safe__head h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--cm-ink); }

.mx-safe__icon {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 999px;
  background: var(--cm-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mx-safe__list {
  margin: 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--cm-ink);
  list-style: disc;
}

.mx-safe__partners {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--cm-yellow);
  border: 1.5px solid var(--cm-yellow-border);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--cm-ink);
}

.mx-safe__partners:hover { background: var(--fd-under-border); color: var(--cm-ink); }

.mx-safe__sub { margin: 0; font-size: 14px; font-weight: 700; color: var(--cm-ink); }
.mx-safe__spots { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

.mx-spot {
  padding: 6px 11px;
  border-radius: 999px;
  border: 0;
  background: #CFEBE3;
  font-size: 13px;
  font-weight: 600;
  color: var(--cm-blue-ink);
  cursor: pointer;
}

.mx-spot:hover { background: var(--cm-blue-light); }

.mx-safe__foot {
  padding-top: 12px;
  border-top: 1px solid #C9D8B4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mx-safe__action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 14px;
  color: #555555;
  text-align: left;
  cursor: pointer;
}

.mx-safe__action:hover { color: var(--pf-danger); }
