/* ═══ B平台表格修正（自动注入）═══ */
.rili-markdown-renderer table { display:table!important; table-layout:auto!important; width:100%!important; border-collapse:collapse!important; }
.rili-markdown-renderer table caption { display:table-caption!important; caption-side:top!important; text-align:center!important; padding:8px!important; }
.rili-markdown-renderer thead { display:table-header-group!important; }
.rili-markdown-renderer tbody { display:table-row-group!important; }
.rili-markdown-renderer tr { display:table-row!important; }
.rili-markdown-renderer th, .rili-markdown-renderer td { display:table-cell!important; }

/* ═══ B平台按钮组保护（自动注入 — 防止按钮消失）═══
   原理：B平台消息操作按钮结构为：
   .flex.items-center.gap-1.ml-auto (hover显隐包装)
     └── .bg-muted.rounded.flex.p-0.5 (按钮组容器)
           └── button.rounded-full.size-7 (单个按钮)
   以下规则使用高specificity + !important确保按钮
   不被任何转换后/透传的CSS规则意外隐藏
   ═══════════════════════════════════════════════ */
/* 按钮组容器保护 */
.w-full.h-full.flex.group .bg-muted.rounded.flex.p-0\.5,
.is-user .bg-muted.rounded.flex.p-0\.5,
.is-assistant .bg-muted.rounded.flex.p-0\.5 {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible !important;
  position: relative !important;
  width: auto !important;
  height: auto !important;
  max-height: none !important;
  pointer-events: auto !important;
  clip: auto !important;
  clip-path: none !important;
}
/* 单个按钮保护 */
.w-full.h-full.flex.group .bg-muted.rounded.flex.p-0\.5 > button,
.is-user .bg-muted.rounded.flex.p-0\.5 > button,
.is-assistant .bg-muted.rounded.flex.p-0\.5 > button {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: relative !important;
  clip: auto !important;
  clip-path: none !important;
}
/* hover显隐包装层保护 — 仅保留B平台原生的opacity过渡 */
.flex.items-center.gap-1.ml-auto.md\:opacity-0.group-hover\:opacity-100 {
  visibility: visible !important;
  display: flex !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
/* 操作行保护 */
.flex.w-full.items-center.justify-between.gap-2.px-2 {
  display: flex !important;
  visibility: visible !important;
  overflow: visible !important;
}

/* ========================================
   星幕状态栏 · 浅色星幕主题 · 黑色字体
   全部自定义标签已改用 class（.f, .d, .skill, .equip 等）
   保留毛玻璃、发光动效、所有布局和细节
   ======================================== */

/* ===== 1. 全局容器 ===== */
.starry-sky {
  display: block;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a2e;
  word-break: break-word;
  background: linear-gradient(145deg, #f0f4fe, #e8ecfa);
  border-radius: 18px;
  padding: 6px 10px 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ===== 2. 面板基础 ===== */
.starry-sky .status-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.starry-sky .panel-section {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(79, 172, 254, 0.15);
  border-radius: 14px;
  padding: 8px 14px 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
}

.starry-sky .panel-section[open] {
  border-color: rgba(79, 172, 254, 0.4);
  box-shadow: 0 6px 24px rgba(79, 172, 254, 0.08), inset 0 1px 0 #fff;
}

/* ===== 3. Summary ===== */
.starry-sky .panel-section summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: #1a1a2e;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  user-select: none;
}

.starry-sky .panel-section summary::-webkit-details-marker { display: none; }

.starry-sky .panel-section summary .icon-starburst {
  display: inline-block;
  font-size: 14px;
  color: #c47a1a;
  transition: transform 0.3s ease;
}

.starry-sky .panel-section[open] summary .icon-starburst {
  transform: rotate(90deg);
  color: #3a7eb0;
}

/* ===== 4. 字段排版（使用 .f 和 .d） ===== */
.starry-sky .stat-block {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.starry-sky .stat-block:last-child { border-bottom: none; }

/* .f 标签后加冒号 */
.starry-sky .stat-block .f::after,
.starry-sky .stat .f::after {
  content: "：";
  color: #6a7b9c;
  margin-right: 2px;
}

/* .f 与 .d 的颜色 */
.starry-sky .stat-block .f,
.starry-sky .stat .f {
  font-weight: 600;
  color: #2c3e50;
}
.starry-sky .stat-block .d,
.starry-sky .stat .d {
  color: #000000;
  font-weight: 400;
}

/* ===== 5. 网格 ===== */
.starry-sky .grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  padding: 6px 0;
}
.starry-sky .grid-2col .stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 0;
}

/* ===== 6. 子列表 ===== */
.starry-sky .sub-list { margin-top: 6px; padding: 4px 0; }
.starry-sky .sub-list > .f {
  display: block !important;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}
.starry-sky .sub-list ul,
.starry-sky .sub-list ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.starry-sky .sub-list li {
  padding: 3px 0 3px 12px;
  position: relative;
  color: #1a1a2e;
  border-bottom: 1px solid rgba(0, 0, 0, 0.02);
}
.starry-sky .sub-list li::before {
  content: "⋆";
  position: absolute;
  left: 0;
  color: rgba(79, 172, 254, 0.5);
}

/* ===== 7. skill / equip 单独金色 ===== */
.starry-sky .skill,
.starry-sky .equip {
  color: #c47a1a !important;
  font-weight: 600 !important;
}

/* ===== 8. AP 条 ===== */
.starry-sky .ap-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1a1a2e;
}
.starry-sky .ap-bar::before {
  content: "";
  display: inline-block;
  width: 60px;
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ===== 9. R值 / 侵蚀 ===== */
.starry-sky .r-value {
  font-weight: 700;
  color: #c47a1a;
  animation: pulse-glow-light 2s ease-in-out infinite;
}
.starry-sky .erosion-index {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
.starry-sky .erosion-index:is(:contains("安全"), :contains("低风险")) {
  color: #2a6b9e;
  background: rgba(79, 172, 254, 0.08);
}
.starry-sky .erosion-index:is(:contains("中风险")) {
  color: #b8860b;
  background: rgba(245, 166, 35, 0.08);
}
.starry-sky .erosion-index:is(:contains("高危"), :contains("临界")) {
  color: #b22222;
  background: rgba(255, 107, 107, 0.08);
  animation: danger-pulse-light 1s ease-in-out infinite;
}

/* ===== 10. 警告闪烁 ===== */
.starry-sky .warning-glint {
  border-left: 3px solid rgba(200, 50, 50, 0.3);
  padding-left: 10px;
  animation: danger-border-light 2s ease-in-out infinite;
}

/* ===== 11. 记忆表格 ===== */
.starry-sky .memory-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin-top: 4px;
  overflow-x: auto;
  display: block;
}
.starry-sky .memory-grid thead {
  background: rgba(79, 172, 254, 0.06);
}
.starry-sky .memory-grid th {
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}
.starry-sky .memory-grid td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.02);
  color: #1a1a2e;
}

/* ===== 12. NPC 身体细节 ===== */
.starry-sky .npc-body-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.starry-sky .npc-body-detail .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
  font-size: 0.92em;
}
.starry-sky .npc-body-detail .stat .f {
  font-size: 0.85em;
  color: #4a5b6e;
}
.starry-sky .npc-body-detail .stat + .stat::before {
  content: "|";
  color: rgba(0, 0, 0, 0.1);
  margin-right: 6px;
}

/* ===== 13. 日记 ===== */
.starry-sky .diary-entry {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  border-left: 3px solid rgba(196, 122, 26, 0.3);
}
.starry-sky .diary-date {
  font-weight: 600;
  color: #b8860b;
  font-size: 0.9em;
}
.starry-sky .diary-entry blockquote {
  margin: 4px 0 0;
  padding: 0;
  font-style: italic;
  color: #1a1a2e;
  border: none;
}

/* ===== 14. 聊天消息 ===== */
.starry-sky .chat-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.starry-sky .msg {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.93em;
  max-width: 90%;
}
.starry-sky .msg.incoming {
  background: #eef2f7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  align-self: flex-start;
}
.starry-sky .msg.outgoing {
  background: #fcf5e6;
  border: 1px solid rgba(196, 122, 26, 0.2);
  align-self: flex-end;
}
.starry-sky .msg .sender {
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.85em;
}
.starry-sky .msg .timestamp {
  font-size: 0.75em;
  color: rgba(0, 0, 0, 0.3);
  margin-left: 6px;
}

/* ===== 15. 信号强度 ===== */
.starry-sky .signal-strength {
  font-size: 0.8em;
  margin-left: 6px;
  font-weight: 600;
}
.starry-sky .signal-strength:is(:contains("强"), :contains("清晰")) { color: #2a6b9e; }
.starry-sky .signal-strength:is(:contains("中"), :contains("不稳定")) { color: #b8860b; }
.starry-sky .signal-strength:is(:contains("弱"), :contains("模糊")) { color: #b22222; }

/* ===== 16. 四象 ===== */
.starry-sky .element.fire { color: #c0392b; }
.starry-sky .element.water { color: #2980b9; }
.starry-sky .element.air { color: #5d8aa8; }
.starry-sky .element.earth { color: #5a7a5a; }
.starry-sky .element-value { color: #1a1a2e; margin-left: 4px; }

/* ===== 17. 成就 ===== */
.starry-sky .achievement-tier {
  padding: 6px 0;
  animation: slide-in 0.4s ease both;
}
.starry-sky .achievement-tier:nth-child(2) { animation-delay: 0.1s; }
.starry-sky .achievement-tier:nth-child(3) { animation-delay: 0.2s; }
.starry-sky .achievement-tier.gold .f { color: #c47a1a; }
.starry-sky .achievement-tier.silver .f { color: #7f8c8d; }
.starry-sky .achievement-tier.bronze .f { color: #a0522d; }

/* ===== 18. 行动推荐 ===== */
.starry-sky .action-list {
  list-style: none;
  padding: 0;
  counter-reset: action-counter;
}
.starry-sky .action-item {
  counter-increment: action-counter;
  padding: 5px 0 5px 28px;
  position: relative;
  color: #1a1a2e;
}
.starry-sky .action-item::before {
  content: counter(action-counter);
  position: absolute;
  left: 0;
  top: 5px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75em;
  font-weight: 700;
  color: #2c3e50;
}
.starry-sky .action-item:hover::before {
  background: rgba(196, 122, 26, 0.12);
  border-color: rgba(196, 122, 26, 0.3);
  color: #b8860b;
}

/* ===== 19. 头部 ===== */
.starry-sky .cosmic-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  margin-bottom: 8px;
  font-size: 0.9em;
}
.starry-sky .cosmic-header .starlight-time {
  color: #b8860b;
  font-weight: 600;
}

/* ===== 20. 任务 ===== */
.starry-sky .quest-main { border-left: 3px solid #c47a1a; padding-left: 10px; }
.starry-sky .world-event {
  background: rgba(196, 122, 26, 0.05);
  border: 1px solid rgba(196, 122, 26, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
}

/* ===== 21. 动效（调亮） ===== */
@keyframes pulse-glow-light {
  0%, 100% { text-shadow: 0 0 6px rgba(196, 122, 26, 0.15); }
  50% { text-shadow: 0 0 18px rgba(196, 122, 26, 0.4); }
}
@keyframes danger-pulse-light {
  0%, 100% { text-shadow: 0 0 8px rgba(178, 34, 34, 0.15); }
  50% { text-shadow: 0 0 24px rgba(178, 34, 34, 0.4); }
}
@keyframes danger-border-light {
  0%, 100% { border-color: rgba(178, 34, 34, 0.15); }
  50% { border-color: rgba(178, 34, 34, 0.5); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== 22. 移动端 ===== */
@media (max-width: 480px) {
  .starry-sky { font-size: 14px; }
  .starry-sky .grid-2col { grid-template-columns: 1fr; gap: 3px; }
  .starry-sky .msg { max-width: 100%; }
}

/* ===== 23. 月相 ===== */
.starry-sky [data-phase="full-moon"]::after { content: " 🌕"; }
.starry-sky [data-phase="new-moon"]::after { content: " 🌑"; }
.starry-sky [data-phase="上弦月"]::after { content: " 🌓"; }
.starry-sky [data-phase="下弦月"]::after { content: " 🌗"; }

/* ===== 24. 战斗记录 ===== */
.starry-sky .result.win { color: #2a6b9e; font-weight: 600; }
.starry-sky .result:contains("败") { color: #b22222; }
.starry-sky .result:contains("撤退") { color: #b8860b; }

/* ===== 25. 司命关系 ===== */
.starry-sky .relation.hostile { color: #b22222; }
.starry-sky .relation.neutral { color: #b8860b; }
.starry-sky .relation.wary { color: #c07a3a; }
.starry-sky .relation.cautious { color: #2a6b9e; }

/* ========================================
   【气泡正文强制纯黑】—— 适合浅色背景
   ======================================== */
.group .rili-markdown-renderer,
.group .rili-markdown-renderer *,
.rili-markdown-renderer,
.rili-markdown-renderer * {
  color: #000000 !important;
  font-weight: 400 !important;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.9) !important;
}

.group.is-user > div:first-child {
  background: #ffffff !important;
  border: 1px solid #d0d5e0 !important;
  border-radius: 16px !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04) !important;
}
.group.is-assistant > div:first-child {
  background: #f7faff !important;
  border: 1px solid #c8cdd8 !important;
  border-radius: 16px !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04) !important;
}