/* ──────────────────────────────────────────────────────────────────────
   Dashboard — merged chat stream
   Filter source: sidebar Teams tree (state.selectedAgents). Selection is a
   filter, never navigation.
   ────────────────────────────────────────────────────────────────────── */

.chat-pane {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--paper-card);
  position: relative;
}

.chat-pane .pane-hdr {
  padding: 22px 32px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--rule-soft);
}
.chat-pane .filter-summary {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 22, "wdth" 100;
  margin: 0;
}
.chat-pane .filter-summary .where {
  color: var(--ink);
  font-weight: 700;
}
.chat-pane .filter-summary .sub {
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 8px;
  font-size: 14px;
  letter-spacing: -0.005em;
}
.chat-pane .filter-summary .clear {
  color: var(--ink-4);
  font-size: 12.5px;
  font-weight: 500;
  margin-left: 12px;
  cursor: pointer;
  letter-spacing: -0.003em;
  border-bottom: 1px dotted transparent;
  padding-bottom: 1px;
  transition: color 120ms ease, border-color 120ms ease;
}
.chat-pane .filter-summary .clear:hover {
  color: var(--clay);
  border-bottom-color: var(--clay);
}
.chat-pane .pane-hdr .right {
  display: flex; align-items: center; gap: 6px;
}

/* thread */
.chat-pane .thread {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px 32px 18px;
  scrollbar-width: thin;
}

.chat-pane .thread .empty {
  padding: 64px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
}

.chat-pane .thread .load-older-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 14px;
}
.chat-pane .thread .load-older-wrap .btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.chat-pane .msg {
  margin: 14px 0;
}
.chat-pane .msg .head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px;
  margin-bottom: 4px;
  color: var(--ink-3);
  flex-wrap: wrap;
  padding-left: 18px;
}
.chat-pane .msg .head .who {
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.008em;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
.chat-pane .msg .head .who:hover {
  border-bottom-color: var(--ink-3);
}

/* Spawn-status indicator before an agent name. Designed to be readable
   for red-green colorblind users: each state uses BOTH a colorblind-safe
   hue (steel blue vs clay orange vs muted brick) AND a distinct shape
   (filled disc vs hollow ring vs ringed-with-glyph) so the meaning
   survives pure monochrome viewing. Hover reveals the literal state name. */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 0px;
  position: relative;
  box-sizing: border-box;
}

/* Running — solid steel blue (colorblind-safe vs orange/red) with a
   subtle paper-color inset ring so it reads as "lit". */
.status-dot.on {
  background: var(--steel);
  box-shadow: inset 0 0 0 1.5px var(--paper-card),
              0 0 0 1.5px var(--steel);
}

/* Transient (suspending/resuming) — solid clay orange. Distinct from
   blue at any colorblind-vision profile. */
.status-dot.transient {
  background: var(--clay);
  box-shadow: inset 0 0 0 1.5px var(--paper-card),
              0 0 0 1.5px var(--clay);
}

/* Suspended — hollow ring in muted brick. The ring shape alone (no fill)
   conveys "not running" independent of color. */
.status-dot.off {
  background: transparent;
  border: 1.5px solid var(--brick);
}

/* Failed — solid brick disc with a glyph × overlay drawn via two
   crossed pseudo-elements. The × is the only state with a glyph, so
   "failed" reads correctly even in grayscale. */
.status-dot.failed {
  background: var(--brick);
}
.status-dot.failed::before,
.status-dot.failed::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 1.5px;
  background: var(--paper-card);
  border-radius: 1px;
}
.status-dot.failed::before { transform: translate(-50%, -50%) rotate(45deg); }
.status-dot.failed::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* Void / never-started — hollow ring in light grey. Same shape as
   "off" but lighter color; the tooltip disambiguates. */
.status-dot.void {
  background: transparent;
  border: 1.5px solid var(--ink-4);
}

/* In system-event rows the body font is smaller — scale the dot down. */
.sys-event .status-dot { width: 8px; height: 8px; margin-right: 5px; }
.sys-event .status-dot.failed::before,
.sys-event .status-dot.failed::after { width: 6px; }
.chat-pane .msg.from-eph .head .who { color: var(--steel); }
.chat-pane .msg.from-per .head .who { color: var(--plum); }
.chat-pane .msg.from-me  .head .who { color: var(--ink); }
.chat-pane .msg .head .arrow { color: var(--ink-4); font-weight: 400; font-size: 12px; }
.chat-pane .msg .head .to {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.chat-pane .msg .head .to:hover { border-bottom-color: var(--ink-4); }
.chat-pane .msg .head .topic {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--steel);
  background: var(--steel-bg);
  padding: 1px 7px;
  border-radius: 2px;
  font-weight: 500;
  letter-spacing: -0.002em;
}
.chat-pane .msg .head .topic.default {
  color: var(--ink-4);
  background: var(--paper-2);
  font-weight: 400;
}
.chat-pane .msg .head .time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
}

.chat-pane .msg .body {
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  padding: 2px 0 2px 18px;
  border-left: 2px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-pane .msg.from-eph .body { border-left-color: var(--steel); }
.chat-pane .msg.from-per .body { border-left-color: var(--plum); }
.chat-pane .msg.from-me  .body { border-left-color: var(--ink-3); }
.chat-pane .msg.withdrawn .body {
  opacity: 0.45;
  font-style: italic;
}
/* Transient highlight when a search result jumps to a specific message. */
.chat-pane .msg.focus-flash {
  background: var(--clay-soft);
  border-radius: 4px;
  animation: msg-focus-flash 1.6s ease-out;
}
@keyframes msg-focus-flash {
  0%   { background: rgba(184,90,58,0.20); }
  60%  { background: rgba(184,90,58,0.12); }
  100% { background: transparent; }
}

.chat-pane .msg .body .mention {
  color: var(--steel);
  font-weight: 600;
  background: var(--steel-bg);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 13.5px;
}
.chat-pane .msg .body code.inl {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: 500;
}
.chat-pane .msg .body pre {
  margin: 10px 0 2px;
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
}

/* trigger / exit banners — system events */
.chat-pane .trigger-banner,
.chat-pane .exit-banner {
  display: flex; align-items: baseline;
  gap: 12px;
  padding: 7px 0 7px 18px;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.55;
}
.chat-pane .trigger-banner::before {
  content: "→";
  color: var(--steel);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}
.chat-pane .trigger-banner .body .hash,
.chat-pane .exit-banner .body .hash {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}
.chat-pane .trigger-banner .body .who { color: var(--plum); font-weight: 500; }
.chat-pane .trigger-banner .time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
}

/* composer */
.chat-pane .composer {
  padding: 14px 32px 22px;
  position: relative;
  border-top: 1px solid var(--rule-soft);
}
.chat-pane .composer .input-wrap {
  position: relative;
  background: var(--paper-2);
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: border-color 140ms ease, background 140ms ease;
}
.chat-pane .composer .input-wrap:focus-within {
  background: var(--paper-card);
  border-color: var(--steel);
}
.chat-pane .composer textarea {
  width: 100%;
  min-height: 56px;
  max-height: 240px;
  padding: 14px 16px 8px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  line-height: 1.55;
}
.chat-pane .composer textarea::placeholder { color: var(--ink-4); }

.chat-pane .composer .ctrls {
  padding: 4px 8px 10px;
  display: flex; align-items: center;
  gap: 6px;
}
.chat-pane .composer .ctrls .hint {
  font-size: 11.5px;
  color: var(--ink-3);
}
.chat-pane .composer .ctrls .hint .target {
  color: var(--ink-2);
  font-weight: 500;
}
.chat-pane .composer .ctrls .hint .explode {
  font-family: var(--mono);
  color: var(--clay);
  font-weight: 600;
  margin-left: 4px;
}
.chat-pane .composer .ctrls .hint .escape-topics {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 1px 8px;
  margin-left: 8px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: -0.003em;
}
.chat-pane .composer .ctrls .hint .escape-topics:hover {
  color: var(--ink);
  background: var(--paper-2);
  border-color: var(--rule-strong);
}
.chat-pane .composer .ctrls .spacer { flex: 1; }
.chat-pane .composer .ctrls kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  padding: 0 5px;
  border-radius: 2px;
  color: var(--ink-3);
}

/* profile popover */
.profile-pop {
  position: absolute;
  background: var(--paper-card);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 2px rgba(22,24,28,0.06),
    0 16px 40px -8px rgba(22,24,28,0.22);
  border: 1px solid var(--rule);
  width: 360px;
  max-width: calc(100vw - 24px);
  z-index: 20;
  overflow: hidden;
}
.profile-pop .ph {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--rule-soft);
}
.profile-pop .ph .kind {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 600;
  margin-bottom: 6px;
}
.profile-pop .ph .kind.per { color: var(--plum); }
.profile-pop .ph .nm {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}
.profile-pop .meta {
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 16px;
  font-size: 12.5px;
}
.profile-pop .meta .k {
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  align-self: center;
}
.profile-pop .meta .v { color: var(--ink-2); font-weight: 500; min-width: 0; }
.profile-pop .meta .v.mono { font-family: var(--mono); font-size: 12px; font-weight: 400; }
.profile-pop .meta .v.trunc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-pop .pa {
  display: flex;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule-soft);
  padding: 8px 12px;
  gap: 4px;
  background: var(--paper);
}
.profile-pop .pa.secondary { background: transparent; }
.profile-pop .pa .btn {
  flex: 1 1 calc(50% - 4px);
  text-align: center;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.profile-pop .pa .btn.primary {
  background: var(--pill-on-bg);
  color: var(--pill-on-fg);
  border: 1px solid var(--pill-on-bg);
}
.profile-pop .pa .btn.primary:hover { filter: brightness(1.08); }

/* Mobile — pin to bottom of viewport as a sheet so the popover never
   slides off-screen near the right edge. The JS still computes top/left
   but these rules override (with !important) on narrow viewports. */
@media (max-width: 600px) {
  .profile-pop {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: 12px !important;
    width: auto !important;
    max-width: none;
    max-height: 85vh;
    overflow-y: auto;
  }
  .profile-pop .pa .btn { flex-basis: calc(50% - 4px); }
}

/* mini toast (delivery error) */
.chat-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--paper-card);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--sans);
  z-index: 30;
  box-shadow: 0 8px 20px -6px rgba(22,24,28,0.4);
}
.chat-toast.error { background: var(--brick); }

/* system / lifecycle events — compact one-line row, not a bubble */
.chat-pane .sys-event {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 18px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
  margin: 6px 0;
}
.chat-pane .sys-event.lifecycle::before {
  content: "→";
  color: var(--steel);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}
.chat-pane .sys-event .body {
  flex: 1;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.chat-pane .sys-event .body .who {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
.chat-pane .sys-event .body .who:hover {
  border-bottom-color: var(--ink-3);
}
.chat-pane .sys-event .body .rest {
  color: var(--ink-3);
}
.chat-pane .sys-event .time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  margin-left: auto;
}

/* @-mention autocomplete — anchored to the composer input-wrap */
.chat-pane .composer .input-wrap { position: relative; }
.mention-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-width: calc(100vw - 64px);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px -10px rgba(22,24,28,0.22);
  z-index: 30;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.mention-empty {
  padding: 14px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-4);
  font-style: italic;
  text-align: center;
}
.mention-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule-soft);
}
.mention-item:last-child { border-bottom: none; }
.mention-item.sel { background: var(--paper-2); color: var(--ink); }
.mention-item .status {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-4);
  flex: 0 0 7px;
}
.mention-item .status.online { background: var(--steel); }
.mention-item .status.busy { background: var(--clay); }
/* paused is now equivalent to failed (statusClass unifies them); keep the
   selector for back-compat in case stale markup is cached, but route to
   the same color. */
.mention-item .status.paused,
.mention-item .status.failed { background: var(--brick); }
.mention-item .status.offline { background: var(--ink-4); }
.mention-item .nm {
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-item .meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── voice controls ────────────────────────────────────────────────── */
.voice-ctrls {
  display: flex;
  gap: 2px;
  background: var(--paper);
  border-radius: 4px;
  padding: 2px;
  margin-right: 8px;
}
.voice-ctrls button {
  font-size: 11px;
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  border-radius: 3px;
  transition: background 100ms ease, color 100ms ease;
}
.voice-ctrls button:hover {
  background: var(--rule-soft);
  color: var(--ink-2);
}
.voice-ctrls button.active {
  background: var(--accent);
  color: white;
}
.voice-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--paper);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-3);
  transition: background 100ms ease, color 100ms ease, transform 50ms ease;
  margin-right: 12px;
}
.voice-btn:hover:not(.inactive) {
  background: var(--accent);
  color: white;
}
.voice-btn.inactive {
  opacity: 0.4;
  cursor: default;
}
.voice-btn.recording {
  background: var(--brick);
  color: white;
  animation: voice-pulse 1s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.voice-status {
  font-size: 12px;
  color: var(--ink-3);
  padding: 4px 16px;
  background: var(--paper);
  border-radius: 4px;
  margin: 0 16px 8px;
}

/* ── drag-and-drop file upload ─────────────────────────────────────── */
.chat-pane.drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -6px;
  background: color-mix(in srgb, var(--accent) 4%, var(--paper-card));
}
.chat-pane.drag-over::after {
  content: 'Drop files here to upload';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--paper-card) 85%, transparent);
  pointer-events: none;
  z-index: 100;
}
