/* RaysCHAT · Apple 液态玻璃风格
   纯 CSS，无第三方字体/图标库；模糊只用在浮层与卡片，保证低配设备顺滑 */

:root {
    --bg: #f3f5f8;
    --bg-2: #eef2f7;
    --text: #101114;
    --text-2: #4b4f57;
    --muted: #8b8f97;
    --line: rgba(16, 24, 40, .07);
    --blue: #0a84ff;
    --blue-deep: #0071e3;
    --green: #30d158;
    --red: #ff3b30;
    --glass: rgba(255, 255, 255, .64);
    --glass-strong: rgba(255, 255, 255, .84);
    --glass-line: rgba(255, 255, 255, .8);
    --blur: saturate(185%) blur(28px);
    --r-xl: 26px;
    --r-l: 20px;
    --r-m: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 18px 40px -26px rgba(16, 24, 40, .45);
    --shadow-soft: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 20px -14px rgba(16, 24, 40, .3);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0; height: 100%;
    /* 页面本身永不滚动：滚动只发生在 .main / .chat-body 里，
       否则整个页面跟着手指走（顶栏、dock 一起被拖着弹来弹去） */
    overflow: hidden;
    overscroll-behavior: none;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue",
        "Microsoft YaHei", system-ui, sans-serif;
    font-size: 15px; line-height: 1.5; letter-spacing: -.011em;
    -webkit-font-smoothing: antialiased;
}

/* 玻璃要有东西可折射：铺一层极淡的天空蓝环境光 */
html { background: var(--bg); }
body { background: transparent; }
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(46% 30% at 8% 0%, rgba(120, 190, 255, .30), transparent 62%),
        radial-gradient(38% 26% at 96% 4%, rgba(160, 150, 255, .18), transparent 60%),
        radial-gradient(52% 34% at 88% 100%, rgba(120, 225, 205, .16), transparent 64%),
        linear-gradient(180deg, #f7fbff 0%, #eff3f8 46%, #eef1f6 100%);
}

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
img, video { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 0; height: 0; }

.hidden { display: none !important; }

/* ---------------- 通用玻璃件 ---------------- */
.glass {
    background: var(--glass);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: .5px solid var(--glass-line);
    box-shadow: var(--shadow), inset 0 .5px 0 rgba(255, 255, 255, .95);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 980px;
    background: rgba(255, 255, 255, .9); color: var(--text);
    font-size: 14px; font-weight: 600;
    border: .5px solid rgba(16, 24, 40, .06);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
    transition: transform .14s cubic-bezier(.2, .9, .3, 1), background .16s ease;
}
.btn:active { transform: scale(.965); }
.btn.primary {
    background: linear-gradient(180deg, #3aa0ff, var(--blue-deep));
    color: #fff; border-color: rgba(0, 90, 190, .4);
    box-shadow: 0 1px 2px rgba(0, 80, 180, .25), 0 10px 22px -12px rgba(0, 113, 227, .8);
}
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.field {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, .72);
    border: .5px solid var(--line);
    border-radius: var(--r-m);
    padding: 11px 14px;
    transition: border-color .16s ease, background .16s ease;
}
.field:focus-within { border-color: rgba(10, 132, 255, .55); background: #fff; }
.field input {
    flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
    font-size: 15px; padding: 0;
}
.field .tag { font-size: 12px; color: var(--muted); }

/* ---------------- 登录 ---------------- */
#auth {
    position: fixed; inset: 0; z-index: 80;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    padding-top: calc(var(--safe-top) + 24px);
    padding-bottom: calc(var(--safe-bottom) + 24px);
    /* 不透明底色：把后面的主界面完全盖住 */
    background: var(--bg);
}
html[data-theme="dark"] #auth { background: #0a0c11; }
.auth-card {
    width: min(380px, 100%);
    padding: 30px 24px 24px;
    border-radius: var(--r-xl);
    background: var(--glass-strong);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: .5px solid var(--glass-line);
    box-shadow: 0 2px 4px rgba(16, 24, 40, .04), 0 40px 80px -40px rgba(16, 24, 40, .5),
        inset 0 1px 0 rgba(255, 255, 255, .95);
}
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px;
    display: grid; place-items: center;
    background: linear-gradient(160deg, #2c5cff 0%, #0a2a86 100%);
    box-shadow: 0 10px 24px -12px rgba(12, 36, 120, .8), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.auth-logo svg { width: 34px; height: 34px; }
.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: -.6px; text-align: center; font-weight: 700; }
.auth-card .sub { margin: 6px 0 22px; text-align: center; font-size: 12.5px; color: var(--muted); }
.auth-card .field { margin-bottom: 10px; }
.auth-card .btn { margin-top: 8px; }
.auth-switch { margin-top: 14px; text-align: center; font-size: 13px; color: var(--text-2); }
.auth-switch b { color: var(--blue); font-weight: 600; cursor: pointer; }
.auth-err {
    margin-top: 10px; font-size: 12.5px; color: var(--red); text-align: center; min-height: 18px;
}

/* ---------------- 主框架 ---------------- */
#app { height: 100%; min-height: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    padding: calc(var(--safe-top) + 8px) 16px 9px 24px;
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(180deg, rgba(247, 251, 255, .94), rgba(247, 251, 255, .58) 72%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
/* 标题绝对居中，两侧各放东西，视觉重心才稳 */
.topbar .tb-center {
    position: absolute; left: 50%; transform: translateX(-50%);
    text-align: center; pointer-events: none; max-width: 46%;
}
.topbar h1 { margin: 0; font-size: 17.5px; font-weight: 800; letter-spacing: 3.5px; line-height: 1.2; }
.topbar .sub { margin-top: 1px; font-size: 10px; letter-spacing: .1em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb-avatar {
    width: 34px; height: 34px; flex: none; padding: 0;
    border-radius: 50%; overflow: hidden;
    border: .5px solid rgba(16, 24, 40, .08);
    box-shadow: 0 2px 8px -4px rgba(16, 24, 40, .55);
    transition: transform .14s ease;
}
.topbar .tb-avatar:active { transform: scale(.93); }
.topbar .tb-avatar .avatar { width: 100%; height: 100%; border-radius: 50%; font-size: 15px; box-shadow: none; }
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.topbar .icon-btn {
    width: 32px; height: 32px;
    background: rgba(255, 255, 255, .68);
    box-shadow: none;
}
.topbar .icon-btn svg { width: 16.5px; height: 16.5px; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .78);
    border: .5px solid rgba(16, 24, 40, .06);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
    color: var(--text-2);
    transition: transform .14s ease, background .16s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 18px; height: 18px; }

.main {
    flex: 1; min-height: 0;
    /* 列表自己滚，页面不动 */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 4px 16px calc(112px + var(--safe-bottom));
}

/* ---------------- 会话列表 ---------------- */
.conv-list { display: grid; gap: 10px; }
.conv {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: var(--r-l);
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
    border: .5px solid rgba(255, 255, 255, .75);
    box-shadow: var(--shadow-soft);
    transition: transform .16s cubic-bezier(.2, .9, .3, 1), background .16s ease;
    cursor: pointer;
}
.conv:active { transform: scale(.985); background: rgba(255, 255, 255, .8); }
.avatar {
    width: 46px; height: 46px; border-radius: 16px; flex: none;
    display: grid; place-items: center;
    font-size: 21px; color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
    position: relative;
}
.avatar.sm { width: 36px; height: 36px; border-radius: 13px; font-size: 17px; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.conv-last {
    margin-top: 2px; font-size: 12.5px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700;
    display: grid; place-items: center; flex: none;
    box-shadow: 0 2px 6px -2px rgba(255, 59, 48, .8);
}
.empty {
    padding: 60px 24px; text-align: center; color: var(--muted); font-size: 13px;
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------------- 聊天页 ---------------- */
#chat {
    position: fixed; inset: 0; z-index: 70;
    display: flex; flex-direction: column;
    background: transparent;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.25, .9, .3, 1);
}
#chat.open { transform: translateX(0); }
#chat::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(180deg, #f8fbff 0%, #eef3f9 55%, #eaf0f7 100%);
}
.chat-head {
    display: flex; align-items: center; gap: 10px;
    padding: calc(var(--safe-top) + 8px) 12px 8px;
    background: rgba(255, 255, 255, .62);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-bottom: .5px solid rgba(16, 24, 40, .06);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 6px 18px -14px rgba(16, 24, 40, .4);
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 15.5px; font-weight: 650; }
.chat-head .who span { font-size: 11px; color: var(--muted); }

.chat-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex; flex-direction: column; gap: 10px;
    -webkit-overflow-scrolling: touch;
}
.day {
    align-self: center; margin: 6px 0 2px;
    font-size: 11px; color: var(--muted);
    padding: 3px 10px; border-radius: 980px;
    background: rgba(255, 255, 255, .6);
    border: .5px solid rgba(255, 255, 255, .7);
}

.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 82%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble {
    padding: 9px 13px; border-radius: 20px 20px 20px 6px;
    background: rgba(255, 255, 255, .9);
    border: .5px solid rgba(255, 255, 255, .9);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 20px -16px rgba(16, 24, 40, .5);
    font-size: 15px; line-height: 1.45;
    white-space: pre-wrap; word-break: break-word;
}
.msg.mine .bubble {
    border-radius: 20px 20px 6px 20px;
    background: linear-gradient(180deg, #2f9bff, #0077ed);
    color: #fff; border-color: rgba(0, 90, 190, .35);
    box-shadow: 0 1px 2px rgba(0, 80, 180, .2), 0 10px 22px -14px rgba(0, 113, 227, .8);
}
.msg .meta { font-size: 10.5px; color: var(--muted); padding: 0 4px; }
.msg.mine .meta { text-align: right; }
.msg .meta .rd { margin-left: 5px; color: #9aa3af; }
.msg .meta .rd.on { color: #3b82f6; }
.msg .bubble.media { padding: 5px; background: rgba(255, 255, 255, .8); }
.msg.mine .bubble.media { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .28); }
.bubble.media img, .bubble.media video {
    border-radius: 16px; max-height: 46vh; max-width: min(62vw, 420px); object-fit: cover;
}
.bubble.media video { background: #000; }

/* 语音气泡 */
.voice {
    display: flex; align-items: center; gap: 10px; min-width: 108px;
    padding: 2px 2px 2px 0;
}
.voice .play {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: rgba(10, 132, 255, .12); color: var(--blue-deep);
}
.msg.mine .voice .play { background: rgba(255, 255, 255, .24); color: #fff; }
.voice .play svg { width: 14px; height: 14px; }
.voice .bars { display: flex; align-items: center; gap: 2.5px; flex: 1; }
.voice .bars i {
    width: 2.5px; border-radius: 2px; background: currentColor; opacity: .5;
    animation: vb 1s ease-in-out infinite;
}
.voice.playing .bars i { animation-play-state: running; }
.voice .bars i:nth-child(1) { height: 8px; animation-delay: 0s; }
.voice .bars i:nth-child(2) { height: 14px; animation-delay: .1s; }
.voice .bars i:nth-child(3) { height: 10px; animation-delay: .2s; }
.voice .bars i:nth-child(4) { height: 16px; animation-delay: .3s; }
.voice .bars i:nth-child(5) { height: 9px; animation-delay: .15s; }
.voice .dur { font-size: 11.5px; opacity: .85; font-variant-numeric: tabular-nums; }
@keyframes vb { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1); } }

/* 输入区 */
.composer {
    padding: 8px 12px calc(8px + var(--safe-bottom));
    background: rgba(255, 255, 255, .66);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-top: .5px solid rgba(16, 24, 40, .06);
    display: flex; align-items: flex-end; gap: 8px;
}
.composer .box {
    flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 6px;
    background: rgba(255, 255, 255, .92);
    border: .5px solid rgba(16, 24, 40, .08);
    border-radius: 22px; padding: 6px 8px 6px 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 2px rgba(16, 24, 40, .04);
}
.composer textarea {
    flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
    resize: none; max-height: 96px; line-height: 1.4; padding: 5px 0;
    font-size: 15px;
}
.c-btn {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    display: grid; place-items: center; color: var(--text-2);
    background: rgba(255, 255, 255, .9);
    border: .5px solid rgba(16, 24, 40, .07);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: transform .14s ease, background .16s ease, color .16s ease;
}
.c-btn:active { transform: scale(.92); }
.c-btn svg { width: 20px; height: 20px; }
.c-btn.send { background: linear-gradient(180deg, #3aa0ff, var(--blue-deep)); color: #fff; border-color: rgba(0, 90, 190, .4); }
.c-btn.rec { background: linear-gradient(180deg, #ff5f57, #ff3b30); color: #fff; border-color: rgba(200, 20, 10, .4); }

/* 录音浮层 */
.rec-layer {
    position: fixed; inset: 0; z-index: 95;
    display: none; align-items: center; justify-content: center;
    background: rgba(10, 14, 20, .28);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.rec-layer.on { display: flex; }
.rec-card {
    width: 220px; padding: 22px 18px; border-radius: var(--r-xl); text-align: center;
    background: rgba(28, 30, 36, .82); color: #fff;
    border: .5px solid rgba(255, 255, 255, .16);
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .8);
}
.rec-card .wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 44px; margin-bottom: 8px; }
.rec-card .wave i {
    width: 3px; border-radius: 2px; background: #5ec2ff;
    animation: vb 1.1s ease-in-out infinite;
}
.rec-card .time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.rec-card .tip { margin-top: 6px; font-size: 11.5px; color: rgba(255, 255, 255, .6); }

/* 附件面板 */
.sheet-mask {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(10, 14, 20, .3);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.sheet-mask.on { opacity: 1; pointer-events: auto; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
    padding: 10px 14px calc(16px + var(--safe-bottom));
    border-radius: 26px 26px 0 0;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-top: .5px solid rgba(255, 255, 255, .95);
    box-shadow: 0 -20px 50px -30px rgba(16, 24, 40, .5);
    transform: translateY(110%);
    transition: transform .3s cubic-bezier(.22, .9, .3, 1);
}
.sheet.on { transform: translateY(0); }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: rgba(16, 24, 40, .16); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: -.3px; }
.sheet .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.sheet .item {
    display: grid; place-items: center; gap: 6px;
    padding: 14px 6px; border-radius: 18px;
    background: rgba(255, 255, 255, .85);
    border: .5px solid rgba(16, 24, 40, .06);
    font-size: 12px; color: var(--text-2);
}
.sheet .item svg { width: 24px; height: 24px; }
.sheet textarea {
    width: 100%; min-height: 90px; resize: none;
    border-radius: 16px; padding: 12px 14px;
    border: .5px solid rgba(16, 24, 40, .08);
    background: rgba(255, 255, 255, .9);
    outline: none; font-size: 15px; line-height: 1.5;
}
.sheet .actions { display: flex; gap: 10px; margin-top: 12px; }
.sheet .actions .btn { flex: 1; }

/* ---------------- 朋友圈 ---------------- */
.moments { display: grid; gap: 12px; }
.moment {
    border-radius: var(--r-l); padding: 14px;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
    border: .5px solid rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-soft);
}
.moment-head { display: flex; align-items: center; gap: 10px; }
.moment-head .who { flex: 1; min-width: 0; }
.moment-head b { font-size: 14px; font-weight: 650; }
.moment-head span { display: block; font-size: 11px; color: var(--muted); }
.moment-text { margin: 10px 2px 0; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.moment-media { margin-top: 10px; display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); }
.moment-media.one { grid-template-columns: 1fr; }
.moment-media.two { grid-template-columns: repeat(2, 1fr); }
.moment-media .cell {
    position: relative; border-radius: 12px; overflow: hidden; background: #dfe4ea;
    aspect-ratio: 1 / 1;
}
.moment-media.one .cell { aspect-ratio: auto; max-height: 62vh; }
.moment-media .cell img, .moment-media .cell video { width: 100%; height: 100%; object-fit: cover; }
.moment-actions {
    display: flex; align-items: center; gap: 16px; margin-top: 10px; padding-top: 8px;
    border-top: .5px solid rgba(16, 24, 40, .07);
    font-size: 12.5px; color: var(--muted);
}
.moment-actions button { display: inline-flex; align-items: center; gap: 5px; color: inherit; font-size: 12.5px; }
.moment-actions button.on { color: var(--red); }
.moment-actions svg { width: 16px; height: 16px; }
.comments { margin-top: 8px; display: grid; gap: 4px; }
.comments .c { font-size: 12.5px; color: var(--text-2); background: rgba(16, 24, 40, .04); padding: 6px 10px; border-radius: 10px; }
.comments .c b { color: var(--blue-deep); font-weight: 600; }

/* ---------------- 我的 ---------------- */
.profile-card {
    border-radius: var(--r-xl); padding: 22px;
    background: var(--glass-strong);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: .5px solid var(--glass-line);
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px;
}
.profile-card .avatar { width: 60px; height: 60px; border-radius: 20px; font-size: 28px; }
.profile-card h2 { margin: 0; font-size: 19px; letter-spacing: -.4px; }
.profile-card p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.list-card {
    margin-top: 12px; border-radius: var(--r-l); overflow: hidden;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(170%); -webkit-backdrop-filter: blur(18px) saturate(170%);
    border: .5px solid rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-soft);
}
.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; font-size: 14.5px;
    border-bottom: .5px solid rgba(16, 24, 40, .06);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .v { color: var(--muted); font-size: 13px; }
.list-row.danger { color: var(--red); }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.emoji-pick button {
    width: 42px; height: 42px; border-radius: 14px; font-size: 22px;
    background: rgba(255, 255, 255, .8); border: .5px solid rgba(16, 24, 40, .06);
}
.emoji-pick button.on { background: rgba(10, 132, 255, .14); border-color: rgba(10, 132, 255, .4); }

/* ---------------- 底部 Dock ---------------- */
.dock {
    position: fixed; z-index: 60;
    left: 14px; right: 14px;
    bottom: calc(2px + var(--safe-bottom));
    padding: 3px 7px;
    border-radius: 24px;
    display: flex;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: .5px solid rgba(255, 255, 255, .9);
    box-shadow: 0 18px 40px -18px rgba(16, 20, 28, .38), 0 2px 8px -5px rgba(16, 20, 28, .16),
        inset 0 1px 0 rgba(255, 255, 255, .98);
}
.dock button {
    flex: 1; display: grid; place-items: center; gap: 0;
    padding: 2px 0 3px; border-radius: 18px;
    color: var(--muted); font-size: 9.5px; font-weight: 560;
    transition: color .18s ease, background .18s ease, transform .14s ease;
}
.dock button:active { transform: scale(.95); }
.dock button svg { width: 18px; height: 18px; padding: 4px; box-sizing: content-box; border-radius: 999px; stroke-width: 1.9; transition: background .2s ease, stroke-width .2s ease; }
.dock button.on { color: var(--blue); }
.dock button.on svg { background: rgba(0, 122, 255, .13); stroke-width: 2.2; }
.dock button.on span { font-weight: 700; }

/* ---------------- 浮层 / 提示 ---------------- */
#viewer {
    position: fixed; inset: 0; z-index: 120; display: none;
    background: rgba(0, 0, 0, .94);
    align-items: center; justify-content: center;
}
#viewer.on { display: flex; }
#viewer img, #viewer video { max-width: 100vw; max-height: 100vh; object-fit: contain; }

.toast {
    position: fixed; left: 50%; bottom: calc(120px + var(--safe-bottom)); z-index: 130;
    transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
    padding: 9px 16px; border-radius: 980px;
    background: rgba(24, 26, 32, .86); color: #fff; font-size: 12.5px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    transition: opacity .2s ease, transform .24s cubic-bezier(.2, .9, .3, 1);
    max-width: 78vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.https-tip {
    margin: 10px 0 0; padding: 10px 12px; border-radius: 14px;
    background: rgba(255, 204, 0, .12);
    border: .5px solid rgba(255, 170, 0, .32);
    color: #8a5a00; font-size: 12px; line-height: 1.45;
}
.https-tip b { color: #6b4500; }

/* 桌面端：收成手机宽的一列，居中 */
@media (min-width: 760px) {
    #app { max-width: 520px; margin: 0 auto; }
    .topbar { border-radius: 0; }
    .dock { left: 50%; right: auto; transform: translateX(-50%); width: 480px; }
    #chat { left: 50%; transform: translateX(calc(-50% + 100vw)); width: 520px; }
    #chat.open { transform: translateX(-50%); }
    body::after {
        content: ""; position: fixed; inset: 0; z-index: -1;
        background: radial-gradient(60% 50% at 50% 0%, rgba(120, 190, 255, .18), transparent 70%);
    }
}

/* ---------------- 开关 / 小字提示 ---------------- */
.switch {
    position: relative; width: 46px; height: 28px; border-radius: 980px; flex: none;
    background: rgba(120, 128, 140, .28);
    transition: background .2s ease;
}
.switch i {
    position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s cubic-bezier(.3, .9, .3, 1);
}
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(18px); }

.list-hint {
    margin: 14px 4px 0; text-align: center;
    font-size: 11px; color: var(--muted); opacity: .8;
}
.https-tip a { color: inherit; font-weight: 600; text-decoration: underline; }
.https-tip.ok { background: rgba(48, 209, 88, .12); border-color: rgba(48, 209, 88, .3); color: #146b32; }

.sheet-note { margin: 0 2px 10px; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.sheet-note.dim { color: var(--muted); font-size: 11.5px; }
.secure-url {
    margin: 0 0 10px; padding: 11px 13px; border-radius: 13px;
    background: rgba(10, 132, 255, .1); border: .5px solid rgba(10, 132, 255, .28);
    color: #0b4a86; font-size: 13px; font-weight: 600;
    word-break: break-all; font-variant-numeric: tabular-nums;
}
.icon-btn.muted { color: #b0b4bb; }

/* ---------------- 通话浮层 ---------------- */
.call {
    position: fixed; inset: 0; z-index: 115;
    display: none; flex-direction: column; align-items: center;
    padding: calc(var(--safe-top) + 34px) 22px calc(var(--safe-bottom) + 30px);
    color: #fff; overflow: hidden;
}
.call.on { display: flex; }
.call-bg {
    position: absolute; inset: 0; z-index: -1;
    background:
        radial-gradient(70% 52% at 50% 0%, rgba(60, 120, 230, .55), transparent 62%),
        radial-gradient(60% 45% at 82% 92%, rgba(90, 70, 200, .35), transparent 60%),
        linear-gradient(180deg, #0a1526 0%, #0c1220 52%, #070a12 100%);
}
.call-remote {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; background: #000; opacity: 0; transition: opacity .3s ease; z-index: -1;
}
.call.video.active .call-remote { opacity: 1; }
.call-local {
    position: absolute; right: 18px; bottom: calc(var(--safe-bottom) + 122px);
    width: 96px; height: 132px; border-radius: 18px; object-fit: cover;
    background: #111; box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .9);
    border: .5px solid rgba(255, 255, 255, .22);
    opacity: 0; transition: opacity .25s ease; pointer-events: none;
}
.call.video.active .call-local { opacity: 1; }

.call-face {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; text-align: center;
}
.call.video.active .call-face { opacity: 0; pointer-events: none; }
.call-face .avatar.lg {
    width: 104px; height: 104px; border-radius: 34px; font-size: 46px;
    box-shadow: 0 20px 50px -22px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.call-face b { font-size: 23px; font-weight: 650; letter-spacing: -.4px; }
.call-face span { font-size: 13.5px; color: rgba(255, 255, 255, .62); font-variant-numeric: tabular-nums; }
.call.incoming .call-face .avatar.lg { animation: callPulse 1.9s ease-in-out infinite; }
@keyframes callPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 20px 50px -22px rgba(0, 0, 0, .9); }
    50% { transform: scale(1.05); box-shadow: 0 22px 60px -18px rgba(90, 160, 255, .75); }
}
.call-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 178px); text-align: center; font-size: 12px; color: rgba(255, 255, 255, .55); }

.call-ctrl, .call-answer {
    display: none; gap: 26px; align-items: flex-start; justify-content: center;
    width: 100%; padding-bottom: 6px;
}
.call-ctrl.on { display: flex; }
.call-answer.on { display: flex; gap: 44px; }
.call-ctrl button, .call-answer button {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    color: rgba(255, 255, 255, .9); font-size: 11px;
}
.call-ctrl button svg, .call-answer button svg {
    width: 26px; height: 26px; padding: 15px; box-sizing: content-box; border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    border: .5px solid rgba(255, 255, 255, .18);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    transition: transform .14s ease, background .18s ease;
}
.call-ctrl button:active svg, .call-answer button:active svg { transform: scale(.92); }
.call-ctrl button.off svg { background: rgba(255, 255, 255, .92); color: #101114; }
.call-ctrl button.danger svg, .call-answer button.danger svg { background: #ff3b30; color: #fff; border-color: rgba(255, 255, 255, .1); }
.call-answer button.ok svg { background: #30d158; color: #fff; border-color: rgba(255, 255, 255, .1); }
.call-answer button svg { width: 30px; height: 30px; padding: 18px; }

/* 证书安装按钮（安全连接面板内） */
.cert-btn {
    display: block; margin: 4px 0 10px; padding: 13px 14px;
    border-radius: 14px; text-align: center; text-decoration: none;
    font-size: 14.5px; font-weight: 600; color: #fff;
    background: linear-gradient(180deg, #2f7cf6, #1b63d8);
    box-shadow: 0 10px 24px -14px rgba(27, 99, 216, .9);
}
.cert-btn:active { transform: scale(.985); opacity: .92; }

/* 「服务地址」可点击切换服务器时的箭头 */
.list-row .chev { color: var(--muted); opacity: .55; font-size: 15px; margin-left: 2px; }

/* 下拉刷新提示气泡 */
.ptr {
    position: fixed; left: 50%; top: calc(var(--safe-top) + 46px);
    transform: translate(-50%, -46px); opacity: 0;
    z-index: 60; pointer-events: none; white-space: nowrap;
    padding: 6px 14px; border-radius: 980px;
    font-size: 12px; font-weight: 500; color: var(--text-2);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 22px -12px rgba(16, 24, 40, .5);
    transition: opacity .18s ease;
}
.ptr.ready { color: #0a6ad6; font-weight: 600; }

/* ================================================================== */
/* 深色模式（data-theme="dark"）：只是换一套配色，布局完全不变          */
/* ================================================================== */

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0c11;
    --bg-2: #0e1117;
    --text: #eef1f6;
    --text-2: #b7bec9;
    --muted: #79818f;
    --line: rgba(255, 255, 255, .085);
    --blue: #2f95ff;
    --blue-deep: #0a6fd8;
    --green: #32d74b;
    --red: #ff453a;
    --glass: rgba(26, 30, 38, .62);
    --glass-strong: rgba(22, 26, 33, .86);
    --glass-line: rgba(255, 255, 255, .08);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 40px -24px rgba(0, 0, 0, .95);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 20px -14px rgba(0, 0, 0, .9);
}

html[data-theme="dark"] body::before {
    background:
        radial-gradient(46% 30% at 8% 0%, rgba(38, 92, 190, .30), transparent 62%),
        radial-gradient(38% 26% at 96% 4%, rgba(96, 76, 200, .20), transparent 60%),
        radial-gradient(52% 34% at 88% 100%, rgba(26, 120, 108, .16), transparent 64%),
        linear-gradient(180deg, #0c1017 0%, #0a0d13 46%, #080a0f 100%);
}
html[data-theme="dark"] body::after {
    background: radial-gradient(60% 50% at 50% 0%, rgba(60, 120, 230, .16), transparent 70%);
}

html[data-theme="dark"] .glass,
html[data-theme="dark"] .auth-card { box-shadow: var(--shadow), inset 0 .5px 0 rgba(255, 255, 255, .07); }

html[data-theme="dark"] .btn {
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] .btn.primary {
    background: linear-gradient(180deg, #3a9dff, #0a6fd8);
    border-color: rgba(120, 180, 255, .28);
}

html[data-theme="dark"] .field { background: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .field:focus-within { background: rgba(255, 255, 255, .1); }

html[data-theme="dark"] .topbar {
    background: linear-gradient(180deg, rgba(9, 12, 18, .95), rgba(9, 12, 18, .52) 72%, transparent);
}
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .topbar .icon-btn {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .07);
    box-shadow: none;
}
html[data-theme="dark"] .topbar .tb-avatar { border-color: rgba(255, 255, 255, .12); box-shadow: 0 2px 8px -4px #000; }

html[data-theme="dark"] .conv,
html[data-theme="dark"] .moment,
html[data-theme="dark"] .list-card { border-color: rgba(255, 255, 255, .07); }
html[data-theme="dark"] .conv:active { background: rgba(255, 255, 255, .09); }

html[data-theme="dark"] #chat::before {
    background: linear-gradient(180deg, #0b0f15 0%, #0a0d13 55%, #080a0f 100%);
}
html[data-theme="dark"] .chat-head {
    background: rgba(17, 21, 28, .74);
    border-bottom-color: rgba(255, 255, 255, .06);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 6px 18px -14px #000;
}
html[data-theme="dark"] .day {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .05);
}
html[data-theme="dark"] .msg .bubble {
    background: rgba(255, 255, 255, .085);
    border-color: rgba(255, 255, 255, .07);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
html[data-theme="dark"] .msg .bubble.media { background: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .msg .bubble.media { border-color: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .msg .meta .rd { color: #7c8492; }
html[data-theme="dark"] .msg .meta .rd.on { color: #4da3ff; }

html[data-theme="dark"] .composer {
    background: rgba(15, 19, 25, .80);
    border-top-color: rgba(255, 255, 255, .06);
}
html[data-theme="dark"] .composer .box {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .07);
    box-shadow: none;
}
html[data-theme="dark"] .c-btn {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .07);
    box-shadow: none;
}

html[data-theme="dark"] .sheet {
    background: rgba(19, 23, 30, .95);
    border-top-color: rgba(255, 255, 255, .08);
    box-shadow: 0 -20px 50px -30px #000;
}
html[data-theme="dark"] .sheet .item,
html[data-theme="dark"] .sheet textarea,
html[data-theme="dark"] .emoji-pick button {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .07);
}
html[data-theme="dark"] .sheet .grab { background: rgba(255, 255, 255, .18); }
html[data-theme="dark"] .emoji-pick button.on {
    background: rgba(10, 132, 255, .22);
    border-color: rgba(10, 132, 255, .5);
}

html[data-theme="dark"] .list-row { border-bottom-color: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .moment-actions { border-top-color: rgba(255, 255, 255, .07); }
html[data-theme="dark"] .moment-media .cell { background: #1a1f27; }
html[data-theme="dark"] .comments .c { background: rgba(255, 255, 255, .06); color: var(--text-2); }
html[data-theme="dark"] .comments .c b { color: #6fb6ff; }

html[data-theme="dark"] .dock {
    background: rgba(22, 26, 33, .84);
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 18px 40px -18px #000, 0 2px 8px -5px #000, inset 0 1px 0 rgba(255, 255, 255, .07);
}
html[data-theme="dark"] .dock button.on svg { background: rgba(47, 149, 255, .18); }

html[data-theme="dark"] .switch { background: rgba(255, 255, 255, .16); }
html[data-theme="dark"] .switch i { background: #f2f5fa; box-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

html[data-theme="dark"] .ptr { background: rgba(30, 35, 44, .92); }
html[data-theme="dark"] .ptr.ready { color: #6fb6ff; }

html[data-theme="dark"] .https-tip {
    background: rgba(255, 196, 0, .10);
    border-color: rgba(255, 180, 0, .22);
    color: #e6c37c;
}
html[data-theme="dark"] .https-tip b { color: #f2d79a; }
html[data-theme="dark"] .https-tip.ok {
    background: rgba(48, 209, 88, .12);
    border-color: rgba(48, 209, 88, .24);
    color: #86e2a4;
}
html[data-theme="dark"] .secure-url {
    background: rgba(10, 132, 255, .14);
    border-color: rgba(10, 132, 255, .30);
    color: #9ccbff;
}
html[data-theme="dark"] .toast { background: rgba(50, 56, 66, .92); }
html[data-theme="dark"] .icon-btn.muted { color: #5f6673; }

/* 主题切换分段控件 */
.seg {
    display: inline-flex; gap: 2px; padding: 3px;
    border-radius: 980px; background: rgba(120, 128, 140, .14);
    flex: none;
}
.seg button {
    padding: 5px 12px; border-radius: 980px;
    font-size: 12.5px; font-weight: 560; color: var(--text-2);
    transition: background .16s ease, color .16s ease;
}
.seg button.on {
    background: #fff; color: var(--text);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .16);
}
html[data-theme="dark"] .seg { background: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .seg button.on { background: rgba(255, 255, 255, .18); box-shadow: none; }

/* 头像右下角在线小绿点 */
.avatar .dot {
    position: absolute; right: -1px; bottom: -1px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--green); border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .04);
}
html[data-theme="dark"] .avatar .dot { border-color: #10141a; }
.avatar.sm .dot { width: 9px; height: 9px; }
.conv-name .live { font-size: 11px; color: var(--green); font-weight: 600; margin-left: 6px; }

/* 说明类提示条（浅色 / 深色两套）*/
.https-tip.info {
    background: rgba(10, 132, 255, .08);
    border-color: rgba(10, 132, 255, .28);
    color: #0b4a86;
}
html[data-theme="dark"] .https-tip.info {
    background: rgba(10, 132, 255, .12);
    border-color: rgba(10, 132, 255, .26);
    color: #9ccbff;
}
.chat-head .who span.live { color: var(--green); font-weight: 600; }

/* ================================================================
   桌面端（≥960px）：微信式布局
   左侧竖排导航 + 中间会话列表 + 右侧聊天面板。
   手机端排版完全不受这段影响。
   ================================================================ */
@media (min-width: 960px) {
    html { overflow: hidden; }

    /* 底部 dock → 左侧竖排导航栏 */
    .dock {
        left: 0; right: auto; top: 0; bottom: 0;
        width: 76px; padding: 22px 0;
        flex-direction: column; gap: 8px;
        border-radius: 0;
        border: none;
        border-right: .5px solid rgba(16, 24, 40, .08);
        box-shadow: none;
        transform: none;    /* 760px 断点给了 translateX(-50%)，必须清掉 */
    }
    .dock button { flex: none; padding: 6px 0 7px; border-radius: 16px; }
    .dock button svg { width: 21px; height: 21px; padding: 5px; }
    .dock button span { font-size: 10px; }

    /* 中间列：会话列表 */
    #app {
        position: fixed; left: 76px; top: 0; bottom: 0; width: 424px;
        max-width: none; margin: 0; min-height: 0;
        border-right: .5px solid rgba(16, 24, 40, .08);
    }
    .topbar { padding-top: calc(var(--safe-top) + 16px); }
    .main { overflow-y: auto; padding-bottom: 32px; }
    .ptr { display: none !important; }

    /* 右侧：聊天面板（不再整屏滑入） */
    #chat {
        left: 500px; right: 0; top: 0; bottom: 0; width: auto;
        transform: none;
        transition: opacity .16s ease;
        opacity: 0; visibility: hidden; pointer-events: none;
        border-left: .5px solid rgba(16, 24, 40, .08);
    }
    #chat.open {
        transform: none;
        opacity: 1; visibility: visible; pointer-events: auto;
    }
    .chat-head { padding-left: 18px; padding-right: 18px; }
    .chat-body { padding: 18px 30px 10px; }
    .msg { max-width: 64%; }
    .composer { padding-left: 24px; padding-right: 24px; }
    .composer .box { max-width: 720px; }

    /* 还没开聊天时右侧的占位提示 */
    #deskHint { display: none; }
    #deskHint {
        position: fixed; left: 500px; right: 0; top: 0; bottom: 0;
        z-index: 69; pointer-events: none;
        display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 14px;
        color: var(--muted); font-size: 14px;
    }
    #deskHint svg { width: 46px; height: 46px; opacity: .45; }
    #chat.open ~ #deskHint { display: none; }

    /* 深色模式下的分隔线 */
    html[data-theme="dark"] .dock { border-right-color: rgba(255, 255, 255, .07); }
    html[data-theme="dark"] #app { border-right-color: rgba(255, 255, 255, .07); }
    html[data-theme="dark"] #chat { border-left-color: rgba(255, 255, 255, .07); }
}

/* 登录卡片整体上移一点：垂直居中偏上（约 42% 高度处），水平仍居中 */
#auth { align-items: flex-start; }
.auth-card { margin-top: max(18vh, calc(var(--safe-top) + 96px)); }

/* ================================================================
   通话记录条目（会话内居中，微信风格）
   ================================================================ */
.callrec {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin: 10px auto; padding: 5px 13px;
    width: fit-content; max-width: 90%;
    font-size: 12px; color: var(--muted);
    background: rgba(16, 24, 40, .055);
    border-radius: 999px;
}
.callrec .ic { font-size: 13px; line-height: 1; }
.callrec .label { font-weight: 500; }
.callrec .note { opacity: .95; }
.callrec .t { opacity: .6; margin-left: 2px; }
.callrec.missed { color: #d64545; background: rgba(214, 69, 69, .09); }
.callrec.busy,
.callrec.declined { color: #b4732a; background: rgba(180, 115, 42, .09); }
html[data-theme="dark"] .callrec { background: rgba(255, 255, 255, .075); }
html[data-theme="dark"] .callrec.missed { color: #ff8f8f; background: rgba(214, 69, 69, .18); }
html[data-theme="dark"] .callrec.busy,
html[data-theme="dark"] .callrec.declined { color: #ffc188; background: rgba(255, 180, 90, .15); }

/* ================================================================
   移动端性能：iOS 上大面积 28px backdrop 模糊很吃 GPU，
   会话/消息一多就掉帧甚至卡死 → 手机上降到 14px
   ================================================================ */
@media (max-width: 959px) {
    :root { --blur: saturate(160%) blur(14px); }
    .chat-body { overscroll-behavior: contain; }
    .conv, .glass { -webkit-backdrop-filter: saturate(150%) blur(12px); backdrop-filter: saturate(150%) blur(12px); }
}
