/* ============================================
   STELLAR-UI · CYBERPUNK SPACE HUD
   适配深色/浅色双模式 · 移动端/桌面端双适配
   ============================================ */

/* ---------- 0. 变量与主题 ---------- */
.stellar-ui {
  --neon-cyan: #00f0ff;
  --neon-pink: #ff2d75;
  --neon-purple: #b14aff;
  --neon-gold: #ffcc4d;
  --neon-green: #2dffb0;
  --neon-red: #ff4757;
  --bg-deep: #050818;
  --bg-panel: rgba(10, 18, 38, 0.78);
  --bg-panel-inner: rgba(8, 14, 30, 0.55);
  --txt-main: #d8e6ff;
  --txt-dim: #8aa0c8;
  --border-glow: rgba(0, 240, 255, 0.45);
  --scan-line: rgba(0, 240, 255, 0.08);

  position: relative;
  display: block;
  max-width: 100%;
  margin: 12px auto;
  padding: 18px 14px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--txt-main);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(177, 74, 255, 0.18), transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(0, 240, 255, 0.16), transparent 55%),
    linear-gradient(135deg, #050818 0%, #0a0e26 50%, #0e0820 100%);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  box-shadow:
    0 0 24px rgba(0, 240, 255, 0.25),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

/* 浅色模式适配（系统偏好） */
@media (prefers-color-scheme: light) {
  .stellar-ui {
    --bg-panel: rgba(20, 28, 56, 0.9);
    --txt-main: #e8f1ff;
    /* 内容区始终保持深色科技感，避免赛博风在白底下失味 */
  }
}

/* 顶部 / 底部装饰扫描线 */
.stellar-ui::before,
.stellar-ui::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  box-shadow: 0 0 12px var(--neon-cyan);
  pointer-events: none;
}
.stellar-ui::before { top: 0; }
.stellar-ui::after  { bottom: 0; }

/* ---------- 1. 隐藏 💞 心标 ---------- */
.stellar-ui .heart-token {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}

/* ---------- 2. 通用 coser-panel 折叠面板 ---------- */
.stellar-ui .coser-panel {
  position: relative;
  margin: 14px 0;
  padding: 0;
  background: var(--bg-panel);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-left: 3px solid var(--neon-cyan);
  border-radius: 6px;
  box-shadow:
    0 0 12px rgba(0, 240, 255, 0.15),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.stellar-ui .coser-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 3px,
      var(--scan-line) 3px,
      var(--scan-line) 4px
    );
  pointer-events: none;
  opacity: 0.4;
}

.stellar-ui .coser-panel > summary {
  position: relative;
  padding: 10px 14px 10px 38px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--neon-cyan);
  cursor: pointer;
  list-style: none;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.18), transparent 70%);
  border-bottom: 1px dashed rgba(0, 240, 255, 0.25);
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
  user-select: none;
  transition: all .25s ease;
}
.stellar-ui .coser-panel > summary::-webkit-details-marker { display: none; }
.stellar-ui .coser-panel > summary::marker { content: ""; }

.stellar-ui .coser-panel > summary::before {
  content: "▶";
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
  transition: transform .3s ease;
}
.stellar-ui .coser-panel[open] > summary::before {
  transform: translateY(-50%) rotate(90deg);
}

.stellar-ui .coser-panel[open] > summary {
  background: linear-gradient(90deg, rgba(177, 74, 255, 0.25), rgba(0, 240, 255, 0.1) 70%);
  color: #fff;
}

/* 面板内容内边距 */
.stellar-ui .coser-panel > *:not(summary) {
  position: relative;
  z-index: 1;
}
.stellar-ui .coser-panel > *:not(summary):not(details) {
  padding-left: 14px;
  padding-right: 14px;
}
.stellar-ui .coser-panel > p,
.stellar-ui .coser-panel > ul,
.stellar-ui .coser-panel > ol {
  padding: 6px 14px;
  margin: 4px 0;
  line-height: 1.75;
  word-break: break-word;
}

/* 不同面板的霓虹色彩区分 */
.stellar-ui .thinking-panel { border-left-color: var(--neon-purple); }
.stellar-ui .thinking-panel > summary { color: var(--neon-purple); text-shadow: 0 0 6px rgba(177,74,255,.6);}
.stellar-ui .scene-panel    { border-left-color: var(--neon-cyan); }
.stellar-ui .player-panel   { border-left-color: var(--neon-pink); }
.stellar-ui .player-panel > summary { color: var(--neon-pink); text-shadow: 0 0 6px rgba(255,45,117,.6);}
.stellar-ui .comment-panel  { border-left-color: var(--neon-gold); }
.stellar-ui .comment-panel > summary { color: var(--neon-gold); text-shadow: 0 0 6px rgba(255,204,77,.6);}
.stellar-ui .memory-panel   { border-left-color: var(--neon-green); }
.stellar-ui .memory-panel > summary { color: var(--neon-green); text-shadow: 0 0 6px rgba(45,255,176,.6);}
.stellar-ui .action-panel   { border-left-color: var(--neon-red); }
.stellar-ui .action-panel > summary { color: var(--neon-red); text-shadow: 0 0 6px rgba(255,71,87,.6);}

/* ---------- 3. 思维链 cyber-stream ---------- */
.stellar-ui .cyber-stream {
  margin: 10px 14px;
  padding: 10px 14px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(177, 74, 255, 0.4);
  border-radius: 4px;
}
.stellar-ui .cyber-stream .stream-line {
  display: block;
  color: var(--neon-purple);
  opacity: 0.85;
  letter-spacing: .5px;
  animation: streamBlink 2.4s infinite;
}
.stellar-ui .cyber-stream .stream-line:nth-child(2) { animation-delay: .6s; color: var(--neon-cyan);}
.stellar-ui .cyber-stream .stream-line:nth-child(3) { animation-delay: 1.2s; color: var(--neon-green);}
@keyframes streamBlink { 0%,100%{opacity:.4;} 50%{opacity:1;} }

/* ---------- 4. 场景信息 scene-grid ---------- */
.stellar-ui .scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  padding: 12px 14px;
}
.stellar-ui .scene-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-panel-inner);
  border-left: 2px solid var(--neon-cyan);
  border-radius: 3px;
  font-size: 13px;
}
.stellar-ui .scene-key {
  flex: 0 0 auto;
  margin-right: 8px;
  padding: 2px 6px;
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.1);
  border-radius: 2px;
  font-size: 12px;
  letter-spacing: 1px;
}
.stellar-ui .scene-val {
  flex: 1;
  color: var(--txt-main);
  word-break: break-word;
}

/* ---------- 5. 正文 rev-main ---------- */
.stellar-ui .rev-main {
  position: relative;
  margin: 18px 4px;
  padding: 22px 20px;
  background:
    linear-gradient(180deg, rgba(8, 14, 30, 0.85), rgba(14, 8, 32, 0.85));
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 4px;
  box-shadow:
    0 0 20px rgba(177, 74, 255, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
  line-height: 2;
  font-size: 15px;
  letter-spacing: .5px;
}

/* 四角装饰 */
.stellar-ui .rev-frame-tl,
.stellar-ui .rev-frame-tr,
.stellar-ui .rev-frame-bl,
.stellar-ui .rev-frame-br {
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
  pointer-events: none;
}
.stellar-ui .rev-frame-tl { top:-1px;    left:-1px;    border-right:none; border-bottom:none;}
.stellar-ui .rev-frame-tr { top:-1px;    right:-1px;   border-left:none;  border-bottom:none;}
.stellar-ui .rev-frame-bl { bottom:-1px; left:-1px;    border-right:none; border-top:none;}
.stellar-ui .rev-frame-br { bottom:-1px; right:-1px;   border-left:none;  border-top:none;}

.stellar-ui .rev-content { position: relative; z-index: 1; }

/* 对话 / 心声 / 系统提示 */
.stellar-ui .char-dialogue {
  color: var(--neon-cyan);
  text-shadow: 0 0 4px rgba(0, 240, 255, 0.5);
  font-weight: 500;
}
.stellar-ui .inner-thought {
  color: var(--neon-pink);
  font-style: italic;
  text-shadow: 0 0 4px rgba(255, 45, 117, 0.4);
}
.stellar-ui .system-alert {
  margin: 12px 0;
  padding: 10px 14px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 1px;
  background: linear-gradient(90deg, rgba(255, 71, 87, 0.25), rgba(255, 204, 77, 0.15));
  border: 1px solid var(--neon-red);
  border-left: 4px solid var(--neon-red);
  border-radius: 3px;
  text-shadow: 0 0 6px rgba(255, 71, 87, 0.6);
  animation: alertPulse 1.6s infinite;
}
@keyframes alertPulse {
  0%,100% { box-shadow: 0 0 8px rgba(255,71,87,.4);}
  50%     { box-shadow: 0 0 18px rgba(255,71,87,.8);}
}

/* ---------- 6. 身份卡 id-card ---------- */
.stellar-ui .id-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 14px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255,45,117,.15), rgba(0,240,255,.1));
  border: 1px solid rgba(255, 45, 117, 0.4);
  border-radius: 4px;
}
.stellar-ui .id-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 56px; height: 56px;
  background:
    radial-gradient(circle, rgba(255,45,117,.4), transparent 70%),
    repeating-linear-gradient(0deg, #0a0e26 0 2px, #1a1f3a 2px 4px);
  border: 1px solid var(--neon-pink);
  border-radius: 50%;
  overflow: hidden;
}
.stellar-ui .id-scan {
  position: absolute; left:0; right:0;
  height: 2px;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
  animation: scanMove 2.5s infinite;
}
@keyframes scanMove { 0%{top:0;} 50%{top:100%;} 100%{top:0;} }

.stellar-ui .id-meta { flex: 1; min-width: 0; }
.stellar-ui .id-name { font-size: 15px; color: var(--neon-pink); letter-spacing: 1.5px; font-weight: 600;}
.stellar-ui .id-tag  { font-size: 12px; color: var(--txt-dim); margin-top: 4px;}

/* ---------- 7. profile-list ---------- */
.stellar-ui .profile-list {
  list-style: none;
  margin: 8px 14px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 8px;
}
.stellar-ui .profile-list li {
  display: flex;
  padding: 4px 8px;
  background: var(--bg-panel-inner);
  border-left: 2px solid var(--neon-pink);
  border-radius: 2px;
  font-size: 13px;
}
.stellar-ui .pf-key {
  flex: 0 0 60px;
  color: var(--neon-pink);
  letter-spacing: 1px;
}
.stellar-ui .pf-val {
  flex: 1;
  color: var(--txt-main);
  word-break: break-word;
}

/* ---------- 8. sub-title 小节标题 ---------- */
.stellar-ui .sub-title {
  position: relative;
  margin: 14px 14px 8px;
  padding: 5px 12px 5px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--neon-gold);
  background: linear-gradient(90deg, rgba(255, 204, 77, 0.18), transparent 80%);
  border-left: 3px solid var(--neon-gold);
  text-shadow: 0 0 4px rgba(255, 204, 77, 0.5);
}
.stellar-ui .sub-title::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--neon-gold), transparent);
}

/* ---------- 9. dao-stat 状态条 ---------- */
.stellar-ui .dao-stat {
  margin: 10px 14px;
  padding: 10px;
  background: var(--bg-panel-inner);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  border-radius: 4px;
}
.stellar-ui .dao-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.stellar-ui .dao-label {
  flex: 0 0 80px;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--neon-cyan);
}
.stellar-ui .dao-bar {
  position: relative;
  flex: 1;
  height: 16px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}
.stellar-ui .dao-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
  box-shadow: 0 0 8px currentColor;
  transition: width .8s ease;
  position: relative;
}
.stellar-ui .hp-bar .dao-fill { background: linear-gradient(90deg, #ff4757, #ff8e53, #ffcc4d);}
.stellar-ui .mp-bar .dao-fill { background: linear-gradient(90deg, #b14aff, #00f0ff);}
.stellar-ui .dao-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  animation: barFlow 2s linear infinite;
}
@keyframes barFlow { 0%{transform:translateX(-100%);} 100%{transform:translateX(100%);} }
.stellar-ui .dao-num {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #fff;
  text-shadow: 0 0 3px #000;
  z-index: 2;
}
.stellar-ui .dao-desc {
  margin: 6px 0;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--txt-dim);
  border-left: 2px solid var(--neon-cyan);
  background: rgba(0,240,255,.05);
}
.stellar-ui .dao-trait {
  list-style: none;
  margin: 6px 0;
  padding: 0;
}
.stellar-ui .dao-trait li {
  padding: 4px 8px;
  margin: 3px 0;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 2px solid var(--neon-purple);
  border-radius: 2px;
  line-height: 1.7;
}
.stellar-ui .dao-trait b {
  color: var(--neon-gold);
  margin-right: 4px;
}

/* ---------- 10. 飞船铭牌 ---------- */
.stellar-ui .ship-nameplate {
  margin: 12px 14px;
  padding: 12px;
  text-align: center;
  background:
    linear-gradient(90deg, transparent, rgba(0,240,255,.15), transparent),
    repeating-linear-gradient(90deg, #0a0e26 0 4px, #0e1430 4px 8px);
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
}
.stellar-ui .ship-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
}
.stellar-ui .ship-class {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--txt-dim);
}

/* ---------- 11. 推荐行动按钮 ---------- */
.stellar-ui .action-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  padding: 12px 14px;
}
.stellar-ui .action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(0,240,255,.08));
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-left: 3px solid var(--neon-cyan);
  border-radius: 3px;
  cursor: pointer;
  transition: all .25s ease;
  font-size: 13px;
}
.stellar-ui .action-btn:hover {
  transform: translateX(4px);
  background: linear-gradient(90deg, rgba(0,240,255,.2), rgba(0,240,255,.05));
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}
.stellar-ui .act-key {
  flex: 0 0 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--neon-cyan);
  color: #000;
  font-weight: 700;
  border-radius: 50%;
  text-shadow: none;
}
.stellar-ui .act-text { flex: 1; color: var(--txt-main); }

.stellar-ui .act-a { border-left-color: var(--neon-gold);}
.stellar-ui .act-a .act-key { background: var(--neon-gold);}
.stellar-ui .act-b { border-left-color: var(--neon-purple);}
.stellar-ui .act-b .act-key { background: var(--neon-purple); color:#fff;}
.stellar-ui .act-c { border-left-color: var(--neon-pink);}
.stellar-ui .act-c .act-key { background: var(--neon-pink); color:#fff;}
.stellar-ui .act-d { border-left-color: var(--neon-red);}
.stellar-ui .act-d .act-key { background: var(--neon-red); color:#fff;}
.stellar-ui .act-e { border-left-color: var(--neon-green);}
.stellar-ui .act-e .act-key { background: var(--neon-green);}

/* ---------- 12. 记忆面板（保留你原内容，仅外观） ---------- */
.stellar-ui .memory-panel blockquote,
.stellar-ui .memory-panel > * {
  margin: 8px 14px;
  font-size: 13px;
  line-height: 1.8;
}
.stellar-ui .memory-panel table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 12px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(45, 255, 176, 0.3);
}
.stellar-ui .memory-panel th,
.stellar-ui .memory-panel td {
  padding: 6px 8px;
  border: 1px solid rgba(45, 255, 176, 0.2);
  text-align: left;
  word-break: break-word;
}
.stellar-ui .memory-panel th {
  background: rgba(45, 255, 176, 0.15);
  color: var(--neon-green);
  letter-spacing: 1px;
}

/* ---------- 13. 模拟界面 sim-phone ---------- */
.stellar-ui .sim-phone {
  max-width: 420px;
  margin: 14px auto;
  background: #0a0e26;
  border: 2px solid var(--neon-cyan);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4), inset 0 0 30px rgba(0,0,0,.5);
}
.stellar-ui .sim-header {
  padding: 8px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  border-bottom: 1px solid rgba(0,240,255,.3);
  margin-bottom: 10px;
}
.stellar-ui .sim-msg-box {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stellar-ui .sim-msg-box.sim-self { align-items: flex-end; }
.stellar-ui .sim-name { font-size: 11px; color: var(--txt-dim); margin-bottom: 2px;}
.stellar-ui .sim-bubble {
  max-width: 78%;
  padding: 8px 12px;
  background: rgba(0,240,255,.12);
  border: 1px solid rgba(0,240,255,.3);
  border-radius: 12px 12px 12px 2px;
  font-size: 13px;
  color: var(--txt-main);
  word-break: break-word;
}
.stellar-ui .sim-self .sim-bubble {
  background: rgba(255,45,117,.15);
  border-color: rgba(255,45,117,.4);
  border-radius: 12px 12px 2px 12px;
}
.stellar-ui .sim-forum-post { padding: 10px; }
.stellar-ui .sim-forum-title {
  color: var(--neon-gold);
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 0 0 4px rgba(255,204,77,.4);
}
.stellar-ui .sim-forum-info {
  font-size: 11px;
  color: var(--txt-dim);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(255,204,77,.3);
}

/* ---------- 14. 嵌套 details（如生理情况） ---------- */
.stellar-ui .coser-panel details {
  margin: 10px 14px;
  background: rgba(0,0,0,.35);
  border: 1px dashed rgba(255,45,117,.4);
  border-radius: 3px;
}
.stellar-ui .coser-panel details > summary {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--neon-pink);
  cursor: pointer;
  letter-spacing: 1px;
}
.stellar-ui .coser-panel details > summary::-webkit-details-marker { display: none; }
.stellar-ui .coser-panel details[open] > summary {
  border-bottom: 1px dashed rgba(255,45,117,.3);
}
.stellar-ui .coser-panel details > *:not(summary) {
  padding: 4px 12px;
  font-size: 13px;
}

/* ---------- 15. 移动端适配 ---------- */
@media (max-width: 600px) {
  .stellar-ui {
    margin: 6px;
    padding: 12px 8px;
    font-size: 14px;
  }
  .stellar-ui .coser-panel > summary { padding: 9px 12px 9px 32px; font-size: 14px;}
  .stellar-ui .rev-main { margin: 12px 0; padding: 16px 12px; font-size: 14px; line-height: 1.9;}
  .stellar-ui .scene-grid,
  .stellar-ui .profile-list,
  .stellar-ui .action-list { grid-template-columns: 1fr; }
  .stellar-ui .dao-label { flex: 0 0 64px; font-size: 11px; letter-spacing: 1px;}
  .stellar-ui .id-avatar { width: 48px; height: 48px;}
  .stellar-ui .ship-name { font-size: 15px; letter-spacing: 2px;}
  .stellar-ui .coser-panel > p,
  .stellar-ui .coser-panel > ul { padding: 6px 10px; }
}

/* ---------- 16. 防止极端窄屏溢出 ---------- */
.stellar-ui * { max-width: 100%; box-sizing: border-box; }
.stellar-ui pre, .stellar-ui code { white-space: pre-wrap; word-break: break-all; }
/* ============================================
   补丁：修复测试发现的4个问题
   ============================================ */

/* ---------- 修复1：记忆面板summary渐变完整包裹 ---------- */
/* 撤销通用规则对 summary 与展开标记的误伤 */
.stellar-ui .memory-panel > summary {
  margin: 0 !important;
  padding: 10px 14px 10px 38px !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
}

/* 让记忆面板的内容区有自己的内边距，而不是靠子元素 margin 撑开 */
.stellar-ui .memory-panel {
  padding-bottom: 4px;
}
.stellar-ui .memory-panel > *:not(summary) {
  margin: 6px 12px;
}

/* 折叠状态下确保面板自身有完整的渐变背景包裹 summary */
.stellar-ui .memory-panel:not([open]) > summary {
  border-bottom: none;
  border-radius: 4px;
}

/* 同步修正其它面板折叠时 summary 底边圆角缺失 */
.stellar-ui .coser-panel:not([open]) > summary {
  border-bottom-color: transparent;
}

/* ---------- 修复2：system-alert 强制独立块 ---------- */
.stellar-ui .system-alert {
  display: block !important;
  clear: both;
  width: auto;
  margin: 18px 0 !important;
  padding: 12px 16px !important;
  text-align: center;
  letter-spacing: 2px;
  border-radius: 4px;
  /* 防止被父级 inline 化 */
  float: none;
  position: relative;
  z-index: 2;
}
/* 前后强制断行：用伪元素清浮动+撑开间距 */
.stellar-ui .system-alert::before,
.stellar-ui .system-alert::after {
  content: "";
  display: block;
  height: 0;
  clear: both;
}
/* 防止被嵌进 <p> 时塌陷 */
.stellar-ui p .system-alert,
.stellar-ui span .system-alert {
  display: block !important;
  margin-top: 16px !important;
  margin-bottom: 16px !important;
}
/* 装饰角标 */
.stellar-ui .system-alert {
  background:
    linear-gradient(90deg, rgba(255, 71, 87, 0.3), rgba(255, 204, 77, 0.2)),
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,.15) 6px 12px);
  border: 2px solid var(--neon-red);
  box-shadow:
    0 0 14px rgba(255, 71, 87, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.3);
}

/* ---------- 修复3：手机端整体松绑 ---------- */
@media (max-width: 600px) {
  .stellar-ui {
    margin: 4px 2px !important;
    padding: 10px 6px !important;
    border-radius: 6px;
  }
  /* 面板自身贴边 */
  .stellar-ui .coser-panel {
    margin: 10px 0 !important;
    border-radius: 4px;
  }
  /* 内部子元素左右 padding 减半 */
  .stellar-ui .coser-panel > summary {
    padding: 9px 10px 9px 28px !important;
    letter-spacing: .5px;
  }
  .stellar-ui .coser-panel > summary::before { left: 10px; }
  .stellar-ui .coser-panel > p,
  .stellar-ui .coser-panel > ul,
  .stellar-ui .coser-panel > ol {
    padding: 6px 8px !important;
    margin: 4px 0 !important;
  }
  .stellar-ui .coser-panel > *:not(summary):not(details) {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  /* 各种内部容器外边距统一收窄 */
  .stellar-ui .scene-grid,
  .stellar-ui .action-list,
  .stellar-ui .id-card,
  .stellar-ui .profile-list,
  .stellar-ui .dao-stat,
  .stellar-ui .ship-nameplate,
  .stellar-ui .cyber-stream {
    margin-left: 8px !important;
    margin-right: 8px !important;
    padding: 8px !important;
  }
  .stellar-ui .sub-title {
    margin-left: 8px !important;
    margin-right: 8px !important;
    letter-spacing: 1px;
  }
  /* 正文区 */
  .stellar-ui .rev-main {
    margin: 10px 2px !important;
    padding: 14px 10px !important;
    font-size: 14px;
    line-height: 1.95;
  }
  /* 状态条 label 进一步压缩 */
  .stellar-ui .dao-label {
    flex: 0 0 56px;
    font-size: 10px;
    letter-spacing: 1px;
  }
  .stellar-ui .dao-bar { height: 14px; }
  /* 记忆面板表格水平滚动而不是挤变形 */
  .stellar-ui .memory-panel {
    overflow-x: auto;
  }
  .stellar-ui .memory-panel table {
    min-width: 480px;
    font-size: 11px;
  }
  /* profile 单列 + 内部 key 缩短 */
  .stellar-ui .pf-key { flex: 0 0 50px; font-size: 12px; }
  .stellar-ui .pf-val { font-size: 13px; }
  /* sim-phone 占满宽度 */
  .stellar-ui .sim-phone {
    max-width: 100%;
    margin: 10px 0;
    padding: 10px 8px;
  }
  .stellar-ui .sim-bubble { max-width: 85%; font-size: 12px; }
  /* 系统警报手机端字号 */
  .stellar-ui .system-alert {
    margin: 14px 0 !important;
    padding: 10px 12px !important;
    font-size: 13px;
    letter-spacing: 1px;
  }
}

/* 极窄屏（≤360px）补救 */
@media (max-width: 360px) {
  .stellar-ui { padding: 8px 4px !important; }
  .stellar-ui .coser-panel > summary { font-size: 13px !important; }
  .stellar-ui .dao-label { flex: 0 0 48px; }
  .stellar-ui .scene-key { font-size: 11px; }
}

/* ---------- 修复4：🔒生理情况嵌套details排版 ---------- */
.stellar-ui .coser-panel details {
  margin: 12px 14px !important;
  padding: 0 !important;
  background:
    linear-gradient(180deg, rgba(255, 45, 117, 0.08), rgba(0, 0, 0, 0.4)) !important;
  border: 1px solid rgba(255, 45, 117, 0.4) !important;
  border-left: 3px solid var(--neon-pink) !important;
  border-radius: 4px !important;
  overflow: hidden;
}
.stellar-ui .coser-panel details > summary {
  padding: 8px 14px !important;
  font-size: 13px !important;
  font-weight: 600;
  color: var(--neon-pink) !important;
  background: linear-gradient(90deg, rgba(255, 45, 117, 0.2), transparent 80%);
  letter-spacing: 1.5px;
  text-shadow: 0 0 4px rgba(255, 45, 117, 0.5);
  border-bottom: 1px dashed rgba(255, 45, 117, 0.3);
}
.stellar-ui .coser-panel details:not([open]) > summary {
  border-bottom: none;
}

/* 生理情况内的列表 - 卡片化展示 */
.stellar-ui .coser-panel details > ul {
  list-style: none !important;
  margin: 8px !important;
  padding: 0 !important;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.stellar-ui .coser-panel details > ul > li {
  position: relative;
  padding: 8px 10px 8px 28px !important;
  margin: 0 !important;
  font-size: 13px;
  line-height: 1.7;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 45, 117, 0.25);
  border-left: 2px solid var(--neon-pink);
  border-radius: 3px;
  color: var(--txt-main);
  word-break: break-word;
}
.stellar-ui .coser-panel details > ul > li::before {
  content: "❥";
  position: absolute;
  left: 10px; top: 8px;
  color: var(--neon-pink);
  font-size: 12px;
  text-shadow: 0 0 4px rgba(255, 45, 117, 0.6);
}

/* 若内容是段落文本而非列表 */
.stellar-ui .coser-panel details > p {
  margin: 8px !important;
  padding: 8px 10px !important;
  background: rgba(0, 0, 0, 0.4);
  border-left: 2px solid var(--neon-pink);
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.8;
}

/* 移动端生理面板 */
@media (max-width: 600px) {
  .stellar-ui .coser-panel details {
    margin: 10px 6px !important;
  }
  .stellar-ui .coser-panel details > ul {
    margin: 6px !important;
  }
  .stellar-ui .coser-panel details > ul > li {
    padding: 7px 8px 7px 24px !important;
    font-size: 12.5px;
  }
  .stellar-ui .coser-panel details > ul > li::before {
    left: 8px; top: 7px;
  }
}
/* ============================================
   补丁 v2.1 修复版：解决内容挤压无换行问题
   ============================================ */

/* ---------- 修复1：列表项不再与边框重叠 ---------- */
.stellar-ui ul,
.stellar-ui ol {
  padding-left: 28px !important;   /* 恢复合理缩进 */
  margin-left: 0 !important;
  list-style-position: outside;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.stellar-ui li {
  padding-left: 6px;
  margin: 5px 0;
  word-break: break-word;
  white-space: normal;  /* 强制允许换行 */
}

/* 自定义列表点样式：小菱形霓虹 */
.stellar-ui .coser-panel ul:not(.dao-trait):not(.profile-list) {
  list-style: none !important;
  padding-left: 12px !important;
}
.stellar-ui .coser-panel ul:not(.dao-trait):not(.profile-list) > li {
  position: relative;
  padding-left: 20px !important;
}
.stellar-ui .coser-panel ul:not(.dao-trait):not(.profile-list) > li::before {
  content: "◆";
  position: absolute;
  left: 4px; top: 3px;
  font-size: 9px;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px var(--neon-cyan);
}
/* 嵌套列表（二级缩进）换符号区分层级 */
.stellar-ui .coser-panel ul ul {
  padding-left: 20px !important;
}
.stellar-ui .coser-panel ul ul > li::before {
  content: "▸";
  color: var(--neon-purple);
  text-shadow: 0 0 4px var(--neon-purple);
}

/* 段落和容器：确保换行正常 */
.stellar-ui .coser-panel > p,
.stellar-ui .coser-panel > div:not(.cyber-stream):not(.scene-grid):not(.id-card):not(.dao-stat):not(.ship-nameplate):not(.action-list):not(.sub-title):not(.system-alert):not(.rev-content) {
  padding-left: 14px !important;
  padding-right: 14px !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;  /* 关键：允许换行 */
  line-height: 1.75;
}

/* 防止 flex 容器挤压子元素 */
.stellar-ui .coser-panel {
  display: block !important;  /* 确保不是 flex */
  padding-right: 4px;
}

/* ---------- 修复2：手机端真正拓宽内容区 ---------- */
@media (max-width: 600px) {
  .stellar-ui {
    margin: 4px 0 !important;
    padding: 10px 6px !important;  /* 稍微留点内边距，不要完全贴边 */
    border-left-width: 1px;
    border-right-width: 1px;
    border-radius: 4px;
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.2);
    overflow: visible;
  }

  /* 面板内边距适度压缩 */
  .stellar-ui .coser-panel {
    margin: 10px 0 !important;
  }
  .stellar-ui .coser-panel > p,
  .stellar-ui .coser-panel > ul,
  .stellar-ui .coser-panel > ol,
  .stellar-ui .coser-panel > div:not(.cyber-stream):not(.scene-grid):not(.id-card):not(.dao-stat):not(.ship-nameplate):not(.action-list):not(.sub-title):not(.system-alert) {
    padding-left: 12px !important;
    padding-right: 10px !important;
  }
  
  /* 列表缩进保持可读性 */
  .stellar-ui ul,
  .stellar-ui ol {
    padding-left: 24px !important;
  }
  .stellar-ui .coser-panel ul:not(.dao-trait):not(.profile-list) {
    padding-left: 10px !important;
  }
  .stellar-ui .coser-panel ul:not(.dao-trait):not(.profile-list) > li {
    padding-left: 18px !important;
  }

  /* 正文区 */
  .stellar-ui .rev-main {
    margin: 12px 0 !important;
    padding: 16px 14px !important;
    border-radius: 4px;
  }

  /* 内部容器 */
  .stellar-ui .scene-grid,
  .stellar-ui .action-list,
  .stellar-ui .id-card,
  .stellar-ui .profile-list,
  .stellar-ui .dao-stat,
  .stellar-ui .ship-nameplate,
  .stellar-ui .cyber-stream,
  .stellar-ui .sub-title {
    margin-left: 8px !important;
    margin-right: 8px !important;
  }

  /* 嵌套 details */
  .stellar-ui .coser-panel details {
    margin: 10px 6px !important;
  }
}

/* ---------- 修复3：用户档案 / 交互人物 改为电子蓝绿配色 ---------- */
.stellar-ui {
  --neon-blue: #4d8fff;
  --neon-teal: #00d9c0;
  --neon-steel: #7fb8ff;
}

.stellar-ui .player-panel {
  border-left-color: var(--neon-teal) !important;
}
.stellar-ui .player-panel > summary {
  color: var(--neon-teal) !important;
  text-shadow: 0 0 6px rgba(0, 217, 192, 0.6) !important;
  background: linear-gradient(90deg, rgba(0, 217, 192, 0.18), transparent 70%) !important;
}
.stellar-ui .player-panel[open] > summary {
  background: linear-gradient(90deg, rgba(77, 143, 255, 0.25), rgba(0, 217, 192, 0.1) 70%) !important;
  color: #fff !important;
}
.stellar-ui .player-panel > summary::before {
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue);
}

/* 身份卡 */
.stellar-ui .player-panel .id-card {
  background: linear-gradient(135deg, rgba(77, 143, 255, 0.18), rgba(0, 217, 192, 0.12)) !important;
  border-color: rgba(0, 217, 192, 0.45) !important;
}
.stellar-ui .player-panel .id-avatar {
  background:
    radial-gradient(circle, rgba(77, 143, 255, 0.4), transparent 70%),
    repeating-linear-gradient(0deg, #0a0e26 0 2px, #1a2540 2px 4px) !important;
  border-color: var(--neon-teal) !important;
}
.stellar-ui .player-panel .id-name {
  color: var(--neon-teal) !important;
  text-shadow: 0 0 6px rgba(0, 217, 192, 0.5);
}

/* profile-list */
.stellar-ui .player-panel .profile-list li {
  border-left-color: var(--neon-teal) !important;
}
.stellar-ui .player-panel .pf-key {
  color: var(--neon-steel) !important;
}

/* dao-stat */
.stellar-ui .player-panel .dao-desc {
  border-left-color: var(--neon-teal);
  background: rgba(0, 217, 192, 0.06);
}
.stellar-ui .player-panel .dao-trait li {
  border-left-color: var(--neon-blue);
}

/* 区分第二个 player-panel（交互人物）用紫色 */
.stellar-ui .player-panel + .player-panel {
  border-left-color: #b14aff !important;
}
.stellar-ui .player-panel + .player-panel > summary {
  color: #c891ff !important;
  text-shadow: 0 0 6px rgba(177, 74, 255, 0.6) !important;
  background: linear-gradient(90deg, rgba(177, 74, 255, 0.2), transparent 70%) !important;
}
.stellar-ui .player-panel + .player-panel .id-card {
  background: linear-gradient(135deg, rgba(177, 74, 255, 0.18), rgba(77, 143, 255, 0.1)) !important;
  border-color: rgba(177, 74, 255, 0.45) !important;
}
.stellar-ui .player-panel + .player-panel .id-name { color: #c891ff !important; }
.stellar-ui .player-panel + .player-panel .profile-list li { border-left-color: #b14aff !important;}
.stellar-ui .player-panel + .player-panel .pf-key { color: #c891ff !important;}

/* 🔒生理情况保留暗粉 */
.stellar-ui .coser-panel details {
  border-left-color: #ff6b9d !important;
  border-color: rgba(255, 107, 157, 0.35) !important;
}
.stellar-ui .coser-panel details > summary {
  color: #ff8fb3 !important;
}

/* ---------- 修复4：消息气泡上下边框 + 操作按钮美化 ---------- */

/* 顶部 HUD 头条增强 */
.stellar-ui::before {
  background: linear-gradient(90deg,
    transparent,
    var(--neon-cyan) 20%,
    var(--neon-purple) 50%,
    var(--neon-cyan) 80%,
    transparent
  );
  height: 2px;
  box-shadow: 0 0 16px var(--neon-cyan), 0 0 30px rgba(177, 74, 255, 0.5);
}
.stellar-ui::after {
  background: linear-gradient(90deg,
    transparent,
    var(--neon-pink) 20%,
    var(--neon-gold) 50%,
    var(--neon-pink) 80%,
    transparent
  );
  height: 2px;
  box-shadow: 0 0 16px var(--neon-pink), 0 0 30px rgba(255, 204, 77, 0.4);
}

/* 顶部装饰文字 */
.stellar-ui > .heart-token {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 24px !important;
  clip: auto !important;
  overflow: visible !important;
  opacity: 1 !important;
  font-size: 0 !important;
  color: transparent !important;
}
.stellar-ui > .heart-token::after {
  content: "STELLAR-OS · v3.7 · ENCRYPTED LINK";
  position: absolute;
  top: 6px; left: 14px;
  width: auto; height: auto;
  clip: auto;
  opacity: .6;
  font-family: "Consolas", monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px var(--neon-cyan);
  pointer-events: none;
}

/* 操作按钮通用美化 */
.mes_buttons,
.extraMesButtons,
.mes_block .mes_buttons {
  display: flex !important;
  flex-wrap: wrap !important;  /* 允许按钮换行 */
  gap: 6px !important;
  padding: 6px 8px !important;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.05), rgba(177, 74, 255, 0.05)) !important;
  border-top: 1px dashed rgba(0, 240, 255, 0.3) !important;
  border-bottom: 1px dashed rgba(177, 74, 255, 0.2) !important;
}

.mes_buttons .mes_button,
.mes_buttons div[class*="button"],
.extraMesButtons div,
.mes_edit, .mes_copy, .mes_translate,
.mes_continue, .mes_regenerate, .mes_delete,
.menu_button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  color: var(--neon-cyan, #00f0ff) !important;
  background: rgba(8, 14, 30, 0.7) !important;
  border: 1px solid rgba(0, 240, 255, 0.4) !important;
  border-radius: 3px !important;
  text-shadow: 0 0 4px rgba(0, 240, 255, 0.5);
  box-shadow:
    inset 0 0 8px rgba(0, 240, 255, 0.1),
    0 0 4px rgba(0, 240, 255, 0.2);
  transition: all .2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.mes_buttons .mes_button:hover,
.mes_edit:hover, .mes_copy:hover,
.mes_continue:hover, .mes_regenerate:hover,
.menu_button:hover {
  color: #fff !important;
  background: rgba(0, 240, 255, 0.18) !important;
  border-color: var(--neon-cyan, #00f0ff) !important;
  box-shadow:
    inset 0 0 12px rgba(0, 240, 255, 0.3),
    0 0 12px rgba(0, 240, 255, 0.6);
  transform: translateY(-1px);
}

/* 删除按钮红色 */
.mes_delete, .mes_buttons .mes_delete {
  color: #ff6b6b !important;
  border-color: rgba(255, 71, 87, 0.4) !important;
  text-shadow: 0 0 4px rgba(255, 71, 87, 0.5);
}
.mes_delete:hover {
  background: rgba(255, 71, 87, 0.2) !important;
  border-color: var(--neon-red, #ff4757) !important;
  box-shadow: 0 0 12px rgba(255, 71, 87, 0.6) !important;
}

/* 编辑/重新生成 紫色 */
.mes_edit, .mes_regenerate {
  color: #c891ff !important;
  border-color: rgba(177, 74, 255, 0.4) !important;
}
.mes_edit:hover, .mes_regenerate:hover {
  background: rgba(177, 74, 255, 0.2) !important;
  box-shadow: 0 0 12px rgba(177, 74, 255, 0.5) !important;
}

/* 复制 金色 */
.mes_copy {
  color: var(--neon-gold, #ffcc4d) !important;
  border-color: rgba(255, 204, 77, 0.4) !important;
}
.mes_copy:hover {
  background: rgba(255, 204, 77, 0.18) !important;
  box-shadow: 0 0 12px rgba(255, 204, 77, 0.5) !important;
}

/* 评论/评分按钮 */
.comment, .rating, .mes_rating,
button[class*="comment"], button[class*="rating"] {
  background: rgba(8, 14, 30, 0.7) !important;
  border: 1px solid rgba(45, 255, 176, 0.4) !important;
  color: var(--neon-green, #2dffb0) !important;
  border-radius: 3px !important;
  padding: 4px 10px !important;
  text-shadow: 0 0 4px rgba(45, 255, 176, 0.5);
  transition: all .2s ease;
}
.comment:hover, .rating:hover {
  background: rgba(45, 255, 176, 0.15) !important;
  box-shadow: 0 0 10px rgba(45, 255, 176, 0.5) !important;
}

/* 模型/Mod 信息条 */
.model_info, .model_name, .mes_model,
[class*="model-tag"], [class*="mod-tag"] {
  display: inline-block;
  padding: 2px 8px;
  font-family: "Consolas", monospace;
  font-size: 11px !important;
  letter-spacing: 1px;
  color: var(--neon-purple, #b14aff) !important;
  background: rgba(177, 74, 255, 0.1) !important;
  border: 1px solid rgba(177, 74, 255, 0.4) !important;
  border-radius: 2px;
  text-shadow: 0 0 4px rgba(177, 74, 255, 0.5);
}

/* 输入框美化 */
#send_textarea, textarea.text_pole, .text_pole {
  background: rgba(8, 14, 30, 0.85) !important;
  color: var(--txt-main, #d8e6ff) !important;
  border: 1px solid rgba(0, 240, 255, 0.4) !important;
  border-radius: 4px !important;
  box-shadow:
    inset 0 0 12px rgba(0, 240, 255, 0.08),
    0 0 8px rgba(0, 240, 255, 0.15) !important;
  font-family: "Microsoft YaHei", sans-serif !important;
}
#send_textarea:focus, textarea.text_pole:focus {
  border-color: var(--neon-cyan, #00f0ff) !important;
  box-shadow:
    inset 0 0 16px rgba(0, 240, 255, 0.15),
    0 0 14px rgba(0, 240, 255, 0.4) !important;
  outline: none !important;
}

/* 滚动条赛博化 */
.stellar-ui ::-webkit-scrollbar,
.mes ::-webkit-scrollbar {
  width: 6px; height: 6px;
}
.stellar-ui ::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}
.stellar-ui ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 3px;
  box-shadow: 0 0 4px var(--neon-cyan);
}
