/* IM 聊天 App · 移动端原生观感样式 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #F2F3F5;
  color: #1F2329;
  font-size: 15px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

:root {
  --brand: #FF6B35;
  --brand-2: #FF9466;
  --brand-soft: #FFF1EB;
  --text: #1F2329;
  --sub: #8A9099;
  --line: #EFEFEF;
  --danger: #F04E4E;
  --bg: #F2F3F5;
  --card: #FFFFFF;
  --radius: 18px;
}

/* ---------------- 视图容器 ---------------- */
.view {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.view[hidden] { display: none; }

/* ---------------- 顶部导航 ---------------- */
.nav {
  flex: 0 0 auto;
  height: 52px;
  padding: 0 8px;
  display: flex; align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  position: relative;
  z-index: 5;
}
.nav .back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: #333; cursor: pointer;
  border-radius: 50%;
}
.nav .back:active { background: #F2F2F2; }
.nav .title {
  flex: 1; text-align: center;
  font-size: 17px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin: 0 4px;
}
.nav .act {
  min-width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--brand); cursor: pointer; padding: 0 8px;
}

/* ---------------- 滚动区 ---------------- */
.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.list { background: #fff; }

/* ---------------- Tab 栏 ---------------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: #9AA0A6;
  cursor: pointer; user-select: none;
}
.tab .ico { font-size: 21px; line-height: 1; }
.tab.on { color: var(--brand); }
.tab.on .ico { transform: translateY(-1px); }

/* ---------------- 登录页 ---------------- */
.auth-wrap {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: 0 26px;
  background: linear-gradient(180deg, #FFF4EF 0%, #F2F3F5 40%);
  padding-top: calc(env(safe-area-inset-top) + 64px);
}
.auth-logo {
  width: 76px; height: 76px; border-radius: 22px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff;
  margin-bottom: 14px;
}
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.auth-sub { font-size: 13px; color: var(--sub); margin-top: 6px; margin-bottom: 30px; }
.field {
  background: #fff;
  border-radius: 16px;
  padding: 0 16px;
  height: 52px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.field .ico { font-size: 17px; color: #C6CBD4; }
.field input {
  flex: 1; border: 0; outline: 0; font-size: 15px;
  background: transparent; color: var(--text); min-width: 0;
}
.field input::placeholder { color: #B9BEC7; }
.btn-primary {
  width: 100%; height: 52px; border: 0; border-radius: 26px;
  background: linear-gradient(135deg, var(--brand), #FF8A4C);
  color: #fff; font-size: 16px; font-weight: 600;
  margin-top: 8px; cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .55; }
.auth-switch {
  text-align: center; margin-top: 22px;
  font-size: 14px; color: var(--sub);
}
.auth-switch b { color: var(--brand); font-weight: 600; cursor: pointer; margin-left: 4px; }
.auth-tip {
  margin-top: auto; padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
  text-align: center; font-size: 12px; color: #A9AFB8; line-height: 1.7;
}

/* ---------------- 会话列表 ---------------- */
.conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  background: #fff;
  cursor: pointer;
  transition: background .12s;
}
.conv-item:active { background: #F7F7F8; }
.avatar {
  width: 48px; height: 48px; border-radius: 15px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #FFD9C8, #FFB899);
  color: #fff; font-size: 17px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
.avatar.lg { width: 82px; height: 82px; border-radius: 26px; font-size: 28px; }

.conv-main { flex: 1; min-width: 0; }
.conv-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.conv-name {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { font-size: 11px; color: #A9AFB8; flex: 0 0 auto; }
.conv-bottom {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px; gap: 8px;
}
.conv-last {
  font-size: 13px; color: var(--sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.badge.self { background: var(--brand); }

/* ---------------- 空状态 ---------------- */
.empty {
  padding: 90px 30px; text-align: center; color: #B2B7C0;
}
.empty .ico { font-size: 44px; opacity: .5; margin-bottom: 12px; display: block; }
.empty p { font-size: 14px; margin: 0; line-height: 1.7; }

/* ---------------- 聊天页 ---------------- */
.chat-view { background: #F2F3F5; }
.chat-banner {
  flex: 0 0 auto;
  background: var(--brand-soft);
  color: #C4562A;
  font-size: 12px;
  padding: 8px 16px;
  line-height: 1.6;
  display: flex; align-items: flex-start; gap: 6px;
  border-bottom: 1px solid #FFE3D6;
}
.chat-banner .i { flex: 0 0 auto; }

.chat-scroll { padding: 12px 0 20px; }

.msg-row { display: flex; padding: 4px 12px; align-items: flex-end; gap: 8px; }
.msg-row.me { justify-content: flex-end; }

.msg-body { max-width: 70%; display: flex; flex-direction: column; gap: 4px; }
.msg-row.me .msg-body { align-items: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  background: #fff;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}
.msg-row.me .bubble {
  background: linear-gradient(135deg, var(--brand), #FF8A4C);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-row.you .bubble { border-bottom-left-radius: 6px; }

.bubble.img { padding: 5px; background: #fff; }
.msg-row.me .bubble.img { background: #fff; }
.bubble.img img {
  display: block;
  max-width: 190px;
  max-height: 240px;
  border-radius: 14px;
  object-fit: cover;
}

.msg-meta {
  font-size: 11px;
  color: #A9AFB8;
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px;
}
.msg-meta .destroy {
  color: #C9793C;
  background: #FFF2E8;
  border-radius: 8px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.msg-meta .destroy.soon { color: #E0453A; background: #FFEDEC; }

.sys-line {
  text-align: center;
  font-size: 12px;
  color: #A9AFB8;
  margin: 10px 0;
}

/* ---------------- 输入区 ---------------- */
.chat-input {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 8px;
}
.chat-input .plus {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 12px; background: #F4F5F7;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #6B7280; cursor: pointer;
}
.chat-input .plus:active { background: #E9EAEC; }
.chat-input textarea {
  flex: 1; min-width: 0;
  border: 0; outline: 0; resize: none;
  background: #F4F5F7; border-radius: 14px;
  padding: 10px 14px;
  font-size: 15px; line-height: 1.4;
  max-height: 110px;
  font-family: inherit;
}
.send-btn {
  flex: 0 0 auto;
  height: 38px; padding: 0 18px;
  border: 0; border-radius: 19px;
  background: linear-gradient(135deg, var(--brand), #FF8A4C);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.send-btn:disabled { opacity: .45; }

/* ---------------- 通讯录 ---------------- */
.cell {
  display: flex; align-items: center; gap: 12px;
  background: #fff; padding: 13px 16px; cursor: pointer;
}
.cell:active { background: #F7F7F8; }
.cell .ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex: 0 0 auto;
}
.cell .ico.orange { background: #FFF1EB; }
.cell .ico.blue { background: #EAF2FF; }
.cell .ico.green { background: #EAF8F0; }
.cell .ico.gray { background: #F2F3F5; }
.cell-main { flex: 1; min-width: 0; }
.cell-title { font-size: 15px; font-weight: 500; }
.cell-desc { font-size: 12px; color: var(--sub); margin-top: 2px; }
.cell .arrow { color: #C6CBD4; font-size: 16px; }

.section-label {
  padding: 16px 16px 8px;
  font-size: 13px; color: var(--sub);
}

/* ---------------- 我的 ------------- */
.profile-head {
  background: linear-gradient(160deg, #FF8A4C, #FF6B35);
  padding: 26px 20px 34px;
  display: flex; align-items: center; gap: 16px;
  padding-top: calc(env(safe-area-inset-top) + 26px);
}
.profile-head .avatar { border: 3px solid rgba(255,255,255,.75); }
.profile-info { flex: 1; min-width: 0; color: #fff; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-sub { font-size: 12px; opacity: .85; margin-top: 5px; }
.profile-card {
  margin: -18px 14px 14px;
  background: #fff; border-radius: var(--radius);
  overflow: hidden;
}
.profile-rules {
  margin: 0 14px 16px;
  background: #fff; border-radius: var(--radius);
  padding: 16px;
  font-size: 13px; color: var(--sub); line-height: 1.8;
}
.profile-rules b { color: var(--text); display: block; margin-bottom: 6px; font-size: 14px; }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.mask[hidden] { display: none; }
.dialog {
  width: 100%; max-width: 320px;
  background: #fff; border-radius: 20px;
  padding: 22px 20px 16px;
  text-align: center;
}
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 18px; font-size: 14px; color: var(--sub); line-height: 1.6; }
.dialog .row { display: flex; gap: 10px; }
.dialog .row button {
  flex: 1; height: 44px; border: 0; border-radius: 22px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.dialog .cancel { background: #F2F3F5; color: #4A5058; }
.dialog .confirm { background: linear-gradient(135deg, var(--brand), #FF8A4C); color: #fff; }

.toast {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  background: rgba(0,0,0,.78);
  color: #fff; font-size: 14px;
  padding: 11px 18px; border-radius: 12px;
  z-index: 300; max-width: 78%;
  text-align: center; line-height: 1.5;
  pointer-events: none;
  opacity: 0; transition: opacity .18s;
}
.toast.show { opacity: 1; }

/* ---------------- 通话页 ---------------- */
.call-view {
  background: linear-gradient(180deg, #2A2E38, #17191E);
  color: #fff;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 60px) 20px calc(env(safe-area-inset-bottom) + 46px);
}
.call-avatar {
  width: 100px; height: 100px; border-radius: 32px;
  background: linear-gradient(135deg, #FFD9C8, #FFB899);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 600; color: #fff;
  overflow: hidden;
  box-shadow: 0 0 0 8px rgba(255,255,255,.06);
}
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-name { font-size: 22px; font-weight: 600; margin-top: 22px; }
.call-state { font-size: 14px; opacity: .62; margin-top: 8px; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: 34px; align-items: center; }
.call-btn {
  width: 62px; height: 62px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 25px; cursor: pointer; border: 0;
  color: #fff; background: rgba(255,255,255,.14);
}
.call-btn .lbl { font-size: 10px; margin-top: 2px; opacity: .8; }
.call-btn.hangup { background: #F04E4E; }
.call-btn.answer { background: #22C55E; }

/* ---------------- 悬浮通知 ---------------- */
.invite-banner {
  position: fixed; left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 8px);
  background: #fff; border-radius: 16px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  z-index: 180;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.invite-banner[hidden] { display: none; }
.invite-banner .t { flex: 1; min-width: 0; font-size: 14px; }
.invite-banner .t small { display: block; color: var(--sub); font-size: 12px; margin-top: 2px; }
.invite-banner .go {
  background: var(--brand); color: #fff;
  border: 0; border-radius: 14px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  flex: 0 0 auto;
}
.invite-banner .x {
  color: #B9BEC7; font-size: 18px; padding: 0 2px; cursor: pointer;
  flex: 0 0 auto;
}

/* ---------------- 工具类 ---------------- */
.row-flex { display: flex; align-items: center; }
.gap8 { gap: 8px; }
.p16 { padding: 16px; }
.mtb12 { margin: 12px 0; }
.fs12 { font-size: 12px; }
.muted { color: var(--sub); }
.center { text-align: center; }
.pt8 { padding-top: 8px; }
.divider { height: 1px; background: var(--line); margin-left: 16px; }
