/* 私信页（/dm）：仿微信桌面版——左栏联系人列表 + 右栏聊天窗，同高同卡像一个客户端窗口 */

/* 导航「私信」未读红点 */
.nav-red-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border-radius: 50%;
  background: #e5484d;
  vertical-align: middle;
}

/* ---------- 页面骨架：两栏占满一屏 ---------- */

body.page-dm main {
  max-width: 1180px;
  margin-top: 18px;
  padding: 0 16px 36px;
}

.dm-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  height: clamp(480px, calc(100vh - 150px), 840px);
}

/* ---------- 左栏：联系人列表 ---------- */

.dm-list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
}

.dm-search { padding: 10px 10px 6px; }
.dm-search input {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--paper-2);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: var(--ink);
}
.dm-search input:focus { box-shadow: 0 0 0 2px rgba(13, 159, 134, .18); }
.dm-search input::placeholder { color: var(--muted); }

.dm-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 8px;
}

.dm-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s;
}
.dm-contact:hover { background: rgba(13, 159, 134, .07); }
.dm-contact.current { background: rgba(13, 159, 134, .14); }

.dm-contact-av {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  object-fit: cover;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.dm-contact-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dm-contact-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dm-contact-top b {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-contact-top small {
  flex: none;
  font-size: 11px;
  color: var(--muted);
}
/* 有备注时：备注名后的原昵称小字，主名不再独占整行 */
.dm-contact-top .dm-contact-origin {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .75;
}
.dm-contact-top:has(.dm-contact-origin) b { flex: none; }
.dm-contact-bot {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dm-contact-bot small {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-unread-n {
  flex: none;
  font-style: normal;
  background: #fa5151;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  text-align: center;
  padding: 0 5px;
}

.dm-list-empty {
  margin: 30px 18px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
}
.dm-list-empty a { color: var(--accent-deep); }

/* ---------- 右栏：聊天窗 ---------- */

.dm-chat {
  min-width: 0;
  min-height: 0;
  display: flex;
}
.dm-chat > .empty-tip {
  flex: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dm-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
}

.dm-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--rule);
}
.dm-panel-head b { font-size: 15px; }
.dm-back {
  display: none;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}
.dm-av {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.dm-locktip { color: #b45309; font-size: 12.5px; margin-left: auto; }
.dm-del {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 16px;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s;
}
.dm-del:hover { opacity: 1; }
.dm-panel-head .dm-locktip + .dm-del { margin-left: 8px; }

/* 消息流：浅灰绿底，居中时间分隔，微信式头像+气泡 */
.dm-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f2f7f5;
}
.dm-time-sep {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}
.dm-empty {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.dm-msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 78%;
}
.dm-msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.dm-msg-av {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.dm-bubble {
  position: relative;
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
/* 气泡小尖朝向说话方 */
.dm-bubble::before {
  content: "";
  position: absolute;
  top: 12px;
  left: -6px;
  border: 5px solid transparent;
  border-right-color: #fff;
}
.dm-msg.mine .dm-bubble {
  background: var(--accent, #0d9f86);
  color: #fff;
}
.dm-msg.mine .dm-bubble::before {
  left: auto;
  right: -6px;
  border-right-color: transparent;
  border-left-color: var(--accent, #0d9f86);
}
.dm-bubble p { margin: 0; white-space: pre-wrap; }
.dm-bubble img {
  max-width: 240px;
  border-radius: 6px;
  display: block;
  margin-top: 4px;
}

/* 输入区：微信式「上边框 + 图片按钮 + 下划线输入 + 绿色发送」 */
.dm-composer {
  border-top: 1px solid var(--rule);
  padding: 10px 14px;
  background: #fff;
}
.dm-composer--locked {
  font-size: 13.5px;
  color: var(--ink-soft);
  text-align: center;
  padding: 16px;
}
.dm-composer--locked a { color: var(--accent, #0d9f86); }
.dm-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
}
.dm-preview img { max-height: 90px; border-radius: 8px; display: block; }
.dm-preview button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.dm-input-row { display: flex; align-items: center; gap: 10px; }
.dm-addimg {
  border: 0;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: color .15s;
}
.dm-addimg:hover { color: var(--accent-deep); }
.dm-input-row input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 7px 4px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
}
.dm-input-row input[type="text"]:focus { border-bottom-color: var(--accent, #0d9f86); }
.dm-input-row button[type="submit"] {
  border: 0;
  border-radius: 8px;
  background: var(--accent, #0d9f86);
  color: #fff;
  font-size: 13.5px;
  padding: 8px 20px;
  cursor: pointer;
  transition: opacity .15s;
}
.dm-input-row button[type="submit"]:disabled { opacity: .45; cursor: default; }

/* ---------- 移动端：单栏上下切换（微信手机版） ---------- */

@media (max-width: 760px) {
  body.page-dm main { margin-top: 10px; padding: 0 10px 24px; }
  .dm-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 120px);
  }
  .dm-back { display: block; }
  .dm-layout.has-chat .dm-list-pane { display: none; }
  .dm-layout:not(.has-chat) .dm-chat { display: none; }
  .dm-msg { max-width: 86%; }
}
