/* ===== 微聊 - 微信风格样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #f2f2f7; color: #111; font-size: 16px;
  user-select: none; -webkit-user-select: none;
}
#app { height: 100%; max-width: 520px; margin: 0 auto; position: relative; background: #f2f2f7; box-shadow: 0 0 20px rgba(0,0,0,.08); }

/* ---------- 视图切换 ---------- */
.view { position: absolute; inset: 0; display: none; flex-direction: column; background: #f2f2f7; }
.view.active { display: flex; }
.view-slide { z-index: 10; }

/* ---------- 导航栏 ---------- */
.navbar {
  height: calc(52px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px);
  background: #f7f7f8; border-bottom: .5px solid #d9d9de;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; flex-shrink: 0;
}
.navbar-title { position: absolute; left: 60px; right: 60px; text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar-back { padding: 0 12px; height: 52px; display: flex; align-items: center; color: #111; cursor: pointer; position: relative; z-index: 2; }
.navbar-back:active { opacity: .4; }
.navbar-right { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; color: #111; cursor: pointer; position: relative; z-index: 2; }
.navbar-right:active { opacity: .4; }

/* ---------- 登录 ---------- */
#view-login { background: linear-gradient(160deg, #0ec46a 0%, #07C160 45%, #059048 100%); }
.login-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo h1 { color: #fff; font-size: 30px; letter-spacing: 6px; margin-top: 12px; }
.login-logo p { color: rgba(255,255,255,.85); font-size: 14px; margin-top: 6px; letter-spacing: 2px; }
.login-form { width: 100%; max-width: 340px; }
.field { background: rgba(255,255,255,.96); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.field input { width: 100%; border: none; outline: none; padding: 15px 16px; font-size: 16px; background: transparent; }
.login-error { color: #ffe1e1; font-size: 13px; min-height: 20px; margin-bottom: 8px; text-align: center; }
.btn-primary {
  width: 100%; border: none; border-radius: 10px; padding: 15px;
  background: #fff; color: #07C160; font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .5; }
.login-switch { text-align: center; margin-top: 18px; color: rgba(255,255,255,.9); font-size: 14px; }
.login-switch span { text-decoration: underline; cursor: pointer; margin-left: 4px; }
.login-server { position: absolute; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); color: rgba(255,255,255,.8); font-size: 12px; }
.login-server .link { text-decoration: underline; cursor: pointer; margin-left: 6px; }

/* ---------- 页面容器 ---------- */
.page-container { flex: 1; position: relative; overflow: hidden; }
.page { position: absolute; inset: 0; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page.active { display: block; }

.conn-banner { background: #ffe9a8; color: #7a5c00; text-align: center; font-size: 13px; padding: 6px 0; position: sticky; top: 0; z-index: 5; }

/* ---------- 会话列表 ---------- */
.conv-item { display: flex; align-items: center; padding: 12px 14px; background: #fff; cursor: pointer; }
.conv-item:active { background: #ececf1; }
.conv-item + .conv-item { border-top: .5px solid #f0f0f4; }
.conv-body { flex: 1; min-width: 0; margin-left: 12px; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; }
.conv-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: #b2b2b8; margin-left: 8px; flex-shrink: 0; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.conv-last { font-size: 14px; color: #8a8a90; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-tip { text-align: center; color: #b2b2b8; font-size: 14px; padding: 60px 0; display: none; }

.badge { min-width: 18px; height: 18px; border-radius: 9px; background: #fa5151; color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 5px; flex-shrink: 0; }
.conv-badge { margin-left: 8px; }

/* ---------- 头像 ---------- */
.avatar { width: 46px; height: 46px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 19px; font-weight: 600; flex-shrink: 0; position: relative; }
.avatar-lg { width: 62px; height: 62px; font-size: 26px; border-radius: 10px; }
.avatar-sm { width: 40px; height: 40px; font-size: 16px; border-radius: 6px; }
.online-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #09BB07; border: 2px solid #fff; }

/* ---------- 通讯录 ---------- */
.contact-item { display: flex; align-items: center; padding: 10px 14px; background: #fff; cursor: pointer; }
.contact-item:active { background: #ececf1; }
.contact-item + .contact-item { border-top: .5px solid #f0f0f4; }
.contact-name { margin-left: 12px; font-size: 16px; }
.contact-status { margin-left: auto; font-size: 12px; color: #b2b2b8; }
.contact-status.online { color: #09BB07; }

/* ---------- 我 ---------- */
.me-header { display: flex; align-items: center; background: #fff; padding: 22px 16px; margin-bottom: 10px; }
.me-info { margin-left: 14px; min-width: 0; }
.me-nickname { font-size: 20px; font-weight: 600; }
.me-username { font-size: 13px; color: #8a8a90; margin-top: 4px; }
.me-signature { font-size: 13px; color: #8a8a90; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cell-group { background: #fff; margin-bottom: 10px; }
.cell { display: flex; align-items: center; padding: 14px 16px; cursor: pointer; }
.cell:active { background: #ececf1; }
.cell + .cell { border-top: .5px solid #f0f0f4; }
.cell-icon { font-size: 18px; margin-right: 12px; }
.cell-label { font-size: 16px; }
.cell-value { margin-left: auto; font-size: 13px; color: #8a8a90; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-arrow { color: #c7c7cc; font-size: 20px; margin-left: auto; }
.cell-value + .cell-arrow { margin-left: 6px; }
.cell-danger .cell-label { color: #fa5151; }

/* ---------- 底部 Tab ---------- */
.tabbar {
  height: calc(56px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #f7f7f8; border-top: .5px solid #d9d9de;
  display: flex; flex-shrink: 0;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8a8a90; cursor: pointer; position: relative; gap: 2px; }
.tab span { font-size: 11px; }
.tab.active { color: #07C160; }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); }

/* ---------- 聊天页 ---------- */
.navbar-chat .navbar-title small { display: block; font-size: 11px; color: #8a8a90; font-weight: 400; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; background: #ededf0; -webkit-overflow-scrolling: touch; }
.msg-row { display: flex; margin-bottom: 16px; align-items: flex-start; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-bubble {
  max-width: 68%; padding: 10px 12px; border-radius: 6px; font-size: 16px; line-height: 1.45;
  background: #fff; position: relative; word-break: break-word; white-space: pre-wrap;
  user-select: text; -webkit-user-select: text;
}
.msg-row.mine .msg-bubble { background: #95ec69; }
.msg-bubble::before { content: ''; position: absolute; top: 12px; border: 6px solid transparent; }
.msg-row:not(.mine) .msg-bubble::before { left: -11px; border-right-color: #fff; }
.msg-row.mine .msg-bubble::before { right: -11px; border-left-color: #95ec69; }
.msg-avatar { margin: 0 10px; }
.msg-time { text-align: center; font-size: 12px; color: #a8a8ae; margin: 10px 0; }
.msg-status { font-size: 11px; color: #a8a8ae; margin-top: 4px; text-align: right; }

.chat-input-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #f7f7f8; border-top: .5px solid #d9d9de; flex-shrink: 0;
}
.chat-input-bar input {
  flex: 1; border: none; outline: none; border-radius: 6px; padding: 10px 12px; font-size: 16px; background: #fff;
}
.chat-input-bar button {
  border: none; border-radius: 6px; padding: 10px 18px; font-size: 15px;
  background: #07C160; color: #fff; cursor: pointer; flex-shrink: 0;
}
.chat-input-bar button:disabled { background: #b5e8c9; }
.btn-img { display: flex; align-items: center; padding: 4px; cursor: pointer; flex-shrink: 0; }
.btn-img:active { opacity: .5; }
.btn-icon { display: flex; align-items: center; padding: 4px; cursor: pointer; flex-shrink: 0; }
.btn-icon:active { opacity: .5; }
.btn-icon.active svg { stroke: #07C160; }
#btn-talk { flex: 1; border: none; outline: none; border-radius: 6px; padding: 10px 12px; font-size: 16px; background: #fff; color: #333; cursor: pointer; }
#btn-talk.recording { background: #d9d9de; }
.msg-bubble.img-bubble { padding: 4px; background: transparent; }
.msg-bubble.img-bubble::before { display: none; }
.msg-bubble.img-bubble img { display: block; max-width: 200px; max-height: 240px; border-radius: 6px; cursor: pointer; }
#img-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 300; display: flex; align-items: center; justify-content: center; }
#img-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- 表情面板 ---------- */
.emoji-panel { grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px)); background: #f7f7f8; border-top: .5px solid #d9d9de; max-height: 216px; overflow-y: auto; flex-shrink: 0; }
.emoji-panel[style*="grid"] { display: grid; }
.emoji-item { font-size: 24px; text-align: center; padding: 5px 0; cursor: pointer; border-radius: 6px; line-height: 1.3; }
.emoji-item:active { background: #e0e0e6; }

/* ---------- 语音气泡 ---------- */
.voice-bubble { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.msg-row.mine .voice-bubble { flex-direction: row-reverse; }
.voice-bubble .voice-ico { font-size: 15px; }
.voice-bubble .voice-dur { font-size: 15px; }
.voice-bubble.playing .voice-ico { animation: voicepulse .8s infinite; }
@keyframes voicepulse { 50% { opacity: .25; } }
.msg-sender { font-size: 12px; color: #a8a8ae; margin: 0 0 2px 2px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 录音提示 ---------- */
#voice-hint { position: fixed; inset: 0; z-index: 250; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#voice-hint .vh-box { background: rgba(0,0,0,.65); color: #fff; border-radius: 12px; padding: 22px 28px; text-align: center; font-size: 13px; }
#voice-hint .vh-mic { font-size: 42px; margin-bottom: 8px; }

/* ---------- 发起群聊 ---------- */
.group-member-list { max-height: 220px; overflow-y: auto; margin: 2px 0 10px; border: 1px solid #eee; border-radius: 8px; }
.group-member { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 15px; cursor: pointer; }
.group-member + .group-member { border-top: .5px solid #f0f0f4; }
.group-member input { width: auto !important; margin: 0 !important; padding: 0 !important; border: none !important; }

/* ---------- 联系人详情 ---------- */
.contact-detail { flex: 1; overflow-y: auto; }
.cd-header { background: #fff; padding: 24px 16px; display: flex; align-items: center; margin-bottom: 10px; }
.cd-info { margin-left: 14px; }
.cd-nickname { font-size: 20px; font-weight: 600; }
.cd-username { font-size: 13px; color: #8a8a90; margin-top: 4px; }
.cd-signature { background: #fff; padding: 14px 16px; font-size: 14px; color: #666; margin-bottom: 10px; }
.cd-signature .label { color: #b2b2b8; font-size: 12px; display: block; margin-bottom: 4px; }
.cd-action { display: block; width: calc(100% - 32px); margin: 10px auto; border: none; border-radius: 10px; padding: 14px; background: #07C160; color: #fff; font-size: 16px; cursor: pointer; }
.cd-action:active { opacity: .85; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: 82%; max-width: 320px; padding: 20px; }
.modal h3 { font-size: 16px; margin-bottom: 14px; text-align: center; }
.modal input { width: 100%; border: 1px solid #e0e0e5; border-radius: 8px; padding: 11px 12px; font-size: 15px; outline: none; margin-bottom: 10px; }
.modal input:focus { border-color: #07C160; }
.modal .modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal .modal-btns button { flex: 1; border: none; border-radius: 8px; padding: 11px; font-size: 15px; cursor: pointer; }
.modal .btn-cancel { background: #f0f0f4; color: #333; }
.modal .btn-ok { background: #07C160; color: #fff; }
.modal .modal-tip { font-size: 13px; color: #8a8a90; text-align: center; line-height: 1.6; }

/* toast */
.toast { position: fixed; left: 50%; top: 45%; transform: translate(-50%,-50%); background: rgba(0,0,0,.72); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 200; }
