.agent-widget {
  position: fixed;
  z-index: 9000;
  right: 26px;
  bottom: 22px;
  color: #f8fbff;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.agent-widget[hidden], .agent-widget__panel[hidden] { display: none !important; }
.agent-widget__trigger {
  position: relative;
  display: flex;
  width: 120px;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.agent-widget.is-dragging .agent-widget__trigger { cursor: grabbing; }
.agent-widget__robot {
  position: relative;
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 8px 19px rgba(15, 42, 165, .45));
  transition: transform .25s ease;
}
.agent-widget__trigger:hover .agent-widget__robot,
.agent-widget__trigger:focus-visible .agent-widget__robot { transform: translateY(-5px); }
.agent-widget__fallback, .agent-widget__animation { position: absolute; inset: 0; width: 100%; height: 100%; }
.agent-widget__fallback { display: block; object-fit: contain; }
.agent-widget__robot.is-animated .agent-widget__fallback { opacity: 0; }
.agent-widget__animation { pointer-events: none; }
.agent-widget__animation svg { width: 100% !important; height: 100% !important; }
.agent-widget__label {
  display: grid;
  min-width: 100px;
  height: 35px;
  place-items: center;
  padding: 0 12px;
  border: 1px solid rgba(167, 218, 255, .65);
  border-radius: 999px;
  background: linear-gradient(130deg, rgba(18, 32, 113, .96), rgba(34, 17, 122, .94));
  box-shadow: inset 0 1px 8px rgba(99, 208, 255, .34), 0 9px 24px rgba(5, 8, 50, .4);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .07em;
  white-space: nowrap;
}
.agent-widget__label-text { transition: opacity .16s ease, transform .16s ease; }
.agent-widget__label-text.is-changing { opacity: 0; transform: translateY(-4px); }
.agent-widget__peek { display: none; }
.agent-widget.is-tucked .agent-widget__robot,
.agent-widget.is-tucked .agent-widget__label { visibility: hidden; }
.agent-widget.is-tucked .agent-widget__peek {
  position: absolute;
  display: grid;
  width: 40px;
  height: 56px;
  place-items: center;
  top: 50%;
  border: 1px solid rgba(167, 218, 255, .7);
  border-radius: 14px;
  background: linear-gradient(130deg, #172b8e, #25106d);
  box-shadow: 0 7px 22px rgba(5, 8, 50, .45);
  color: #d9faff;
  font: 700 28px/1 sans-serif;
  transform: translateY(-50%);
}
.agent-widget[data-tucked-side="left"] .agent-widget__peek { right: 0; border-radius: 0 14px 14px 0; }
.agent-widget[data-tucked-side="right"] .agent-widget__peek { left: 0; border-radius: 14px 0 0 14px; }
.agent-widget[data-tucked-side="top"] .agent-widget__peek,
.agent-widget[data-tucked-side="bottom"] .agent-widget__peek {
  left: 50%;
  width: 56px;
  height: 40px;
  transform: translateX(-50%);
}
.agent-widget[data-tucked-side="top"] .agent-widget__peek { top: auto; bottom: 0; border-radius: 0 0 14px 14px; }
.agent-widget[data-tucked-side="bottom"] .agent-widget__peek { top: 0; border-radius: 14px 14px 0 0; }
.agent-widget__trigger:focus-visible, .agent-widget__close:focus-visible,
.agent-widget__form button:focus-visible, .agent-widget__form input:focus-visible {
  outline: 2px solid #76ddff;
  outline-offset: 3px;
}
.agent-widget__panel {
  position: absolute;
  right: 0;
  bottom: 138px;
  display: flex;
  width: min(390px, calc(100vw - 28px));
  height: min(590px, calc(100dvh - 165px));
  min-height: 270px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(120, 190, 255, .46);
  border-radius: 23px;
  background: linear-gradient(160deg, #101557, #0a0e3e 58%, #090b2a);
  box-shadow: 0 20px 65px rgba(0, 0, 0, .52), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.agent-widget__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid rgba(165, 206, 255, .16);
  background: rgba(61, 67, 171, .18);
}
.agent-widget__avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.agent-widget__title { display: block; font-size: 16px; font-weight: 700; line-height: 1.25; }
.agent-widget__quota { display: block; margin-top: 4px; color: rgba(232, 241, 255, .66); font-size: 11px; line-height: 1.3; }
.agent-widget__quota[hidden] { display: none; }
.agent-widget__close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: 24px/1 sans-serif;
  cursor: pointer;
}
.agent-widget__thread {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 16px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(111, 176, 255, .4) transparent;
}
.agent-widget__notice {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 13px;
  border-top: 1px solid rgba(165, 206, 255, .12);
  color: rgba(232, 241, 255, .76);
  font-size: 22px;
  line-height: 1.4;
}
.agent-widget__status { flex:0 0 auto; margin:0; padding:6px 13px; color:#ffd2a1; font-size:14px; line-height:1.4; }
.agent-widget__status[hidden] { display:none; }
.agent-widget__welcome {
  align-self: flex-start;
  max-width: 89%;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid rgba(67, 206, 255, .54);
  border-radius: 5px 17px 17px 17px;
  background: linear-gradient(115deg, #0647e7, #243cdb 64%, #4b20c8);
  color: #fff;
  font-size: 14px;
  line-height: 1.6;
}
.agent-widget__message {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
.agent-widget__message--user { align-self: flex-end; border-bottom-right-radius: 4px; background: #484b9e; }
.agent-widget__message--assistant { align-self: flex-start; border: 1px solid rgba(72, 199, 255, .48); border-top-left-radius: 4px; background: linear-gradient(115deg, #0647e7, #2926ca); }
.agent-widget__message--assistant .agent-project-link { color: #cbf8ff; font-weight: 700; text-decoration: underline; text-decoration-color: rgba(203, 248, 255, .75); text-underline-offset: .18em; -webkit-tap-highlight-color: transparent; }
.agent-widget__message--assistant .agent-project-link:focus-visible { outline: 2px solid #cbf8ff; outline-offset: 2px; border-radius: 2px; }
.agent-widget__message--thinking { color: rgba(255, 255, 255, .7); }
.agent-widget__form {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-top: 1px solid rgba(165, 206, 255, .16);
}
.agent-widget__form input {
  min-width: 0;
  height: 43px;
  flex: 1;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid rgba(127, 206, 255, .55);
  border-radius: 14px;
  background: rgba(26, 39, 119, .85);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}
.agent-widget__form input::placeholder { color: rgba(255, 255, 255, .56); }
.agent-widget__form button {
  height: 43px;
  padding: 0 15px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #32dbff, #3683ff);
  color: #061543;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.agent-widget__form button:disabled { cursor: wait; opacity: .6; }
@media (max-width: 600px) {
  .agent-widget { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .agent-widget__trigger { width: 100px; }
  .agent-widget__robot { width: 72px; height: 72px; }
  .agent-widget__label { min-width: 82px; height: 32px; padding-inline: 8px; font-size: 13px; }
  .agent-widget__panel { right: 0; bottom: 115px; height: min(560px, calc(100dvh - 145px)); }
}
@media (prefers-reduced-motion: reduce) {
  .agent-widget__robot, .agent-widget__label-text { transition: none; }
}
