/* ==================================================================
   密信
   index.php     整屏聊天（.app 那一套）
   status.html   服务器状态页（.page 那一套）
   ================================================================== */

:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1f2937;
    --text-dim: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --primary: #4f7cff;
    --primary-dim: rgba(79, 124, 255, .1);
    --danger: #ef4444;
    --success: #00a854;
    --input-bg: #ffffff;
    --their-bubble: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .07);
}
html[data-theme="dark"], body.dark {
    --bg: #0f1117;
    --card: #1a1d27;
    --text: #e4e4e7;
    --text-dim: #a1a1aa;
    --text-muted: #71717a;
    --border: #2d3148;
    --primary: #3b82f6;
    --primary-dim: rgba(59, 130, 246, .16);
    --danger: #ef4444;
    --success: #4ade80;
    --input-bg: #252836;
    --their-bubble: #23262f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

/* ==================================================================
   整屏聊天
   ================================================================== */

/* 用 position:fixed + inset 撑满，比 100vh 稳：
   手机上地址栏收起/弹出会改 vh，fixed 不受影响。
   键盘弹起时 --kb 是键盘占掉的高度，把底边抬上来，
   输入框就不会被盖住（安卓靠 viewport 的 resizes-content，iOS 靠 visualViewport）。 */
.app {
    position: fixed;
    left: 0; right: 0; top: 0;
    bottom: var(--kb, 0px);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overscroll-behavior: none;
}

/* ---- 顶栏 ---- */
/* ---- 老版本提示条 ------------------------------------------------
   跟 .topbar 一样是 flex 里的固定项，所以它一出现就把下面的顶栏、
   消息区、输入栏整体往下推，不会被压在底下。

   注意别改成 position:fixed 浮层 —— 顶栏里有返回按钮，盖住就退不出去。 */
.upd-bar {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: #fff7e6;
    border-bottom: 1px solid #f0d9a8;
    color: #7a4b00;
    font-size: 12.5px;
    line-height: 1.5;
    z-index: 6;
}
.upd-bar .upd-txt { flex: 1; min-width: 0; }
.upd-bar b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.upd-bar .upd-x {
    flex-shrink: 0;
    border: 1px solid #e0bd7a;
    background: #fff;
    color: #7a4b00;
    border-radius: 7px;
    padding: 4px 10px;
    font-size: 12.5px;
    cursor: pointer;
}
html[data-theme="dark"] .upd-bar,
body.dark .upd-bar {
    background: #3a2f18;
    border-bottom-color: #5c4a24;
    color: #f5d99a;
}
html[data-theme="dark"] .upd-bar .upd-x,
body.dark .upd-bar .upd-x {
    background: #4a3c20;
    border-color: #6b5629;
    color: #f5d99a;
}

.topbar {
    flex-shrink: 0;
    min-height: 56px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top, 0px);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 5;
}
.tb-back {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: transparent; color: var(--primary);
    font-size: 21px; line-height: 1;
    cursor: pointer;
}
.tb-back:hover { background: var(--primary-dim); }
.tb-avatar {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
}
.tb-text { flex: 1; min-width: 0; }
.tb-title {
    font-size: 16px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-sub {
    font-size: 11.5px; color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- 中间内容区（唯一会滚的地方）---- */
.content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ---- 底部 ---- */
.bottom {
    flex-shrink: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}

/* ---- 身份行 ---- */
.me-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.name-input {
    flex: 1; min-width: 0;
    padding: 7px 0;
    border: none;
    border-bottom: 1px dashed transparent;
    background: transparent;
    color: var(--text);
    font-size: 16px; font-weight: 600; font-family: inherit;
}
.name-input::placeholder { font-weight: 400; color: var(--text-muted); }
.name-input:focus { outline: none; border-bottom-color: var(--primary); }

/* ---- 联系人 ---- */
.peer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    background: var(--card);
}
.peer:hover { background: var(--primary-dim); }
.avatar {
    position: relative;          /* 给右上角的未读红圈当定位参照 */
    width: 46px; height: 46px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700;
}
.peer-body { flex: 1; min-width: 0; }
.peer-name { font-size: 15px; font-weight: 600; }
.peer-seen { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.peer-seen.on { color: var(--success); }

/* 未读红圈：贴在头像右上角，微信那个样子。
   外面套一圈跟背景同色的描边，是为了让它跟底下的头像"断开"，
   不然红点压在蓝头像上会糊成一团、看不出是个独立的圈。 */
.peer-badge {
    position: absolute;
    top: -5px; right: -5px;
    z-index: 1;
    box-sizing: border-box;
    min-width: 21px; height: 21px;
    padding: 0 5px;
    border-radius: 11px;
    background: #ff3b30; color: #fff;
    border: 2px solid var(--card);
    font-size: 11.5px; font-weight: 700;
    line-height: 17px; text-align: center;
}
/* 免打扰的群来了新消息：点一个灰点代替红数字。
   位置、大小、描边都跟 .peer-badge 对齐，只是不报数、不上色 ——
   红数字是"要你管"，灰点是"告诉你一声"，跟微信一个意思。 */
.peer-dot {
    position: absolute;
    top: -3px; right: -3px;
    z-index: 1;
    box-sizing: border-box;
    width: 13px; height: 13px;
    border-radius: 50%;
    background: #9ca3af;
    border: 2px solid var(--card);
}
.online-dot {
    display: inline-block;
    width: 7px; height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--success);
    vertical-align: middle;
}
@media (prefers-reduced-motion: no-preference) {
    .online-dot { animation: pmDot 2s ease-in-out infinite; }
    @keyframes pmDot { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
}

/* ---- 消息 ---- */
#msgs { padding: 10px 12px 4px; }
.msg { display: flex; flex-direction: column; margin-bottom: 10px; }
.msg.me  { align-items: flex-end; }
.msg.you { align-items: flex-start; }

/* 本地已经发出去、但服务器还没确认的那条 —— 稍微透明一点，
   一眼能看出"还在路上"。服务器一确认就恢复原样，通常快到看不见。 */
.bubble.pending { opacity: .62; }

.bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: var(--shadow);
}
.msg.me  .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.msg.you .bubble { background: var(--their-bubble); color: var(--text); border-bottom-left-radius: 5px; }
.bubble.can-recall { cursor: pointer; }
.bubble.bad {
    background: rgba(239, 68, 68, .14) !important;
    color: var(--danger) !important;
    font-size: 13px;
}
.bubble.burnt {
    background: rgba(217, 119, 6, .13) !important;
    color: #b45309 !important;
    font-style: italic;
}
html[data-theme="dark"] .bubble.burnt,
body.dark .bubble.burnt {
    background: rgba(251, 191, 36, .14) !important;
    color: #fbbf24 !important;
}

.burn {
    font-size: 10.5px;
    color: #d97706;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}
.burn.done { color: var(--text-muted); }
.burn.warn { color: var(--danger); font-weight: 600; }

.meta { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.meta .tick { color: var(--text-muted); }
.meta .tick.done { color: var(--primary); font-weight: 700; }

/* ---- 群聊：标出这条是谁发的 ----------------------------------------
   群里别人发的消息改成 [头像] [名字 / 气泡 / 时间] 两栏，跟微信、Telegram 一样。
   没有这一段的话，一屋子人的消息长得一模一样（只有靠左靠右之分），
   根本分不出谁是谁。

   私聊完全不受影响：那边没有 .grp 这个类，还是原来的一栏结构。 */
.msg.grp {
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
}
.msg-av {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    /* 往下推一点，跟右边气泡对齐 —— 气泡上面还有一行名字。
       17px ≈ 名字那行的高度（11.5px 字 + 3px 下边距）。 */
    margin-top: 17px;
}
.msg-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;      /* 气泡按内容宽，不拉满 */
}
.sender {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 3px 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- 输入栏 ---- */
.composer {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px 0;
}
.composer textarea {
    flex: 1; min-width: 0;
    min-height: 40px; max-height: 120px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--input-bg); color: var(--text);
    font-size: 16px; font-family: inherit; line-height: 1.45;
    resize: none;
    overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: var(--primary); }

.ttl-wrap { position: relative; flex-shrink: 0; }
.ttl-btn {
    height: 40px; min-width: 40px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--input-bg); color: var(--text-dim);
    font-size: 13px; font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.ttl-btn.on {
    border-color: #d97706;
    background: rgba(217, 119, 6, .1);
    color: #b45309;
    font-weight: 600;
}
.ttl-menu {
    position: absolute;
    left: 0; bottom: calc(100% + 8px);
    z-index: 20;
    min-width: 116px;
    padding: 5px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .3);
    display: flex; flex-direction: column; gap: 1px;
}
.ttl-item {
    padding: 9px 12px;
    border: none; border-radius: 9px;
    background: transparent; color: var(--text);
    font-size: 14px; font-family: inherit;
    text-align: left; cursor: pointer;
}
.ttl-item:hover { background: var(--primary-dim); }
.ttl-item.on { color: var(--primary); font-weight: 700; }

.send-btn {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border: none; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 17px; line-height: 1;
    cursor: pointer;
}
.send-btn:hover { opacity: .9; }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 空状态 ---- */
.empty {
    padding: 28px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.8;
}
.empty-icon { font-size: 34px; margin-bottom: 10px; }
.empty b { color: var(--text); }
.empty button {
    margin-top: 14px;
    padding: 11px 22px;
    border: none; border-radius: 22px;
    background: var(--primary); color: #fff;
    font-size: 15px; font-family: inherit;
    cursor: pointer;
}
.empty button:disabled { opacity: .5; }

/* ==================================================================
   ★ hidden 属性的修正 —— 漏了这条页面就会一片空白
   ==================================================================

   浏览器对 hidden 属性的默认处理 [hidden]{display:none} 是**用户代理样式**，
   优先级最低。只要作者样式里给同一个元素写了 display:flex / block，
   就会把它盖掉 —— 元素带着 hidden 属性照样显示出来。

   后果（这次真踩了）：
     #app 上有 hidden，但 .app{display:flex} 把它盖住 → 那个全屏不透明的
     容器一直显示着，又因为没有登录所以里面是空的，于是盖在登录框上面，
     整页看起来就是一片空白。

   所以凡是"要能藏起来"的元素都必须在这里列全，一个都不能漏。
   新增带 display 的元素时记得回来加。
   ================================================================== */
#app[hidden],
#loginView[hidden],
#adminView[hidden],
#msgs[hidden],
#listView[hidden],
#composer[hidden],
#ttlMenu[hidden],
#btnBack[hidden],
#tbAvatar[hidden] {
    display: none !important;
}

/* ==================================================================
   通用页面版式（status.html 等）
   ================================================================== */

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 14px 12px calc(40px + env(safe-area-inset-bottom, 0px));
}
.card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin-bottom: 10px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.id-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.id-label { font-size: 13px; color: var(--text-muted); flex-shrink: 0; width: 52px; }
.id-code, .fp-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    line-height: 1.85;
}
.id-code {
    padding: 4px 8px; border-radius: 6px;
    background: var(--primary-dim); color: var(--primary);
    letter-spacing: .5px;
}
.fp-box { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-dim); }
.fp-title { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.fp-code { font-size: 12.5px; letter-spacing: 1px; color: var(--primary); }

.sec-body { font-size: 13.5px; line-height: 1.85; color: var(--text-dim); }
.sec-body p { margin: 10px 0 6px; }
.sec-body b { color: var(--text); }
.sec-body ul { margin: 4px 0 4px 20px; }
.sec-body li { margin: 4px 0; }
.sec-body code {
    padding: 1px 5px; border-radius: 4px;
    background: var(--primary-dim); color: var(--primary);
    font-size: 12.5px;
}
.sec-body .warn { color: var(--danger); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn {
    padding: 9px 16px;
    border: none; border-radius: 20px;
    background: var(--primary); color: #fff;
    font-size: 14px; font-family: inherit;
    cursor: pointer;
}
.btn:hover { opacity: .9; }
.btn.plain {
    background: var(--primary-dim);
    color: var(--primary);
    font-weight: 600;
}
.btn.danger { background: rgba(239, 68, 68, .12); color: var(--danger); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.key-text {
    width: 100%;
    min-height: 100px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--input-bg); color: var(--text);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px; line-height: 1.6;
    resize: vertical;
}
.key-text:focus { outline: none; border-color: var(--primary); }

.hint { font-size: 13px; color: var(--text-dim); line-height: 1.7; margin-bottom: 10px; }

/* ==================================================================
   登录页
   ================================================================== */
.login-wrap {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    overflow-y: auto;
}
.login-card {
    width: 100%;
    max-width: 340px;
    padding: 30px 24px 22px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .28);
    text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.login-card h1 { font-size: 22px; margin-bottom: 12px; letter-spacing: 1px; }
.login-sub {
    font-size: 13px; color: var(--text-dim); line-height: 1.8;
    margin-bottom: 20px;
}
.login-sub strong { color: var(--primary); }
.login-card input {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg); color: var(--text);
    font-size: 16px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button {
    width: 100%;
    margin-top: 6px;
    padding: 12px;
    border: none; border-radius: 12px;
    background: var(--primary); color: #fff;
    font-size: 16px; font-weight: 600; font-family: inherit;
    cursor: pointer;
}
.login-card button:disabled { opacity: .55; cursor: not-allowed; }
.login-err {
    min-height: 20px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--danger);
    line-height: 1.5;
}

/* 账号那一行小字 */
.account-tip {
    padding: 0 16px 12px;
    font-size: 11.5px;
    color: var(--text-muted);
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

/* 小按钮 */
.btn-sm {
    flex-shrink: 0;
    padding: 6px 12px;
    border: none; border-radius: 9px;
    background: var(--primary-dim); color: var(--primary);
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.btn-sm:hover { opacity: .85; }
.btn-plain { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-danger { background: rgba(239, 68, 68, .12); color: var(--danger); }

/* ==================================================================
   管理后台
   ================================================================== */
#adminView { padding: 12px; }
.admin-title {
    font-size: 13px; font-weight: 600; color: var(--text-dim);
    margin: 6px 0 10px;
}
.admin-form {
    padding: 14px;
    margin-bottom: 14px;
    background: var(--card);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.admin-fields { display: flex; flex-direction: column; gap: 8px; }
.admin-fields input[type=text], .admin-fields input[type=password], .admin-fields input:not([type]) {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--input-bg); color: var(--text);
    font-size: 15px; font-family: inherit;
}
.admin-fields input:focus { outline: none; border-color: var(--primary); }
.admin-check {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; color: var(--text-dim);
    padding: 4px 2px;
}
.admin-check input { width: auto; margin: 0; }
.btn-primary {
    width: 100%;
    margin-top: 12px;
    padding: 11px;
    border: none; border-radius: 11px;
    background: var(--primary); color: #fff;
    font-size: 15px; font-weight: 600; font-family: inherit;
    cursor: pointer;
}
.admin-msg { min-height: 18px; margin-top: 10px; font-size: 12.5px; line-height: 1.6; }
.admin-msg.ok  { color: var(--success); }
.admin-msg.err { color: var(--danger); }

.admin-list {
    padding: 14px;
    background: var(--card);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.admin-row {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-info { flex: 1; min-width: 0; }
.admin-name {
    font-size: 14.5px; font-weight: 600;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.admin-sub {
    font-size: 11.5px; color: var(--text-muted); margin-top: 3px;
    word-break: break-all;
}
.admin-tag {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: 6px;
    background: var(--primary-dim); color: var(--primary);
    font-size: 10.5px; font-weight: 700;
}
.admin-tag.me { background: rgba(0, 168, 84, .14); color: var(--success); }
.admin-acts { display: flex; gap: 6px; flex-shrink: 0; }

/* ==================================================================
   说明页的新元素
   ================================================================== */
.sec-h {
    font-size: 15px; font-weight: 700; color: var(--text);
    margin: 22px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.sec-h:first-child { margin-top: 0; }
.sec-body > p:first-of-type { margin-top: 0; }

.callout {
    padding: 13px 15px;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 13.5px;
    line-height: 1.8;
}
.callout.warn {
    background: rgba(239, 68, 68, .09);
    border-left: 3px solid var(--danger);
    color: var(--text-dim);
}
.callout.warn b { color: var(--danger); }

.who-can-see {
    margin: 10px 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.wcs-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}
.wcs-row:last-child { border-bottom: none; }
.wcs-row span { color: var(--text-dim); }
.wcs-row b { font-size: 13px; white-space: nowrap; }
.wcs-row.yes { background: rgba(239, 68, 68, .06); }
.wcs-row.yes b { color: var(--danger); }
.wcs-row.no b { color: var(--success); }

.sec-body .warn { color: var(--danger); }

/* ==================================================================
   电脑版：左边联系人栏，右边聊天框（Telegram 桌面版那个样子）
   ==================================================================

   手机上是单栏 —— 列表和聊天二选一，靠 JS 的 show() 切换。
   屏幕宽了以后改成两栏，而且 **一行 DOM 都没动**：

     联系人栏本来是 .content 里面的一个普通 div（跟着内容一起滚），
     这里用 position:fixed 把它抽出来钉在左边，
     剩下的顶栏 / 消息 / 输入栏自然就排在右边那 300px 之外了。

   为什么不动 DOM：一动就得连着改手机上那套切换逻辑，
   而手机版是天天在用的，不该为了电脑版去冒这个险。
   ================================================================== */

@media (min-width: 860px) {

    /* 左边让出 300px */
    .app { padding-left: 300px; }

    /* 联系人栏（连身份行一起）。
       注意 #listView[hidden] 也要一并盖住 ——
       进聊天时 JS 会把它设成 hidden，那是手机上的逻辑，
       电脑上两栏同时可见，它必须一直在。

       ★ display 这里必须带 !important：
         上面那条通用的 `#listView[hidden] { display: none !important }`
         是带 !important 的，不带就压不住它 —— 光靠"写在后面"没用。
         （这个漏掉过一次：量出来进聊天后联系人栏整个宽高归零。） */
    #listView,
    #listView[hidden] {
        display: block !important;
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 300px;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--card);
        border-right: 1px solid var(--border);
        z-index: 6;
    }

    /* 电脑上不存在"返回列表"这回事（同样要 !important，理由同上） */
    #btnBack, #btnBack[hidden] { display: none !important; }

    /* 一个联系人都没选的时候，右边别是一片空白。
       两个都 hidden 才出提示 —— 看管理后台时不该出。 */
    .content:has(> #msgs[hidden]):has(> #adminView[hidden])::before {
        content: "选一个联系人，开始聊天";
        display: block;
        padding: 90px 20px;
        text-align: center;
        color: var(--text-muted);
        font-size: 14px;
    }

    /* 正在聊的那个人在左边高亮出来，左边一条竖线（TG 桌面版那样） */
    .peer { position: relative; }
    .peer.active { background: var(--primary-dim); }
    .peer.active::before {
        content: "";
        position: absolute;
        left: 0; top: 6px; bottom: 6px;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: var(--primary);
    }

    /* 鼠标悬停时"点一下撤回"更好懂 */
    .bubble.can-recall:hover { opacity: .8; }
}

/* ==================================================================
   "验证签名中…" 的占位气泡
   ==================================================================

   老设备没有原生 Ed25519（要 Chrome 113+），验签只能用纯 JS，
   一条 180ms —— 一百多条的会话得十几二十秒才验得完。

   以前是"验完才画"，那段时间界面全白，看着像卡死。
   现在先画这个占位，验好一条换一条。

   为什么不直接把明文显示出来：验签是"这条不是别人冒充的"唯一依据，
   没验完就渲染等于把一个安全保证变成"事后再说"。宁可先占位。

   样式上要两边都盖住（.msg.me / .msg.you 各自的底色），
   所以写成 .msg.me .bubble.verifying 这种四段选择器，
   而不是给 .bubble.verifying 加 !important。 */
.msg.me .bubble.verifying,
.msg.you .bubble.verifying {
    background: transparent;
    color: var(--text-muted);
    font-style: italic;
    border: 1px dashed var(--border);
}

/* ==================================================================
   社交层：搜索、底部菜单、设置页、群聊
   ================================================================== */

/* ---- 搜索框 ---- */
.search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.search-row input {
    flex: 1; min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px; font-family: inherit;
}
.search-row input:focus { outline: none; border-color: var(--primary); }
#searchResult .peer { background: var(--primary-dim); }

/* ---- 列表里的小标题（联系人 / 群聊）---- */
.list-head {
    padding: 10px 16px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    letter-spacing: .5px;
}

/* ---- 每一行右边的「⋯」---- */
.peer-more {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted);
    font-size: 19px; line-height: 1;
    cursor: pointer;
}
.peer-more:hover { background: var(--border); color: var(--text); }

/* ---- 群头像跟好友区分一下 ---- */
.avatar.group-avatar { border-radius: 14px; background: var(--success); }

/* ---- 底部弹出的操作菜单 ---- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-mask {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, .38);
}
.sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
    max-height: 70vh;
    overflow-y: auto;
}
.sheet-title {
    padding: 10px 14px 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
}
.sheet-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none; border-radius: 12px;
    background: transparent; color: var(--text);
    font-size: 16px; font-family: inherit;
    text-align: center;
    cursor: pointer;
}
.sheet-btn:hover { background: var(--primary-dim); }
.sheet-btn.danger { color: var(--danger); }
.sheet-cancel { margin-top: 6px; color: var(--text-muted); }

/* ---- 内页（设置 / 建群 / 群资料）---- */
.panel-title {
    padding: 18px 16px 8px;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .5px;
}
.form-row {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    background: var(--card);
}
.form-row input {
    flex: 1; min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--input-bg); color: var(--text);
    font-size: 15px; font-family: inherit;
}
.form-row input:focus { outline: none; border-color: var(--primary); }

.switch-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.switch-text { flex: 1; min-width: 0; }
.switch-label { font-size: 15px; }
.switch-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.switch {
    flex-shrink: 0;
    width: 22px; height: 22px;
    accent-color: var(--primary);
    cursor: pointer;
}
.pick-row { cursor: pointer; }

.panel-go {
    display: block;
    width: calc(100% - 32px);
    margin: 18px 16px;
    padding: 14px;
    border: none; border-radius: 12px;
    background: var(--primary); color: #fff;
    font-size: 16px; font-weight: 600; font-family: inherit;
    cursor: pointer;
}
.panel-go:disabled { opacity: .55; cursor: not-allowed; }
