.page-agent-wrapper {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translate(-50%) translateY(20px);
  opacity: 0;
  z-index: 2147483642;
  box-sizing: border-box;
  overflow: visible;
  --width: 360px;
  --height: 40px;
  --border-radius: 12px;
  --side-space: 12px;
  --history-width: calc(var(--width) - var(--side-space) * 2);
  --color-1: rgb(57, 182, 255);
  --color-2: rgb(189, 69, 251);
  --color-3: rgb(255, 87, 51);
  --color-4: rgb(255, 214, 0);
  width: var(--width);
  height: var(--height);
  transition: all .3s ease-in-out;
}

.page-agent-wrapper * {
  box-sizing: border-box;
}

@media(max-width: 480px) {
  .page-agent-wrapper {
    width: calc(100vw - 40px);
    --width: calc(100vw - 40px);
  }
}

.page-agent-wrapper .page-agent-background {
  position: absolute;
  inset: -2px -8px;
  border-radius: calc(var(--border-radius) + 4px);
  filter: blur(16px);
  overflow: hidden;
}

.page-agent-wrapper .page-agent-background:before {
  content: "";
  z-index: -1;
  pointer-events: none;
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-image: linear-gradient(to bottom left, var(--color-1), var(--color-2), var(--color-1));
  animation: page-agent-mask-running 2s linear infinite;
}

.page-agent-wrapper .page-agent-background:after {
  content: "";
  z-index: -1;
  pointer-events: none;
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-image: linear-gradient(to bottom left, var(--color-2), var(--color-1), var(--color-2));
  animation: page-agent-mask-running 2s linear infinite;
  animation-delay: 1s;
}

@keyframes page-agent-mask-running {
  0% { transform: translate(-100%); }
  100% { transform: translate(100%); }
}

.page-agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  -webkit-user-select: none;
  user-select: none;
  position: absolute;
  inset: 0;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  background-clip: padding-box;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 0 5px 1px rgba(255, 255, 255, 0.3);
}

.page-agent-header .page-agent-status-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-height: 24px;
}

.page-agent-header .page-agent-status-section .page-agent-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
  animation: none;
}

.page-agent-header .page-agent-status-section .page-agent-indicator.thinking {
  background: #39b6ff;
  animation: page-agent-pulse .8s ease-in-out infinite;
}

.page-agent-header .page-agent-status-section .page-agent-indicator.tool-executing {
  background: #bd45fb;
  animation: page-agent-pulse .6s ease-in-out infinite;
}

.page-agent-header .page-agent-status-section .page-agent-indicator.retry {
  background: #ffd600;
  animation: page-agent-retry-pulse 1s ease-in-out infinite;
}

.page-agent-header .page-agent-status-section .page-agent-indicator.completed,
.page-agent-header .page-agent-status-section .page-agent-indicator.input,
.page-agent-header .page-agent-status-section .page-agent-indicator.output {
  background: #22c55e;
  animation: none;
}

.page-agent-header .page-agent-status-section .page-agent-indicator.error {
  background: #ef4444;
  animation: none;
}

.page-agent-header .page-agent-status-section .page-agent-status-text {
  color: #fff;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  transition: all .3s ease-in-out;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 24px;
}

.page-agent-header .page-agent-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-agent-header .page-agent-controls .page-agent-control-button {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.page-agent-header .page-agent-controls .page-agent-control-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.page-agent-header .page-agent-controls .page-agent-stop-button {
  background: rgba(239, 68, 68, 0.2);
  color: #ff2929;
  font-weight: 600;
}

.page-agent-header .page-agent-controls .page-agent-stop-button:hover {
  background: rgba(239, 68, 68, 0.3);
}

@keyframes page-agent-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(1.3); }
}

@keyframes page-agent-retry-pulse {
  0%, 100% { opacity: 1; transform: scale(1) rotate(0); }
  25% { opacity: .6; transform: scale(1.2) rotate(90deg); }
  50% { opacity: .8; transform: scale(1.1) rotate(180deg); }
  75% { opacity: .6; transform: scale(1.2) rotate(270deg); }
}

.page-agent-history-wrapper {
  position: absolute;
  width: var(--history-width);
  bottom: var(--height);
  left: var(--side-space);
  z-index: -2;
  padding-top: 0;
  visibility: collapse;
  overflow: hidden;
  transition: all .2s;
  background: rgba(2, 0, 20, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-shadow: 0 0 1px rgba(0, 0, 0, .2);
  border-top-left-radius: calc(var(--border-radius) + 4px);
  border-top-right-radius: calc(var(--border-radius) + 4px);
  border: 2px solid rgba(255, 255, 255, .4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.page-agent-wrapper.expanded .page-agent-history-wrapper {
  padding-top: 8px;
  visibility: visible;
}

.page-agent-history-wrapper .page-agent-history {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  max-height: 0;
  padding-inline: 8px;
  transition: max-height .2s;
}

.page-agent-wrapper.expanded .page-agent-history-wrapper .page-agent-history {
  max-height: 400px;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border-radius: 8px;
  border-left: 2px solid rgba(57, 182, 255, .5);
  font-size: 12px;
  color: #fff;
  line-height: 1.3;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.15), 0 2px 4px rgba(0, 0, 0, 0.15);
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item:last-child {
  margin-bottom: 10px;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.completed,
.page-agent-history-wrapper .page-agent-history .page-agent-history-item.input,
.page-agent-history-wrapper .page-agent-history .page-agent-history-item.output {
  border-left-color: #22c55e;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.error {
  border-left-color: #ef4444;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.retry {
  border-left-color: #ffd600;
  background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(255, 214, 0, 0.05));
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.observation {
  border-left-color: #9333ea;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(147, 51, 234, 0.05));
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.question {
  border-left-color: #ff9f43;
  background: linear-gradient(135deg, rgba(255, 159, 67, 0.15), rgba(255, 159, 67, 0.08));
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.done-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
  border: none;
  border-left: 4px solid rgb(34, 197, 94);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3), inset 0 1px rgba(255, 255, 255, 0.2), 0 0 20px rgba(34, 197, 94, 0.1);
  font-weight: 600;
  color: #dcfce7;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.done-success:before {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, .4), transparent);
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.done-success:after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .1), transparent);
  animation: page-agent-shimmer 2s ease-in-out infinite;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.done-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
  border: none;
  border-left: 4px solid rgb(239, 68, 68);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3), inset 0 1px rgba(255, 255, 255, 0.2), 0 0 20px rgba(239, 68, 68, 0.1);
  font-weight: 600;
  color: #fee2e2;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item.done-error:before {
  background: linear-gradient(90deg, transparent, rgba(239, 68, 68, .4), transparent);
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item .page-agent-history-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-break: break-all;
  white-space: pre-wrap;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item .page-agent-history-content .page-agent-status-icon {
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1;
  transition: all .3s ease;
}

.page-agent-history-wrapper .page-agent-history .page-agent-history-item .page-agent-history-meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
  line-height: 1;
}

@keyframes page-agent-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.page-agent-input-wrapper {
  position: absolute;
  width: var(--history-width);
  top: var(--height);
  left: var(--side-space);
  z-index: -1;
  visibility: visible;
  overflow: hidden;
  height: 48px;
  transition: all .2s;
  background: rgba(186, 186, 186, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: calc(var(--border-radius) + 4px);
  border-bottom-right-radius: calc(var(--border-radius) + 4px);
  border: 2px solid rgba(255, 255, 255, .3);
  box-shadow: 0 1px 16px rgba(0, 0, 0, 0.4);
}

.page-agent-input-wrapper.hidden {
  visibility: collapse;
  height: 0;
}

.page-agent-input-wrapper .page-agent-input-section {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-task-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 10px;
  padding-inline: 10px;
  color: #141414;
  font-size: 12px;
  height: 28px;
  line-height: 1;
  outline: none;
  transition: all .2s ease;
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-task-input::placeholder {
  color: #353535;
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-task-input:focus {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(57, 182, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(57, 182, 255, 0.2);
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-submit-button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-1), var(--color-2));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all .2s ease;
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-submit-button:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(57, 182, 255, 0.4);
}

.page-agent-input-wrapper .page-agent-input-section .page-agent-submit-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.page-agent-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483641;
  cursor: wait;
  overflow: hidden;
  display: none;
}

.page-agent-overlay.visible {
  display: block;
}

.page-agent-cursor {
  position: absolute;
  width: var(--cursor-size, 75px);
  height: var(--cursor-size, 75px);
  pointer-events: none;
  z-index: 10000;
}

.page-agent-cursor-border {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #39b6ff, #bd45fb);
  -webkit-mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none'%3e%3cg%3e%3cpath d='M 15 42 L 15 36.99 Q 15 31.99 23.7 31.99 L 28.05 31.99 Q 32.41 31.99 32.41 21.99 L 32.41 17 Q 32.41 12 41.09 16.95 L 76.31 37.05 Q 85 42 76.31 46.95 L 41.09 67.05 Q 32.41 72 32.41 62.01 L 32.41 57.01 Q 32.41 52.01 23.7 52.01 L 19.35 52.01 Q 15 52.01 15 47.01 Z' fill='none' stroke='%23000000' stroke-width='6' stroke-miterlimit='10' style='stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));'/%3e%3c/g%3e%3c/svg%3e");
  mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none'%3e%3cg%3e%3cpath d='M 15 42 L 15 36.99 Q 15 31.99 23.7 31.99 L 28.05 31.99 Q 32.41 31.99 32.41 21.99 L 32.41 17 Q 32.41 12 41.09 16.95 L 76.31 37.05 Q 85 42 76.31 46.95 L 41.09 67.05 Q 32.41 72 32.41 62.01 L 32.41 57.01 Q 32.41 52.01 23.7 52.01 L 19.35 52.01 Q 15 52.01 15 47.01 Z' fill='none' stroke='%23000000' stroke-width='6' stroke-miterlimit='10' style='stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));'/%3e%3c/g%3e%3c/svg%3e");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  transform-origin: center;
  transform: rotate(-135deg) scale(1.2);
  margin-left: -10px;
  margin-top: -18px;
}

.page-agent-cursor-filling {
  position: absolute;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3e%3cdefs%3e%3c/defs%3e%3cg xmlns='http://www.w3.org/2000/svg' style='filter: drop-shadow(light-dark(rgba(0, 0, 0, 0.4), rgba(237, 237, 237, 0.4)) 3px 4px 4px);'%3e%3cpath d='M 15 42 L 15 36.99 Q 15 31.99 23.7 31.99 L 28.05 31.99 Q 32.41 31.99 32.41 21.99 L 32.41 17 Q 32.41 12 41.09 16.95 L 76.31 37.05 Q 85 42 76.31 46.95 L 41.09 67.05 Q 32.41 72 32.41 62.01 L 32.41 57.01 Q 32.41 52.01 23.7 52.01 L 19.35 52.01 Q 15 52.01 15 47.01 Z' fill='%23ffffff' stroke='none' style='fill: %23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transform-origin: center;
  transform: rotate(-135deg) scale(1.2);
  margin-left: -10px;
  margin-top: -18px;
}

.page-agent-cursor-ripple {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  margin-left: -50%;
  margin-top: -50%;
}

.page-agent-cursor-ripple:after {
  content: "";
  opacity: 0;
  position: absolute;
  inset: 0;
  border: 4px solid rgba(57, 182, 255, 1);
  border-radius: 50%;
}

.page-agent-cursor.clicking .page-agent-cursor-ripple:after {
  animation: page-agent-cursor-ripple .3s ease-out forwards;
}

@keyframes page-agent-cursor-ripple {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

.page-agent-wrapper.visible {
  opacity: 1;
  transform: translate(-50%) translateY(0);
}

.page-agent-element-highlight {
  position: absolute;
  border: 2px solid var(--color-1);
  background: rgba(57, 182, 255, 0.1);
  border-radius: 4px;
  pointer-events: none;
  z-index: 2147483640;
  transition: all 0.2s ease;
}

.page-agent-element-highlight.active {
  border-color: var(--color-2);
  background: rgba(189, 69, 251, 0.2);
  animation: page-agent-highlight-pulse 0.5s ease-in-out;
}

@keyframes page-agent-highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(189, 69, 251, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(189, 69, 251, 0); }
}
