/* 族谱树选中卡片高亮 */
.member-card.card-selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 6px 20px rgba(158, 32, 32, 0.25);
}
/* 手机端：取消选中卡片的红框 */
@media (max-width: 900px) {
    .member-card.card-selected {
        outline: none !important;
        box-shadow: none !important;
    }
}

/* 绑定按钮：朱砂红渐变（与编辑/删除同属 overlay 按钮体系） */
.card-bind-btn {
    background: linear-gradient(135deg, #9E2020 0%, #7A1818 100%);
    border: 1px solid #fff;
}

/* 卡片内覆盖按钮（编辑/删除）：foreignObject 内的 HTML 按钮 */
.card-overlay-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #fff !important;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: opacity .15s, transform .15s;
    opacity: .92;
    font-family: inherit;
}
.card-overlay-btn:hover { opacity: 1; transform: scale(1.05); }
.card-overlay-btn span { line-height: 1; white-space: nowrap; }

/* 编辑按钮：靛蓝色 */
.card-edit-btn {
    background: #2c5282;
    border: 1px solid #fff;
}
/* 删除按钮：朱砂红 */
.card-delete-btn {
    background: #c0392b;
    border: 1px solid #fff;
}
/* 详情按钮：米黄色（古卷风格），配合族谱树调性 */
.card-detail-btn {
    background: linear-gradient(135deg, #8b6914 0%, #6b4f0e 100%);
    border: 1px solid #fff;
    color: #fff;
}

/* 4方向添加按钮：长方形 */
.card-dir-btn {
    width: 100%;
    height: 100%;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(158, 32, 32, 0.3);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
    border: 1px solid #fff;
    font-family: inherit;
}
.card-dir-btn:hover {
    transform: scale(1.08);
    background: var(--primary-dark);
    box-shadow: 0 3px 10px rgba(158, 32, 32, 0.45);
}
.card-dir-btn .dir-label {
    font-size: 11px;
    line-height: 1;
    letter-spacing: .5px;
    font-weight: 600;
    white-space: nowrap;
}

/* 添加关系弹窗样式 */
.node-modal-inner { padding: 14px 18px !important; }
.gen-text { display:flex; align-items:center; min-height: 39px; font-size: 13px; color: var(--primary-dark); font-weight: 600; padding: 5px 9px; background: #f5f0e6; border-radius: 4px; border: 1px solid var(--border); box-sizing: border-box; line-height: 1.4; }
.add-modal-head {
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 8px;
}
.add-modal-head h4 {
    margin: 0 0 1px 0;
    color: var(--primary);
    font-size: 16px;
}
.add-modal-sub {
    margin: 0;
    color: var(--text-light);
    font-size: 12px;
}
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.form-row { display: flex; flex-direction: column; gap: 3px; }
.form-row-2col { flex-direction: row; gap: 10px; }
.form-row-2col > div { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.form-row-actions {
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}
.form-input, .form-textarea {
    width: 100%;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(158, 32, 32, 0.12);
}
.form-textarea { resize: vertical; min-height: 44px; }
.form-radio-group {
    display: flex !important;
    gap: 16px;
    padding: 2px 0;
}
.form-radio {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 0 !important;
    white-space: nowrap;
}
.form-radio input[type="radio"] {
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
    appearance: auto !important;
    -webkit-appearance: auto !important;
}
.add-modal-msg {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 14px;
}
.add-modal-msg.is-err { background: #fdecea; color: #c0392b; border: 1px solid #f5c2be; }
.add-modal-msg.is-ok { background: #eafaf1; color: #2e7d32; border: 1px solid #b7e4c7; }

/* ===== 手机端：成员卡片操作功能卡片（顶部浮动、最上层） ===== */
/* 仅在手机端生效，PC 端不会出现 .mobile-action-card 元素 */
@media (max-width: 900px) {
    .mobile-action-card {
        position: fixed;
        /* top: 72px 硬编码已废弃；导航高度随断点变化（PC 72px，900↓ 双行约 62px，
           宽屏/动态还会变），改为 JS 实时写入 .site-header.getBoundingClientRect().height。
           这里只留默认兜底值（0），不参与最终定位。 */
        top: 0;
        left: 0;
        right: 0;
        z-index: 10001; /* 高于导航 z-index:10000，确保卡片完整露出、不被当前行/导航遮挡 */
        background: #FFFBF5;
        border: 1px solid var(--primary);
        border-top: none;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
        font-family: var(--serif);
        overflow: hidden;
        animation: mobileActionCardDrop .18s ease-out;
    }
    @keyframes mobileActionCardDrop {
        from { transform: translateY(-100%); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }
    .mobile-action-card-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 8px 12px;
        background: linear-gradient(135deg, #9E2020 0%, #7A1818 100%);
        color: #fff;
    }
    .mobile-action-card-title {
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 1px;
        line-height: 1.3;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .mobile-action-card-close {
        flex-shrink: 0;
        width: 26px;
        height: 26px;
        border: none;
        background: rgba(255, 255, 255, 0.18);
        color: #fff;
        font-size: 20px;
        line-height: 1;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-family: inherit;
    }
    .mobile-action-card-body {
        padding: 8px 10px 10px;
    }
    .mobile-action-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 8px;
    }
    .mobile-action-row:last-child { margin-bottom: 0; }
    .mobile-action-row-dir {
        padding-top: 8px;
        border-top: 1px dashed var(--border);
    }
    /* 浮动卡片内按钮：流式布局，覆盖原始 absolute 定位与尺寸 */
    .mobile-action-card .mobile-action-btn {
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        min-width: 64px;
        height: 32px !important;
        flex: 1 1 auto;
        padding: 0 12px;
        border-radius: 6px;
        font-size: 13px;
    }
    .mobile-action-card .card-dir-btn {
        box-shadow: none;
    }
    .mobile-action-card .card-dir-btn .dir-label {
        font-size: 13px;
        letter-spacing: 1px;
    }

    /* ===== 手机端：展开面板（替代模态框） ===== */
    .mobile-expand-panel {
        display: none;
        background: #FAF6ED;
        border-top: 1px solid var(--border);
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mobile-expand-panel.panel-expanded {
        display: block;
    }
    .mobile-expand-panel::-webkit-scrollbar {
        width: 3px;
    }
    .mobile-expand-panel::-webkit-scrollbar-thumb {
        background: rgba(158,32,32,0.3);
        border-radius: 2px;
    }

    /* 面板头部 */
    .mobile-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 8px 12px;
        background: linear-gradient(135deg, #9E2020 0%, #7A1818 100%);
        color: #fff;
        flex-shrink: 0;
    }
    .mobile-panel-title {
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 1px;
        line-height: 1.3;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #fff;
    }
    .mobile-panel-close {
        flex-shrink: 0;
        width: 26px;
        height: 26px;
        border: none;
        background: rgba(255, 255, 255, 0.18);
        color: #fff;
        font-size: 18px;
        line-height: 1;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-panel-close:active {
        background: rgba(255, 255, 255, 0.3);
    }

    /* 面板内容 */
    .mobile-expand-panel > div:not(.mobile-panel-head) {
        padding: 10px 12px 16px;
    }

    /* 子标题 */
    .mobile-panel-sub {
        font-size: 12px;
        color: var(--text);
        margin: 0 0 4px;
        line-height: 1.4;
    }
    .mobile-panel-sub strong {
        color: var(--primary);
    }
    .mobile-panel-rel {
        color: var(--primary);
        font-weight: 600;
    }

    /* 关系描述 */
    .mobile-panel-reldes {
        font-size: 11px;
        color: #666;
        margin: 0 0 8px;
        padding: 5px 8px;
        background: rgba(158,32,32,0.06);
        border-radius: 4px;
        border-left: 2px solid var(--primary);
        line-height: 1.4;
    }

    /* 消息提示 */
    .mobile-panel-msg {
        display: none;
        margin: 0 0 8px;
        padding: 6px 10px;
        border-radius: 5px;
        font-size: 12px;
        line-height: 1.4;
        background: #f8f4e9;
        border: 1px solid #e5ddc8;
        color: var(--text);
    }
    .mobile-panel-msg.is-err {
        background: #fdecea;
        border-color: #f5c2be;
        color: #c0392b;
    }
    .mobile-panel-msg.is-ok {
        background: #e8f5e9;
        border-color: #a5d6a7;
        color: #2e7d32;
    }

    /* 表单行 */
    .mobile-form-row {
        margin-bottom: 8px;
    }
    .mobile-form-label {
        display: block;
        font-size: 12px;
        font-weight: 600;
        color: var(--text);
        margin-bottom: 3px;
    }
    .mobile-form-content {
        width: 100%;
    }
    .mobile-input {
        width: 100%;
        padding: 7px 10px;
        border: 1px solid #d5cdb8;
        border-radius: 5px;
        font-size: 16px;
        color: var(--text);
        background: #FFFBF5;
        font-family: inherit;
        box-sizing: border-box;
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 2px rgba(158,32,32,0.15);
    }
    .mobile-input::placeholder {
        color: #aaa;
    }
    .mobile-textarea {
        min-height: 60px;
        resize: vertical;
    }

    /* 单选按钮 */
    .mobile-radio {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin-right: 14px;
        font-size: 13px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-radio input[type="radio"] {
        width: 16px;
        height: 16px;
        accent-color: var(--primary);
    }

    /* 世代/字辈显示 */
    .mobile-gen-display {
        padding: 7px 10px;
        background: rgba(158,32,32,0.05);
        border-radius: 5px;
        font-size: 13px;
        color: var(--text);
        border: 1px dashed #d5cdb8;
    }

    /* 农历日期 */
    .mobile-lunar {
        line-height: 1.4;
    }

    /* 日期输入组 */
    .mobile-date-wrap {
        width: 100%;
    }
    .mobile-date-input {
        width: 100%;
    }
    .mobile-date-input::-webkit-calendar-picker-indicator {
        opacity: 0.6;
        cursor: pointer;
    }
    .mobile-date-input:empty {
        color: #999;
    }
    .mobile-date-hint {
        font-size: 11px;
        color: #b58a34;
        margin-top: 4px;
        line-height: 1.4;
    }

    .mobile-form-content .mobile-date-input {
        width: 100%;
        min-height: 36px;
    }
    .mobile-form-content .mobile-lunar {
        display: block;
        margin-top: 2px;
    }
    .mobile-form-content .mobile-date-hint {
        display: block;
        margin-top: 4px;
    }

    /* 面板按钮 */
    .mobile-panel-btns {
        display: flex;
        gap: 8px;
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid #e5ddc8;
    }
    .mobile-btn {
        flex: 1;
        padding: 9px 14px;
        border: none;
        border-radius: 5px;
        font-size: 14px;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-btn:active {
        transform: scale(0.97);
    }
    .mobile-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }
    .mobile-btn-cancel {
        background: #fff;
        border: 1px solid #d5cdb8;
        color: var(--text);
    }
    .mobile-btn-cancel:active {
        background: #f8f4e9;
    }
    .mobile-btn-primary {
        background: var(--primary);
        color: #fff;
    }
    .mobile-btn-primary:active {
        background: #7A1818;
    }
    .mobile-btn-danger {
        background: #c0392b;
        color: #fff;
    }
    .mobile-btn-danger:active {
        background: #a93226;
    }

    /* 删除面板 */
    .mobile-panel-delete .mobile-panel-body {
        padding: 0 0 8px;
    }
    .mobile-panel-delete-msg {
        font-size: 15px;
        margin: 0 0 8px;
        color: var(--text);
        line-height: 1.5;
        font-size: 13px;
    }
    .mobile-panel-delete-msg strong {
        color: var(--primary);
        font-size: 15px;
    }
    .mobile-panel-block {
        color: #e67e22;
        font-size: 12px;
        margin: 8px 0;
        padding: 6px 10px;
        background: rgba(230,126,34,0.1);
        border-radius: 5px;
        border-left: 3px solid #e67e22;
    }

    /* 绑定面板 */
    .mobile-panel-bind .mobile-panel-body {
        padding: 4px 0;
    }

    /* ===== 防止iOS Safari点击输入框自动放大页面 =====
         iOS Safari 在输入框字体 < 16px 时会自动放大页面，
         退出输入后不会自动缩回。统一设为 16px 解决此问题。*/
    .form-input,
    .form-textarea,
    .form-select,
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    select,
    textarea {
        font-size: 16px !important;
    }
}
