:root {
  --wx-green: #95ec69;
  --brand-green: #07c160;
  --page: #ededed;
  --line: #d9d9d9;
  --muted: #999;
  --text: #191919;
  --bar: #f7f7f7;
  --theme-accent: #07c160;
  --theme-bubble-self: #95ec69;
  --theme-bg: #ededed;
  --theme-header-bg: #ededed;
  --theme-panel-bg: #f7f7f7;
  --theme-bubble-self-image: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--page); }
body { color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; font-size: 15px; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.phone-app { position: relative; width: 100%; height: 100dvh; max-height: 100%; overflow: hidden; background: var(--page); }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.topbar { flex: 0 0 auto; height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); display: flex; align-items: center; background: var(--theme-header-bg); border-bottom: 1px solid rgba(0,0,0,.055); z-index: 5; }
.home-topbar { padding-left: 14px; padding-right: 5px; justify-content: space-between; }
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.topbar-actions { display: flex; gap: 2px; }
.icon-btn, .back-btn, .composer-btn, .sheet-close { border: 0; background: transparent; display: grid; place-items: center; padding: 0; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; }
.icon-btn svg { width: 21px; height: 21px; }
.home-content { flex: 1 1 auto; overflow-y: auto; background: #fff; overscroll-behavior: contain; }
.search-row { padding: 6px 10px; background: var(--page); }
.search-box { height: 32px; border-radius: 4px; background: #fff; color: #8d8d8d; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; }
.search-box svg { width: 15px; height: 15px; }
.conversation { position: relative; min-height: 60px; display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 8px 11px; background: #fff; cursor: pointer; }
.conversation:active { background: #ececec; }
.conversation::after { content: ""; position: absolute; left: 65px; right: 0; bottom: 0; height: 1px; background: #ededed; transform: scaleY(.5); }
.avatar { width: 44px; height: 44px; border-radius: 3px; display: block; overflow: hidden; user-select: none; background-color: #d7d7d7; }
.avatar.photo { background-image: url("avatar-sprite.png"); background-size: 300% 200%; background-position: var(--avatar-x) var(--avatar-y); background-repeat: no-repeat; }
.avatar.sm { width: 38px; height: 38px; }
.avatar.group-avatar { background: #d8d8d8 !important; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 1px; padding: 2px; }
.group-avatar i { display: block; background-image: url("avatar-sprite.png"); background-size: 300% 200%; background-position: var(--avatar-x) var(--avatar-y); background-repeat: no-repeat; }
.conv-body { min-width: 0; align-self: center; }
.conv-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 15px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { flex: 0 0 auto; color: #b5b5b5; font-size: 10px; }
.conv-preview { margin-top: 2px; color: #999; font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 16px; }
.avatar-wrap { position: relative; width: 44px; height: 44px; }
.unread { position: absolute; top: -5px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center; background: #fa5151; color: #fff; border: 1.5px solid #fff; font-size: 9px; line-height: 1; }
.unread.dot-only { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -3px; right: -3px; }
.tabbar { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4,1fr); min-height: 50px; padding-bottom: env(safe-area-inset-bottom); background: #f7f7f7; border-top: 1px solid #d7d7d7; z-index: 4; }
.tab { position: relative; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1px; padding: 3px 0 2px; font-size: 9px; color: #666; cursor: pointer; }
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--brand-green); }
.tab-icon-wrap { position: relative; display: grid; place-items: center; }
.tab-dot { position: absolute; top: -4px; right: -11px; min-width: 16px; height: 16px; border-radius: 9px; padding: 0 4px; display: grid; place-items: center; background: #fa5151; color: white; border: 1px solid var(--bar); font-size: 9px; font-style: normal; }
.contacts-head { padding: 10px 14px 5px; color: #888; background: var(--page); font-size: 12px; }
.contact-row { position: relative; height: 54px; display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: #fff; cursor: pointer; }
.contact-row::after { content: ""; position: absolute; left: 68px; right: 0; bottom: 0; border-bottom: 1px solid #ededed; transform: scaleY(.5); }
.contact-row:active { background: #eee; }
.contact-name { font-size: 15px; }
.contact-action-icon { width: 38px; height: 38px; border-radius: 3px; display: grid; place-items: center; background: #f5a623; color: white; }
.contact-action-icon.green { background: #42b983; }
.contact-action-icon svg { width: 22px; height: 22px; }
.empty-pane { height: 100%; display: grid; place-items: center; align-content: center; gap: 8px; background: #f5f5f5; color: #aaa; font-size: 14px; }
.empty-pane svg { width: 48px; height: 48px; color: #c7c7c7; }

.chat-topbar { display: grid; grid-template-columns: 44px 1fr 44px; }
.back-btn { width: 44px; height: 44px; justify-self: start; }
.back-btn svg { width: 22px; height: 22px; }
.chat-title-wrap { min-width: 0; text-align: center; }
.chat-title-wrap h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title-wrap span { display: block; margin-top: 2px; color: #8f8f8f; font-size: 10px; }
.theme-toggle { position: absolute; top: calc(55px + env(safe-area-inset-top)); right: 9px; z-index: 6; height: 24px; padding: 0 7px; border: 1px solid rgba(0,0,0,.08); border-radius: 3px; background: rgba(255,255,255,.82); color: #777; font-size: 10px; line-height: 22px; cursor: pointer; }
.theme-toggle:active { background: #e4e4e4; }
.theme-picker { position: absolute; top: calc(82px + env(safe-area-inset-top)); right: 9px; z-index: 7; width: 122px; padding: 3px 0; border: 1px solid rgba(0,0,0,.09); border-radius: 4px; background: #fff; }
.theme-picker button { width: 100%; height: 31px; padding: 0 9px; border: 0; background: transparent; color: #555; text-align: left; font-size: 11px; cursor: pointer; }
.theme-picker button + button { border-top: 1px solid #f0f0f0; }
.theme-picker button[aria-checked="true"] { color: #111; font-weight: 500; }
.theme-picker button[aria-checked="true"]::after { content: "✓"; float: right; color: var(--theme-accent); }
.messages { position: relative; flex: 1 1 auto; min-height: 0; padding: 8px 11px 14px; overflow-y: auto; overscroll-behavior: contain; background-color: var(--theme-bg); }
.time-divider { margin: 10px 0 12px; text-align: center; color: #999; font-size: 10px; }
.reply-now { align-self: center; margin: 0 0 7px; padding: 4px 12px; border: 1px solid #c8c8c8; border-radius: 14px; background: rgba(255,255,255,.8); color: #666; font-size: 11px; cursor: pointer; }
.typing-status { display: inline-flex; align-items: center; gap: 4px; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #e34d59; animation: typing-breathe 1.6s ease-in-out infinite; }
@keyframes typing-breathe { 50% { opacity: .35; transform: scale(.85); } }
.composer-wrap.replying { opacity: .62; }
.message-row { display: flex; align-items: flex-start; gap: 9px; margin: 9px 0; }
.message-row.self { flex-direction: row-reverse; }
.message-main { max-width: calc(100% - 90px); }
.sender-name { height: 14px; margin: -2px 0 2px 1px; color: #8b8b8b; font-size: 9px; }
.bubble { position: relative; padding: 6px 9px; border: 1px solid rgba(0,0,0,.035); border-radius: 3px; background: #fff; font-size: 14px; line-height: 1.42; word-break: break-word; white-space: pre-wrap; }
.self .bubble { background-color: var(--theme-bubble-self); background-image: var(--theme-bubble-self-image); }
.bubble::before { content: ""; position: absolute; top: 10px; left: -3px; width: 6px; height: 6px; background: #fff; border-left: 1px solid rgba(0,0,0,.03); border-bottom: 1px solid rgba(0,0,0,.03); transform: rotate(45deg); }
.self .bubble::before { left: auto; right: -3px; background: var(--theme-bubble-self); border: 0; transform: rotate(45deg); }
.message-row.compact { margin-top: -2px; }
.transfer-card { position: relative; width: 210px; overflow: visible; border-radius: 3px; background: #f89b3c; color: #fff; cursor: pointer; }
.transfer-card::after { content: ""; position: absolute; top: 13px; right: -3px; width: 6px; height: 6px; background: #f89b3c; transform: rotate(45deg); }
.message-row:not(.self) .transfer-card::after { right: auto; left: -3px; }
.transfer-main { display: flex; align-items: center; gap: 9px; min-height: 58px; padding: 8px 10px 7px; overflow: hidden; border-radius: 3px 3px 0 0; }
.money-icon { flex: 0 0 34px; width: 34px; height: 34px; border: 1.5px solid rgba(255,255,255,.95); border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 400; }
.transfer-info { min-width: 0; }
.transfer-info strong { display: block; margin-bottom: 2px; font-size: 16px; line-height: 20px; font-weight: 400; }
.transfer-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; line-height: 14px; }
.transfer-foot { height: 20px; padding: 3px 10px 0; overflow: hidden; border-radius: 0 0 3px 3px; background: #fff; color: #999; font-size: 9px; line-height: 14px; }
.composer-wrap { flex: 0 0 auto; padding-bottom: env(safe-area-inset-bottom); background: var(--theme-panel-bg); border-top: 1px solid #ddd; z-index: 5; }
.composer { min-height: 50px; display: flex; align-items: flex-end; gap: 5px; padding: 6px 7px; }
.composer-btn { flex: 0 0 29px; width: 29px; height: 36px; }
.composer-btn svg { width: 25px; height: 25px; }
#messageInput { flex: 1; min-width: 0; min-height: 36px; max-height: 90px; resize: none; border: 0; border-radius: 4px; outline: 0; padding: 7px 8px; background: #fff; color: #111; font-size: 14px; line-height: 21px; }
.send-btn { flex: 0 0 auto; height: 32px; margin-bottom: 2px; padding: 0 11px; border: 0; border-radius: 3px; background: var(--theme-accent); color: #fff; font-size: 13px; cursor: pointer; }
.feature-panel { flex: 0 0 170px; display: grid; grid-template-columns: repeat(4,1fr); align-content: start; gap: 18px 8px; padding: 22px 15px; background: var(--theme-panel-bg); border-top: 1px solid #e1e1e1; }
.feature-item { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 8px; color: #777; font-size: 12px; cursor: pointer; }
.feature-icon { width: 50px; height: 50px; border-radius: 7px; display: grid; place-items: center; background: #fff; color: #222; }
.feature-icon svg { width: 26px; height: 26px; }

/* 轻二次元实验主题：只改视觉变量，不改变微信式尺寸与结构。 */
.view-chat[data-theme="soft"] {
  --theme-accent: #ad7865;
  --theme-bubble-self: #d9b9a9;
  --theme-bg: #f0ece9;
  --theme-header-bg: #ede7e3;
  --theme-panel-bg: #f4f0ed;
}
.view-chat[data-theme="soft"] .chat-title-wrap span { color: #9b7769; }
.view-chat[data-theme="soft"] .chat-title-wrap span::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 4px 1px 0; border-radius: 50%; background: #82a67e; }
.view-chat[data-theme="soft"] .theme-toggle { border-color: #d8ccc5; background: rgba(255,253,251,.86); color: #8b675a; }
.view-chat[data-theme="soft"] .feature-icon { border: 1px solid #e1d8d2; background: #fffdfb; color: var(--theme-accent); }
.view-chat[data-theme="soft"] .feature-icon svg { width: 25px; height: 25px; }

/* 梦幻二次元：聊天软件结构不动，只增加低强度的甜系装饰层。 */
.view-chat[data-theme="dream"] {
  --theme-accent: #9a79c7;
  --theme-bubble-self: #e7cbe5;
  --theme-bubble-self-image: linear-gradient(135deg, #f1c7da 0%, #e0d0ef 55%, #cbdff1 100%);
  --theme-bg: #f5f1f6;
  --theme-header-bg: #f3edf6;
  --theme-panel-bg: #f7f2f8;
}
.view-chat[data-theme="dream"] .messages::before,
.view-chat[data-theme="dream"] .messages::after { position: absolute; z-index: 0; pointer-events: none; color: rgba(131,99,160,.075); }
.view-chat[data-theme="dream"] .messages::before { content: "✦  ·  ☾  ·  ✧"; top: 68px; right: 18px; font-size: 18px; letter-spacing: 7px; transform: rotate(-7deg); }
.view-chat[data-theme="dream"] .messages::after { content: "✧  ·  ✦"; top: 310px; left: 24px; font-size: 15px; letter-spacing: 10px; transform: rotate(6deg); }
.view-chat[data-theme="dream"] .message-row,
.view-chat[data-theme="dream"] .time-divider { position: relative; z-index: 1; }
.view-chat[data-theme="dream"] .self .bubble::after { content: ""; position: absolute; top: -4px; right: 18px; width: 6px; height: 5px; background: #eac9df; clip-path: polygon(0 100%, 50% 0, 100% 100%); filter: drop-shadow(10px 0 0 #d8d7ef); opacity: .9; }
.view-chat[data-theme="dream"] .self .bubble::before { background: #ddd4ed; }
.view-chat[data-theme="dream"] .chat-title-wrap span { color: #8d73a5; }
.view-chat[data-theme="dream"] .chat-title-wrap span::before { content: "✦"; display: inline-block; margin-right: 4px; color: #a487c1; font-size: 8px; }
.view-chat[data-theme="dream"] .theme-toggle { border-color: #dcd0e6; background: rgba(255,251,255,.9); color: #7d658e; }
.view-chat[data-theme="dream"] .theme-picker { border-color: #e1d6e9; background: #fffafd; }
.view-chat[data-theme="dream"] .feature-icon { border: 1px solid #e6d8eb; border-radius: 9px; background: #fff9fd; color: var(--theme-accent); }
.view-chat[data-theme="dream"] .feature-icon svg { width: 24px; height: 24px; }
.view-chat[data-theme="dream"] .composer-btn { color: #65566f; }

.overlay { position: absolute; inset: 0; z-index: 20; display: block; background: #f7f7f7; }
.transfer-sheet { width: 100%; height: 100%; min-height: 100%; padding-top: env(safe-area-inset-top); padding-bottom: max(18px, env(safe-area-inset-bottom)); background: #f7f7f7; }
.sheet-header { height: 48px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; border-bottom: 1px solid #e3e3e3; text-align: center; background: #ededed; }
.sheet-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-close { width: 48px; height: 48px; }
.sheet-close svg { width: 22px; height: 22px; }
.payee { display: flex; flex-direction: column; align-items: center; padding: 22px 16px 14px; }
.payee .avatar { width: 46px; height: 46px; margin-bottom: 7px; }
.payee strong { font-size: 15px; font-weight: 500; }
.payee > span { margin-top: 4px; color: #aaa; font-size: 11px; }
.amount-box { margin: 4px 24px 0; padding: 13px 0 3px; border-bottom: 1px solid #e5e5e5; background: #fff; }
.amount-box label { font-size: 13px; }
.amount-line { display: flex; align-items: center; margin-top: 4px; }
.amount-line b { font-size: 28px; font-weight: 500; }
.amount-line input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 2px 8px; font-size: 38px; font-weight: 500; }
.note-field { height: 48px; margin: 0 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #e5e5e5; background: #fff; }
.note-field span { flex: 0 0 auto; color: #555; font-size: 13px; }
.note-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: #222; text-align: right; font-size: 13px; }
.confirm-transfer { display: block; width: calc(100% - 48px); height: 44px; margin: 28px 24px 0; border: 0; border-radius: 5px; background: var(--brand-green); color: #fff; font-size: 16px; cursor: pointer; }
.confirm-transfer:disabled { background: #9edfb9; color: rgba(255,255,255,.8); }
.mock-tip { margin: 14px 20px 0; color: #bbb; text-align: center; font-size: 10px; }
.toast { position: absolute; z-index: 40; left: 50%; bottom: 86px; transform: translateX(-50%); max-width: 80%; padding: 9px 13px; border-radius: 4px; background: rgba(0,0,0,.7); color: white; font-size: 12px; white-space: nowrap; }

@media (min-width: 561px) {
  .phone-app { height: 100%; }
}
@media (max-width: 480px) {
  html, body {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
  .phone-app {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}
@media (max-width: 370px) {
  .message-main { max-width: calc(100% - 82px); }
  .transfer-card { width: 198px; }
  .composer { gap: 4px; }
  .composer-btn { flex-basis: 29px; width: 29px; }
}
