/* ===== 基础 ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px; color: #111;
  background: #ededed;
}
body { display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===== 屏幕容器 ===== */
.screen {
  position: absolute; inset: 0; bottom: 54px;
  display: flex; flex-direction: column;
  background: #ededed;
}

/* ===== 顶栏 ===== */
.topbar {
  flex: 0 0 auto; height: 48px; display: flex; align-items: center; justify-content: center;
  position: relative; background: #ededed; border-bottom: 1px solid #d6d6d6;
  padding-top: env(safe-area-inset-top);
  height: calc(48px + env(safe-area-inset-top));
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 22px; line-height: 1; color: #333; padding: 6px;
}

/* ===== 微信会话列表 ===== */
.chatlist { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff; }
.chat-item { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.chat-item:active { background: #f2f2f2; }
.avatar {
  width: 48px; height: 48px; border-radius: 6px; flex: 0 0 auto;
  background: #c8c8c8; color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-main { flex: 1; min-width: 0; margin-left: 12px; }
.chat-name-row { display: flex; justify-content: space-between; align-items: baseline; }
.chat-name { font-size: 16px; font-weight: 500; }
.chat-time { font-size: 12px; color: #b2b2b2; flex: 0 0 auto; margin-left: 8px; }
.chat-preview {
  font-size: 14px; color: #9a9a9a; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge {
  background: #fa5151; color: #fff; font-size: 11px; border-radius: 9px;
  min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px;
  margin-left: 8px; flex: 0 0 auto;
}

/* ===== 聊天窗口 ===== */
.chatview {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; background: #ededed;
}
.chat-topbar { justify-content: center; }
.back {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 30px; line-height: 1; color: #333; padding: 4px 12px;
}
.chat-title { font-size: 17px; font-weight: 600; }
.chat-more {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: #576b95; padding: 6px;
}
.msglist {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px 16px; background: #ededed;
}

/* 时间分隔线 */
.date-divider { text-align: center; margin: 12px 0 8px; }
.date-divider span {
  background: #d8d8d8; color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 3px;
}

/* 消息行 */
.msg-row { display: flex; margin-bottom: 14px; align-items: flex-start; }
.msg-row.me { flex-direction: row-reverse; }
.msg-avatar {
  width: 40px; height: 40px; border-radius: 5px; flex: 0 0 auto;
  background: #c8c8c8; color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-body { max-width: 68%; margin: 0 10px; }

/* 气泡 */
.bubble {
  position: relative; padding: 9px 12px; border-radius: 6px;
  font-size: 16px; line-height: 1.42; word-break: break-word; white-space: pre-wrap;
  background: #fff;
}
.msg-row.me .bubble { background: #95ec69; }
.bubble::after {
  content: ""; position: absolute; top: 12px; width: 0; height: 0;
  border: 6px solid transparent;
}
.msg-row.him .bubble::after { left: -11px; border-right-color: #fff; }
.msg-row.me .bubble::after { right: -11px; border-left-color: #95ec69; }

/* 语音条 */
.voice-bubble {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 6px; background: #fff; cursor: pointer;
  position: relative; min-width: 90px;
}
.msg-row.me .voice-bubble { background: #95ec69; flex-direction: row-reverse; }
.voice-bubble::after {
  content: ""; position: absolute; top: 12px; width: 0; height: 0; border: 6px solid transparent;
}
.msg-row.him .voice-bubble::after { left: -11px; border-right-color: #fff; }
.msg-row.me .voice-bubble::after { right: -11px; border-left-color: #95ec69; }
.voice-waves { display: flex; align-items: center; gap: 2px; height: 16px; }
.voice-waves i { display: block; width: 2px; background: #555; border-radius: 1px; }
.voice-dur { font-size: 13px; color: #666; }
.msg-row.me .voice-dur { color: #3a6b1f; }
.voice-transcript {
  margin-top: 6px; font-size: 13px; color: #8a8a8a; line-height: 1.5;
  border-top: 1px dashed #ddd; padding-top: 6px; display: none;
}
.voice-wrap.expanded .voice-transcript { display: block; }
.msg-row.me .voice-transcript { color: #4a7a2a; border-top-color: rgba(0,0,0,.12); }

/* 正在输入 */
.typing .bubble { padding: 12px 14px; }
.typing .dots { display: flex; gap: 4px; }
.typing .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #bbb; display: block;
  animation: blink 1.2s infinite both;
}
.typing .dots i:nth-child(2) { animation-delay: .2s; }
.typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .3 } 40% { opacity: 1 } }

/* ===== 输入栏 ===== */
.inputbar {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: #f7f7f7; border-top: 1px solid #d6d6d6;
}
.input {
  flex: 1; min-width: 0; border: none; border-radius: 6px; padding: 9px 12px;
  font-size: 16px; background: #fff; outline: none; font-family: inherit;
}
.send {
  flex: 0 0 auto; background: #07c160; color: #fff; border-radius: 6px;
  padding: 0 18px; font-size: 15px; font-weight: 500;
}
.send:disabled { opacity: .5; }

/* ===== 线下见面 ===== */
/* 每次见面之间的分隔 */
.meeting-divider { position: relative; text-align: center; margin: 30px 0 20px; }
.meeting-divider:first-child { margin-top: 4px; }
.meeting-divider span {
  display: inline-block; position: relative; z-index: 1;
  padding: 3px 12px; border-radius: 12px; background: #e2e2e2;
  color: #8a8a8a; font-size: 12px;
}
.meeting-divider::before {
  content: ""; position: absolute; left: 6%; right: 6%; top: 50%;
  height: 1px; background: #dcdcdc;
}
.rp-empty { text-align: center; padding: 70px 30px; color: #999; }
.rp-empty p { font-size: 14px; line-height: 1.8; margin: 0 0 20px; }
.rp-empty .btn { display: inline-block; padding: 12px 28px; background: #07c160; color: #fff; }
.rp-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px; }
.rp-block { margin-bottom: 16px; line-height: 1.75; font-size: 16px; }
.rp-block.me { text-align: right; }
.rp-block .rp-actor { font-weight: 600; color: #07c160; font-size: 13px; display: block; margin-bottom: 3px; }
.rp-block.me .rp-actor { color: #576b95; }
.rp-action { color: #9a9a9a; font-style: italic; }
.rp-speech { color: #111; }

/* ===== 设置 ===== */
.settings { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 30px; }
.set-group { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.set-label { font-size: 13px; color: #888; margin-bottom: 8px; }
.set-hint { font-size: 12px; color: #aaa; margin-top: 6px; line-height: 1.5; }
.set-group .input { background: #f4f4f4; width: 100%; }
.field { margin-bottom: 10px; }
.field-name { font-size: 12px; color: #999; margin-bottom: 4px; }
.set-group .range-row { display: flex; align-items: center; gap: 8px; }
.set-group .range-row .num { width: 62px; flex: 0 0 auto; text-align: center; }
.range-sep { font-size: 13px; color: #888; flex: 0 0 auto; }
textarea.input { min-height: 66px; resize: vertical; line-height: 1.5; }
.row-line { display: flex; align-items: center; font-size: 14px; color: #444; margin-bottom: 8px; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; font-size: 14px; color: #333; line-height: 1.55; }
.switch-row small { display: block; color: #999; font-size: 12px; margin-top: 4px; line-height: 1.55; }
.switch-row input { width: 22px; height: 22px; flex: 0 0 auto; margin: 2px 0 0; accent-color: #07c160; }
.persona-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.persona-tab {
  padding: 7px 14px; border-radius: 16px; background: #f0f0f0; font-size: 14px; color: #444;
}
.persona-tab.active { background: #07c160; color: #fff; }
.persona-actions { display: flex; gap: 8px; }
.btn {
  flex: 1; padding: 10px; border-radius: 8px; background: #f0f0f0; color: #333;
  font-size: 14px; text-align: center;
}
.btn.primary { background: #07c160; color: #fff; }
.btn.danger { background: #fff0f0; color: #e64340; }

/* ===== 底部弹出选择 ===== */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #f7f7f7; border-radius: 14px 14px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-title { font-size: 14px; color: #888; text-align: center; margin-bottom: 14px; }
.sheet-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sheet-option {
  background: #fff; border-radius: 10px; padding: 15px 16px; text-align: center;
  font-size: 16px; color: #222;
}
.sheet-option:active { background: #efefef; }
.sheet-option small { display: block; font-size: 12px; color: #aaa; margin-top: 3px; }
.sheet-panel .btn { background: #fff; }

/* 版本切换条（对方一轮回复有多个版本时） */
.verbar { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -8px 0 16px; }
.ver-btn {
  width: 26px; height: 26px; line-height: 24px; text-align: center;
  border-radius: 50%; background: #dcdcdc; color: #555; font-size: 16px;
}
.ver-btn:active { background: #c9c9c9; }
.ver-idx { font-size: 12px; color: #999; letter-spacing: .5px; }

/* 编辑面板 */
.edit-area { width: 100%; background: #fff; margin-bottom: 12px; min-height: 84px; }
.sheet-panel .btn.edit-save { background: #07c160; color: #fff; margin-bottom: 8px; }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(54px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #f7f7f7; border-top: 1px solid #d6d6d6;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: #999;
}
.tab.active { color: #07c160; }
.tab-ico { font-size: 19px; line-height: 1; }

/* ===== 首次设置 ===== */
.setup { position: fixed; inset: 0; z-index: 50; background: #ededed; display: flex; align-items: center; justify-content: center; padding: 24px; }
.setup-box { width: 100%; max-width: 360px; text-align: center; }
.setup-emoji { font-size: 46px; margin-bottom: 10px; }
.setup-box h2 { font-size: 20px; margin: 0 0 8px; }
.setup-box p { font-size: 14px; color: #888; line-height: 1.6; margin: 0 0 18px; }
.setup-box .input { width: 100%; background: #fff; margin-bottom: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 14px; padding: 10px 18px;
  border-radius: 8px; z-index: 99; max-width: 80%; text-align: center; line-height: 1.4;
}
