/**
 * WebChat 桌面端样式 v3.2.1
 * 与移动端 mobile.css 完全隔离：本文件使用 --primary/--bg 等变量与 .app/.sidebar 等类名
 * 移动端使用 --m-* 变量和 .m- 前缀类名，详见 mobile.css
 * v3.2.0: 未读角标从列表项右侧移到昵称旁边（昵称行内 flex 排列）
 * v3.2.1: 修复侧栏 tab 上的角标被挤到第二行（tab 内容强制同排不换行）
 * v3.3.1: 通讯录面板：新增 .ct-cell「新的朋友」入口行样式
 * v3.3.2: 通讯录面板：新增 .contact-list/.ct-item 朋友名单样式
 * v3.3.3: 发起群聊：视图内成员勾选步骤样式 .group-select*
 * v3.3.4: 设置改为右侧视图：删除 .me-submenu/.me-sub-item，新增 .settings-list
 * v3.4.0: 个人资料可编辑：新增 .avatar-img 头像图片、.pv-edit 操作按钮行、.pv-nick-edit 昵称输入行
 * v3.4.1: 「我/退出登录」菜单图标改为图片：新增 .menu-icon-img
 * v3.4.2: 好友资料页底部「发送消息」按钮：新增 .pv-send
 * v3.6.2: 长消息撑满内容区：.msg-row max-width 72%→100%（气泡仍按内容收缩），并移除窄屏 86% 覆盖
 * v3.6.3: 长消息对侧再留一个头像宽：.msg-row max-width 改 calc(100% - 42px)
 * v3.6.4: 注册邮箱+找回密码：新增 .auth-forgot 链接、.auth-hint 提示、.fp-sent 成功盒
 * v3.6.8: 资料页编辑行下方新增「关闭」链接：.pv-edit-close
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #07c160;
    --primary-dark: #06a850;
    --bg: #f5f6f8;
    --sidebar-bg: #ededed;
    --panel-bg: #ffffff;
    --border: #e5e6eb;
    --text: #1f2329;
    --text-sub: #86909c;
    --bubble-mine: #95ec69;
    --bubble-other: #ffffff;
    --danger: #f53f3f;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.hidden {
    display: none !important;
}

/* ============ 登录页 ============ */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e8f8f0 0%, #d6e9ff 100%);
}

.auth-card {
    width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.auth-logo {
    text-align: center;
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-sub);
}

.field input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}

.field input:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px 16px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

/* 登录页底部「忘记密码？」小字链接 */
.auth-forgot {
    text-align: right;
    font-size: 12px;
    margin-top: 6px;
}
.auth-forgot a {
    color: var(--text-sub);
    text-decoration: none;
}
.auth-forgot a:hover {
    color: var(--primary);
}
/* 表单字段下的提示小字 */
.auth-hint {
    font-size: 12px;
    color: var(--text-sub);
    line-height: 1.5;
}
.fp-hint {
    margin: 4px 0 14px;
    text-align: center;
}
/* 重置链接发送后的成功提示盒 */
.fp-sent {
    background: #e8f7ef;
    border: 1px solid #bfe8d0;
    color: #1a7f4e;
    border-radius: 10px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}
.fp-sent-icon {
    font-size: 26px;
    margin-bottom: 6px;
}

/* ============ 主布局 ============ */
.app {
    display: flex;
    height: 100vh;
    max-width: 1280px;
    margin: 0 auto;
    background: var(--panel-bg);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.06);
}

.sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.me-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #e4e4e4;
}

.me-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.me-name {
    font-weight: 600;
    font-size: 15px;
}

.me-status {
    font-size: 12px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.btn-link {
    border: none;
    background: none;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-link:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
}

.side-tabs {
    display: flex;
    background: #e9e9e9;
    border-bottom: 1px solid var(--border);
}

.side-tab {
    flex: 1;
    padding: 10px 2px;
    border: none;
    background: none;
    font-size: 13px;
    color: var(--text-sub);
    cursor: pointer;
    position: relative;
    /* 文字与角标强制同排：窄 tab 下不折行 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}

.side-tab .badge {
    margin-left: 0;
}
/* 微信式图标 tab：上图标下文字，图标颜色跟随文字（选中变主题色） */
.side-tab {
    flex-direction: column;
    gap: 3px;
}
.side-tab .tab-icon {
    display: block;
}
.tab-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.side-tab.active {
    color: var(--primary);
    font-weight: 600;
    background: var(--sidebar-bg);
}

.badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    background: var(--danger);
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
}

.side-panel {
    flex: 1;
    overflow-y: auto;
}

/* ---------- 交流面板：+ 添加下拉子菜单 + 内联子面板 + 分区标签 ---------- */
.talk-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 10px;
    position: relative;
}
/* 顶栏「+ 添加」按钮的下拉锚点 */
.talk-menu-anchor {
    position: relative;
}
/* 微信式圆圈加号（⊕）纯图标按钮 */
.talk-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #1d1d1d;
    cursor: pointer;
}
.talk-add-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}
.talk-add-btn:active {
    background: rgba(0, 0, 0, 0.1);
}
.talk-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 136px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
    z-index: 30;
}
.talk-menu.hidden { display: none; }
.talk-menu-divider {
    height: 1px;
    margin: 4px 8px;
    background: var(--border);
}
.talk-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    border-radius: 6px;
}
.talk-menu-item:hover { background: rgba(0, 0, 0, .05); }
.talk-sub {
    margin: 0 10px 8px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, .03);
    border-radius: 8px;
}
.talk-sub.hidden { display: none; }
.talk-sub-close { margin-left: 8px; }
.talk-section {
    padding: 8px 12px 4px;
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 600;
    letter-spacing: .4px;
}
.talk-section.hidden { display: none; }

/* ---------- 通讯录面板：「新的朋友」入口行 ---------- */
.ct-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
    color: var(--text, #191919);
    cursor: pointer;
    text-align: left;
}
.ct-cell:hover { background: #f5f5f5; }
.ct-cell-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
    background: #f0f1f3;
    font-size: 15px;
}
.ct-cell-title { flex: 0 1 auto; }

/* 通讯录：朋友名单 */
.contact-list {
    display: flex;
    flex-direction: column;
    background: #fff;
}
.contact-list.hidden { display: none; }
.ct-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-top: 1px solid var(--border);
    background: #fff;
    color: var(--text, #191919);
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}
.ct-item:hover { background: #f5f5f5; }
.ct-item-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
    background: #07c160;
    color: #fff;
    font-size: 13px;
}

/* ---------- 「我」面板 ---------- */
.me-menu {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.me-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-top: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
    color: var(--text, #191919);
    cursor: pointer;
    text-align: left;
}
.me-menu-item:first-child { border-top: none; }
.me-menu-item:hover { background: #f5f6f7; }
.me-menu-icon { width: 20px; text-align: center; }
.menu-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
}
.me-menu-arrow {
    margin-left: auto;
    color: var(--text-sub);
    font-size: 16px;
}
/* 设置视图内的菜单列表 */
.settings-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.profile-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 2px 2px;
}
.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}
.profile-label { color: var(--text-sub); }
.about-box {
    padding: 18px 2px 8px;
    text-align: center;
}
.about-logo { font-size: 40px; }
.about-name {
    margin-top: 6px;
    font-size: 16px;
    font-weight: 600;
}
.about-desc {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-sub);
}
.about-version {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-sub);
}

/* 右侧个人资料整页视图 */
.profile-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f7f7f7;
}
.profile-view.hidden { display: none; }
.profile-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    height: 56px;
    padding: 0 190px 0 20px; /* 右侧留白避开固定定位的语言切换浮层 */
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
}
.profile-view-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
}
.pv-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin: 0 auto;
    border-radius: 12px;
    background: #07c160;
    color: #fff;
    font-size: 32px;
    font-weight: 600;
}
.pv-nickname {
    margin-top: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}
.pv-rows {
    max-width: 420px;
    margin: 28px auto 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.pv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    font-size: 14px;
}
.pv-row + .pv-row { border-top: 1px solid var(--border); }
.pv-label { color: var(--text-sub); }
/* 邮箱行：长邮箱换行完整展示，点击复制（chat.js bindEmailCopy） */
#pvEmailWrap { cursor: pointer; }
#pvEmailWrap .pv-value {
    min-width: 0;
    flex: 1;
    margin-left: 16px;
    text-align: right;
    word-break: break-all;
    line-height: 1.5;
}
.avatar-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}
.pv-edit {
    display: flex;
    justify-content: center;
    gap: 12px;
    max-width: 420px;
    margin: 16px auto 0;
}
.pv-nick-edit {
    display: flex;
    gap: 8px;
    max-width: 420px;
    margin: 12px auto 0;
}
.pv-nick-edit input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
/* 编辑行下方的「关闭」链接：收起当前展开的编辑表单 */
.pv-edit-close {
    max-width: 420px;
    margin: 8px auto 0;
    text-align: center;
}
.pv-edit-close button {
    border: none;
    background: none;
    padding: 4px 10px;
    color: #576b95;
    font-size: 14px;
    cursor: pointer;
}
.pv-edit-close button:hover { text-decoration: underline; }
.pv-send {
    max-width: 420px;
    margin: 24px auto 0;
}
.pv-send button { width: 100%; }
.pv-card {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.pv-card-title {
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 600;
}
.pv-card.about-box { text-align: center; }
.settings-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-form label {
    font-size: 12px;
    color: var(--text-sub);
}
.settings-form input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    background: #fafbfc;
}
.settings-form input:focus {
    border-color: var(--primary);
    background: #fff;
}
.settings-form .btn-primary {
    margin-top: 10px;
}

.empty-hint {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-sub);
    font-size: 13px;
}

.avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 600;
    user-select: none;
}

/* 群头像拼格（微信式）：成员头像平铺 2×2，外框圆角裁切 */
.g-avatar {
    display: grid;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    background: #e8e8e8;
}
.g-avatar-2 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}
.g-avatar-3,
.g-avatar-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.g-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}
.g-cell .avatar-img {
    border-radius: 0;
}
.g-avatar-3 .g-cell:first-child {
    grid-column: 1 / -1;
}

.me-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
}

.small-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 14px;
    border-radius: 6px;
}

.friend-list, .request-list {
    display: flex;
    flex-direction: column;
}

.friend-item, .request-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    position: relative;
}

.friend-item:hover, .request-item:hover {
    background: #e3e3e3;
}

.friend-item.active {
    background: #d6d6d6;
}

.friend-meta {
    flex: 1;
    min-width: 0;
}

.friend-name {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.friend-name-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-sub {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-online {
    background: var(--primary);
}

.dot-offline {
    background: #c0c4cc;
}

.unread {
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    text-align: center;
    /* 显示在昵称旁边：不压缩、不被长昵称挤掉 */
    flex-shrink: 0;
}

.request-item {
    cursor: default;
}

.request-actions {
    display: flex;
    gap: 6px;
}

.btn-small {
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-small:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--text-sub);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
}

.add-box {
    display: flex;
    gap: 8px;
    padding: 12px;
}

.add-box input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    font-size: 13px;
}

.add-box input:focus {
    border-color: var(--primary);
}

/* ============ 聊天区 ============ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f5f6f8;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-sub);
    font-size: 15px;
}

.placeholder-emoji {
    font-size: 52px;
}

.conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    height: 56px;
    min-height: 56px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.peer-status {
    font-size: 12px;
    font-weight: 400;
}

.peer-online {
    color: var(--primary);
}

.peer-offline {
    color: var(--text-sub);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.load-more {
    align-self: center;
    border: none;
    background: #e1e2e6;
    color: var(--text-sub);
    border-radius: 12px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 4px;
}

.msg-row {
    display: flex;
    gap: 8px;
    /* 长消息撑满内容区，但对侧（自己消息的左边/他人消息的右边）再留一个头像宽（42px） */
    max-width: calc(100% - 42px);
}

/* 撤回后的整行居中系统提示（微信式） */
.msg-row.msg-recalled {
    display: block;
    max-width: 100%;
    align-self: center;
    margin: 10px 0;
}

.sys-note {
    text-align: center;
    font-size: 12px;
    color: #9aa0a6;
}

.row-other {
    align-self: flex-start;
}

.row-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.row-mine .msg-body {
    align-items: flex-end;
}

.msg-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 3px;
    padding: 0 4px;
}

.bubble {
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    /* 长文本回复引用块不得把气泡撑出 msg-row 宽度 */
    max-width: 100%;
    min-width: 0;
}

.row-other .bubble {
    background: var(--bubble-other);
}

.row-mine .bubble {
    background: var(--bubble-mine);
}

.text-content {
    white-space: pre-wrap;
}

.bubble-image {
    padding: 4px;
    background: transparent !important;
    box-shadow: none !important;
}

.msg-image {
    max-width: 220px;
    max-height: 260px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}

/* 右键撤回菜单（与移动版同款） */
.msg-context-menu {
    position: fixed;
    z-index: 3500;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 4px 0;
}

.msg-context-menu button {
    display: block;
    border: none;
    background: none;
    padding: 8px 22px;
    font-size: 14px;
    color: #e64340;
    cursor: pointer;
}

.msg-context-menu button:hover {
    background: #f2f3f5;
}

/* 微信式语音气泡：扇形图标 + 时长，点击播放（与移动版一致） */
.voice-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* 自己发的（右侧气泡）：时长在左、扇形在右，声波朝左 */
.row-mine .voice-msg {
    flex-direction: row-reverse;
}

/* 收到的（左侧气泡）：扇形在左，声波朝右（水平镜像） */
.row-other .voice-fan svg {
    transform: scaleX(-1);
}

.voice-fan {
    display: inline-flex;
    flex-shrink: 0;
}

.voice-msg .vf-arc {
    opacity: 1;
}

.voice-msg.playing .vf-arc1 {
    animation: vfPulse 0.9s infinite;
}

.voice-msg.playing .vf-arc2 {
    animation: vfPulse 0.9s 0.2s infinite;
}

.voice-msg.playing .vf-arc3 {
    animation: vfPulse 0.9s 0.4s infinite;
}

@keyframes vfPulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.voice-msg .voice-dur {
    font-size: 14px;
    font-weight: 500;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    min-width: 220px;
}

.file-icon {
    font-size: 26px;
}

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: var(--text-sub);
}

.file-down {
    font-size: 12px;
    color: var(--primary);
}

/* ============ 输入区 ============ */
/* 按住说话按钮（语音模式替换文本框） */
.hold-talk-btn {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafbfc;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.hold-talk-btn.pressing {
    background: #e5e7eb;
}

/* 按住说话录音浮层（居中，与移动版一致） */
.voice-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 3000;
}

.voice-overlay-box {
    min-width: 150px;
    padding: 20px 24px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.82);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.voice-overlay-box .voice-wave {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 28px;
}

.voice-overlay-box .voice-wave span {
    width: 4px;
    height: 8px;
    border-radius: 2px;
    background: #4ade80;
    animation: voiceWave 0.9s ease-in-out infinite;
}

.voice-overlay-box .voice-wave span:nth-child(2) { animation-delay: 0.15s; }
.voice-overlay-box .voice-wave span:nth-child(3) { animation-delay: 0.3s; }
.voice-overlay-box .voice-wave span:nth-child(4) { animation-delay: 0.45s; }
.voice-overlay-box .voice-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes voiceWave {
    0%, 100% { height: 8px; }
    50% { height: 26px; }
}

.voice-overlay-box .voice-timer {
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.voice-overlay-box .voice-tip {
    font-size: 14px;
}

.voice-overlay-box .voice-sub-tip {
    font-size: 12px;
    opacity: 0.7;
}

/* 上滑进入取消区 */
.voice-overlay-box.cancel {
    background: rgba(153, 27, 27, 0.88);
}

.voice-overlay-box.cancel .voice-wave span {
    background: #fca5a5;
    animation-play-state: paused;
    height: 8px;
}

.composer {
    position: relative;
    background: var(--panel-bg);
    border-top: 1px solid var(--border);
    padding: 8px 14px 12px;
}

/* 语音/键盘切换按钮 */
.voice-toggle-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    align-self: flex-end;
}

.voice-toggle-btn:hover {
    background: var(--bg);
}

/* + 按钮 */
.plus-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    padding: 0;
    border: none;
    background: var(--bg);
    color: var(--text-sub);
    font-size: 22px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    align-self: flex-end;
}

.plus-btn.active {
    background: var(--primary);
    color: #fff;
}

/* 工具抽屉（图片/文件），从输入栏上方弹出 */
.tools-drawer {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.tools-drawer .tool-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    border-radius: 12px;
    background: var(--bg);
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    transition: background 0.15s;
    min-height: 64px;
}

.tools-drawer .tool-cell:hover {
    background: #e2e8f0;
}

.tools-drawer .tool-icon {
    font-size: 24px;
}

.composer-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.composer-input-wrap {
    flex: 1;
    position: relative;
}

.composer-row textarea {
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    padding: 6px 4px;
    background: transparent;
}

.btn-send {
    padding: 8px 22px;
}

/* ============ @ 提及浮层 ============ */
.mention-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    max-height: 200px;
    overflow-y: auto;
    min-width: 180px;
    z-index: 100;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
}

.mention-item:hover,
.mention-item.active {
    background: #f0f7ff;
}

.tiny-avatar {
    width: 22px;
    height: 22px;
    font-size: 11px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
}

.mention-name {
    white-space: nowrap;
}

/* 被提及消息高亮 */
.msg-row.msg-mention .bubble {
    border-left: 3px solid var(--primary);
}

.mention-highlight {
    color: var(--primary-dark);
    font-weight: 500;
    background: #e8f7ef;
    padding: 0 2px;
    border-radius: 2px;
}

/* 回复按钮 */
.msg-reply-btn {
    border: none;
    background: none;
    color: var(--text-sub);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    margin-top: 2px;
    border-radius: 4px;
}

.msg-reply-btn:hover {
    background: var(--bg);
    color: var(--text);
}

/* 回复提示条 */
.reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f0f7ff;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--primary-dark);
}

.reply-bar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.reply-bar-text {
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 420px;
}

.reply-close {
    border: none;
    background: none;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}

/* ============ 回复引用块（气泡内） ============ */
.reply-quote {
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.5;
}

.rq-item {
    background: rgba(7, 193, 96, 0.12);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-mine .rq-item {
    background: rgba(0, 0, 0, 0.08);
    border-left-color: #5a8a3f;
}

.rq-item:hover {
    opacity: 0.85;
}

.rq-name {
    color: var(--primary-dark);
    font-weight: 500;
}

.row-mine .rq-name {
    color: #4a7a32;
}

.rq-text {
    color: var(--text-sub);
}

/* 折叠区容器：包裹更早的对话树 */
.rq-older {
    margin-top: 4px;
}

/* 树状层次：每层向右缩进 + 左侧竖线连接，体现父子关系 */
.rq-nested {
    margin-left: 10px;
    margin-top: 3px;
    padding-left: 8px;
    border-left: 2px solid rgba(7, 193, 96, 0.35);
}

.row-mine .rq-nested {
    border-left-color: rgba(90, 138, 63, 0.35);
}

.rq-toggle {
    border: none;
    background: none;
    color: var(--primary-dark);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    margin-top: 2px;
}

.rq-toggle:hover {
    text-decoration: underline;
}

/* 点击引用定位到原消息时的闪烁提示 */
.msg-row.msg-flash .bubble {
    animation: msgFlash 2s ease-out;
}

@keyframes msgFlash {
    0% {
        box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.55);
        background: #d8f5e4;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(7, 193, 96, 0);
    }
}

/* ============ 弹窗 / Toast ============ */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    width: 340px;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 20px;
    white-space: pre-line;
}

/* 通用确认弹窗：取消 / 确认双按钮 */
.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions button {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}

.modal-actions .btn-confirm {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.modal-actions .btn-confirm:hover {
    opacity: 0.9;
}

/* ============ 屏幕截图预览 / 裁剪弹层（chat.js 路径B） ============ */
.ss-modal {
    width: min(860px, 92vw);
    text-align: left;
    padding: 18px 20px;
}

.ss-modal .modal-title {
    text-align: center;
    margin-bottom: 12px;
}

.ss-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f1f1f;
    border-radius: 8px;
    overflow: hidden;
}

.ss-stage img {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    user-select: none;
    -webkit-user-drag: none;
    cursor: crosshair;
}

.ss-select {
    position: absolute;
    border: 2px solid #2b7cff;
    background: rgba(43, 124, 255, 0.12);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.ss-hint {
    font-size: 12px;
    color: var(--text-sub);
    margin: 10px 0 14px;
    text-align: center;
}

.ss-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ss-actions button {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: var(--text);
}

.ss-actions .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.toast-box {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    align-items: center;
}

.toast {
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 8px;
    max-width: 80vw;
}

.toast-error {
    background: rgba(245, 63, 63, 0.92);
}

@media (max-width: 720px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }
}

/* ==================== 群聊 ==================== */
.owner-badge {
    color: var(--primary);
    font-size: 11px;
    margin-right: 4px;
}

.chat-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-header #callBtn {
    margin-left: auto;
}

/* 私聊通话按钮在左、群操作在右同时显示时间距 */
.chat-header #callBtn:not(.hidden) + .chat-actions:not(.hidden),
.chat-header #callBtn:not(.hidden) ~ .chat-actions:not(.hidden) {
    margin-left: 12px;
}

.chat-actions .btn-link {
    font-size: 12px;
    color: var(--text-sub);
}

.chat-actions .btn-link:hover {
    color: var(--danger);
}

.msg-sender {
    font-size: 12px;
    color: var(--text-sub);
    margin-right: 8px;
    font-weight: 500;
}

#panel-groups .add-box {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

#panel-groups .add-box input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
}

#panel-groups .friend-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

#panel-groups .friend-item input[type="checkbox"] {
    cursor: pointer;
}

.btn-primary[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- 语言切换器（固定右上角，登录页/聊天页共用） ---------- */
.lang-switch {
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 2001;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border, #e3e5e8);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 13px;
    line-height: 1;
}

.lang-switch .lang-globe {
    font-size: 14px;
    margin-right: 2px;
}

.lang-switch .lang-btn {
    border: none;
    background: transparent;
    padding: 4px 7px;
    border-radius: 999px;
    color: #666;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}

.lang-switch .lang-btn:hover {
    color: var(--primary, #4f7cff);
}

.lang-switch .lang-btn.active {
    background: var(--primary, #4f7cff);
    color: #fff;
    cursor: default;
}

@media (max-width: 640px) {
    .lang-switch {
        top: 8px;
        right: 8px;
    }
}

/* 「我/设置/多语言」页内 中文 [开关] EN 控件（i18n.js mountLangToggle） */
.lang-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 4px;
}

.lt-opt {
    font-size: 14px;
    color: var(--text-sub);
}

.lt-opt.lt-active {
    color: var(--text);
    font-weight: 600;
}

.lang-toggle {
    width: 46px;
    height: 26px;
    border: none;
    border-radius: 13px;
    background: #c8c9cc;
    position: relative;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}

.lang-toggle.lt-on {
    background: var(--primary);
}

.lt-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: left 0.2s;
}

.lang-toggle.lt-on .lt-knob {
    left: 23px;
}

.lt-hint {
    font-size: 12px;
    color: var(--text-sub);
    padding-bottom: 8px;
}

/* ---------- 发起群聊：视图内成员勾选步骤 ---------- */
.group-select {
    margin-top: 8px;
}

.group-select-hint {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
}

.group-select-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    cursor: pointer;
}

.group-select-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* 群成员管理视图（移除/邀请/审批） */
.gm-badge-wrap {
    position: relative;
    display: inline-flex;
}
.gm-badge {
    position: absolute;
    top: -7px;
    right: -10px;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    padding: 0 4px;
    border-radius: 8px;
    background: #fa5151;
    color: #fff;
    font-size: 10px;
    text-align: center;
    pointer-events: none;
}
.gm-rename {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.gm-rename input {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 14px;
}
.avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    font-size: 14px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #ddd;
    color: #fff;
}
.gm-member {
    cursor: default;
}
.gm-member .avatar-sm .avatar-img,
.gm-member .avatar-sm .avatar-letter {
    width: 100%;
    height: 100%;
    border-radius: inherit;
}
.gm-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.gm-kick {
    color: #fa5151;
    flex-shrink: 0;
}
.gm-approve {
    color: #07c160;
    flex-shrink: 0;
}
.gm-reject {
    color: #888;
    flex-shrink: 0;
}
#gmInviteList .gm-member {
    cursor: pointer;
}
.gm-member.gm-invited {
    opacity: 0.55;
    pointer-events: none;
}

.group-select-confirm {
    margin-top: 16px;
    width: 100%;
}

/* 「我」面板：全屏模式开关 */
.fs-switch {
    margin-left: auto;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: #d0d0d0;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.fs-switch .fs-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: transform .2s;
}
.fs-switch.on {
    background: #07c160;
}
.fs-switch.on .fs-knob {
    transform: translateX(18px);
}

/* ---- 备份聊天记录视图 ---- */
.backup-desc {
    color: #888;
    font-size: 13px;
    line-height: 1.6;
    margin: 8px 0 12px;
}
.backup-stat {
    font-size: 14px;
    color: #333;
    background: #f7f7f7;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.backup-btns {
    display: flex;
    gap: 10px;
    align-items: center;
}
.backup-btns button[disabled] {
    opacity: .5;
    cursor: not-allowed;
}
