/* ============ 明暗变量系统 ============ */
@media (prefers-color-scheme: light) {
  ai {
    --bg: #fdf6f0;
    --bg2: #f5eae4;
    --bg3: #ede0d8;
    --border: #ddc8be;
    --border2: #c9a8b8;
    --accent: #9b6fa0;
    --accent2: #c9748a;
    --gold: #b8860b;
    --text: #2a1a22;
    --text2: #5a3d4a;
    --text3: #8a6070;
    --nsfw-bg: #fdeef2;
    --nsfw-border: #e8a0b0;
    --nsfw-text: #c0304a;
    --risk-low: #3a8a4a;
    --risk-high: #c0304a;
    --tag-bg: #eedde8;
    --tag-text: #7a3060;
    --choice-bg: #f8f0f4;
    --choice-hover: #eedde8;
    --choice-border: #d4a8c0;
    --mem-bg: #f8f3f0;
    --shadow: rgba(120,60,80,0.10);
    --glow: rgba(180,100,140,0.13);
    --hd-bg: linear-gradient(135deg,#f8eae4 0%,#f0dce8 100%);
    --stg-bg: linear-gradient(90deg,#c9748a,#9b6fa0);
  }
}
@media (prefers-color-scheme: dark) {
  ai {
    --bg: #100c14;
    --bg2: #1a1220;
    --bg3: #231828;
    --border: #3a2a40;
    --border2: #6a3a58;
    --accent: #c9a0dc;
    --accent2: #e8c4b8;
    --gold: #f0d080;
    --text: #f0eaea;
    --text2: #c8b8c0;
    --text3: #907888;
    --nsfw-bg: #1e0e18;
    --nsfw-border: #7a2848;
    --nsfw-text: #f08098;
    --risk-low: #60c878;
    --risk-high: #f08098;
    --tag-bg: #2a1830;
    --tag-text: #c9a0dc;
    --choice-bg: #18101e;
    --choice-hover: #281828;
    --choice-border: #5a3060;
    --mem-bg: #14101a;
    --shadow: rgba(0,0,0,0.40);
    --glow: rgba(200,120,180,0.10);
    --hd-bg: linear-gradient(135deg,#1e1228 0%,#180e20 100%);
    --stg-bg: linear-gradient(90deg,#8a3060,#6a30a0);
  }
}

/* ============ 容器基础 ============ */
ai {
  display: block;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 24px var(--shadow);
  border: 1px solid var(--border);
  font-family: "PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  position: relative;
}
ai::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 18px,
      rgba(180,120,160,0.03) 18px,
      rgba(180,120,160,0.03) 19px
    );
  pointer-events: none;
  z-index: 0;
}
ai > * { position: relative; z-index: 1; }

/* ============ 顶栏 ============ */
ai hd {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 14px 8px;
  background: var(--hd-bg);
  border-bottom: 1px solid var(--border);
  position: relative;
}
ai hd::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,transparent,var(--accent),var(--accent2),transparent);
  opacity: 0.6;
}
ai hd t {
  font-size: 12px;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  white-space: nowrap;
}
ai hd loc {
  display: block;
  width: 100%;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.03em;
  margin-top: 2px;
}
ai hd stg {
  display: inline-block;
  background: var(--stg-bg);
  color: #fff;
  font-size: 11px;
  border-radius: 20px;
  padding: 1px 10px;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ============ 正文 ============ */
ai text {
  display: block;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
ai text p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.9;
  font-size: 14.5px;
  text-align: justify;
}
ai text p:first-child::first-letter {
  font-size: 2em;
  float: left;
  line-height: 1;
  margin: 2px 4px 0 0;
  color: var(--accent2);
  font-weight: 700;
}
ai text p:last-child { margin-bottom: 0; }

/* ============ details 折叠卡片 ============ */
ai details {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
ai details:last-of-type { border-bottom: none; }
ai details summary {
  list-style: none;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  background: var(--bg2);
  letter-spacing: 0.04em;
  transition: background 0.2s;
}
ai details summary:hover { background: var(--bg3); }
ai details summary::-webkit-details-marker { display: none; }
ai details summary::before {
  content: "▶";
  font-size: 9px;
  color: var(--text3);
  transition: transform 0.25s;
  display: inline-block;
}
ai details[open] summary::before { transform: rotate(90deg); }

/* ============ 信息行 ============ */
ai sec {
  display: block;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
ai sec::before {
  content: "";
  position: absolute;
  left: 6px; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg,var(--accent),transparent);
  border-radius: 2px;
  opacity: 0.5;
}
ai sec:last-child { border-bottom: none; }
ai row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}
ai row:last-child { border-bottom: none; }
ai k {
  font-size: 11px;
  color: var(--accent);
  min-width: 40px;
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.03em;
}
ai v {
  font-size: 13px;
  color: var(--text2);
  flex: 1;
}
ai v b { color: var(--text); font-weight: 700; }
ai v em {
  font-style: normal;
  color: var(--accent2);
  font-size: 12.5px;
}
ai v.r b { color: var(--risk-high); }
ai v.g b { color: var(--risk-low); }

/* ============ 🔞 区块 ============ */
ai sec.nsfw {
  background: var(--nsfw-bg);
  border-left: 3px solid var(--nsfw-border);
  padding-left: 12px;
}
ai sec.nsfw::before { background: linear-gradient(180deg,var(--nsfw-border),transparent); }
ai sec.nsfw k { color: var(--nsfw-text); }
ai sec.nsfw v { color: var(--text2); }
ai nt {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--nsfw-text);
  padding: 3px 0 4px;
  letter-spacing: 0.05em;
}
ai row.nsfw k { color: var(--nsfw-text); }

/* ============ 记忆区 ============ */
ai mem {
  display: block;
  font-size: 12px;
  color: var(--gold);
  padding: 6px 14px 4px;
  background: var(--mem-bg);
}
ai mt {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 14px 2px;
  letter-spacing: 0.04em;
}
ai table {
  width: calc(100% - 28px);
  margin: 4px 14px 8px;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
ai th {
  background: linear-gradient(90deg,var(--bg3),var(--bg2));
  color: var(--accent);
  font-weight: 700;
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
ai td {
  padding: 4px 8px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
ai tr:last-child td { border-bottom: none; }
ai tr:nth-child(even) td { background: rgba(180,120,160,0.04); }

/* ============ 选项区 ============ */
ai ch {
  display: block;
  padding: 10px 12px 12px;
  background: var(--bg2);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
ai c {
  display: block;
  background: var(--choice-bg);
  border: 1px solid var(--choice-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  position: relative;
  overflow: hidden;
  line-height: 1.5;
}
ai c::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 8px 0 0 8px;
}
ai c:hover {
  background: var(--choice-hover);
  border-color: var(--accent);
  color: var(--text);
}
ai c:hover::before { opacity: 1; }
ai c:first-child::after,
ai c:nth-child(2)::after {
  content: "";
}

/* ============ 微动效 ============ */
@media (prefers-reduced-motion: no-preference) {
  ai hd stg {
    animation: stg-pulse 3s ease-in-out infinite;
  }
  @keyframes stg-pulse {
    0%,100% { box-shadow: 0 0 0 0 transparent; }
    50% { box-shadow: 0 0 8px 2px var(--glow); }
  }
  ai sec.nsfw {
    animation: nsfw-glow 4s ease-in-out infinite;
  }
  @keyframes nsfw-glow {
    0%,100% { box-shadow: inset 0 0 0 0 transparent; }
    50% { box-shadow: inset 2px 0 12px var(--glow); }
  }
}