/* ------------------------------------------- team messaging (LinkedIn-style dock) */
.messaging {
  position: fixed; right: 16px; bottom: 0;
  z-index: 1040;
  display: flex; align-items: flex-end; gap: 10px;
  pointer-events: none;
}
.messaging > *, .msg-windows > * { pointer-events: auto; }
.msg-windows { display: flex; align-items: flex-end; gap: 10px; flex-direction: row-reverse; }

.dock, .chat-win {
  background: var(--raised);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex; flex-direction: column;
}
[data-theme='dark'] .dock, [data-theme='dark'] .chat-win { background: #15161a; }
.dock { width: 300px; }
.dock.open { height: min(520px, calc(100vh - 80px)); }
.dock-head, .win-head {
  height: 48px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 10px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.dock.open .dock-head, .chat-win:not(.min) .win-head { border-bottom-color: var(--divider); }
.dock-head:hover, .win-head:hover { background: var(--hover); }
.dock-title { flex: 1; font-weight: 600; font-size: var(--text-md); color: var(--text-strong); }
.dock-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dock-sub { display: flex; align-items: center; gap: 6px; padding: 8px 10px 0; font-weight: 600; font-size: var(--text-sm); color: var(--text-strong); }
.dock-search { position: relative; margin: 8px 10px; }
.dock-search svg { position: absolute; left: 9px; top: 9px; color: var(--text-faint); }
.dock-search input {
  width: 100%; height: 30px; padding: 0 10px 0 28px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text-strong); font-size: var(--text-sm);
  user-select: text;
}
.dock-search input:focus { border-color: var(--accent-line); box-shadow: var(--focus-ring); }
.dock-list { flex: 1; min-height: 0; overflow: auto; padding: 0 4px 6px; }
.dock-empty { padding: 20px 14px; text-align: center; font-size: var(--text-sm); color: var(--text-muted); line-height: 1.5; }

.conv-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border: 0; background: none; border-radius: var(--r-md);
  text-align: left; color: var(--text);
}
.conv-row:hover { background: var(--hover); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-title { flex: 1; min-width: 0; font-size: var(--text-md); font-weight: 500; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: var(--text-2xs); color: var(--text-faint); flex: none; }
.conv-preview { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.conv-preview > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.conv-row.unread .conv-title, .conv-row.unread .conv-preview { color: var(--text-strong); font-weight: 600; }
.conv-chan { display: inline-grid; place-items: center; border-radius: 9px; color: #fff; flex: none; }
.unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
}
.live-pill { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); font-weight: 600; font-size: 10px; flex: none; }
.presence-wrap { position: relative; display: inline-flex; flex: none; }
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--raised); }
[data-theme='dark'] .presence-dot { box-shadow: 0 0 0 2px #15161a; }

/* conversation windows */
.chat-win { width: 340px; height: min(480px, calc(100vh - 80px)); }
.chat-win.min { height: 48px; }
.chat-win.in-call { border-color: color-mix(in srgb, var(--success) 50%, var(--border)); }
.win-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.win-title b { font-size: var(--text-md); font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-title small { font-size: var(--text-2xs); color: var(--text-faint); }
.win-tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--divider); flex: none; }
.win-tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border: 0; background: none;
  font-size: var(--text-sm); font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.win-tabs button:hover { color: var(--text-strong); }
.win-tabs button.on { color: var(--text-strong); border-bottom-color: var(--accent); }
.tab-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--active); font-size: 10px; color: var(--text-muted); }
.win-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.win-scroll { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; user-select: text; }
.win-empty { padding: 28px 12px; text-align: center; color: var(--text-faint); font-size: var(--text-sm); line-height: 1.5; }

.msg-row { display: flex; gap: 8px; padding-top: 10px; }
.msg-row.grouped { padding-top: 2px; }
.msg-gutter { width: 28px; flex: none; }
.msg-col { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 6px; font-size: var(--text-xs); color: var(--text-faint); margin-bottom: 1px; }
.msg-meta b { color: var(--text-strong); font-weight: 600; font-size: var(--text-sm); }
.via-ai { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); padding: 0 5px; border-radius: 999px; }
.msg-text { font-size: var(--text-md); color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg-system { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 12px 0 4px; font-size: var(--text-2xs); color: var(--text-faint); }

.win-composer { flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px 10px 12px; border-top: 1px solid var(--divider); }
.win-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--input-bg); color: var(--text-strong); padding: 7px 10px;
  font-size: var(--text-md); line-height: 1.4; max-height: 120px; outline: none; user-select: text;
}
.win-composer textarea:focus { border-color: var(--accent-line); box-shadow: var(--focus-ring); }

/* transcript tab */
.transcript { padding-top: 6px; }
.tr-call { margin-bottom: 12px; }
.tr-head { position: sticky; top: -6px; display: flex; align-items: center; gap: 5px; padding: 6px 0; font-size: var(--text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); background: var(--raised); z-index: 1; }
.tr-line { padding: 5px 0 5px 10px; border-left: 2px solid var(--border); margin-bottom: 4px; }
.tr-line.live { border-left-color: var(--success); }
.tr-line.live p { color: var(--text-muted); }
.tr-who { font-size: var(--text-xs); font-weight: 600; color: var(--text-strong); margin-right: 6px; }
.tr-time { font-size: var(--text-2xs); color: var(--text-faint); }
.tr-line p { margin: 2px 0 0; font-size: var(--text-md); color: var(--text); line-height: 1.45; }

/* calls */
.call-strip { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--success) 9%, transparent); border-bottom: 1px solid var(--divider); }
.call-people { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; }
.call-face { position: relative; border-radius: 50%; display: inline-flex; transition: box-shadow var(--fast); }
.call-face.speaking { box-shadow: 0 0 0 2px var(--success), 0 0 0 5px color-mix(in srgb, var(--success) 25%, transparent); }
.muted-dot { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; display: grid; place-items: center; background: var(--danger); color: #fff; }
.call-time { margin-left: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.call-actions { display: flex; gap: 4px; }
.call-btn { width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--active); color: var(--text); }
.call-btn:hover { background: var(--border-strong); }
.call-btn.off { background: var(--danger); color: #fff; }
.call-btn.on { color: var(--accent-text); }
.call-btn.hang { background: var(--danger); color: #fff; }
.call-btn.hang:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.call-banner { flex: none; display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: var(--text-sm); color: var(--success); background: color-mix(in srgb, var(--success) 9%, transparent); border-bottom: 1px solid var(--divider); }
.call-banner span { flex: 1; }
.rec-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: blink 1.4s infinite; }
.caption-overlay {
  position: absolute; left: 10px; right: 10px; bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
.caption-overlay > div { padding: 6px 9px; border-radius: var(--r-md); background: rgba(0, 0, 0, 0.78); color: #fff; font-size: var(--text-sm); line-height: 1.4; backdrop-filter: blur(4px); }
.caption-overlay b { color: color-mix(in srgb, var(--accent) 55%, #fff); margin-right: 4px; }

.incoming {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  display: flex; align-items: center; gap: 10px;
  width: 360px; padding: 10px 10px 10px 12px;
  border-radius: var(--r-lg); background: var(--raised); border: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
  animation: toast-in 220ms var(--ease);
}
[data-theme='dark'] .incoming { background: #15161a; }
.ring-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); animation: ring-pulse 1.2s infinite; flex: none; }
@keyframes ring-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
.incoming-text { flex: 1; min-width: 0; font-size: var(--text-sm); color: var(--text); display: flex; flex-direction: column; }
.incoming-text small { color: var(--text-faint); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-theme='dark'] .tr-head { background: #15161a; }

/* top-bar Messages button */
.tb-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
}
.tb-live { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px var(--bg); }
