/* 无障碍：跳过导航链接，仅聚焦时可见 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.sr-only:focus {
    position: fixed;
    width: auto;
    height: auto;
    padding: 0.5rem 0.75rem;
    margin: 0;
    clip: auto;
    z-index: 9999;
}

/* 手机端：当前家族下拉不撑破界面，选中项过长时省略显示 */
.family-select {
    max-width: 100%;
}
@media (max-width: 640px) {
    .family-select {
        min-width: 0;
        width: 100%;
    }
}

/* 手机端：搜索框不撑破容器 */
.search-input-mobile {
    max-width: 100%;
}
@media (max-width: 640px) {
    .search-input-mobile {
        min-width: 0;
    }
}

/* 可搜索下拉选择器 */
.searchable-select {
    position: relative;
}
.searchable-select-input {
    cursor: text;
}
.searchable-select-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 2px;
}
.searchable-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f3f4f6;
}
.searchable-select-option:last-child {
    border-bottom: none;
}
.searchable-select-option:hover,
.searchable-select-option.highlighted {
    background: #eef2ff;
    color: #4f46e5;
}
.searchable-select-option.selected {
    background: #e0e7ff;
    font-weight: 600;
}
.searchable-select-empty {
    padding: 12px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}
.searchable-select-hint {
    padding: 8px 12px;
    font-size: 12px;
    color: #d97706;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* 列表页标题最多 2 行，超出省略 */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 族谱关系图：层级与连线 */
#tree-canvas {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    min-height: 400px;
}

.tree-generation-label {
    margin-top: 20px;
    margin-bottom: 12px;
}
.tree-generation-label:first-child {
    margin-top: 0;
}
.tree-generation-label {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.tree-generation-badge {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border-radius: 9999px;
    letter-spacing: 0.05em;
}
.tree-generation-stats {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
    flex-wrap: wrap;
}
.tree-gen-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.tree-gen-stat--male {
    color: #3b82f6;
}
.tree-gen-stat--female {
    color: #ec4899;
}
.tree-gen-stat--sons {
    color: #2563eb;
}
.tree-gen-stat--daughters {
    color: #db2777;
}
.tree-gen-stat--inlaw-wives {
    color: #7c3aed;
}
.tree-gen-stat--inlaw-husbands {
    color: #4f46e5;
}
.tree-gen-stat--other {
    color: #94a3b8;
}
.tree-gen-detail {
    font-size: 11px;
    margin-left: 4px;
    color: #64748b;
    font-weight: normal;
}
.tree-generation-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    position: relative;
}
.tree-node {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
}
.tree-node-couple {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.tree-couple-link {
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, #a78bfa, #ec4899);
    border-radius: 1px;
    flex-shrink: 0;
}
.tree-node-children {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    padding-left: 20px;
    border-left: 2px solid #c7d2fe;
    margin-left: 8px;
}
.tree-card {
    background: #fff;
    border-width: 2px;
    border-radius: 12px;
    padding: 12px 14px;
    min-width: 160px;
    max-width: 280px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}
.tree-card:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}
.tree-card--compact {
    min-width: 120px;
    max-width: 200px;
    padding: 8px 12px;
}
.tree-card--compact .tree-card-dot {
    width: 6px;
    height: 6px;
}
.tree-card-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tree-card-gender-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tree-card-gender {
    font-size: 0.75rem;
}
.tree-card--compact .tree-card-gender {
    font-size: 0.625rem;
}
.tree-card-actions {
    opacity: 0;
    transition: opacity 0.2s;
}
.tree-card:hover .tree-card-actions {
    opacity: 1;
}
.tree-card-actions button {
    background: none;
    border: none;
    cursor: pointer;
}

/* 层次类型切换按钮 */
.tree-view-btn {
    background: transparent;
    color: #64748b;
    border: none;
    cursor: pointer;
}
.tree-view-btn:hover {
    color: #334155;
}
.tree-view-btn--active {
    background: #4f46e5;
    color: #fff;
}
.tree-view-btn--active:hover {
    color: #fff;
}

/* 按分支：整棵分支树 */
.tree-branch-root {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}
.tree-branch {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    background: #fff;
}
.tree-branch-title {
    font-weight: 700;
    color: #4338ca;
    margin-bottom: 4px;
    font-size: 14px;
}
.tree-branch-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e7ff;
}
.tree-branch-stats .tree-gen-stat--male {
    color: #3b82f6;
}
.tree-branch-stats .tree-gen-stat--female {
    color: #ec4899;
}
.tree-branch-stats .tree-gen-stat--other {
    color: #94a3b8;
}
.tree-branch-node {
    margin-left: 0;
}
.tree-branch-couple {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.tree-branch-toggle {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #e0e7ff;
    color: #4f46e5;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.tree-branch-toggle:hover {
    background: #c7d2fe;
}
.tree-branch-toggle--empty {
    background: transparent;
    cursor: default;
}
.tree-branch-children {
    margin-top: 12px;
    padding-left: 28px;
    border-left: 2px solid #c7d2fe;
    margin-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tree-branch-children--collapsed {
    display: none;
}

/* 搜索高亮 */
mark {
    background-color: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
}

/* 打印样式 */
@media print {
    .no-print, button, .tree-card-actions {
        display: none !important;
    }
    .tree-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* 第1世与后续世视觉区分 */
.tree-generation-row .tree-node:first-child .tree-card {
    border-width: 2px;
}
.tree-generation-label + .tree-generation-row .tree-node .tree-node-children {
    border-left-color: #818cf8;
}

/* 自定义样式 */
#tree-view {
    padding: 20px;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Toast 提示 */
@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
.animate-slide-in {
    animation: slide-in 0.3s ease-out;
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* 适配移动端 */
@media (max-width: 768px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    #tree-canvas {
        padding: 10px;
        min-height: 300px;
    }
    .tree-generation-row {
        gap: 10px;
        flex-direction: column;
    }
    .tree-card {
        min-width: 100%;
        max-width: 100%;
        padding: 10px 12px;
    }
    .tree-card--compact {
        min-width: 100%;
        padding: 8px 10px;
    }
    .tree-node-children {
        padding-left: 10px;
        margin-left: 4px;
        width: 100%;
    }
    .tree-view-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .tree-branch-children {
        padding-left: 12px;
        margin-left: 6px;
    }
    .tree-generation-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .tree-generation-stats {
        flex-wrap: wrap;
        font-size: 12px;
    }
    .tree-node-couple {
        flex-direction: column;
        align-items: flex-start;
    }
    .tree-couple-link {
        width: 2px;
        height: 20px;
        margin: 4px 0;
    }
}

@media (max-width: 640px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    #tree-canvas {
        padding: 8px;
    }
    .tree-card {
        font-size: 13px;
    }
    .tree-card h4 {
        font-size: 14px;
    }
    .tree-card p {
        font-size: 11px;
    }
}

/* 人物小传富文本：详情弹层内展示 */
.biography-content {
    word-break: break-word;
}
.biography-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}
.biography-content p {
    margin: 0.25em 0;
}
.biography-content p:first-child {
    margin-top: 0;
}
.biography-content p:last-child {
    margin-bottom: 0;
}

/* Quill 编辑器在弹层内 */
#m-bio-editor.ql-container {
    min-height: 120px;
    border-radius: 0.5rem;
}
#member-modal .ql-toolbar.ql-snow {
    border-radius: 0.5rem 0.5rem 0 0;
}
#member-modal .ql-container.ql-snow {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* ========== 祭拜模态框（墓碑风格） ========== */
.memorial-modal-inner {
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border: 1px solid #4a5568;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.memorial-tombstone {
    padding: 2rem 1.5rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}
.memorial-plaque {
    background: linear-gradient(145deg, #4a5568 0%, #2d3748 50%, #1a202c 100%);
    border: 2px solid #718096;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    min-width: 220px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
}
.memorial-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
}
.memorial-dates {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 0.75rem;
}
.memorial-rest {
    font-size: 1rem;
    color: #c6a227;
    letter-spacing: 0.2em;
    font-weight: 500;
}
.memorial-actions {
    padding: 0 1.5rem 1rem;
}
.memorial-actions-title {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 0.75rem;
    text-align: center;
}
.memorial-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.memorial-btns--disabled {
    opacity: 0.6;
    pointer-events: none;
}
.memorial-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
    border: 1px solid #718096;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.memorial-btn:hover {
    background: linear-gradient(180deg, #5a6578 0%, #3d4758 100%);
    border-color: #a0aec0;
    color: #fff;
    transform: translateY(-1px);
}
.memorial-btn i {
    font-size: 1rem;
}
.memorial-count {
    background: #c6a227;
    color: #1a202c;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    min-width: 1.2rem;
    text-align: center;
}
.memorial-stats {
    padding: 0 1.5rem 1rem;
    font-size: 0.8rem;
    color: #a0aec0;
    text-align: center;
}
.memorial-logs {
    padding: 0 1.5rem 1rem;
    border-top: 1px solid #4a5568;
}
.memorial-logs-title {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 0.5rem;
}
.memorial-logs-list {
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.8rem;
    color: #cbd5e0;
}
.memorial-logs-list::-webkit-scrollbar {
    width: 6px;
}
.memorial-logs-list::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 3px;
}
.memorial-logs-list .memorial-log-item {
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(74, 85, 104, 0.5);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
.memorial-logs-list .memorial-log-item:last-child {
    border-bottom: none;
}
.memorial-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
}
.memorial-close-btn {
    padding: 0.5rem 2rem;
    background: #4a5568;
    border: 1px solid #718096;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.memorial-close-btn:hover {
    background: #5a6578;
    color: #fff;
}
/* 祭拜图标（成员卡片） */
.tree-card .memorial-icon-btn {
    color: #8b7355;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}
.tree-card .memorial-icon-btn:hover {
    color: #c6a227;
    background: rgba(198, 162, 39, 0.15);
}
