.team-chat-shell {
  height: calc(100dvh - 78px);
  min-height: 32rem;
}

.team-chat-shell form.button_to {
  margin: 0;
}

@media (max-width: 640px) {
  .team-chat-shell {
    height: calc(100dvh - 72px);
    min-height: 28rem;
    margin: -6px -5px 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}

/* ── Team Chat launcher ───────────────────────────────────────────────────
   Bottom-left bubble + popover on desktop; full-width bottom bar + sheet at
   <= 1024px. z-index 45 sits in the 31-49 band: above the nav (30) and the
   dropdown (40), below the line-item drawer and Undo toast (50), the mobile
   sidebar (55-70) and the Companion (1000). The closed sheet is display:none. */
.team-launcher__bubble {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: #8566eb;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.15s;
}
.team-launcher__bubble:hover { background: #765ad0; transform: scale(1.05); }
.team-launcher__bubble:focus-visible,
.team-launcher-bar:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 3px; }

.team-launcher__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.team-launcher__badge--inline { position: static; }

.team-launcher-bar { display: none; }

.team-launcher__sheet {
  display: none;
  position: fixed;
  bottom: 88px;
  left: 24px;
  z-index: 46;
  width: 340px;
  max-height: min(70vh, 520px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e6e3ed;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(27, 23, 46, 0.18), 0 1px 3px rgba(27, 23, 46, 0.08);
}
.team-launcher__sheet.team-sheet--open { display: flex; }

.team-launcher__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e6e3ed;
  background: #8566eb;
  color: #fff;
}
.team-launcher__header h2 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.team-launcher__close {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.team-launcher__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.team-launcher__heading {
  margin: 0;
  padding: 10px 14px 4px;
  color: #6b7280;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.team-launcher__list { margin: 0; padding: 0; list-style: none; }
.team-launcher__list form.button_to { margin: 0; }
.team-launcher__row {
  position: relative;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: #1f2937;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.team-launcher__row:hover { background: #f5f3ff; text-decoration: none; }
.team-launcher__row-title { display: block; padding-right: 16px; overflow: hidden; font-size: 0.875rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.team-launcher__row-preview { display: block; overflow: hidden; color: #6b7280; font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.team-launcher__dot { position: absolute; top: 50%; right: 14px; width: 10px; height: 10px; border-radius: 50%; background: #8566eb; transform: translateY(-50%); }
.team-launcher__empty { margin: 0; padding: 10px 14px; color: #6b7280; font-size: 0.82rem; }
.team-launcher__footer { padding: 8px 14px; border-top: 1px solid #e6e3ed; }
.team-launcher__open { display: inline-flex; align-items: center; min-height: 36px; color: #765ad0; font-size: 0.875rem; font-weight: 600; }

/* Keep the last portfolio-tree items reachable above the bottom-left bubble. */
body:has(.team-launcher) .sidebar { padding-bottom: 84px; }

/* The two launchers never both open. Companion behavior itself is untouched. */
body:has(.team-sheet--open) .companion-bubble { display: none; }
body:has(.companion-panel--open) .team-launcher__sheet { display: none; }

/* ── Phones and tablets (<= 1024px): bottom bar + bottom sheet ─────────── */
@media (max-width: 1024px) {
  .team-launcher__bubble { display: none; }

  .team-launcher-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: content-box;
    height: 56px;
    padding: 0 16px env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    background: #8566eb;
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
  }
  .team-launcher-bar__label { flex: 1; text-align: left; }
  .team-launcher-bar__chevron { font-size: 0.7rem; opacity: 0.8; }
  body:has(.companion-panel--open) .team-launcher-bar { display: none; }

  .team-launcher__sheet {
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 48;
    width: 100%;
    max-height: 75vh;
    max-height: 75dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Companion bubble rides above the bar (companion.css:586-587 sets bottom: 24px). */
  body:has(.team-launcher-bar) .companion-bubble { bottom: calc(56px + env(safe-area-inset-bottom) + 16px); }

  /* The 10-second Undo toast (z-50, bottom-4) must never hide behind the bar. */
  body:has(.team-launcher-bar) [data-testid="pin-undo-toast"] { bottom: calc(56px + env(safe-area-inset-bottom) + 12px); }

  /* Overrides application.css:183 and :1263 so the last row clears the bar. */
  body:has(.team-launcher-bar) .page-content { padding-bottom: calc(56px + env(safe-area-inset-bottom) + 16px); }
  body:has(.team-launcher-bar) .sidebar { padding-bottom: calc(56px + env(safe-area-inset-bottom) + 16px); }
}

/* The mobile sidebar (<= 760px) is a fixed drawer above the bar; keep its own padding. */
@media (max-width: 760px) {
  body:has(.team-launcher-bar) .sidebar { padding-bottom: 28px; }
}
