/* =========================
   CHAT (clean final) — slim
   ========================= */

/* --- layout shell --- */
.chatWrap {
  width: min(1100px, 94vw);
  height: calc(var(--vvh, 100vh) - 2 * var(--gutter));
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
}



.chatWindow {
  flex: 1;
  border: var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--desk-paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

/* --- titlebar --- */
.chatTitlebar {
  height: 52px;
  border-bottom: var(--line);
  background: var(--desk-paper-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
}

.chatTitle {
  font-weight: 900;
  letter-spacing: .16em;
  font-size: 15px;
}

.chatActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatIconBtn {
  width: 34px;
  height: 34px;
  border: var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease;
}

.chatIconBtn:hover {
  transform: translateY(-1px);
}

.chatBackBtn {
  height: 34px;
  padding: 0 10px;
  border: var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .75);
  cursor: pointer;
  font-weight: 700;
}

/* --- body --- */
.chatBody {
  flex: 1;
  display: flex;
  min-height: 0;
}

.chatMessages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  box-sizing: border-box;
}

/* message item */
.chatItem {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  align-items: flex-start;
}

/* ✅ 不再使用左侧名字列：全部放进气泡里 */
.chatItem .nameTag{
  width: 0;
  flex: 0 0 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}



.nameAvatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: var(--line);
  background: rgba(255, 255, 255, .75);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nameAvatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nameText {
  font-weight: 800;
  font-size: 13px;
  opacity: .9;
}

/* bubble */
.chatMsg {
  flex: 1;
  border: 2px solid rgba(0, 0, 0, .18);
  border-radius: 16px;
  background: rgba(255, 255, 255, .68);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .18);
  padding: 10px 12px;
  position: relative;
  min-width: 0;
  /* 防止长文本把布局撑爆 */
}

/* chatMeta 退役：不再用于放名字/按钮 */
.chatMeta{
  display: none;
}

/* ✅ 让气泡顶部左右分布：左边留空/右边放按钮 */
.chatItem.me .chatMeta{
  justify-content: flex-end;
}

.msgActions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.msgActBtn {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, .16);
  background: rgba(255, 255, 255, .75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease;
  color: #2b2b2b; /* ✅ 确保 currentColor 有值 */
}

.msgActBtn svg{
  width: 18px;
  height: 18px;
  display: block;
}

#chatSend{
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2b2b2b; /* ✅ 同上 */
}

#chatSend svg{
  display: block;
}

.msgActBtn:hover {
  transform: translateY(-1px);
}


.chatText {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- composer --- */
.chatComposer {
  border-top: var(--line);
  background: var(--desk-paper-2);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 5;
}

#chatInput {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  background: rgba(255, 255, 255, .75);
  font-size: 14px;
  line-height: 1.4;
}

#chatSend {
  height: 44px;
  padding: 0 14px;
  border: var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  cursor: pointer;
  font-weight: 800;
}

/* --- drawer / mask (用于清空弹窗遮罩) --- */
.chatMask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .28);
  z-index: 9998;
}

/* =========================
   Phone Overlay (虚拟小手机)
   ========================= */
.phoneMask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .28);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.phoneOverlay {
  position: fixed;
  right: 16px;
  top: 64px;
  width: min(380px, 92vw);
  height: min(680px, calc(var(--vvh, 100vh) - 2 * var(--gutter)));
  z-index: 9999;

  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition: opacity .18s ease, transform .18s ease;

  /* ✅ 只改这些：去外框外底 */
  border-radius: 0;
  border: none;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.phoneMask[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.phoneOverlay[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#miniPhoneMount {
  width: 100%;
  height: 100%;
}

#miniPhoneMount>* {
  width: 100%;
  height: 100%;
}

/* mobile */
@media (max-width: 980px) {
  .phoneOverlay {
    left: 50%;
    top: 50%;
    right: auto;

    width: min(380px, calc(var(--vvw, 100vw) - 2 * var(--gutter)));
    height: min(680px, calc(var(--vvh, 100vh) - 2 * var(--gutter)));

    transform: translate(-50%, -50%) scale(0.98);
  }

  .phoneOverlay[data-open="true"] {
    transform: translate(-50%, -50%) scale(1);
  }
}


/* =========================
   Clear modal
   ========================= */
.chatClearModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.chatClearModal[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.chatClearCard {
  width: min(420px, 88vw);
  border-radius: 18px;
  border: 2px solid rgba(0, 0, 0, .16);
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .18);
  padding: 14px 14px 12px;
}

.chatClearTitle {
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 6px;
}

.chatClearSub {
  opacity: .8;
  font-size: 13px;
  margin-bottom: 12px;
}

.chatClearBtns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chatClearBtns button {
  border: 2px solid rgba(0, 0, 0, .16);
  background: rgba(255, 255, 255, .75);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

/* =========================
   Contact Bar (联系人切换条) — restore
   ========================= */
.chatContactBar {
  border-bottom: var(--line);
  background: rgba(255, 255, 255, .30);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chatContactBar::-webkit-scrollbar {
  height: 8px;
}

.chatContactBar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .18);
  border-radius: 999px;
}

/* 每个胶囊 */
.chatChip {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .22);
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .16);

  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.chatChip:hover {
  transform: translateY(-1px);
}

/* 隐藏原生 radio */
.chatChip input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 左侧小圆点 */
.chatChip .dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .28);
  background: rgba(255, 255, 255, .7);
  flex: 0 0 12px;
}

/* 文本 */
.chatChip .label {
  font-weight: 900;
  letter-spacing: .02em;
}

/* 选中态：描边更深 + 圆点变色 + 胶囊背景更亮 */
.chatChip.is-active {
  border-color: rgba(0, 0, 0, .45);
  background: rgba(255, 255, 255, .78);
}

.chatChip.is-active .dot {
  background: rgba(60, 120, 255, .95);
  border-color: rgba(0, 0, 0, .25);
}

/* 选中态：整体变亮、描边更深、圆点变蓝、文字加重 */
.chatChip.is-active {
  border-color: rgba(0, 0, 0, .45);
  background: rgba(255, 255, 255, .78);
}

.chatChip.is-active .dot {
  background: rgba(60, 120, 255, .95);
  border-color: rgba(0, 0, 0, .25);
}

.chatChip.is-active .label {
  font-weight: 900;
}

/* =========================
   Contact Bar — active state (matches chat.js)
   ========================= */

.chatContactBar {
  border-bottom: var(--line);
  background: rgba(255, 255, 255, .30);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 胶囊按钮 */
.chatChip {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 6px 10px;
  /* ↓ 缩内边距 */
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .22);
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .16);
  /* ↓ 阴影高度一起缩 */

  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.chatChip:hover {
  transform: translateY(-1px);
}

/* 左侧小圆点（你真实 class 叫 chatChipDot） */
.chatChipDot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .28);
  background: rgba(255, 255, 255, .7);
  flex: 0 0 12px;
}

/* 文字（你 JS 创建的 label 没 class，所以直接取第二个 span） */
.chatChip>span:last-child {
  font-weight: 900;
  letter-spacing: .02em;
}

/* ✅ 选中态：chat.js 用的是 .active */
.chatChip.active {
  border-color: rgba(0, 0, 0, .45);
  background: rgba(255, 255, 255, .78);
}

.chatChip.active .chatChipDot {
  background: rgba(60, 120, 255, .95);
  border-color: rgba(0, 0, 0, .25);
}

/* ✅ 手机端：miniPhone 居中覆盖（不拖动） */
@media (pointer: coarse),
(max-width: 768px) {
  .phoneOverlay {
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;

    /* 让它更像覆盖层：宽高更贴近屏幕 */
    width: min(92vw, 420px) !important;
    height: min(86vh, 740px) !important;

    /* ⚠️ 你的桌面动画是 translateY(18px) -> translateY(0)
       手机端我们要在居中基础上再叠加这段动画 */
    transform: translate(-50%, calc(-50% + 18px)) !important;
  }

  /* ✅ 适配你的“打开态”选择器：二选一，哪个存在用哪个 */
  .phoneOverlay.open,
  .phoneOverlay[data-open="true"] {
    transform: translate(-50%, -50%) !important;
  }
}
/* ===== 圆形发送键：chatSendBtn ===== */
#viewChat .chatComposer{
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#viewChat .chatSendBtn{
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  border: 3px solid #2b2b2b;
  background: #fff7e4;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.18),
    0 10px 18px rgba(0,0,0,0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

#viewChat .chatSendBtn:active{
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0,0,0,0.18),
    0 8px 14px rgba(0,0,0,0.18);
}

#viewChat .chatSendBtn svg{
  display: block;
}
/* ===== 气泡头部：头像+名字进气泡 ===== */
.chatMsg{
  position: relative;
}

/* 头部一行：左=头像+名字，右=操作键 */
.chatHead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.chatWhoLeft{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chatAva{
  width: 50px;
  height: 50px;
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 2px solid rgba(0,0,0,0.18);
  background: rgba(255,255,255,0.75);
}

.chatAva img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chatWho{
  font-weight: 900;
  font-size: 13px;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* 右侧操作键排到最右 */
.chatOps{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* 原来的 .chatMeta 现在只当“容器”，不额外占行高 */
.chatMeta{
  padding: 0;
  margin: 0;
}
/* =========================
   Edit modal（消息编辑弹层）- 卡片同款风格
   ========================= */

.chatEditMask{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.22);
  z-index: 10010;
}

/* 卡片：奶油底 + 粗描边 + 立体阴影 */
.chatEditModal{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10011;

  width: min(760px, 92vw);
  max-height: min(74vh, 620px);

  display: flex;
  flex-direction: column;

  border-radius: 18px;
  border: 3px solid rgba(0,0,0,.78);
  background: #f7f1e6; /* 奶油纸 */
  box-shadow:
    0 10px 0 rgba(0,0,0,.22),
    0 22px 40px rgba(0,0,0,.18);
  overflow: hidden;
}

/* 顶栏：同款卡片头，简单干净 */
.chatEditHeader{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  background: #f3eadb;
  border-bottom: 3px solid rgba(0,0,0,.72);
}

.chatEditTitle{
  font-weight: 900;
  font-size: 14px;
  color: rgba(0,0,0,.86);
  user-select: none;
}

/* 右侧按钮：同款小圆角按钮 */
.chatEditHeaderRight{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chatEditIcon{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 3px solid rgba(0,0,0,.72);
  background: #fffaf1;
  box-shadow: 0 5px 0 rgba(0,0,0,.22);
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition: transform .08s ease, box-shadow .08s ease;
}

.chatEditIcon svg{ width: 18px; height: 18px; }

.chatEditIcon:active{
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,.22);
}

/* 文本区：像卡片内部纸张 */
.chatEditArea{
  flex: 1;
  min-height: 260px;
  padding: 12px 12px;

  border: none;
  outline: none;
  resize: none;

  background: #fbf6ee;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(0,0,0,.88);

  white-space: pre-wrap;
  word-break: break-word;
}

/* 底部留点呼吸（可选） */
.chatEditModal::after{
  content: "";
  display: block;
  height: 10px;
  background: #f7f1e6;
}

/* 打开弹窗时禁滚动 */
body.chat-editing{ overflow: hidden; }

/* 小屏适配 */
@media (max-width: 520px){
  .chatEditModal{
    width: 92vw;
    max-height: 66vh;
    border-radius: 16px;
  }
  .chatEditArea{ min-height: 220px; }
}
.chatErrSource{
  margin-top: 6px;
  font-size: 12px;
  opacity: .75;
  line-height: 1.2;
}
#chatSend svg{
  width: 22px;
  height: 22px;
  display: block;
}
#chatSend{ color:#2b2b2b; }
