/* ---------- Messages (messages.js; Rohan, 9 Oct 2026: "the same as WhatsApp",
   and "I want it to look right on phone too") ----------
   A wider window: the conversations on the left, the open one on the right,
   each scrolling on its own. A phone: the list, and a tap opens the
   conversation full screen with the top bar's back arrow (mobile.js); the
   bottom bar steps aside there so the box to write in sits at the foot.
   Colours are the app's own tokens, so light mode needs nothing here. */

.msg-app {
  display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 18px;
  height: min(76vh, 860px); margin-top: 14px;
}
.msg-side, .msg-thread {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  color: var(--band-text); background: var(--tile-face); border: var(--tile-edge);
  border-radius: 18px; box-shadow: var(--row-shadow);
}
.msg-problem {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn);
}

/* the list */
.msg-tools { display: grid; gap: 10px; padding: 12px; border-bottom: 1px solid var(--hair); }
.msg-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.msg-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-chip {
  min-height: 32px; padding: 0 12px; border: 1px solid var(--quiet-line); border-radius: 999px;
  background: none; color: var(--band-text2); font: 500 13px/1 var(--font); cursor: pointer;
}
.msg-chip[aria-pressed="true"] { background: var(--acc-dim); border-color: var(--acc-line); color: var(--acc-text); }
.msg-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#msg-line { width: auto; min-height: 32px; padding: 4px 30px 4px 10px; font-size: 13px; }
#msg-refresh { margin-left: auto; }
.msg-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.msg-list > .hint { padding: 12px; }

.msg-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 10px; border-radius: 12px; color: var(--band-text); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.msg-row + .msg-row { margin-top: 2px; }
.msg-row:hover { background: color-mix(in srgb, var(--band-text) 5%, transparent); }
.msg-row.is-open { background: var(--acc-dim); }
.msg-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.msg-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--acc-text);
  font: 600 15px/1 var(--font); letter-spacing: .02em;
}
.msg-avatar-none { background: color-mix(in srgb, var(--band-text) 10%, transparent); color: var(--band-text2); }
.msg-row-main { display: grid; gap: 3px; min-width: 0; }
.msg-row-top, .msg-row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.msg-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 15.5px/1.3 var(--font-head); }
.msg-row-when { flex: none; font-size: 12px; color: var(--band-text2); }
.msg-row-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--band-text2); }
.msg-row.is-waiting .msg-row-name { font-weight: 700; }
.msg-row.is-waiting .msg-row-when { color: var(--acc-text); font-weight: 600; }
.msg-row.is-waiting .msg-row-text { color: var(--band-text); }
.msg-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.msg-tag { flex: none; padding: 2px 8px; border-radius: 999px; font: 600 11px/1.4 var(--font); background: color-mix(in srgb, var(--band-text) 10%, transparent); color: var(--band-text2); }
.msg-lines { display: flex; gap: 4px; }
.msg-line { padding: 2px 6px; border-radius: 6px; font: 600 10.5px/1.3 var(--font); letter-spacing: .06em; }
.msg-line-3001 { background: color-mix(in srgb, var(--mint) 16%, transparent); color: var(--alt-text); }
.msg-line-3030 { background: var(--acc-dim); color: var(--acc-text); }

/* the open conversation */
.msg-empty { margin: auto; padding: 30px; text-align: center; color: var(--band-text2); }
.msg-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--hair); }
.msg-head-main { flex: 1; min-width: 0; }
.msg-head-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 18px/1.25 var(--font-head); }
.msg-head-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--band-text2); }
.msg-head-link { color: var(--acc-text); }
.msg-call { flex: none; }

.msg-bubbles { display: flex; flex: 1; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; }
.msg-day { align-self: center; margin: 10px 0 4px; font-size: 12px; color: var(--band-text2); }
.msg-day span { padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--band-text) 9%, transparent); }
.msg-bubble { max-width: min(78%, 520px); padding: 8px 12px 6px; border-radius: 16px; }
.msg-in { align-self: flex-start; border-bottom-left-radius: 6px; background: color-mix(in srgb, var(--band-text) 9%, transparent); }
.msg-out { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--bubble-me-bg); color: var(--bubble-me-text); }
.msg-failed { box-shadow: 0 0 0 1px var(--bad); }
.msg-body { font-size: 15px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { margin-top: 2px; font-size: 11px; text-align: right; opacity: .72; }

/* opted out: Call and Email in place of the text box */
.msg-notexts { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--hair); background: var(--tile-face); }
.msg-notexts p { margin: 0; font-size: 14px; color: var(--band-text2); }
.msg-notexts-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* writing a text */
.msg-compose { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--hair); background: var(--tile-face); }
.msg-rules { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--band-text2); }
.msg-rules-t { font: 600 10.5px/1.4 var(--font); letter-spacing: .14em; text-transform: uppercase; }
.msg-rule::before { content: "·"; margin-right: 6px; color: var(--acc-text); }
.msg-warn:empty { display: none; }
.msg-warn p { margin: 0; font-size: 13px; color: var(--bad); }
.msg-compose-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-text { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
.msg-send { flex: none; min-height: 44px; }
.msg-compose-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; font-size: 12px; color: var(--band-text2); }
.msg-from { width: auto; min-height: 30px; padding: 2px 28px 2px 8px; font-size: 13px; }
.msg-off { margin: 0; font-size: 12px; color: var(--warn); }

/* a phone: the list, or one conversation full screen */
@media (max-width: 760px) {
  .msg-app { display: block; height: auto; margin-top: 10px; }
  .msg-side, .msg-thread { overflow: visible; border-radius: 16px; }
  .msg-list { overflow: visible; }
  .msg-filters { flex: 1 1 100%; }
  body[data-msg="list"] .msg-thread { display: none; }
  body[data-msg="thread"] :is(#view-messages > h2, #view-messages > .hint, #view-messages > .m-fold-btn, .msg-side) { display: none; }
  body[data-msg="thread"] .msg-app { margin-top: 0; }
  .msg-bubbles { overflow: visible; padding: 12px 12px 8px; }
  .msg-bubble { max-width: 85%; }
  .msg-head { padding: 12px; }
  .msg-compose { position: sticky; bottom: 0; z-index: 5; padding-bottom: calc(12px + env(safe-area-inset-bottom)); border-radius: 0 0 16px 16px; }
  .msg-notexts { border-radius: 0 0 16px 16px; }
  /* in a conversation the bottom bar steps aside, as in WhatsApp */
  body[data-msg="thread"] .mnav { display: none; }
  body[data-msg="thread"] main { padding-bottom: 12px; }
}

/* the 3030 line connected but empty: bring in its past texts once */
.msg-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 14px; background: var(--acc-dim); color: var(--acc-text); }
.msg-offer-note { flex: 1 1 240px; }
