/* 外部容器 - 避免全局污染 */
ai {
  --pink: #ff1493;
  --pink-light: #ffb6c1;
  --pink-pale: #fff0f5;
  --purple: #9400d3;
  --purple-light: #8a2be2;
  --blue: #4682b4;
  --orange: #ffa500;
  --grad-pink: linear-gradient(135deg, #ffb6c1 0%, #ff69b4 100%);
  --grad-purple: linear-gradient(135deg, #e0218a 0%, #c71585 100%);
  --grad-blue: linear-gradient(135deg, #87ceeb 0%, #4682b4 100%);
  --shadow: 0 2px 8px rgba(255,20,147,0.15);
  display: block;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}

/* 思维链 - 警示橙黄主题 */
ai details.c {
  background: linear-gradient(135deg, #fff9e6 0%, #ffe4b5 100%);
  border: 2px solid var(--orange);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
  position: relative;
}
ai details.c::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--orange) 0%, #ff6347 100%);
  border-radius: 8px 0 0 8px;
}
ai details.c summary {
  font-weight: bold;
  font-size: 16px;
  color: var(--orange);
  cursor: pointer;
  margin-bottom: 8px;
  padding-left: 8px;
}
ai details.c summary:hover {
  color: #ff6347;
  text-shadow: 0 0 8px rgba(255,165,0,0.4);
}
ai details.c d {
  display: block;
  padding: 6px 8px;
  margin: 4px 0;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: rgba(255,255,255,0.6);
}
ai details.c d[w] {
  border-left-color: #ffa500;
  background: rgba(255,245,230,0.8);
}
ai details.c d[s] {
  border-left-color: #ff1493;
  background: rgba(255,240,245,0.8);
  font-size: 13px;
}
ai details.c d[s]::before {
  content: "🔞 ";
}
ai details.c d[r] {
  border-left-color: #8a2be2;
  background: rgba(248,248,255,0.8);
  font-weight: bold;
  margin-top: 8px;
}

/* 时间地点头部 */
ai hd {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--grad-pink);
  padding: 10px 15px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
ai hd::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 10%, transparent 10%);
  background-size: 20px 20px;
  animation: sparkle 20s linear infinite;
}
@keyframes sparkle {
  0% { transform: translate(0, 0); }
  100% { transform: translate(20px, 20px); }
}

/* 正文区域 */
ai article {
  background: #ffffff;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid #ffe4e1;
  box-shadow: var(--shadow);
  line-height: 1.8;
}
ai article p {
  margin: 10px 0;
  text-indent: 2em;
}

/* 记忆回廊 */
ai details.m {
  background: var(--pink-pale);
  border: 1px solid var(--pink-light);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  position: relative;
}
ai details.m::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--grad-pink);
  border-radius: 8px 0 0 8px;
}
ai details.m summary {
  font-weight: bold;
  font-size: 16px;
  color: var(--pink);
  cursor: pointer;
  padding-left: 8px;
  margin-bottom: 8px;
}
ai details.m summary:hover {
  color: #c71585;
  text-shadow: 0 0 8px rgba(255,20,147,0.3);
}
ai details.m p {
  margin: 8px 0;
  padding: 8px;
  border-radius: 6px;
}
ai details.m p[t="短期"] {
  background: rgba(255,182,193,0.15);
}
ai details.m p[t="短期"]::before {
  content: "⚡ 短期记忆 (60-80字/条)";
  display: block;
  font-weight: bold;
  color: var(--pink);
  margin-bottom: 6px;
  font-size: 13px;
}
ai details.m p[t="长期"] {
  background: rgba(138,43,226,0.1);
}
ai details.m p[t="长期"]::before {
  content: "📚 长期归档 (300-350字/条)";
  display: block;
  font-weight: bold;
  color: var(--purple);
  margin-bottom: 6px;
  font-size: 13px;
}
ai details.m d {
  display: block;
  padding: 5px 8px;
  margin: 4px 0;
  background: rgba(255,255,255,0.6);
  border-left: 3px solid var(--pink-light);
  border-radius: 4px;
  font-size: 13px;
}

/* 主控玩家面板 */
ai details.p {
  background: #f8f8ff;
  border: 1px solid var(--purple-light);
  border-left: 5px solid var(--purple-light);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
ai details.p summary {
  font-weight: bold;
  font-size: 16px;
  color: var(--purple);
  cursor: pointer;
  margin-bottom: 8px;
}
ai details.p summary:hover {
  color: var(--purple-light);
  text-shadow: 0 0 8px rgba(138,43,226,0.3);
}
ai details.p d {
  display: block;
  padding: 4px 0;
  border-bottom: 1px solid rgba(138,43,226,0.1);
  font-size: 14px;
}
ai details.p d:last-child {
  border-bottom: none;
}
ai details.p d[g] {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid var(--purple-light);
  border-bottom: none;
}
ai details.p d[g] span {
  display: inline-block;
  background: linear-gradient(135deg, #e6e6fa 0%, #d8bfd8 100%);
  padding: 4px 10px;
  margin: 3px 5px 3px 0;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--purple-light);
}
ai details.p f {
  display: inline-block;
  font-weight: bold;
  color: var(--purple);
  margin-right: 8px;
  min-width: 80px;
}
ai details.p f::after {
  content: "：";
}

/* 女性NPC面板 */
ai details.f {
  background: #ffebf0;
  border: 1px solid #e0218a;
  border-left: 5px solid #e0218a;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  position: relative;
}
ai details.f::after {
  content: "💕";
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  opacity: 0.3;
  animation: heartbeat 2s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
ai details.f summary {
  font-weight: bold;
  font-size: 16px;
  color: #e0218a;
  cursor: pointer;
  margin-bottom: 8px;
}
ai details.f summary:hover {
  color: #c71585;
  text-shadow: 0 0 8px rgba(224,33,138,0.4);
}
ai details.f d {
  display: block;
  padding: 4px 0;
  border-bottom: 1px solid rgba(224,33,138,0.1);
  font-size: 14px;
}
ai details.f d:last-child {
  border-bottom: none;
}
ai details.f f {
  display: inline-block;
  font-weight: bold;
  color: #e0218a;
  margin-right: 8px;
  min-width: 70px;
}
ai details.f f::after {
  content: "：";
}
ai details.f p[t="体感"] {
  margin-top: 10px;
  padding: 10px;
  background: rgba(255,105,180,0.08);
  border-radius: 6px;
  border: 1px dashed #ff69b4;
}
ai details.f p[t="体感"]::before {
  content: "💋 躯体敏感雷达";
  display: block;
  font-weight: bold;
  color: #ff1493;
  margin-bottom: 6px;
  font-size: 15px;
}
ai details.f p[t="体感"] d {
  border-bottom: none;
  padding: 3px 0;
  font-size: 13px;
}
ai details.f p[t="体感"] f {
  min-width: 45px;
  color: #ff1493;
}

/* 男性NPC面板 */
ai details.n {
  background: #e6f2ff;
  border: 1px solid var(--blue);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
ai details.n summary {
  font-weight: bold;
  font-size: 16px;
  color: var(--blue);
  cursor: pointer;
  margin-bottom: 8px;
}
ai details.n summary:hover {
  color: #5cacee;
  text-shadow: 0 0 8px rgba(70,130,180,0.3);
}
ai details.n d {
  display: block;
  padding: 4px 0;
  border-bottom: 1px solid rgba(70,130,180,0.1);
  font-size: 14px;
}
ai details.n d:last-child {
  border-bottom: none;
}
ai details.n f {
  display: inline-block;
  font-weight: bold;
  color: var(--blue);
  margin-right: 8px;
  min-width: 70px;
}
ai details.n f::after {
  content: "：";
}

/* 后台NPC推演 */
ai details.b {
  background: #f0f8ff;
  border: 1px solid #b0d4f1;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
ai details.b summary {
  font-weight: bold;
  font-size: 16px;
  color: var(--blue);
  cursor: pointer;
  margin-bottom: 6px;
}
ai details.b summary:hover {
  color: #5cacee;
}
ai details.b d {
  display: block;
  padding: 5px 8px;
  margin: 4px 0;
  background: rgba(255,255,255,0.5);
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  font-size: 13px;
}

/* 行动按钮区 */
ai div.act {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 15px;
  padding: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 8px;
}
ai btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
ai btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}
ai btn:hover::before {
  width: 300px;
  height: 300px;
}
ai btn[a] {
  background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
}
ai btn[a]:hover {
  background: linear-gradient(135deg, #ff1493 0%, #c71585 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255,20,147,0.4);
}
ai btn[b] {
  background: linear-gradient(135deg, #8a2be2 0%, #9400d3 100%);
}
ai btn[b]:hover {
  background: linear-gradient(135deg, #9400d3 0%, #8b008b 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(138,43,226,0.4);
}
ai btn[c] {
  background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
}
ai btn[c]:hover {
  background: linear-gradient(135deg, #ff8c00 0%, #ff7f00 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255,165,0,0.4);
}

/* 用户输入框美化 */
.user-message, [class*="user"] > *, p:has(> strong:first-child) {
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f2ff 100%) !important;
  border-left: 5px solid var(--blue) !important;
  border-radius: 8px !important;
  padding: 12px 15px !important;
  margin: 10px 0 !important;
  box-shadow: 0 2px 8px rgba(70,130,180,0.15) !important;
  position: relative !important;
  line-height: 1.6 !important;
  color: #333 !important;
}
.user-message::before, [class*="user"] > *::before {
  content: "👤";
  position: absolute;
  left: -25px;
  top: 10px;
  font-size: 20px;
  opacity: 0.6;
}

/* 响应式优化 */
@media (max-width: 600px) {
  ai {
    font-size: 13px;
  }
  ai hd {
    flex-direction: column;
    gap: 5px;
    font-size: 14px;
    padding: 8px 12px;
  }
  ai div.act {
    flex-direction: column;
    gap: 8px;
  }
  ai btn {
    width: 100%;
  }
  ai details.c d[s] {
    font-size: 12px;
  }
  ai details.p f, ai details.f f, ai details.n f {
    min-width: 60px;
  }
}

/* 通用details折叠动画 */
ai details summary {
  user-select: none;
  transition: all 0.3s ease;
}
ai details[open] summary {
  margin-bottom: 10px;
}

/* markdown标签适配（平台自动转换） */
ai h2 {
  color: var(--pink);
  border-bottom: 2px solid var(--pink-light);
  padding-bottom: 5px;
  margin: 15px 0 10px 0;
}
ai strong {
  color: var(--purple);
  font-weight: bold;
}
ai em {
  color: var(--blue);
  font-style: italic;
}
ai li {
  margin: 5px 0;
  padding-left: 5px;
}
ai blockquote {
  border-left: 4px solid var(--pink-light);
  padding-left: 10px;
  margin: 10px 0;
  color: #666;
  background: var(--pink-pale);
  border-radius: 4px;
  padding: 8px 10px;
}