/* ============================================================
   Chatly —— 即时通讯主题
   覆盖：登录 / 注册 / 主聊天 / 个人资料 / 设置 / 弹窗 / Toast
         / 头像 / 群聊 / 用户菜单 / 隐私设置 / 群信息面板
   ============================================================ */

:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --bg: #f1f5f9;
    --sidebar: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0f172a;
    --text: #1e293b;
    --muted: #94a3b8;
    --border: #e2e8f0;
    --bubble-me: #2563eb;
    --bubble-other: #fff;
    --online: #22c55e;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #16a34a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body.chatly-body {
    font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* ============================================================
   头像
   ============================================================ */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    user-select: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 44px; height: 44px; font-size: 18px; }
.avatar-xl { width: 80px; height: 80px; font-size: 32px; }

/* 有图片时隐藏字母，仅显示图片 */
.avatar.has-image {
    color: transparent;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.avatar[data-user-id] { cursor: pointer; }

/* ============================================================
   认证页（登录 / 注册）
   ============================================================ */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef2ff 0%, #f1f5f9 100%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px 32px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
}
.auth-logo {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 12px;
}
.auth-title {
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 6px;
}
.auth-sub {
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 24px;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.auth-form label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    margin-top: 10px;
}
.auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
    outline: none;
    transition: 0.2s;
    font-family: inherit;
}
.auth-form input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.auth-hint {
    font-size: 0.8rem;
    color: var(--muted);
}
.auth-hint.err { color: var(--danger); }
.auth-err {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    border-left: 4px solid var(--danger);
    line-height: 1.5;
}
.auth-ok {
    background: #dcfce7;
    color: #166534;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    border-left: 4px solid var(--success);
    line-height: 1.5;
}
.auth-foot {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}
.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 14px;
    transition: 0.2s;
    font-family: inherit;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   主聊天界面
   ============================================================ */
.chat-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #fff;
}

/* ---------- 左侧栏 ---------- */
.chat-side {
    width: 320px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #0f172a;
}

/* ============================================================
   搜索框（单行，用户 / 群共用） + 创建群按钮
   ============================================================ */
.chat-search-box {
    padding: 14px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-search-inner {
    flex: 1;
    min-width: 0;
    position: relative;
}

.chat-search-inner input {
    width: 100%;
    padding: 8px 40px 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
    height: 36px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.chat-search-inner input::placeholder { color: #64748b; }
.chat-search-inner input:focus { border-color: var(--brand); }

.chat-search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.chat-search-btn:hover {
    background: rgba(37, 99, 235, 0.15);
    color: #fff;
}
.chat-search-btn:active {
    transform: translateY(-50%) scale(0.94);
}

/* 创建群按钮（与搜索框并排） */
.chat-create-group-btn {
    background: var(--sidebar-hover);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 1.25rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-create-group-btn:hover { background: var(--brand); }
.chat-create-group-btn:active { transform: scale(0.94); }

/* ---------- Tab ---------- */
.chat-tabs {
    display: flex;
    gap: 2px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 10px;
    font-size: 0.88rem;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.chat-tab.is-active {
    color: #fff;
    border-bottom-color: var(--brand);
}

/* ---------- 列表 ---------- */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.chat-list-empty {
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
    font-size: 0.9rem;
    line-height: 1.7;
}
.chat-list-group-title {
    padding: 8px 16px;
    color: #94a3b8;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    color: inherit;
    text-decoration: none;
}
.chat-item:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}
.chat-item.is-active { background: var(--sidebar-active); }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
    color: #fff;
    font-size: 0.92rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-item-last {
    color: #64748b;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.chat-item-time {
    color: #64748b;
    font-size: 0.72rem;
}
.chat-item-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    font-size: 0.7rem;
    text-align: center;
}
.chat-item.online .chat-item-name::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--online);
    margin-left: 6px;
    vertical-align: middle;
}

/* ---------- 非好友标记 ---------- */
.chat-item-not-friend {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 4px;
    background: var(--warning);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 8px;
    vertical-align: middle;
    line-height: 1.4;
}

/* ---------- 好友请求卡片 ---------- */
.chat-request {
    background: rgba(255, 255, 255, 0.05);
    margin: 8px 12px;
    padding: 12px;
    border-radius: 10px;
    border-left: 3px solid var(--warning);
}
.chat-request-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.chat-request-name {
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
}
.chat-request-msg {
    color: #94a3b8;
    font-size: 0.82rem;
    margin-bottom: 8px;
    line-height: 1.5;
}
.chat-request-actions {
    display: flex;
    gap: 6px;
}
.chat-request-actions button {
    padding: 4px 12px;
    border-radius: 6px;
    border: none;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
}
.btn-ok { background: var(--success); color: #fff; }
.btn-ok:hover { background: #15803d; }
.btn-reject {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}
.btn-reject:hover { background: rgba(255, 255, 255, 0.16); }

/* ============================================================
   右侧聊天区
   ============================================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

/* 顶部 header */
.chat-main-head {
    background: #fff;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    position: relative;
}
.chat-back-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text);
    padding: 0 8px;
    flex-shrink: 0;
}
.chat-main-title {
    font-size: 1.05rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-online-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--online);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    flex-shrink: 0;
}

.chat-head-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.15s;
    font-family: inherit;
    flex-shrink: 0;
    white-space: nowrap;
}
.chat-head-btn:hover { background: #f1f5f9; }
.chat-head-danger { color: var(--danger); border-color: #fecaca; }
.chat-head-danger:hover { background: #fef2f2; }

/* ============================================================
   右上角：用户头像按钮 + 弹窗菜单
   ============================================================ */
.chat-user-info {
    position: relative;
    flex-shrink: 0;
    margin-left: 4px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.chat-user-avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.chat-user-avatar-btn:hover {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.chat-user-avatar-btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* 头像弹窗 */
.user-menu-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
    z-index: 500;
    overflow: hidden;
    animation: userMenuPopIn 0.15s ease-out;
}
@keyframes userMenuPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.user-menu-avatar { flex-shrink: 0; }
.user-menu-info { flex: 1; min-width: 0; }
.user-menu-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-username {
    color: var(--muted);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-settings {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 1rem;
    color: var(--muted);
    text-decoration: none;
    flex-shrink: 0;
    transition: 0.15s;
}
.user-menu-settings:hover {
    background: #e2e8f0;
    color: var(--text);
    text-decoration: none;
}

.user-menu-meta {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.user-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    font-size: 0.85rem;
}
.user-menu-row .label { color: var(--muted); flex-shrink: 0; }
.user-menu-row .value {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.user-menu-status {
    padding: 3px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    transition: 0.15s;
    line-height: 1.4;
}
.user-menu-status.is-plain {
    background: #fef3c7;
    color: #92400e;
}
.user-menu-status.is-plain:hover { background: #fde68a; color: #78350f; }
.user-menu-status.is-encrypted {
    background: #dbeafe;
    color: #1d4ed8;
}
.user-menu-status.is-encrypted:hover { background: #bfdbfe; color: #1e40af; }

.user-menu-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
}
.user-menu-actions .btn-menu {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: 0.15s;
    font-family: inherit;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}
.user-menu-actions .btn-menu-primary {
    background: var(--brand);
    color: #fff;
}
.user-menu-actions .btn-menu-primary:hover {
    background: var(--brand-dark);
    text-decoration: none;
}
.user-menu-actions .btn-menu-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.user-menu-actions .btn-menu-danger:hover {
    background: #fee2e2;
    text-decoration: none;
}

/* ============================================================
   群公告条
   ============================================================ */
.chat-announcement {
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
    padding: 10px 20px;
    flex-shrink: 0;
}
.chat-announcement-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1e40af;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.chat-announcement-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.chat-announcement-close:hover { color: var(--text); }
.chat-announcement-body {
    color: #334155;
    font-size: 0.88rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}

/* ============================================================
   不是好友提示条
   ============================================================ */
.chat-friend-notice {
    padding: 8px 20px;
    background: #fef3c7;
    border-top: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.85rem;
    flex-shrink: 0;
    line-height: 1.6;
}
.chat-friend-notice a {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
    margin-left: 6px;
}
.chat-friend-notice a:hover { color: #78350f; }

/* ---------- 消息区 ---------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    line-height: 1.7;
}
.chat-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

/* 消息气泡 */
.msg-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.msg-row.is-mine { flex-direction: row-reverse; }
.msg-bubble {
    max-width: 70%;
    padding: 9px 14px;
    border-radius: 14px;
    font-size: 0.93rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.msg-row.is-mine .msg-bubble {
    background: var(--bubble-me);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-row:not(.is-mine) .msg-bubble {
    background: var(--bubble-other);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.msg-time {
    font-size: 0.7rem;
    color: var(--muted);
    align-self: flex-end;
    margin-bottom: 2px;
    flex-shrink: 0;
}
.msg-system {
    align-self: center;
    color: var(--muted);
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px 12px;
    border-radius: 10px;
}

/* 明文提示条 */
.chat-plain-notice {
    padding: 8px 20px;
    background: #fef3c7;
    border-top: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.85rem;
    flex-shrink: 0;
    line-height: 1.6;
}
.chat-plain-notice a {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
    margin-left: 6px;
}
.chat-plain-notice a:hover { color: #78350f; }

/* 输入区 */
.chat-compose {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid var(--border);
    align-items: flex-end;
    flex-shrink: 0;
}
.chat-compose textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    background: #fff;
}
.chat-compose textarea:focus { border-color: var(--brand); }

.chat-encrypt-toggle {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}
.chat-encrypt-toggle.is-encrypted {
    background: #eff6ff;
    border-color: var(--brand);
    color: var(--brand);
}
.chat-encrypt-toggle:hover { border-color: var(--brand); }

.chat-send-btn {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--brand-dark); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   个人资料页
   ============================================================ */
.profile-wrap {
    min-height: 100vh;
    padding: 100px 24px 40px;
    display: flex;
    justify-content: center;
}
.profile-card {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
    align-self: flex-start;
}
.profile-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.profile-back {
    color: var(--brand);
    font-size: 0.9rem;
}
.profile-head h1 { font-size: 1.4rem; }
.profile-user {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 16px;
}
.profile-user-info { min-width: 0; }
.profile-user-name {
    font-size: 1.1rem;
    font-weight: 600;
}
.profile-user-username {
    color: var(--muted);
    font-size: 0.85rem;
}
.profile-user-email {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 头像上传操作区 */
.profile-avatar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 20px 0;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.profile-avatar-actions .btn-secondary {
    padding: 7px 16px;
    font-size: 0.85rem;
    background: #f1f5f9;
    color: #1e293b;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
}
.profile-avatar-actions .btn-secondary:hover { background: #e2e8f0; }
.profile-avatar-actions .btn-danger-outline {
    color: var(--danger);
    background: #fef2f2;
    border: 1px solid #fecaca;
}
.profile-avatar-actions .btn-danger-outline:hover { background: #fee2e2; }
.profile-avatar-hint {
    font-size: 0.78rem;
    color: var(--muted);
}

/* 表单 */
.profile-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.profile-form label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    margin-top: 4px;
}
.profile-form input[type="text"],
.profile-form input[type="tel"],
.profile-form input[type="email"],
.profile-form input[type="date"],
.profile-form select,
.profile-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    background: #fff;
    color: var(--text);
    box-sizing: border-box;
    transition: 0.2s;
}
.profile-form input[type="text"]:focus,
.profile-form input[type="tel"]:focus,
.profile-form input[type="email"]:focus,
.profile-form input[type="date"]:focus,
.profile-form select:focus,
.profile-form textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.profile-form textarea {
    min-height: 70px;
    resize: vertical;
}

/* 性别 + 电话并排 */
.profile-row {
    display: flex;
    gap: 14px;
}
.profile-row > .profile-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ============================================================
   设置页（隐私设置）
   ============================================================ */
.settings-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}
.settings-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.settings-section-hint {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--muted);
    line-height: 1.5;
}

/* radio 卡片 */
.radio-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.radio-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}
.radio-item.is-checked {
    border-color: var(--brand);
    background: #eff6ff;
}
.radio-item input[type="radio"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    flex-shrink: 0;
    cursor: pointer;
}
.radio-body { flex: 1; min-width: 0; }
.radio-label {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}
.radio-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

/* checkbox 网格 */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s;
    background: #fff;
    color: var(--text);
}
.checkbox-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}
.checkbox-item.is-checked {
    border-color: var(--brand);
    background: #eff6ff;
    color: var(--brand);
}
.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.settings-tip {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    line-height: 1.6;
    margin-top: 8px;
}

/* ============================================================
   弹窗（通用）
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.4);
}
.modal-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.modal-head h3 { font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--muted);
    line-height: 1;
    padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body {
    padding: 20px;
    overflow-y: auto;
}
.modal-body label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    margin: 10px 0 6px;
    color: var(--text);
}
.modal-body textarea,
.modal-body input[type="text"],
.modal-body input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}
.modal-body textarea:focus,
.modal-body input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.modal-body .btn-primary {
    margin-top: 14px;
}

/* ============================================================
   二级弹窗：覆盖在普通弹窗之上
   典型场景：
     群成员弹窗（1000）→ 点击头像 → 用户资料弹窗（1100）
     用户资料弹窗（1100）→ 加好友 → 好友申请弹窗（1100）
   ============================================================ */
#userProfileModal,
#friendRequestModal,
#groupInfoModal {
    z-index: 1100;
}

/* ============================================================
   加密设置弹窗内部
   ============================================================ */
#e2eeSettingsBody > p {
    color: #475569;
    line-height: 1.7;
    margin-bottom: 16px;
    font-size: 0.92rem;
}
#e2eeSettingsBody .btn-secondary {
    padding: 10px;
    background: #f1f5f9;
    color: #1e293b;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: 0.2s;
    width: 100%;
}
#e2eeSettingsBody .btn-secondary:hover { background: #e2e8f0; }
#e2eeSettingsBody .btn-danger {
    padding: 10px;
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: 0.2s;
    width: 100%;
}
#e2eeSettingsBody .btn-danger:hover { background: #fee2e2; }
.e2ee-warn {
    padding: 10px 14px;
    background: #fef3c7;
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    color: #92400e;
    font-size: 0.82rem;
    line-height: 1.6;
    margin: 10px 0 16px;
}
.e2ee-err {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.4em;
    margin-top: 8px;
}
.e2ee-link {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    transition: 0.2s;
}
.e2ee-link:hover {
    color: var(--danger);
    background: #fef2f2;
}
#e2eeSettingsBody code {
    background: #e2e8f0;
    padding: 1px 6px;
    border-radius: 3px;
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    font-size: 0.88em;
    color: var(--text);
}
#e2eeSettingsBody ul {
    padding-left: 20px;
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.8;
    margin: 0 0 12px;
}

/* ============================================================
   用户资料弹窗
   ============================================================ */
.profile-popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px 0 4px;
}
.profile-popup .avatar-xl {
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.2);
}
.profile-popup-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.profile-popup-username {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.profile-popup-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    margin-bottom: 14px;
}
.profile-popup-status.is-online {
    background: #dcfce7;
    color: #166534;
}
.profile-popup-status.is-offline {
    background: #f1f5f9;
    color: #64748b;
}
.profile-popup-signature {
    width: 100%;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 10px;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.7;
    word-break: break-word;
    margin-bottom: 14px;
    text-align: left;
    border-left: 3px solid var(--brand);
    white-space: pre-wrap;
}
.profile-popup-signature.is-empty {
    color: var(--muted);
    font-style: italic;
    border-left-color: var(--border);
}
.profile-popup-info {
    width: 100%;
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 6px 12px;
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 0.88rem;
}
.profile-popup-info .label { color: var(--muted); }
.profile-popup-info .value { color: var(--text); word-break: break-all; }

.profile-popup-warn {
    width: 100%;
    padding: 8px 12px;
    background: #fef3c7;
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    color: #92400e;
    font-size: 0.82rem;
    margin-bottom: 14px;
    text-align: left;
    line-height: 1.6;
}
.profile-popup-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}
.profile-popup-actions .btn-primary,
.profile-popup-actions .btn-secondary {
    flex: 1;
    margin: 0;
    padding: 10px;
    font-size: 0.92rem;
}
.profile-popup-actions .btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
}
.profile-popup-actions .btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}
.profile-popup-actions .btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 删除好友按钮（红色描边） */
.profile-popup-actions .btn-danger-outline {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.profile-popup-actions .btn-danger-outline:hover:not(:disabled) {
    background: #fee2e2;
}

/* ============================================================
   搜索结果（用户 + 群）
   ============================================================ */
.search-section-title {
    padding: 10px 0 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.search-section-title:first-child {
    padding-top: 0;
}

.user-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.user-search-item:last-child { border-bottom: none; }
.user-search-info { flex: 1; min-width: 0; }
.user-search-name {
    font-weight: 500;
    font-size: 0.92rem;
}
.user-search-handle {
    color: var(--muted);
    font-size: 0.8rem;
}
.user-search-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.user-search-actions button {
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
}
.btn-start {
    background: var(--brand);
    color: #fff;
}
.btn-start:hover { background: var(--brand-dark); }
.btn-start:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-friend {
    background: var(--warning);
    color: #fff;
}
.btn-friend:hover { background: #d97706; }
.btn-friend:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* ============================================================
   群成员选择器（创建群弹窗内）
   ============================================================ */
.group-member-picker {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
    margin-top: 4px;
}
.group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 400;
    transition: background 0.15s;
}
.group-member-item:hover { background: #f8fafc; }
.group-member-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    flex-shrink: 0;
    margin: 0;
}

/* ============================================================
   群信息面板
   ============================================================ */
.group-info-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.group-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}
.group-avatar-edit {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.group-info-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.group-info-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}
.group-info-no {
    font-size: 0.82rem;
    color: var(--muted);
    font-family: ui-monospace, monospace;
}
.group-info-count { font-size: 0.82rem; color: var(--muted); }
.group-title-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    width: 100%;
    box-sizing: border-box;
}
.group-info-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.group-info-section:last-of-type { border-bottom: none; }
.group-info-section-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 8px;
}
.group-info-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}
.group-info-inline input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}
.btn-small {
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
    transition: 0.15s;
}
.btn-small:hover { background: #f1f5f9; }
.group-announcement-text {
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #334155;
    line-height: 1.6;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 全群禁言 toggle */
.group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}
.group-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
    margin: 0;
}

/* 群成员列表 */
.group-member-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.group-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 6px;
    transition: background 0.15s;
    flex-wrap: wrap;
}
.group-member-row:hover { background: #f8fafc; }
.group-member-row .avatar { cursor: default; }
.group-member-meta { flex: 1; min-width: 0; }
.group-member-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.group-member-sub {
    font-size: 0.78rem;
    color: var(--muted);
}
.group-member-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    width: 100%;
    padding-left: 42px;
    margin-top: 4px;
}
.btn-tiny {
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    transition: 0.15s;
}
.btn-tiny:hover { background: #f1f5f9; }
.btn-tiny.btn-danger {
    color: var(--danger);
    border-color: #fecaca;
}
.btn-tiny.btn-danger:hover { background: #fef2f2; }

.group-role-badge {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.4;
}
.group-role-badge.is-owner { background: #f59e0b; color: #fff; }
.group-role-badge.is-admin { background: #2563eb; color: #fff; }
.group-muted-badge {
    padding: 1px 8px;
    border-radius: 10px;
    background: #fef2f2;
    color: var(--danger);
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid #fecaca;
    line-height: 1.4;
}

.group-info-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.group-info-footer .btn-danger {
    padding: 9px 20px;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.group-info-footer .btn-danger:hover { background: #b91c1c; }
.group-info-footer .btn-secondary {
    padding: 9px 20px;
    background: #f1f5f9;
    color: #1e293b;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.group-info-footer .btn-secondary:hover { background: #e2e8f0; }

/* 群成员弹窗内复用 .user-search-item，头像可点击 */
#groupMembersBody .user-search-item { cursor: default; }

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    max-width: 500px;
    width: 90%;
    pointer-events: none;
}
.chatly-toast {
    pointer-events: auto;
    display: inline-block;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: 0.3s;
    font-size: 0.9rem;
    border-left: 4px solid var(--brand);
    line-height: 1.5;
}
.chatly-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.chatly-toast.error { border-left-color: var(--danger); }
.chatly-toast.success { border-left-color: var(--success); }
.chatly-toast.info { border-left-color: var(--brand); }
.chatly-toast.warning { border-left-color: var(--warning); }

/* ============================================================
   响应式：平板 / 手机
   ============================================================ */
@media (max-width: 768px) {
    /* 单栏模式 */
    .chat-side { width: 100%; }
    .chat-main { display: none; }
    .chat-app.in-chat .chat-side { display: none; }
    .chat-app.in-chat .chat-main { display: flex; }
    .chat-back-btn { display: block; }
    .msg-bubble { max-width: 80%; }

    /* 搜索框 */
    .chat-search-box { padding: 12px 14px; gap: 6px; }
    .chat-search-inner input { height: 34px; font-size: 0.85rem; }
    .chat-search-btn { width: 28px; height: 28px; font-size: 0.9rem; }
    .chat-create-group-btn { width: 34px; height: 34px; font-size: 1.15rem; }

    /* 顶部 header */
    .chat-main-head { padding: 10px 14px; gap: 8px; }
    .chat-head-btn { font-size: 0.72rem; padding: 4px 8px; }

    /* 用户头像按钮 */
    .chat-user-info { padding-left: 8px; margin-left: 2px; }
    .user-menu-pop { width: 240px; }
    .user-menu-row .value { max-width: 120px; }

    /* 聊天内容 */
    .chat-messages { padding: 14px; }
    .chat-compose { padding: 10px 14px; gap: 6px; }
    .chat-encrypt-toggle { padding: 8px 10px; font-size: 0.78rem; }
    .chat-send-btn { padding: 10px 14px; font-size: 0.85rem; }
    .chat-plain-notice { padding: 8px 14px; font-size: 0.8rem; }
    .chat-friend-notice { padding: 8px 14px; font-size: 0.8rem; }

    /* 群公告 */
    .chat-announcement { padding: 8px 14px; }
    .chat-announcement-head { font-size: 0.82rem; }
    .chat-announcement-body { font-size: 0.82rem; max-height: 90px; }

    /* 认证页 */
    .auth-wrap { padding: 16px; }
    .auth-card { padding: 32px 24px 24px; }
    .auth-title { font-size: 1.4rem; }

    /* 个人资料 / 设置页 */
    .profile-wrap { padding: 80px 16px 32px; }
    .profile-card { padding: 24px 20px; }
    .profile-head h1 { font-size: 1.2rem; }
    .profile-user {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    .profile-user-info { text-align: center; }
    .profile-avatar-actions { justify-content: center; }
    .profile-avatar-hint { width: 100%; text-align: center; }

    /* 性别/电话在窄屏仍并排（但间距更小） */
    .profile-row { gap: 10px; }

    /* 设置页 */
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
    .radio-item { padding: 10px 12px; }

    /* 弹窗 */
    .modal { padding: 12px; }
    .modal-box { max-height: 85vh; }
    .modal-body { padding: 16px; }

    /* 用户资料弹窗 */
    #userProfileModal .modal-box { max-width: 100%; }
    .profile-popup .avatar-xl { width: 72px; height: 72px; font-size: 28px; }
    .profile-popup-info { grid-template-columns: 70px 1fr; font-size: 0.85rem; }

    /* 群信息面板 */
    .group-member-actions { padding-left: 0; }
    .group-info-head { flex-direction: column; align-items: center; text-align: center; }
}

@media (max-width: 480px) {
    .chat-item-info { min-width: 0; }
    .chat-item-last { font-size: 0.75rem; }
    .msg-bubble { max-width: 85%; font-size: 0.9rem; }
    .chat-empty-icon { font-size: 2.5rem; }
    .auth-logo { font-size: 2.5rem; }
    .user-search-item { gap: 8px; }
    .user-search-actions button { padding: 4px 10px; font-size: 0.75rem; }
    .profile-popup-actions { flex-direction: column; }
    .group-member-item { font-size: 0.85rem; padding: 6px 8px; }

    /* 极窄屏：性别/电话上下堆叠 */
    .profile-row { flex-direction: column; gap: 10px; }
}

/* ============================================================
   滚动条美化（Webkit）
   ============================================================ */
.chat-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.group-member-picker::-webkit-scrollbar,
.chat-announcement-body::-webkit-scrollbar {
    width: 6px;
}
.chat-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.group-member-picker::-webkit-scrollbar-track,
.chat-announcement-body::-webkit-scrollbar-track {
    background: transparent;
}
.chat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.chat-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
.chat-messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.group-member-picker::-webkit-scrollbar-thumb,
.chat-announcement-body::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.group-member-picker::-webkit-scrollbar-thumb:hover,
.chat-announcement-body::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.25);
}


/* ============================================================
   联系人分区标题
   ============================================================ */
.chat-list-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.chat-list-section-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.15rem;     /* ★ 加大，让 ＋ 更醒目 */
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    border-radius: 4px;
    transition: 0.15s;
    font-family: inherit;
}
.chat-list-section-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ============================================================
   分组标题
   ============================================================ */
.chat-group-folder { margin-bottom: 4px; }
.chat-group-folder-title {
    padding: 6px 16px;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
}
.chat-group-folder-count {
    display: inline-block;
    padding: 0 6px;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    border-radius: 8px;
    font-size: 0.7rem;
    line-height: 16px;
}

/* ============================================================
   右键菜单
   ============================================================ */
.context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 180px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    padding: 6px;
    animation: contextMenuFadeIn 0.1s ease-out;
}
@keyframes contextMenuFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
.context-menu-items { display: flex; flex-direction: column; }
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 6px;
    text-align: left;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s;
    white-space: nowrap;
}
.context-menu-item:hover { background: #f1f5f9; }
.context-menu-item.is-danger { color: var(--danger); }
.context-menu-item.is-danger:hover { background: #fef2f2; }
.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ============================================================
   分组管理弹窗
   ============================================================ */
.group-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.group-manage-item:last-child { border-bottom: none; }
.group-manage-name {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}
.group-manage-name:focus { border-color: var(--brand); }

/* 分配分组 */
.assign-group-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.assign-group-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.9rem;
}
.assign-group-item:hover { background: #f8fafc; }
.assign-group-item.is-selected {
    background: #eff6ff;
    color: var(--brand);
    font-weight: 500;
}
.assign-group-item input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
    margin: 0;
}

/* 移动端 */
@media (max-width: 768px) {
    .context-menu { min-width: 150px; }
    .context-menu-item { padding: 10px 14px; font-size: 0.92rem; }
}
/* ============================================================
   分组展开/收起
   ============================================================ */
.chat-group-folder-title {
    padding: 6px 16px;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.chat-group-folder-title:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
}
.chat-group-folder-title .folder-arrow {
    display: inline-block;
    width: 12px;
    text-align: center;
    font-size: 0.65rem;
    color: #94a3b8;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.chat-group-folder-title .folder-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-group-folder-items {
    /* 展开时的容器 */
}