:root {
  --xy-ai-ink: #12263a;
  --xy-ai-panel: #ffffff;
  --xy-ai-line: #e6edf5;
  --xy-ai-muted: #66798c;
  --xy-ai-accent: #0f766e;
  --xy-ai-accent-soft: #e6f5f3;
  --xy-ai-wa: #25d366;
  --xy-ai-shadow: 0 18px 48px rgba(18, 38, 58, 0.18);
}

.xy-ai-launcher-wrap {
  position: fixed;
  /* 始终避开右侧 Online 侧栏（约 46px），避免图标被挡住 */
  right: 70px;
  bottom: 24px;
  /* 高于侧栏 Online / mfoot，避免被盖住 */
  z-index: 100050;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  color: var(--xy-ai-ink);
  box-sizing: border-box;
}

/* 隔离主题全局 button / input 样式（如 zzshe.css uppercase、深色底） */
.xy-ai-launcher-wrap *,
.xy-ai-launcher-wrap *::before,
.xy-ai-launcher-wrap *::after {
  box-sizing: border-box;
}

.xy-ai-launcher-wrap button,
.xy-ai-launcher-wrap input,
.xy-ai-launcher-wrap textarea,
.xy-ai-launcher-wrap a {
  text-transform: none !important;
  letter-spacing: normal !important;
  font-family: inherit !important;
  box-shadow: none;
  background-image: none;
}

.xy-ai-launcher-wrap.is-open {
  /* 展开时保持同一右偏移，避免与 Online 重叠 */
  right: 70px;
}

.xy-ai-launcher-btn {
  position: relative;
  width: 58px !important;
  height: 58px !important;
  min-width: 58px !important;
  min-height: 58px !important;
  padding: 0 !important;
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #0f2237 0%, #1e3a5f 100%) !important;
  background-color: #0f2237 !important;
  color: #fff !important;
  font-size: 0 !important;
  line-height: 1 !important;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(15, 34, 55, 0.35) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  outline: none;
  /* 覆盖主题 button{overflow:hidden}，否则圆角裁切绿点/脉冲 */
  overflow: visible !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  animation: xyAiFloat 3s ease-in-out infinite;
}

.xy-ai-launcher-wrap.is-open .xy-ai-launcher-btn {
  animation: none;
}

.xy-ai-launcher-btn:hover {
  animation: none;
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 40px rgba(15, 34, 55, 0.45);
}

.xy-ai-launcher-btn:active {
  transform: scale(0.96);
}

.xy-ai-launcher-btn .icon-open,
.xy-ai-launcher-btn .icon-close {
  position: absolute;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.xy-ai-launcher-btn .icon-open {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.xy-ai-launcher-btn .icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.xy-ai-launcher-wrap.is-open .xy-ai-launcher-btn .icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.xy-ai-launcher-wrap.is-open .xy-ai-launcher-btn .icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* 右上角在线绿点 + 扩散脉冲（对齐 naikegifts） */
.xy-ai-online-ping {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #ffffff;
  z-index: 2;
  pointer-events: none;
}

.xy-ai-online-ping::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: xyAiPingGreen 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.xy-ai-launcher-wrap.is-open .xy-ai-online-ping {
  display: none;
}

@keyframes xyAiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes xyAiPingGreen {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.xy-ai-panel {
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  background: var(--xy-ai-panel);
  border: 1px solid var(--xy-ai-line);
  border-radius: 18px;
  box-shadow: var(--xy-ai-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.xy-ai-launcher-wrap.is-open .xy-ai-panel {
  display: flex;
}

.xy-ai-header {
  background: linear-gradient(135deg, #12263a 0%, #1c3d57 100%);
  color: #fff;
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.xy-ai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.xy-ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f59e0b;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.xy-ai-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.xy-ai-status {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  gap: 6px;
}

.xy-ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.xy-ai-header-tools {
  display: flex;
  gap: 6px;
}

.xy-ai-tool-btn {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  background-color: rgba(255, 255, 255, 0.12) !important;
  color: rgba(255, 255, 255, 0.92) !important;
  font-size: 0 !important;
  line-height: 1 !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.xy-ai-tool-btn svg {
  display: block;
  flex-shrink: 0;
}

.xy-ai-tool-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.xy-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f7fafc;
}

.xy-ai-welcome {
  background: #fff;
  border: 1px solid var(--xy-ai-line);
  border-radius: 14px;
  padding: 14px;
}

.xy-ai-welcome h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--xy-ai-ink);
}

.xy-ai-welcome p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--xy-ai-muted);
  line-height: 1.5;
}

.xy-ai-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.xy-ai-badge {
  font-size: 11px;
  color: var(--xy-ai-accent);
  background: var(--xy-ai-accent-soft);
  border-radius: 999px;
  padding: 4px 8px;
}

.xy-ai-wa-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eafff2;
  color: #146c43;
  text-decoration: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
  transition: background 0.2s ease, color 0.2s ease;
}

.xy-ai-wa-chip:hover {
  background: #d8f8e7;
  color: #0f5c38;
}

.xy-ai-wa-ico {
  flex-shrink: 0;
  color: #25d366;
  display: block;
}

.xy-ai-suggestions {
  display: grid;
  gap: 8px;
}

.xy-ai-pill-btn {
  width: 100% !important;
  text-align: left !important;
  border: 1px solid var(--xy-ai-line) !important;
  background: #fff !important;
  background-color: #fff !important;
  border-radius: 10px !important;
  padding: 10px 12px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: var(--xy-ai-ink) !important;
  cursor: pointer;
  line-height: 1.4 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

.xy-ai-pill-btn:hover {
  border-color: #b7d8d4 !important;
  background: #f3fbfa !important;
  background-color: #f3fbfa !important;
  color: var(--xy-ai-ink) !important;
}

.xy-ai-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

.xy-ai-row.user {
  justify-content: flex-end;
}

.xy-ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(15, 34, 55, 0.08);
}

.xy-ai-msg-avatar.bot {
  background: #f59e0b;
}

.xy-ai-msg-avatar.user {
  background: #0f2237;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(226, 232, 240, 0.95);
}

.xy-ai-bubble {
  max-width: calc(100% - 48px);
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.xy-ai-row.assistant .xy-ai-bubble {
  background: #fff;
  border: 1px solid var(--xy-ai-line);
  color: var(--xy-ai-ink);
  border-top-left-radius: 4px;
}

.xy-ai-row.user .xy-ai-bubble {
  background: var(--xy-ai-ink);
  color: #fff;
  border-top-right-radius: 4px;
}

.xy-ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.xy-ai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: xyAiBlink 1.2s infinite ease-in-out;
}

.xy-ai-typing i:nth-child(2) { animation-delay: 0.15s; }
.xy-ai-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes xyAiBlink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.xy-ai-footer {
  border-top: 1px solid var(--xy-ai-line);
  background: #fff;
  padding: 10px;
}

.xy-ai-input-row {
  display: flex;
  align-items: flex-end;
}

.xy-ai-input-shell {
  flex: 1;
  display: flex !important;
  align-items: flex-end !important;
  gap: 6px;
  min-height: 46px !important;
  height: auto !important;
  max-height: none !important;
  border: 1px solid #cfe0ea;
  border-radius: 14px;
  background: #f8fafc;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.xy-ai-input-shell:focus-within {
  border-color: #8eb8cf;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(100, 149, 180, 0.12);
}

/* 覆盖主题全局 textarea 高度，默认单行；增高仅由 JS 行内 height 控制 */
.xy-ai-launcher-wrap textarea.xy-ai-input,
.xy-ai-input {
  flex: 1 1 auto !important;
  width: auto !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 110px !important;
  resize: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 8px 0 !important;
  margin: 0 !important;
  background: transparent !important;
  font: inherit !important;
  font-size: 13.5px !important;
  line-height: 1.45 !important;
  color: var(--xy-ai-ink) !important;
  outline: none !important;
  box-shadow: none !important;
  overflow-y: auto !important;
  field-sizing: fixed !important;
}

.xy-ai-input:focus {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

.xy-ai-send {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  flex-shrink: 0;
  border: 0 !important;
  border-radius: 10px !important;
  background: #dbeaf3 !important;
  background-color: #dbeaf3 !important;
  color: #5b7c94 !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 1 !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.xy-ai-send:hover:not(:disabled) {
  background: #c9e0ee !important;
  background-color: #c9e0ee !important;
  color: #3f647d !important;
}

.xy-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.xy-ai-send svg {
  display: block !important;
  width: 18px !important;
  height: 18px !important;
  fill: none !important;
  stroke: currentColor !important;
  color: inherit !important;
  flex-shrink: 0;
}

.xy-ai-launcher-btn svg,
.xy-ai-tool-btn svg {
  stroke: currentColor !important;
  fill: none !important;
  color: inherit !important;
}

.xy-ai-note {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
}

@media (max-width: 480px) {
  .xy-ai-launcher-wrap,
  .xy-ai-launcher-wrap.is-open {
    right: 14px;
    /* 避开手机底栏 mfoot */
    bottom: 78px;
  }

  .xy-ai-panel {
    width: calc(100vw - 20px);
    height: calc(100vh - 160px);
  }
}
