/* =========================================
   0. 全局变量与背景 (蔚蓝之恋·内核兼容优化版)
   ========================================= */
:root {
  --scroll-bg: #EAF5FC;
  --scroll-ink: #2c3e50;
  --scroll-red: #66a3ff;
  --scroll-gold: #B5D0D9;
  --scroll-accent: #2D80A0;
  --scroll-border: 2px solid #66a3ff;
  --scroll-shadow: 4px 4px 0px 0px rgba(102, 163, 255, 0.3);
  --paper-texture: none;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "SimSun", "STSong", "KaiTi", serif;
  --font-kaiti: "KaiTi", "STKaiti", "HKaiT", "Fangkaiti", serif;
}
/* =========================================
   1. 核心气泡容器 (极致兼容修复版 - 蓝色系)
   ========================================= */
div.group.relative > div.relative.inline-block.bg-gray-100\/90 {
  display: block !important;
  isolation: isolate;
  transform-style: preserve-3d;
  background: linear-gradient(135deg, rgba(240,248,255,0.94), rgba(240,248,255,0.94)) !important;
  background: -webkit-linear-gradient(135deg, rgba(240,248,255,0.94), rgba(240,248,255,0.94)) !important;
  border: 2px solid #66a3ff;
  border-image: linear-gradient(135deg, #4d94ff, #66a3ff, #99c2ff) 1;
  border-image: -webkit-linear-gradient(135deg, #4d94ff, #66a3ff, #99c2ff) 1;
  border-radius: 12px;
  box-shadow: 0 6px 15px rgba(102,163,255,0.1);
  padding: 15px 28px;
  width: 95%;
  max-width: 48em;
  margin: 10px auto;
  box-sizing: border-box;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #2c3e50 !important;
  font-size: 1rem;
  line-height: 1.6;
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
  -webkit-font-smoothing: antialiased;
}
@media screen and (max-width: 600px) {
  div.group.relative > div.relative.inline-block.bg-gray-100\/90 {
    padding: 15px 12px;
    width: 98%;
    font-size: 0.92rem;
  }
}
div.group.relative > div.relative.inline-block.bg-gray-100\/90::before {
  content: "";
  position: absolute;
  top: 6px; bottom: 6px; left: 6px; right: 6px;
  border: 1px dashed rgba(102, 163, 255, 0.3);
  border-radius: 8px;
  pointer-events: none;
  z-index: -1;
  transform: translateZ(-1px);
  background: transparent !important;
}
div.group.relative > div.relative.inline-block.bg-gray-100\/90 p[data-character="天照院夜夜"] {
  position: relative;
  display: inline-block;
  padding-right: 12px;
  color: var(--scroll-accent);
  font-weight: 900;
  border-bottom: 2px solid rgba(102, 163, 255, 0.3);
  padding-bottom: 2px;
  margin-bottom: 5px;
  font-family: var(--font-kaiti);
}
div.group.relative > div.relative.inline-block.bg-gray-100\/90 p[data-character="天照院夜夜"]::after {
  content: "❤";
  position: absolute;
  right: -8px;
  top: 50%;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  font-size: 0.7em;
  opacity: 0.7;
  color: #66a3ff;
  -webkit-animation: heartbeat 1.5s infinite;
          animation: heartbeat 1.5s infinite;
}
@-webkit-keyframes heartbeat {
  0% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
  25% { -webkit-transform: translateY(-50%) scale(1.1); transform: translateY(-50%) scale(1.1); }
  50% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
  75% { -webkit-transform: translateY(-50%) scale(1.2); transform: translateY(-50%) scale(1.2); }
  100% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
}
@keyframes heartbeat {
  0% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
  25% { -webkit-transform: translateY(-50%) scale(1.1); transform: translateY(-50%) scale(1.1); }
  50% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
  75% { -webkit-transform: translateY(-50%) scale(1.2); transform: translateY(-50%) scale(1.2); }
  100% { -webkit-transform: translateY(-50%) scale(1); transform: translateY(-50%) scale(1); }
}
/* =========================================
   2. ClassUI 面板 (蔚蓝屏风)
   ========================================= */
.classUI-details-panel,
.classUI-panel {
  margin-bottom: 15px;
  background-color: #EAF5FC;
  border: 1px solid #e0f0ff;
  border-radius: 8px;
  box-shadow: 3px 3px 0 rgba(102, 163, 255, 0.2);
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}
.classUI-details-panel:hover,
.classUI-panel:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 rgba(102, 163, 255, 0.3);
  transition: all 0.3s ease;
}
.styled-prose-container {
  background: transparent;
  --classUI-panel-bg: #EAF5FC;
  --classUI-panel-border: #B5D0D9;
  --classUI-header-bg: #D9EFF5;
  --classUI-text-secondary: #506C6E;
  --classUI-accent: #2D80A0;
  --classUI-code-bg: #EDF5F7;
  --classUI-code-text: #263D3F;
  --classUI-summary-hover-bg: #D3EDF4;
  --novel-text-color: #283A3E;
  padding: 0;
  box-shadow: none;
}
.classUI-panel-header,
.classUI-summary-header {
  background-color: var(--classUI-header-bg, #D9EFF5);
  padding: 10px 15px;
  font-weight: 700;
  color: var(--scroll-accent);
  border-bottom: 1px solid var(--classUI-panel-border, #B5D0D9);
  font-family: var(--font-serif);
  display: flex;
  align-items: center;
}
.classUI-summary-header {
  background: linear-gradient(to right, #66a3ff, #99c2ff);
  background: -webkit-linear-gradient(to right, #66a3ff, #99c2ff);
  color: white;
  transition: all 0.3s ease;
}
.classUI-summary-header:hover,
.classUI-summary-header:focus {
  background: linear-gradient(to right, #4d94ff, #66a3ff);
  background: -webkit-linear-gradient(to right, #4d94ff, #66a3ff);
}
.classUI-summary-header::before {
  content: "❤";
  color: #fff;
  margin-right: 10px;
  font-size: 0.8em;
}
.classUI-panel-content {
  padding: 1.2em;
  color: var(--scroll-ink);
  font-family: var(--font-serif);
}
.classUI-master-system .classUI-system-line {
  display: block;
  margin-bottom: 0.8em;
  line-height: 1.6;
  border-bottom: 1px dotted #B5D0D9;
  padding-bottom: 6px;
}
.classUI-master-system .classUI-label {
  color: #2D80A0;
  background: rgba(102, 163, 255, 0.2);
  padding: 0 6px;
  margin-right: 0.6em;
  font-weight: bold;
  border-radius: 4px;
  font-family: var(--font-serif);
  display: inline-block;
  margin-bottom: 4px;
}
.classUI-master-system .classUI-value {
  color: var(--scroll-ink);
  font-family: var(--font-serif);
  display: block;
  width: 100%;
}
.classUI-master-system .classUI-task-active,
.classUI-master-system .classUI-task-completed,
.classUI-master-system .classUI-task-failed {
  font-size: 0.75em;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 0.5em;
  font-weight: 900;
  border: 1px solid;
  font-family: var(--font-kaiti);
  display: inline-block;
}
.classUI-master-system .classUI-task-active {
  color: #fff;
  background-color: #66a3ff;
  border-color: #66a3ff;
}
.classUI-master-system .classUI-task-completed {
  color: #fff;
  background-color: #70E000;
  border-color: #70E000;
}
.classUI-master-system .classUI-task-failed {
  color: #fff;
  background-color: #FF4D6D;
  border-color: #FF4D6D;
}
.classUI-compass-options {
  gap: 12px;
}
.classUI-compass-option {
  border: 1px solid #B5D0D9;
  background-color: #FFFFFF;
  color: #506C6E;
  border-radius: 8px;
  position: relative;
  box-shadow: 2px 2px 0 rgba(102, 163, 255, 0.2);
}
.classUI-compass-option:hover {
  background-color: #D3EDF4;
  border-color: #2D80A0;
  transform: translateY(-1px);
  box-shadow: 3px 3px 0 rgba(45, 128, 160, 0.2);
}
.classUI-option-label {
  color: #2D80A0;
  font-weight: 900;
  border-right: 1px solid rgba(181, 208, 217, 0.5);
  padding-right: 10px;
  font-family: var(--font-kaiti);
}
/* =========================================
   3. MomoTalk (保持原样)
   ========================================= */
.momo-talk-wrapper {
  font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, 'Microsoft YaHei', sans-serif !important;
  background-color: #7297C8 !important;
  border: none !important;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: #000 !important;
  text-indent: 0 !important;
  clear: both;
}
.momo-talk-wrapper details > summary {
  list-style: none;
  cursor: pointer;
  outline: none;
}
.momo-talk-wrapper details > summary::-webkit-details-marker {
  display: none;
}
.momo-talk-wrapper * {
  text-indent: 0 !important;
  box-sizing: border-box;
}
.momo-header {
  background-color: #263342 !important;
  color: #FFFFFF !important;
  padding: 12px 18px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.1) !important;
  font-size: 1em;
  letter-spacing: 0.5px;
}
.momo-header:hover {
  filter: brightness(1.05);
}
.momo-body {
  background-color: #7297C8 !important;
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  background-image: none;
}
.momo-msg {
  display: flex;
  align-items: flex-start;
  animation: momoFadeIn 0.3s ease-out;
  margin-bottom: 5px;
  width: 100%;
}
.momo-msg.student-side {
  justify-content: flex-start;
}
.momo-msg.student-side .momo-avatar-box {
  margin-right: 8px;
  margin-top: 2px;
}
.momo-msg.sensei-side {
  justify-content: flex-end;
}
.momo-msg.sensei-side .momo-avatar-box {
  display: none;
}
.momo-msg.sensei-side .momo-content {
  align-items: flex-end;
}
.momo-msg.sensei-side .momo-bubble {
  background-color: #85E249 !important;
  color: #000000 !important;
  border: none !important;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  position: relative;
}
.momo-msg.sensei-side .momo-bubble::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #85E249;
}
.momo-avatar-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #E0E0E0;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  box-shadow: none;
  overflow: hidden;
}
.momo-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.momo-avatar-text {
  font-size: 10px;
  display: none;
}
.momo-content {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.momo-name {
  font-size: 0.75em;
  color: #FFFFFF !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  margin-bottom: 4px;
  margin-left: 2px;
  line-height: 1.2;
}
.momo-msg.sensei-side .momo-name {
  display: none;
}
.momo-bubble {
  background-color: #FFFFFF !important;
  border: none !important;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.95em;
  line-height: 1.5;
  color: #000000 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  text-align: left;
  white-space: pre-line !important;
  word-wrap: break-word;
  min-width: 2em;
  position: relative;
}
.momo-msg.student-side .momo-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 8px 6px 0;
  border-color: transparent #FFFFFF transparent transparent;
}
.momo-bubble p {
  text-indent: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
.momo-sticker {
  max-width: 140px;
  border-radius: 12px;
  margin-top: 4px;
}
@keyframes momoFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-color-scheme: dark) {
  .momo-talk-wrapper {
    background-color: #1B1B1B !important;
    box-shadow: none;
    border: 1px solid #333 !important;
  }
  .momo-header {
    background-color: #202020 !important;
    border-bottom-color: #333 !important;
  }
  .momo-body {
    background-color: #1B1B1B !important;
  }
  .momo-bubble {
    background-color: #2F2F2F !important;
    color: #FFFFFF !important;
  }
  .momo-msg.student-side .momo-bubble::before {
    border-color: transparent #2F2F2F transparent transparent;
  }
  .momo-msg.sensei-side .momo-bubble {
    background-color: #518F42 !important;
    color: #FFFFFF !important;
  }
  .momo-msg.sensei-side .momo-bubble::after {
    border-color: transparent transparent transparent #518F42;
  }
  .momo-name {
    color: #BBBBBB !important;
    text-shadow: none;
  }
}
/* =========================================
   4. 角色信息面板 - 进度条 (蓝色适配版)
   ========================================= */
.classUI-bubble-bar {
  position: relative;
  background-color: #EAF5FC;
  border: 1px solid #B5D0D9;
  border-radius: 8px;
  box-shadow: inset 0 1px 3px rgba(102,163,255,0.1);
  min-height: 24px;
  height: auto;
  width: 100%;
  overflow: hidden; 
  margin-top: 2px;
  display: flex;
  align-items: center;
}
.classUI-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  z-index: 1;
  opacity: 0.85;
  transition: width 0.5s ease-in-out;
  background-color: #66a3ff;
  border-radius: inherit; 
}
.classUI-bar-text {
  position: relative;
  z-index: 2;
  color: #2c3e50;
  font-weight: 900;
  font-family: var(--font-serif);
  font-size: 0.85em;
  line-height: 1.5;
  padding: 4px 8px;
  white-space: normal;
  word-wrap: break-word;
  text-shadow: 0 0 2px rgba(255,255,255,0.7);
  width: 100%;
  text-indent: 0 !important; 
}
.classUI-bar-fill.pink { background-color: #FF85A2 !important; }
.classUI-bar-fill.purple { background-color: #C77DFF !important; }
.classUI-bar-fill.teal, .classUI-bar-fill.cyan { background-color: #4CC9F0 !important; }
.classUI-bar-fill.green { background-color: #70E000 !important; }
.classUI-bar-fill.dark, .classUI-bar-fill.black { background-color: #5D4037 !important; }
.classUI-bar-fill.yellow, .classUI-bar-fill.gold { background-color: #FFB703 !important; }
.classUI-bar-fill.blue { background-color: #66a3ff !important; }
/* =========================================
   5. 角色面板 (Dashboard - 蓝色适配)
   ========================================= */
.classUI-top-dashboard {
  border: 2px solid #66a3ff;
  padding: 10px;
  background: #EAF5FC;
  box-shadow: 0 4px 8px rgba(102,163,255,0.3);
  border-radius: 12px;
}
.classUI-top-dashboard .classUI-system-line:nth-child(1) {
  color: #2D80A0;
  border-bottom: 2px solid #B5D0D9;
  font-size: 1.6em;
  font-family: var(--font-kaiti);
}
.classUI-top-dashboard .classUI-system-line:not(:nth-child(1)) {
  background-color: #FFFFFF;
  border: 1px solid #B5D0D9;
  border-radius: 8px;
  padding: 4px 8px;
}
/* =========================================
   6. 开发度标签
   ========================================= */
.classUI-dev-tag {
  background: transparent;
  color: #FF4D6D;
  border: 2px solid #FF4D6D;
  border-radius: 4px;
  padding: 2px 10px;
  font-weight: 900;
  font-family: var(--font-kaiti);
  transform: rotate(-3deg);
  display: inline-block;
}
/* =========================================
   [终极防断层版] 字号精准自适应，解决换行割裂，手机端头像放大
   ========================================= */
/* 1. 名字行基础布局：限制整体空间 */
.classUI-top-dashboard .classUI-system-line.classUI-name-row {
  grid-column: 1 / -1 !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 5px 0 12px 0 !important;
  margin-bottom: 10px !important;
  border-bottom: 2px solid !important;
  border-image: linear-gradient(to right, #A8D5C5, #E6C07B, #A8D5C5) 1 !important;
}

/* 2. 名字文字区域：自适应可用空间 */
.classUI-name-area {
  display: flex !important;
  align-items: center !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
}

/* 前面的“姓名”标签 */
.classUI-name-area .classUI-label {
  flex-shrink: 0 !important;
  font-size: 0.95em !important;
  white-space: nowrap !important;
}

/* 名字内容：废除导致断层的webkit-box，采用紧凑行高+彻底的断词换行 */
.classUI-name-area .classUI-value {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  font-size: 1.25em !important;   /* 电脑端默认字号 */
  font-weight: 800 !important;
  padding-left: 4px !important;
  
  /* 核心修复：解决长名字换行时，上下字间距过大(撕裂)的问题 */
  line-height: 1.15 !important;
  white-space: normal !important;
  word-break: break-all !important; /* 确保长名字能在任何字断开换行，绝不越界 */
  display: inline-block !important; /* 保持为内联块，使紧凑line-height完美生效 */
}

/* 3. 右侧头像容器：电脑端保持不变 (85px) */
.classUI-avatar-wrapper {
  flex-shrink: 0 !important;          
  width: 85px !important;
  height: 85px !important;
  min-width: 85px !important;
  min-height: 85px !important;
  max-width: 85px !important;
  max-height: 85px !important;
  margin-left: 15px !important;
  box-sizing: border-box !important;

  border-radius: 50% !important;      
  clip-path: circle(50% at 50% 50%) !important;  
  border: 3px solid #E6C07B !important;
  overflow: hidden !important;
  background: #F5EFE6 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  box-shadow: 0 4px 12px rgba(230, 192, 123, 0.3) !important;
  transition: all 0.3s ease !important;
}

.classUI-avatar-wrapper:hover {
  transform: scale(1.05) rotate(-2deg) !important;
  border-color: #D4A85A !important;
}

/* 4. 头像图片自身强制约束 */
.classUI-avatar {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 50% !important;     
  object-fit: cover !important;
  object-position: top center !important; 
  display: block !important;
}

/* 5. 适配暗色模式 */
.classUI-avatar-wrapper:is(.dark *) {
  border-color: #D4A85A !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
  background: #4D443A !important;
}
.classUI-avatar-wrapper:hover:is(.dark *) {
  border-color: #E6C07B !important;
}

/* 6. 移动端适配：强制缩小字号，同时进一步放大头像 */
@media (max-width: 768px) {
  .classUI-avatar-wrapper {
    /* 手机端头像大幅放大至 80px (非常接近电脑端尺寸) */
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    min-height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
    border-width: 2px !important;
    margin-left: 10px !important;
  }
  /* 强制缩小字号，防止名字过长换行 */
  .classUI-name-area .classUI-value {
    font-size: 1.05em !important; 
  }
  .classUI-name-area .classUI-label {
    font-size: 0.85em !important;
  }
}

/* 7. 小屏手机极值适配 */
@media (max-width: 420px) {
  .classUI-avatar-wrapper {
    /* 极小屏头像也强行保持 75px 的大尺寸（原来只有52px） */
    width: 75px !important;
    height: 75px !important;
    min-width: 75px !important;
    min-height: 75px !important;
    max-width: 75px !important;
    max-height: 75px !important;
    margin-left: 8px !important;
  }
  /* 极限缩小字号，把空间全让给名字，绝不溢出 */
  .classUI-name-area .classUI-value {
    font-size: 0.9em !important; 
  }
  .classUI-name-area .classUI-label {
    font-size: 0.8em !important;
  }
}