/* 好友与私聊 */
#view-friends {
  max-width: var(--app-shell-max, 520px);
  margin: 0 auto;
}

/* —— 私聊：飞书/微信式全屏 —— */
#view-dm:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  flex-direction: column;
  background: #ebedf0;
  max-width: none;
  margin: 0;
}

.dm-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: var(--app-shell-max, 520px);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  background: #ededed;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04);
}

/* 顶栏 */
.dm-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 10px;
  background: #fff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.dm-topbar-spacer {
  width: 72px;
  flex-shrink: 0;
}

.dm-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: #e60012;
  font-size: 15px;
  padding: 6px 4px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 72px;
}

.dm-back-ico {
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
  margin-top: -2px;
}

.dm-back-txt {
  font-weight: 500;
}

.dm-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.dm-peer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
}

.dm-peer-meta {
  min-width: 0;
  text-align: left;
}

.dm-peer-name {
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}

.dm-peer-dept {
  font-size: 12px;
  color: #64748b;
  margin-top: 1px;
}

/* 消息区：微信/飞书 — 自上而下排列，进入会话滚到最新 */
.dm-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ededed;
}

.dm-msgs-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}

.dm-msgs {
  box-sizing: border-box;
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dm-msgs-anchor {
  height: 1px;
  flex-shrink: 0;
  pointer-events: none;
}

.dm-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.dm-msg.dm-msg--chain {
  margin-top: -6px;
  margin-bottom: 14px;
}

.dm-msg.dm-msg--chain .dm-msg-avatar {
  visibility: hidden;
}

.dm-msg.me {
  justify-content: flex-end;
}

.dm-msg.peer {
  justify-content: flex-start;
}

.dm-msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}

.dm-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 52px);
  flex: 0 1 auto;
}

.dm-msg.me .dm-bubble-wrap {
  align-items: flex-end;
  max-width: min(72vw, 280px);
}

.dm-msg.peer .dm-bubble-wrap {
  align-items: flex-start;
  max-width: min(72vw, 280px);
}

.dm-bubble {
  position: relative;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  word-break: break-word;
  text-align: left;
}

/* 己方：主题红（略柔和），圆角仿微信 */
.dm-msg.me .dm-bubble {
  background: #fa5151;
  color: #fff;
  border-top-right-radius: 2px;
}

.dm-msg.me .dm-bubble::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 10px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left-color: #fa5151;
  border-right: 0;
}

.dm-msg.me.dm-msg--chain .dm-bubble::after {
  display: none;
}

/* 对方：白底 */
.dm-msg.peer .dm-bubble {
  background: #fff;
  color: #191919;
  border-top-left-radius: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.dm-msg.peer .dm-bubble::after {
  content: '';
  position: absolute;
  left: -5px;
  top: 10px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}

.dm-msg.peer.dm-msg--chain .dm-bubble::after {
  display: none;
}

/* 时间 / 日期：居中灰条（微信样式） */
.dm-day-sep,
.dm-time-sep {
  display: flex;
  justify-content: center;
  margin: 6px 0 12px;
  flex-shrink: 0;
}

.dm-day-sep span,
.dm-time-sep span {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}

/* 底栏输入：固定贴底 */
.dm-composer {
  flex-shrink: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #f7f8fa;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.dm-composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.dm-input {
  flex: 1;
  min-height: 22px;
  max-height: 100px;
  margin: 6px 0;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.45;
  background: transparent;
  color: #0f172a;
  resize: none;
  overflow-y: auto;
  overflow-x: hidden;
  appearance: none;
  -webkit-appearance: none;
  field-sizing: content;
}

.dm-input:focus {
  outline: none;
}

.dm-input::placeholder {
  color: #94a3b8;
}

.dm-input::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.dm-send {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  min-width: 56px;
  height: 34px;
  padding: 0 14px;
  margin-bottom: 2px;
  background: #e60012;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.dm-send:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.dm-send:not(:disabled):active {
  transform: scale(0.96);
  opacity: 0.92;
}

.dm-msgs:empty::before {
  content: '暂无消息，打个招呼吧';
  display: block;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 32px 16px 48px;
}

body:has(#view-dm:not(.hidden)) {
  overflow: hidden;
}

body:has(#view-dm:not(.hidden)) .yc-assist-fab,
body:has(#view-dm:not(.hidden)) .yc-feedback-fab {
  display: none !important;
}

/* —— 好友列表 —— */
.friends-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin: 12px;
  border-radius: 14px;
}

.friends-back {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  padding: 4px 0;
  cursor: pointer;
  flex-shrink: 0;
}

.friends-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.friends-section {
  margin: 0 12px 12px;
}

.friends-section-h {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px 4px;
}

.friends-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.friends-add-row {
  display: flex;
  gap: 8px;
}

.friends-add-row .input {
  flex: 1;
}

.friends-lookup {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  font-size: 14px;
}

.friends-lookup.hidden {
  display: none;
}

.friend-item,
.dm-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  cursor: pointer;
}

.friend-item:last-child,
.dm-conv-item:last-child {
  border-bottom: none;
}

.friend-item__avatar,
.dm-conv-item__avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
}

.friend-item__body,
.dm-conv-item__body {
  flex: 1;
  min-width: 0;
}

.friend-item__name,
.dm-conv-item__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.friend-item__sub,
.dm-conv-item__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-item__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.friend-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.friend-btn--primary {
  background: linear-gradient(135deg, #ff1a2d, #e60012);
  color: #fff;
}

.friend-btn--ghost {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
}

.friends-badge,
.mine-menu__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.mine-menu__badge.hidden,
.friends-badge.hidden {
  display: none;
}

/* —— 我的 · 功能入口菜单 —— */
.mine-menu {
  padding: 14px 14px 10px !important;
}

.mine-menu__label {
  margin: 0 0 10px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.mine-menu__list {
  display: flex;
  flex-direction: column;
}

.mine-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 8px;
  margin: 0;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

.mine-menu__item:not(:last-child) {
  margin-bottom: 2px;
}

.mine-menu__item:active {
  background: rgba(22, 93, 255, 0.06);
}

@media (hover: hover) {
  .mine-menu__item:hover {
    background: rgba(22, 93, 255, 0.05);
  }
}

.mine-menu__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mine-menu__icon svg {
  width: 22px;
  height: 22px;
}

.mine-menu__icon--admin {
  color: #7c3aed;
  background: linear-gradient(145deg, #ede9fe 0%, #ddd6fe 100%);
}

.mine-menu__icon--kb {
  color: #1d4ed8;
  background: linear-gradient(145deg, #dbeafe 0%, #bfdbfe 100%);
}

.mine-menu__icon--friends {
  color: #0d9488;
  background: linear-gradient(145deg, #ccfbf1 0%, #99f6e4 100%);
}

.mine-menu__icon--game {
  color: #ea580c;
  background: linear-gradient(145deg, #ffedd5 0%, #fed7aa 100%);
}

.mine-menu__tag--fun {
  color: #c2410c;
  background: rgba(234, 88, 12, 0.12);
}

.mine-menu__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mine-menu__title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.mine-menu__desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.mine-menu__tag {
  display: inline-block;
  align-self: flex-start;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.1);
}

.mine-menu__chev {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mine-menu__chev svg {
  width: 18px;
  height: 18px;
}

/* 兼容旧类名（其它页若仍用 friends-entry-btn） */
.friends-entry-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  background: var(--card);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.friends-entry-btn__left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.friends-entry-btn__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.friends-entry-btn__sub {
  font-size: 12px;
  color: var(--muted);
}

.friends-entry-btn__arrow {
  color: var(--muted);
  font-size: 18px;
}

.friends-flash {
  margin: 0 12px 8px;
  font-size: 13px;
  min-height: 18px;
}

.friends-flash.err {
  color: #dc2626;
}

.friends-flash.ok {
  color: #16a34a;
}

.friends-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
}
