/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-hover: #357abd;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --secondary-color: #95a5a6;
    --secondary-hover: #7f8c8d;
    --bg-color: #f5f5f5;
    --header-bg: #2c3e50;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --node-width: 100px;
    --node-height: 36px;
    --node-avatar-size: 28px;
    --generation-gap: 120px;
    --sibling-gap: 40px;
    --couple-gap: 20px;
}

html, body {
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 主内容区域 */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* 辈分标尺 */
.generation-ruler {
    width: 50px;
    background-color: transparent !important;
    background: transparent !important;
    border-right: none; /* 去掉边框 */
    overflow: visible;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10;
    height: 100vh;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.generation-ruler.visible {
    opacity: 1;
}

.ruler-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100%;
    background-color: transparent !important;
    background: transparent !important;
}

.ruler-item {
    position: absolute;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: transparent !important;
    background: transparent !important;
    cursor: pointer;
    transition: all 0.2s;
    transform: translate(-50%, -50%);
}

.ruler-item:hover .ruler-generation,
.ruler-item:hover .ruler-word {
    background-color: rgba(227, 242, 253, 0.9) !important;
    background: rgba(227, 242, 253, 0.9) !important;
}

.ruler-generation {
    font-size: 10px;
    color: #666;
    text-align: center;
    line-height: 1.2;
    background-color: rgba(248, 249, 250, 0.85) !important;
    background: rgba(248, 249, 250, 0.85) !important;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    /* 绝对定位在字辈上方，不影响 item 的中心点 */
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
}

.ruler-word {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    background-color: rgba(248, 249, 250, 0.85) !important;
    background: rgba(248, 249, 250, 0.85) !important;
    white-space: nowrap;
}

.ruler-word:hover {
    background-color: rgba(227, 242, 253, 0.95) !important;
    background: rgba(227, 242, 253, 0.95) !important;
}

/* 画布容器 */
.canvas-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #fafafa;
    min-height: calc(100vh - 120px); /* 确保最小高度 */
}

/* 成员统计浮层 */
.tree-stats-overlay {
    position: fixed;
    right: 15px; /* 改为右侧 */
    bottom: 61px; /* 导航栏高度 56px + 5px 间距 = 61px */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 1000;
    pointer-events: none;
    transition: all 0.3s ease;
}

.tree-stats-overlay:hover {
    background: rgba(255, 255, 255, 0.8);
    pointer-events: auto;
}

.stats-item {
    display: flex;
    flex-direction: row; /* 改为单行显示 */
    align-items: center;
    gap: 4px; /* 标签和值的间距 */
}

.stats-label {
    font-size: 10px; /* 缩小字号 */
    color: #64748b;
    font-weight: 500;
}

.stats-value {
    font-size: 13px; /* 缩小字号 */
    font-weight: 700;
    color: #1e293b;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.stats-divider {
    width: 1px;
    height: 14px; /* 减小分割线高度 */
    background: rgba(0, 0, 0, 0.1);
}

.stats-item.male .stats-value {
    color: #4a90d9;
}

.stats-item.female .stats-value {
    color: #e91e63;
}

.canvas-wrapper {
    position: relative;
    transform-origin: 0 0;
    transition: transform 0.3s ease;
}

/* 强行禁用过渡动画 */
.no-transition {
    transition: none !important;
}

.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.connections-layer line,
.connections-layer path {
    fill: none;
    /* stroke 和 stroke-width 由 JavaScript 动态设置 */
}

.nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

/* 人物节点样式 */
.person-node {
    position: absolute;
    width: var(--node-width);
    height: var(--node-height);
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 10;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击时的蓝色高亮 */
}

.person-node:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
    z-index: 20;
}

.person-node.male {
    border-color: #4a90d9;
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
}

.person-node.female {
    border-color: #e91e63;
    background: linear-gradient(135deg, #fce4ec 0%, #ffffff 100%);
}

/* 纵向矩形视图样式 */
.person-node.vertical {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1px; /* 统一设置 1px 内边距，确保头像和名字容器四周间距相等 */
    gap: 0;
}

.person-node.vertical .node-avatar {
    width: 100%; /* 占据父容器扣除 padding 后的全部宽度 */
    height: auto;
    aspect-ratio: 1;
    border-radius: 4px;
    margin: 0; /* 改用父级 padding 控制边距 */
    margin-bottom: 1px; /* 头像与名字容器间留 1px 间距 */
    flex-shrink: 0;
    min-width: 0;
    min-height: 0;
}

.person-node.vertical .node-info {
    margin: 0;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-bottom: 1px;
}

.person-node.vertical .node-name {
    writing-mode: horizontal-tb; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* 移除重复和冲突的定义 */
.person-node.vertical .node-name span {
    font: inherit;
    color: inherit;
    display: inline-block;
    line-height: 1.1;
}

/* 2字姓名在纵向模式下的两端分散对齐 */
.person-node.vertical .node-name.two-chars {
    justify-content: space-between;
    padding: 8% 0; /* 稍微减小百分比，让 2 字排版更协调 */
}

.person-node.selected {
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.3);
}

/* 本人节点标志 (红点) */
.self-badge {
    position: absolute;
    top: -8px; /* 稍微向上移动一点 */
    right: -8px; /* 稍微向右移动一点 */
    width: 16px; /* 变大一点 */
    height: 16px; /* 变大一点 */
    background-color: #ff4d4f;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(255, 77, 79, 0.4);
    z-index: 100; /* 极高层级 */
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: self-badge-pulse 2s infinite;
}

.self-badge::after {
    content: '我';
    font-size: 9px;
    color: #fff;
    font-weight: bold;
}

@keyframes self-badge-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 77, 79, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
}

.node-avatar {
    width: var(--node-avatar-size);
    height: var(--node-avatar-size);
    border-radius: 4px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    margin-right: 6px;
    flex-shrink: 0;
    overflow: hidden;
    /* 固定头像框，不受内容影响 */
    min-width: var(--node-avatar-size);
    min-height: var(--node-avatar-size);
}

.node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden; /* 防止内容溢出 */
}

.node-name {
    font-weight: inherit;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    font-style: inherit;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 1.4em;
    overflow: visible;
}

/* 纵向模式下的姓名容器 */
.person-node.vertical .node-name {
    writing-mode: horizontal-tb; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 默认居中，3字姓名将紧凑排列 */
    height: 100%;
    width: 100%;
    padding: 4px 0; /* 基础内边距：增加上下各 4px，使其远离头像和底边 */
}

/* 2字姓名在纵向模式下的两端分散对齐 */
.person-node.vertical .node-name.two-chars {
    justify-content: space-between;
    padding: 15% 0; /* 加大百分比：从 8% 增加到 15%，使 2 字位置更靠内 */
}

/* 节点菜单 */
.node-menu {
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 8px 0;
    min-width: 120px;
    z-index: 1000;
    display: none;
}

.node-menu.visible {
    display: block;
}

.menu-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.menu-item:hover {
    background: #f5f5f5;
}

.menu-item.delete {
    color: var(--danger-color);
}

/* 搜索弹窗 */
.search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
}

.search-result-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
}

.search-result-info {
    flex: 1;
}

.result-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.result-info {
    font-size: 12px;
    color: #999;
}

.search-empty {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* 节点详情弹窗 */
.node-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.node-detail-modal.visible {
    display: flex;
}

.node-detail-modal.visible .node-detail-content {
    transform: scale(1);
    opacity: 1;
}

.node-detail-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    padding: 15px;
    /* 缩放过度动画：由小到大 */
    transform: scale(0.85);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.detail-parents {
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    color: #666;
}

.detail-parents:empty {
    display: none;
}

.detail-info {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.info-avatar {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #666;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.info-avatar:hover {
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.3);
}

.info-avatar.clickable {
    position: relative;
}

.info-avatar .avatar-overlay {
    position: absolute;
    bottom: 4px;
    left: auto;
    right: 4px;
    transform: none;
    background: rgba(102, 126, 234, 0.55);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    z-index: 1;
    pointer-events: none;
}

.info-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.info-table {
    width: auto;
    border-collapse: collapse;
    background: transparent;
}

.info-table td {
    padding: 4px 0;
    vertical-align: middle;
}

.info-table .field-label {
    color: #999;
    font-size: 13px;
    width: auto;
    white-space: nowrap;
    text-align: left;
    padding-right: 4px;
}

.info-table .field-value {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    padding-right: 15px;
    white-space: nowrap;
    padding-left: 0;
}

.info-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-label {
    color: #999;
    font-size: 13px;
    min-width: 35px;
}

.field-value {
    font-weight: 500;
    color: #333;
}

/* 操作按钮 - 紧凑单行 */
.detail-actions {
    margin-bottom: 12px;
}

.detail-actions.compact {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 60px;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.action-btn:hover {
    background: #f5f5f5;
    border-color: #4a90d9;
    color: #4a90d9;
}

.action-btn.danger {
    color: #e74c3c;
    border-color: #f5c6cb;
}

.action-btn.danger:hover {
    background: #ffebee;
    border-color: #e74c3c;
}

.action-btn.wechat {
    color: #07c160;
    border-color: #c8e6c9;
    background: #f1f8e9;
}

.action-btn.wechat:hover {
    background: #e8f5e9;
    border-color: #07c160;
}

/* 快捷添加按钮 - 紧凑单行 */
.detail-quick-add {
    margin-bottom: 12px;
}

.detail-quick-add.compact {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.quick-add-btn {
    flex: 1;
    min-width: 55px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-add-btn:hover {
    background: #f5f5f5;
    border-color: #4a90d9;
}

.add-icon {
    font-size: 16px;
    color: #4a90d9;
}

.add-label {
    font-size: 11px;
    color: #666;
}

/* 更多功能 - 紧凑 */
.detail-more {
    margin-bottom: 12px;
}

.detail-more.compact {
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.more-title {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    text-align: center;
    position: relative;
}

.more-title::before,
.more-title::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    background: #e0e0e0;
}

.more-title::before {
    left: 20px;
}

.more-title::after {
    right: 20px;
}

.more-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.more-actions .action-btn {
    flex: 0 1 auto;
    min-width: 120px;
}

.more-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.more-btn:hover {
    background: #f5f5f5;
    border-color: #4a90d9;
    color: #4a90d9;
}

/* 关闭按钮 */
.detail-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.detail-close:hover {
    background: #e0e0e0;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* 确保在人数统计组件之上 */
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* 节点编辑弹窗特殊样式 */
#nodeModal .modal-content {
    padding-bottom: 70px; /* 为底部悬浮按钮留出空间 */
}

#nodeModal /* 节点编辑表单行布局 */
.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.form-row.align-top {
    align-items: flex-start;
}

.row-label {
    width: 80px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
    flex-shrink: 0;
}

.row-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.row-input:focus {
    border-color: #4a90d9;
}

.row-input.readonly {
    background-color: #f8f9fa;
    color: #666;
    border-color: #eee;
    cursor: not-allowed;
}

/* 性别单选框样式 */
.radio-group {
    display: flex;
    gap: 20px;
    border: none;
    padding: 0;
    align-items: center;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.radio-item input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 12px 0;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: center;
    gap: 0;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

#nodeModal .modal-footer .btn {
    flex: 1;
    margin: 0 15px;
    height: 44px;
    border-radius: 22px;
    font-weight: bold;
    font-size: 15px;
}

#nodeModal .modal-footer .btn-secondary {
    background: #f5f5f5;
    color: #666;
}

#nodeModal .modal-footer .btn-primary {
    background: #4a90d9;
    color: white;
    box-shadow: 0 4px 10px rgba(74, 144, 217, 0.3);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-content.modal-small {
    max-width: 360px;
}

/* 删除确认弹窗：为底部悬浮按钮留出空间 */
#deleteModal .modal-content {
    padding-bottom: 70px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #f5f5f5;
    color: #333;
}

/* 个人资料编辑弹窗特定样式 */
#profileEditModal .modal-content {
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 性别选项样式 */
.gender-option-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gender-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gender-option span {
    font-size: 16px;
    color: #333;
}

.gender-option .check-icon {
    display: none;
    width: 18px;
    height: 18px;
    position: relative;
}
.gender-option .check-icon::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    transform: rotate(45deg);
}

.gender-option.active {
    background: #eef6ff;
    border-color: var(--primary-color);
}

.gender-option.active .check-icon {
    display: block;
}

.gender-option:active {
    transform: scale(0.98);
}

.role-check {
    display: inline-block;
    width: 18px;
    height: 18px;
    position: relative;
    vertical-align: middle;
    margin-left: 8px;
}
.role-check::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    transform: rotate(45deg);
}

#profileEditModal .modal-body {
    padding: 24px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 120px; /* 设置最小高度，防止遮挡 */
}

#profileEditModal .modal-footer {
    position: static; /* 覆盖通用样式的 absolute */
    padding: 10px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

#profileEditModal select, 
#profileEditModal textarea,
#profileEditModal input[type="text"] {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8.8L1.2 4h9.6L6 8.8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px !important;
    outline: none;
    transition: border-color 0.2s;
}

#profileEditModal select:focus,
#profileEditModal textarea:focus,
#profileEditModal input[type="text"]:focus {
    border-color: var(--primary-color);
}

#profileEditModal textarea,
#profileEditModal input[type="text"] {
    background-image: none;
    padding-right: 12px !important;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

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

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

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-group .required {
    color: var(--danger-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 250;
}

/* 仅查看此分支提示 */
.view-branch-notice {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(74, 144, 217, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1001;
    font-size: 14px;
}

.view-branch-notice button {
    padding: 6px 12px;
    border: 1px solid white;
    background: transparent;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-branch-notice button:hover {
    background: white;
    color: var(--primary-color);
}

/* ========== 聊天室样式已移至 pages.css ========== */

.page-container,
#chatPage,
#profilePage {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 56px; /* 减去底部导航栏高度 */
    display: none;
    flex-direction: column;
    background-color: #f5f5f5;
    z-index: 10;
}

.page-container.active,
#chatPage.active,
#profilePage.active {
    display: flex !important;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    background-color: #ededed;
    border-bottom: 1px solid #dcdcdc;
    padding: 0 15px;
    flex-shrink: 0;
}

.chat-tabs {
    display: flex;
    gap: 20px;
    flex: 1;
    justify-content: center;
}

.chat-tabs .tab {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.chat-tabs .tab:hover {
    background-color: #e0e0e0;
}

.chat-tabs .tab.active {
    background-color: #4CAF50;
    color: white;
}

.header-left,
.header-right {
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-title {
    flex: 1;
    text-align: center;
}

.header-title h1 {
    font-size: 17px;
    font-weight: 500;
    color: #000;
    margin: 0;
}

.room-select-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}

.room-select-btn:active {
    opacity: 0.6;
}

/* 聊天室列表侧边栏 */
.room-list-sidebar {
    position: fixed;
    top: 50px;
    left: -280px;
    width: 280px;
    height: calc(100vh - 106px);
    background-color: #fff;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.room-list-sidebar.show {
    left: 0;
}

.room-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    padding: 0 15px;
    background-color: #ededed;
    border-bottom: 1px solid #dcdcdc;
}

.room-list-header h2 {
    font-size: 17px;
    font-weight: 500;
    color: #000;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #000;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:active {
    opacity: 0.6;
}

.room-list {
    overflow-y: auto;
    height: calc(100% - 50px);
}

.room-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.room-item:active {
    background-color: #f5f5f5;
}

.room-item.active {
    background-color: #e8f4ff;
}

.room-icon {
    width: 45px;
    height: 45px;
    border-radius: 6px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-right: 12px;
    flex-shrink: 0;
}

.room-info {
    flex: 1;
    overflow: hidden;
}

.room-name {
    font-size: 16px;
    color: #000;
    margin-bottom: 4px;
    font-weight: 500;
}

.room-type {
    font-size: 13px;
    color: #999;
}

/* 聊天室消息样式 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f5f5f5;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 系统消息居中显示 */
.chat-system-message {
    display: flex;
    justify-content: center;
    margin: 10px 0;
    width: 100%;
}

.system-message-content {
    background: rgba(0, 0, 0, 0.06);
    color: #888;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 12px;
    max-width: 85%;
    text-align: center;
    line-height: 1.5;
}

.chat-notification-message {
    margin: 12px 16px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
}

.notification-message-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.notification-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-right: 6px;
    flex-shrink: 0;
}

.notification-sender {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-right: 8px;
}

.notification-date {
    font-size: 11px;
    color: #999;
}

.notification-message-content {
    font-size: 14px;
    color: #333;
    line-height: 1.6;
    word-break: break-word;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
    width: 100%;
}

.chat-message.other {
    flex-direction: row;
    justify-content: flex-start;
}

.chat-message.self {
    flex-direction: row-reverse;
    justify-content: flex-start; /* 因为是 row-reverse，所以这里 start 实际是靠右 */
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-message.other .chat-avatar {
    margin-right: 10px;
}

.chat-message.self .chat-avatar {
    margin-left: 10px;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chat-message.self .chat-message-content {
    align-items: flex-end !important;
}

.chat-message-name {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.chat-message-bubble {
    background-color: #fff;
    border-radius: 6px;
    padding: 10px 14px;
    position: relative;
    word-wrap: break-word;
}

.chat-message.self .chat-message-bubble {
    background-color: #95ec68;
    border: 1px solid #8ad862;
}

.message-text {
    font-size: 15px;
    color: #000;
    line-height: 1.5;
}

.chat-message-time {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* 聊天输入区域 */
.chat-input-area {
    background-color: #f7f7f7;
    border-top: 1px solid #e5e5e5;
    padding: 10px 15px;
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    align-items: center; /* 垂直居中对齐 */
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    -webkit-flex-shrink: 0; /* iOS 兼容 */
}

.chat-input {
    flex: 1;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 120px;
    height: 40px; /* 初始高度 */
    min-height: 40px; /* 最小高度 */
    line-height: 1.5;
    -webkit-appearance: none; /* 移除 iOS 默认样式 */
    -webkit-box-sizing: border-box; /* iOS 盒模型 */
    box-sizing: border-box;
    overflow-y: auto; /* 允许垂直滚动 */
    display: block; /* 确保正确显示 */
    margin: 0; /* 移除默认外边距 */
}

.chat-input:focus {
    border-color: #4CAF50;
}

.chat-send-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 56px;
    transition: background-color 0.2s;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background-color: #45a049;
}

.chat-send-btn:active {
    opacity: 0.6;
}

/* 消息列表区域 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f5f5f5;
}

.messages-wrapper {
    display: flex;
    flex-direction: column;
}

.message-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
}

.message-item.self {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    margin: 0 10px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-item.self .message-content {
    align-items: flex-end;
}

.message-nickname {
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 6px;
    position: relative;
    word-wrap: break-word;
}

.message-item.other .message-bubble {
    background-color: #fff;
    border: 1px solid #e5e5e5;
}

.message-item.self .message-bubble {
    background-color: #95ec68;
    border: 1px solid #8ad862;
}

.message-text {
    font-size: 15px;
    color: #000;
    line-height: 1.5;
}

.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* 消息输入区域 */
.message-input-area {
    background-color: #f7f7f7;
    border-top: 1px solid #e5e5e5;
    padding: 10px 15px;
    flex-shrink: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background-color: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    border: 1px solid #e5e5e5;
}

.message-textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    font-family: inherit;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    padding: 0;
    margin: 0;
}

.message-textarea::placeholder {
    color: #999;
}

.send-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #07c160;
    flex-shrink: 0;
}

.send-btn:active {
    opacity: 0.6;
}

.send-btn svg {
    width: 28px;
    height: 28px;
}

/* 底部导航栏 */
/* 空状态样式 */
.tree-empty-state #canvasContainer {
    background-color: #f1f5f9 !important;
    filter: grayscale(1);
    opacity: 0.6;
}

.tree-empty-state .toolbar,
.tree-empty-state .zoom-controls {
    display: none !important;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background: white;
    display: flex;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: #94a3b8;
    position: relative;
    padding: 0;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.nav-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.icon-active {
    display: none;
}

.nav-item.active .icon-normal {
    display: none;
}

.nav-item.active .icon-active {
    display: block;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
}

.nav-unread-dot {
    position: absolute;
    top: 8px;
    right: calc(50% - 12px);
    width: 8px;
    height: 8px;
    background: var(--danger-color);
    border-radius: 50%;
    border: 2px solid white;
}

.nav-profile-dot {
    display: none;
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #ff3b30;
    border-radius: 50%;
    border: 2px solid white;
}

/* 顶部工具栏图标 */
.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toolbar-btn img {
    filter: brightness(0) invert(1); /* 将 SVG 图标变为白色以适配深色工具栏 */
}

/* 响应式适配 */
@media (max-width: 768px) {
    .header {
        padding: 0 10px;
    }
    
    .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .generation-ruler {
        width: 35px;
    }
    
    .ruler-word {
        font-size: 14px;
    }
    
    /* 聊天室移动端适配 */
    .chat-input {
        font-size: 16px; /* 防止 iOS 自动缩放 */
        height: 44px; /* 稍大一点，方便触摸 */
    }
    
    .chat-send-btn {
        padding: 8px 16px;
        font-size: 15px;
        min-width: 60px;
    }
    
    :root {
        --node-width: 100px;
        --node-height: 60px;
        --generation-gap: 100px;
        --sibling-gap: 30px;
    }
}

/* 隐藏文件输入 */
input[type="file"] {
    padding: 8px 0;

}

/* ========== 私信相关样式 ========== */

/* 用户资料弹窗 */
.user-profile-modal {
    background: var(--bg-color);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#userProfileModal {
    z-index: 12000;
}

.user-profile-header {
    position: relative;
    height: 120px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.5);
}

.user-profile-content {
    padding: 30px 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.user-profile-avatar {
    width: 100px;
    height: 100px;
    margin: -70px auto 15px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--bg-color);
    background: white;
    position: relative;
    z-index: 10;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.user-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-profile-nickname {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 8px 0;
}

.user-profile-gender {
    font-size: 14px;
    color: var(--secondary-text);
    margin: 0 0 12px 0;
}

.user-profile-bio {
    font-size: 14px;
    color: var(--secondary-text);
    line-height: 1.6;
    margin: 0 0 20px 0;
    min-height: 40px;
}

.user-profile-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.user-profile-actions .btn {
    flex: 1;
    max-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* 私信会话列表 */
.private-conversations-list {
    background: var(--bg-color);
}

.private-conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.private-conversation-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.private-conversation-item.unread {
    background: rgba(66, 133, 244, 0.05);
}

.conversation-avatar {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conversation-avatar .unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-nickname {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
}

.conversation-time {
    font-size: 12px;
    color: var(--secondary-text);
}

.conversation-last-message {
    font-size: 13px;
    color: var(--secondary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.private-conversation-item.unread .conversation-last-message {
    color: var(--text-color);
    font-weight: 500;
}

/* 私信消息状态 */
.chat-message-status {
    font-size: 11px;
    color: var(--secondary-text);
    margin-top: 4px;
    text-align: right;
}

/* 私信聊天界面 */
.private-chat-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.private-chat-back {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-color);
    margin-right: 10px;
}

.private-chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

/* 我的私信入口角标 */
.private-message-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    display: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .user-profile-modal {
        width: 95%;
        max-width: 350px;
    }
    
    .user-profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .user-profile-nickname {
        font-size: 18px;
    }
    
    .conversation-avatar {
        width: 45px;
        height: 45px;
    }
}

/* ========== 新的统一聊天列表样式 ========== */

/* 聊天列表页面 */
.chat-list-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-list-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    flex-shrink: 0;
}

.chat-list-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

/* 聊天列表项 */
.chat-list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.chat-list-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.chat-list-item.unread {
    background: rgba(66, 133, 244, 0.05);
}

.chat-list-avatar {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 10px; /* 圆角方形 */
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid #eee; /* 1px 边框 */
    box-sizing: border-box;
}

.chat-list-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px; /* 圆角方形 */
}

/* 底部导航未读红点 */
.nav-unread-dot {
    position: absolute !important;
    top: 5px !important;
    left: 55% !important;
    width: 8px !important;
    height: 8px !important;
    background-color: #ff3b30 !important;
    border-radius: 50% !important;
    border: 1.5px solid white !important;
    z-index: 100 !important;
}

.chat-list-avatar .chat-type-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-list-info {
    flex: 1;
    min-width: 0;
}

.chat-list-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-list-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
}

.chat-list-time {
    font-size: 12px;
    color: var(--secondary-text);
}

.chat-list-last-message {
    font-size: 13px;
    color: var(--secondary-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chat-list-last-message-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-mute-icon {
    font-size: 12px;
    opacity: 0.6;
}

/* 长按菜单样式 */
.chat-context-menu {
    position: fixed; /* 确保固定定位 */
    background: white;
    border-radius: 12px; /* 更圆润的圆角 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.25); /* 更深的阴影增强悬浮感 */
    z-index: 2000; /* 确保在最顶层 */
    min-width: 200px; /* 增加宽度 */
    overflow: hidden;
    border: 1px solid #eee;
}

.chat-context-menu .menu-item {
    padding: 16px 20px; /* 增加点击区域 */
    font-size: 16px; /* 增大字号方便移动端点击 */
    color: #333;
    cursor: pointer;
    text-align: center; /* 居中文字 */
    transition: background 0.2s;
}

.chat-context-menu .menu-item:hover {
    background: #f5f5f5;
}

.chat-context-menu .menu-item.danger {
    color: #ff3b30;
}

.chat-context-menu .menu-item:not(:last-child) {
    border-bottom: 1px solid #eee;
}

.chat-list-item.muted {
    opacity: 0.8;
}

.chat-list-item.muted .chat-list-unread-badge {
    display: none !important;
}

/* 聊天页头部按钮 */
.chat-header-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-header-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* 聊天成员列表样式 - 网格排列 */
.chat-member-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 移动端默认 4 列 */
    gap: 15px 8px;
    padding: 10px 5px;
}

@media (min-width: 480px) {
    .chat-member-list {
        grid-template-columns: repeat(5, 1fr); /* 较宽屏幕显示 5 列 */
    }
}

.chat-member-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chat-member-item:hover {
    background: #f0f0f0;
}

.chat-member-avatar {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #eee;
    background: #fff;
}

.chat-member-info {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-member-name {
    font-size: 12px;
    font-weight: 400;
    color: #333;
    line-height: 1.3;
    width: 100%;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 32px; /* 固定高度确保对齐 */
}

.chat-member-role {
    font-size: 10px;
    color: #fff;
    background: #ccc;
    padding: 1px 4px;
    border-radius: 4px;
    margin-top: 2px;
    transform: scale(0.9);
}

/* 特殊角色颜色 */
.chat-member-role.role-founder { background: #ff9500; }
.chat-member-role.role-admin { background: #5856d6; }
.chat-member-role.role-member { display: none; } /* 普通成员不显示标签以节省空间 */

.chat-list-item.unread .chat-list-last-message {
    color: var(--text-color);
    font-weight: 500;
}

.chat-list-unread-badge {
    background-color: #ff3b30 !important;
    color: white !important;
    border-radius: 10px !important;
    padding: 0 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    min-width: 18px !important;
    height: 18px !important;
    line-height: 18px !important;
    text-align: center !important;
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    z-index: 100 !important;
    border: 1.5px solid #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* 聊天对话页面头部 */
.chat-conversation-header {
    display: flex;
    align-items: center;
    height: 50px;
    background-color: #ededed;
    border-bottom: 1px solid #dcdcdc;
    padding: 0 15px;
    flex-shrink: 0;
}

.chat-conversation-header .btn-back {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #000;
    padding: 5px 8px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    width: auto;
    min-width: 50px;
    text-align: left;
    font-family: inherit;
}

.chat-conversation-header .chat-header-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 500;
    color: #000;
    margin: 0;
}

/* 聊天对话容器 */
#chatConversationPage {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-conversation-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

/* 聊天消息区域 */
.chat-conversation-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.chat-session-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* 输入区域 */
.chat-conversation-input-area {
    display: flex;
    align-items: center; /* 改为居中对齐 */
    background-color: #fff;
    border-top: 1px solid #dcdcdc;
    padding: 10px 15px;
    flex-shrink: 0;
    gap: 12px; /* 增加间距 */
}
