ai {
  /* --- 变量定义 --- */
  --bg: #f4f1e9;
  --text: #2a2a2a;
  --primary: #8a2432; /* 主题红，比原色稍暗，更显沉稳 */
  --secondary: #3c4a5d; /* 辅佐蓝灰 */
  --border: #d1c7b8;
  --card-bg: rgba(249, 246, 239, 0.85); /* 卡片背景，带透明度 */
  --quote-bg: rgba(60, 74, 93, 0.05);
  --action-hover: rgba(60, 74, 93, 0.1);
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', serif;
  --font-sans: 'Helvetica Neue', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;

  /* --- 基础样式 --- */
  background-color: var(--bg);
  /* 和风·青海波纹样背景 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23d1c7b8' fill-opacity='0.2'%3E%3Cpath fill-rule='evenodd' d='M0 0h40v40H0V0zm40 40h40v40H40V40z'/%3E%3E%3C/g%3E%3C/svg%3E");
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* --- 页眉：时间地点 & 印章 --- */
ai hd {
  display: block;
  font-size: 13px;
  color: var(--secondary);
  font-family: var(--font-serif);
  padding: 5px 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
ai hd::after {
  content: '鬼';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: var(--bg);
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  border-radius: 3px;
  font-family: var(--font-serif);
}

/* --- 主要叙述文本 --- */
ai tx p {
  margin: 0 0 1em 0;
  padding: 0 5px;
}
ai tx p:last-child {
  margin-bottom: 0;
}

/* --- 卡片式折叠面板 --- */
ai details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 10px 0;
  overflow: hidden;
  transition: all 0.2s ease-in-out;
}
ai details[open] {
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

/* --- 折叠面板标题 --- */
ai summary {
  padding: 10px 15px;
  font-weight: bold;
  cursor: pointer;
  color: var(--secondary);
  font-family: var(--font-serif);
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
  list-style: none; /* 移除默认箭头 */
}
ai summary::-webkit-details-marker { display: none; } /* 兼容Webkit */
ai summary:hover {
  background-color: var(--action-hover);
}
ai details[open] > summary {
  border-bottom: 1px solid var(--border);
  color: var(--primary);
}
/* 标题图标 */
ai summary::before {
  font-size: 1.2em;
}
ai details:nth-of-type(1) > summary::before { content: '📋'; }
ai details:nth-of-type(2) > summary::before { content: '👥'; }
ai details:nth-of-type(3) > summary::before { content: '🌐'; }
ai details:nth-of-type(4) > summary::before { content: '💡'; }

/* --- 卡片内容区域 --- */
ai .panel, ai .char-sheet, ai .actions, ai .sub-panel {
  padding: 15px;
  font-size: 14px;
}
ai .panel p, ai .char-sheet p {
  margin: 0.5em 0;
}

/* --- 自定义内容标签 --- */
/* 节标题 <s> */
ai s {
  display: block;
  font-family: var(--font-serif);
  color: var(--primary);
  font-weight: bold;
  padding-bottom: 4px;
  margin-top: 15px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  width: fit-content;
  max-width: 100%;
}
ai .panel s:first-of-type, ai .char-sheet s:first-of-type {
  margin-top: 0;
}

/* 键值对标签 <t> */
ai t {
  font-weight: bold;
  color: var(--secondary);
  margin-right: 8px;
}

/* 数据行 <d> */
ai d {
  display: block;
  margin-bottom: 6px;
}

/* 引用块 <q> */
ai q {
  display: block;
  background: var(--quote-bg);
  padding: 8px 12px;
  border-left: 3px solid var(--border);
  border-radius: 0 4px 4px 0;
  margin: 10px 0;
  font-style: italic;
}

/* --- 行动选项 --- */
ai .actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
ai .actions a {
  display: block;
  padding: 10px 15px;
  background-color: var(--quote-bg);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text);
}
ai .actions a:hover {
  background-color: var(--action-hover);
  border-color: var(--border);
  color: var(--primary);
  transform: translateY(-1px);
}

/* --- 嵌套的Details --- */
ai .sub-detail {
  margin: 15px 0 5px 0;
  background: transparent;
  border: 1px dashed var(--border);
}
ai .sub-detail summary {
  padding: 8px 12px;
  font-size: 1em;
  color: var(--secondary);
}
ai .sub-detail[open] > summary {
  color: var(--primary);
}
ai .sub-panel {
  padding: 0 12px 12px 12px;
}