.project-collaboration {
  --collab-bg: var(--menu-surface, var(--surface-solid, #fff));
  --collab-text: var(--menu-ink, var(--text, #202937));
  --collab-muted: var(--menu-muted, var(--muted, #697586));
  --collab-line: var(--menu-border, var(--line, #dce1e8));
  /* Keep the assistant/comments launchers in the existing right-hand rail clear. */
  position: fixed; right: 78px; bottom: 76px; z-index: 850;
  color: var(--collab-text); font: 12px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
}
.project-collaboration[hidden], .project-collaboration [hidden] { display: none !important; }
.project-collaboration button { font: inherit; color: inherit; cursor: pointer; }
.project-collaboration-launcher {
  display: flex; align-items: center; gap: 9px; min-height: 38px; max-width: min(350px, calc(100vw - 96px));
  padding: 7px 12px; border: 1px solid var(--collab-line); border-radius: 22px; background: var(--collab-bg);
  box-shadow: 0 3px 15px #172b4d18; font-weight: 600 !important;
}
.project-collaboration button:focus-visible { outline: 3px solid #5391ff; outline-offset: 3px; }
.project-collaboration-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #8793a1; }
.project-collaboration[data-state="live"] .project-collaboration-dot { background: #1c9c70; }
.project-collaboration[data-state="attention"] .project-collaboration-dot,
.project-collaboration[data-state="offline"] .project-collaboration-dot { background: #bb7d1b; }
.project-collaboration-avatars { display: flex; padding-left: 2px; }
.project-collaboration-avatar {
  flex: 0 0 28px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--peer-colour, #6955cc); color: #fff; font-size: 10px; font-weight: 750;
}
.project-collaboration-avatars .project-collaboration-avatar { width: 23px; height: 23px; flex-basis: 23px; margin-left: -5px; border: 2px solid var(--collab-bg); }
.project-collaboration-panel {
  position: fixed; right: 12px; bottom: 124px; width: min(460px, calc(100vw - 24px)); height: min(650px, calc(100dvh - 160px)); max-height: calc(100dvh - 160px);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--collab-line); border-radius: 14px; background: var(--collab-bg); box-shadow: 0 12px 40px #172b4d24;
}
.project-collaboration-panel > header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--collab-line); }
.project-collaboration-panel > header strong { font-size: 15px; }
.project-collaboration-panel > header > div { min-width: 0; }
.project-collaboration-panel > header small { display: block; margin-top: 3px; color: var(--collab-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-collaboration-close { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; font-size: 20px !important; }
.project-collaboration-close:hover { background: #8881; }
.project-collaboration-status { margin: 0 0 10px; color: var(--collab-muted); }
.project-collaboration-people { list-style: none; margin: 0; padding: 0; }
.project-collaboration-people li { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-top: 1px solid var(--collab-line); }
.project-collaboration-people li > span:last-child { min-width: 0; }
.project-collaboration-people strong, .project-collaboration-people small { display: block; overflow-wrap: anywhere; }
.project-collaboration-people small { margin-top: 2px; color: var(--collab-muted); font-size: 11px; }
.project-collaboration-note { margin: 8px 16px 12px; padding: 9px 10px; border-radius: 8px; background: #bc842916; color: var(--collab-text); overflow-wrap: anywhere; }
.project-collaboration-review { margin: 0 16px 12px; padding: 7px 10px; border: 1px solid var(--collab-line); border-radius: 7px; background: transparent; font-weight: 600 !important; }
.project-collaboration-review:disabled { opacity: .6; cursor: wait; }
.project-collaboration-panel > footer { flex: 0 0 auto; margin: 0; padding: 10px 16px; color: var(--collab-muted); font-size: 10px; line-height: 1.5; border-top: 1px solid var(--collab-line); }
.project-collaboration-overlay { position: fixed; inset: 0; z-index: 640; pointer-events: none; overflow: hidden; contain: layout style paint; }
.project-collaboration-outline { position: absolute; border: 2px dashed var(--peer-colour); border-radius: 5px; box-sizing: border-box; pointer-events: none; }
.project-collaboration-outline > span { position: absolute; left: -2px; top: -21px; max-width: 220px; padding: 2px 5px; border-radius: 4px 4px 0 0; background: var(--peer-colour); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 10px/15px ui-sans-serif, system-ui, sans-serif; }
.project-collaboration-cursor { position: absolute; transform: translate(6px, 8px); max-width: 160px; padding: 2px 5px; border-radius: 3px; background: var(--peer-colour); color: #fff; white-space: nowrap; overflow: visible; font: 10px/15px ui-sans-serif, system-ui, sans-serif; }
.project-collaboration-cursor::before { content: ''; position: absolute; top: -9px; left: -7px; width: 0; height: 0; border-right: 8px solid transparent; border-top: 12px solid var(--peer-colour); transform: rotate(-15deg); }
.project-team-space { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.project-team-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); flex: 0 0 auto; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--collab-line); }
.project-team-tabs button { min-width: 0; min-height: 36px; padding: 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-weight: 650; }
.project-team-tabs button[aria-selected="true"] { background: var(--menu-selected, #e9f2ff); border-color: var(--menu-selected-border, #b4d1ff); color: var(--menu-accent, #0865ce); }
.project-team-overview { flex: 1 1 auto; min-height: 0; padding: 14px 16px; overflow: auto; overscroll-behavior: contain; }
.project-team-self { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.project-team-self > div { min-width: 0; flex: 1; }
.project-team-self strong { display: block; overflow-wrap: anywhere; }
.project-team-self small { color: var(--collab-muted); font-size: 11px; }
.project-team-you { border: 1px solid var(--collab-line); border-radius: 20px; padding: 2px 8px; color: var(--collab-muted); font-size: 10px; }
.project-team-roundup { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--collab-line); }
.project-team-roundup-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.project-team-roundup h3 { margin: 0; font-size: 13px; font-weight: 700; }
.project-team-roundup-head > span, .project-team-roundup-hint, .project-team-history-note { font-size: 10px; color: var(--collab-muted); }
.project-team-roundup-hint { margin: 6px 0 12px; line-height: 1.5; }
.project-team-empty { border: 1px dashed var(--collab-line); border-radius: 10px; padding: 18px 14px; color: var(--collab-muted); line-height: 1.6; }
.project-team-action { margin-top: 7px; padding: 10px; border: 1px solid var(--collab-line); border-radius: 9px; }
.project-team-action summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
.project-team-action summary > span:first-child { min-width: 0; }
.project-team-action summary strong, .project-team-action summary small { display: block; overflow-wrap: anywhere; }
.project-team-action summary small { margin-top: 3px; color: var(--collab-muted); font-size: 10px; }
.project-team-action-count { flex: 0 0 auto; font-size: 10px; color: var(--collab-muted); }
.project-team-action summary::after { content: '+'; color: var(--collab-muted); }
.project-team-action[open] summary::after { content: '−'; }
.project-team-action p { margin: 8px 0; overflow-wrap: anywhere; }
.project-team-action-detail { display: grid; gap: 3px; padding-top: 8px; border-top: 1px solid var(--collab-line); }
.project-team-action-detail small { color: var(--collab-muted); }
.project-team-conversation { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.project-team-feed-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex: 0 0 auto; padding: 12px 16px 0; }
.project-team-feed-head > div { min-width: 0; }
.project-team-feed-head strong { display: block; font-size: 12px; }
.project-team-feed-head small { display: block; margin-top: 3px; color: var(--collab-muted); font-size: 10px; line-height: 1.5; }
.project-team-space :is([data-team-refresh],.project-team-older) { min-height: 32px; padding: 5px 9px; border: 1px solid var(--collab-line); border-radius: 7px; background: var(--collab-bg); }
.project-team-service-status { margin: 8px 16px; color: var(--collab-muted); font-size: 10px; line-height: 1.5; flex: 0 0 auto; }
.project-team-service-status:is([data-state="error"],[data-state="blocked"],[data-state="unavailable"]) { color: var(--danger, #b84138); }
.project-team-feed { min-height: 60px; flex: 1 1 auto; padding: 4px 16px 12px; overflow: auto; overscroll-behavior: contain; }
.project-team-post { padding: 10px; margin-bottom: 8px; border: 1px solid var(--collab-line); border-radius: 10px; background: var(--menu-subtle, var(--surface-soft, #f6f8fb)); overflow-wrap: anywhere; }
.project-team-post.is-own { border-color: var(--menu-selected-border, #b4d1ff); background: var(--menu-selected, #eef5ff); }
.project-team-post-head { display: flex; align-items: center; gap: 7px; }
.project-team-post-head strong { min-width: 0; flex: 1; font-size: 11px; }
.project-team-post-head time { color: var(--collab-muted); font-size: 9px; }
.project-team-post-avatar { display: inline-flex; flex: 0 0 22px; height: 22px; align-items: center; justify-content: center; border-radius: 7px; background: var(--collab-bg); color: var(--menu-accent, #0865ce); font-size: 9px; font-weight: 700; }
.project-team-post h4 { margin: 9px 0 4px; font-size: 12px; }
.project-team-post p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.6; }
.project-team-older { margin: 0 16px 8px; flex: 0 0 auto; }
.project-team-compose { margin: 0; padding: 12px 16px; border-top: 1px solid var(--collab-line); flex: 0 0 auto; }
.project-team-compose label { display: grid; gap: 5px; color: var(--collab-muted); font-size: 11px; font-weight: 600; }
.project-team-notice-title { margin-bottom: 8px; }
.project-team-compose :is(input,textarea) { box-sizing: border-box; width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--collab-line); border-radius: 8px; background: var(--collab-bg); color: var(--collab-text); font: inherit; font-weight: 400; }
.project-team-compose input { min-height: 36px; }
.project-team-compose textarea { resize: vertical; min-height: 64px; max-height: 120px; line-height: 1.5; }
.project-team-compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; }
.project-team-compose-actions small { flex: 1 1 100%; color: var(--collab-muted); font-size: 10px; font-weight: 400; }
.project-team-compose-actions > span { flex: 1; color: var(--collab-muted); font-size: 10px; }
.project-team-compose-actions button { min-height: 34px; padding: 6px 12px; border: 1px solid var(--menu-primary, #0865ce); border-radius: 8px; background: var(--menu-primary, #0865ce); color: #fff; font-weight: 650; }
.project-team-space :is(button,input,textarea,summary):focus-visible { outline: 2px solid var(--menu-accent, #0865ce); outline-offset: 2px; }
.project-team-space button:disabled { opacity: .55; cursor: not-allowed; }
@media (pointer: coarse) { .project-team-space button { min-height: 44px; } }
@media (max-height: 650px) {
  .project-team-conversation { display: block; overflow: auto; overscroll-behavior: contain; }
  .project-team-feed { height: auto; min-height: 60px; overflow: visible; }
  .project-team-compose { padding-block: 8px; }
  .project-team-compose textarea { min-height: 48px; max-height: 80px; }
  .project-collaboration-panel > footer { padding-block: 6px; font-size: 9px; }
}
@media (max-width: 600px) { .project-collaboration { right: 72px; bottom: 72px; } .project-collaboration-launcher { font-size: 11px; } }
@media print { .project-collaboration, .project-collaboration-overlay { display: none !important; } }

/* Private message attachments use the same compact theme tokens as Team. */
.project-team-compose.has-image-attachments { display: flex; flex-direction: column; gap: 6px; }
.has-image-attachments .project-team-compose-actions { order: 3; }
.project-team-image-composer { order: 2; min-width: 0; }
.project-team-image-composer[hidden], .project-team-image-actions input[hidden] { display: none; }
.project-team-image-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-team-image-actions button, .project-team-image-draft button, .project-team-post-image button { min-height: 30px; padding: 5px 9px; border: 1px solid var(--collab-line); border-radius: 7px; background: var(--collab-bg); color: var(--collab-text); font: inherit; font-size: 11px; cursor: pointer; }
.project-team-image-actions small { flex: 1 1 150px; color: var(--collab-muted); font-size: 10px; line-height: 1.5; }
.project-team-image-drafts, .project-team-post-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 7px; margin-top: 7px; }
.project-team-image-draft, .project-team-post-image { min-width: 0; margin: 0; padding: 6px; border: 1px solid var(--collab-line); border-radius: 9px; background: var(--collab-bg); }
.project-team-image-draft img { display: block; width: 100%; height: 65px; object-fit: contain; border-radius: 5px; }
.project-team-image-viewport { display: grid; place-items: center; width: 100%; min-height: 72px; max-height: 200px; overflow: hidden; border-radius: 5px; background: var(--menu-subtle, var(--surface-soft, #f6f8fb)); }
.project-team-image-viewport > :is(img,button) { grid-area: 1 / 1; }
.project-team-post-image img { display: block; width: 100%; height: 100%; min-height: 0; max-height: 200px; object-fit: contain; border-radius: 5px; }
.project-team-image-footer { min-height: 19px; }
.project-team-post-image img[hidden], .project-team-post-image button[hidden], .project-team-post-image a[hidden] { display: none; }
.project-team-image-draft figcaption, .project-team-post-image figcaption { margin-top: 4px; overflow-wrap: anywhere; color: var(--collab-muted); font-size: 10px; line-height: 1.4; }
.project-team-image-draft button { margin-top: 5px; width: 100%; }
.project-team-post-image a { display: inline-block; margin-top: 5px; color: var(--menu-primary, #0865ce); font-size: 10px; }
.project-team-image-error { margin: 5px 0 0; color: var(--menu-danger, #b53a44); font-size: 11px; line-height: 1.5; }
.project-team-image-error:empty { display: none; }
.project-team-post[data-team-highlighted="true"] { outline: 2px solid var(--menu-accent, #0865ce); outline-offset: 2px; }

/* Private conversations remain visibly separate from the project-wide feed. */
.project-team-tabs { grid-template-columns: repeat(4,minmax(0,1fr)); }
.project-team-tabs [data-team-direct-count] { display: inline-flex; align-items: center; justify-content: center; margin-inline-start: 5px; min-width: 17px; padding: 0 4px; border-radius: 12px; background: var(--menu-accent, #0865ce); color: var(--menu-on-accent, #fff); font-size: 10px; line-height: 17px; }
.project-team-tabs [data-team-direct-count][hidden] { display: none; }
.project-team-direct-picker { flex: 0 0 auto; padding: 11px 16px; border-bottom: 1px solid var(--collab-line); background: var(--menu-subtle, var(--collab-bg)); }
.project-team-direct-picker[hidden] { display: none; }
.project-team-direct-picker > div { display: flex; align-items: flex-end; gap: 8px; }
.project-team-direct-picker label { flex: 1 1 auto; min-width: 0; color: var(--collab-muted); font-size: 11px; font-weight: 650; }
.project-team-direct-picker select { display: block; width: 100%; min-width: 0; min-height: 34px; margin-top: 4px; padding: 6px 9px; border: 1px solid var(--collab-line); border-radius: 8px; background: var(--collab-bg); color: var(--collab-text); font: inherit; text-overflow: ellipsis; }
.project-team-direct-picker button, .project-team-person-message { flex: 0 0 auto; min-height: 32px; padding: 5px 9px; border: 1px solid var(--collab-line); border-radius: 8px; background: var(--collab-bg); color: var(--menu-accent, #0865ce); font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; }
.project-team-direct-picker button:disabled { opacity: .6; cursor: default; }
.project-team-direct-picker small { display: block; margin-top: 7px; color: var(--collab-muted); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.project-collaboration-people li > span:nth-child(2) { flex: 1 1 auto; min-width: 0; }
.project-team-person-message { margin-inline-start: auto; }
.project-team-person-message:hover { background: var(--menu-selected, #e9f2ff); }
.project-team-person-message:focus-visible, .project-team-direct-picker :is(select,button):focus-visible { outline: 2px solid var(--menu-accent, #0865ce); outline-offset: 2px; }
.project-collaboration-panel:has(.project-team-tabs [data-team-tab="direct"][aria-selected="true"]) { height: min(760px, calc(100dvh - 160px)); }
@media (max-width: 380px) { .project-team-tabs { padding-inline: 7px; gap: 2px; } .project-team-tabs button { padding-inline: 3px; font-size: 11px; } .project-team-direct-picker { padding-inline: 12px; } .project-team-direct-picker button { max-width: 78px; } }

/* The private recipient picker adds fixed-height content. On laptop-height
   windows the complete conversation is the single scroll owner, so its form
   cannot leak across the fixed footer or make scrollIntoView move the panel. */
@media (max-height: 900px) {
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) .project-team-conversation { display: block; overflow: auto; overscroll-behavior: contain; min-height: 0; }
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) .project-team-feed { height: auto; min-height: 0; overflow: visible; overscroll-behavior: auto; }
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) .project-team-compose { padding-block: 8px; }
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) .project-team-compose textarea { min-height: 48px; max-height: 80px; }
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) .project-team-direct-picker { padding-block: 8px; }
  .project-collaboration-panel:has([data-team-tab="direct"][aria-selected="true"]) > footer { padding-block: 6px; font-size: 9px; }
}
