/* ==================== 设置页面样式 ==================== */
* {
    -webkit-tap-highlight-color: transparent; /* 消除移动端点击蓝色高亮 */
    outline: none; /* 消除焦点外框 */
}

.settings-container {
    --settings-toolbar-height: 60px;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100); /* 适配移动端动态视口 */
    min-height: 100dvh;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.settings-list {
    flex: 1;
    padding-bottom: 150px; /* 进一步增加底部边距，确保即使有软键盘也能滚到底 */
}

.settings-header {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    height: var(--settings-toolbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.25);
    position: fixed; /* 改为 fixed 以在页面滚动时始终悬浮 */
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.settings-header .btn-back {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.3s;
}

.settings-header .btn-back:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateX(-2px);
}

.settings-header h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
}

.settings-content {
    padding: 20px;
    padding-top: calc(var(--settings-toolbar-height) + 20px); /* 与工具栏高度保持一致 */
    flex: 1;
}

/* 设置分组样式 */
.settings-group {
    background: #fff;
    border-radius: 16px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.settings-group-title {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 设置分类样式 */
.settings-category {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f8fafc;
    position: relative;
    user-select: none;
}

.settings-category:last-child {
    border-bottom: none;
}

.settings-category:hover {
    background: #f8fafc;
}

.settings-category:active,
.settings-category.active {
    background: #f1f5f9;
}

/* 增加左侧激活条，代替可能出现的阴影效果 */
.settings-category.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #4a90d9;
}

.settings-category.danger:hover {
    background: #fef2f2;
}

.settings-category-icon {
    font-size: 28px;
    margin-right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 12px;
}

.settings-category.danger .settings-category-icon {
    background: #fef2f2;
}

.settings-category-info {
    flex: 1;
}

.settings-category-title {
    font-size: 16px;
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-category.danger .settings-category-title {
    color: #dc2626;
}

.settings-category-desc {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.settings-arrow {
    color: #cbd5e1;
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
}

/* 设置详情样式 */
.settings-detail {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    background: #f5f7fa;
    z-index: 1000;
}

.settings-detail.active {
    display: flex;
    animation: settingsSlideIn 0.25s ease-out;
}

@keyframes settingsSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.settings-detail-header {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    height: var(--settings-toolbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.25);
    position: fixed; /* 改为 fixed 确保在详情页滚动时也悬浮 */
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.settings-detail-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-detail-nav .btn-back {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 500;
    transition: all 0.3s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-detail-nav .btn-back:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateX(-2px);
}

.settings-detail-nav h2 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.settings-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-top: calc(var(--settings-toolbar-height) + 20px); /* 与工具栏高度保持一致 */
    padding-bottom: 150px; /* 进一步增加底部边距 */
    -webkit-overflow-scrolling: touch;
}

/* 字辈设置样式 */
.generation-words-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.generation-word-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.generation-number {
    min-width: 75px;
    font-size: 15px;
    color: #475569;
    font-weight: 600;
}

.generation-input {
    flex: 1;
}

.generation-input input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 500;
    outline: none;
    transition: all 0.3s;
    background: #fafafa;
}

.generation-input input:focus {
    border-color: #4a90d9;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.1);
}

.btn-remove-word {
    width: 38px;
    height: 38px;
    border: none;
    background: #fef2f2;
    border-radius: 10px;
    font-size: 22px;
    color: #dc2626;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-remove-word:hover:not(:disabled) {
    background: #fee2e2;
    transform: scale(1.1);
}

.btn-remove-word:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-add-generation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 18px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fff;
    color: #4a90d9;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 16px;
}

.btn-add-generation:hover {
    border-color: #4a90d9;
    background: rgba(74, 144, 217, 0.05);
    transform: translateY(-2px);
}

.btn-add-generation span:first-child {
    font-size: 26px;
    line-height: 1;
}

/* 表单组样式 */
.form-group {
    margin-bottom: 16px;
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #475569;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="color"],
.form-group input[type="range"],
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #4a90d9;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.1);
}

.color-picker-row {
    display: flex;
    gap: 16px;
}

.color-picker-item {
    flex: 1;
}

.color-picker-item .color-label {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 10px;
    font-weight: 500;
}

.color-picker-item input[type="color"] {
    width: 100%;
    height: 56px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
}

.readonly-field {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    color: #64748b;
    font-size: 14px;
}

/* 预览区域样式 */
.preview-section {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 20px;
}

.preview-section h3 {
    font-size: 13px;
    color: #475569;
    margin: 0 0 10px 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-canvas {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #e2e8f0;
}

/* 预览节点样式 */
.preview-parents-container {
    display: flex;
    align-items: center;
    gap: 0;
}

/* 字体外观卡片布局 */
.appearance-grid {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.appearance-card {
    flex: 1;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.appearance-card:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.appearance-card.active {
    border-color: #4a90d9;
    background: #f0f7ff;
    box-shadow: 0 0 0 1px #4a90d9;
}

.appearance-card-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.appearance-card-label {
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
}

.color-preview-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #e2e8f0;
}

.appearance-card input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}

/* 提示框美化 */
.style-tip-box {
    margin-top: 24px;
    padding: 16px 20px;
    background: #eff6ff;
    border-radius: 16px;
    border: 1px solid #dbeafe;
}

.style-tip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: #2563eb;
    font-weight: 500;
    font-size: 14px;
}

.style-tip-content {
    font-size: 13px;
    color: #3b82f6;
    line-height: 1.6;
}

/* 节点设置美化样式 */
.section-header-styled {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.accent-bar {
    width: 4px;
    height: 18px;
    background: #4a90d9;
    border-radius: 2px;
}

.section-title-text {
    font-size: 16px;
    color: #1e293b;
    font-weight: 500;
}

.range-slider-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    height: 32px;
}

.range-slider-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    width: 100%;
    height: 32px;
    background: transparent !important;
    outline: none;
    margin: 0;
    cursor: pointer;
}

/* Webkit 轨道 */
.range-slider-group input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    background: #000;
    border: none;
    border-radius: 0;
}

/* Firefox 轨道 */
.range-slider-group input[type="range"]::-moz-range-track {
    width: 100%;
    height: 1px;
    background: #000;
    border: none;
    border-radius: 0;
}

/* Webkit 滑块 */
.range-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    border: 2px solid #fff;
    margin-top: -7.5px; /* (1px - 16px) / 2 = -7.5px */
    transition: all 0.2s;
}

/* Firefox 滑块 */
.range-slider-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    border: 2px solid #fff;
    transition: all 0.2s;
    border: none;
}

.range-slider-group input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25);
}

.range-slider-group input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25);
}

.range-slider-group input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25);
}

.range-value-display {
    min-width: 40px;
    padding: 2px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    text-align: center;
}

.color-cards-row {
    display: flex;
    gap: 20px;
    margin-top: 12px;
}

.color-card-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-card-label {
    font-size: 14px;
    color: #475569;
}

.color-fill-btn {
    position: relative;
    width: 80px;
    height: 36px;
    border-radius: 6px; /* 缩小圆角，更方正 */
    border: 1.5px solid #1e293b; 
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
}

.color-fill-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.color-fill-btn input[type="color"] {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 150%;
    height: 150%;
    cursor: pointer;
    border: none;
    padding: 0;
}

.preview-node {
    width: 110px;
    height: 54px;
    border: 2px solid;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.preview-node.male {
    border-color: #4a90d9;
}

.preview-node.female {
    border-color: #e91e63;
}

.preview-node .node-name {
    font-size: 15px;
    color: #1e293b;
    font-weight: 600;
}

.preview-node .node-generation {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.preview-couple-line {
    width: 44px;
    height: 3px;
    background: #94a3b8;
}

/* 隐藏类 */
.settings-list.hidden {
    display: none;
}

/* 保存成功提示 Toast */
.save-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.save-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 成员权限管理样式 */
.permission-header {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.member-list {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.member-item:last-child {
    border-bottom: none;
}

.member-item:hover {
    background: #f8fafc;
}

.member-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f1f5f9;
    margin-right: 14px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

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

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

.member-nickname {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.member-role {
    font-size: 12px;
    color: #64748b;
}

.member-badge-me {
    font-size: 10px;
    background: #f1f5f9;
    color: #64748b;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.btn-change-role {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-change-role:hover {
    background: #357abd;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(74, 144, 217, 0.2);
}

.btn-change-role:active {
    transform: translateY(0);
}

/* 权限分配弹窗样式 */
.role-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.role-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.role-modal-content {
    position: relative;
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 1;
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html.export-progress-open,
body.export-progress-open {
    overflow: hidden !important;
    touch-action: none;
}

#exportProgressModal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 12000 !important;
    pointer-events: auto;
    overscroll-behavior: contain;
}

#exportProgressModal .modal-content {
    width: min(320px, 100%);
    max-width: 320px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes modal-pop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.role-modal-header {
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.role-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.role-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.role-modal-body {
    padding: 20px;
}

.target-user-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 12px;
}

#targetUserNickname {
    font-weight: 700;
    color: #4a90d9;
    font-size: 16px;
}

.role-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-option-card {
    padding: 16px;
    border: 2px solid #f1f5f9;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.role-option-card:hover {
    border-color: #4a90d9;
    background: #f0f9ff;
}

.role-option-card.active {
    border-color: #4a90d9;
    background: #f0f9ff;
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.15);
}

.role-option-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.role-option-desc {
    display: block;
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
}
