/* Layout */
.layout__content--messages {
  display: flex;
  min-height: 100vh;
}

/* LEFT: Inbox / threads */
.inbox {
  width: 340px;
  border-right: 1px solid #e5e7eb;
  padding: 24px 24px 16px;
  background: #f9fbff;
  display: flex;
  flex-direction: column;
}

.inbox__header {
  margin-bottom: 16px;
}

.inbox__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.inbox__subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.inbox__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 8px 12px;
}

.inbox__search-input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 0.9rem;
}

.inbox__search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af; /* icon colour */
}

.inbox__search-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}


/* Threads list */
.thread-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.thread-list__empty {
  font-size: 0.9rem;
  color: #9ca3af;
  padding: 8px;
}

.thread {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.05s ease,
    background-color 0.15s ease;
  align-items: center;
}

.thread:hover {
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.thread--active {
  box-shadow: 0 0 0 2px #22c1c3;
}

.thread__avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #22c1c3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.thread__body {
  flex: 1;
  min-width: 0;
}

.thread__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.thread__name {
  font-size: 0.95rem;
  font-weight: 600;
}

.thread__time {
  font-size: 0.75rem;
  color: #9ca3af;
}

.thread__meta {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 2px;
}

.thread__plate {
  font-weight: 500;
}

.thread__snippet {
  font-size: 0.85rem;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RIGHT: Conversation panel */

.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  background: #f3f4fb;
}

.conversation--hidden {
  display: none;
}

/* Empty state */
.conversation-empty {
  flex: 1;
  display: none; /* JS toggles this */
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #6b7280;
}

.conversation-empty__icon {
  font-size: 2rem;
}

.conversation-empty__title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Conversation header */
/* Conversation header */
.conversation__header {
  position: relative;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center; /* center the whole group */
}

/* Center VRM + meta in the header */
.conversation__header-left {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Keep the remove button in the top-right corner */
.conversation__remove-btn {
  position: absolute;
  right: 24px;
  top: 24px;
}

/* Make the plate look like your standard UK plate */
.conversation__plate {
  background: #DEDE17;
  border-radius: 13px;
  border: 1px solid #D1C044;
  padding: 8px 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
  /* text styling lives here, because the VRM is the direct text node */
  font-family: "UKNumberPlate", "UKNumberPlate Regular", system-ui, sans-serif;
  font-size: 44px;       /* tweak as you like */
  line-height: 1;
  
  text-transform: uppercase;
}

/* Center plate + meta block in the header */
.conversation__header {
  position: relative;
}

.conversation__header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;   /* centers plate + meta */
  gap: 4px;
}

/* Keep “Remove chat” on the right */
.conversation__remove-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}


.conversation__meta {
  font-size: 0.9rem;
  color: #6b7280;
  text-align: center; /* centre beneath the plate */
}


/* Messages area */
.conversation__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Individual message rows */


.conversation__message--mine {
  align-self: flex-end;
  text-align: right;
}

.conversation__message--theirs {
  align-self: flex-start;
  text-align: left;
}

/* Speech bubbles */
.conversation__bubble {
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.conversation__message--mine .conversation__bubble {
  background: #00c2a8;
  color: white;
  border-bottom-right-radius: 4px;
}

.conversation__message--theirs .conversation__bubble {
  background: #ffffff;
  color: #111827;
  border-bottom-left-radius: 4px;
}

/* Timestamp under each bubble */
.conversation__time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 4px;
}

/* Input bar fixed at bottom of panel */
.conversation__form {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
}

.conversation__input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}

.conversation__input:focus {
  border-color: #22c1c3;
  box-shadow: 0 0 0 1px rgba(34, 193, 195, 0.6);
}

.conversation__send-btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: #111827;
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.conversation__send-btn:hover {
  opacity: 0.9;
}

.account-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  font-size: 13px;
  margin-bottom: 16px;
}

.account-box__label {
  color: #6b7280;
}

.account-box__email {
  font-weight: 500;
  color: #111827;
}

.account-box__switch {
  margin-left: 8px;
  border: none;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  font-size: 13px;
}

/* Switch panel (can be a little floating card) */
.account-switch {
  margin-top: 8px;
}

.account-switch--hidden {
  display: none;
}

.account-switch__form {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
  max-width: 260px;
}

.account-switch__title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.account-switch__input {
  width: 100%;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 13px;
}

.account-switch__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.account-switch__submit {
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: #111827;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

.account-switch__cancel {
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: #e5e7eb;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
}

.thread__unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  background: #111827; /* dark pill */
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
}

/* Optional: make unread threads look bolder */
.thread--unread .thread__name {
  font-weight: 600;
}

.thread--unread .thread__snippet {
  font-weight: 500;
}

.conversation__remove-btn {
  border: none;
  background: transparent;
  font-size: 13px;
  color: #9ca3af;
  cursor: pointer;
}

.conversation__remove-btn:hover {
  color: #ef4444;
}

/* ---------------------------------------------------
   System / offer / automatic messages
   --------------------------------------------------- */

/* Legacy helper if you ever use it elsewhere */
.chat-bubble--system {
  background-color: #0f172a;
  color: #e5f0ff;
  border-radius: 16px;
  padding: 8px 14px;
  max-width: 70%;
  margin: 6px auto;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-bubble--system strong {
  font-weight: 600;
}

/* Dark blue automatic messages – bubble look */
.conversation__message--system .conversation__bubble {
  background-color: #0f172a; /* dark navy */
  color: #e5f0ff;
  border-radius: 18px;
  padding: 10px 16px;
  max-width: 80%;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.conversation__message--system .conversation__bubble strong {
  font-weight: 600;
}



/* Offer cards container */


/* Title line for offer / counter cards */
.conversation__offer-title {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Shared body text */
.conversation__offer-text {
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Big centred price for initial offer / counter */
.conversation__offer-card--pricing .conversation__offer-amount {
  margin: 6px 0 6px;
  font-size: 1.6rem;
  font-weight: 700;
  align-self: stretch;
  text-align: center;
}




/* Accepted card: compact with single sentence + CTA */
.conversation__offer-card--accepted {
  gap: 8px;
}

.conversation__offer-card--accepted .conversation__offer-text {
  font-size: 0.95rem;
}

/* Hide amount block in accepted cards (we don't use it there) */
.conversation__offer-card--accepted .conversation__offer-amount {
  display: none;
}

/* Action buttons row (accept / counter / payment CTA) */
.conversation__offer-actions {
  margin-top: 8px;
  margin-bottom: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* Slightly tighter spacing for accepted card CTA row */
.conversation__offer-card--accepted .conversation__offer-actions {
  margin-top: 6px;
}

/* Buttons */
.conversation__offer-btn {
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;    /* <-- remove link underline / colour */
  font-weight: 600;         /* optional, makes label stronger */
}


/* Primary accept / payment button (green) */
.conversation__offer-btn--accept {
  background-color: #10b981; /* emerald */
  color: #ffffff;
}

/* Secondary counter button (outline) */
.conversation__offer-btn--counter {
  background-color: transparent;
  border: 1px solid #e5e7eb;
  color: #e5f0ff; /* light text against dark bubble */
}

/* Disabled / greyed-out buttons */
.conversation__offer-btn--disabled,
.conversation__offer-btn[disabled] {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* Notices under cards (e.g. "Another user has already bought this reg.") */
/* Generic notice under an offer card */
.conversation__notice {
  margin-top: 8px;
  font-size: 13px;
  width: 100%;              /* stretch to full card width */
  white-space: normal; /* collapse spaces & treat like regular text */
}

/* Danger notice: simple left-aligned block */
.conversation__notice--danger {
  color: #ff4d4f;
  font-weight: 600;
  display: block;           /* no flex, no odd centering */
}


.conversation__message--system .conversation__bubble {
  background: #081027;
  color: #e5f0ff;
  padding: 10px 16px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
/* Keep system/offer cards from becoming huge on desktop */
.conversation__message--system {
  max-width: 420px;
}

.conversation__message--system .conversation__bubble {
  max-width: 420px;
}

/* ---------------------------------------------------
   Mobile-only UI (matches CarTrait pattern)
   --------------------------------------------------- */

/* Hidden by default (desktop/tablet) */
.reg-mobile-menu-btn,
.reg-mobile-menu,
.conversation__back-btn {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop sidebar */
  #side-nav {
    display: none !important;
  }

  /* Make the main messages layout full-width on mobile */
  .layout__content--messages {
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  /* Inbox panel becomes full width */
  .inbox {
    width: 100%;
    border-right: none;
    padding: 18px 16px 12px;
  }

  /* Don’t show the right-side empty state on mobile (prevents stacking) */
  #conversation-empty {
    display: none !important;
  }

  /* When a thread is opened on mobile, show conversation full-width and hide inbox list */
  body.messages-thread-open .inbox {
    display: none;
  }

  body.messages-thread-open #conversation-panel {
    display: flex;
  }

  /* Conversation panel full-width + safe bottom padding above bottom nav */
  .conversation {
    width: 100%;
    padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
  }

  /* Header row for title + menu */
  .reg-header-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
  }

  /* Mobile dashboard dropdown button */
  .reg-mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 12px;
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    flex: 0 0 auto;
  }

  /* Dropdown */
  .reg-mobile-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(10, 10, 10, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    z-index: 50;
  }

  .reg-mobile-menu.is-open {
    display: block;
  }

  .reg-mobile-menu__item {
    display: block;
    padding: 10px 10px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
  }

  .reg-mobile-menu__item.is-active {
    background: rgba(255, 255, 255, 0.10);
  }

  /* Mobile back button in conversation header */
  .conversation__back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  /* Tone down plate sizing on mobile so it doesn’t overflow */
  .conversation__plate {
    font-size: 28px;
    padding: 8px 18px;
  }

  .conversation__remove-btn {
    right: 0;
  }

  
}

@media (max-width: 768px) {
  /* Stop header overlap: back | plate/meta | remove */
  .conversation__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
  }

  /* Undo any absolute/transform centering on mobile */
  .conversation__header-left,
  .conversation__remove-btn {
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
  }

  .conversation__header-left {
    min-width: 0;
    text-align: center;
  }

  .conversation__plate {
    max-width: 100%;
    box-sizing: border-box;
    padding: 8px 14px;
    font-size: clamp(28px, 9vw, 44px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .conversation__meta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation__remove-btn {
    font-size: 12px;
    white-space: nowrap;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Prevent bubbles/cards pushing off-screen */
  .conversation__bubble {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Give messages more room on mobile (fix offer cards overflowing) */
  .conversation__message {
    max-width: 88%;
  }

  .conversation__message--system {
    max-width: 92%;
    align-self: center;
  }
}


/* Hide dropdown on desktop by default */
.reg-mobile-menu-btn,
.reg-mobile-menu {
  display: none;
}

/* ---------------- Mobile-only layout + dropdown (match other pages) ---------------- */
@media (max-width: 768px) {
  /* Ensure media queries behave properly + avoid horizontal overflow */
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Header row anchors dropdown */
  .reg-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    margin-bottom: 14px;
  }

  /* Make the messages layout single-column */
  .layout__content--messages {
    display: block;
    min-height: auto;
  }

  /* Left column becomes full-width */
  .inbox {
    width: 100%;
    border-right: none;
    padding: 18px 16px 0;
    box-sizing: border-box;
  }

  /* Thread list should scroll naturally with the page */
  .thread-list {
    overflow: visible;
  }

  /* Conversation view: hidden until a thread is opened */
  .conversation {
    display: none;
    padding: 16px 16px 120px;
    box-sizing: border-box;
  }

  body.messages-thread-open .inbox {
    display: none;
  }

  body.messages-thread-open .conversation {
    display: flex;
  }

  /* Back button only on mobile */
  .conversation__back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(17, 24, 39, 0.12);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
  }

  /* Fix header overlap on mobile (your desktop header uses absolute positioning) */
  .conversation__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    justify-content: unset;
    min-height: auto;
  }

  .conversation__header-left,
  .conversation__remove-btn {
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
  }

  .conversation__header-left {
    min-width: 0;
    text-align: center;
    align-items: center;
  }

  .conversation__plate {
    max-width: 100%;
    box-sizing: border-box;
    padding: 8px 14px;
    font-size: clamp(28px, 9vw, 44px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .conversation__meta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation__remove-btn {
    font-size: 12px;
    white-space: nowrap;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Prevent bubbles/cards pushing off-screen */
  .conversation__bubble {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .conversation__message {
    max-width: 88%;
  }

  .conversation__message--system {
    max-width: 92%;
    align-self: center;
  }

  /* ✅ Dropdown styles (same as your other pages) */
  .reg-mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(17, 24, 39, 0.10);
    background: rgba(255, 255, 255, 0.75);
    color: #111827;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    flex-shrink: 0;
  }

  .reg-mobile-menu {
    display: none;
    position: absolute;
    top: 52px;
    right: 0;
    width: 240px;
    border-radius: 18px;
    padding: 10px;
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(255,255,255,0.08);
    z-index: 9999;
  }

  .reg-mobile-menu.is-open {
    display: block;
  }

  .reg-mobile-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 600;
  }

  .reg-mobile-menu__item:hover {
    background: rgba(255,255,255,0.08);
  }

  .reg-mobile-menu__icon {
    width: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.95;
  }

  .reg-mobile-menu__item.is-active {
    background: rgba(34, 211, 238, 0.15);
  }
}

/* ✅ FINAL mobile rules (single source of truth) */
@media (max-width: 768px) {
  /* Prevent sideways overflow */
  html, body { overflow-x: hidden; }

  /* Thread open: conversation takes full screen */
  body.messages-thread-open .inbox { display: none; }
  body.messages-thread-open #conversation-panel { display: flex; }

  .conversation {
    width: 100%;
    max-width: 100%;
    padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }

  /* Header: Back | centered plate | Remove chat */
  .conversation__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: auto;
  }

  .conversation__back-btn,
  .conversation__header-left,
  .conversation__remove-btn {
    position: static !important;
    transform: none !important;
  }

  .conversation__header-left {
    text-align: center;
    align-items: center;
    min-width: 0;
  }

  .conversation__plate {
    max-width: 100%;
    padding: 8px 14px;
    font-size: clamp(26px, 8.5vw, 40px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Message rows */
  .conversation__message { max-width: 88%; }
  .conversation__bubble { overflow-wrap: anywhere; word-break: break-word; }

  /* ✅ System/offer cards: compact + centered */
  .conversation__message--system {
    align-self: center;
    max-width: 100%;
  }

  .conversation__message--system .conversation__bubble {
    width: auto;
    max-width: 92%;
    padding: 10px 14px;
    border-radius: 16px;
  }

  /* Offer card internals */
  .conversation__offer-card--pricing .conversation__offer-amount {
    font-size: clamp(22px, 7vw, 32px);
    margin: 6px 0 4px;
  }

  /* ✅ Buttons: pill-sized, not full width */
  .conversation__offer-actions {
    justify-content: center;
    gap: 10px;
  }

  .conversation__offer-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 118px;
    padding: 8px 14px;
    font-size: 0.86rem;
    border-radius: 999px;
  }
}

/* Desktop/laptop: stop system cards becoming huge */
.conversation__message--system .conversation__bubble {
  max-width: 520px;
}


@media (max-width: 768px) {
  /* tighter vertical rhythm */
  .conversation__messages {
    gap: 6px;
    padding: 12px 0;
  }

  .conversation__message {
    width: 100%;
    max-width: 100%;
    margin: 2px 0;
  }

  /* normal chat bubbles should stay readable */
  .conversation__message .conversation__bubble {
    max-width: 78%;
  }

  /* system/offer cards: NOT centered + max width 150px */
  .conversation__message--system .conversation__bubble {
    max-width: 150px;
    padding: 10px 12px;
  }

  /* make sure system cards follow mine/theirs alignment (not centered) */
  .conversation__message--mine.conversation__message--system .conversation__bubble {
    margin-left: auto;
    margin-right: 0;
  }

  .conversation__message--theirs.conversation__message--system .conversation__bubble {
    margin-right: auto;
    margin-left: 0;
  }

  /* shrink the offer typography so the cards don’t become tall */
  .conversation__offer-title,
  .conversation__offer-text {
    font-size: 0.85rem;
    line-height: 1.3;
  }

  .conversation__offer-card--pricing .conversation__offer-amount {
    font-size: 1.2rem;
    margin: 6px 0;
  }

  .conversation__offer-actions {
    gap: 8px;
    margin-top: 6px;
  }

  .conversation__offer-btn {
    padding: 7px 12px;
    font-size: 0.85rem;
  }
}

/* =========================================================
   SINGLE SOURCE OF TRUTH — Inbox message layout + system cards
   ========================================================= */

#conversation-messages{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:12px 0;
}

/* each message: bubble then timestamp */
#conversation-messages .conversation__message{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  margin:0;
}
#conversation-messages .conversation__message--mine{
  align-items:flex-end;
}

/* bubbles should size to content, not stretch full width */
#conversation-messages .conversation__bubble{
  display:inline-block;
  width:fit-content;
  max-width:min(520px,78%);
  margin:0;
}
#conversation-messages .conversation__time{
  margin-top:4px;
}

/* System bubble base (applies to offer + accepted + notices) */
#conversation-messages .conversation__message--system .conversation__bubble{
  background:#081027;
  color:#e5f0ff;
  border-radius:18px;
  padding:10px 14px;
  max-width:min(420px,72%);
}

/* Offer card internals: compact stacking */
#conversation-messages .conversation__message--system .conversation__offer-card{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:0;
  padding:0;
  width:100%;
  max-width:420px;
}
#conversation-messages .conversation__message--system .conversation__offer-title,
#conversation-messages .conversation__message--system .conversation__offer-text,
#conversation-messages .conversation__message--system .conversation__offer-amount{
  margin:0;
}
#conversation-messages .conversation__message--system .conversation__offer-actions{
  margin-top:6px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* -----------------------------
   Mobile
   ----------------------------- */
@media (max-width:768px){
  #conversation-messages{ gap:8px; padding:10px 0; }

  /* normal bubbles */
  #conversation-messages .conversation__bubble{
    max-width:min(300px,78%);
  }

  /* system bubble should be readable on mobile (accepted msg uses this) */
  #conversation-messages .conversation__message--system .conversation__bubble{
    max-width:92%;
    padding:10px 12px;
  }

  /* ✅ ONLY pricing/counter cards become 150px wide */
  #conversation-messages .conversation__message--system .conversation__offer-card--pricing{
    width:150px;
    max-width:150px;
  }

  /* buttons stack only inside the 150px pricing card */
  #conversation-messages .conversation__message--system
    .conversation__offer-card--pricing .conversation__offer-actions{
    flex-direction:column;
    align-items:stretch;
    gap:8px;
  }
  #conversation-messages .conversation__message--system
    .conversation__offer-card--pricing .conversation__offer-btn{
    width:100%;
    text-align:center;
  }
}

/* --- tighten top padding in system bubbles (accepted message) --- */
#conversation-messages .conversation__message--system .conversation__bubble{
  /* force bubble to size to content (kills any inherited height) */
  display: inline-block !important;
  height: auto !important;
  min-height: 0 !important;

  /* make top/bottom padding symmetrical */
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

/* remove any “first element margin” that creates extra top space */
#conversation-messages .conversation__message--system .conversation__bubble > :first-child{
  margin-top: 0 !important;
}

/* accepted card sometimes has its own spacing */
#conversation-messages .conversation__message--system .conversation__offer-card--accepted{
  padding: 0 !important;
  margin: 0 !important;
}
#conversation-messages .conversation__message--system .conversation__offer-card--accepted > *{
  margin: 0 !important;
}

/* -------------------------------------------------
   FIX: remove dark "dead space" under inbox (pc + mobile)
   Sidebar layout uses a dark background; when content is shorter,
   it shows through unless we force a light page background + full height.
-------------------------------------------------- */

html, body {
  background: #f6f7fb;
}

.layout,
.layout__content--messages {
  background: #f6f7fb;
  min-height: 100vh;
}

/* Mobile: you set min-height:auto earlier — override that */
@media (max-width: 768px) {
  .layout__content--messages {
    min-height: 100vh !important;
  }

  /* Optional: stops bottom nav covering the last item */
  .inbox {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
}


/* =========================================================
   FIX: Keep message composer pinned to bottom (above bottom nav)
   ========================================================= */
@media (max-width: 768px) {
  :root{
    /* match your bottom nav height (tweak if needed) */
    --ct-bottom-nav-h: 64px;
  }

  /* When a thread is open, prevent page scroll (messages will scroll instead) */
  body.messages-thread-open {
    overflow: hidden;
  }

  /* Make conversation panel fill the screen ABOVE the bottom nav */
  body.messages-thread-open #conversation-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;

    /* this ensures the input NEVER goes under the nav */
    bottom: calc(var(--ct-bottom-nav-h) + env(safe-area-inset-bottom));

    display: flex;
    flex-direction: column;

    padding: 16px;
    box-sizing: border-box;

    background: #f3f4fb;
    z-index: 50;
  }

  /* Messages area scrolls */
  body.messages-thread-open #conversation-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }

  /* Composer stays at bottom of the panel */
  body.messages-thread-open #conversation-form {
    flex-shrink: 0;
    background: #f3f4fb; /* prevents “see-through” while scrolling */
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    margin-top: 0;
  }
}
