/* ── 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; }

/* Wave 5: broadcast composer + history */
.ms-head .ms-btn { margin-left: 6px; }
.ms-bc-body { display: flex; flex-direction: column; gap: 12px; }
.ms-seg-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ms-seg { border: 1px solid var(--line, #d8ded9); background: var(--panel, #fff); color: inherit;
  border-radius: 999px; padding: 6px 13px; font-size: .8rem; font-weight: 600; cursor: pointer; }
.ms-seg.on { background: var(--brand-primary, #0F3327); border-color: var(--brand-primary, #0F3327); color: #fff; }
.ms-bc-field { display: flex; flex-direction: column; gap: 5px; }
.ms-bc-field > label { font-size: .74rem; font-weight: 700; color: var(--muted, #556); text-transform: uppercase; letter-spacing: .03em; }
.ms-bc-field select, .ms-bc-field input[type="search"], .ms-bc-field textarea {
  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; resize: vertical; }
.ms-picklist { border: 1px solid var(--line, #e2e6e2); border-radius: 10px; max-height: 260px; overflow-y: auto; background: var(--panel, #fff); }
.ms-pickrow { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-bottom: 1px solid var(--line, #eef1ee); cursor: pointer; font-size: .85rem; }
.ms-pickrow:last-child { border-bottom: 0; }
.ms-pickname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-pickph { font-size: .74rem; color: var(--muted, #667); flex: 0 0 auto; }
.ms-bc-hint { font-size: .78rem; color: var(--muted, #667); background: rgba(0, 0, 0, .04); border-radius: 8px; padding: 8px 11px; }
.ms-bc-hint code { font-family: ui-monospace, Menlo, monospace; font-size: .76rem; background: rgba(0, 0, 0, .06); padding: 0 3px; border-radius: 3px; }
.ms-bc-preview { font-size: .84rem; background: #e9f2ec; color: #14432e; border-radius: 8px; padding: 9px 12px; }
.ms-bc-preview .ms-bc-ex { color: #8c5a00; }
.ms-bc-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ms-bc-actions .ms-btn[disabled] { opacity: .5; cursor: default; }
.ms-rstatus { margin-left: auto; font-size: .7rem; font-weight: 700; border-radius: 5px; padding: 1px 7px; flex: 0 0 auto; }
.ms-rstatus.ms-rs-ok { background: #e2f0e8; color: #1e6f47; }
.ms-rstatus.ms-rs-ex { background: rgba(0, 0, 0, .07); color: var(--muted, #667); }
@media (prefers-color-scheme: dark) {
  .ms-bc-preview { background: rgba(46, 122, 78, .22); color: #b9e6cc; }
  .ms-rstatus.ms-rs-ok { background: rgba(46, 122, 78, .28); color: #b9e6cc; }
}

/* Wave 4: enable-notifications card */
.ms-notif { border: 1px solid var(--line, #e2e6e2); border-left: 3px solid var(--brand-accent, #a8853a);
  border-radius: 12px; background: var(--panel, #fff); padding: 12px 14px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 3px; }
.ms-notif b { font-size: .86rem; }
.ms-notif span { font-size: .78rem; color: var(--muted, #667); }
.ms-notif-a { display: flex; gap: 8px; margin-top: 8px; }

/* Per-person opt-in toggles under the compose bar (Web/SMS read-only, Verbal interactive). */
.ms-optin-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:8px 12px; border-top:1px solid #e5e7eb; font-size:12px; background:#fbfcfd; }
.ms-optin-lbl { color:#64748b; font-weight:700; letter-spacing:.02em; }
.ms-optin { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:999px; background:#eef1f4; color:#64748b; font-weight:600; border:1px solid transparent; }
.ms-optin.on { background:#e3f0ee; color:#0a554c; }
.ms-optin .ms-optin-sw { width:8px; height:8px; border-radius:50%; background:#cbd5e1; }
.ms-optin.on .ms-optin-sw { background:#0e6e63; }
.ms-optin-ro { font-size:10px; color:#94a3b8; font-weight:500; }
.ms-optin.ro { cursor:default; }
.ms-optin.act { cursor:pointer; border-color:#cbd5e1; }
.ms-optin.act:hover { border-color:#0e6e63; color:#0a554c; }
.ms-optin.act.on { border-color:#0e6e63; }
.ms-optin.act:focus-visible { outline:2px solid #0e6e63; outline-offset:2px; }
.ms-optin-msg { flex-basis:100%; font-size:11px; line-height:1.45; color:#64748b; margin-top:2px; }
.ms-optin-msg.ok { color:#0a554c; }
.ms-optin-msg.warn { color:#9a3412; }
