/* REQ-126: Messages. The colour tokens (:root) and shared components are in ../styles.css; this file never defines :root variables. */

.ms-list, .ms-thread { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.ms-list { padding: 8px; max-height: calc(100vh - 170px); overflow: auto; }
.ms-lede { margin: 6px 8px 10px; color: var(--mute); font-size: 13px; }
.ms-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ms-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; min-height: 56px; padding: 8px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.ms-row:hover { background: var(--sunken); }
.ms-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ms-row.on { background: var(--accent-soft); }
.ms-av { width: 40px; height: 40px; border-radius: 50%; background: var(--sunken); }
.ms-gav { display: grid; place-items: center; color: var(--accent); font-size: 18px; }
.ms-rt { display: grid; gap: 2px; min-width: 0; }
.ms-rtop { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.ms-rtop b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-when { color: var(--faint); font-size: 12px; flex: none; }
.ms-prev { color: var(--mute); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-row.unread .ms-prev { color: var(--ink); font-weight: 700; }
.ms-unread { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--needs); color: var(--on-needs, #fff); font: 700 12px/1 var(--font-mono); }
.ms-empty, .ms-none, .ms-ro { color: var(--mute); padding: 16px; margin: 0; }
/* REQ-121.3: 'Between agents', folded by default; two avatars per row, no unread dot. */
.ms-between { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
.ms-btoggle { width: 100%; min-height: 44px; display: flex; gap: 8px; align-items: center; justify-content: flex-start; text-align: left; }
.ms-bcount { margin-left: auto; color: var(--mute); font-size: 13px; font-weight: 400; }
.ms-pav { display: inline-flex; flex: none; }
.ms-pav .ms-av + .ms-av { margin-left: -12px; box-shadow: 0 0 0 2px var(--panel); }
.ms-prow { grid-template-columns: 52px 1fr; }
.ms-prow .ms-av.sm { width: 32px; height: 32px; }
.ms-thread { display: flex; flex-direction: column; min-height: 420px; max-height: calc(100vh - 170px); }
.ms-thead { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ms-who { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.ms-who h2 { margin: 0; font-size: 18px; }
.ms-who h2:focus { outline: none; }
.ms-role { color: var(--mute); font-size: 13px; }
.ms-thead .ms-back { display: none; }
.ms-sess, .ms-back { min-height: 44px; align-items: center; text-decoration: none; }
.ms-sess { display: inline-flex; }
.ms-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ms-msg { max-width: min(560px, 85%); align-self: flex-start; background: var(--sunken); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.ms-msg.mine { align-self: flex-end; background: var(--accent-soft); border-radius: 14px 14px 4px 14px; }
.ms-mmeta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--mute); }
.ms-mmeta b { color: var(--ink); }
.ms-mre { font-family: var(--font-mono); }
.ms-mtext { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ms-deliv { margin: 4px 0 0; font-size: 12px; color: var(--mute); text-align: right; }
/* REQ-138.1.2: a message that asks for a reply, until the reader answers. */
.ms-wait { display: inline-block; margin: 6px 0 0; padding: 3px 10px; border-radius: 999px; font: 700 12px/1.4 var(--font-body); color: var(--needs); background: var(--needs-soft); }
.ms-q { align-self: flex-start; width: min(620px, 100%); border: 1px solid var(--line); border-left: 4px solid var(--needs); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.ms-q.q-answered { border-left-color: var(--done); }
.ms-q.q-dropped { border-left-color: var(--idle); }
.ms-q.focus { box-shadow: 0 0 0 2px var(--accent); }
.ms-q { position: relative; transition: background-color .2s ease; }
/* REQ-143.1 (Pablo): an answered, dropped or self-closed card recedes: 45° stripes
   at 7% of the text colour behind the content, a word pill top right. */
.ms-q.ms-qclosed::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--ink) 7%, transparent) 0 6px, transparent 6px 14px); }
.ms-qclosed > * { position: relative; }
.ms-qpill { margin-left: auto; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 700; font-size: 12px; }
.ms-qclosed .ms-qtext { font-weight: 600; }
.ms-qsettled { color: var(--mute); }
@media (prefers-reduced-motion: reduce) { .ms-q { transition: none; } }
.ms-q:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-qtop { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--mute); }
.ms-qid { font-family: var(--font-mono); }
.ms-qst { display: inline-flex; gap: 4px; align-items: center; }
.ms-qst .ms-av.xs { width: 20px; height: 20px; }
.ms-qtext { margin: 6px 0; font-weight: 700; overflow-wrap: anywhere; }
.ms-qctx { margin: 0 0 6px; color: var(--mute); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ms-qnote { margin: 6px 0 0; font-size: 13px; }
.ms-qreply { min-height: 44px; margin-top: 8px; }
.ms-qreply[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
/* REQ-186.1: Later beside Reply, and when the put-off question reminds you. */
.ms-qlaterbtn { min-height: 44px; margin-top: 8px; margin-left: 8px; }
.ms-qlater { color: var(--accent); }
.ms-later { color: var(--accent); font-size: 12px; flex: none; }
.ms-comp { border-top: 1px solid var(--line); padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.ms-replying { grid-column: 1 / -1; margin: 0; display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--accent); }
.ms-ta { width: 100%; min-height: 44px; resize: vertical; font: 15px/1.4 var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-sizing: border-box; }
.ms-ta:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ms-send { min-height: 44px; }
.ms-hint { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }
.ms-err { grid-column: 1 / -1; margin: 0; }
.ms-new { display: flex; justify-content: center; align-items: center; min-height: 44px; margin: 0 8px 8px; text-decoration: none; }
.ms-new[hidden] { display: none; }
.ms-closedtag { font-size: 11px; color: var(--done); font-weight: 700; flex: none; }
.ms-av.sm { width: 24px; height: 24px; }
.ms-gmembers { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--mute); }
.ms-gmembers li { display: inline-flex; align-items: center; gap: 4px; }
.ms-grefs { margin: 4px 0 0; font-size: 13px; color: var(--mute); }
.ms-close { min-height: 44px; }
.ms-gform, .ms-cform { padding: 14px; display: grid; gap: 12px; }
.ms-cform { border-bottom: 1px solid var(--line); }
.ms-field { display: grid; gap: 4px; font-size: 13px; color: var(--mute); }
.ms-field input { min-height: 44px; font: 15px var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.ms-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ms-members { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; max-height: 320px; overflow: auto; }
.ms-members legend { font-size: 13px; color: var(--mute); padding: 0 4px; }
.ms-member { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.ms-member input { width: 20px; height: 20px; accent-color: var(--accent); }
.ms-gbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.ms-cancel { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.ms-closed { margin: 0; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--ink); background: var(--done-soft); border-radius: 0 0 14px 14px; }
.ms-closed i { color: var(--done); font-style: normal; font-weight: 700; }
@media (max-width: 759px) {
  .ms-grid { grid-template-columns: 1fr; }
  .ms-grid.open .ms-list { display: none; }
  .ms-grid:not(.open) .ms-thread { display: none; }
  .ms-thead .ms-back { display: inline-flex; }
  .ms-thead { flex-wrap: wrap; }
  .ms-list, .ms-thread { max-height: none; }
  .ms-thread { min-height: calc(100vh - 150px); }
  .ms-msg { max-width: 92%; }
  .ms-back { order: 1; }
  .ms-sess { order: 2; margin-left: auto; }
  .ms-who { order: 3; flex-basis: 100%; }
  .ms-tcycle { order: 2; margin-left: auto; }   /* REQ-191.2: next to ← Conversations, the name below */
  .ms-tcycle ~ .ms-sess { margin-left: 0; }
}   
/* REQ-110.4: the one Answer, a 44 px target */
/* REQ-92.4: a task card in a message (Pablo's note 7). */
.ms-task { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 6px; }
.ms-task.closed { border-color: color-mix(in srgb, var(--done) 45%, transparent); }
.ms-ttitle { overflow-wrap: anywhere; }
.ms-tline { margin: 0; font-size: 13px; color: var(--mute); }
.ms-tstate { color: var(--done); font-weight: 700; }
.ms-tbar { width: 100%; height: 8px; accent-color: var(--accent); }
.ms-topen { justify-self: start; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
/* REQ-145.2: a requirement-thread question in the asker's chat: its requirement, its state, an answer box. */
.ms-tq { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 6px; }
.ms-tq.q-answered { border-color: color-mix(in srgb, var(--done) 45%, transparent); }
.ms-tqline { margin: 0; font-size: 13px; color: var(--mute); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ms-tqline .chip { min-height: 32px; display: inline-flex; align-items: center; text-decoration: none; }
.q-answered .ms-tqst { color: var(--done); font-weight: 700; }
.ms-tqa { width: 100%; box-sizing: border-box; }
.ms-tqsend { justify-self: start; min-height: 44px; }
/* REQ-145.1: arriving from 'Open chat', the question's ring lasts 2 s (messagesView.js). */
.ms-q { transition: box-shadow .3s; }
@media (prefers-reduced-motion: reduce) { .ms-q { transition: none; } }
/* REQ-145.1: 'Open chat', from an agent's question anywhere (cards, office, My office) into its chat (openChat.js). */
.open-chat:not(.qitem) { font-weight: 600; white-space: nowrap; }
@media (pointer: coarse), (max-width: 759px) { .open-chat:not(.qitem) { display: inline-flex; align-items: center; min-height: 44px; } }
/* REQ-149.1.4: a member's privacy line above their chats. */
.ms-privacy { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: var(--sunken); color: var(--mute); font-size: 14px; }
/* REQ-149.1.6: Steven's Show filter (Mine, a person, Everyone). */
.ms-show { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; color: var(--mute); }
.ms-show select { min-height: 44px; flex: 1; min-width: 0; }
.ms-sep { list-style: none; margin: 12px 0 4px; padding: 0 4px; color: var(--mute); font-size: 13px; }
/* REQ-149.1.5: the empty state reads as a sentence, not a blank list. */
.ms-pempty { padding: 16px 10px; color: var(--mute); }

/* REQ-191.1: 'Answer questions' with the open count, opening the question cycle. */
.ms-cycle { margin-left: auto; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.ms-cycle[hidden] { display: none; }
.ms-cycle-n { min-width: 24px; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font: 700 13px/24px var(--font-mono); text-align: center; }
@media (max-width: 600px) { .ms-cycle { margin-left: 0; } }
/* REQ-191.2: 'Cycle through N' in an agent's chat header. */
.ms-tcycle { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
