/* ── Messages surface (Dialer Wave 2) ─────────────────────────────────────────
   Messenger-style inbox + thread inside #panel-messages. Uses the app's shared
   tokens (falls back gracefully); mobile-first and vertically compact per the
   mobile rules; desktop gets more breathing room via the same layout. */
#panel-messages .ms2 { max-width: 860px; margin: 0 auto; padding: 10px 12px 84px; }

.ms-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.ms-head h2 { margin: 0; font-size: 1.15rem; }
.ms-btn { border: 1px solid var(--line, #d8ded9); background: var(--panel, #fff); color: inherit;
  border-radius: 9px; padding: 7px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.ms-btn.gold { background: var(--brand-accent, #a8853a); border-color: var(--brand-accent, #a8853a); color: #fff; }

.ms-list { border: 1px solid var(--line, #e2e6e2); border-radius: 12px; overflow: hidden; background: var(--panel, #fff); }
.ms-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line, #eef1ee); }
.ms-row:last-child { border-bottom: 0; }
.ms-row:hover { background: rgba(0, 0, 0, .03); }
.ms-ava { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: .85rem; color: #fff; background: var(--brand-primary, #0F3327); }
.ms-main { min-width: 0; flex: 1; }
.ms-top { display: flex; align-items: center; gap: 6px; }
.ms-top b { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-when { margin-left: auto; font-size: .7rem; color: var(--muted, #667); flex: 0 0 auto; }
.ms-prev { font-size: .78rem; color: var(--muted, #667); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ms-line { font-size: .68rem; color: var(--muted, #889); margin-top: 1px; }
.ms-row.unread b { font-weight: 800; }
.ms-row.unread .ms-prev { color: inherit; font-weight: 600; }
.ms-badge { background: var(--brand-accent, #a8853a); color: #fff; border-radius: 999px; font-size: .68rem;
  font-weight: 700; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.ms-chip { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border-radius: 5px; padding: 1px 5px; background: rgba(0, 0, 0, .07); color: var(--muted, #556); }
.ms-chip.stop { background: #f6e3e0; color: #8c2f24; }
.ms-empty { padding: 26px 16px; text-align: center; color: var(--muted, #667); font-size: .84rem; }

/* thread */
.ms-thread-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 10px; }
.ms-back { border: 0; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 2px 8px; color: inherit; }
.ms-th-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.ms-th-main b { font-size: .95rem; }
.ms-th-main span { font-size: .72rem; color: var(--muted, #667); }
.ms-call { flex: 0 0 auto; }
.ms-stopbar { background: #f6e3e0; color: #8c2f24; font-size: .76rem; border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.ms-scroll { border: 1px solid var(--line, #e2e6e2); border-radius: 12px; background: var(--panel, #fff);
  height: min(58vh, 560px); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.ms-bub { max-width: 78%; border-radius: 14px; padding: 7px 11px; font-size: .86rem; line-height: 1.35; }
.ms-bub.them { align-self: flex-start; background: rgba(0, 0, 0, .06); border-bottom-left-radius: 4px; }
.ms-bub.me { align-self: flex-end; background: var(--brand-primary, #0F3327); color: #fff; border-bottom-right-radius: 4px; }
.ms-txt { white-space: pre-wrap; word-break: break-word; }
.ms-meta { font-size: .64rem; opacity: .65; margin-top: 2px; text-align: right; }
.ms-tick.ok { color: #7fd6a3; }
.ms-tick.bad { color: #e4a19a; font-weight: 800; }
.ms-compose { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.ms-compose textarea { flex: 1; resize: none; border: 1px solid var(--line, #d8ded9); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: .88rem; min-height: 40px; max-height: 120px; background: var(--panel, #fff); color: inherit; }
.ms-search { margin-bottom: 8px; }
.ms-search input { width: 100%; border: 1px solid var(--line, #d8ded9); border-radius: 10px; padding: 9px 11px;
  font: inherit; font-size: .88rem; background: var(--panel, #fff); color: inherit; }

@media (max-width: 620px) {
  #panel-messages .ms2 { padding: 8px 8px 90px; }
  .ms-scroll { height: calc(100dvh - 320px); min-height: 260px; }
  .ms-bub { max-width: 86%; }
}

/* Wave 3: call events in the thread + the in-call screen */
.ms-call-ev { align-self: center; text-align: center; font-size: .74rem; color: var(--muted, #667);
  background: rgba(0, 0, 0, .045); border-radius: 999px; padding: 4px 12px; margin: 2px 0; }
.ms-call-ev audio { display: block; width: 230px; height: 32px; margin: 6px auto 2px; }
.ec-wrap { position: fixed; inset: 0; z-index: 9000; background: rgba(10, 20, 15, .55); display: flex;
  align-items: center; justify-content: center; }
.ec-card { background: var(--brand-primary, #0F3327); color: #fff; border-radius: 18px; padding: 28px 30px;
  width: min(320px, 88vw); text-align: center; box-shadow: 0 18px 50px rgba(0, 0, 0, .4); }
.ec-name { font-size: 1.2rem; font-weight: 700; }
.ec-sub { font-size: .8rem; opacity: .75; margin-top: 2px; }
.ec-state { font-size: .9rem; margin: 14px 0 18px; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.ec-actions { display: flex; gap: 10px; justify-content: center; }
.ec-btn { border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: .85rem; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; }
.ec-btn.on { background: rgba(255, 255, 255, .38); }
.ec-btn.end { background: #b3362a; }
.ec-btn.ok { background: #1e7a4e; }
.ec-banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9000;
  background: var(--brand-primary, #0F3327); color: #fff; border-radius: 14px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 34px rgba(0, 0, 0, .35); max-width: 94vw; }
.ec-b-main { display: flex; flex-direction: column; }
.ec-b-main b { font-size: .82rem; }
.ec-b-main span { font-size: .78rem; opacity: .85; }
