.cognitive-presence {
  display: none;
  min-width: 0;
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px solid rgba(56, 189, 248, .16);
  border-radius: 13px;
  background: rgba(2, 6, 23, .28);
}

.conversation-panel:has(#cognitive-presence) {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto !important;
}

.cognitive-presence.active {
  display: block;
  animation: cognitive-presence-in 240ms ease both;
}

.cognitive-presence header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--white);
  font-size: .76rem;
}

.cognitive-presence ol {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cognitive-presence li {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  color: #64748b;
  font-size: clamp(.54rem, .65vw, .66rem);
  line-height: 1.2;
  transition: color 220ms ease, opacity 220ms ease;
}

.cognitive-presence li.active {
  color: #7dd3fc;
}

.cognitive-presence li.complete {
  color: #94a3b8;
}

.cognitive-presence li.complete.requested {
  color: #67e8f9;
}

.cognitive-presence li.error {
  color: #fca5a5;
}

.cognitive-stage-marker {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.cognitive-presence li.active .cognitive-stage-marker {
  animation: cognitive-marker-pulse 1.4s ease-in-out infinite;
}

.pipeline-explanation {
  width: 100% !important;
  max-width: 100% !important;
  border-color: rgba(56, 189, 248, .3) !important;
}

.quick-actions:has(.pipeline-explain-button) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.pipeline-flow {
  display: grid;
  gap: 0;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.pipeline-flow li {
  position: relative;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0 7px 16px;
  border-left: 1px solid rgba(56, 189, 248, .28);
}

.pipeline-flow li::before {
  content: "";
  position: absolute;
  top: 13px;
  left: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, .4);
}

.pipeline-flow li:last-child {
  border-left-color: transparent;
}

.pipeline-flow span {
  color: var(--white);
  font-size: .74rem;
  font-weight: 700;
}

.pipeline-flow small {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35;
}

.os-window[data-atlas-state="idle"] .portrait-head {
  animation: atlas-idle-breathe 5.5s ease-in-out infinite;
}

.os-window[data-atlas-state="idle"] .portrait-glow {
  animation: atlas-glow-breathe 5.5s ease-in-out infinite;
}

.os-window[data-atlas-state="thinking"] .portrait-glow {
  animation: atlas-thinking 1.8s ease-in-out infinite;
}

.os-window[data-atlas-state="thinking"] .portrait-head {
  animation: atlas-thinking-head 2.2s ease-in-out infinite;
}

.os-window[data-atlas-state="speaking"] .voice-wave {
  height: 3px;
  animation: atlas-speaking-wave .72s ease-in-out infinite;
}

.os-window[data-atlas-state="speaking"] .portrait-glow {
  animation: atlas-speaking-glow 1.1s ease-in-out infinite;
}

.os-window[data-atlas-state="research"] .portrait-glow {
  border-color: var(--ambient-temp-color);
  border-top-color: transparent;
  animation: atlas-research-rotate 7s linear infinite;
}

.os-window[data-atlas-state="listening"] .human-presence {
  border-color: rgba(56, 189, 248, .58) !important;
  box-shadow: 0 0 34px rgba(56, 189, 248, .2) !important;
}

.os-window[data-atlas-state="listening"] .portrait-glow {
  animation: atlas-listening 1.6s ease-in-out infinite;
}

.os-window[data-atlas-state="error"] .human-presence {
  border-color: rgba(248, 113, 113, .34) !important;
  box-shadow: 0 0 24px rgba(248, 113, 113, .1) !important;
}

.os-window[data-atlas-state="error"] .portrait-head,
.os-window[data-atlas-state="error"] .portrait-glow {
  filter: sepia(.22) saturate(1.25) hue-rotate(305deg);
}

.os-window[data-avatar="sphere"][data-atlas-state="thinking"] .human-presence::before,
.os-window[data-avatar="sphere"][data-atlas-state="speaking"] .human-presence::before,
.os-window[data-avatar="sphere"][data-atlas-state="listening"] .human-presence::before {
  animation: atlas-thinking 1.8s ease-in-out infinite;
}

@keyframes cognitive-presence-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cognitive-marker-pulse {
  0%, 100% { opacity: .5; transform: scale(.86); }
  50% { opacity: 1; transform: scale(1.12); }
}

@keyframes atlas-idle-breathe {
  0%, 100% { transform: translateY(0) scale(.99); }
  50% { transform: translateY(-3px) scale(1.01); }
}

@keyframes atlas-glow-breathe {
  0%, 100% { opacity: .62; transform: scale(.98); }
  50% { opacity: .9; transform: scale(1.03); }
}

@keyframes atlas-thinking {
  0%, 100% { opacity: .58; transform: scale(.96); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes atlas-thinking-head {
  0%, 100% { transform: translateY(1px); filter: brightness(.96); }
  50% { transform: translateY(-4px); filter: brightness(1.12); }
}

@keyframes atlas-speaking-wave {
  0%, 100% { opacity: .35; transform: scaleX(.72); }
  50% { opacity: 1; transform: scaleX(1.08); }
}

@keyframes atlas-speaking-glow {
  0%, 100% { opacity: .62; }
  50% { opacity: 1; }
}

@keyframes atlas-research-rotate {
  to { transform: rotate(360deg); }
}

@keyframes atlas-listening {
  0%, 100% { opacity: .7; box-shadow: 0 0 20px rgba(56, 189, 248, .18); }
  50% { opacity: 1; box-shadow: 0 0 38px rgba(56, 189, 248, .34); }
}

@media (max-width: 720px) {
  .cognitive-presence {
    padding: 7px 8px;
  }

  .cognitive-presence ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 6px;
  }

  .cognitive-presence li {
    font-size: .58rem;
  }

  .pipeline-flow li {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .quick-actions:has(.pipeline-explain-button) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-x: visible;
  }
}
