/* ============================================================
   邮信X - 仿微信 WebApp 样式
   设计基准：微信桌面端（三栏）+ 微信移动端（单栏切换）
   主色：#07c160（微信绿）
   ============================================================ */

:root {
    --wx-green: #07c160;
    --wx-green-dark: #06ad56;
    --wx-green-light: #e5f7ec;
    --bg-app: #f5f5f5;
    --bg-panel: #ffffff;
    --bg-rail: #2e2e2e;
    --bg-list-hover: #f0f0f0;
    --bg-chat: #f5f5f5;
    --bg-bubble-in: #ffffff;
    --bg-bubble-out: #95ec69;
    --text-primary: #191919;
    --text-secondary: #7f7f7f;
    --text-placeholder: #b3b3b3;
    --border-color: #e7e7e7;
    --danger: #fa5151;
    --radius: 8px;
    --rail-w: 68px;
    --list-w: 300px;
    --header-h: 60px;
    --shadow: 0 2px 12px rgba(0, 0, 0, .08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
[hidden] { display: none !important; }

/* 刷新恢复：会话仍有效时首帧直接显示主界面，避免闪回登录页 */
html.app-restoring #auth-view { display: none !important; }
html.app-restoring #main-view[hidden] { display: flex !important; }
@media (max-width: 900px) {
    html.app-restoring #main-view[hidden] { display: block !important; }
    html.app-restoring-tabbar #mobile-tabbar[hidden] { display: grid !important; }
}

/* ============ 冷启动连线更新遮罩 ============ */
.update-splash {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #fff; color: var(--text-primary);
}
html:not(.app-cold-start) .update-splash { display: none !important; }
.splash-logo {
    width: 72px; height: 72px; border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    background: var(--wx-green); color: #fff; font-size: 40px; line-height: 1;
    box-shadow: 0 8px 24px rgba(7, 193, 96, .25);
}
.splash-title { margin: 18px 0 26px; font-size: 20px; font-weight: 600; letter-spacing: .08em; }
.splash-progress {
    width: 220px; height: 4px; border-radius: 2px;
    background: #e8e8e8; overflow: hidden;
}
.splash-bar {
    width: 8%; height: 100%; border-radius: 2px;
    background: var(--wx-green); transition: width .25s ease;
}
.splash-status { margin: 14px 0 0; font-size: 12px; color: var(--text-secondary); }

.app { height: 100vh; height: 100dvh; overflow: hidden; }

/* ============ 登录 / 注册 ============ */
.auth-view {
    height: 100%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #e8f8ee 0%, #d4f0de 50%, #c5e9d2 100%);
    padding: 20px;
    overflow-y: auto;
}

.auth-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(7, 193, 96, .16), 0 2px 8px rgba(0, 0, 0, .04);
    padding: 36px 30px 28px;
}

.auth-brand { text-align: center; margin-bottom: 28px; }
.brand-icon { display: inline-flex; margin-bottom: 8px; }
.auth-brand h1 { margin: 0; font-size: 26px; letter-spacing: 2px; color: #1a1a1a; }
.auth-subtitle { margin: 6px 0 0; color: var(--text-secondary); font-size: 13px; }

.auth-tabs {
    display: flex; gap: 3px;
    padding: 3px; margin-bottom: 24px;
    background: #ededed; border-radius: 11px;
}
.auth-tab {
    flex: 1; padding: 9px 0;
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 14px; color: var(--text-secondary);
    border-radius: 8px; transition: background .18s, color .18s;
    -webkit-tap-highlight-color: transparent;
}
.auth-tab.active {
    color: var(--text-primary); font-weight: 600;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

.auth-form { display: flex; flex-direction: column; gap: 18px; }
.form-field label { display: block; margin-bottom: 7px; font-size: 13px; color: #444; font-weight: 500; }
.form-field input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: #f5f5f7;
    outline: none;
    transition: background .2s, border-color .2s, box-shadow .2s;
}
.form-field input:focus {
    background: #fff;
    border-color: var(--wx-green);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, .1);
}
.field-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--text-placeholder); }

/* 登录/注册：用户名 + 节点域下拉 */
.auth-email-wrap { position: relative; }
.auth-email-control {
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 11px;
    background: #f5f5f7;
    transition: background .2s, border-color .2s, box-shadow .2s;
}
.auth-email-control:focus-within {
    background: #fff;
    border-color: var(--wx-green);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, .1);
}
.auth-email-control > input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 13px 6px 13px 14px;
    border: 0 !important;
    border-radius: 11px 0 0 11px;
    background: transparent !important;
    box-shadow: none !important;
}
.auth-email-control > input:focus { border: 0 !important; box-shadow: none !important; }
.auth-domain-btn {
    flex: 0 0 auto;
    max-width: 48%;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px 12px;
    border: 0;
    border-left: 1px solid #e3e3e6;
    background: transparent;
    color: var(--wx-green-dark);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#auth-domain-btn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 注册态：节点域锁定为当前节点域，按钮只作提示，不展开菜单 */
.auth-domain-btn.is-locked { cursor: default; }
.auth-domain-caret { flex: 0 0 auto; color: var(--text-placeholder); font-size: 11px; transition: transform .18s; }
.auth-domain-btn[aria-expanded="true"] .auth-domain-caret { transform: rotate(180deg); }
.auth-domain-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    width: max(200px, 100%);
    max-height: 264px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .14);
}
.auth-domain-menu-title { padding: 6px 10px 4px; font-size: 11px; color: var(--text-placeholder); }
.auth-domain-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.auth-domain-option:hover, .auth-domain-option:focus-visible { background: #e8f8ee; outline: none; }
.auth-domain-option.selected { background: #f0fbf4; color: var(--wx-green-dark); font-weight: 600; }
.auth-domain-option em {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 8px;
    background: #e8f8ee;
    color: var(--wx-green);
    font-size: 10px;
    font-style: normal;
    font-weight: 400;
}
.auth-domain-custom {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}
.auth-domain-custom input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f8f8f8;
    font-size: 12px;
    outline: none;
}
.auth-domain-custom input:focus { border-color: var(--wx-green); background: #fff; }
.auth-domain-custom button {
    flex: 0 0 auto;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: var(--wx-green);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

.auth-error {
    min-height: 18px;
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--wx-green);
    color: #fff;
    border: 0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    transition: background .2s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.btn-secondary {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-primary:hover { background: var(--wx-green-dark); }
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.auth-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-secondary);
}
.auth-install { margin-top: 10px; text-align: center; }
.auth-install-link {
    border: 0; background: none; padding: 4px 6px;
    color: var(--wx-green); font-size: 12px; cursor: pointer;
}
.auth-install-link:hover { color: var(--wx-green-dark); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-on { background: var(--wx-green); box-shadow: 0 0 0 3px rgba(7, 193, 96, .15); }
.status-off { background: #d0d0d0; }

/* ============ 主布局 ============ */
.main-view { display: flex; height: 100%; background: var(--bg-panel); }

/* 功能栏 */
.rail {
    width: var(--rail-w);
    flex: 0 0 var(--rail-w);
    background: var(--bg-rail);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 0 14px;
    gap: 6px;
}
.rail-avatar {
    width: 38px; height: 38px;
    border-radius: 6px;
    background: var(--wx-green);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 600; margin-bottom: 18px;
    overflow: hidden; object-fit: cover;
}
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.rail-btn {
    width: 44px; height: 44px;
    border-radius: 8px;
    color: #8e8e8e;
    display: grid; place-items: center;
    position: relative;
    transition: color .15s, background .15s;
}
.rail-btn:hover { color: #d8d8d8; }
.rail-btn.active { color: var(--wx-green); }
.rail-badge, .tab-badge {
    position: absolute;
    top: 4px; right: 4px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-style: normal;
    line-height: 16px;
    text-align: center;
}
.rail-spacer { flex: 1; }
.rail-bottom { margin-top: auto; }

/* 通用面板 */
.panel { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.panel-list {
    width: var(--list-w);
    flex: 0 0 var(--list-w);
    border-right: 1px solid var(--border-color);
    background: #f7f7f7;
}
.panel-chat { flex: 1; background: var(--bg-chat); position: relative; }
.panel-secondary {
    width: var(--list-w);
    flex: 0 0 var(--list-w);
    border-left: 1px solid var(--border-color);
    background: #f7f7f7;
    position: relative; /* 朋友圈子视图的定位上下文；移动端媒体查询会覆盖为 absolute */
}

.list-header {
    height: var(--header-h);
    flex: 0 0 var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #f7f7f7;
    border-bottom: 1px solid var(--border-color);
}
.list-title { font-size: 16px; font-weight: 600; }
.list-heading { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.list-sub {
    font-size: 11px; color: var(--text-placeholder);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-sub[hidden] { display: none; }
.list-actions { display: flex; gap: 4px; }

.icon-btn {
    width: 34px; height: 34px;
    border-radius: 6px;
    display: grid; place-items: center;
    color: #555;
    transition: background .15s;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }

.search-box { padding: 8px 12px; border-bottom: 1px solid var(--border-color); }
.search-box input {
    width: 100%; padding: 8px 12px;
    border: 1px solid #ddd; border-radius: 6px;
    outline: none; font-size: 13px;
}
.search-box input:focus { border-color: var(--wx-green); }

/* ============ 会话列表 ============ */
.conversation-list { flex: 1; overflow-y: auto; background: #f7f7f7; }
.loading-state { padding: 30px; text-align: center; color: var(--text-placeholder); font-size: 13px; }

.conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 14px;
    cursor: pointer;
    transition: background .12s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.conv-item:hover { background: var(--bg-list-hover); }
.conv-item.active { background: #e6e6e6; }
.conv-item:active { background: #dedede; }
.conv-item::after {
    content: ''; position: absolute;
    left: 70px; right: 0; bottom: 0;
    height: 1px; background: #ececec;
}
.conv-item .avatar { border-radius: 10px; }

.avatar {
    width: 44px; height: 44px; flex: 0 0 44px;
    border-radius: 6px;
    display: grid; place-items: center;
    color: #fff; font-size: 18px; font-weight: 600;
    overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-online {
    position: absolute;
    right: -1px; bottom: -1px;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--wx-green);
    border: 2px solid #f7f7f7;
}

.conv-info { flex: 1; min-width: 0; }
.conv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-placeholder); flex: 0 0 auto; }
.conv-preview {
    margin-top: 5px;
    font-size: 12px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-domain {
    display: inline-block;
    white-space: nowrap;
    flex: 0 0 auto;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--wx-green-light);
    color: var(--wx-green);
    margin-left: 5px;
    vertical-align: middle;
}
.conv-domain.remote { background: #fff2e0; color: #d48806; }
.unread-badge {
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff; font-size: 11px;
    line-height: 18px; text-align: center;
    flex: 0 0 auto;
}

.list-empty {
    padding: 50px 20px;
    text-align: center;
    color: var(--text-placeholder);
    font-size: 13px;
    line-height: 1.8;
}
.list-empty button { color: var(--wx-green); font-weight: 500; }

/* ============ 聊天区 ============ */
.chat-empty {
    height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-placeholder);
    gap: 10px;
}
.chat-empty p { margin: 0; font-size: 15px; color: #888; }
.chat-empty small { font-size: 12px; }

/* 键盘弹起时由 visualViewport 写入 --chat-kb-inset，压缩消息区而不是把输入框顶出视口 */
.chat-active {
    display: flex;
    flex-direction: column;
    height: calc(100% - var(--chat-kb-inset, 0px));
    position: relative;
    --protocol-h: 0px;
}
.chat-header {
    height: var(--header-h);
    flex: 0 0 var(--header-h);
    display: flex; align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: #f7f7f7;
    z-index: 2;
}
/* 返回/关闭会话：移动端与桌面端都保留出口。
   桌面虽然有三栏，但聊天窗口一旦打开就没有「回到空态」的控件，
   窄窗口或全屏 PWA 下容易进退两难，所以这里不再隐藏。 */
.back-btn { display: grid; }
/* 桌面端返回按钮的语义是「关闭会话」，与移动端的层级返回区分开 */
@media (min-width: 901px) {
    .back-btn { margin-left: -6px; margin-right: 2px; color: #666; }
    .back-btn:hover { color: #111; }
}
.chat-header-info { flex: 1; min-width: 0; margin-left: 4px; }
.chat-title { font-size: 15px; font-weight: 600; }
.chat-subtitle { font-size: 11px; color: var(--text-secondary); margin-top: 2px; display: flex; align-items: center; gap: 5px; min-width: 0; }
.chat-presence { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; color: var(--text-placeholder); }
.chat-presence i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chat-presence.on { color: var(--wx-green); }
.chat-sub-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.message-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 18px 20px;
    scroll-behavior: auto;
}
.chat-active.protocol-open .message-list { padding-bottom: calc(18px + var(--protocol-h)); }

.msg-row { display: flex; margin-bottom: 18px; gap: 10px; align-items: flex-start; }
.msg-row.out { flex-direction: row-reverse; }

.msg-avatar {
    width: 38px; height: 38px; flex: 0 0 38px;
    border-radius: 5px;
    display: grid; place-items: center;
    color: #fff; font-size: 15px; font-weight: 600;
    overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-body { max-width: min(65%, 520px); }
.msg-sender { font-size: 11px; color: var(--text-placeholder); margin: 0 0 4px 2px; }
.msg-row.out .msg-sender { text-align: right; margin-right: 2px; }

.bubble {
    padding: 10px 13px;
    border-radius: 6px;
    background: var(--bg-bubble-in);
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.bubble::before {
    content: '';
    position: absolute;
    top: 12px;
    border: 6px solid transparent;
}
.msg-row.in .bubble::before { left: -12px; border-right-color: var(--bg-bubble-in); }
.msg-row.out .bubble {
    background: var(--bg-bubble-out);
}
.msg-row.out .bubble::before { right: -12px; border-left-color: var(--bg-bubble-out); }
.bubble.text { white-space: pre-wrap; }
.bubble.image { padding: 4px; cursor: zoom-in; }
.bubble.image img { max-width: 220px; max-height: 220px; border-radius: 4px; display: block; }
.bubble.file { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.bubble.file .file-icon { font-size: 26px; }
.bubble.file .file-name { flex: 1; }
.bubble.file a { color: var(--wx-green); text-decoration: none; }

/* 视频气泡：首帧封面 + 播放徽标 */
.bubble.video {
    padding: 4px; cursor: pointer; position: relative;
    width: 220px; max-width: 220px;
}
.bubble.video video {
    display: block; width: 100%; height: 132px;
    border-radius: 4px; background: #000; object-fit: cover;
    pointer-events: none;
}
.bubble.video .media-play,
.bubble.audio .media-play {
    position: absolute; left: 50%; top: 50%;
    width: 42px; height: 42px; margin: -21px 0 0 -21px;
    border-radius: 50%; background: rgba(0, 0, 0, .55);
    color: #fff; display: grid; place-items: center;
    font-size: 15px; padding-left: 3px; pointer-events: none;
}
.bubble.video .media-dur {
    position: absolute; right: 8px; bottom: 8px;
    padding: 1px 5px; border-radius: 3px;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px;
    pointer-events: none;
}
/* 音频气泡：唱片 + 文件名 + 时长 */
.bubble.audio {
    display: flex; align-items: center; gap: 10px;
    min-width: 190px; cursor: pointer; position: relative;
}
.bubble.audio .media-play { position: static; margin: 0; width: 34px; height: 34px; flex: 0 0 34px; font-size: 13px; background: var(--wx-green); }
.bubble.audio .audio-main { flex: 1; min-width: 0; }
.bubble.audio .audio-name {
    font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bubble.audio .audio-wave { display: flex; align-items: flex-end; gap: 2px; height: 12px; margin-top: 4px; }
.bubble.audio .audio-wave i { width: 2px; background: rgba(0, 0, 0, .22); border-radius: 1px; }
.bubble.audio .audio-time { font-size: 11px; color: var(--text-secondary); flex: 0 0 auto; }

.msg-meta {
    font-size: 10px; color: var(--text-placeholder);
    margin-top: 4px; display: flex; gap: 8px; align-items: center;
}
.msg-row.out .msg-meta { justify-content: flex-end; }
.msg-meta .proto-tag {
    padding: 1px 4px; border-radius: 3px;
    background: #e8f4ff; color: #5a8dc7;
}
.msg-meta .msg-state.sending { color: var(--text-secondary); }
.msg-meta .msg-state.pending { color: #e6a23c; }

.msg-divider {
    text-align: center; font-size: 11px; color: var(--text-placeholder);
    margin: 10px 0 18px;
}

/* 协议信息条 */
.protocol-bar {
    position: absolute;
    left: 0; right: 0;
    bottom: 100%;
    z-index: 9;
    gap: 8px;
    padding: 6px 16px;
    background: #eef7ff;
    border-top: 1px solid #d8e9f7;
    border-bottom: 1px solid #d8e9f7;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .06);
    font-size: 11px;
    color: #5a7a99;
    display: flex; justify-content: space-between; align-items: center;
    white-space: nowrap;
    max-height: min(160px, 30vh);
    overflow: hidden;
}
.protocol-bar.expanded { align-items: flex-start; white-space: normal; overflow-y: auto; }
.protocol-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.protocol-bar.expanded span { overflow: visible; text-overflow: clip; }
.link-btn { color: #5a8dc7; font-size: 11px; flex: 0 0 auto; margin-left: 8px; }

/* 回到最新消息：浮在输入区上方，避免遮挡输入框 */
.jump-latest {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px + var(--protocol-h));
    transform: translateX(-50%);
    z-index: 8;
    padding: 7px 14px;
    border: 0;
    border-radius: 16px;
    background: rgba(7, 193, 96, .94);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(7, 193, 96, .28);
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.jump-latest:active { transform: translateX(-50%) scale(.96); }

/* 输入区 */
.composer {
    flex: 0 0 auto;
    background: #fff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
    position: relative;
    z-index: 7;
}
.composer-toolbar {
    display: flex; align-items: center; gap: 2px;
    padding: 6px 14px 0;
}
.composer-hint { margin-left: auto; font-size: 11px; color: var(--text-placeholder); }
.composer-input-row { display: flex; gap: 10px; padding: 6px 14px 12px; align-items: flex-end; }
/* ⊙ 收纳按钮 */
.btn-more {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #666;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.btn-more:hover { background: #f5f5f5; color: var(--wx-green); border-color: #b8e6c8; }
.btn-more.active { background: var(--wx-green-light); color: var(--wx-green); border-color: var(--wx-green); }
/* ⊙ 收纳面板（浮于输入框上方） */
.more-panel {
    position: absolute;
    left: 0; right: 0;
    bottom: 100%;
    background: #fff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    padding: 14px 16px 16px;
    z-index: 12;
}
.more-panel[hidden] { display: none; }
.more-media-row { display: flex; flex-wrap: wrap; gap: 14px; }
.more-media {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    border: none; background: transparent; cursor: pointer;
    font-size: 12px; color: var(--text-secondary);
    padding: 4px 8px; border-radius: 8px;
}
.more-media:hover { background: #f5f5f5; }
.more-media-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: grid; place-items: center; color: #fff;
}
.more-media-icon.image { background: #4a90d9; }
.more-media-icon.file { background: #f5a623; }
.more-media-icon.camera { background: #9b59b6; }
.more-media-icon.video { background: #e05a4f; }
.more-media-icon.audio { background: #07c160; }
.more-panel-label {
    margin: 14px 0 8px; font-size: 12px; color: var(--text-secondary);
    border-top: 1px solid var(--border-color); padding-top: 12px;
}
.more-emoji-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px; max-height: 168px; overflow-y: auto;
}
.more-emoji-grid .emoji-item { width: 40px; height: 40px; }
#message-input {
    flex: 1;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    max-height: 120px;
    min-height: 42px;
    outline: none;
    line-height: 1.5;
}
#message-input:focus { border-color: var(--wx-green); }
.btn-send {
    padding: 9px 20px;
    background: var(--wx-green);
    color: #fff;
    border-radius: 6px;
    font-weight: 500;
    flex: 0 0 auto;
    height: 42px;
}
.btn-send:hover { background: var(--wx-green-dark); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 通讯录 / 发现 / 我 ============ */
.secondary-content { flex: 1; overflow-y: auto; background: var(--bg-app); }
.section-title {
    padding: 12px 16px 6px;
    font-size: 12px; color: var(--text-secondary);
    background: #f7f7f7;
}
/* ---------- 通讯录 ---------- */
.contacts-page {
    width: 100%;
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

/* 搜索框：整块内嵌，聚焦时浮起 */
.contacts-search-wrap {
    display: flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 12px;
    background: #ececee; border-radius: 10px;
    color: var(--text-secondary);
    transition: background .15s, box-shadow .15s;
}
.contacts-search-wrap:focus-within {
    background: #fff;
    box-shadow: 0 0 0 1.5px rgba(7, 193, 96, .45), 0 2px 8px rgba(0, 0, 0, .05);
}
.contacts-search-wrap input {
    flex: 1; min-width: 0; height: 100%;
    border: none; background: transparent; outline: none;
    font-size: 13.5px; color: var(--text-primary);
    -webkit-appearance: none; appearance: none;
}
.contacts-search-wrap input::placeholder { color: var(--text-placeholder); }
.contacts-search-wrap input::-webkit-search-cancel-button { display: none; }
.search-clear {
    border: none; background: #c8c8c8; color: #fff;
    width: 17px; height: 17px; border-radius: 50%;
    font-size: 13px; line-height: 1; cursor: pointer;
    display: grid; place-items: center; flex: 0 0 auto;
}

/* 分组：轻标题 + 卡片 */
.contacts-section { margin-top: 18px; }
.contacts-section-title {
    display: flex; align-items: center; gap: 6px;
    margin: 0; padding: 0 6px 8px;
    font-size: 12px; font-weight: 500; color: var(--text-secondary);
}
.contacts-section-title.is-online::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--wx-green); flex: 0 0 6px;
}
.contacts-section-count {
    min-width: 18px; height: 16px; padding: 0 5px;
    display: inline-grid; place-items: center;
    border-radius: 8px; background: rgba(0, 0, 0, .055);
    font-size: 10.5px; font-weight: 500; color: var(--text-secondary);
}
.contacts-card {
    background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.contacts-empty {
    padding: 56px 24px; text-align: center;
    font-size: 13px; line-height: 1.9; color: var(--text-placeholder);
}

/* 好友行 */
.contact-item {
    display: flex; align-items: center; gap: 12px;
    min-height: 62px; padding: 10px 14px;
    cursor: pointer; background: #fff;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s;
}
.contact-item + .contact-item { border-top: 1px solid #f4f4f5; }
.contact-item:active { background: #f2f2f3; }
@media (hover: hover) {
    .contact-item:hover { background: #fafafa; }
}
.contact-item:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.contact-avatar { position: relative; flex: 0 0 42px; width: 42px; height: 42px; }
.contact-avatar .avatar { width: 42px; height: 42px; flex-basis: 42px; border-radius: 11px; font-size: 17px; }
.presence-dot {
    position: absolute; right: -2px; bottom: -2px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--wx-green);
    box-shadow: 0 0 0 2px #fff;
}
.presence-dot[hidden] { display: none; }
.contact-info { flex: 1; min-width: 0; }
.contact-name {
    display: flex; align-items: center; gap: 6px;
    font-size: 14.5px; line-height: 1.35; color: var(--text-primary);
}
/* 名称过长时在标签之前截断，标签始终紧贴名称 */
.contact-name-text {
    max-width: 68%; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-email {
    margin-top: 3px; font-size: 11.5px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-alias { color: var(--text-placeholder); }
.contact-sep { margin: 0 4px; color: #dcdcdc; }
.contact-domain-tag {
    margin-left: 6px; padding: 0 4px; border-radius: 3px;
    background: rgba(250, 157, 59, .14); color: #bf7620; font-size: 10px;
}
/* 兼容旧结构：会话/资料卡里的在线文字与圆点 */
.contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.online-label { font-size: 10px; color: var(--text-placeholder); }
.online-label.on { color: var(--wx-green); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; flex: 0 0 8px; }
.online-dot.on { background: var(--wx-green); }
.empty-hint { font-size: 11px; color: var(--text-placeholder); }
/* 资料卡状态行与操作按钮 */
.contact-status-line {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 8px; font-size: 12px; color: var(--text-secondary);
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; }

.profile-card { background: #fff; padding: 24px 16px; text-align: center; }
.profile-avatar {
    width: 64px; height: 64px; border-radius: 8px;
    margin: 0 auto 12px;
    background: var(--wx-green);
    color: #fff; display: grid; place-items: center;
    font-size: 26px; font-weight: 600;
    overflow: hidden;
}
/* 头像图必须铺满容器：否则 240px 原图会按原始尺寸居中溢出，只露出中心约 27%，
   看起来就像"保存的图和裁剪结果偏移/放大了"。 */
.profile-avatar img {
    width: 100%; height: 100%; display: block;
    object-fit: cover; object-position: center;
    border-radius: inherit;
}
.profile-name { font-size: 17px; font-weight: 600; }
.profile-email { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.profile-avatar-lg { width: 76px; height: 76px; flex-basis: 76px; font-size: 30px; }
.profile-signature {
    margin-top: 10px; font-size: 13px; color: var(--text-secondary);
    line-height: 1.5; word-break: break-word;
}

/* 个人资料编辑 */
.profile-edit-avatar-row { display: flex; align-items: center; gap: 14px; }
.profile-edit-avatar {
    position: relative; width: 72px; height: 72px; flex: 0 0 72px;
    padding: 0; border: 0; background: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.profile-edit-avatar .profile-avatar { width: 72px; height: 72px; margin: 0; font-size: 28px; }
.profile-avatar-cam {
    position: absolute; right: -4px; bottom: -4px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--wx-green); color: #fff; border: 2px solid #fff;
    display: grid; place-items: center; font-size: 16px; line-height: 1;
}
.profile-edit-avatar-tip { flex: 1; min-width: 0; }
.profile-edit-label { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.link-danger {
    margin-top: 6px; padding: 0; border: 0; background: none;
    color: #e05252; font-size: 12px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.profile-field { margin-top: 18px; }
.profile-field label {
    display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary);
}

/* 头像裁剪编辑器 */
.cropper { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; }
.cropper-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.cropper-panel {
    position: relative; width: min(400px, 100%); max-height: 94vh; overflow-y: auto;
    background: #fff; border-radius: 14px; box-shadow: var(--shadow);
    display: flex; flex-direction: column;
}
.cropper-stage {
    position: relative; width: min(280px, 74vw); aspect-ratio: 1 / 1;
    margin: 16px auto 12px; overflow: hidden; background: #111;
    border-radius: 8px; cursor: grab; touch-action: none; user-select: none;
    -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.cropper-stage.dragging { cursor: grabbing; }
#crop-image {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block;
    pointer-events: none;
}
.cropper-grid {
    position: absolute; inset: 0; pointer-events: none; box-sizing: border-box;
    border: 2px solid rgba(255,255,255,.9);
}
.cropper-grid::before, .cropper-grid::after { content: ''; position: absolute; }
.cropper-grid::before {
    left: 33.333%; right: 33.333%; top: 0; bottom: 0;
    border-left: 1px solid rgba(255,255,255,.42);
    border-right: 1px solid rgba(255,255,255,.42);
}
.cropper-grid::after {
    top: 33.333%; bottom: 33.333%; left: 0; right: 0;
    border-top: 1px solid rgba(255,255,255,.42);
    border-bottom: 1px solid rgba(255,255,255,.42);
}
.cropper-toolbar { display: flex; align-items: center; gap: 10px; padding: 0 16px 12px; }
.cropper-tool {
    flex: 0 0 auto; padding: 7px 12px; border: 1px solid var(--border-color);
    background: #fff; border-radius: 6px; font-size: 13px;
    color: var(--text-primary); cursor: pointer;
}
.cropper-tool:active { background: #f5f5f5; }
.cropper-zoom { flex: 1; min-width: 0; accent-color: var(--wx-green); }
.cropper-zoom-label { flex: 0 0 42px; text-align: right; font-size: 12px; color: var(--text-secondary); }
.cropper-result { display: flex; align-items: center; gap: 12px; padding: 0 16px 2px; }
.cropper-result .modal-hint { margin: 0; }
.cropper-preview {
    width: 56px; height: 56px; flex: 0 0 56px; border-radius: 8px; overflow: hidden;
    background: var(--wx-green); box-shadow: 0 0 0 1px var(--border-color);
}
.cropper-preview canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 480px) {
    .cropper { padding: 10px; }
    .cropper-panel { max-height: 96vh; }
    .cropper-result .modal-hint { font-size: 11px; }
}

.info-group { background: #fff; margin-top: 10px; }
.info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row .value { color: var(--text-secondary); font-size: 13px; }
.info-row .wx-green { color: var(--wx-green); }

.discover-item {
    display: flex; align-items: center; gap: 12px;
    min-height: 62px; padding: 10px 14px; background: #fff;
    -webkit-tap-highlight-color: transparent;
}
.discover-icon {
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
    display: grid; place-items: center;
    color: #fff; font-size: 18px;
}
.discover-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.discover-title { font-size: 15px; font-weight: 500; }
.discover-desc { font-size: 11px; color: var(--text-secondary); }
.discover-entry { cursor: pointer; }
.discover-entry:active { background: #f2f2f2; }
.discover-entry:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.discover-arrow { width: 17px; height: 17px; color: #c7c7cc; flex: 0 0 auto; }

/* ============ 「我」页：原生设置页风格 ============ */
.me-page {
    /* 底部留白：移动端 Tab 栏的高度由面板自己让开（见下方 .has-tabbar 规则），
       这里只负责最后一张卡片到面板底边之间的视觉缓冲，不再重复叠加安全区 */
    padding-bottom: 24px;
}

/* 个人资料卡片 */
.me-hero { padding: 16px 12px 0; }
.me-hero-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 16px; background: #fff; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.me-hero-card[role="button"] { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.me-hero-card[role="button"]:active { background: #f7f7f7; }
.me-hero-card[role="button"]:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.me-hero-card .me-section-arrow { margin-left: 2px; }
.me-hero-card .profile-avatar {
    width: 62px; height: 62px; margin: 0;
    border-radius: 14px; font-size: 25px; flex: 0 0 62px;
}
.me-hero-info { flex: 1; min-width: 0; }
.me-hero-name { font-size: 19px; font-weight: 600; line-height: 1.3; }
.me-hero-email {
    margin-top: 4px; font-size: 12px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.me-online {
    display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
    padding: 4px 9px; border-radius: 999px;
    background: var(--wx-green-light); color: var(--wx-green); font-size: 11px;
}
.me-online i { width: 6px; height: 6px; border-radius: 50%; background: var(--wx-green); }
.me-online.off { background: #f2f2f2; color: var(--text-secondary); }
.me-online.off i { background: var(--text-placeholder); }

/* 分组卡片 */
.me-group { margin-top: 18px; padding: 0 12px; }
.me-group-title { padding: 0 4px 8px; font-size: 12px; color: var(--text-secondary); }
.me-card {
    background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.me-card .info-row:last-child { border-bottom: none; }

/* 可折叠分组行 */
.me-section + .me-section { border-top: 1px solid #efefef; }
.me-section-head {
    width: 100%; display: flex; align-items: center; gap: 12px;
    min-height: 62px; padding: 10px 14px;
    border: 0; background: #fff; font: inherit; color: inherit;
    text-align: left; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}
.me-section-head:active { background: #f2f2f2; }
.me-section-head:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.me-section-icon {
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
    display: grid; place-items: center; color: #fff;
}
.me-section-icon svg { width: 19px; height: 19px; }
.me-section-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.me-section-title { font-size: 15px; font-weight: 500; }
.me-section-summary {
    font-size: 11px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.me-section-arrow {
    width: 17px; height: 17px; flex: 0 0 auto; color: #c7c7cc;
    transition: transform .18s ease;
}
.me-section-head[aria-expanded="true"] .me-section-arrow { transform: rotate(90deg); }

/* 展开后的明细行：左侧缩进与图标对齐 */
.me-section-body { background: #fbfbfb; }
.me-section-body[hidden] { display: none; }
.me-detail-row, .me-feature-row {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px 11px 58px; border-top: 1px solid #efefef;
}
.me-detail-row { justify-content: space-between; font-size: 14px; }
.me-detail-value { color: var(--text-secondary); font-size: 13px; }
.me-detail-empty { color: #b2b2b2; }
.me-detail-action { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.me-detail-action:active { background: #f2f2f2; }
.me-detail-action .me-detail-value { display: inline-flex; align-items: center; gap: 4px; }
.me-detail-action .me-section-arrow { width: 14px; height: 14px; }
.me-feature-icon {
    width: 28px; height: 28px; border-radius: 8px; flex: 0 0 28px;
    display: grid; place-items: center; color: #fff; font-size: 14px;
}
.me-feature-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.me-feature-title { font-size: 13px; }
.me-feature-desc { font-size: 11px; color: var(--text-secondary); }

/* 退出登录：独立居中卡片 */
.me-logout-group { margin-top: 18px; }
.me-logout-group .info-row {
    justify-content: center; min-height: 52px;
    font-size: 15px; -webkit-tap-highlight-color: transparent;
}

/* 消息提醒：应用图标角标开关 */
.badge-row { min-height: 62px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.badge-row:active { background: #f7f7f7; }
.badge-row:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.badge-label { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.badge-icon {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
    background: var(--wx-green); color: #fff;
}
/* 图标右上角的小红点：说明「角标」这个概念，不是真实未读数 */
.badge-icon::after {
    content: '';
    position: absolute; top: -4px; right: -4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fa5151; border: 2px solid #fff;
}
.badge-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.badge-title { font-size: 15px; }
.badge-desc {
    font-size: 11px; line-height: 1.45; color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.badge-row.unsupported .badge-desc { color: #b0b0b0; }
.badge-switch {
    position: relative;
    width: 46px; height: 27px; flex: 0 0 46px; margin-left: 10px;
    border-radius: 999px; background: #e5e5ea;
    transition: background .18s ease;
}
.badge-switch i {
    position: absolute; top: 2px; left: 2px;
    width: 23px; height: 23px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform .18s ease;
}
.badge-row.on .badge-switch { background: var(--wx-green); }
.badge-row.on .badge-switch i { transform: translateX(19px); }
/* 锁屏推送：与角标同卡第二行，用蓝色区分「系统通知」 */
.push-row .badge-icon { background: #4a90d9; }
.push-row .badge-icon::after { display: none; }
.push-row.on .badge-switch { background: #4a90d9; }
.badge-row.busy { opacity: .55; pointer-events: none; }
/* 通知被浏览器永久阻止：用红点提示「点进去改设置」，而不是假装没开 */
.push-row.blocked .badge-icon { background: var(--danger); }
.push-row.blocked .badge-desc { color: var(--danger); }

/* ---------- 推送权限引导弹窗 ---------- */
.push-guide { display: flex; flex-direction: column; gap: 14px; }
.pg-note {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    color: #4a4a4a;
    word-break: break-word;
}
.pg-steps {
    margin: 0;
    padding-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-primary);
}
.pg-steps li { padding-left: 2px; }
.pg-steps li::marker { color: var(--wx-green); font-weight: 700; }
.pg-addr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #f5f5f7;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}
.pg-addr code {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #2b2b2e;
}
.pg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 2px; }
.pg-btn {
    appearance: none;
    border: 1px solid transparent;
    background: #f0f0f2;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1;
    padding: 11px 18px;
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.pg-btn:active { background: #e6e6e8; }
.pg-btn.primary { background: var(--wx-green); color: #fff; }
.pg-btn.primary:active { background: var(--wx-green-dark); }
@media (max-width: 480px) {
    .pg-note { font-size: 13.5px; }
    .pg-steps { font-size: 13px; padding-left: 20px; }
    .pg-actions { flex-direction: column-reverse; }
    .pg-btn { width: 100%; padding: 13px 18px; }
}

/* 安装入口 */
.install-row { align-items: center; min-height: 62px; -webkit-tap-highlight-color: transparent; }.install-label { display: inline-flex; align-items: center; gap: 10px; }
.install-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--wx-green); color: #fff; flex: 0 0 auto;
}
.install-row:active .install-icon { background: var(--wx-green-dark); }

/* 桌面 / 平板安装横幅：检测到 beforeinstallprompt 时显示 */
.install-banner {
    position: fixed;
    left: 50%; bottom: 84px;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex; align-items: center; gap: 12px;
    width: min(520px, calc(100vw - 32px));
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 34px rgba(0, 0, 0, .18);
}
.install-banner[hidden] { display: none !important; }
.install-banner-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex: 0 0 auto;
    border-radius: 10px; background: var(--wx-green); color: #fff;
    font-size: 22px; font-weight: 600; line-height: 1;
}
.install-banner-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.35; }
.install-banner-copy strong { font-size: 14px; color: var(--text-primary); }
.install-banner-copy span {
    font-size: 12px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.install-banner-btn {
    flex: 0 0 auto; border: 0; border-radius: 8px;
    padding: 8px 16px; background: var(--wx-green); color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.install-banner-btn:hover { background: var(--wx-green-dark); }
.install-banner-close {
    flex: 0 0 auto; border: 0; background: none; padding: 4px;
    color: var(--text-placeholder); font-size: 20px; line-height: 1; cursor: pointer;
}
.install-banner-close:hover { color: var(--text-secondary); }
@media (max-width: 640px) {
    .install-banner { display: none !important; }
}

/* ============ 朋友圈 ============ */
.moment-view {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    background: var(--bg-app);
    z-index: 10;
}
.moment-view[hidden] { display: none; }
.moment-header {
    height: var(--header-h); flex: 0 0 var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px; font-weight: 600;
}
.moment-list { flex: 1; overflow-y: auto; padding: 12px; }
.moment-header-actions { display: flex; align-items: center; gap: 2px; }
/* 动态上的可见范围标签（仅自己的动态展示） */
.moment-scope-tag {
    margin-left: 6px; padding: 1px 6px;
    border-radius: 9px; background: #f2f3f5;
    color: var(--text-secondary); font-size: 11px; font-weight: 400;
    vertical-align: 1px;
}
/* 可见范围设置面板 */
.scope-options { display: flex; flex-direction: column; gap: 8px; }
.scope-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 12px 14px;
    background: #fff; border: 1px solid var(--border-color);
    border-radius: 10px; cursor: pointer; text-align: left;
    font-family: inherit;
}
.scope-option.active { border-color: var(--wx-green); background: var(--wx-green-light); }
.scope-option-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.scope-option-main b { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.scope-option-main em { font-style: normal; font-size: 12px; color: var(--text-secondary); }
.scope-check { color: var(--wx-green); font-size: 15px; font-weight: 700; }
/* 发布弹窗里的「谁可以看」行 */
.composer-scope {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 10px; font-size: 13px; color: var(--text-secondary);
}
.composer-scope-btn {
    border: none; background: transparent; cursor: pointer;
    color: #576b95; font-size: 13px; font-family: inherit;
    padding: 4px 0;
}
.moment-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 220px; gap: 8px;
    color: var(--text-secondary); font-size: 14px;
}
.moment-empty-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--wx-green-light); color: var(--wx-green);
    display: grid; place-items: center; font-size: 26px;
}
.moment-item {
    display: flex; gap: 12px;
    padding: 14px; margin-bottom: 12px;
    background: #fff; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.moment-item:last-child { margin-bottom: 0; }
.moment-avatar .avatar { width: 40px; height: 40px; border-radius: 10px; font-size: 17px; }
.moment-body { flex: 1; min-width: 0; }
.moment-author { color: #576b95; font-size: 14px; font-weight: 600; }
.moment-text {
    margin-top: 6px; font-size: 14px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}
.moment-images {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px; margin-top: 8px;
}
/* 单图放大、双图/四图两列：避免一张图被挤成三分之一宽 */
.moment-images[data-count="1"] { grid-template-columns: minmax(0, 180px); }
.moment-images[data-count="2"],
.moment-images[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 150px)); }
.moment-images[data-video="1"] { grid-template-columns: minmax(0, 220px); }
.moment-images[data-video="1"] .moment-video { aspect-ratio: 4 / 3; }
.moment-img {
    width: 100%; aspect-ratio: 1; object-fit: cover;
    border-radius: 4px; cursor: pointer;
    -webkit-user-select: none; user-select: none;
    transition: filter .15s;
}
.moment-img:hover { filter: brightness(.93); }
.moment-video {
    position: relative; width: 100%; aspect-ratio: 1;
    border-radius: 4px; overflow: hidden; cursor: pointer;
    background: #000;
}
.moment-video video {
    width: 100%; height: 100%; object-fit: cover;
    display: block; pointer-events: none;
}
.moment-video .media-play,
.moment-preview .preview-play {
    position: absolute; left: 50%; top: 50%;
    width: 38px; height: 38px; margin: -19px 0 0 -19px;
    border-radius: 50%; background: rgba(0, 0, 0, .55);
    color: #fff; display: grid; place-items: center;
    font-size: 14px; padding-left: 3px; pointer-events: none;
}
.moment-video .media-dur {
    position: absolute; right: 6px; bottom: 6px;
    padding: 1px 5px; border-radius: 3px;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px;
    pointer-events: none;
}
.moment-video:focus-visible,
.moment-img:focus-visible { outline: 2px solid var(--wx-green); outline-offset: 2px; }
.moment-actions {
    display: flex; align-items: center; gap: 14px;
    margin-top: 10px;
}
.moment-time { flex: 1; font-size: 11px; color: var(--text-placeholder); }
.moment-like, .moment-del, .moment-edit {
    border: none; background: transparent; cursor: pointer;
    display: flex; align-items: center; gap: 4px;
    color: var(--text-secondary); font-size: 12px;
    padding: 4px 8px; border-radius: 5px;
}
.moment-like:hover, .moment-del:hover, .moment-edit:hover { background: #f5f5f5; }
.moment-edit { color: #576b95; }
.moment-like.liked { color: #e05252; }
.moment-like .heart { font-size: 16px; line-height: 1; }
.modal-textarea {
    width: 100%; resize: vertical;
    border: 1px solid var(--border-color); border-radius: 6px;
    padding: 10px 12px; font-size: 14px; font-family: inherit;
    outline: none; line-height: 1.6;
}
.modal-textarea:focus { border-color: var(--wx-green); }
.moment-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.moment-preview { position: relative; width: 64px; height: 64px; }
.moment-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; }
.moment-preview.is-video { width: 96px; }
.moment-preview.is-video video {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: 5px; background: #000;
}
.moment-preview.is-video .preview-play { width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 11px; }
.preview-remove {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%;
    border: none; background: rgba(0,0,0,.6); color: #fff;
    font-size: 12px; line-height: 1; cursor: pointer;
}

/* ============ 弹窗 / Toast ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-card {
    position: relative;
    width: min(460px, 100%);
    max-height: 80vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-input {
    width: 100%; padding: 11px 12px;
    border: 1px solid #ddd; border-radius: 6px;
    outline: none; margin-bottom: 12px;
}
.modal-input:focus { border-color: var(--wx-green); }
.modal-hint { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.modal-hint.warn { color: #c0392b; }
.install-steps {
    margin: 14px 0 0; padding-left: 20px;
    font-size: 13px; line-height: 2; color: var(--text-primary);
}
.contact-pick {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 6px; cursor: pointer;
}
.contact-pick:hover { background: #f5f5f5; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
    max-height: 340px;
    overflow-y: auto;
}
.emoji-item {
    width: 40px; height: 40px;
    border-radius: 6px;
    font-size: 22px;
    display: grid; place-items: center;
    transition: background .12s;
}
.emoji-item:hover { background: #f0f0f0; }

.toast {
    position: fixed;
    left: 50%; bottom: 80px;
    transform: translateX(-50%);
    background: rgba(0,0,0,.78);
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 12000;
    max-width: 80vw;
    text-align: center;
}

/* ============ 移动端 Tab 栏 ============ */
.mobile-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(56px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--border-color);
    /* 默认不显示：作者样式的 display 会覆盖 [hidden] 的 UA display:none，
       因此基础态设为 none，仅在 :not([hidden]) 时显示（见响应式区块） */
    display: none;
    grid-template-columns: repeat(4, 1fr);
    z-index: 20;
}
.mobile-tabbar .tab {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    color: #888;
    font-size: 10px;
    position: relative;
}
.mobile-tabbar .tab.active { color: var(--wx-green); }
.mobile-tabbar .tab-badge { top: 2px; right: 22%; }
/* 聊天页双保险：无论 hidden 属性状态如何，聊天视图下强制隐藏 Tab 栏 */
.main-view.show-chat ~ .mobile-tabbar { display: none !important; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
    .rail { display: none; }
}

/* 平板与手机统一走单栏滑入布局：761–900px 也保留底部 Tabbar，避免导航断层 */
@media (max-width: 900px) {
    :root { --header-h: 54px; }
    .main-view { display: block; position: relative; }
    .panel-list, .panel-chat, .panel-secondary {
        position: absolute; inset: 0;
        width: 100%; flex: none;
        border: none;
        /* 必须清掉 .panel 的 height:100%：absolute 下 top 与 height 同时生效时 bottom 会被忽略，
           面板仍占满整屏，底部 Tab 栏就压在内容上面（「我」页退出登录被遮挡即由此产生） */
        height: auto;
    }
    .panel-list { z-index: 3; }
    .panel-chat { z-index: 5; }
    .panel-secondary { z-index: 7; }
    .main-view.show-chat .panel-list { transform: translateX(-100%); }
    .panel-list, .panel-chat, .panel-secondary { transition: transform .22s ease; }
    .panel-chat { transform: translateX(100%); }
    .main-view.show-chat .panel-chat { transform: translateX(0); }
    .panel-secondary { transform: translateX(100%); }
    .main-view.show-secondary .panel-secondary { transform: translateX(0); }
    .back-btn { display: grid; }
    .mobile-tabbar:not([hidden]) { display: grid; }
    .main-view.has-tabbar .panel-list,
    .main-view.has-tabbar .panel-chat,
    .main-view.has-tabbar .panel-secondary { bottom: calc(56px + var(--safe-bottom)); }
    /* 「我」页最后一张卡（退出登录）与面板底边之间的留白 */
    .main-view.has-tabbar .me-page { padding-bottom: 28px; }
    .main-view.has-tabbar .contacts-page { padding-bottom: 28px; }
    .message-list { padding: 14px 12px; }
    .chat-active.protocol-open .message-list { padding-bottom: calc(14px + var(--protocol-h)); }
    .msg-body { max-width: 78%; }
    .composer-input-row { padding-bottom: calc(12px + var(--safe-bottom)); }
    .composer-hint { display: none; }
    .chat-subtitle { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* 桌面宽屏：二级面板内容限制在 720px 内居中，标题与卡片左缘对齐 */
@media (min-width: 901px) {
    .panel-secondary .list-header {
        padding-left: max(16px, calc((100% - 720px) / 2 + 12px));
    }
    .me-page, .contacts-page {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* 桌面：切到通讯录 / 发现 / 我时，用二级面板接管主区，聊天窗口不再钉在中间 */
@media (min-width: 901px) {
    .mobile-tabbar { display: none !important; }
    .panel-secondary { display: none; }
    .main-view.show-secondary .panel-secondary {
        display: flex;
        flex: 1;
        width: auto;
    }
    .main-view.show-secondary .panel-list,
    .main-view.show-secondary .panel-chat { display: none; }
}

/* 减小动画（无障碍） */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============ 个人资料 / 账号安全 ============ */
.auth-aux { display: flex; justify-content: flex-end; margin: -4px 0 14px; }
.auth-link {
    padding: 2px; border: 0; background: none; cursor: pointer;
    color: var(--wx-green); font-size: 13px;
    -webkit-tap-highlight-color: transparent;
}
.auth-link:active { opacity: .65; }

.profile-section-title {
    margin: 22px 0 6px;
    font-size: 12px; font-weight: 600;
    color: var(--text-secondary); letter-spacing: .04em;
}
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 430px) { .profile-grid { grid-template-columns: 1fr; } }

select.modal-input {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8.2 2.2 4.4l.8-.8L6 6.6l3-3 .8.8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
}
.profile-switch-row { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 8px; }
.profile-switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary); }
.profile-switch input { width: 17px; height: 17px; accent-color: var(--wx-green); margin: 0; }

.login-log-list { margin-top: 4px; }
.login-log-row { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.login-log-row:last-child { border-bottom: none; }
.login-log-main { font-size: 14px; color: var(--text-primary); }
.login-log-meta { margin-top: 3px; font-size: 12px; color: var(--text-secondary); }

.profile-remark-tag {
    display: inline-block; margin-left: 6px; padding: 1px 6px;
    border-radius: 4px; background: #eef6f1; color: var(--wx-green);
    font-size: 11px; vertical-align: middle;
}
.contact-group-tag {
    flex: 0 0 auto; padding: 1px 5px; border-radius: 4px;
    background: #f0f2f5; color: var(--text-secondary);
    font-size: 10.5px; line-height: 1.5;
    max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}


/* ---------- 好友握手（通讯录权限分离） --------------------------------- */
/* 非好友会话提示条：固定在聊天头部下方，不占消息区滚动 */
.chat-friend-hint {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    background: #fff7e6;
    border-bottom: 1px solid #ffe1b3;
    font-size: 12px; color: #ad6800;
    flex: 0 0 auto;
}
.chat-friend-hint span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-friend-hint .link-btn { color: #d46b08; font-weight: 600; white-space: nowrap; }
.chat-friend-hint .link-btn[disabled] { color: var(--text-placeholder); cursor: default; }

/* 通讯录顶部入口：新的朋友 / 添加朋友，同卡两行 */
.contacts-actions {
    margin-top: 10px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    overflow: hidden;
}
.contacts-action {
    display: flex; align-items: center; gap: 12px;
    min-height: 56px; padding: 10px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s;
}
.contacts-action + .contacts-action { border-top: 1px solid #f4f4f5; }
.contacts-action:hover { background: #fafafa; }
.contacts-action:active { background: #f2f2f3; }
.contacts-action:focus-visible { outline: 2px solid var(--wx-green); outline-offset: -2px; }
.contacts-action-icon {
    width: 34px; height: 34px; border-radius: 9px;
    display: grid; place-items: center;
    color: #fff; flex: 0 0 34px;
}
.contacts-action-icon.friends { background: #fa9d3b; }
.contacts-action-icon.add { background: var(--wx-green); }
.contacts-action-title { flex: 1; font-size: 14.5px; color: var(--text-primary); }
.contacts-action-arrow { width: 15px; height: 15px; color: #ccc; flex: 0 0 15px; }
.contacts-entry-badge {
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--danger, #fa5151);
    color: #fff; font-size: 11px; line-height: 18px; text-align: center;
    flex: 0 0 auto;
}
.contacts-entry-badge[hidden] { display: none; }
/* 新的朋友：申请行 */
.friend-req { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.friend-req + .friend-req { border-top: 1px solid var(--border-light, #f0f0f0); }
.friend-req-info { flex: 1; min-width: 0; }
.friend-req-name { font-size: 14px; color: var(--text-primary); }
.friend-req-msg { font-size: 12px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-req-email { font-size: 11px; color: var(--text-placeholder); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-req-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.friend-req-wait { font-size: 12px; color: var(--text-placeholder); white-space: nowrap; }
.btn-mini {
    border: none; border-radius: 7px; padding: 5px 11px;
    font-size: 12px; background: #f2f2f3; color: var(--text-primary);
    cursor: pointer; white-space: nowrap;
}
.btn-mini.primary { background: var(--wx-green); color: #fff; }
.btn-mini[disabled] { opacity: .55; cursor: default; }

/* 添加朋友：搜索结果卡 */
.add-friend-card {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; margin-bottom: 10px;
    background: #f7f7f8; border-radius: 12px;
}
.add-friend-info { flex: 1; min-width: 0; }
.add-friend-name { font-size: 14px; color: var(--text-primary); }
.add-friend-email { font-size: 12px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 媒体查看器（图片 / 视频 / 音乐） ===== */
.media-viewer {
    position: fixed; inset: 0; z-index: 300;
    display: flex; flex-direction: column;
    background: #080808;
    color: #fff;
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.media-viewer[hidden] { display: none; }
.media-viewer:not([hidden]) { animation: mvFadeIn .16s ease-out; }
@keyframes mvFadeIn { from { opacity: 0; } to { opacity: 1; } }
/* 预览时隐藏安装横幅，避免遮挡播放控制 */
html.mv-open #install-banner { display: none !important; }
.mv-bar {
    display: flex; align-items: center; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    flex: 0 0 auto;
}
.mv-title {
    flex: 1; min-width: 0; text-align: center;
    font-size: 13px; color: rgba(255, 255, 255, .72);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mv-tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.mv-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: rgba(255, 255, 255, .12); color: #fff;
    display: grid; place-items: center; cursor: pointer;
    transition: background .15s;
}
.mv-btn:hover { background: rgba(255, 255, 255, .24); }
.mv-counter { font-size: 12px; color: rgba(255, 255, 255, .7); }
.mv-stage { flex: 1; position: relative; overflow: hidden; }
.mv-canvas {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; touch-action: none;
}
.mv-img {
    max-width: 100%; max-height: 100%;
    transform-origin: center center;
    will-change: transform;
    cursor: zoom-in; -webkit-user-drag: none;
}
.mv-img.zoomed { cursor: grab; }
.mv-img.dragging { cursor: grabbing; }
.mv-video {
    max-width: 100%; max-height: 100%;
    background: #000; border-radius: 6px;
    outline: none;
}
.mv-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: rgba(255, 255, 255, .13); color: #fff;
    font-size: 26px; line-height: 1; padding-bottom: 5px;
    display: grid; place-items: center; cursor: pointer;
    z-index: 2;
}
.mv-nav:hover { background: rgba(255, 255, 255, .26); }
.mv-nav.prev { left: 12px; }
.mv-nav.next { right: 12px; }
.mv-nav[hidden] { display: none; }
.mv-footer {
    flex: 0 0 auto;
    padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.mv-footer:empty { padding-bottom: 8px; }
.mv-dots { display: flex; gap: 6px; }
.mv-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .28); }
.mv-dots i.on { background: #fff; }
.mv-dots[hidden] { display: none; }
.mv-audio {
    width: min(520px, 100%);
    display: flex; align-items: center; gap: 12px;
    background: rgba(255, 255, 255, .08);
    border-radius: 14px; padding: 12px 14px;
}
.mv-audio[hidden] { display: none; }
.mv-audio-btn {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 50%; border: none; cursor: pointer;
    background: var(--wx-green); color: #fff; font-size: 14px;
}
.mv-audio-main { flex: 1; min-width: 0; }
.mv-audio-name {
    font-size: 13px; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mv-audio-track {
    position: relative; height: 4px; margin-top: 9px;
    border-radius: 2px; background: rgba(255, 255, 255, .18);
    cursor: pointer;
}
.mv-audio-track i {
    position: absolute; left: 0; top: 0; bottom: 0; width: 0;
    background: var(--wx-green); border-radius: 2px;
}
.mv-audio-track b {
    position: absolute; top: 50%; left: 0;
    width: 10px; height: 10px; margin: -5px 0 0 -5px;
    border-radius: 50%; background: #fff;
}
.mv-audio-time { flex: 0 0 auto; font-size: 11px; color: rgba(255, 255, 255, .62); }
.mv-audio-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.mv-audio-cover {
    width: 148px; height: 148px; border-radius: 50%;
    background: radial-gradient(circle at 32% 30%, #35d07f, #0a8f45);
    display: grid; place-items: center;
    font-size: 50px; color: #fff;
    box-shadow: 0 12px 44px rgba(7, 193, 96, .35);
    animation: mvSpin 9s linear infinite;
    animation-play-state: paused;
}
.mv-audio-cover.spinning { animation-play-state: running; }
@keyframes mvSpin { to { transform: rotate(360deg); } }
.mv-audio-stage .mv-audio-title {
    max-width: 72vw; font-size: 13px; color: rgba(255, 255, 255, .82);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.mv-open, html.mv-open body { overflow: hidden; }

@media (max-width: 640px) {
    .mv-nav { width: 38px; height: 38px; font-size: 22px; }
    .mv-nav.prev { left: 6px; }
    .mv-nav.next { right: 6px; }
    .mv-audio-cover { width: 120px; height: 120px; font-size: 40px; }
    .bubble.video { width: 190px; }
    .bubble.video video { height: 114px; }
}

/* 窄屏：收纳面板 5 个入口一行排开，避免「拍照」掉到第二行 */
@media (max-width: 480px) {
    .more-media-row { gap: 10px; justify-content: space-between; }
    .more-media { padding: 4px 2px; }
    .more-media-icon { width: 44px; height: 44px; border-radius: 9px; }
}

/* ============ 管理后台 ============ */
/* 入口：桌面侧栏按钮 + 移动 Tab（仅管理员可见，由 app.js syncAdminEntry 控制 hidden） */
.mobile-tabbar.admin-enabled { grid-template-columns: repeat(5, 1fr); }

.admin-view {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f2f3f5;
    overflow: hidden;
}
.admin-view[hidden] { display: none !important; }
/* 后台打开时三块业务面板整体让位（桌面与移动端一致） */
.main-view.show-admin .panel-list,
.main-view.show-admin .panel-chat,
.main-view.show-admin .panel-secondary { display: none !important; }

.adm-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}
.adm-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.adm-logo {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #07c160, #0aa054);
    color: #fff;
    display: grid; place-items: center;
}
.adm-title { font-size: 16px; font-weight: 600; color: #1a1a1a; line-height: 1.3; }
.adm-sub { font-size: 12px; color: #8a8a8a; line-height: 1.4; margin-top: 2px; }
.adm-back {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    background: #f2f3f5;
    color: #4a4a4a;
    font-size: 13px;
}
.adm-back:hover { background: #e8e9eb; }

.adm-tabs {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px 14px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tab {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13.5px;
    color: #666;
    white-space: nowrap;
}
.adm-tab:hover { background: #f4f4f5; }
.adm-tab.active { background: rgba(7, 193, 96, .12); color: var(--wx-green-dark, #0a8f4d); font-weight: 600; }

.adm-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
}
.adm-wrap {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 12px;
}

/* 概览统计卡 */
.adm-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
}
.adm-stat {
    background: #fff;
    border-radius: 12px;
    padding: 13px 14px;
    border: 1px solid #ececee;
}
.adm-stat.green { background: linear-gradient(135deg, #effaf3, #fff); border-color: #d6f0e0; }
.adm-stat-value { font-size: 22px; font-weight: 700; color: #1a1a1a; line-height: 1.2; font-variant-numeric: tabular-nums; }
.adm-stat-label { font-size: 12.5px; color: #666; margin-top: 4px; }
.adm-stat-hint { font-size: 11.5px; color: #9a9a9a; margin-top: 3px; }

.adm-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #ececee;
    padding: 14px;
}
.adm-card-title {
    margin: 0 0 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.adm-card-extra { font-size: 11.5px; font-weight: 400; color: #9a9a9a; }
.adm-kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 13.5px;
    color: #555;
    border-bottom: 1px dashed #f0f0f2;
}
.adm-kv-row:last-child { border-bottom: none; padding-bottom: 0; }
.adm-kv-row > span:last-child { color: #1f1f1f; font-weight: 500; }
.wx-danger { color: var(--danger) !important; }

.adm-bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 12.5px; color: #555; }
.adm-bar-label { flex: 0 0 72px; color: #666; }
.adm-bar { flex: 1; height: 6px; border-radius: 3px; background: #f0f0f2; overflow: hidden; }
.adm-bar i { display: block; height: 100%; background: var(--wx-green); border-radius: 3px; }
.adm-bar-value { flex: 0 0 76px; text-align: right; color: #888; font-variant-numeric: tabular-nums; }

/* 工具条 */
.adm-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-search {
    flex: 1 1 220px;
    display: flex; align-items: center; gap: 7px;
    height: 38px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid #e6e6e8;
    border-radius: 10px;
    color: #9a9a9a;
}
.adm-search:focus-within { border-color: #bfe9d2; box-shadow: 0 0 0 3px rgba(7, 193, 96, .08); }
.adm-search input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; font-size: 13.5px; color: #1f1f1f; }
.adm-select, .adm-input {
    height: 38px;
    padding: 0 10px;
    border: 1px solid #e6e6e8;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    color: #333;
}
.adm-select:disabled, .adm-input:disabled, .adm-textarea:disabled { background: #f7f7f8; color: #9a9a9a; }
.adm-textarea {
    width: 100%;
    min-height: 72px;
    padding: 9px 11px;
    border: 1px solid #e6e6e8;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.6;
    color: #1f1f1f;
    resize: vertical;
    font-family: inherit;
}
.adm-textarea:focus, .adm-input:focus, .adm-select:focus { outline: none; border-color: #bfe9d2; box-shadow: 0 0 0 3px rgba(7, 193, 96, .08); }

/* 用户列表 */
.adm-list-card { padding: 4px 6px; }
.adm-user-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 9px;
    text-align: left;
    border-bottom: 1px solid #f4f4f6;
}
.adm-user-row:last-child { border-bottom: none; }
.adm-user-row:hover { background: #f8f9fa; }
.adm-avatar { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 8px; overflow: hidden; }
.adm-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.adm-avatar.lg { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 12px; font-size: 20px; }
.adm-user-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.adm-user-name { font-size: 14px; font-weight: 500; color: #1f1f1f; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user-short { font-size: 11px; color: #9a9a9a; font-weight: 400; }
.adm-user-mail { font-size: 12px; color: #8a8a8a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user-tags { display: flex; gap: 5px; flex: 0 0 auto; }
.adm-user-time { flex: 0 0 auto; font-size: 11.5px; color: #aaa; min-width: 44px; text-align: right; }
.adm-chevron { width: 16px; height: 16px; flex: 0 0 16px; color: #c8c8cc; }
.adm-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 17px;
    white-space: nowrap;
}
.adm-chip.brand { background: rgba(7, 193, 96, .12); color: #0a8f4d; }
.adm-chip.ok { background: #eef7f1; color: #13894a; }
.adm-chip.danger { background: #fdecec; color: #c0392b; }
.adm-chip.plain { background: #f2f3f5; color: #777; }

.adm-empty { padding: 28px 12px; text-align: center; color: #9a9a9a; font-size: 13px; }
.adm-pager {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    font-size: 12.5px; color: #777;
}
.adm-pager button {
    height: 32px; padding: 0 14px;
    border-radius: 999px; background: #fff; border: 1px solid #e6e6e8;
    color: #444; font-size: 12.5px;
}
.adm-pager button:disabled { opacity: .45; }
.adm-pager button:not(:disabled):hover { border-color: #bfe9d2; color: var(--wx-green-dark, #0a8f4d); }

/* 内容管理 */
.adm-seg {
    display: inline-flex;
    align-self: flex-start;
    padding: 3px;
    background: #e9eaec;
    border-radius: 10px;
    gap: 2px;
}
.adm-seg button {
    height: 30px; padding: 0 16px;
    border-radius: 8px;
    font-size: 13px; color: #555;
}
.adm-seg button.active { background: #fff; color: #1a1a1a; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.adm-msg-row {
    display: flex; align-items: center; gap: 14px;
    padding: 9px 8px;
    border-bottom: 1px solid #f4f4f6;
}
.adm-msg-row:last-child { border-bottom: none; }
.adm-msg-main { flex: 1; min-width: 0; }
.adm-msg-peers { font-size: 13px; color: #2b2b2b; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-msg-mail { font-size: 11.5px; color: #9a9a9a; font-weight: 400; margin-left: 6px; }
.adm-arrow { color: #b0b0b0; margin: 0 2px; }
.adm-msg-text { font-size: 13px; color: #555; margin-top: 3px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.adm-msg-meta { font-size: 11.5px; color: #9a9a9a; margin-top: 4px; }
.adm-msg-side { flex: 0 0 auto; display: flex; flex-direction: row; align-items: center; gap: 10px; }
.adm-msg-time { font-size: 11px; color: #a5a5a5; }
.adm-msg-seq { font-size: 10.5px; color: #b8b8b8; font-variant-numeric: tabular-nums; }

.adm-btn {
    height: 32px; padding: 0 13px;
    border-radius: 8px;
    background: #f2f3f5; color: #444;
    font-size: 12.5px;
    border: 1px solid transparent;
}
.adm-btn:hover { background: #e8e9eb; }
.adm-btn.primary { background: var(--wx-green); color: #fff; }
.adm-btn.primary:hover { background: #06ad56; }
.adm-btn.danger { background: #fdecec; color: #c0392b; }
.adm-btn.danger:hover { background: #fbdcdc; }
.adm-btn.small { height: 26px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; }
.adm-btn:disabled { opacity: .5; pointer-events: none; }
.adm-btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 设置 */
.adm-toggle-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid #f4f4f6;
    cursor: pointer;
}
.adm-toggle-row:last-of-type { border-bottom: none; }
.adm-toggle-text { flex: 1; min-width: 0; }
.adm-toggle-title { font-size: 14px; color: #1f1f1f; }
.adm-toggle-desc { font-size: 12px; color: #8a8a8a; margin-top: 3px; line-height: 1.5; }
.adm-toggle-row.on .badge-switch { background: var(--wx-green); }
.adm-toggle-row.on .badge-switch i { transform: translateX(19px); }
.adm-field { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 13.5px; color: #555; }
.adm-field.column { flex-direction: column; align-items: stretch; gap: 7px; }
.adm-note { font-size: 12px; color: #9a9a9a; line-height: 1.5; }
.adm-alert {
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff7e6;
    color: #8a5a00;
    font-size: 12.5px;
    line-height: 1.6;
}
.adm-alert.brand { background: #effaf3; color: #146c43; }
.adm-alert code {
    display: inline-block;
    margin: 0 6px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px dashed #9bd8b4;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: #0a7a44;
    user-select: all;
}

/* 日志 */
.adm-log-list { max-height: 320px; overflow-y: auto; }
.adm-log-row {
    display: grid;
    grid-template-columns: 118px minmax(140px, 190px) 128px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 0;
    font-size: 12px;
    color: #555;
    border-bottom: 1px dashed #f2f2f4;
}
.adm-log-row:last-child { border-bottom: none; }
.adm-log-time { color: #9a9a9a; font-variant-numeric: tabular-nums; }
.adm-log-actor { color: #2b2b2b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-log-action { color: #0a8f4d; white-space: nowrap; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.adm-log-target { color: #777; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-pre {
    margin: 0;
    max-height: 300px;
    overflow: auto;
    padding: 10px;
    border-radius: 9px;
    background: #1f2329;
    color: #d7dae0;
    font-size: 11.5px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 用户详情抽屉（复用 #modal） */
.adm-detail-head { display: flex; align-items: center; gap: 12px; }
.adm-detail-name { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.adm-detail-mail { font-size: 12.5px; color: #8a8a8a; margin-top: 3px; word-break: break-all; }
.adm-detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.adm-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin: 14px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}
.adm-detail-grid > div { display: flex; flex-direction: column; gap: 2px; }
.adm-detail-grid span { font-size: 11.5px; color: #9a9a9a; }
.adm-detail-grid b { font-size: 13px; font-weight: 500; color: #2b2b2b; word-break: break-all; }
.adm-detail-actions { display: flex; flex-direction: column; gap: 8px; }

/* 登录页公告 */
.auth-notice { margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.auth-notice-line {
    padding: 9px 12px;
    border-radius: 9px;
    background: #effaf3;
    color: #146c43;
    font-size: 12.5px;
    line-height: 1.6;
    word-break: break-word;
}
.auth-notice-line strong { font-weight: 600; }

/* 移动端：后台视图铺满主区，并给底部 Tab 栏让位 */
@media (max-width: 900px) {
    .admin-view { position: absolute; inset: 0; z-index: 9; }
    .main-view.has-tabbar .admin-view { bottom: calc(56px + var(--safe-bottom)); }
    .adm-head { padding: 10px 14px; }
    .adm-body { padding: 12px; }
    /* 手机上搜索框独占一行，两个筛选下拉各占一半 */
    .adm-toolbar .adm-search { flex: 1 1 100%; }
    .adm-toolbar .adm-select { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .adm-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .adm-user-time { display: none; }
    .adm-user-tags .adm-chip.ok, .adm-user-tags .adm-chip.plain { display: none; }
    .adm-msg-row { gap: 8px; align-items: flex-start; }
    .adm-msg-side { flex-direction: column; align-items: flex-end; gap: 5px; }
    .adm-msg-text { -webkit-line-clamp: 3; }
    .adm-log-row { grid-template-columns: 96px 1fr; }
    .adm-log-action, .adm-log-target { grid-column: 2; }
    .adm-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 400px) {
    .adm-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .adm-stat { padding: 11px; }
    .adm-stat-value { font-size: 19px; }
}

/* ============================================================
   会话操作：清空 / 撤回 / 拉黑 / 上下文菜单
   ============================================================ */

/* 拉黑提示条：与「非好友提示」同构，用红色区分 */
.chat-block-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    background: #fff1f0;
    border-bottom: 1px solid #ffd6d3;
    font-size: 12px; color: #c0392b;
    flex: 0 0 auto;
}
.chat-block-bar span { flex: 1; min-width: 0; }
.chat-block-bar .link-btn { color: #c0392b; font-weight: 600; white-space: nowrap; }
.chat-block-bar.by-peer { background: #fafafa; border-bottom-color: #ececec; color: var(--text-secondary); }

/* 会话列表的「已拉黑」标记 */
.conv-blocked-chip {
    display: inline-block; margin-left: 6px; padding: 0 5px;
    border-radius: 3px; background: #ffecec; color: #c0392b;
    font-size: 10px; font-weight: 600; line-height: 16px;
    vertical-align: 1px;
}

/* 撤回后的气泡：灰底灰字，不能再点开媒体 */
.bubble.recalled {
    background: #ececec !important;
    color: var(--text-secondary);
    padding: 6px 11px;
    font-size: 12px;
    box-shadow: none;
    cursor: default;
}
.bubble.recalled .recalled-text { user-select: none; }
.msg-meta .msg-state.recalled { color: var(--text-placeholder); }

/* 输入区禁用态 */
.composer textarea:disabled { background: #f7f7f7; cursor: not-allowed; }
.btn-send:disabled, .btn-more:disabled { opacity: .45; cursor: not-allowed; }

/* 浮动上下文菜单 */
.ctx-menu {
    position: fixed; z-index: 1200;
    min-width: 148px; padding: 5px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 26px rgba(0, 0, 0, .16), 0 0 0 1px rgba(0, 0, 0, .04);
}
.ctx-item {
    display: block; width: 100%;
    padding: 9px 12px;
    border-radius: 7px;
    text-align: left; font-size: 13.5px;
    color: var(--text-primary);
    white-space: nowrap;
}
.ctx-item:hover { background: #f2f2f2; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: #fff1f0; }
.ctx-sep { height: 1px; margin: 4px 6px; background: #eee; }

/* 确认框正文 */
.confirm-text { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--text-secondary); }

/* 危险按钮（确认框 / 详情页操作） */
.btn-danger {
    flex: 1; padding: 11px 18px;
    border-radius: 8px;
    background: var(--danger); color: #fff;
    font-size: 14px; font-weight: 600;
}
.btn-danger:hover { background: #e04848; }
.btn-danger:active { transform: scale(.985); }

/* 会话详情里的整行动作 */
.info-action {
    display: block; width: 100%; padding: 13px 16px;
    text-align: left; font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}
.info-action:last-child { border-bottom: none; }
.info-action:hover { background: #f7f7f7; }
.info-action.danger { color: var(--danger); }

@media (max-width: 900px) {
    .ctx-menu { min-width: 160px; }
    .ctx-item { padding: 11px 14px; font-size: 15px; }
}
.ctx-item:disabled { color: var(--text-placeholder); cursor: default; }
.ctx-item:disabled:hover { background: transparent; }

/* 黑名单管理（「我」→ 黑名单） */
.block-list { max-height: 52vh; overflow-y: auto; margin: 0 -4px; }
.block-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
}
.block-row:last-child { border-bottom: none; }
.block-row .avatar { width: 38px; height: 38px; flex: 0 0 38px; font-size: 15px; }
.block-info { flex: 1; min-width: 0; }
.block-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-email { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-row .btn-secondary { flex: 0 0 auto; padding: 6px 14px; font-size: 13px; }

/* ============================================================
   交互过渡层（v1.7.0）
   原则：只做位移与透明度，全部 ≤ 220ms；不改变布局尺寸，
   避免过渡结束瞬间的二次重排。prefers-reduced-motion 由
   文件中的全局规则统一降级为 0.01ms。
   ============================================================ */
:root {
    --ease-out: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- 二级面板切页入场 ---------- */
@keyframes viewIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
@keyframes viewInBack {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: none; }
}
.view-anim { animation: viewIn .18s var(--ease-out) both; }
.view-anim-back { animation: viewInBack .18s var(--ease-out) both; }

/* ---------- 列表逐条入场（仅首屏，避免轮询刷新时反复动画） ---------- */
@keyframes itemIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.stagger > * {
    animation: itemIn .2s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 16ms);
}

/* ---------- 骨架屏 ---------- */
.sk-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 6px; flex: 0 0 40px; }
.sk-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 10px; border-radius: 5px; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w85 { width: 85%; }
.sk-avatar, .sk-line {
    background: linear-gradient(90deg, #ededed 25%, #f7f7f7 37%, #ededed 63%);
    background-size: 400% 100%;
    animation: skShimmer 1.2s ease infinite;
}
@keyframes skShimmer {
    from { background-position: 100% 0; }
    to   { background-position: 0 0; }
}
/* 消息区气泡骨架 */
.sk-msg { display: flex; gap: 10px; padding: 8px 16px; align-items: flex-start; }
.sk-msg.out { flex-direction: row-reverse; }
.sk-bubble { height: 34px; border-radius: 6px; flex: 0 1 auto; width: 42%; }
.sk-msg.out .sk-bubble { width: 34%; }

/* ---------- 顶部加载进度条 ---------- */
#nav-progress {
    position: fixed; top: 0; left: 0; z-index: 900;
    height: 2px; width: 0; opacity: 0;
    background: var(--wx-green);
    box-shadow: 0 0 6px rgba(7, 193, 96, .5);
    transition: width .2s ease, opacity .25s ease;
    pointer-events: none;
}
#nav-progress.active { opacity: 1; }

/* ---------- 按钮忙碌态：保持宽度，中心转圈 ---------- */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading > * { visibility: hidden; }
.btn-loading::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: btnSpin .62s linear infinite;
}
.btn-secondary.btn-loading::after, .icon-btn.btn-loading::after {
    border-color: rgba(0, 0, 0, .12);
    border-top-color: var(--text-secondary);
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* ---------- 图片气泡占位与淡入 ---------- */
.bubble.image img { opacity: 0; transition: opacity .22s ease; }
.bubble.image img.is-loaded { opacity: 1; }

/* ---------- 弹窗 ---------- */
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal:not([hidden]) .modal-backdrop { animation: backdropIn .16s ease both; }
.modal:not([hidden]) .modal-card { animation: modalIn .2s var(--ease-out) both; }

/* ---------- 底部 Tab 指示条 ---------- */
.mobile-tabbar .tab::after {
    content: ""; position: absolute; bottom: 3px; left: 50%;
    width: 16px; height: 2px; border-radius: 2px;
    background: var(--wx-green);
    transform: translateX(-50%) scaleX(0);
    opacity: 0;
    transition: transform .2s var(--ease-out), opacity .2s ease;
}
.mobile-tabbar .tab.active::after { transform: translateX(-50%) scaleX(1); opacity: 1; }

/* ---------- 新消息入场 ---------- */
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.msg-row.is-new { animation: msgIn .18s var(--ease-out) both; }

/* ---------- 回到最新浮层 ---------- */
#btn-jump-latest { transition: opacity .18s ease, transform .18s var(--ease-out); }

/* ---------- 加载更早消息时的顶部提示 ---------- */
#message-list.loading-older::before {
    content: "正在加载更早的消息…";
    display: block; text-align: center;
    padding: 10px 0 6px;
    font-size: 12px; color: var(--text-placeholder);
}
