/* nmchat-h5 样式 —— 双主题：默认深色（清爽青绿），html[data-theme="light"] 亮色 */
:root {
  --bg: #0e1d1a;
  --bg-soft: #122621;
  --card: #15302a;
  --bg-deep: #0a1411;
  --primary: #31c796;
  --primary-2: #23a97e;
  --primary-soft: rgba(49, 199, 150, .18);
  --text: #e8f5f0;
  --text-dim: #7fa398;
  --line: #1f4038;
  --danger: #ff5c7a;
  --danger-soft: rgba(255, 92, 122, .4);
  --ok: #34d399;
  --hover: rgba(255, 255, 255, .05);
  --hover-strong: rgba(255, 255, 255, .12);
  --bg-active: #1b3d34;
  --warn-bg: #2a2415;
  --warn-text: #ffd98a;
  --bot: #c9b6ff;
  --bot-soft: rgba(124, 92, 255, .22);
  --gold: #ffc159;
  --gold-text: #ffc159;
  --gold-line: rgba(255, 193, 89, .35);
  --gold-soft: rgba(255, 193, 89, .12);
}

html[data-theme="light"] {
  --bg: #f4faf8;
  --bg-soft: #e9f4f0;
  --card: #ffffff;
  --bg-deep: #ecf5f1;
  --primary: #0f8a68;
  --primary-2: #0c6e54;
  --primary-soft: rgba(15, 138, 104, .14);
  --text: #17332c;
  --text-dim: #5f7d74;
  --line: #d9e8e2;
  --danger: #d94b66;
  --danger-soft: rgba(217, 75, 102, .35);
  --ok: #0f9d68;
  --hover: rgba(23, 51, 44, .05);
  --hover-strong: rgba(23, 51, 44, .12);
  --bg-active: #dcece6;
  --warn-bg: #fdf3dd;
  --warn-text: #8a5a00;
  --bot: #6b4fd8;
  --bot-soft: rgba(124, 92, 255, .12);
  --gold: #ffc159;
  --gold-text: #9c6a00;
  --gold-line: rgba(156, 106, 0, .35);
  --gold-soft: rgba(255, 193, 89, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1 { font-size: 20px; margin: 0; font-weight: 600; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
.dim { color: var(--text-dim); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.flex1 { flex: 1; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }
.name { font-size: 16px; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ── 视图容器 ── */
.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  /* 默认允许纵向滚动：VIP / 历史 等长页面内容超出屏幕时，也能滚到底部的按钮。
     之前只放行了 home/settings/friends，导致手机上 VIP 页的「立即开通」滚不到、看不见。 */
  overflow-x: hidden;
  overflow-y: auto;
}
/* 聊天页由内部 .msgs 自己滚动，容器锁住，避免双层滚动 */
#view-chat.active { overflow: hidden; }
.page { padding: 16px; flex: 1; }

.brand { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; position: relative; }
#btnTheme { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 18px; padding: 8px 12px; }
.brand p { margin: 2px 0 0; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
}

.banner {
  background: var(--warn-bg); color: var(--warn-text); font-size: 12.5px;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; line-height: 1.55;
}

.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 14px; }

.btn {
  background: var(--primary); color: #fff; border-radius: 999px;
  padding: 13px 20px; font-weight: 600; text-align: center; display: block;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn-ghost {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 18px; text-align: center; display: block;
}
.btn-ghost:active { background: var(--bg-active); }
.mini-btn { padding: 6px 14px; font-size: 13px; }
.btn-bot { background: linear-gradient(135deg, #7c5cff, #b06bff); box-shadow: 0 6px 18px rgba(124, 92, 255, .35); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.tag {
  display: inline-block; font-size: 11px; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px; padding: 2px 10px;
}
.bot-tag { color: var(--bot); background: var(--bot-soft); margin-left: 8px; }
.tags { margin-top: 8px; }
.tags .tag { margin: 4px 6px 0 0; }

.card.idcard .field { margin-bottom: 10px; }
.card.idcard .row.gap .field { margin-bottom: 0; }
.idcard .code {
  font-size: 22px; letter-spacing: 2px; color: var(--primary);
  margin: 10px 0 14px; font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
}

.matchbox { text-align: center; padding: 6px 0 18px; }
.big-emoji { font-size: 44px; margin-bottom: 10px; }

.grid { display: flex; flex-wrap: wrap; }
.grid-item {
  width: 25%; text-align: center; padding: 12px 0;
  font-size: 12px; color: var(--text-dim); border-radius: 12px;
}
.grid-item:active { background: var(--bg-soft); }
.grid-item span { font-size: 24px; display: block; margin-bottom: 4px; }

/* ── 聊天 ── */
.chat-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-soft);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
}
.chat-top .who { min-width: 0; flex: 1; }
.chat-top .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  padding: 6px 10px; border-radius: 10px; font-size: 13px;
  color: var(--text-dim); background: var(--hover);
}
.icon-btn:active { background: var(--hover-strong); }
#btnBack { font-size: 22px; line-height: 1; padding: 2px 12px 6px; }
.icon-btn.danger { color: var(--danger); }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }

.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 4px; -webkit-overflow-scrolling: touch; }
.msg { display: flex; margin-bottom: 12px; align-items: flex-start; gap: 8px; }
.msg.mine { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.msg.mine .avatar { background: var(--primary-soft); border-color: transparent; }
.bubble {
  max-width: 72%; padding: 10px 14px; border-radius: 16px;
  background: var(--card); word-break: break-word; white-space: pre-wrap;
  border-bottom-left-radius: 5px;
}
.msg.mine .bubble {
  background: var(--primary); color: #fff; border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
}
.bubble img { max-width: 100%; border-radius: 10px; display: block; }
.sys {
  text-align: center; font-size: 12px; color: var(--text-dim);
  margin: 10px 0; padding: 0 20px; line-height: 1.6;
}
.sys.warn { color: var(--warn-text); }

.composer {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-soft); border-top: 1px solid var(--line); flex-shrink: 0;
}
.composer input {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 14px; outline: none;
}
.composer input:focus { border-color: var(--primary); }
.send-btn { padding: 10px 18px; font-size: 14px; flex-shrink: 0; }

.emoji-panel {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px;
  background: var(--bg-soft); border-top: 1px solid var(--line);
  max-height: 168px; overflow-y: auto; flex-shrink: 0;
}
.emoji-panel[hidden] { display: none; } /* 默认折叠：hidden 属性被 display:flex 覆盖，需显式恢复 */
.emoji-panel button { font-size: 22px; width: 12.5%; padding: 4px 0; border-radius: 8px; }
.emoji-panel button:active { background: var(--card); }

/* ── 表单 ── */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.field input[type="text"], .field input:not([type]) , .field input[type="number"] {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; outline: none;
}
.field input:focus { border-color: var(--primary); }
.row.field { margin-bottom: 16px; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 10px 0; border-radius: 12px; background: var(--bg-soft);
  border: 1px solid var(--line); color: var(--text-dim); font-size: 14px;
}
.seg button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 匹配偏好（性别筛选） */
.pref-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
}
.pref-label { font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
.seg-sm { flex: 1; gap: 6px; }
.seg-sm button { padding: 7px 0; font-size: 13px; border-radius: 10px; }
.seg-sm button.locked { opacity: .45; }
.lock-tag { font-size: 13px; flex-shrink: 0; }

.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute; inset: 0; background: var(--line);
  border-radius: 999px; transition: background .2s;
}
.switch i::after {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s;
}
.switch input:checked + i { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.switch input:checked + i::after { transform: translateX(22px); }

/* ── 浮层 ── */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 22, .82);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay-box {
  background: var(--card); border-radius: 20px; padding: 26px 22px;
  width: 100%; max-width: 340px; text-align: center;
}
.overlay-box.left { text-align: left; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border: 4px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.report-list { margin: 14px 0 4px; }
.report-list button {
  display: block; width: 100%; text-align: left; padding: 13px 4px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.report-list button:last-child { border-bottom: none; }
.report-list button:active { color: var(--primary); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .88); color: #fff; padding: 11px 20px;
  border-radius: 999px; font-size: 14px; z-index: 99; max-width: 82vw;
  text-align: center; pointer-events: none;
}
.toast[hidden] { display: none; }

/* ── 好友列表 ── */
.friend {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card); border-radius: 16px; margin-bottom: 10px;
}
.friend .info { flex: 1; min-width: 0; }
.friend .last {
  font-size: 13px; color: var(--text-dim); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
/* ── VIP 会员 ── */
.vip-status { border: 1px solid var(--gold-line); }
.vip-status.is-vip { background: var(--gold-soft); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.plan {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; position: relative; transition: border-color .15s, transform .1s;
}
.plan:active { transform: scale(.98); }
.plan.active { border-color: var(--gold-text); box-shadow: 0 0 0 2px var(--gold-soft); }
.plan .pname { font-size: 15px; font-weight: 600; }
.plan .pprice { font-size: 22px; font-weight: 700; color: var(--gold-text); margin-top: 4px; }
.plan .pprice small { font-size: 12px; font-weight: 400; color: var(--text-dim); }
.plan .pdesc { font-size: 11px; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }
.plan .ptag {
  position: absolute; top: -8px; right: 8px; background: var(--primary); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 8px;
}
.plan .ptag:empty { display: none; }
.perk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perk-table th, .perk-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.perk-table th { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.perk-table td.vip { color: var(--gold-text); }
.perk-table tr:last-child td, .perk-table tr:last-child th { border-bottom: none; }
.pay-qr { margin: 14px auto 4px; width: 190px; height: 190px; display: flex; align-items: center; justify-content: center; }
.pay-qr img { width: 190px; height: 190px; background: #fff; border-radius: 10px; padding: 6px; }
.pay-qr .qr-fallback { font-size: 12px; color: var(--text-dim); text-align: center; line-height: 1.6; }

/* 手工收款码展示（过渡方案：个人收款码） */
.manual-pay { display: flex; flex-direction: column; gap: 14px; align-items: center; margin: 8px 0; }
.manual-pay .mp-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.manual-pay .mp-title { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.manual-pay img { width: 160px; height: 160px; object-fit: contain; background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); }
.manual-pay img.mp-broken { display: none; }
.manual-pay .mp-uid { font-size: 14px; margin-top: 2px; }
.manual-pay .mp-uid b { color: var(--gold-text); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; }
.manual-pay .mp-copy { color: var(--primary); font-size: 12px; cursor: pointer; text-decoration: underline; margin-left: 6px; }
.manual-pay .mp-contact { font-size: 14px; font-weight: 600; color: var(--text); }
.manual-pay .mp-note { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.vip-badge { color: var(--gold-text); font-size: 11px; margin-left: 4px; }

/* ── 首页 VIP 快捷入口 ── */
.vip-promo {
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  cursor: pointer;
}
.vip-promo:active { opacity: .85; }
.vip-crown { font-size: 24px; }
.vip-title { font-weight: 700; color: var(--gold-text); }
.vip-btn {
  background: linear-gradient(135deg, #ffc159, #ff9d2e);
  color: #4a2e00; border-radius: 999px; padding: 8px 16px;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}

/* ── 正在输入提示 / 消息撤回 ── */
.typing-tip { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); margin: 4px 0 4px 46px; }
.typing-tip span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-dim); display: inline-block; animation: typingDot 1.1s infinite; }
.typing-tip span:nth-child(2) { animation-delay: .18s; }
.typing-tip span:nth-child(3) { animation-delay: .36s; }
.typing-tip i { font-style: normal; margin-left: 2px; }
@keyframes typingDot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.bubble.can-revoke { cursor: pointer; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.dot.on { background: var(--ok); }
.friend { flex-wrap: wrap; }
.factions { display: flex; gap: 8px; flex-wrap: wrap; }
.factions .mini-btn { margin: 0; }
.mini-btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; font-size: 14px; }

/* ── 兑换码卡片 ── */
.redeem-card { border: 1px dashed var(--gold-line); background: var(--gold-soft); }
.redeem-card .row input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); font-size: 15px;
}
.redeem-card .row input::placeholder { color: var(--text-dim); }
.redeem-card .btn-primary {
  background: linear-gradient(135deg, #ffc159, #ff9d2e); color: #4a2e00;
  font-weight: 700; white-space: nowrap;
}
.redeem-card .btn-primary:disabled { opacity: .55; }

/* ── 兑换码卡片：客服联系方式 ── */
.cs-contact {
  border: 1px solid var(--gold-line); border-radius: 12px;
  background: var(--bg-soft); padding: 12px 14px;
}
.cs-contact-head { font-size: 13px; font-weight: 700; color: var(--gold-text); margin-bottom: 10px; }
.cs-qq-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cs-qq-label { font-size: 12px; color: var(--text-dim); }
.cs-qq-num {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px; font-weight: 700; letter-spacing: 1px; color: var(--text);
  user-select: all;
}
.cs-qq-copy {
  padding: 5px 14px; font-size: 13px; background: var(--primary);
  color: #fff; border-radius: 999px; border: none; cursor: pointer; margin-left: auto;
}
.cs-qq-add {
  display: block; text-align: center; text-decoration: none;
  background: linear-gradient(135deg, #12b7f5, #0a8ed6); color: #fff;
  font-weight: 700; font-size: 14px; padding: 11px; border-radius: 999px;
}
.cs-qq-add:active { opacity: .85; }
.cs-qq-tip { margin-top: 8px; line-height: 1.5; }

/* ── 账号：绑定 / 登录 / 改密 ── */
#accountBadge.on { color: #1a7f37; background: rgba(26,127,55,.12); }
.acct-login-box {
  border-top: 1px dashed var(--border, rgba(128,128,128,.3));
  padding-top: 14px; margin-top: 16px;
}
.acct-login-box .field input { font-size: 15px; }
