/* Messages: Crew chat, DMs, groups, announcements, polls, photos, reactions. Fits half a laptop screen. */
.msg-split { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; height: calc(100vh - 150px); min-height: 480px; }
.msg-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg-pane { display: flex; flex-direction: column; min-width: 0; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.msg-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .msg-row:hover { background: var(--fill-pressed); }
}
.msg-row.selected { border-color: var(--navy); background: var(--badge-info-bg); }
.msg-ico { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--badge-info-bg); display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--navy); }
.msg-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-row-top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.msg-row-top strong { flex: 0 1 auto; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row-top .caption { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row-time { margin-left: auto; flex: none; }
.msg-row-line { display: flex; gap: 6px; align-items: center; min-width: 0; }
.msg-row-text { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row.unread .msg-row-text { color: var(--text); font-weight: 600; }
.msg-count, #msg-badge { background: var(--navy); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.msg-note { margin: 8px 4px; }
.msg-announce { background: var(--accent-tint); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.msg-announce-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; color: var(--accent-text); }
.msg-announce-body { margin: 4px 0; font-size: 15px; }
.msg-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.msg-head .caption { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg-item { max-width: 82%; }
.msg-bubble-row { display: flex; align-items: flex-start; gap: 4px; }
.chat-msg.mine .msg-bubble-row { flex-direction: row-reverse; }
.msg-item .bubble.wide { width: 320px; max-width: 100%; }
.msg-react-btn { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px; }
.msg-item:hover .msg-react-btn, .msg-react-btn:focus { opacity: 1; }
.msg-react-bar { display: inline-flex; flex-wrap: wrap; max-width: 100%; justify-content: center; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 2px 6px; margin-top: 4px; }
.msg-react-bar button { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 2px 4px; }
.msg-reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chat-msg.mine .msg-reactions { justify-content: flex-end; }
.msg-rx { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 1px 8px; font-size: 13px; cursor: pointer; }
.msg-rx.mine { border-color: var(--navy); background: var(--badge-info-bg); }
.msg-seen { margin-top: 2px; }
.msg-photo { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin: 4px 0; }
.msg-mention { font-weight: 700; color: var(--link); }
.chat-msg.mine .msg-mention { color: #cfe0ff; }
.msg-share { display: flex; align-items: center; gap: 10px; margin: 4px 0; padding: 8px 10px; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; text-align: left; }
.msg-share span { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-poll { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; color: var(--text); }
.chat-msg.mine .bubble .msg-poll { color: #fff; }
.msg-poll-opt { position: relative; overflow: hidden; display: flex; flex-direction: column; text-align: left; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 10px; padding: 6px 10px; cursor: pointer; font: inherit; }
.msg-poll-opt.yours { border-color: var(--navy); border-width: 2px; }
.msg-poll-opt:disabled { cursor: default; }
.msg-poll-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--badge-info-bg); }
.msg-poll-row, .msg-poll-voters { position: relative; display: flex; justify-content: space-between; gap: 8px; }
.msg-poll-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-msg.mine .msg-poll-foot .caption { color: #dfe6f1; }
.chat-msg.mine .msg-poll-foot .link-btn { color: #fff; text-decoration: underline; }
.msg-composer-wrap { position: relative; border-top: 1px solid var(--border); padding: 10px 16px 0; }
.msg-composer { flex-direction: column; align-items: stretch; margin-top: 0; }
.msg-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-tools .btn { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.msg-compose-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-compose-row textarea, .msg-compose-row input { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); min-width: 0; }
.msg-suggest { position: absolute; bottom: 100%; left: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 4px; display: flex; flex-direction: column; z-index: 5; }
.msg-suggest[hidden] { display: none; }
.msg-suggest button { border: 0; background: none; text-align: left; padding: 8px 12px; font: inherit; cursor: pointer; border-radius: 8px; }
.msg-suggest button:hover { background: var(--fill); }
.msg-modal { max-width: 520px; }
.msg-pick { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.msg-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.msg-pick-row > span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.msg-pick-row.check input { width: 18px; height: 18px; }
.msg-poll-inputs { display: flex; flex-direction: column; gap: 6px; }
.msg-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
/* Half a laptop screen: keep list and thread side by side, just tighter. Phones stack. */
@media (max-width: 980px) { .msg-split { grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); gap: 10px; } .msg-item { max-width: 92%; } .msg-row-top .caption { display: none; } }

/* Keyboard inset for the chat composer and message split. */
.msg-composer-wrap { padding-bottom: calc(12px + var(--kb-inset, 0px)); }
.msg-split { height: calc(100vh - 150px - var(--kb-inset, 0px)); }
.msg-back { display: none; }

/* Phone: same 599px single-column breakpoint as Calls (.split).
   600-999 stays side-by-side (tighter from the 980px rule). Never stack
   the thread list above the chat. */
@media (max-width: 599px) {
  .top-actions { flex-wrap: wrap; max-width: 100%; }
  .msg-tools { flex-wrap: wrap; }
  .msg-split {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .msg-split:not(.has-selection) .msg-pane { display: none; }
  .msg-split.has-selection .msg-list { display: none; }
  .msg-split.has-selection .msg-pane {
    display: flex;
    min-height: calc(100dvh - 180px - var(--kb-inset, 0px));
    height: auto;
  }
  .msg-head { flex-wrap: wrap; align-items: center; }
  .msg-back {
    display: inline-block;
    flex: 1 0 100%;
    margin: 0 0 4px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
  }
}

