:root {
  --bg: #fff5f7;
  --panel: #ffffff;
  --ink: #2b2228;
  --muted: #8a7b83;
  --accent: #f06e95;
  --accent-ink: #ffffff;
  --me: #f06e95;
  --me-ink: #ffffff;
  --her: #ffffff;
  --her-ink: #2b2228;
  --line: #f1dde4;
  --notice: #fde9ef;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1719; --panel: #262023; --ink: #f4ecef; --muted: #a8979f;
    --accent: #f27aa0; --me: #d95c83; --her: #2f282b; --her-ink: #f4ecef;
    --line: #3a3135; --notice: #33262b;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1719; --panel: #262023; --ink: #f4ecef; --muted: #a8979f;
  --accent: #f27aa0; --me: #d95c83; --her: #2f282b; --her-ink: #f4ecef;
  --line: #3a3135; --notice: #33262b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 640px; margin: 0 auto; height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--notice); }
.who { flex: 1; min-width: 0; }
.name { font-weight: 600; font-size: 17px; }
.ai-tag {
  font-size: 11px; font-weight: 600; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px; margin-left: 4px; vertical-align: 2px;
}
.status { font-size: 12px; color: var(--muted); }
.icon-btn {
  border: 0; background: var(--notice); width: 38px; height: 38px; border-radius: 50%;
  font-size: 18px; cursor: pointer;
}
.icon-btn.on { background: var(--accent); }
.ai-notice {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 6px 16px; background: var(--notice);
}
.chat {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.row.me { justify-content: flex-end; }
.row .mini { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; }
.bubble {
  max-width: 76%; padding: 10px 13px; border-radius: 18px; line-height: 1.55; font-size: 15.5px;
  white-space: pre-wrap; word-break: break-word;
}
.row.her .bubble { background: var(--her); color: var(--her-ink); border-bottom-left-radius: 6px; border: 1px solid var(--line); }
.row.me .bubble { background: var(--me); color: var(--me-ink); border-bottom-right-radius: 6px; }
.play {
  border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 4px; cursor: pointer; flex: none;
}
.play.loading { opacity: .5; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--notice); padding: 4px 10px; border-radius: 10px; text-align: center; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: b 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes b { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.install-tip {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; font-size: 13px;
}
.install-tip span { flex: 1; }
.install-tip button { border: 0; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; }
.install-tip .install-btn { background: var(--accent); color: var(--accent-ink); font-size: 13px; border-radius: 8px; padding: 6px 12px; }
.share-ico { display: inline-block; border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; font-size: 11px; }

.composer {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 20px; padding: 10px 14px; font-size: 16px; font-family: inherit; max-height: 120px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer button {
  border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 20px; padding: 0 18px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.composer button:disabled { opacity: .5; }

.gate {
  position: fixed; inset: 0; background: rgba(30, 20, 25, .55); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10;
}
.gate[hidden], .install-tip[hidden] { display: none; }
.gate-card {
  background: var(--panel); border-radius: 20px; padding: 24px 20px; max-width: 380px; width: 100%; text-align: center;
}
.gate-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; }
.gate-card h1 { font-size: 20px; margin: 10px 0 8px; }
.gate-card p { font-size: 14px; line-height: 1.6; color: var(--ink); text-align: left; margin: 8px 0; }
.gate-card .small { font-size: 12px; color: var(--muted); text-align: center; }
.check { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 14px; margin: 14px 0; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
#gateBtn {
  width: 100%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 600;
  border-radius: 12px; padding: 12px; cursor: pointer;
}
#gateBtn:disabled { opacity: .45; }

/* ---------- 多页面 ---------- */
.view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.view[hidden] { display: none; }
.app { overflow: hidden; }
.back {
  border: 0; background: transparent; color: var(--ink); font-size: 34px; line-height: 1;
  width: 32px; height: 40px; margin-left: -8px; cursor: pointer; flex: none;
}
.avatar-wrap { flex: none; }
.ava {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex: none;
}
.ava.big { width: 58px; height: 58px; font-size: 30px; }
.ava.mini { width: 30px; height: 30px; font-size: 16px; }
.vip-btn {
  border: 0; background: linear-gradient(135deg, #ffd36e, #f5a524); color: #4a2f00; font-weight: 600;
  border-radius: 18px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}

/* 角色列表 */
.roles { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.role-card {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer;
  color: var(--ink); font: inherit;
}
.role-card:active { transform: scale(.99); }
.role-card .info { flex: 1; min-width: 0; }
.role-card .rname { font-size: 17px; font-weight: 600; }
.role-card .rtag { font-size: 13px; color: var(--muted); margin-top: 3px; }
.role-card .last { font-size: 13px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.badge.vip { background: #ffe7a8; color: #6b4500; }
.chev { color: var(--muted); font-size: 22px; }

/* 会员页 */
.vip-page { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card-title { font-weight: 600; margin-bottom: 10px; }
.status-card { background: linear-gradient(135deg, #fde3ea, #fff3d6); border: 0; color: #2b2228; }
.status-title { font-size: 20px; font-weight: 700; }
.status-sub { font-size: 13px; color: #7a6a72; margin-top: 4px; }
.quota { display: flex; gap: 12px; margin-top: 14px; }
.quota > div { flex: 1; background: rgba(255,255,255,.7); border-radius: 12px; padding: 10px; text-align: center; }
.quota b { display: block; font-size: 22px; }
.quota span { font-size: 12px; color: #7a6a72; }
.redeem { display: flex; gap: 8px; }
.redeem input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 12px; padding: 11px 12px; font-size: 16px; letter-spacing: .5px; outline: none;
}
.redeem input:focus { border-color: var(--accent); }
.redeem button { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 0 18px; font-size: 15px; font-weight: 600; cursor: pointer; }
.redeem button:disabled { opacity: .5; }
.redeem-msg { font-size: 13px; margin-top: 8px; min-height: 1em; }
.redeem-msg.ok { color: #1f9d55; } .redeem-msg.err { color: #d9363e; }
.benefits { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.plan .pname { font-weight: 600; }
.plan .pprice { font-size: 22px; font-weight: 700; color: var(--accent); margin: 6px 0 2px; }
.plan .pdesc { font-size: 12px; color: var(--muted); }
.contact { font-size: 13px; color: var(--muted); text-align: center; margin: 4px 0 20px; }
.upsell { align-self: center; border: 0; background: linear-gradient(135deg, #ffd36e, #f5a524); color: #4a2f00; font-weight: 600; border-radius: 14px; padding: 8px 14px; font-size: 13px; cursor: pointer; }

/* 付款 */
.steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.pay-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.pay-tab { flex: 1; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 9px; font-size: 14px; cursor: pointer; }
.pay-tab.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.pay-img { text-align: center; }
.pay-img img { width: 100%; max-width: 260px; border-radius: 12px; background: #fff; }
.pay-img.small img { max-width: 170px; padding: 6px; }
.pay-tip { font-size: 12px; color: var(--muted); text-align: center; margin: 8px 0 0; line-height: 1.6; }

.pay-card { max-width: 260px; margin: 0 auto; border-radius: 16px; overflow: hidden; text-align: center; padding-bottom: 12px; }
.pay-card.wechat { background: #09b83e; } .pay-card.alipay { background: #1677ff; }
.pay-head { color: #fff; font-weight: 700; font-size: 18px; padding: 12px 0 10px; }
.pay-card img { width: 78%; background: #fff; border-radius: 10px; padding: 8px; display: block; margin: 0 auto; image-rendering: pixelated; }
.pay-name { color: #fff; font-size: 13px; margin-top: 8px; }
.pay-img.small img { image-rendering: pixelated; }

.games-link{display:flex;align-items:center;gap:10px;margin:4px 16px 20px;padding:14px 16px;border-radius:16px;background:linear-gradient(135deg,#ffe2c4,#ffd0de);color:#4a2a3a;text-decoration:none;box-shadow:0 4px 14px rgba(240,110,149,.18)}
.games-link span{font-size:26px}.games-link b{font-size:16px}.games-link small{flex:1;color:#8a5a6a;font-size:12px}.games-link i{font-style:normal;font-size:22px;color:#c06080}

/* ---------- 图片 / 视频 ---------- */
.bubble .pic { display: block; max-width: min(220px, 60vw); max-height: 300px; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; background: var(--notice); }
.bubble video.pic { cursor: default; }
.pic-wait { font-size: 13px; color: var(--muted); padding: 18px 10px; border: 1px dashed var(--line); border-radius: 12px; margin-top: 4px; }
.composer .attach { flex: none; background: var(--notice); color: var(--ink); padding: 0; width: 40px; border-radius: 50%; font-size: 18px; }
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
/* ---------- 语音通话 ---------- */
.call { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #3a2430, #1b1418); color: #fff; text-align: center; }
.call-top { position: absolute; top: max(16px, env(safe-area-inset-top)); font-size: 13px; opacity: .8; }
.call-top .ai-tag { color: #ffb3c8; border-color: #ffb3c8; }
.call-ava .ava { width: 120px; height: 120px; font-size: 52px; border-radius: 50%; box-shadow: 0 0 0 8px rgba(255,255,255,.08), 0 0 0 18px rgba(255,255,255,.04); }
.call-name { font-size: 24px; font-weight: 700; margin-top: 8px; }
.call-time { font-variant-numeric: tabular-nums; opacity: .7; }
.call-state { min-height: 22px; color: #ffc7d6; }
.call-heard { max-width: 340px; min-height: 48px; font-size: 14px; line-height: 1.6; opacity: .85; }
.call-btns { display: flex; gap: 48px; margin-top: 28px; }
.call-btns button { border: 0; width: 68px; height: 68px; border-radius: 50%; font-size: 26px; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.call-btns button span { position: absolute; top: 76px; font-size: 12px; white-space: nowrap; opacity: .8; }
.call-btns button.on { background: #fff; color: #222; }
.call-btns .end { background: #e5484d; }
.viewer[hidden], .call[hidden] { display: none; }
