/* Nexus AI Surgery Stabilizer: loaded last */
#nexus-v4-presence.nxv4-is-closed #nxv4-rail,
#nexus-v4-presence.nxv4-mode-orb #nxv4-rail:not(.open) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#nexus-v4-presence.nxv4-mode-orb [data-nxv4-panel-shell] {
  display: none !important;
}

#nexus-v4-presence.nxv4-mode-orb #nxv4-settings-panel,
#nexus-v4-presence.nxv4-is-closed #nxv4-settings-panel {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#nexus-v4-presence [data-nxv4-panel-shell].nxv4-panel-hidden {
  display: none !important;
}

#nexus-v4-presence.nxv4-mode-compact [data-nxv4-panel-shell],
#nexus-v4-presence.nxv4-mode-focus [data-nxv4-panel-shell],
#nexus-v4-presence.nxv4-mode-expanded [data-nxv4-panel-shell],
#nexus-v4-presence.nxv4-mode-alert [data-nxv4-panel-shell] {
  display: block !important;
}

#nexus-v4-presence #nxv4-rail.open {
  height: min(760px, calc(100dvh - 132px)) !important;
  max-height: min(760px, calc(100dvh - 132px)) !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  overflow: hidden !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

#nexus-v4-presence #nxv4-rail .nxv4-body {
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  scrollbar-width: thin !important;
  scrollbar-gutter: stable !important;
}

#nexus-v4-presence #nxv4-rail .nxv4-body::-webkit-scrollbar {
  width: 10px;
}

#nexus-v4-presence #nxv4-rail .nxv4-body::-webkit-scrollbar-thumb {
  background: rgba(100,116,139,.55);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/*
Quick-start mic badge: attached to the orb's own bottom-left corner (orb is right:24px,
bottom:24px, 104x104) rather than floating independently. Sized down from a standalone button to
a badge so it reads as part of the orb, and kept well below the callout's bottom edge
(.nxv4-micro-speakout bottom:114px) so the two never collide regardless of message length.
*/
#nexus-v4-presence .nxv4-orb-conversation-toggle {
  position: absolute;
  right: 110px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34,197,94,.35);
  background: rgba(255,255,255,.96);
  color: #16a34a;
  z-index: 10021;
  box-shadow: 0 8px 20px rgba(15,23,42,.2), 0 0 0 3px rgba(34,197,94,.12);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, color .16s ease, border-color .16s ease;
}

#nexus-v4-presence .nxv4-orb-conversation-toggle:hover { transform: translateY(-1px) scale(1.04); }
#nexus-v4-presence .nxv4-orb-conversation-icon::before { content: "🎙"; font-size: 14px; line-height: 1; }

#nexus-v4-presence .nxv4-orb-conversation-toggle[data-nexus-conversation-color="red"] {
  color: #dc2626;
  border-color: rgba(220,38,38,.35);
  box-shadow: 0 10px 28px rgba(15,23,42,.18), 0 0 0 4px rgba(220,38,38,.10), 0 0 24px rgba(220,38,38,.20);
}

#nexus-v4-presence .nxv4-orb-conversation-toggle[data-nexus-conversation-color="amber"] {
  color: #d97706;
  border-color: rgba(217,119,6,.35);
  box-shadow: 0 10px 28px rgba(15,23,42,.18), 0 0 0 4px rgba(245,158,11,.12), 0 0 24px rgba(245,158,11,.22);
}

#nexus-v4-presence.nxv4-conversation-paused .nxv4-orb-conversation-toggle,
#nexus-v4-presence.nxv4-conversation-recovering .nxv4-orb-conversation-toggle { animation: nxv4MicPulse 1.8s ease-in-out infinite; }

@keyframes nxv4MicPulse { 50% { transform: scale(1.06); } }

@keyframes nxv4ListeningPulse {
  50% { transform: scale(1.04); opacity: .72; }
}

#nexus-v4-presence[data-nexus-voice-state="listening"] #nxv4-orb {
  box-shadow: 0 0 0 6px rgba(34,197,94,.28), 0 0 42px rgba(34,197,94,.62), 0 18px 48px rgba(15,23,42,.22) !important;
  transform: translateY(-1px) scale(1.02);
}
#nexus-v4-presence[data-nexus-voice-state="listening"] #nxv4-orb::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  border: 2px solid rgba(34,197,94,.68);
  box-shadow: 0 0 32px rgba(34,197,94,.45);
  animation: nxv4ListeningPulse 1.2s ease-in-out infinite;
}
#nexus-v4-presence[data-nexus-voice-state="listening"] #nxv4-orb .nxv5-orb-host { filter: hue-rotate(95deg) saturate(2.0) brightness(1.15); }

#nexus-v4-presence.nxv4-is-open .nxv4-orb-conversation-toggle,
#nexus-v4-presence.nxv4-is-opening .nxv4-orb-conversation-toggle { display: none !important; }

#nexus-v4-presence.nxv4-conversation-focus [data-nxv4-cues],
#nexus-v4-presence.nxv4-conversation-focus [data-nxv4-form-assist],
#nexus-v4-presence.nxv4-conversation-focus [data-nxv4-briefing-watch] { display:none !important; }

#nexus-v4-presence.nxv4-conversation-focus [data-nxv4-transcript-panel] {
  display:flex !important;
  flex-direction:column;
  min-height:280px;
  max-height:min(52vh,520px);
}

#nexus-v4-presence [data-nxv4-transcript-log] { overflow-y:auto; scroll-behavior:smooth; }
#nexus-v4-presence #nxv4-settings-panel .nxv4-settings-body {
  min-height: 0 !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable !important;
}

#nexus-v4-presence .nxv4-legacy-voice-controls { display:none !important; }
#nexus-v4-presence .nxv4-voice-status-card { display:none; }
#nexus-v4-presence.nxv4-conversation-focus .nxv4-voice-status-card { display:flex; }

@media (max-width:640px) {
  #nexus-v4-presence .nxv4-orb-conversation-toggle {
    /* Mobile orb shrinks to 88x88 (nexus-ai-v5-3d-orb.css); keep the badge anchored to its
       bottom-left corner the same way as desktop. */
    right: 94px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: 34px;
    height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #nexus-v4-presence .nxv4-orb-conversation-toggle { animation: none !important; transition:none !important; }
}

#nexus-v4-presence #nxv4-rail[hidden],
#nexus-v4-presence #nxv4-rail[data-nxv4-state="closed"]:not(.open) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translate3d(120%, 0, 0) scale(.98) !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: 0 !important;
}

#nexus-v4-presence #nxv4-rail.open[data-nxv4-state="open"] {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
