/* V8 communications audit owner: compact desktop surfaces and single-border controls. */
.bms-opendesign-v8 .internal-chat-window {
  width: min(800px, calc(100vw - 36px));
  height: min(600px, calc(100dvh - 110px));
}

/* Feedback direction B: keep the unified composer intact after V8 form primitives load. */
body.bms-opendesign-v8.bms-wave-5 .pop-nexus-feedback-dialog #popFeedbackForm .pop-feedback-description textarea {
  display: block;
  width: 100%;
  min-height: 165px;
  padding: 8px 15px 14px;
  border: 0;
  border-radius: 0;
  outline: 0;
  resize: vertical;
  color: var(--bms-text);
  background: var(--bms-surface);
  box-shadow: none;
  font: 400 14px/1.55 var(--bms-font-ui);
}

body.bms-opendesign-v8.bms-wave-5 .pop-nexus-feedback-dialog #popFeedbackForm .pop-feedback-description textarea:is(:focus, :focus-visible) {
  border: 0;
  outline: 0;
  box-shadow: none;
}

body.bms-opendesign-v8.bms-wave-5 .pop-nexus-feedback-dialog #popFeedbackForm .pop-feedback-composer-toolbar select {
  min-height: 38px;
  height: 38px;
  padding: 0 10px;
}

.bms-opendesign-v8 .pop-nexus-window {
  width: min(440px, calc(100vw - 36px));
  height: min(640px, calc(100dvh - 110px));
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion .internal-chat-window {
  top: calc(var(--bms-topbar-height) + 80px);
  right: max(20px, var(--bms-safe-area-right));
  bottom: auto;
  left: auto;
  width: min(620px, calc(100vw - 36px));
  height: min(560px, calc(100dvh - 110px));
  transform-origin: top right;
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion.is-project-anchored .internal-chat-window {
  top: var(--project-popup-top);
  right: var(--project-popup-right);
  height: min(560px, var(--project-popup-space));
  max-height: var(--project-popup-space);
  border-top-right-radius: 0;
  animation: project-discussion-drop .18s ease-out;
}

.bms-opendesign-v8 .internal-chat-root.is-project-anchored .internal-chat-window::before {
  position: absolute;
  z-index: 2;
  top: -1px;
  right: -1px;
  width: var(--project-popup-anchor-width);
  height: 2px;
  background: var(--bms-surface);
  content: "";
  pointer-events: none;
}

@keyframes project-discussion-drop {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .bms-opendesign-v8 .internal-chat-root.is-project-anchored .internal-chat-window { animation: none; }
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion .internal-chat-body,
.bms-opendesign-v8 .internal-chat-root.is-project-discussion .internal-chat-body:has(.chat-info:not([hidden])) {
  grid-template-columns: minmax(0, 1fr);
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion .chat-sidebar,
.bms-opendesign-v8 .internal-chat-root.is-project-discussion .chat-info {
  display: none;
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion .chat-thread {
  display: grid;
}

.bms-opendesign-v8 .internal-chat-root.is-project-discussion .chat-project-demo-note {
  grid-row: 5;
  margin: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--bms-border);
  color: var(--bms-text-muted);
  background: var(--bms-surface);
  font: 500 12px/1.4 var(--bms-font-ui);
}

.chat-mention { padding: 1px 4px; border-radius: 5px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); font-weight: 700; }
.chat-mention-suggestions { position: absolute; z-index: 8; right: 44px; bottom: calc(100% + 7px); left: 44px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 14px 35px color-mix(in srgb, var(--ink) 18%, transparent); }
.chat-mention-suggestions[hidden] { display: none; }
.chat-mention-suggestions > button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 48px; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.chat-mention-suggestions > button:last-child { border-bottom: 0; }
.chat-mention-suggestions > button:hover { background: var(--brand-soft); }
.chat-mention-suggestions .chat-avatar { width: 32px; height: 32px; }
.chat-mention-suggestions strong,.chat-mention-suggestions small { display: block; }
.chat-mention-suggestions small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.chat-topic-composer { position: relative; }
.chat-topic-composer > .chat-mention-suggestions { right: 0; left: 0; }
.chat-topic-composer .chat-mention-suggestions > button { display: flex; place-items: initial; width: 100%; height: auto; min-height: 44px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); }
.chat-topic-composer .chat-mention-suggestions > button:last-child { border-bottom: 0; }
.chat-topic-composer .chat-mention-suggestions > button:hover,.chat-topic-composer .chat-mention-suggestions > button:focus-visible { background: var(--brand-soft); outline: 0; }

/* Wave 5 correctly styles standalone fields. Inputs nested inside a framed
   composite control must remain borderless or the result is a double frame. */
.bms-opendesign-v8 :is(
  .chat-sidebar-toolbar label,
  .chat-online-panel > label,
  .chat-composer,
  .pop-nexus-composer
) :is(input, textarea) {
  border: 0 !important;
  border-radius: 0;
  background: transparent;
  box-shadow: none !important;
  outline: 0 !important;
}

.bms-opendesign-v8 :is(.chat-composer, .pop-nexus-composer) {
  border: 1px solid var(--line);
  background: var(--surface);
}

/* Textarea controls receive generic field padding from the foundation layer.
   Keep entered multiline text compact, but center the empty-state placeholder
   mathematically by matching its line box to the 44px composer controls. */
.bms-opendesign-v8 .pop-nexus-composer textarea {
  min-height: 34px;
  padding: 7px 3px !important;
  line-height: 20px !important;
  font-family: var(--bms-font-ui);
}

.bms-opendesign-v8 .pop-nexus-composer textarea:placeholder-shown {
  height: 44px !important;
  min-height: 44px;
  padding-block: 0 !important;
  line-height: 44px !important;
  overflow-y: hidden;
}

.bms-opendesign-v8 :is(.chat-composer, .pop-nexus-composer):focus-within,
.bms-opendesign-v8 .chat-sidebar-toolbar label:focus-within,
.bms-opendesign-v8 .chat-online-panel > label:focus-within {
  border-color: var(--bms-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bms-primary) 12%, transparent);
}

/* The message article is layout-only. The inner bubble owns the one visible
   border; keeping both produced the nested cards found during the audit. */
.bms-opendesign-v8 .pop-nexus-message,
.bms-opendesign-v8 .pop-nexus-message.user {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.bms-opendesign-v8 .pop-nexus-message.user > div {
  border-color: color-mix(in srgb, var(--bms-primary) 45%, transparent);
  color: var(--bms-surface);
  background: var(--bms-primary);
}

.bms-opendesign-v8 :is(.pop-nexus-avatar, .pop-nexus-message-avatar) svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bms-opendesign-v8 .pop-nexus-messages {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 50%, transparent) transparent;
}

.bms-opendesign-v8 .pop-nexus-tools-sheet {
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.bms-opendesign-v8 :is(.internal-chat-header, .pop-nexus-header) button {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
}

@media (max-width: 900px), (orientation: landscape) and (max-width: 950px) and (max-height: 500px) {
  .bms-opendesign-v8 .internal-chat-root.is-project-discussion .internal-chat-window {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .bms-opendesign-v8 .internal-chat-root.is-project-anchored .internal-chat-window::before { display: none; }
  .bms-opendesign-v8 .topbar {
    flex-wrap: nowrap;
    gap: var(--bms-space-2);
  }

  .bms-opendesign-v8 .topbar-brand {
    flex: 1 1 auto;
    overflow: hidden;
    max-width: none;
  }

  .bms-opendesign-v8 .shell-breadcrumbs {
    overflow: hidden;
  }

  .bms-opendesign-v8 .topbar-user-actions {
    flex: 0 0 auto;
    gap: var(--bms-space-2);
  }

  .bms-opendesign-v8 .floating-actions-container {
    position: static;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: auto;
    width: auto;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: var(--bms-space-2);
    padding: 0;
    transform: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .bms-opendesign-v8 .floating-action-host {
    flex: 0 0 var(--bms-control-touch);
  }

  .bms-opendesign-v8 #floatingActionsContainer button.floating-action-bubble {
    width: var(--bms-control-touch);
    min-width: var(--bms-control-touch);
    height: var(--bms-control-touch);
    min-height: var(--bms-control-touch);
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--bms-primary) 30%, var(--bms-border));
    border-radius: var(--bms-radius-round);
    color: var(--bms-surface);
    background: var(--bms-primary);
    box-shadow: none;
    transform: none;
  }

  .bms-opendesign-v8 #floatingActionsContainer button.floating-action-bubble:hover {
    background: var(--bms-primary-hover);
    box-shadow: none;
    transform: none;
  }

  .bms-opendesign-v8 #floatingActionsContainer button.floating-action-bubble:active {
    background: var(--bms-primary-active);
  }

  .bms-opendesign-v8 #floatingActionsContainer button.floating-action-bubble:focus-visible {
    outline: 2px solid var(--bms-focus);
    outline-offset: 2px;
  }

  .bms-opendesign-v8 #floatingActionsContainer .floating-action-bubble__icon {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
  }

  :root[data-floating-surface] .bms-opendesign-v8 .floating-action-bubble {
    display: none;
  }

  .bms-opendesign-v8 :is(.internal-chat-window, .pop-nexus-window) {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
  }

  .bms-opendesign-v8 .pop-nexus-messages {
    padding-inline: 12px;
  }

  .bms-opendesign-v8 .pop-nexus-message > div {
    max-width: 88%;
  }

  .bms-opendesign-v8 :is(
    .internal-chat-header button,
    .chat-sidebar-toolbar > button,
    .chat-thread-header > button,
    .chat-info > header button,
    .pop-nexus-icon-btn,
    .pop-nexus-send
  ) {
    width: var(--bms-control-touch);
    min-width: var(--bms-control-touch);
    height: var(--bms-control-touch);
    min-height: var(--bms-control-touch);
  }
}
