ai {
  --bg: #fafafa;
  --line: #222;
  --text: #111;
  --gray: #666;
  --p-bubble: #d0e6ff;
  --p-text: #0a1a33;
  --s-bubble: #ffd6d6;
  --s-text: #330a0a;
  --n-bubble: #d4f5d4;
  --n-text: #0a330a;
  --shadow: rgba(0,0,0,0.12);
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  padding: 0;
  margin: 0;
  position: relative;
}

/* ========== 场景信息区 ========== */
ai sc {
  display: block;
  background: #fff;
  border: 3px solid var(--line);
  padding: 14px 12px;
  margin: 0 0 12px 0;
  position: relative;
}

ai sc::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border: 1px solid var(--line);
  pointer-events: none;
}

ai sc t {
  display: block;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  margin: 0 0 10px 0;
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}

ai sc row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 13px;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}

ai sc w { display: inline-block; }
ai sc lo { display: inline-block; text-align: right; }

ai sc sd {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--gray);
  margin: 10px 0 0 0;
  font-style: italic;
  position: relative;
  z-index: 1;
}

/* ========== 正文区 ========== */
ai article {
  display: block;
  padding: 10px 0;
  margin: 0 0 12px 0;
}

ai nar {
  display: block;
  padding: 8px 14px;
  margin: 6px 0;
  line-height: 1.8;
  border-left: 3px solid #ddd;
  text-indent: 2em;
}

/* ========== 对话气泡系统 ========== */
ai bl {
  display: block;
  padding: 12px 16px 10px 16px;
  margin: 10px 0;
  border-radius: 14px;
  position: relative;
  max-width: 80%;
  line-height: 1.8;
  box-shadow: 2px 2px 6px var(--shadow);
  font-size: 14px;
}

ai bl::before {
  content: attr(n);
  display: block;
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

/* 玩家气泡 - 蓝色 左侧 */
ai bl[who="p"] {
  background: var(--p-bubble);
  color: var(--p-text);
  margin-right: auto;
  margin-left: 0;
  border-bottom-left-radius: 3px;
}

ai bl[who="p"]::before {
  text-align: left;
  color: #1a4a7a;
}

ai bl[who="p"]::after {
  content: '';
  position: absolute;
  bottom: 10px;
  left: -9px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 9px solid var(--p-bubble);
}

/* 星野奈气泡 - 红色 右侧 */
ai bl[who="s"] {
  background: var(--s-bubble);
  color: var(--s-text);
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 3px;
}

ai bl[who="s"]::before {
  text-align: right;
  color: #7a1a1a;
}

ai bl[who="s"]::after {
  content: '';
  position: absolute;
  bottom: 10px;
  right: -9px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid var(--s-bubble);
}

/* NPC气泡 - 绿色 右侧 */
ai bl[who="n"] {
  background: var(--n-bubble);
  color: var(--n-text);
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 3px;
}

ai bl[who="n"]::before {
  text-align: right;
  color: #1a5a1a;
}

ai bl[who="n"]::after {
  content: '';
  position: absolute;
  bottom: 10px;
  right: -9px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid var(--n-bubble);
}

/* ========== 手机讯息悬浮窗（仅PC端） ========== */
ai ph {
  display: none;
}

@media (min-width: 769px) {
  ai ph {
    display: block;
    position: fixed;
    top: 80px;
    right: 12px;
    width: 300px;
    background: #fff;
    border: 3px solid var(--line);
    border-radius: 16px;
    box-shadow: 5px 5px 0 var(--shadow);
    max-height: 72vh;
    overflow-y: auto;
    z-index: 100;
    padding: 0;
  }

  ai phtitle {
    display: block;
    background: var(--line);
    color: #fff;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    border-radius: 12px 12px 0 0;
  }

  ai phd {
    display: block;
    padding: 9px 14px;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 0.5px;
    background: #f5f5f5;
    border-top: 2px solid #e0e0e0;
    color: #333;
  }

  ai phd:first-of-type {
    border-top: none;
    margin-top: 0;
  }

  ai mg {
    display: block;
    padding: 11px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    line-height: 1.7;
    transition: background 0.2s, transform 0.2s;
    background: #fff;
  }

  ai mg:hover {
    background: #fafafa;
    transform: translateX(-3px);
  }

  ai phd + mg {
    border-top: none;
  }
}

/* ========== 移动端手机讯息（嵌入式） ========== */
@media (max-width: 768px) {
  ai ph {
    display: block;
    position: static;
    width: 100%;
    margin: 0 0 12px 0;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 0;
  }

  ai phtitle {
    display: block;
    background: var(--line);
    color: #fff;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    border-radius: 10px 10px 0 0;
  }

  ai phd {
    display: block;
    padding: 8px 12px;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 0.5px;
    background: #f5f5f5;
    border-top: 2px solid #e0e0e0;
    color: #333;
  }

  ai phd:first-of-type {
    border-top: none;
  }

  ai mg {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    line-height: 1.7;
    background: #fff;
  }

  ai phd + mg {
    border-top: none;
  }
}

/* ========== 便利贴 ========== */
ai memo {
  display: block;
  background: linear-gradient(135deg, #e8f4fd 0%, #ffffff 60%, #f0f8ff 100%);
  border: none;
  padding: 30px 24px 24px;
  margin: 0 0 12px 0;
  position: relative;
  transform: rotate(-0.8deg);
  box-shadow: 3px 3px 10px var(--shadow), 0 0 0 1px rgba(0,0,0,0.08);
  min-height: 130px;
  border-radius: 2px;
}

ai memo::before {
  content: '';
  position: absolute;
  bottom: 12px;
  left: 14px;
  width: 55px;
  height: 55px;
  background-image: url('https://i.postimg.cc/Y0V8sZPh/f40312cde904f11ce8da8247a340b929.jpg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
  filter: contrast(1.3) grayscale(0.2);
}

ai memo::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 65px;
  height: 22px;
  background: linear-gradient(180deg, rgba(200,220,240,0.7), rgba(200,220,240,0.3));
  border-radius: 0 0 4px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

ai memo:hover {
  animation: memo-shake 0.4s ease;
}

@keyframes memo-shake {
  0%, 100% { transform: rotate(-0.8deg); }
  20% { transform: rotate(-1.4deg); }
  40% { transform: rotate(-0.2deg); }
  60% { transform: rotate(-1.2deg); }
  80% { transform: rotate(-0.5deg); }
}

ai mt {
  display: block;
  font-family: 'Comic Sans MS', 'Segoe Print', cursive, sans-serif;
  font-size: 15px;
  line-height: 2;
  color: #222;
  text-align: center;
  transform: rotate(0.5deg);
  margin: 0 0 16px 0;
  letter-spacing: 0.4px;
}

ai ms {
  display: block;
  text-align: right;
  font-family: 'Comic Sans MS', 'Segoe Print', cursive, sans-serif;
  font-size: 13px;
  color: var(--gray);
  transform: rotate(-1.3deg);
  margin-right: 16px;
}

/* ========== 状态区details ========== */
ai details {
  display: block;
  border: 2px solid var(--line);
  margin: 0 0 10px 0;
  background: #fff;
  border-radius: 4px;
}

ai details summary {
  display: block;
  padding: 11px 14px;
  font-weight: bold;
  font-size: 15px;
  cursor: pointer;
  background: #f5f5f5;
  user-select: none;
  transition: background 0.2s;
  border-radius: 2px 2px 0 0;
}

ai details summary:hover {
  background: #e8e8e8;
}

ai details[open] summary {
  background: var(--line);
  color: #fff;
}

ai info, ai sec, ai mem {
  display: block;
  padding: 10px 14px;
  border-top: 1px solid #eee;
}

ai stitle, ai mtitle {
  display: block;
  font-weight: bold;
  font-size: 13px;
  color: var(--line);
  margin: 0 0 6px 0;
  letter-spacing: 0.5px;
}

ai d {
  display: block;
  margin: 5px 0;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ========== 选项区 ========== */
ai op {
  display: block;
  margin: 12px 0 0 0;
}

ai op d {
  display: block;
  background: #fff;
  border: 2px solid var(--line);
  padding: 11px 16px;
  margin: 0 0 9px 0;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  border-radius: 4px;
}

ai op d::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 10px solid var(--line);
}

ai op d::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 8px solid #fff;
}

ai op d:hover {
  background: #f5f5f5;
  transform: translateX(5px);
  box-shadow: 3px 3px 0 var(--shadow);
}

ai op d:last-child {
  border-width: 3px;
  font-weight: bold;
}

/* ========== 移动端调整 ========== */
@media (max-width: 768px) {
  ai bl {
    max-width: 88%;
  }

  ai memo::before {
    width: 48px;
    height: 48px;
  }
}