:root { color-scheme: dark; }
:root {
  --bg: #0e0e17;
  --bg-2: #14141f;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-strong: rgba(255, 255, 255, 0.085);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f1ee;
  --muted: #a5a0ad;
  --faint: #746f7d;
  --rose: #f0a6b5;
  --peach: #f5c8a8;
  --accent-a: #f2b3bd;
  --accent-b: #d7a6f0;
  --lilac: #b9a6f5;
  --mint: #9fd9c2;
  --danger: #ef7b86;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: #08080e;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
::selection { background: rgba(240, 166, 181, .35); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; background:
  radial-gradient(120% 90% at 50% -10%, #1c1724 0%, #0b0b13 55%, #07070c 100%); }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.orb-a { width: 380px; height: 380px; left: -160px; top: -120px; background: #b3718a; animation: drift 18s ease-in-out infinite alternate; }
.orb-b { width: 320px; height: 320px; right: -150px; top: 18%; background: #6b64b8; animation: drift 22s ease-in-out infinite alternate-reverse; }
.orb-c { width: 360px; height: 360px; left: 20%; bottom: -220px; background: #a56a52; opacity: .32; animation: drift 26s ease-in-out infinite alternate; }
.grain { position: absolute; inset: 0; opacity: .05; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E"); }
@keyframes drift { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(30px,40px,0) scale(1.08); } }

.app-shell {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(20, 19, 30, .82), rgba(10, 10, 17, .94));
  backdrop-filter: blur(20px);
}

.screen { display: none; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: calc(22px + var(--safe-top)) 20px calc(108px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.screen::-webkit-scrollbar { display: none; }
.screen.active { display: flex; flex-direction: column; animation: screen-in .32s cubic-bezier(.2,.7,.2,1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow { margin: 0 0 4px; font-size: 10px; letter-spacing: .2em; color: var(--faint); text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

/* ============ onboarding ============ */
.onboarding { margin: auto 0; padding: 18px 4px 12px; display: flex; flex-direction: column; align-items: stretch; }
.brand-mark { display: flex; align-items: center; gap: 9px; margin-bottom: 26px; }
.brand-orb { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); color: #1c1620; box-shadow: 0 10px 32px rgba(240,166,181,.28); }
.brand-orb svg { width: 25px; height: 25px; stroke-width: 1.6; }
.brand-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(159,217,194,.12); }
.onboarding-title { font-size: 40px; letter-spacing: -.04em; font-weight: 700; background: linear-gradient(100deg, #fff, var(--accent-a) 45%, var(--accent-b) 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.onboarding-sub { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.onboarding-fields { margin: 28px 0 20px; display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.link { color: var(--rose); text-decoration: none; font-size: 11px; opacity: .9; }
.input {
  width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.045); border-radius: var(--radius-sm);
  padding: 13px 14px; font-size: 15px; color: var(--text); outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
.input::placeholder { color: #66616f; }
.input:focus { border-color: rgba(240,166,181,.5); background: rgba(255,255,255,.07); box-shadow: 0 0 0 3px rgba(240,166,181,.09); }
.textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); }
.advanced { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 0 12px; }
.advanced summary { padding: 12px 2px; font-size: 12px; color: var(--muted); cursor: pointer; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced[open] { padding-bottom: 14px; }
.advanced .field + .field { margin-top: 10px; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 11px; color: var(--faint); }
.privacy-note svg { width: 13px; height: 13px; color: var(--mint); }

/* ============ buttons ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 14px; padding: 11px 17px; font-size: 14px; font-weight: 560; transition: transform .16s, opacity .2s, background .2s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); color: #231a27; box-shadow: 0 10px 28px rgba(220,160,200,.22); }
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost { background: rgba(255,255,255,.055); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.09); }
.btn-danger { background: rgba(239,123,134,.1); border: 1px solid rgba(239,123,134,.26); color: #ffb3ba; }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 11px; }
.btn-lg { padding: 15px 20px; font-size: 15px; border-radius: 16px; width: 100%; }
.btn-full { width: 100%; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.07); }
.text-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--rose); padding: 6px 2px; }
.text-btn svg { width: 14px; height: 14px; }
.spacer { flex: 1; }

/* ============ avatars ============ */
.avatar { display: grid; place-items: center; border-radius: 38%; background: linear-gradient(145deg, rgba(240,166,181,.32), rgba(185,166,245,.2)); border: 1px solid rgba(255,255,255,.14); font-size: 22px; user-select: none; flex: none; overflow: hidden; }
.avatar-xs { width: 26px; height: 26px; font-size: 13px; border-radius: 9px; }
.avatar-sm { width: 42px; height: 42px; font-size: 20px; border-radius: 14px; }
.avatar-lg { width: 58px; height: 58px; font-size: 28px; border-radius: 19px; }
.avatar-xl { width: 76px; height: 76px; font-size: 36px; border-radius: 24px; }

/* ============ home ============ */
.home-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 22px; }
.home-hello { display: flex; align-items: center; gap: 12px; }
.home-name { font-size: 21px; }
.install-banner { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 12px; border-radius: 17px; border: 1px solid rgba(255,255,255,.1); background: linear-gradient(135deg, rgba(240,166,181,.1), rgba(185,166,245,.06)); }
.install-banner-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; color: var(--rose); background: rgba(255,255,255,.06); }
.install-banner-icon svg { width: 17px; height: 17px; }
.install-banner-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.install-banner-text strong { font-size: 12px; font-weight: 580; }
.install-banner-text span { font-size: 10px; color: var(--faint); }
.install-banner .btn { flex: none; }
.install-close { width: 28px; height: 28px; border: 0; background: transparent; color: var(--faint); flex: none; }
.install-close svg { width: 14px; height: 14px; }

.continue-card { position: relative; overflow: hidden; border-radius: 24px; padding: 18px; margin-bottom: 26px; border: 1px solid rgba(255,255,255,.11); background: linear-gradient(135deg, rgba(240,166,181,.13), rgba(185,166,245,.07) 60%, rgba(255,255,255,.03)); box-shadow: 0 18px 50px rgba(0,0,0,.22); }
.continue-glow { position: absolute; width: 160px; height: 160px; right: -40px; top: -70px; border-radius: 50%; background: rgba(240,166,181,.3); filter: blur(40px); pointer-events: none; }
.continue-main { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.continue-text { min-width: 0; }
.continue-text h3 { font-size: 18px; margin: 2px 0 4px; }
.continue-text p:last-child { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
#btn-continue { position: relative; width: 100%; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.section-head h3 { font-size: 14px; color: #d9d4df; letter-spacing: .02em; }
.role-strip { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px 24px; scrollbar-width: none; }
.role-strip::-webkit-scrollbar { display: none; }
.role-chip { flex: none; width: 92px; border-radius: 20px; padding: 13px 10px 11px; display: flex; flex-direction: column; align-items: center; gap: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.04); transition: transform .2s, border-color .2s, background .2s; }
.role-chip:hover { transform: translateY(-2px); border-color: var(--line-strong); background: rgba(255,255,255,.07); }
.role-chip .avatar { width: 48px; height: 48px; font-size: 24px; }
.role-chip strong { font-size: 12px; font-weight: 560; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip small { font-size: 9px; color: var(--faint); }
.role-chip.add { border-style: dashed; color: var(--faint); justify-content: center; min-height: 112px; }
.role-chip.add svg { width: 20px; height: 20px; }
.recent-list { display: grid; gap: 8px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 16px; border: 1px solid transparent; transition: background .2s; text-align: left; width: 100%; }
.recent-item:hover { background: rgba(255,255,255,.045); }
.recent-item .avatar { width: 42px; height: 42px; font-size: 20px; border-radius: 14px; }
.recent-main { flex: 1; min-width: 0; }
.recent-main strong { display: block; font-size: 13px; font-weight: 560; }
.recent-main p { font-size: 11px; color: var(--faint); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { font-size: 10px; color: var(--faint); flex: none; }
.empty-state { padding: 26px 16px; border: 1px dashed var(--line); border-radius: 18px; color: var(--faint); font-size: 12px; text-align: center; line-height: 1.9; }
.empty-state strong { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* ============ pages ============ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin: 6px 0 22px; }
.roles-grid { display: grid; gap: 12px; }
.role-card { position: relative; border-radius: 20px; border: 1px solid var(--line); background: rgba(255,255,255,.04); padding: 15px; display: flex; gap: 13px; align-items: flex-start; transition: border-color .2s, background .2s, transform .2s; }
.role-card:hover { border-color: var(--line-strong); background: rgba(255,255,255,.065); transform: translateY(-1px); }
.role-card .avatar { width: 54px; height: 54px; font-size: 26px; border-radius: 18px; }
.role-card-main { flex: 1; min-width: 0; }
.role-card-title { display: flex; align-items: center; gap: 7px; }
.role-card-title strong { font-size: 15px; }
.role-card-title span { font-size: 10px; color: var(--faint); }
.role-card-desc { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.role-card-foot { margin-top: 9px; display: flex; align-items: center; gap: 6px; }
.pill { font-size: 9px; padding: 3px 7px; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--faint); border: 1px solid var(--line); }
.role-card-actions { display: flex; gap: 2px; flex: none; }
.role-card-actions .icon-btn { width: 32px; height: 32px; border-radius: 10px; border-color: transparent; background: transparent; color: var(--faint); }
.role-card-actions .icon-btn:hover { color: var(--text); background: rgba(255,255,255,.07); }
.library-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.library-actions .btn { flex: 1 1 44%; }
.library-actions #btn-export-roles { flex: 1 1 100%; }

/* ============ chat ============ */
.chat-screen { padding: 0; overflow: hidden; background: linear-gradient(180deg, rgba(10,9,16,.16), rgba(10,9,16,.3)); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: max(10px, var(--safe-top)) 12px 10px; border-bottom: 1px solid var(--line); background: rgba(13,13,21,.78); backdrop-filter: blur(18px); z-index: 3; flex: none; }
.icon-btn.active { color: var(--rose); border-color: rgba(240,166,181,.3); background: rgba(240,166,181,.1); }
.chat-person { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-person-text { display: grid; gap: 2px; min-width: 0; }
.chat-person-text strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--mint); }
.online i { width: 5px; height: 5px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px rgba(159,217,194,.14); }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px calc(10px + env(safe-area-inset-bottom)); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chat-body::-webkit-scrollbar { display: none; }
.chat-day { text-align: center; color: var(--faint); font-size: 10px; margin: 2px 0 10px; }
.messages { display: flex; flex-direction: column; padding-top: 18px; }
.load-older { align-self: center; margin: 2px auto 14px; padding: 7px 14px; border-radius: 999px; font-size: 11px; color: #6f767d; background: rgba(255,255,255,.55); border: 1px solid rgba(0,0,0,.06); }
.load-older:active { transform: scale(.97); }
.msg-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 22px; animation: msg-in .25s cubic-bezier(.2,.7,.2,1); }
.msg-row:first-child { margin-top: 0; }
/* 同一人连发、且这条不显示时间时，收紧行距 */
.msg-row.cont { margin-top: 10px; }
.msg-row.me { flex-direction: row-reverse; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-avatar { flex: none; }
.bubble-wrap { position: relative; max-width: 70%; display: flex; flex-direction: column; gap: 0; }
.msg-row.me .bubble-wrap { align-items: flex-end; }
/* 时间：贴在气泡外左上角，小到几乎不打扰 */
.bubble-meta { position: absolute; left: 2px; bottom: calc(100% + 3px); display: flex; align-items: center; gap: 5px; padding: 0; color: var(--faint); font-size: 10px; line-height: 1; letter-spacing: .02em; opacity: .9; white-space: nowrap; }
.msg-row.me .bubble-meta { left: auto; right: 2px; }
.bubble { padding: 8px 12px; border-radius: 14px; background: rgba(255,255,255,.075); border: 1px solid rgba(255,255,255,.075); font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; color: #ece8ef; }
.msg-row.me .bubble { background: linear-gradient(135deg, rgba(240,166,181,.9), rgba(214,166,239,.9)); color: #241c27; border: none; }
.msg-read { color: var(--faint); display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; flex: none; }
.msg-read:hover { color: var(--text); background: rgba(255,255,255,.06); }
.msg-read svg { width: 11px; height: 11px; }
.bubble.streaming::after { content: "▍"; color: var(--rose); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.typing-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; }
.typing-bubble { display: flex; gap: 4px; align-items: center; height: 39px; padding: 0 14px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.typing-bubble span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing-bubble span:nth-child(2) { animation-delay: .15s; }
.typing-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.composer-wrap { display: flex; align-items: flex-end; gap: 7px; padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(13,13,21,.86); backdrop-filter: blur(18px); }
.composer { flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 0; border-radius: 19px; border: 1px solid var(--line); background: rgba(255,255,255,.05); padding: 4px 6px 5px 12px; min-height: 44px; }
.composer textarea { width: 100%; border: 0; outline: 0; background: transparent; resize: none; padding: 8px 0 2px; max-height: 110px; font-size: 14px; line-height: 1.5; color: var(--text); }
.composer-toolbar { display: flex; align-items: center; gap: 1px; padding-top: 2px; }
.composer-toolbar .send-btn { margin-left: auto; }
.composer textarea::placeholder { color: #6f6a78; }
.composer-voice { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: var(--faint); border: 1px solid var(--line); background: rgba(255,255,255,.035); flex: none; }
.composer-voice.on { color: var(--rose); border-color: rgba(240,166,181,.35); background: rgba(240,166,181,.1); }
.send-btn { width: 36px; height: 36px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); color: #241c27; flex: none; transition: opacity .2s, transform .16s; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .35; }
.stop-btn { height: 42px; padding: 0 14px; border-radius: 14px; border: 1px solid rgba(239,123,134,.3); background: rgba(239,123,134,.1); color: #ffb3ba; font-size: 12px; flex: none; }

/* ============ settings ============ */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(135deg, rgba(240,166,181,.1), rgba(185,166,245,.05)); margin-bottom: 20px; }
.profile-text h3 { font-size: 17px; }
.profile-text p { margin-top: 4px; font-size: 11px; color: var(--faint); }
.settings-group { border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 20px; padding: 14px; margin-bottom: 13px; display: grid; gap: 11px; }
.group-title { font-size: 10px; letter-spacing: .16em; color: var(--faint); text-transform: uppercase; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch-row strong { font-size: 13px; font-weight: 560; }
.switch-row p { font-size: 10px; color: var(--faint); margin-top: 3px; line-height: 1.4; }
.switch { width: 46px; height: 27px; border-radius: 999px; background: rgba(255,255,255,.1); border: 1px solid var(--line); position: relative; flex: none; transition: background .25s; }
.switch i { position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: #cfc9d6; transition: transform .25s, background .25s; }
.switch[aria-checked="true"] { background: linear-gradient(135deg, rgba(240,166,181,.9), rgba(214,166,239,.8)); border-color: transparent; }
.switch[aria-checked="true"] i { transform: translateX(19px); background: #241c27; }
.range-row { display: grid; gap: 7px; }
.range-row label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.range-row label span { color: var(--rose); }
input[type="range"] { width: 100%; height: 4px; appearance: none; background: rgba(255,255,255,.12); border-radius: 999px; outline: none; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border-radius: 50%; background: #f2c1c9; box-shadow: 0 0 0 5px rgba(240,166,181,.13); cursor: pointer; }
.hint { font-size: 10px; color: var(--faint); line-height: 1.6; }
.inline-row { display: flex; align-items: center; gap: 10px; }
.status-text { font-size: 11px; color: var(--faint); }
.status-text.ok { color: var(--mint); }
.status-text.err { color: var(--danger); }
.data-actions { display: flex; gap: 8px; }
.data-actions .btn { flex: 1; }
.data-actions + .data-actions { margin-top: 8px; }
.data-stats { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin: 0 0 10px; }
.data-stats.warn { color: var(--danger); }
.onboarding-restore { display: flex; width: 100%; justify-content: center; margin-top: 10px; font-size: 12px; }

/* ---- 按住说话 ---- */
#btn-mic { touch-action: none; }
#btn-mic.active { color: var(--rose); border-color: rgba(240,166,181,.5); background: rgba(240,166,181,.16); }
.voice-hold {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 18px calc(112px + env(safe-area-inset-bottom)); pointer-events: none;
  background: linear-gradient(180deg, rgba(6,6,10,0) 30%, rgba(6,6,10,.5) 72%, rgba(6,6,10,.68));
}
.voice-hold-card {
  width: 100%; max-width: 420px; border-radius: 22px; padding: 16px 18px 14px;
  background: rgba(24,22,32,.94); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); text-align: center;
}
.voice-mic-dot {
  width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center;
  color: #2a1e2a; background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  animation: voicePulse 1.1s ease-in-out infinite;
}
.voice-mic-dot svg { width: 22px; height: 22px; }
@keyframes voicePulse { 0%,100% { transform: scale(1); opacity: .92; } 50% { transform: scale(1.08); opacity: 1; } }
.voice-live { min-height: 20px; max-height: 44px; overflow: hidden; margin: 0 0 6px; font-size: 13px; color: var(--text); line-height: 1.5; }
.voice-hintline { margin: 0 0 10px; font-size: 10.5px; color: var(--faint); }
.voice-modes { display: flex; gap: 8px; }
.voice-modes span {
  flex: 1; padding: 7px 4px; border-radius: 11px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); background: rgba(255,255,255,.04); transition: .15s;
}
.voice-modes span.on { color: #2a1e2a; border-color: transparent; background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); }
body[data-mode="light"] .voice-hold { background: linear-gradient(180deg, rgba(255,255,255,0) 30%, rgba(30,20,40,.32) 75%); }
body[data-mode="light"] .voice-hold-card { background: rgba(255,255,255,.97); }
@media (max-width: 360px) {
  .voice-hold { padding: 0 12px calc(104px + env(safe-area-inset-bottom)); }
}
.about { text-align: center; font-size: 10px; color: #615c6b; line-height: 1.8; margin: 22px 0 8px; }

/* ============ tabbar ============ */
.tabbar { position: absolute; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 3px; padding: 6px; border-radius: 22px; border: 1px solid var(--line); background: rgba(16,16,25,.82); backdrop-filter: blur(22px); z-index: 5; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px 6px; border-radius: 16px; color: #77717f; font-size: 9px; transition: color .2s, background .2s; }
.tab svg { width: 19px; height: 19px; }
.tab.active { color: #f3dfe4; background: rgba(255,255,255,.075); }
.tabbar.chat-hidden { display: none; }

/* ============ modal ============ */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(4,4,8,.62); backdrop-filter: blur(6px); padding: 16px; animation: fade-in .2s; }
.modal-center { align-items: center; }
@keyframes fade-in { from { opacity: 0; } }
.modal-sheet { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; border-radius: 26px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #1b1924, #12111a); box-shadow: var(--shadow); animation: sheet-up .28s cubic-bezier(.2,.7,.2,1); }
@keyframes sheet-up { from { transform: translateY(26px); opacity: .6; } }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; background: linear-gradient(180deg, rgba(27,25,36,.98), rgba(27,25,36,.9)); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 4px 16px 18px; display: grid; gap: 11px; }
.role-preview { display: flex; gap: 13px; align-items: center; }
.role-preview-fields { display: flex; gap: 10px; flex: 1; }
.role-preview-fields .field { flex: 1; }
.role-preview-fields .field:last-child { flex: 0 0 58px; }
.color-input { width: 58px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: transparent; padding: 4px; cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.confirm-card { width: min(92vw, 360px); border-radius: 24px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #1c1a25, #12111a); padding: 22px; text-align: center; box-shadow: var(--shadow); animation: sheet-up .25s; }
.confirm-icon { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: rgba(240,166,181,.12); color: var(--rose); }
.confirm-card h3 { font-size: 16px; }
.confirm-card p { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 7px; }
.confirm-actions { display: flex; gap: 8px; margin-top: 18px; }
.confirm-actions .btn { flex: 1; }

/* ============ toast ============ */
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); max-width: 82vw; padding: 10px 15px; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(28,26,37,.96); color: var(--text); font-size: 12px; line-height: 1.5; opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s; box-shadow: 0 12px 30px rgba(0,0,0,.35); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* ---- themes ---- */
body[data-theme="blue"] { --rose: #a9c9ef; --peach: #b9d7f7; --lilac: #b9a6f5; --accent-a: #a9d4f5; --accent-b: #b8b0f8; --mint: #9fd9e2; }
body[data-theme="peach"] { --rose: #f4b8a0; --peach: #f7d0b0; --lilac: #efb0c8; --accent-a: #f6c2a7; --accent-b: #efb0c8; --mint: #b9dbc4; }
body[data-theme="forest"] { --rose: #a8d5bd; --peach: #c6e5d2; --lilac: #b8c9a7; --accent-a: #a9d8c1; --accent-b: #c6d9a8; --mint: #c6e5d2; }

/* ---- avatar images / uploads ---- */
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn { padding: 0; cursor: pointer; }
.avatar-btn:hover { filter: brightness(1.08); }
.avatar-actions { display: flex; align-items: center; gap: 8px; margin-top: -4px; }
.avatar-actions .text-btn { padding: 2px; }
.theme-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.theme-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; position: relative; transition: transform .16s, border-color .2s; }
.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch.active { border-color: rgba(255,255,255,.9); box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.profile-card .text-btn { margin-left: auto; flex: none; }
.app-shell.has-custom-bg .ambient { opacity: .25; }


/* ---- onboarding v2 ---- */
.onboarding { padding: 10px 2px 8px; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.brand-row .brand-mark { margin: 0; }
.brand-word { font-size: 11px; letter-spacing: .26em; color: var(--faint); font-weight: 560; }
.onboarding-kicker { display: flex; align-items: center; gap: 8px; font-size: 9px; letter-spacing: .22em; color: var(--faint); margin-bottom: 14px; }
.onboarding-kicker span { width: 5px; height: 5px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 4px rgba(240,166,181,.12); }
.onboarding-title { font-size: 38px; line-height: 1.13; }
.onboarding-title em { font-style: normal; background: linear-gradient(100deg, var(--accent-a), var(--accent-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.onboarding-sub { margin-top: 13px; }
.feature-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 20px; }
.feature-chips span { font-size: 10px; color: var(--muted); padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.onboarding-card { border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(255,255,255,.065), rgba(255,255,255,.025)); padding: 16px; display: grid; gap: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.start-btn { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.start-arrow { font-size: 17px; line-height: 1; transform: translateY(-1px); }

/* ---- navigation ---- */
.page-head-left { display: flex; align-items: center; gap: 12px; }
.page-back { width: 38px; height: 38px; border-radius: 12px; flex: none; }
.page-back svg { width: 18px; height: 18px; }

/* ---- advanced entry ---- */
.settings-entry { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 13px 14px; margin-bottom: 13px; border-radius: 19px; border: 1px solid var(--line); background: linear-gradient(135deg, rgba(240,166,181,.08), rgba(255,255,255,.025)); transition: background .2s, border-color .2s; }
.settings-entry:hover { background: rgba(255,255,255,.06); border-color: var(--line-strong); }
.entry-icon { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; flex: none; color: var(--rose); background: rgba(255,255,255,.055); border: 1px solid var(--line); }
.entry-icon svg { width: 18px; height: 18px; }
.entry-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.entry-text strong { font-size: 13px; font-weight: 580; }
.entry-text p { font-size: 10px; color: var(--faint); }
.entry-arrow { width: 16px; height: 16px; color: var(--faint); transform: rotate(180deg); flex: none; }

/* ---- install guide ---- */
.install-guide { max-width: 420px; }
.install-guide .modal-body { text-align: center; gap: 9px; padding-bottom: 20px; }
.install-guide-icon { width: 48px; height: 48px; margin: 2px auto 2px; border-radius: 16px; display: grid; place-items: center; color: var(--rose); background: rgba(240,166,181,.1); border: 1px solid rgba(240,166,181,.18); }
.install-guide-title { font-size: 15px; font-weight: 600; }
.install-guide-text { font-size: 12px; color: var(--muted); line-height: 1.8; white-space: pre-wrap; text-align: left; }
.install-guide-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.install-guide-actions .btn { flex: 1 1 calc(50% - 4px); }
.install-guide-actions .btn-primary { flex-basis: 100%; }
.install-guide-actions .btn { flex: 1; }


.login-mode { display: flex; gap: 4px; padding: 4px; border-radius: 13px; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.login-mode button { flex: 1; padding: 8px 6px; border-radius: 10px; font-size: 11px; color: var(--faint); transition: background .2s, color .2s; }
.login-mode button.active { background: rgba(255,255,255,.1); color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.field-hint { font-size: 10px; color: var(--faint); line-height: 1.4; }
.invite-input { letter-spacing: .12em; font-weight: 600; text-transform: uppercase; }


.text-import-entry { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 13px 14px; margin-bottom: 15px; border-radius: 19px; border: 1px dashed rgba(240,166,181,.24); background: linear-gradient(135deg, rgba(240,166,181,.08), rgba(185,166,245,.045)); transition: background .2s, border-color .2s; }
.text-import-entry:hover { background: rgba(255,255,255,.06); border-color: rgba(240,166,181,.45); }
.text-import-entry .entry-icon { color: var(--peach); }
.text-file-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.text-file-row .hint { flex: 1; min-width: 130px; }
#text-role-input { min-height: 190px; font-size: 13px; line-height: 1.7; }


/* ---- voice / image / stickers ---- */
.chat-screen { position: relative; }
.composer-action { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); flex: none; }
.composer-action:hover { color: var(--text); background: rgba(255,255,255,.06); }
.composer-action.active { color: var(--rose); background: rgba(240,166,181,.12); }
.composer-action svg { width: 19px; height: 19px; }
.image-preview { position: absolute; left: 12px; bottom: 66px; width: 66px; height: 66px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); background: #111; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 4; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-preview button { position: absolute; right: 2px; top: 2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: rgba(10,10,16,.75); color: #fff; }
.image-preview button svg { width: 11px; height: 11px; }
.sticker-panel { position: absolute; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 42dvh; overflow-y: auto; z-index: 6; border-radius: 20px; border: 1px solid var(--line-strong); background: rgba(20,19,29,.97); backdrop-filter: blur(20px); box-shadow: 0 -12px 40px rgba(0,0,0,.4); padding: 10px; }
.sticker-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px; }
.sticker-head strong { font-size: 12px; color: var(--text); }
.sticker-close { width: 28px; height: 28px; border: 0; background: transparent; }
.sticker-close svg { width: 14px; height: 14px; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.sticker-item { border-radius: 13px; padding: 3px; background: rgba(255,255,255,.045); border: 1px solid var(--line); transition: transform .15s, border-color .2s; }
.sticker-item:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.sticker-item img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 9px; display: block; }
.sticker-credit { font-size: 9px; color: var(--faint); text-align: center; margin: 8px 0 1px; }
.bubble.image-bubble { padding: 4px; background: rgba(255,255,255,.06); }
.bubble.image-bubble img { max-width: min(230px, 58vw); max-height: 280px; border-radius: 13px; display: block; object-fit: contain; }
.msg-row.me .bubble.image-bubble { background: rgba(255,255,255,.08); }
.bubble.sticker-bubble { padding: 3px; background: transparent; border: 0; }
.bubble.sticker-bubble img { width: 116px; height: 116px; object-fit: contain; display: block; border-radius: 12px; }
.msg-caption { font-size: 13px; line-height: 1.55; padding: 4px 9px 3px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.msg-row.me .msg-caption { color: #241c27; }


.sticker-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 0 2px 8px; scrollbar-width: none; }
.sticker-tabs::-webkit-scrollbar { display: none; }
.sticker-tab { flex: none; padding: 5px 9px; border-radius: 999px; font-size: 10px; color: var(--faint); border: 1px solid var(--line); background: rgba(255,255,255,.03); white-space: nowrap; }
.sticker-tab.active { color: var(--text); background: rgba(255,255,255,.1); border-color: var(--line-strong); }


/* ---- mobile adaptation ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img { max-width: 100%; }
.bubble-wrap, .chat-person, .role-card-main, .section-head, .home-hello { min-width: 0; }
/* 高度只认可视区（--app-height 由 JS 用 visualViewport 实时更新），不再额外减掉 80px 假底栏 */
.app-shell { height: calc(var(--app-height, 100dvh) - var(--browser-bottom, 0px)); }
@supports not (height: 100dvh) { .app-shell { height: var(--app-height, 100vh); } }
@media (max-width: 700px) {
  .input, .textarea, #chat-input, .composer textarea { font-size: 16px; }
}
@media (max-width: 360px) {
  .screen:not(.chat-screen) { padding-left: 14px; padding-right: 14px; }
  .onboarding-title { font-size: 33px; }
  .onboarding-card { padding: 13px; }
  .composer { padding-left: 9px; padding-right: 4px; }
  .composer-action { width: 30px; height: 30px; }
  .composer-action svg { width: 18px; height: 18px; }
  .send-btn { width: 34px; height: 34px; }
  .chat-head { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .chat-head .icon-btn { width: 38px; height: 38px; }
  .sticker-grid { grid-template-columns: repeat(3, 1fr); }
  .roles-grid .role-card { padding: 12px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .chat-body { padding-top: 8px; }
  .onboarding { margin: 8px 0; }
  .onboarding-title { font-size: 30px; }
  .onboarding-card { max-height: 48dvh; overflow-y: auto; }
}


/* ---- viewport / 国产浏览器兼容 ---- */
:root { --app-height: 100dvh; --app-offset-top: 0px; --kb-bottom: 0px; }
.app-shell { height: calc(var(--app-height, 100dvh) - var(--browser-bottom, 0px)); }
/* 手机端：外壳直接钉在「可视区」上（--app-height / --app-offset-top 由 app.js 用 visualViewport 实时写入）。
   键盘一弹，可视区自己就变矮，外壳跟着变矮，输入栏自然贴住键盘；
   不再靠估算键盘高度去让位，所以输入框和键盘之间不会多出一截空白。 */
@media (max-width: 639px) {
  .app-shell {
    position: fixed;
    left: 0; right: 0;
    top: var(--app-offset-top, 0px);
    bottom: auto;
    height: calc(var(--app-height, 100dvh) - var(--kb-bottom, 0px));
    transform: none;
  }
}
.modal { top: var(--app-offset-top); bottom: auto; height: calc(var(--app-height, 100dvh) - var(--browser-bottom, 0px) - var(--kb-bottom, 0px)); padding: max(12px, var(--safe-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.modal-sheet { max-height: calc(var(--app-height, 100dvh) - 24px - env(safe-area-inset-bottom)); }
.toast { bottom: calc(86px + env(safe-area-inset-bottom) + var(--browser-bottom, 0px)); }

/* ---- 键盘弹出时的贴底处理（只针对手机竖屏：≥640px 是电脑端的居中卡片布局） ---- */
.kb-filler { display: none; }
@media (max-width: 639px) {
  /* 键盘已经盖住了系统手势条，底部安全区不用再留白，输入栏才能真正坐到键盘上 */
  body.kb-open #screen-chat .composer-wrap { padding-bottom: 7px; }
  body.kb-open #screen-chat .chat-body { padding-bottom: 10px; }
  /* 补缝层：万一浏览器报的键盘高度和真实键盘差一点，就用输入栏底色把外壳底下那条补住。
     做成一条带高光的磨砂边，露出来也像是故意留的装饰边，不再是一条黑缝。 */
  body.kb-open .kb-filler {
    display: block;
    position: fixed;
    left: 0; right: 0;
    top: calc(var(--app-offset-top, 0px) + var(--app-height, 100dvh) - var(--kb-bottom, 0px));
    bottom: auto;
    height: 100vh; height: 100dvh;
    z-index: 0;
    background: var(--kb-filler-bg, #ffffff);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -18px 22px -18px rgba(0, 0, 0, .22);
    pointer-events: none;
  }
}

/* 沉浸模式：屏幕最上沿一条很窄的磨砂装饰边，App 不直接贴着玻璃边，
   万一全屏时顶部留出一点点浏览器边距，也被这条边盖住 */
body.immersive::before {
  content: "";
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 7px;
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 8, 14, .62), rgba(8, 8, 14, .16));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
body.immersive[data-mode="light"]::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .10));
}

/* ---- compact home, no horizontal role scrolling ---- */
@media (max-width: 700px) {
  .install-banner { display: none !important; }
  #screen-home { padding: calc(12px + var(--safe-top)) 16px calc(84px + env(safe-area-inset-bottom)); }
  #screen-home .home-head { margin: 4px 0 12px; }
  #screen-home .home-name { font-size: 20px; }
  #screen-home .continue-card { padding: 11px 12px; margin-bottom: 12px; border-radius: 18px; }
  #screen-home .continue-main { gap: 10px; margin-bottom: 8px; }
  #screen-home .continue-main .avatar { width: 42px; height: 42px; font-size: 21px; border-radius: 13px; }
  #screen-home .continue-text h3 { font-size: 16px; margin: 0 0 2px; }
  #screen-home .continue-text p:last-child { font-size: 11px; max-width: 200px; }
  #screen-home #btn-continue { padding: 8px 10px; font-size: 12px; }
  #screen-home .section-head { margin-bottom: 7px; }
  #screen-home .role-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; overflow: visible; padding: 0; margin: 0 0 12px; }
  #screen-home .role-chip { width: auto; min-width: 0; padding: 7px 5px 6px; gap: 4px; border-radius: 14px; }
  #screen-home .role-chip .avatar { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  #screen-home .role-chip strong { font-size: 10px; line-height: 1.25; }
  #screen-home .role-chip small { font-size: 8px; line-height: 1.2; }
  #screen-home .role-chip.add { min-height: 0; }
  #screen-home .role-chip.add svg { width: 17px; height: 17px; }
  #screen-home .recent-list { gap: 5px; }
  #screen-home .recent-item { padding: 7px 9px; }
  #screen-home .recent-item .avatar { width: 34px; height: 34px; font-size: 17px; border-radius: 11px; }
  #screen-home .recent-main strong { font-size: 12px; }
  #screen-home .recent-main p { font-size: 10px; margin-top: 1px; }
  #screen-home .empty-state { padding: 14px 10px; font-size: 11px; }
}

@media (min-width: 361px) and (max-width: 380px) {
  .onboarding-title { font-size: 34px; }
  .screen:not(.chat-screen) { padding-left: 16px; padding-right: 16px; }
  .chat-head, .chat-body { padding-left: 12px; padding-right: 12px; }
  .role-strip { margin-right: -16px; }
}

/* Netlify free badge iframe：避免挡住发送按钮 */
#nl-badge-frame { display: none !important; }

.home-head-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.home-game-btn { width: 38px; height: 38px; border-radius: 12px; flex: none; }

/* 首页顶部「沉浸」入口：常驻、带文字、强调色，一点就进全屏 */
.immersive-mini {
  display: inline-flex; align-items: center; gap: 5px; height: 38px; padding: 0 11px;
  border-radius: 13px; border: 1px solid rgba(240,166,181,.34);
  background: linear-gradient(135deg, rgba(240,166,181,.18), rgba(185,166,245,.14));
  color: var(--rose); font-size: 11.5px; font-weight: 600; flex: none;
  transition: background .2s, color .2s, border-color .2s, transform .16s;
}
.immersive-mini svg { width: 15px; height: 15px; }
.immersive-mini:hover { background: linear-gradient(135deg, rgba(240,166,181,.28), rgba(185,166,245,.2)); }
.immersive-mini:active { transform: scale(.96); }
.immersive-mini.active { background: linear-gradient(135deg, var(--rose), var(--lilac)); color: #2a1e2a; border-color: transparent; }
body[data-mode="light"] .immersive-mini {
  border-color: rgba(163,79,104,.26);
  background: linear-gradient(135deg, rgba(240,166,181,.2), rgba(185,166,245,.16));
  color: #a34f68;
}
@media (max-width: 360px) {
  .immersive-mini { height: 36px; padding: 0 9px; gap: 4px; font-size: 11px; }
}

.install-mini { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 10px; border-radius: 13px; border: 1px solid rgba(240,166,181,.24); background: rgba(240,166,181,.1); color: var(--rose); font-size: 11px; flex: none; }
.install-mini svg { width: 15px; height: 15px; }
@media (max-width: 360px) { .install-mini { padding: 0 7px; gap: 3px; font-size: 10px; } }

/* ---- chat background themes ---- */
.chatbg-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; margin-bottom: 10px; }
.chatbg-swatch { position: relative; height: 62px; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); text-align: left; }
.chatbg-swatch span { position: absolute; left: 7px; bottom: 5px; right: 5px; font-size: 9px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbg-swatch.active { border-color: rgba(255,255,255,.85); box-shadow: 0 0 0 2px rgba(240,166,181,.55), inset 0 0 0 1px rgba(0,0,0,.15); }
body[data-chatbg] .bubble { background: rgba(18,15,24,.58); border-color: rgba(255,255,255,.15); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); }
body[data-chatbg] .msg-row.me .bubble { background: linear-gradient(135deg, rgba(240,166,181,.92), rgba(214,166,239,.92)); border: 0; }
body[data-chatbg] .chat-day { color: rgba(255,255,255,.72); text-shadow: 0 1px 5px rgba(0,0,0,.45); }
body[data-chatbg] .chat-head { background: rgba(13,13,21,.62); }
body[data-chatbg] .composer-wrap { background: rgba(13,13,21,.7); }
body[data-chatbg] .typing-bubble { background: rgba(18,15,24,.55); }
body[data-chatbg] .chat-empty { color: rgba(255,255,255,.72); }
@media (max-width: 360px) { .chatbg-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* ===== QQ / WeChat style chat ===== */
:root {
  --bubble-me: #d8ecff;
  --bubble-me-text: #101418;
  --bubble-other: #ffffff;
  --bubble-other-text: #1a1a1a;
}
#screen-chat { background: #f2f3f5; color: #1a1a1a; padding: 0; }
#screen-chat .chat-head {
  background: #ffffff; border-bottom: 1px solid #e6e7e9; color: #111;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
#screen-chat .chat-head .icon-btn {
  color: #33383d; border-color: #e3e4e6; background: #f7f8fa;
}
#screen-chat .chat-head .icon-btn.active { color: #12b7f5; border-color: #b9e5fb; background: #eefaff; }
#screen-chat .chat-person strong { color: #111; font-size: 16px; }
#screen-chat .chat-person .avatar { width: 40px; height: 40px; border-radius: 9px; }
#screen-chat .online { color: #12b7f5; }
#screen-chat .online i { background: #12b7f5; }
#screen-chat .chat-body { background: transparent; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
#screen-chat .chat-day { color: #7e858b; text-shadow: none; font-size: 11px; margin: 2px 0 10px; }
#screen-chat .msg-row { gap: 10px; }
#screen-chat .msg-avatar, #screen-chat .typing-row .avatar { border-radius: 11px; width: 44px; height: 44px; flex: none; font-size: 22px; }
/* emoji 头像的底色本来就是半透明的，浅色聊天背景上会发虚：垫一层白底 + 细描边更清晰 */
#screen-chat .msg-avatar,
#screen-chat .chat-person .avatar {
  background-color: #fff !important;
  border: 1px solid rgba(16, 24, 40, .07);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
#screen-chat .bubble-wrap { max-width: 68%; }
/* 头像也可以点一下朗读这条消息 */
#screen-chat .msg-row:not(.me) .msg-avatar[data-speak] { cursor: pointer; transition: transform .15s; }
#screen-chat .msg-row:not(.me) .msg-avatar[data-speak]:active { transform: scale(.94); }
#screen-chat .bubble {
  background: var(--bubble-other); color: var(--bubble-other-text);
  border: 1px solid rgba(0,0,0,.045); box-shadow: 0 1px 3px rgba(16,24,40,.07);
  border-radius: 14px; padding: 8px 12px;
  font-size: 15px; line-height: 1.45; backdrop-filter: none; -webkit-backdrop-filter: none;
}
#screen-chat .msg-row.me .bubble {
  background: var(--bubble-me); color: var(--bubble-me-text);
  border: 0; box-shadow: 0 1px 3px rgba(16,24,40,.05);
  border-radius: 14px;
}
#screen-chat .msg-row.me .msg-caption { color: #1a1a1a; }
#screen-chat .bubble.image-bubble { background: #fff; border-color: #e8e8e8; border-radius: 14px; }
#screen-chat .msg-row.me .bubble.image-bubble { background: #fff; }
#screen-chat .bubble.image-bubble img { border-radius: 10px; }
#screen-chat .bubble.sticker-bubble { background: transparent; border: 0; box-shadow: none; padding: 2px; }
#screen-chat .bubble-meta { color: #6f767d; font-size: 10px; opacity: 1; }
#screen-chat .msg-read { color: #a0a5aa; width: 16px; height: 16px; }
#screen-chat .msg-read:hover { color: #333; background: #e9edf1; }
#screen-chat .msg-read svg { width: 11px; height: 11px; }
#screen-chat .typing-bubble { background: #fff; border-color: #e8e9eb; border-radius: 14px; box-shadow: 0 1px 3px rgba(16,24,40,.07); height: 44px; }
#screen-chat .typing-bubble span { background: #b8bdc4; }
#screen-chat .composer-wrap {
  background: #ffffff; border-top: 1px solid #e6e7e9;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); gap: 5px;
  flex: none;
}
#screen-chat .composer {
  background: #f4f5f7; border: 1px solid #eceef0; border-radius: 10px;
  padding: 3px 5px 4px 10px; min-height: 40px;
}
#screen-chat .composer textarea { color: #111; font-size: 16px; padding: 7px 0 2px; max-height: 96px; }
#screen-chat .composer textarea::placeholder { color: #a0a5aa; }
#screen-chat .composer-toolbar { padding-top: 1px; }
#screen-chat .composer-action { width: 35px; height: 33px; color: #3b4148; border-radius: 8px; }
#screen-chat .composer-action svg { width: 22px; height: 22px; }
#screen-chat .send-btn { width: 56px; height: 33px; border-radius: 8px; background: #12b7f5; color: #fff; margin-left: auto; box-shadow: none; }
#screen-chat .send-btn svg { width: 21px; height: 21px; }
#screen-chat .send-btn:disabled { opacity: .45; }
#screen-chat .image-preview { background: #fff; border-color: #e6e7e9; color: #333; }
#screen-chat .image-preview img { border-radius: 8px; }
#screen-chat .stop-btn { color: #12b7f5; background: #eefaff; border-color: #b9e5fb; }
#screen-chat .sticker-panel {
  background: #ffffff; border-color: #e6e7e9; color: #111;
  box-shadow: 0 -8px 30px rgba(0,0,0,.12); backdrop-filter: none; -webkit-backdrop-filter: none;
}
#screen-chat .sticker-head strong { color: #111; }
#screen-chat .sticker-tab { color: #666; border-color: #e6e7e9; background: #f7f8fa; }
#screen-chat .sticker-tab.active { color: #111; background: #eaf7fe; border-color: #b9e5fb; }
#screen-chat .sticker-item { background: #f5f6f8; border-color: #eceef0; }
#screen-chat .sticker-credit { color: #9aa0a6; }
#screen-chat .sticker-close { color: #555; }

/* bubble skins */
.bubble-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; margin-bottom: 10px; }
.bubble-swatch { position: relative; height: 64px; border-radius: 13px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); overflow: hidden; }
.bubble-swatch span { position: absolute; left: 7px; bottom: 4px; font-size: 9px; color: rgba(255,255,255,.82); }
.bubble-demo { position: absolute; display: block; height: 15px; border-radius: 7px; }
.bubble-demo-other { left: 8px; top: 12px; width: 34px; background: var(--other); border-top-left-radius: 3px; }
.bubble-demo-me { right: 8px; top: 33px; width: 39px; background: var(--me); border-top-right-radius: 3px; }
.bubble-swatch.active { border-color: rgba(255,255,255,.85); box-shadow: 0 0 0 2px rgba(18,183,245,.55); }

#screen-chat .msg-row .msg-avatar { width: 44px; height: 44px; border-radius: 11px; }
#screen-chat .msg-row.me .msg-avatar { background: #e9edf1 !important; border: 1px solid #dfe4e8; }
#screen-chat .msg-row.me .msg-avatar img { object-fit: cover; }
#screen-chat .msg-avatar img { object-fit: cover; }

/* 窄屏（≤360px）再收紧一点：气泡更窄，给头像留出呼吸 */
@media (max-width: 360px) {
  #screen-chat .msg-row { gap: 8px; }
  #screen-chat .bubble-wrap { max-width: 72%; }
}

/* ===== 小游戏入口 / 选择面板 / 全屏运行 ===== */
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.game-card { display: flex; align-items: center; gap: 9px; padding: 10px; border-radius: 15px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); text-align: left; color: var(--text); }
.game-card:active { transform: scale(.98); }
.game-emoji { width: 40px; height: 40px; flex: none; display: grid; place-items: center; font-size: 20px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.06); }
.game-info { min-width: 0; display: grid; gap: 3px; }
.game-info strong { font-size: 13px; font-weight: 600; }
.game-info span { font-size: 10px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-sheet { width: 100%; max-width: 560px; border-radius: 24px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #1b1924, #12111a); padding: 14px; box-shadow: var(--shadow); animation: sheet-up .28s cubic-bezier(.2,.7,.2,1); }
.game-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 12px; }
.game-head strong { font-size: 16px; }
.game-hint { font-size: 10px; color: var(--faint); line-height: 1.6; margin-top: 10px; padding: 0 2px; }
.game-player { position: fixed; inset: 0; z-index: 60; background: #0b0b13; display: flex; flex-direction: column; padding-top: var(--safe-top); padding-bottom: env(safe-area-inset-bottom); }
.game-player-head { flex: none; height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: #12111a; border-bottom: 1px solid var(--line); }
.game-player-head .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.game-player-head strong { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-open-link { flex: none; font-size: 11px; color: var(--rose); text-decoration: none; border: 1px solid rgba(240,166,181,.24); background: rgba(240,166,181,.08); padding: 6px 9px; border-radius: 9px; }
#game-frame { flex: 1; width: 100%; border: 0; background: #fff; display: block; }
@media (min-width: 640px) {
  .game-player { inset: auto; top: 16px; bottom: 16px; left: 50%; width: min(560px, 100%); transform: translateX(-50%); border-radius: 24px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); padding-bottom: 0; }
}
@media (min-width: 640px) {
  body { display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
  .app-shell {
    width: min(560px, 100%);
    max-width: 560px;
    height: min(900px, calc(var(--app-height, 100dvh) - 32px - var(--kb-bottom, 0px)));
    margin: 0 auto;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: var(--shadow);
  }
  .app-shell .chat-body { padding-bottom: 12px; }
  /* 手机横屏也是这套居中卡片：键盘弹出时把卡片整块抬到键盘上面，输入框才不会被挡 */
  body.kb-inset { align-items: flex-end; padding-bottom: calc(16px + var(--kb-inset, 0px)); }
}

/* ===== 深色 / 浅色模式 ===== */
.mode-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mode-btn { flex: 1; min-width: 86px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted); font-size: 12px; }
.mode-btn span { font-size: 14px; }
.mode-btn.active { color: var(--text); border-color: rgba(240,166,181,.45); background: rgba(240,166,181,.12); }

body[data-mode="light"] {
  --text: #1c1a22;
  --muted: #5f5a68;
  --faint: #8b8695;
  --line: rgba(28, 22, 36, .10);
  --line-strong: rgba(28, 22, 36, .18);
  --panel: rgba(255, 255, 255, .62);
  --panel-strong: rgba(255, 255, 255, .82);
  --shadow: 0 20px 50px rgba(60, 40, 70, .16);
  color-scheme: light;
}
body[data-mode="light"] .ambient { background: radial-gradient(120% 90% at 50% -10%, #fdf3f5 0%, #f3eef7 55%, #ece6f2 100%); }
body[data-mode="light"] .orb { opacity: .22; }
body[data-mode="light"] .grain { opacity: .03; }
body[data-mode="light"] .app-shell { background: linear-gradient(180deg, rgba(250,247,252,.92), rgba(240,236,246,.97)); }
body[data-mode="light"] .input,
body[data-mode="light"] .settings-group,
body[data-mode="light"] .role-card,
body[data-mode="light"] .role-chip,
body[data-mode="light"] .settings-entry,
body[data-mode="light"] .install-banner,
body[data-mode="light"] .feature-chips span,
body[data-mode="light"] .login-mode,
body[data-mode="light"] .advanced,
body[data-mode="light"] .sticker-item,
body[data-mode="light"] .sticker-tab,
body[data-mode="light"] .pill,
body[data-mode="light"] .mode-btn {
  background-color: rgba(255,255,255,.58);
}
body[data-mode="light"] .role-card:hover,
body[data-mode="light"] .role-chip:hover,
body[data-mode="light"] .settings-entry:hover,
body[data-mode="light"] .recent-item:hover,
body[data-mode="light"] .sticker-item:hover,
body[data-mode="light"] .icon-btn:hover,
body[data-mode="light"] .btn-ghost:hover {
  background-color: rgba(255,255,255,.82);
}
body[data-mode="light"] .input::placeholder { color: #948e9e; }
body[data-mode="light"] .icon-btn,
body[data-mode="light"] .btn-ghost { background-color: rgba(255,255,255,.55); }
body[data-mode="light"] .continue-card { background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,255,255,.6)); border-color: rgba(28,22,36,.12); box-shadow: 0 16px 40px rgba(80,50,90,.12); }
body[data-mode="light"] .profile-card { background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(255,255,255,.46)); }
body[data-mode="light"] .onboarding-card { background: linear-gradient(160deg, rgba(255,255,255,.82), rgba(255,255,255,.55)); }
body[data-mode="light"] .onboarding-title { background-image: linear-gradient(100deg, #2b2532, var(--accent-a) 45%, var(--accent-b) 90%); }
body[data-mode="light"] .brand-word,
body[data-mode="light"] .privacy-note,
body[data-mode="light"] .about { color: #8b8695; }
body[data-mode="light"] .section-head h3 { color: #332d3b; }
body[data-mode="light"] .tabbar { background: rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(30,20,40,.14); }
body[data-mode="light"] .tab { color: #8b8695; }
body[data-mode="light"] .tab.active { color: #2a2430; background: rgba(28,22,36,.07); }
body[data-mode="light"] .modal { background: rgba(35,28,45,.35); }
body[data-mode="light"] .modal-sheet,
body[data-mode="light"] .confirm-card { background: linear-gradient(180deg, #ffffff, #f4f0f8); }
body[data-mode="light"] .modal-head { background: linear-gradient(180deg, rgba(255,255,255,.99), rgba(255,255,255,.92)); }
body[data-mode="light"] .toast { background: rgba(255,255,255,.98); border-color: var(--line-strong); box-shadow: 0 12px 30px rgba(40,30,50,.15); }
body[data-mode="light"] .avatar { border-color: rgba(20,16,26,.1); }
body[data-mode="light"] .switch { background: rgba(28,22,36,.14); }
body[data-mode="light"] .switch i { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
body[data-mode="light"] .switch[aria-checked="true"] i { background: #2a1830; }
body[data-mode="light"] input[type="range"] { background: rgba(28,22,36,.16); }
body[data-mode="light"] .theme-swatch.active { border-color: #2a2430; box-shadow: 0 0 0 3px rgba(28,22,36,.12); }
body[data-mode="light"] .bubble-swatch { background: rgba(255,255,255,.45); border-color: rgba(28,22,36,.12); }
body[data-mode="light"] .bubble-swatch span { color: #4a4452; }
body[data-mode="light"] .bubble-demo-other { box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
body[data-mode="light"] .chatbg-swatch { border-color: rgba(28,22,36,.12); }
body[data-mode="light"] .load-older { color: #5d5866; background: rgba(255,255,255,.7); border-color: rgba(28,22,36,.08); }
body[data-mode="light"] .game-sheet { background: linear-gradient(180deg, #ffffff, #f5f1f9); }
body[data-mode="light"] .game-card { background: rgba(28,22,36,.04); border-color: rgba(28,22,36,.1); color: var(--text); }
body[data-mode="light"] .game-emoji { background: rgba(255,255,255,.8); border-color: rgba(28,22,36,.08); }
body[data-mode="light"] .game-hint { color: var(--faint); }
body[data-mode="light"] .game-player-head { background: #ffffff; border-color: var(--line); }body[data-mode="light"] .text-btn,
body[data-mode="light"] .install-mini,
body[data-mode="light"] .link { color: #a34f68; }
body[data-mode="light"] .install-mini { border-color: rgba(163,79,104,.26); background: rgba(240,166,181,.18); }
body[data-mode="light"] .text-btn:hover { color: #7d3348; }
body[data-mode="light"] .btn-danger { color: #a33a45; }
body[data-mode="light"] .status-text.ok { color: #2f7a5c; }
/* 背景遮罩跟随显示模式（和文字用同一套 data-mode，避免深底深字） */
.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body[data-mode="dark"] .app-shell::before {
  background: linear-gradient(180deg, rgba(10,10,17,.62), rgba(9,9,15,.86));
}
body[data-mode="light"] .app-shell::before {
  background: linear-gradient(180deg, rgba(250,248,252,.88), rgba(246,242,250,.94));
}
/* ===== 聊天记录 / 头像资料 ===== */
.msg-avatar[data-role-profile], .msg-avatar[data-user-profile] { cursor: pointer; transition: transform .15s ease; }
.msg-avatar[data-role-profile]:active, .msg-avatar[data-user-profile]:active { transform: scale(.94); }
.msg-target .bubble { animation: msg-flash 2.2s ease; }
@keyframes msg-flash {
  0% { box-shadow: 0 0 0 0 rgba(18,183,245,0); }
  20% { box-shadow: 0 0 0 3px rgba(18,183,245,.4); }
  100% { box-shadow: 0 0 0 0 rgba(18,183,245,0); }
}

.history-sheet { max-height: min(76dvh, 700px); display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.history-sheet .modal-head { padding: 16px 18px 10px; flex: none; }
.history-search { display: flex; align-items: center; gap: 8px; margin: 0 16px 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); flex: none; }
.history-search-icon { font-size: 13px; opacity: .7; }
.history-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; font-family: inherit; }
.history-search input::placeholder { color: var(--faint); }
.history-search-clear { flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.history-list { flex: 1; overflow-y: auto; padding: 0 12px 18px; -webkit-overflow-scrolling: touch; }
.history-empty { padding: 42px 12px; text-align: center; color: var(--faint); font-size: 12px; }
.history-result-count { color: var(--faint); font-size: 11px; padding: 6px 6px 10px; }
.history-date-row { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; font-family: inherit; }
.history-date-main { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.history-date-main strong { font-size: 13px; font-weight: 600; }
.history-date-main em { font-style: normal; color: var(--faint); font-size: 10px; }
.history-date-arrow { color: var(--faint); font-size: 18px; }
.history-day-title { color: var(--muted); font-size: 11px; padding: 4px 8px 8px; }
.history-back { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 8px; cursor: pointer; font-family: inherit; }
.history-item { width: 100%; display: block; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.03); padding: 10px 12px; margin-bottom: 8px; color: var(--text); cursor: pointer; font-family: inherit; }
.history-item.me { background: rgba(240,166,181,.07); }
.history-item-top { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; color: var(--faint); margin-bottom: 4px; }
.history-who { color: var(--muted); }
.history-text { display: block; font-size: 12px; line-height: 1.55; color: var(--text); word-break: break-word; }
.history-text mark { background: rgba(240,166,181,.42); color: inherit; border-radius: 3px; padding: 0 1px; }

.role-profile-sheet { width: min(86vw, 360px); background: linear-gradient(180deg, #1a1822, #12111a); border: 1px solid var(--line-strong); border-radius: 22px; padding: 22px 18px 18px; position: relative; box-shadow: var(--shadow); }
.role-profile-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; font-size: 18px; }
.role-profile-head { display: flex; gap: 12px; align-items: center; }
.role-profile-title h3 { font-size: 18px; }
.role-profile-title p { color: var(--faint); font-size: 11px; margin-top: 3px; }
.role-profile-desc { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 14px 0 16px; word-break: break-word; max-height: 170px; overflow-y: auto; }
.role-profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.role-profile-actions .btn { flex: 1; min-width: 90px; }
.role-profile-hint { color: var(--faint); font-size: 10px; line-height: 1.6; margin-top: 10px; }

body[data-mode="light"] .history-sheet { background: linear-gradient(180deg, #ffffff, #f5f1f9); }
body[data-mode="light"] .history-search { background: rgba(255,255,255,.65); }
body[data-mode="light"] .history-search-clear { background: rgba(28,22,36,.08); }
body[data-mode="light"] .history-item { background: rgba(255,255,255,.6); }
body[data-mode="light"] .history-item.me { background: rgba(240,166,181,.16); }
body[data-mode="light"] .role-profile-sheet { background: linear-gradient(180deg, #ffffff, #f4f0f8); }

/* ===== 手机浏览器可视区适配 ===== */
:root { --safe-top: 0px; --browser-bottom: 0px; }
@media (display-mode: standalone) {
  :root { --safe-top: env(safe-area-inset-top); }
}
#history-modal, #role-modal, #advanced-modal { align-items: center; }
#history-modal .history-sheet { margin: auto; }

/* 手机上固定页面，避免浏览器地址栏收放时整页被上下推移 */
@media (max-width: 700px) {
  body { position: fixed; inset: 0; width: 100%; }
}
.game-player { bottom: var(--browser-bottom, 0px); }

/* ===== 沉浸模式 ===== */
.immersive-btn { width: 100%; }
body.immersive { --safe-top: env(safe-area-inset-top); }
/* ===== 下拉选项可读性 / 长上下文密码 ===== */
#set-context { color-scheme: dark; }
#set-context option { background-color: #1b1924; color: #f4f1ee; }
body[data-mode="light"] #set-context { color-scheme: light; background-color: #ffffff; }
body[data-mode="light"] #set-context option { background-color: #ffffff; color: #1c1a22; }
.context-password-card { width: min(86vw, 340px); }
.context-password-card p { font-size: 12px; line-height: 1.65; color: var(--muted); margin-bottom: 12px; }
.context-password-card .input { margin-bottom: 10px; }
.context-password-error { color: var(--danger) !important; font-size: 11px !important; margin: 0 0 8px !important; }
/* ===== 角色卡进阶字段 ===== */
.checkbox-row { display: flex; align-items: center; gap: 9px; padding: 7px 2px; color: var(--muted); font-size: 12px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--rose); flex: none; }
/* ===== 角色语音消息 ===== */
#screen-chat .bubble.voice-bubble { padding: 0; background: #ffffff; border: 1px solid #e8e9eb; box-shadow: 0 1px 3px rgba(16,24,40,.07); }
#screen-chat .msg-row.me .bubble.voice-bubble { background: #c6e9fb; border-color: #a9dcf6; }
#screen-chat .msg-row.me .voice-msg { color: #0b3d55; }
#screen-chat .msg-row.me .voice-wave i { background: rgba(11,61,85,.32); }
#screen-chat .msg-row.me .voice-dur { color: #2f6d88; }
.voice-msg { display: flex; align-items: center; gap: 9px; min-width: 170px; max-width: 230px; padding: 10px 13px; background: transparent; border: 0; cursor: pointer; color: #111; font-family: inherit; }
.voice-play { width: 27px; height: 27px; border-radius: 50%; background: #f0a6b5; color: #fff; display: grid; place-items: center; flex: none; }
.voice-play svg { width: 15px; height: 15px; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 20px; flex: 1; }
.voice-wave i { display: block; width: 2px; border-radius: 2px; background: #cbbac1; height: 8px; }
.voice-wave i:nth-child(2n) { height: 14px; }
.voice-wave i:nth-child(3n) { height: 18px; }
.voice-wave i:nth-child(4n) { height: 11px; }
.voice-dur { font-size: 11px; color: #7b8087; flex: none; }
.voice-msg:active .voice-play { transform: scale(.92); }
.voice-msg.playing .voice-play { animation: voicePulse 1s ease-in-out infinite; }
.history-actions { display: flex; gap: 8px; margin: 0 16px 10px; flex: none; }
.history-actions .btn { flex: 1; }
.chatbg-opacity-row { display: flex; align-items: center; gap: 10px; margin: 0 16px 10px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); flex: none; }
.chatbg-opacity-label { font-size: 11px; color: var(--muted); flex: none; }
.chatbg-opacity-row input[type="range"] { flex: 1; min-width: 80px; accent-color: var(--rose); }
.chatbg-opacity-value { font-size: 11px; color: var(--faint); flex: none; width: 36px; text-align: right; }
body[data-mode="light"] .chatbg-opacity-row { background: rgba(255,255,255,.6); }
/* ===== 所有下拉选项的可读性（音色/上下文/模型） ===== */
select.input { color-scheme: dark; }
select.input option,
select.input optgroup { background-color: #1b1924; color: #f4f1ee; }
body[data-mode="light"] select.input { color-scheme: light; background-color: #ffffff; }
body[data-mode="light"] select.input option,
body[data-mode="light"] select.input optgroup { background-color: #ffffff; color: #1c1a22; }

/* ===== 手机端性能：默认“流畅模式”去掉开销大的实时模糊和常驻动画；
   「我的 → 外观 → 精致画面」打开后恢复毛玻璃（吃 GPU，但更好看） ===== */
@media (max-width: 700px) {
  body[data-perf="smooth"] .app-shell,
  body[data-perf="smooth"] .chat-head,
  body[data-perf="smooth"] .composer-wrap,
  body[data-perf="smooth"] .modal,
  body[data-perf="smooth"] .voice-hold-card,
  body[data-perf="smooth"] .tabbar,
  body[data-perf="smooth"] .sticker-panel,
  body[data-perf="smooth"] .bubble { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  body[data-perf="smooth"].immersive::before { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  body[data-perf="smooth"] .orb { animation: none !important; filter: blur(46px); }
  body[data-perf="smooth"] .grain { display: none; }
  body[data-perf="smooth"] .continue-card { box-shadow: none; }
  body[data-perf="smooth"] .modal { background: rgba(4, 4, 8, .74); }
  /* 切页/弹窗动画两个模式都缩短，减少等待感 */
  .screen.active { animation-duration: .18s; }
  .modal-sheet { animation-duration: .2s; }
}