/* =========================================================
   Accord — Messages page (messages.html)
   Uses base.css + home.css (top bar, account menu, windows, form fields).
   ========================================================= */

.msg-pagetitle {
  font-family: var(--font-display); font-size: 20px; letter-spacing: -0.3px;
  flex: 1 1 auto; padding-left: 8px; border-left: 1px solid var(--line); margin-left: 4px;
}

/* ---------- Signed-out card ---------- */
.msg-gate { padding-top: 64px; padding-bottom: 64px; }
.msg-gate__card {
  max-width: 460px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 36px 28px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.msg-gate__card h2 { font-family: var(--font-display); font-size: 24px; }
.msg-gate__card p { color: var(--body); }

/* ---------- Two-pane layout ---------- */
.inbox {
  display: flex; gap: 20px; padding-top: 20px; padding-bottom: 20px;
  height: calc(100vh - 73px); min-height: 520px;
}
.threads {
  flex: 0 0 340px; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.threads__title {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted);
  padding: 16px 18px 10px;
}
.threads__list { overflow-y: auto; flex: 1; }
.threads__empty { padding: 18px; font-size: 14px; color: var(--muted); line-height: 1.6; }
.threads__empty a { font-weight: 700; }

.thread {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  display: grid; grid-template-columns: 40px 1fr auto; gap: 4px 12px; align-items: center;
  padding: 14px 18px; border-top: 1px solid #F0EFED;
}
.thread:hover { background: #FAFAF9; }
.thread[aria-current="true"] { background: var(--primary-soft); }
.thread__avatar {
  grid-row: span 2; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text); font-weight: 800; font-size: 13px;
}
.thread[aria-current="true"] .thread__avatar { background: var(--primary); color: #FFFFFF; }
.thread__name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread__time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.thread__line { grid-column: 2 / 4; display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread__last { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.thread__post { grid-column: 2 / 4; font-size: 12px; color: var(--primary-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread--unread .thread__name, .thread--unread .thread__last { color: var(--ink); font-weight: 800; }
.unread-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--coral); flex: none; }
.thread__badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); white-space: nowrap; }
.thread__badge--deal { background: var(--primary); color: #FFFFFF; }

/* ---------- Chat pane ---------- */
.chat {
  flex: 1 1 auto; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.chat__placeholder {
  margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--muted); padding: 24px;
}
.chat__placeholder strong { color: var(--ink); font-family: var(--font-display); font-size: 18px; }
.chat__placeholder a { font-weight: 700; }
.chat__inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat__head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.chat__back {
  display: none; width: 40px; height: 40px; border-radius: 999px; border: 0; background: #F5F5F4;
  place-items: center; cursor: pointer; flex: none;
}
.chat__who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat__who strong { font-size: 16px; }
.chat__who a { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Deal bar ---------- */
.dealbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 18px; background: #FAFAF9; border-bottom: 1px solid var(--line); font-size: 14px;
}
.dealbar__text { flex: 999 1 260px; line-height: 1.5; }
.dealbar__text strong { font-family: var(--font-display); }
.dealbar__note { display: block; color: var(--muted); font-size: 13px; }
.dealbar__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dealbar .btn { min-height: 42px; font-size: 14px; }
.dealbar--pending { background: var(--coral-soft); border-bottom-color: var(--coral-line); }
.dealbar--agreed { background: var(--primary-soft); border-bottom-color: #BFE0DB; }

/* ---------- Messages ---------- */
.chat__messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.chat__start { text-align: center; font-size: 13px; color: var(--muted); padding: 8px 0 4px; }
.day { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: #EFEDE8; }

.msg { max-width: min(78%, 520px); display: flex; flex-direction: column; gap: 3px; }
.msg__bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg__time { font-size: 11px; color: var(--muted); padding: 0 6px; }
.msg--theirs { align-self: flex-start; }
.msg--theirs .msg__bubble { background: #FFFFFF; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg--mine { align-self: flex-end; align-items: flex-end; }
.msg--mine .msg__bubble { background: var(--primary); color: #FFFFFF; border-bottom-right-radius: 4px; }

.msg__offer {
  background: #FFFFFF; border: 2px solid var(--coral); border-radius: 16px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 4px; min-width: 200px;
}
.msg__offer-label { font-size: 11px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--coral-text); }
.msg__offer-amount { font-family: var(--font-display); font-size: 22px; color: var(--ink); }
.msg__offer-note { font-size: 14px; color: var(--body); }

.msg-system {
  align-self: center; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-text);
}
.msg-system--decline { background: #F5F5F4; color: var(--muted); }

/* ---------- Offer form + composer ---------- */
.offer-form .money { min-height: 44px; }
.money input { flex: 1; min-width: 0; }
.msg-system--delivered { background: #FEF3C7; color: #92400E; }
.dealbar__review { display: inline-flex; gap: 2px; color: #F59E0B; font-size: 15px; letter-spacing: 1px; }
.dealbar__code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 700; }
.dealbar--protected { background: var(--primary); border-bottom-color: var(--primary); color: #FFFFFF; }
.dealbar--protected .dealbar__note { color: #D1FAF5; }
.dealbar--protected .btn-outline { color: #FFFFFF; border-color: rgba(255,255,255,.55); }
.dealbar--protected .btn-outline:hover { background: #FFFFFF; color: var(--primary-text); }
.dealbar--protected .btn-primary { background: #FFFFFF; color: var(--primary-text); border-color: #FFFFFF; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.dealbar--protected .btn-primary:hover { background: #F0FDFA; }
.msg-system--bbscrow { background: var(--ink); color: #FFFFFF; }
.offer-form {
  border-top: 1px solid var(--coral-line); background: var(--coral-soft); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.offer-form__row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(200px, 2fr); gap: 12px; }
.offer-form .field input { min-height: 44px; }
.offer-form__actions { display: flex; justify-content: flex-end; gap: 8px; }
.offer-form__actions .btn { min-height: 42px; font-size: 14px; }

.composer-bar { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: #FFFFFF; }
.composer-bar input {
  flex: 1; min-width: 0; min-height: 46px; padding: 0 16px; border: 1.5px solid var(--line-2); border-radius: 999px;
  font-size: 15px;
}
.composer-bar input:focus { outline: none; border-color: var(--primary); }
.composer-bar .btn { min-height: 46px; font-size: 14px; }

/* ---------- Header messages link (feed page) ---------- */
.msgs-link { position: relative; }
.msgs-link__dot {
  position: absolute; top: 6px; right: 8px; width: 10px; height: 10px; border-radius: 999px;
  background: var(--coral); border: 2px solid #FFFFFF;
}

/* =========================================================
   Phones: one pane at a time
   ========================================================= */
/* Back arrow to the feed: phones only (computers have "Back to feed") */
.msg-home-back {
  display: none; width: 42px; height: 42px; flex: none; border-radius: 999px; place-items: center;
  color: var(--ink); background: #F5F5F4;
}
.msg-home-back:hover { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 860px) {
  /* Phones: ←  Messages ............ (profile picture) */
  .messages-page .appbar__inner { flex-wrap: nowrap; gap: 10px; }
  .messages-page .msg-home-back { display: grid; order: 0; }
  .messages-page .appbar .logo { display: none; }
  .messages-page .msg-pagetitle { order: 1; flex: 1 1 auto; border-left: 0; padding-left: 0; margin-left: 0; font-size: 20px; }
  .messages-page .appbar__actions { order: 2; margin-left: auto; }
  .msg-pagetitle { font-size: 17px; }
  .appbar__actions .appbar__post { display: none; }
  .inbox { padding: 0; height: calc(100vh - 69px); gap: 0; }
  .threads, .chat { border-radius: 0; border-left: 0; border-right: 0; }
  .threads { flex-basis: 100%; }
  .chat { display: none; }
  .inbox--chat-open .threads { display: none; }
  .inbox--chat-open .chat { display: flex; flex-basis: 100%; }
  .chat__back { display: grid; }
  .chat__head { padding: 10px 12px; }
  .chat__head .tag { display: none; }
  .msg { max-width: 86%; }
  .offer-form__row { grid-template-columns: 1fr; }
  .composer-bar__offer { padding: 0 12px; }
}

/* ---------- Safety ---------- */
.chat__report {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #FFFFFF; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; flex: none;
}
.chat__report:hover { color: #B42318; border-color: #F3C3BD; background: #FEF3F2; }
.chat__blocked { margin: 10px 14px; }
.msg__warn {
  max-width: 100%; font-size: 13px; line-height: 1.5; padding: 8px 12px; border-radius: 12px;
  background: #FFFAEB; border: 1px solid #FEDF89; color: #7A2E0E;
}
.msg__warn-report { border: 0; background: none; padding: 0; color: #B42318; font-weight: 800; text-decoration: underline; cursor: pointer; }
@media (max-width: 860px) {
  .chat__report span { display: none; }
  .chat__report { padding: 0; width: 40px; justify-content: center; }
}

.chat__name { font-size: 16px; font-weight: 700; color: var(--ink); }
.chat__name:hover { color: var(--primary); text-decoration: underline; }

/* ---------- Pay in parts (offer form + deal bar) ---------- */
.plan { border-top: 1px dashed var(--coral-line); padding-top: 10px; }
.plan__switch { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; line-height: 1.4; }
.plan__switch input { flex: none; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--primary); }
.plan__switch small { display: block; color: var(--muted); font-size: 12.5px; }
.plan__body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.plan__rows { display: flex; flex-direction: column; gap: 6px; }
.plan__row { display: grid; grid-template-columns: 22px minmax(0, 1.6fr) minmax(84px, .8fr) minmax(120px, 1fr) 30px; gap: 6px; align-items: center; }
.plan__n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; }
.plan__row input { min-height: 38px; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 0 9px; font: inherit; font-size: 14px; background: #fff; min-width: 0; }
.plan__row input:focus { outline: none; border-color: var(--primary); }
.plan__row input:disabled { background: #F2F0EC; color: var(--muted); }
.plan__usd { position: relative; }
.plan__usd::before { content: "$"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-weight: 800; font-size: 14px; }
.plan__usd input { width: 100%; padding-left: 20px; font-weight: 700; }
.plan__x { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.plan__x:hover { background: #F2F0EC; color: var(--ink); }
.plan__x:disabled { visibility: hidden; }
.plan__foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.plan__add { min-height: 34px; font-size: 13px; padding: 0 12px; }
.plan__total { font-weight: 800; font-size: 14px; }
.plan__fine { margin: 0; font-size: 12px; color: var(--muted); }
.offer-form .money input:read-only { color: var(--muted); }
@media (max-width: 640px) {
  .plan__row { grid-template-columns: 22px minmax(0, 1fr) 90px 30px; }
  .plan__row .plan__due { grid-row: 2; grid-column: 2 / 4; }
  .plan__row .plan__x { grid-row: 1; grid-column: 4; }
}

.dealbar__parts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 0; list-style: none; }
.dealbar__parts li { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(0,0,0,.05); color: var(--muted); }
.dealbar__parts li::before { content: "○"; }
.dealbar__parts li.is-paid { background: var(--primary-soft); color: var(--primary-text); }
.dealbar__parts li.is-paid::before { content: "✓"; }
.dealbar__parts li.is-active, .dealbar__parts li.is-next { background: #FFF1E8; color: #B4471B; }
.dealbar__parts li.is-active::before, .dealbar__parts li.is-next::before { content: "●"; }
.dealbar__parts li.is-dropped { text-decoration: line-through; opacity: .6; }
.dealbar__parts li.is-refunded::before { content: "↩"; }
.dealbar--protected .dealbar__parts li { background: rgba(255,255,255,.16); color: #fff; }
.dealbar--protected .dealbar__parts li.is-paid { background: rgba(255,255,255,.28); }
.dealbar .btn-link { background: none; border: 0; padding: 0 4px; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: underline; cursor: pointer; }
.dealbar--protected .btn-link { color: #D1FAF5; }

.msg__parts { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.msg__parts li { display: flex; justify-content: space-between; gap: 12px; }
.msg__parts li span { color: var(--muted); }
.msg__parts li b { font-variant-numeric: tabular-nums; }
.msg-system--plan { background: #F5F5F4; color: var(--muted); }