ai {
  display: block;
  --bg-main: #121315;
  --bg-card: #1a1b1e;
  --text-main: #d1d5db;
  --text-dim: #8b949e;
  --accent-survive: #d97706; 
  --accent-lust: #be185d;    
  --border-color: #2d3139;
  
  background: var(--bg-main) repeating-linear-gradient(0deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 1px, transparent 1px, transparent 2px);
  color: var(--text-main);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
  overflow: hidden;
}

ai hd {
  display: flex;
  background: linear-gradient(90deg, #2d3139, transparent);
  color: var(--accent-survive);
  font-size: 12px;
  font-family: monospace;
  padding: 6px 10px;
  border-left: 3px solid var(--accent-survive);
  margin: -8px -8px 10px -8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

ai text {
  display: block;
  padding: 4px 4px 12px 4px;
  font-size: 15px;
  color: #e5e7eb;
  line-height: 1.6;
}
ai text p { margin: 0 0 8px 0; }

/* 基础折叠面板样式 */
ai details {
  background: #0d0d0f;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-top: 6px;
  overflow: hidden;
}

ai summary {
  background: #1f2126;
  color: #fff;
  padding: 8px 12px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}
ai summary:hover { background: #2a2d35; }
ai summary::-webkit-details-marker { display: none; }

/* NPC专属折叠面板视觉强化 (带有[n]属性) */
ai details[n] summary {
  background: linear-gradient(90deg, #2a101b, #1f2126);
  border-left: 3px solid var(--accent-lust);
  color: #fbcfe8;
}
ai details[n] summary:hover { background: linear-gradient(90deg, #381524, #1f2126); }

/* 记忆区折叠面板视觉强化 (带有[m]属性) */
ai details[m] summary {
  background: linear-gradient(90deg, #102a24, #1f2126);
  border-left: 3px solid #10b981;
  color: #a7f3d0;
}

/* 内部卡片布局 */
ai p[t] {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 10px 8px;
  padding: 26px 8px 8px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  position: relative;
}

ai p[t]::before {
  content: attr(t);
  position: absolute;
  top: 0;
  left: 0;
  font-size: 11px;
  padding: 3px 10px;
  border-bottom-right-radius: 4px;
  font-weight: bold;
}

ai p[t="主角"], ai p[t="营地"] { border-left: 2px solid var(--accent-survive); }
ai p[t="主角"]::before, ai p[t="营地"]::before { background: var(--accent-survive); color: #000; }

ai p[t="档案"] { border-left: 2px solid var(--accent-lust); }
ai p[t="档案"]::before { background: var(--accent-lust); color: #fff; }

ai d {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}
ai d:hover { background: rgba(255,255,255,0.05); color: #e5e7eb; }

ai f { color: #fff; font-weight: bold; }

ai bar {
  display: inline-block;
  width: 65px;
  height: 8px;
  background: #000;
  border-radius: 4px;
  margin: 0 6px;
  vertical-align: middle;
  border: 1px solid #333;
  overflow: hidden;
}
ai v {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(45deg, var(--accent-survive), var(--accent-survive) 4px, #b45309 4px, #b45309 8px);
  animation: scan-bar 2s linear infinite;
}
@keyframes scan-bar {
  from { background-position: 0 0; }
  to { background-position: 11px 0; }
}

/* =========================================
   记忆区 Markdown 表格深度美化与移动端防爆
   ========================================= */
ai details[m] p {
  /* 针对Markdown自动生成的p标签 */
  padding: 0 10px;
  margin: 5px 0;
  color: #9ca3af;
  font-size: 13px;
}

ai table {
  width: calc(100% - 16px);
  margin: 10px 8px;
  border-collapse: collapse;
  display: block;
  overflow-x: auto; /* 允许横向滚动，防止表格撑破父容器 */
  white-space: nowrap; /* 前几列保持单行不折行 */
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

ai th, ai td {
  border: 1px solid var(--border-color);
  padding: 8px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: left;
  vertical-align: top;
}

ai th {
  background: #1f2126;
  color: #fff;
  font-weight: bold;
}

/* 核心：强制表格最后一列（客观事实）换行 */
ai td:last-child {
  white-space: normal; /* 允许换行 */
  min-width: 180px;    /* 保证文字有足够空间 */
  word-wrap: break-word;
  line-height: 1.5;
  color: #d1d5db;
}

/* 表格行悬浮效果 */
ai tr:nth-child(even) { background: rgba(0,0,0,0.2); }
ai tr:hover { background: rgba(16, 185, 129, 0.05); }