/* ═══════════════════════════════════════════════════
   THALES: City of the Arena — a03b 游戏内回复美化CSS
   基于 V0.x 风格延续，并补足 a03b 新输出结构
   适用平台: SillyTavern / 酒馆 / 其他前端
   默认选择器: .is-assistant
   如前端选择器不同，请将 .is-assistant 替换为对应消息容器
   ═══════════════════════════════════════════════════ */

/* ===== 根变量 ===== */
.is-assistant {
  --blood: #ff2d2d;
  --blood-soft: rgba(255, 45, 45, 0.12);
  --blood-line: rgba(255, 45, 45, 0.18);
  --cyan: #00f0ff;
  --cyan-soft: rgba(0, 240, 255, 0.08);
  --gold: #d4a574;
  --gold-soft: rgba(212, 165, 116, 0.08);
  --orange: #ff9e3d;
  --violet: #d98fff;
  --bg: rgba(10, 10, 18, 0.92);
  --bg-soft: rgba(255, 255, 255, 0.02);
  --bg-hover: rgba(255, 45, 45, 0.05);
  --txt: #c4c4c4;
  --txt-soft: #a8a8a8;
  --txt-dim: #8d8d96;
  --glow-r: 0 0 12px rgba(255, 45, 45, 0.25);
  --glow-c: 0 0 10px rgba(0, 240, 255, 0.2);
  font-family: 'Courier New', 'Consolas', 'SF Mono', monospace;
  color: var(--txt);
  font-size: 14.5px;
  line-height: 1.78;
}

/* ===== 正文 ===== */
.is-assistant p {
  margin-bottom: 14px;
  text-indent: 2em;
  color: #d0d0d0;
  line-height: 1.85;
}

/* ===== 用户侧引用样式（最小增补） ===== */
.is-user {
  font-family: 'Courier New', 'Consolas', 'SF Mono', monospace;
  color: var(--txt);
  font-size: 14.5px;
  line-height: 1.78;
  border-left: 3px solid #f0d24a;
  padding-left: 12px;
}

.is-user p {
  margin-bottom: 14px;
  text-indent: 2em;
  color: #d0d0d0;
  line-height: 1.85;
}

.is-assistant strong,
.is-assistant b {
  color: var(--blood);
  text-shadow: 0 0 6px rgba(255, 45, 45, 0.22);
}

.is-assistant em,
.is-assistant i {
  color: #9d9da6;
  font-style: italic;
}

/* ===== 对话染色 ===== */
.is-assistant .player-speech {
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.28);
}

.is-assistant .male-speech {
  color: var(--orange);
  text-shadow: 0 0 6px rgba(255, 158, 61, 0.18);
}

.is-assistant .female-speech {
  color: var(--violet);
  text-shadow: 0 0 6px rgba(217, 143, 255, 0.18);
}

.is-assistant .broadcast {
  color: var(--gold);
  font-style: italic;
  font-size: 0.9em;
  text-shadow: 0 0 6px rgba(212, 165, 116, 0.28);
}

/* ===== 通用 details ===== */
.is-assistant details {
  background: var(--bg);
  border: 1px solid rgba(255, 45, 45, 0.15);
  border-left: 3px solid var(--blood);
  border-radius: 3px;
  margin: 12px 0;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.is-assistant details:hover {
  border-color: rgba(255, 45, 45, 0.32);
}

.is-assistant details[open] {
  border-color: rgba(255, 45, 45, 0.4);
  box-shadow: 0 0 15px rgba(255, 45, 45, 0.08);
}

.is-assistant summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: bold;
  font-size: 0.9em;
  letter-spacing: 1.5px;
  color: var(--blood);
  background: rgba(255, 45, 45, 0.06);
  border-bottom: 1px solid rgba(255, 45, 45, 0.1);
  list-style: none;
  user-select: none;
  transition: all 0.2s ease;
}

.is-assistant summary::-webkit-details-marker {
  display: none;
}

.is-assistant summary::before {
  content: '▸ ';
  font-size: 0.85em;
  display: inline-block;
}

.is-assistant details[open] > summary::before {
  content: '▾ ';
}

.is-assistant summary:hover {
  background: rgba(255, 45, 45, 0.12);
  text-shadow: 0 0 10px rgba(255, 45, 45, 0.36);
}

.is-assistant details > *:not(summary) {
  padding: 0 14px;
}

.is-assistant details > p:last-child,
.is-assistant details > div:last-child,
.is-assistant details > ol:last-child,
.is-assistant details > ul:last-child,
.is-assistant details > table:last-child {
  padding-bottom: 12px;
}

/* ===== 顶部栏 / 入狱档案 / 直播间的小幅区分 ===== */
.is-assistant details:has(> summary:first-child:is(:where(*))) > summary {
  position: relative;
}

.is-assistant details:has(> summary:first-child) > summary {
  background-image: linear-gradient(90deg, rgba(255, 45, 45, 0.06), transparent 72%);
}

/* 让顶部栏更冷色，直播间更金色。
   依赖 :has 和 summary 文本中的 emoji；若前端不支持，仍保持通用样式。 */
.is-assistant details:has(> summary:where(:not(:empty))) > summary {
  color: var(--blood);
}

/* ===== 状态栏内部文本 ===== */
.is-assistant details p {
  text-indent: 0;
  margin-bottom: 6px;
  font-size: 0.88em;
  line-height: 1.68;
  color: var(--txt-soft);
}

.is-assistant details strong {
  color: var(--cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, 0.18);
  font-size: 0.92em;
}

/* a03b 中新增了大量“字段 + 说明”的单行内容，单独加强可读性 */
.is-assistant details > *:not(summary) {
  word-break: break-word;
}

/* 玩家状态、目标状态、NPC档案、入狱档案中常见的项目行 */
.is-assistant details ul,
.is-assistant details ol {
  padding-left: 18px;
  margin: 6px 0;
}

.is-assistant details ul li,
.is-assistant details ol li {
  margin-bottom: 4px;
  font-size: 0.88em;
  line-height: 1.66;
  color: var(--txt-soft);
}

/* 让“· 项目 — 描述”一类文本块更稳 */
.is-assistant details li strong {
  color: var(--gold);
  text-shadow: none;
}

/* ===== 表格 ===== */
.is-assistant table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82em;
  margin: 8px 0;
  background: rgba(0, 0, 0, 0.3);
}

.is-assistant th {
  background: rgba(255, 45, 45, 0.12);
  color: var(--blood);
  padding: 8px 6px;
  text-align: left;
  font-size: 0.85em;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 45, 45, 0.2);
  white-space: nowrap;
}

.is-assistant td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #a0a0a0;
  vertical-align: top;
}

.is-assistant tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

.is-assistant tr:hover td {
  background: rgba(0, 240, 255, 0.03);
}

/* 记忆区表格继续保留金色分化 */
.is-assistant details:last-of-type th {
  color: var(--gold);
  background: rgba(212, 165, 116, 0.08);
  border-bottom-color: rgba(212, 165, 116, 0.15);
}

/* ===== 分隔线 ===== */
.is-assistant hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 45, 45, 0.3), transparent);
  margin: 16px 0;
}

/* ===== 行动建议 ===== */
.is-assistant h2 {
  color: var(--blood);
  font-size: 1em;
  letter-spacing: 2px;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 45, 45, 0.15);
}

.is-assistant ol {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.is-assistant ol li {
  background: rgba(10, 10, 18, 0.8);
  border: 1px solid rgba(255, 45, 45, 0.1);
  border-left: 3px solid rgba(255, 45, 45, 0.4);
  padding: 10px 14px;
  margin-bottom: 6px;
  border-radius: 2px;
  font-size: 0.9em;
  color: #b0b0b0;
  transition: all 0.25s ease;
  cursor: default;
}

.is-assistant ol li:hover {
  border-color: rgba(255, 45, 45, 0.4);
  border-left-color: var(--blood);
  background: rgba(255, 45, 45, 0.06);
  color: #d0d0d0;
  box-shadow: 0 0 12px rgba(255, 45, 45, 0.08);
  transform: translateX(4px);
}

/* ===== 行内代码 / 引用 ===== */
.is-assistant code {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.15);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.88em;
  color: var(--cyan);
}

.is-assistant blockquote {
  border-left: 3px solid var(--gold);
  background: rgba(212, 165, 116, 0.05);
  padding: 8px 14px;
  margin: 10px 0;
  font-style: italic;
  color: #b8a080;
  font-size: 0.88em;
}

/* ===== a03b 新增辅助类 ===== */
.is-assistant .danger-glow {
  color: var(--blood) !important;
  text-shadow: 0 0 8px rgba(255, 45, 45, 0.6);
  animation: dangerPulse 1.5s ease-in-out infinite;
}

.is-assistant .safe-glow {
  color: var(--cyan) !important;
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}

.is-assistant .gold-glow {
  color: var(--gold) !important;
  text-shadow: 0 0 6px rgba(212, 165, 116, 0.4);
}

.is-assistant .status-pos {
  color: #4ec9b0;
  font-weight: 600;
  background: rgba(78, 201, 176, 0.08);
  padding: 0 4px;
  border-radius: 2px;
}

.is-assistant .status-neg {
  color: var(--blood);
  font-weight: 600;
  background: rgba(255, 45, 45, 0.08);
  padding: 0 4px;
  border-radius: 2px;
}

.is-assistant .status-env {
  color: var(--gold);
  font-weight: 600;
  background: rgba(212, 165, 116, 0.08);
  padding: 0 4px;
  border-radius: 2px;
}

.is-assistant .flaw-none {
  color: #777;
}

.is-assistant .flaw-minor {
  color: var(--gold);
}

.is-assistant .flaw-major {
  color: var(--blood);
  font-weight: bold;
}

.is-assistant .flaw-fatal {
  color: var(--blood);
  font-weight: bold;
  text-shadow: var(--glow-r);
  animation: pulseFatal 1s ease-in-out infinite;
}

.is-assistant .execution {
  color: var(--blood);
  font-weight: bold;
  font-size: 1.08em;
  text-align: center;
  padding: 8px;
  background: rgba(255, 45, 45, 0.1);
  border: 1px solid rgba(255, 45, 45, 0.3);
  border-radius: 4px;
  margin: 8px 0;
  text-shadow: var(--glow-r);
}

.is-assistant .broadcast-commentary {
  font-size: 0.92em;
  color: var(--gold);
  font-style: italic;
  border-left: 3px solid rgba(212, 165, 116, 0.35);
  padding-left: 10px;
  margin: 6px 0;
}

.is-assistant .broadcast-danmaku {
  font-size: 0.82em;
  color: #9797a1;
  padding-left: 14px;
  position: relative;
}

.is-assistant .broadcast-danmaku::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--gold);
}

.is-assistant .npc-alive {
  color: #4ec9b0;
}

.is-assistant .npc-dead {
  color: var(--blood);
  text-decoration: line-through;
  opacity: 0.65;
}

.is-assistant .npc-unknown {
  color: #888;
  font-style: italic;
}

.is-assistant .memory-title {
  color: var(--gold);
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
  margin: 8px 0 4px;
}

/* a03b 中状态说明变长，给出更适合的说明块类 */
.is-assistant .state-note,
.is-assistant .trait-note,
.is-assistant .archive-note {
  display: inline-block;
  color: var(--txt-soft);
  line-height: 1.6;
}

/* ===== 动画 ===== */
@keyframes dangerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

@keyframes pulseFatal {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* ===== 可选扫描线 ===== */
/*
.is-assistant::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
}
*/

/* ===== 响应式 ===== */
@media screen and (max-width: 768px) {
  .is-assistant {
    font-size: 13.5px;
    line-height: 1.72;
  }

  .is-assistant p {
    text-indent: 1.5em;
    margin-bottom: 10px;
  }

  .is-assistant details {
    margin: 8px 0;
  }

  .is-assistant summary {
    padding: 8px 10px;
    font-size: 0.85em;
  }

  .is-assistant details > *:not(summary) {
    padding: 0 10px;
  }

  .is-assistant table {
    font-size: 0.75em;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .is-assistant th,
  .is-assistant td {
    padding: 5px 4px;
    white-space: nowrap;
  }

  .is-assistant ol li {
    padding: 8px 10px;
    font-size: 0.85em;
  }

  .is-assistant ol li:hover {
    transform: none;
  }
}
