/* 私信页（/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: none;
  margin: 0;
  padding: 0;
}
body.page-dm .site-foot { display: none; }

.dm-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - var(--dm-nav-h, 60px));
  height: calc(100dvh - var(--dm-nav-h, 60px));
}

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

.dm-list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-3);
  border-right: 1px solid var(--rule);
  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(219, 88, 15, .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(219, 88, 15, .07); }
.dm-contact.current { background: rgba(219, 88, 15, .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);
  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-more { position: relative; margin-left: auto; }
.dm-panel-head .dm-locktip + .dm-more { margin-left: 8px; }
.dm-more-btn {
  border: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background .12s, color .12s;
}
.dm-more-btn:hover,
.dm-more-btn[aria-expanded="true"] {
  background: rgba(219, 88, 15, .08);
  color: var(--accent-deep);
}
.dm-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 132px;
  padding: 6px;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.dm-more-menu button {
  border: 0;
  background: none;
  text-align: left;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.dm-more-menu button:hover { background: rgba(219, 88, 15, .08); }
.dm-more-menu .dm-more-danger { color: var(--danger); }

/* 消息流：浅灰绿底，居中时间分隔，微信式头像+气泡 */
.dm-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper-2);
}
.dm-time-sep {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}
/* 顶部「查看更早的消息」 */
.dm-older {
  align-self: center;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-family: inherit;
  padding: 5px 16px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.dm-older:hover {
  color: var(--accent-deep);
  border-color: var(--accent-soft);
}
.dm-older:disabled { opacity: .5; cursor: default; }
/* 撤回系统条：居中胶囊 */
.dm-recalled {
  align-self: center;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 14px;
}
.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: var(--paper-3);
  border: 1px solid var(--rule);
  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: var(--paper-3);
}
.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; font-family: var(--kai); font-size: 14.5px; }
.dm-bubble img {
  max-width: 240px;
  border-radius: 6px;
  display: block;
  margin-top: 4px;
}
/* 2 分钟内自己消息旁的「撤回」小按钮 */
.dm-recall {
  align-self: center;
  flex: none;
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s;
}
.dm-recall:hover { color: var(--danger); }

/* 输入区：微信式「上边框 + 图片按钮 + 下划线输入 + 绿色发送」 */
.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-input-row { display: flex; align-items: center; gap: 10px; }
.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) {
  .dm-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - var(--dm-nav-h, 56px));
    height: calc(100dvh - var(--dm-nav-h, 56px));
  }
  .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%; }
}
