/* ===== 幻想乡·红魔馆主题 — 全CSS ===== */
/* 容器: <ai> 所有样式均基于此限定作用域 */

/* ---------- 基础变量与字体 ---------- */
ai {
  --bg-main: #1a0f0f;
  --bg-card: #251515;
  --bg-darker: #100808;
  --red-wine: #6b1a1a;
  --red-blood: #8b1a1a;
  --red-rose: #a83232;
  --gold: #d4a052;
  --gold-light: #e8c06a;
  --gold-pale: #f0d890;
  --silver: #b8b0a8;
  --text-main: #e0d5c5;
  --text-dim: #9a8a7a;
  --border-color: #4a2a1a;
  --shadow-color: rgba(120, 30, 30, 0.3);

  /* 数值专用色 */
  --love-color: #ff6b8a;
  --caution-color: #5a9aff;
  --sleep-color: #b088d0;
  --lust-color: #ff3355;
  --drunk-color: #e8a030;

  /* 字体 */
  font-family: 'Georgia', 'Times New Roman', 'Noto Serif SC', '思源宋体', serif;
  color: var(--text-main);
  display: block;
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 8px;
  line-height: 1.6;
  font-size: 15px;
  background: 
    radial-gradient(ellipse at 10% 20%, rgba(80,20,20,0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(40,10,50,0.3) 0%, transparent 50%),
    var(--bg-main);
}

/* ---------- 时间/地点/天气 摘要头 ---------- */
ai hd {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--gold-pale);
  letter-spacing: 1px;
  padding: 6px 8px;
  margin: 0 0 6px 0;
  background: linear-gradient(135deg, rgba(40,15,15,0.8), rgba(30,10,20,0.8));
  border: 1px solid var(--border-color);
  border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1;
  font-family: 'Cinzel', 'Georgia', serif;
  text-shadow: 0 0 8px rgba(180,80,30,0.4);
  position: relative;
}

/* 蝙蝠装饰 - 左右各一只 */
ai hd::before,
ai hd::after {
  content: "🦇";
  font-size: 14px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
  animation: batFloat 3s ease-in-out infinite;
}
ai hd::before { left: 6px; }
ai hd::after { right: 6px; }
@keyframes batFloat {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-60%) scale(1.05); }
}

/* ---------- 正文 ---------- */
ai article {
  display: block;
  padding: 8px 10px;
  margin: 0 0 8px 0;
  border-left: 2px solid var(--red-wine);
  background: rgba(20,10,10,0.4);
  font-size: 14px;
  line-height: 1.7;
  text-indent: 0;
}
ai article p {
  margin: 4px 0;
}
ai article p:first-child {
  margin-top: 0;
}

/* ---------- details 通用折叠栏 ---------- */
ai details {
  display: block;
  margin: 4px 0;
  border: 1px solid #3a2020;
  background: var(--bg-card);
  transition: border-color 0.3s;
}
ai details[open] {
  border-color: var(--red-rose);
  box-shadow: 0 0 12px rgba(168,50,50,0.15);
}

/* ---------- summary 折叠头 ---------- */
ai details summary {
  display: block;
  padding: 6px 10px 6px 30px;
  font-size: 14px;
  font-family: 'Cinzel', 'Georgia', serif;
  color: var(--gold);
  background: linear-gradient(135deg, #2a1515, #1a0a0a);
  cursor: pointer;
  user-select: none;
  position: relative;
  border-bottom: 1px solid transparent;
  transition: all 0.3s;
  min-height: 20px;
  line-height: 20px;
}
ai details[open] summary {
  border-bottom-color: #3a2020;
  color: var(--gold-light);
  text-shadow: 0 0 10px rgba(200,150,60,0.3);
}
ai details summary:hover {
  background: linear-gradient(135deg, #3a1a1a, #2a1010);
}
ai details summary::marker {
  content: none;
  display: none;
}

/* 自定义折叠符号 —— 蝙蝠翼 */
ai details summary::before {
  content: "▶";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--red-rose);
  transition: transform 0.3s;
}
ai details[open] summary::before {
  content: "▼";
  transform: translateY(-50%) rotate(0deg);
}

/* 符号装饰 */
ai details:nth-child(2) summary::after { content: " 🦇"; }
ai details:nth-child(3) summary::after { content: " 🩸"; }
ai details:nth-child(4) summary::after { content: " 🧠"; }
ai details:nth-child(5) summary::after { content: " 🎯"; }
ai details:nth-child(6) summary::after { content: " 📜"; }

/* ---------- 内部结构 ---------- */
ai details p[t] {
  display: block;
  padding: 6px 10px 8px;
  margin: 0;
}
ai details d {
  display: block;
  padding: 1px 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
}
ai details d q {
  color: var(--gold-pale);
  font-style: italic;
  font-size: 13px;
  margin-right: 2px;
  opacity: 0.85;
}
ai details d strong {
  color: var(--gold-light);
  font-weight: 600;
}

/* ---------- 名字高亮 ---------- */
ai f {
  display: block;
  font-size: 18px;
  font-family: 'Cinzel Decorative', 'Georgia', serif;
  text-align: center;
  padding: 4px 0 6px;
  letter-spacing: 1px;
}
ai f[lv="1"] {
  color: var(--gold-light);
  text-shadow: 0 0 15px rgba(200,150,60,0.3);
}
ai f[lv="2"] {
  color: #e05050;
  text-shadow: 0 0 15px rgba(200,50,50,0.3);
}

/* ---------- 数值系统 — 每项独立颜色 ---------- */
ai span[tp="love"] { 
  color: var(--love-color); 
  font-weight: bold;
  text-shadow: 0 0 6px rgba(255,107,138,0.3);
}
ai span[tp="caution"] { 
  color: var(--caution-color); 
  font-weight: bold;
  text-shadow: 0 0 6px rgba(90,154,255,0.25);
}
ai span[tp="sleep"] { 
  color: var(--sleep-color); 
  font-weight: bold;
  text-shadow: 0 0 6px rgba(176,136,208,0.25);
}
ai span[tp="lust"] { 
  color: var(--lust-color); 
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255,51,85,0.35);
  animation: lustPulse 2s ease-in-out infinite;
}
@keyframes lustPulse {
  0%, 100% { text-shadow: 0 0 6px rgba(255,51,85,0.3); }
  50% { text-shadow: 0 0 14px rgba(255,51,85,0.6); }
}
ai span[tp="drunk"] { 
  color: var(--drunk-color); 
  font-weight: bold;
  text-shadow: 0 0 6px rgba(232,160,48,0.3);
}

/* ---------- 生理期颜色映射 ---------- */
ai span[pd="1"] { 
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}
/* 安全期 - 绿 */
ai:has(span[pd="1"]:is(:contains("安全"), :not(:contains("危险"):not(:contains("经期"))))) span[pd="1"] {
  color: #6a9a6a;
}
/* 危险期 - 橙 */
ai:has(span[pd="1"]:contains("危险")) span[pd="1"] {
  color: #d4a040;
}
/* 经期中 - 深红闪烁 */
ai:has(span[pd="1"]:contains("经期")) span[pd="1"] {
  color: #cc3355;
  animation: periodFlash 1.5s ease-in-out infinite;
}
@keyframes periodFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ---------- 怀孕概率颜色映射 ---------- */
ai span[pd="2"] { font-weight: bold; }
/* 0% */
ai span[pd="2"]:is(:contains("0%"), :contains("0 %")) { color: #888; }
/* 1-20% */
ai span[pd="2"]:not(:contains("0")):is(:contains("1"),:contains("2"),:contains("3"),:contains("4"),:contains("5"),:contains("6"),:contains("7"),:contains("8"),:contains("9"),:contains("10"),:contains("11"),:contains("12"),:contains("13"),:contains("14"),:contains("15"),:contains("16"),:contains("17"),:contains("18"),:contains("19"),:contains("20")) {
  color: #e8a0a0;
}
/* 21-50% */
ai span[pd="2"]:is(:contains("21"),:contains("22"),:contains("23"),:contains("24"),:contains("25"),:contains("26"),:contains("27"),:contains("28"),:contains("29"),:contains("30"),:contains("31"),:contains("32"),:contains("33"),:contains("34"),:contains("35"),:contains("36"),:contains("37"),:contains("38"),:contains("39"),:contains("40"),:contains("41"),:contains("42"),:contains("43"),:contains("44"),:contains("45"),:contains("46"),:contains("47"),:contains("48"),:contains("49"),:contains("50")) {
  color: #e06060;
}
/* 51-80% */
ai span[pd="2"]:is(:contains("51"),:contains("52"),:contains("53"),:contains("54"),:contains("55"),:contains("56"),:contains("57"),:contains("58"),:contains("59"),:contains("60"),:contains("61"),:contains("62"),:contains("63"),:contains("64"),:contains("65"),:contains("66"),:contains("67"),:contains("68"),:contains("69"),:contains("70"),:contains("71"),:contains("72"),:contains("73"),:contains("74"),:contains("75"),:contains("76"),:contains("77"),:contains("78"),:contains("79"),:contains("80")) {
  color: #cc3355;
  text-shadow: 0 0 8px rgba(200,50,80,0.4);
}
/* 81-100% */
ai span[pd="2"]:is(:contains("81"),:contains("82"),:contains("83"),:contains("84"),:contains("85"),:contains("86"),:contains("87"),:contains("88"),:contains("89"),:contains("90"),:contains("91"),:contains("92"),:contains("93"),:contains("94"),:contains("95"),:contains("96"),:contains("97"),:contains("98"),:contains("99"),:contains("100")) {
  color: #aa2266;
  text-shadow: 0 0 12px rgba(170,34,102,0.5);
  animation: pregAlert 1.2s ease-in-out infinite;
}
@keyframes pregAlert {
  0%, 100% { text-shadow: 0 0 8px rgba(170,34,102,0.4); }
  50% { text-shadow: 0 0 18px rgba(170,34,102,0.7); }
}

/* ---------- 身体状态区 — 保留色气风格 ---------- */
ai details d:has(+ d:has(q:contains("身体状态"))) q[contains="身体状态"],
ai details d q:contains("身体状态") {
  color: var(--red-blood);
  font-weight: bold;
  font-size: 14px;
}
ai details d:has(br) {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}
/* 身体状态中的关键词高亮 */
ai details d:has(br) {
  color: #d0b0a0;
}
/* 性经验/子嗣行正常 */
ai details d:has(q:contains("性经验")),
ai details d:has(q:contains("子嗣")) {
  color: var(--text-dim);
}

/* ---------- 行动推荐 — 差异化排列 ---------- */
ai p[t="action"] {
  counter-reset: action-num;
}
ai p[t="action"] d {
  counter-increment: action-num;
  padding: 3px 6px 3px 28px;
  margin: 2px 0;
  position: relative;
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: all 0.25s;
}
ai p[t="action"] d::before {
  content: counter(action-num) ". ";
  position: absolute;
  left: 4px;
  color: var(--red-rose);
  font-weight: bold;
  font-family: 'Cinzel', serif;
}
/* 行动1 - 战斗/主动 红色调 */
ai p[t="action"] d:nth-child(1) {
  border-left-color: #e04040;
  background: linear-gradient(90deg, rgba(200,40,40,0.1), transparent);
}
/* 行动2 - 社交 金色调 */
ai p[t="action"] d:nth-child(2) {
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(200,160,60,0.08), transparent);
}
/* 行动3 - 探索 蓝色调 */
ai p[t="action"] d:nth-child(3) {
  border-left-color: #4a7aaa;
  background: linear-gradient(90deg, rgba(60,100,160,0.08), transparent);
}
/* 行动4 - 休憩/特殊 紫色调 */
ai p[t="action"] d:nth-child(4) {
  border-left-color: #8a5aaa;
  background: linear-gradient(90deg, rgba(130,70,160,0.08), transparent);
}
/* 行动5 - 色诱/亲密 粉红色调 */
ai p[t="action"] d:nth-child(5) {
  border-left-color: #d06080;
  background: linear-gradient(90deg, rgba(200,60,100,0.1), transparent);
}
ai p[t="action"] d:hover {
  background: rgba(200,150,80,0.06);
}

/* ---------- 记忆区 — 表格风格 ---------- */
ai p[t="memory"] {
  font-family: 'Courier New', monospace;
  font-size: 13px;
}
ai p[t="memory"] q {
  display: block;
  color: var(--gold-pale);
  font-family: 'Georgia', serif;
  font-size: 14px;
  margin: 4px 0 2px;
  border-bottom: 1px dashed #3a2a1a;
}
ai p[t="memory"] d {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  white-space: pre;
  overflow-x: auto;
}

/* ---------- 传闻区 ---------- */
ai p[t="rumor"] d {
  padding: 2px 0;
  font-size: 14px;
  color: var(--text-dim);
}
ai p[t="rumor"] d:first-child {
  margin-top: 2px;
}

/* ---------- 角落小蝙蝠装饰 (靠容器伪元素) ---------- */
ai::before,
ai::after {
  content: "";
  position: fixed;
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.15;
  pointer-events: none;
  z-index: -1;
}
ai::before {
  top: 8px;
  left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23d4a052' d='M12 2C10 6 8 10 8 14c0 2 1 4 3 5l1-3c0-1 0-2 1-2 1 0 1 1 1 2l1 3c2-1 3-3 3-5 0-4-2-8-4-12h-2zM5 7c-1 3-2 6-2 9 0 2 1 4 2 5 1-2 1-5 2-8l-1-6h-1zM19 7c1 3 2 6 2 9 0 2-1 4-2 5-1-2-1-5-2-8l1-6h1z'/%3E%3C/svg%3E");
}
ai::after {
  bottom: 8px;
  right: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23d4a052' d='M12 2C10 6 8 10 8 14c0 2 1 4 3 5l1-3c0-1 0-2 1-2 1 0 1 1 1 2l1 3c2-1 3-3 3-5 0-4-2-8-4-12h-2zM5 7c-1 3-2 6-2 9 0 2 1 4 2 5 1-2 1-5 2-8l-1-6h-1zM19 7c1 3 2 6 2 9 0 2-1 4-2 5-1-2-1-5-2-8l1-6h1z'/%3E%3C/svg%3E");
  transform: scaleX(-1);
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  ai { padding: 3px 4px; font-size: 14px; }
  ai hd { font-size: 12px; padding: 4px 6px; }
  ai details summary { font-size: 13px; padding: 5px 8px 5px 28px; }
  ai details d { font-size: 13px; }
  ai p[t="memory"] d { font-size: 11px; }
}

/* ---------- 呼吸光晕 — 底栏暗纹 ---------- */
ai::after {
  animation: bgGlow 6s ease-in-out infinite alternate;
}
@keyframes bgGlow {
  0% { opacity: 0.1; }
  100% { opacity: 0.2; }
}