.agent-activity-root {
  position: fixed;
  top: max(82px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  z-index: 1080;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
  transition: filter 180ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.agent-activity-root.agent-activity-root--with-digital-human {
  top: max(82px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
}

.agent-activity-panel {
  overflow: hidden;
  border: 1px solid rgba(203, 213, 225, 0.82);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
  color: #0f172a;
  pointer-events: auto;
  backdrop-filter: blur(18px);
  transform-origin: top right;
  transition:
    border-radius 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms ease,
    background 220ms ease,
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.agent-activity-head {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 8px 14px;
  border-bottom: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.agent-activity-root.is-dragging {
  filter: drop-shadow(0 18px 26px rgba(15, 23, 42, 0.12));
  transition: none;
}

.agent-activity-root.is-dragging .agent-activity-panel {
  transform: scale(1.015);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
}

.agent-activity-root.is-dragging .agent-activity-head {
  cursor: grabbing;
}

.agent-activity-title,
.agent-activity-head-actions {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.agent-activity-title {
  color: #0f172a;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}

.agent-activity-title-compact {
  display: none;
}

.agent-activity-count {
  display: inline-flex;
  min-width: 28px;
  height: 19px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.agent-activity-status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.18);
}

.agent-activity-root[data-agent-activity-status="live"] .agent-activity-status-dot {
  background: #0f766e;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.18);
}

.agent-activity-root[data-agent-activity-status="reconnect"] .agent-activity-status-dot,
.agent-activity-root[data-agent-activity-status="connecting"] .agent-activity-status-dot {
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.16);
}

.agent-activity-status {
  flex: 0 0 auto;
  color: #475569;
  font-size: 11px;
  font-weight: 750;
}

.agent-activity-toggle {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #334155;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.agent-activity-toggle:hover,
.agent-activity-toggle:focus-visible {
  border-color: #64748b;
  background: #f1f5f9;
  outline: none;
}

.agent-activity-toggle:active {
  transform: translateY(1px);
}

.agent-activity-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-height: 48px;
  overflow: hidden;
  padding: 0 10px 9px;
  transform-origin: top right;
  transition:
    max-height 250ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 210ms ease,
    padding 230ms ease,
    transform 230ms cubic-bezier(0.22, 1, 0.36, 1);
}

.agent-activity-tab {
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(203, 213, 225, 0.76);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.7);
  color: #475569;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.agent-activity-tab:hover,
.agent-activity-tab:focus-visible {
  border-color: rgba(100, 116, 139, 0.85);
  outline: none;
}

.agent-activity-tab.is-active {
  border-color: rgba(15, 118, 110, 0.26);
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
}

.agent-activity-body {
  border-top: 1px solid rgba(226, 232, 240, 0.72);
  max-height: min(390px, calc(100vh - 150px));
  overflow: hidden;
  padding: 10px;
  transform-origin: top right;
  transition:
    max-height 260ms cubic-bezier(0.22, 1, 0.36, 1),
    border-width 180ms ease,
    opacity 230ms ease,
    padding 230ms ease,
    transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
}

.agent-activity-tab-panel {
  max-height: min(330px, calc(100vh - 190px));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.agent-activity-feed {
  display: grid;
  gap: 9px;
}

.agent-activity-empty {
  padding: 8px 14px 16px;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.agent-activity-empty--inner {
  padding: 14px 8px;
}

.agent-activity-bubble {
  display: grid;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--agent-color, #2563eb) 10%, transparent), transparent 42%),
    rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
  animation: agent-activity-enter 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.agent-activity-bubble.is-latest {
  border-color: rgba(15, 118, 110, 0.28);
  border-color: color-mix(in srgb, var(--agent-color, #2563eb) 34%, #e2e8f0);
}

.agent-activity-bubble.is-error {
  background: rgba(255, 255, 255, 0.96);
  background:
    linear-gradient(90deg, rgba(220, 38, 38, 0.1), transparent 42%),
    rgba(255, 255, 255, 0.96);
}

.agent-activity-bubble__head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.agent-activity-bubble__mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--agent-color, #2563eb);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.agent-activity-bubble__title {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.agent-activity-bubble__title strong {
  overflow: hidden;
  color: #0f172a;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-bubble__title span {
  color: #64748b;
  font-size: 11px;
  line-height: 1.2;
}

.agent-activity-bubble__state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  font-size: 11px;
  font-weight: 850;
}

.agent-activity-bubble__state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.agent-activity-bubble.is-error .agent-activity-bubble__state {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.agent-activity-bubble__flow {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.agent-activity-bubble__code {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.92);
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 850;
}

.agent-activity-bubble__name {
  min-width: 0;
  overflow: hidden;
  color: #1e293b;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-bubble__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.25;
}

.agent-activity-bubble__meta span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.88);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-flow {
  display: grid;
  gap: 8px;
}

.agent-activity-flow-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(226, 232, 240, 0.94);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.agent-activity-flow-item__index {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--agent-color, #2563eb);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
}

.agent-activity-flow-item__body {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.agent-activity-flow-item__body strong,
.agent-activity-flow-item__body span,
.agent-activity-flow-item__time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-flow-item__body strong {
  color: #0f172a;
  font-size: 12px;
  font-weight: 850;
}

.agent-activity-flow-item__body span,
.agent-activity-flow-item__time {
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
}

.agent-activity-detail-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.agent-activity-detail-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 232, 240, 0.88);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.76);
}

.agent-activity-detail-row dt,
.agent-activity-detail-row dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-detail-row dt {
  color: #64748b;
  font-size: 11px;
  font-weight: 850;
}

.agent-activity-detail-row dd {
  color: #0f172a;
  font-size: 12px;
  font-weight: 750;
}

.agent-activity-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.agent-activity-root.is-collapsed {
  width: 82px;
  min-width: 82px;
}

.agent-activity-root.is-collapsed .agent-activity-panel {
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.agent-activity-root.is-collapsed .agent-activity-head {
  min-height: 34px;
  gap: 4px;
  padding: 4px 5px 4px 7px;
}

.agent-activity-root.is-collapsed .agent-activity-title-full {
  display: none;
}

.agent-activity-root.is-collapsed .agent-activity-title-compact {
  display: inline;
  font-size: 12px;
}

.agent-activity-root.is-collapsed .agent-activity-title,
.agent-activity-root.is-collapsed .agent-activity-head-actions {
  gap: 5px;
}

.agent-activity-root.is-collapsed .agent-activity-status-dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}

.agent-activity-root.is-collapsed[data-agent-activity-status="live"] .agent-activity-status-dot {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.agent-activity-root.is-collapsed[data-agent-activity-status="reconnect"] .agent-activity-status-dot,
.agent-activity-root.is-collapsed[data-agent-activity-status="connecting"] .agent-activity-status-dot {
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.agent-activity-root.is-collapsed .agent-activity-count {
  display: none;
}

.agent-activity-root.is-collapsed .agent-activity-status {
  display: none;
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-root.is-collapsed .agent-activity-toggle {
  width: 24px;
  height: 24px;
  font-size: 15px;
}

.agent-activity-root.is-collapsed .agent-activity-tabs,
.agent-activity-root.is-collapsed .agent-activity-body {
  width: 0;
  min-width: 0;
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 0;
  border-top-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
}

.agent-activity-root.is-collapsing .agent-activity-panel {
  transform: scale(0.985);
}

.agent-activity-root.is-expanding .agent-activity-panel {
  animation: agent-activity-panel-pop 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.theme-dark .agent-activity-panel,
html.dark .agent-activity-panel {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.9);
  color: #e5edf7;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

body.theme-dark .agent-activity-head,
html.dark .agent-activity-head {
  background: transparent;
}

body.theme-dark .agent-activity-title,
html.dark .agent-activity-title,
body.theme-dark .agent-activity-bubble__title strong,
html.dark .agent-activity-bubble__title strong,
body.theme-dark .agent-activity-bubble__name,
html.dark .agent-activity-bubble__name {
  color: #f8fafc;
}

body.theme-dark .agent-activity-status,
html.dark .agent-activity-status,
body.theme-dark .agent-activity-empty,
html.dark .agent-activity-empty,
body.theme-dark .agent-activity-bubble__title span,
html.dark .agent-activity-bubble__title span,
body.theme-dark .agent-activity-bubble__meta,
html.dark .agent-activity-bubble__meta {
  color: #a8b3c3;
}

body.theme-dark .agent-activity-toggle,
html.dark .agent-activity-toggle,
body.theme-dark .agent-activity-bubble,
html.dark .agent-activity-bubble,
body.theme-dark .agent-activity-flow-item,
html.dark .agent-activity-flow-item,
body.theme-dark .agent-activity-detail-row,
html.dark .agent-activity-detail-row {
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(17, 24, 39, 0.94);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--agent-color, #2563eb) 18%, transparent), transparent 46%),
    rgba(17, 24, 39, 0.94);
}

body.theme-dark .agent-activity-bubble__code,
html.dark .agent-activity-bubble__code {
  background: #0f172a;
  color: #cbd5e1;
}

body.theme-dark .agent-activity-bubble__meta span,
html.dark .agent-activity-bubble__meta span {
  background: rgba(15, 23, 42, 0.74);
}

body.theme-dark .agent-activity-tabs,
html.dark .agent-activity-tabs,
body.theme-dark .agent-activity-body,
html.dark .agent-activity-body {
  border-color: rgba(148, 163, 184, 0.22);
}

body.theme-dark .agent-activity-tab,
html.dark .agent-activity-tab {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.7);
  color: #a8b3c3;
}

body.theme-dark .agent-activity-tab.is-active,
html.dark .agent-activity-tab.is-active {
  border-color: rgba(45, 212, 191, 0.22);
  background: rgba(45, 212, 191, 0.1);
  color: #99f6e4;
}

body.theme-dark .agent-activity-flow-item__body strong,
html.dark .agent-activity-flow-item__body strong,
body.theme-dark .agent-activity-detail-row dd,
html.dark .agent-activity-detail-row dd {
  color: #f8fafc;
}

@keyframes agent-activity-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes agent-activity-panel-pop {
  from {
    opacity: 0.72;
    transform: translateY(-6px) scale(0.965);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .agent-activity-root.agent-activity-root--with-digital-human {
    top: max(74px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
  }
}

@media (max-width: 560px) {
  .agent-activity-root {
    top: max(68px, env(safe-area-inset-top));
    right: 12px;
    width: min(360px, calc(100vw - 24px));
  }

  .agent-activity-root.agent-activity-root--with-digital-human {
    right: 12px;
  }

  .agent-activity-root.is-collapsed {
    width: auto;
  }

  .agent-activity-tab-panel {
    max-height: min(300px, calc(100vh - 170px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-activity-root,
  .agent-activity-panel,
  .agent-activity-tabs,
  .agent-activity-body,
  .agent-activity-tab,
  .agent-activity-toggle,
  .agent-activity-bubble {
    animation: none;
    transition: none;
  }
}
