:root {
  --jz-ink: #43352a;
  --jz-ink-soft: #6d5942;
  --jz-seal: #9e3b2b;
  --jz-seal-deep: #7e2f22;
  --jz-gold: #b98a44;
  --jz-gold-soft: #d9bc86;
}

.ai-ball,
.ai-dialog,
.ai-dialog * {
  box-sizing: border-box;
}

.ai-ball,
.ai-dialog {
  font-family: "KaiTi", "STKaiti", "楷体", "SimSun", serif;
  color: var(--jz-ink);
}

.ai-ball[hidden],
.ai-dialog[hidden] {
  display: none !important;
}

.ai-ball {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 1000;
  width: 62px;
  height: 62px;
  border: 2px solid var(--jz-gold-soft);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #c05a44, var(--jz-seal) 60%, var(--jz-seal-deep));
  color: #fdf7e9;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(126, 47, 34, 0.45);
  animation: ballPulse 2.6s ease-in-out infinite;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear 0s;
  user-select: none;
}

.ai-ball:hover { transform: scale(1.08); }
.ai-ball.active {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  animation: none;
  transform: scale(0.94);
  transition-delay: 0s, 0s, .2s;
}

@keyframes ballPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(126, 47, 34, 0.45), 0 0 0 0 rgba(158, 59, 43, 0.35); }
  50% { box-shadow: 0 6px 18px rgba(126, 47, 34, 0.45), 0 0 0 14px rgba(158, 59, 43, 0); }
}

.ai-dialog {
  position: fixed;
  right: 26px;
  bottom: 102px;
  z-index: 1000;
  width: 400px;
  max-width: calc(100vw - 32px);
  aspect-ratio: 810 / 1080;
  max-height: min(72vh, 620px);
  background: url("https://assets.rsxr.eu.cc/mobile-ui/assets/panel-dialog.png") center / 100% 100% no-repeat;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.ai-dialog.open { opacity: 1; transform: none; pointer-events: auto; }

.ai-head {
  position: absolute;
  top: 3.2%;
  left: 8%;
  right: 5%;
  height: 10%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--jz-gold-soft);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #c05a44, var(--jz-seal));
  color: #fdf7e9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex: none;
}

.ai-name { font-size: 19px; letter-spacing: 3px; font-weight: bold; flex: 1; }

.ai-icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--jz-ink-soft);
  font: inherit;
  font-size: 19px;
  cursor: pointer;
}

.ai-icon-btn:hover { color: var(--jz-seal); background: rgba(185, 138, 68, 0.15); }

.ai-msgs {
  position: absolute;
  top: 15.5%;
  right: 8%;
  bottom: 20%;
  left: 8%;
  overflow-y: auto;
  padding: 4px 2px;
}

.ai-msg { display: flex; margin-bottom: 10px; }
.ai-msg.user { justify-content: flex-end; }

.ai-bubble {
  max-width: 86%;
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.ai .ai-bubble {
  border: 1px solid var(--jz-gold-soft);
  border-left: 4px solid var(--jz-gold);
  border-top-left-radius: 2px;
  background: rgba(255, 253, 246, 0.9);
}

.ai-msg.ai .ai-bubble strong {
  color: var(--jz-ink);
  font-weight: 700;
}

.ai-msg.user .ai-bubble {
  border: 1px solid rgba(158, 59, 43, 0.35);
  border-right: 4px solid var(--jz-seal);
  border-top-right-radius: 2px;
  background: rgba(158, 59, 43, 0.12);
}

.ai-input-row {
  position: absolute;
  right: 9%;
  bottom: 46px;
  left: 9%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-input-row input {
  flex: 1;
  height: 100%;
  min-width: 0;
  padding: 0 16px;
  border: 1px solid var(--jz-gold-soft);
  border-radius: 20px;
  outline: none;
  background: rgba(255, 253, 246, 0.92);
  font: inherit;
  font-size: 15px;
}

.ai-input-row input:focus { border-color: var(--jz-gold); }

.ai-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--jz-gold-soft);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #c05a44, var(--jz-seal));
  color: #fdf7e9;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
}

.ai-send:hover { filter: brightness(1.1); }

.ai-disclaimer {
  position: absolute;
  right: 9%;
  bottom: 24px;
  left: 9%;
  overflow: hidden;
  color: rgba(109, 89, 66, 0.78);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

@media (max-width: 900px) {
  .ai-dialog { right: 12px; bottom: 92px; }
  .ai-ball { right: 16px; bottom: 16px; }
}
