/* 聊天页现在是从首页联系人列表点开的整屏覆盖层，不是 tab 页内容——
   position:absolute 相对 .frame 铺满，默认滑到右边外面，.show 时滑入。 */
.hv-chat-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.hv-chat-overlay.show {
  transform: translateX(0);
}

.hv-chat-back-btn,
.hv-chat-menu-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  z-index: 2;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  padding: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hv-chat-back-btn { left: 10px; }
.hv-chat-menu-btn { right: 10px; }

.hv-chat-back-btn svg,
.hv-chat-menu-btn svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 顶部联系人资料区块：大头像+昵称+签名竖排的整块 */
.chat-profile {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: calc(46px + env(safe-area-inset-top)) 20px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.chat-avatar-lg-btn {
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.chat-avatar-lg-btn:active { transform: scale(0.92); }

.chat-name-lg {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.chat-sign-lg {
  font-size: 11px;
  color: var(--text);
  opacity: 0.6;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 右上角三条杠弹出的菜单：人设指令/会话列表/页面美化/会话设置 */
.hv-chat-menu-mask {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.hv-chat-menu-mask.show { opacity: 1; pointer-events: auto; }

.hv-chat-menu-drawer {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top));
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 4;
  width: 70%;
  max-width: 260px;
  background: var(--bg-base);
  border-radius: 22px;
  overflow: hidden;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.hv-chat-menu-drawer.show { transform: translateX(0); }

.hv-chat-menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 12px;
}

.hv-chat-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 6px;
  border: none;
  background: none;
  border-radius: 14px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.hv-chat-menu-item-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-tint);
  border: 1px solid var(--border-soft);
}

.hv-chat-menu-item-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 消息列表 */
.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 20px 14px 14px;
}

.chat-msg-row {
  display: flex;
  justify-content: flex-end;
}

.chat-msg-row.theirs {
  justify-content: flex-start;
}

.chat-msg-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 82%;
}

.chat-msg-row.theirs .chat-msg-col {
  align-items: flex-start;
}

.chat-msg-row:not(.theirs) .chat-msg-col {
  align-items: flex-end;
}

/* 一次回复按 [seg] 拆成的每一段都是独立气泡，不是同一个气泡里的换行 */
.chat-msg-bubble {
  padding: 7px 12px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--accent);
  color: #fff;
}

.chat-msg-bubble.theirs {
  cursor: pointer;
  background: var(--card-tint);
  color: var(--text);
  border: 1px solid var(--border-soft);
}

/* 折叠的完整原文——点一下对方气泡才展开，样式故意做得比气泡轻，像引用块 */
.chat-msg-raw {
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--border-soft);
  font-size: 11px;
  line-height: 1.5;
  font-style: italic;
  color: var(--text-soft);
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-raw[hidden] {
  display: none;
}

.chat-msg-time {
  font-size: 10px;
  color: var(--text-soft);
}

.chat-system-notice {
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
  padding: 4px 0;
}

/* 输入区：胶囊输入框（加号在胶囊里靠左）+ 外面单独的圆形发送按钮 */
.chat-input-row {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
}

.chat-input-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  border-radius: 19px;
  border: 1px solid var(--border-soft);
  background: var(--card-tint);
}

.hv-chat-plus-btn {
  flex-shrink: 0;
  width: 30px;
  height: 38px;
  margin-left: 4px;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hv-chat-plus-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.chat-input-pill textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  height: 38px;
  max-height: 120px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  padding: 9px 14px 9px 2px;
  line-height: 1.3;
}

.chat-input-pill textarea::placeholder {
  color: var(--text-soft);
  opacity: 0.6;
}

.chat-send-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 资料卡弹窗 */
.profile-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-modal-card {
  width: 82%;
  max-width: 320px;
  border-radius: 20px;
  padding: 24px 20px;
  background: var(--card-tint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.profile-modal-avatar-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.profile-modal-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.profile-modal-bio-input {
  width: 100%;
  resize: none;
  height: 60px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-base);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.profile-modal-status {
  font-size: 11px;
  color: var(--text-soft);
  min-height: 14px;
}

.profile-modal-btn-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.profile-modal-save-btn,
.profile-modal-close-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 9px 0;
  font-size: 13px;
  cursor: pointer;
}

.profile-modal-save-btn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.profile-modal-close-btn {
  background: var(--bg-base);
  color: var(--text-soft);
}
