/* ===== 全局重置 & 字体 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-size: 15px;
  font-family: -apple-system, "Inter", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(ellipse at 30% 20%, #1a1a2e, #0f0f1a 70%);
  color: #f0f0f5;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

.glass {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* 移动端主容器 */
.service {
  width: 100%;
  max-width: 640px;
  height: 100%;
  position: fixed;
  left: 0;
  right: 0;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 30, 0.4);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* PC 端容器 */
.pc-service {
  width: 372px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 30, 0.4);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* 头部 */
.msg-head {
  height: 50px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #f0f0f5;
  font-size: 17px;
  text-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.3px;
  font-weight: 500;
}
.msg-head a {
  width: 44px;
  height: 44px;
  line-height: 44px;
  position: absolute;
  left: 6px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.7);
  transition: 0.2s;
}
.msg-head a:hover {
  color: #fff;
}
.msg-head a i {
  font-size: 22px;
}
.msg-head .tha {
  height: 22px;
  line-height: 22px;
}
.msg-head .thb {
  height: 22px;
  line-height: 22px;
  font-size: 14px;
  opacity: 0.7;
}

/* 消息列表 */
.msg-box {
  flex: 1;
  background: transparent;
  padding: 14px 12px 0;
  line-height: 1.4;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ===== 核心修复：消息左右布局 ===== */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;          /* 头像与内容的间距 */
  margin-bottom: 14px;
}
.msg:last-of-type {
  margin-bottom: 18px;
}

/* 对方消息：头像在左，内容在右（默认） */
.msg {
  flex-direction: row;
}

/* 自己消息：头像在右，内容在左（翻转） */
.msg.on {
  flex-direction: row-reverse;
}

/* 头像 */
.msg .img1,
.msg .img2 {
  width: 40px;
  height: 40px;
  flex-shrink: 0;      /* 防止压缩 */
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.msg .img1 {
  display: block;
}
.msg .img2 {
  display: none;
}
.msg.on .img1 {
  display: none;
}
.msg.on .img2 {
  display: block;
}

/* 消息气泡 */
.msg .content {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  color: #e8e8f0;
  position: relative;
  text-align: justify;
  word-break: break-word;
  margin: 4px 0 0 0;   /* 只保留上边距，左右由父容器的 gap 控制 */
}

/* 自己消息的气泡（右） */
.msg.on .content {
  background: rgba(80, 130, 255, 0.18);
  border-color: rgba(80, 130, 255, 0.25);
  box-shadow: 0 4px 20px rgba(80, 130, 255, 0.15);
  color: #fff;
}

/* 三角指示器 */
.content .indicate {
  width: 0;
  height: 0;
  border: 10px solid transparent;
  position: absolute;
  top: 12px;
}
.msg .content .left-indicate {
  border-right-color: rgba(255, 255, 255, 0.08);
  left: -18px;
}
.msg .content .right-indicate {
  display: none;
}
.msg.on .content .left-indicate {
  display: none;
}
.msg.on .content .right-indicate {
  display: block;
  border-left-color: rgba(80, 130, 255, 0.18);
  right: -18px;
}

.msg-box p {
  margin: 0;
  line-height: 1.5;
}

/* ===== 输入区 ===== */
.msg-post {
  height: 56px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
}
.msg-post textarea {
  resize: none;
  font-size: 15px;
  line-height: 1.4;
  padding: 8px 12px;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f0f0f5;
  transition: 0.2s;
  min-height: 38px;
  max-height: 80px;
}
.msg-post textarea:focus {
  border-color: rgba(80, 130, 255, 0.5);
  box-shadow: 0 0 20px rgba(80, 130, 255, 0.08);
  background: rgba(255, 255, 255, 0.08);
}
.msg-post textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}
.msg-post label {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.msg-post label .iconfont {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.4);
  transition: 0.2s;
}
.msg-post label .iconfont:hover {
  color: rgba(255, 255, 255, 0.7);
}
.msg-post input[type="file"] {
  display: none;
}
.msg-post input[type="button"] {
  padding: 0 20px;
  height: 38px;
  font-size: 15px;
  margin-left: 6px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, #4a7cf7, #6c5ce7);
  color: #fff;
  cursor: pointer;
  transition: 0.25s;
  font-weight: 500;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(74, 124, 247, 0.25);
}
.msg-post input[type="button"]:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 24px rgba(74, 124, 247, 0.35);
}
.msg-post .back {
  width: 44px;
  height: 38px;
  line-height: 38px;
  text-align: center;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  transition: 0.2s;
}
.msg-post .back a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.5);
  display: block;
}
.msg-post .back:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== PC 端布局 ===== */
.pc-main {
  width: 1014px;
  height: 100%;
  position: fixed;
  left: 0;
  right: 0;
  margin: auto;
  display: flex;
  gap: 16px;
  align-items: stretch;
  padding: 20px 0;
}
.pc-left {
  width: 372px;
  height: 100%;
  background: rgba(20, 20, 30, 0.35);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.pc-right {
  width: 642px;
  height: 100%;
  background: rgba(20, 20, 30, 0.35);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.pc-left, .pc-right {
  border: none;
}

/* ===== 用户列表（左侧） ===== */
.service-box {
  flex: 1;
  font-size: 14px;
  background: transparent;
  overflow-y: auto;
}
.user-box {
  padding: 12px 12px 0;
}
.user-box a {
  text-decoration: none;
  color: inherit;
}
.user-list {
  height: 56px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: 0.2s;
  cursor: default;
}
.user-list:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.08);
}
.user-list img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.user-list .user {
  margin-left: 10px;
  flex: 1;
  min-width: 0;
}
.user-list .user .name {
  height: 24px;
  line-height: 24px;
  font-size: 16px;
  font-weight: 500;
  color: #e8e8f0;
}
.user-list .user .name .ison {
  margin-left: 6px;
  font-size: 12px;
  color: #4ade80;
  vertical-align: 1px;
}
.user-list .user .last-msg {
  height: 20px;
  line-height: 20px;
  color: rgba(255, 255, 255, 0.4);
  padding-left: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-list .data {
  width: 70px;
  text-align: right;
  flex-shrink: 0;
}
.user-list .data .time {
  height: 24px;
  line-height: 24px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
}
.user-list .data .num {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  text-align: center;
  line-height: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

/* ===== 底部菜单（移动端） ===== */
.foot {
  height: 48px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  display: flex;
  gap: 6px;
}
.foot > div {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  line-height: 38px;
  transition: 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.foot > div:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.foot a {
  display: block;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* ===== 辅助 ===== */
.clearfix::after {
  content: "";
  display: block;
  clear: both;
}
.text-center::after {
  content: ' ';
  display: inline-block;
  width: 0;
  height: 100%;
  vertical-align: middle;
  margin-top: 4px;
}