/* ===== 自定义字体 ===== */
@font-face {
    font-family: 'HP';
    src: url('../.fonts/hp.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'HP', 'HP Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #2c1a3d;
    color: #f0edf3;
}

/* ===== 滚动容器 ===== */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.scroll-container::-webkit-scrollbar {
    display: none;
}

/* ===== 每一页 ===== */
.page {
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
    overflow: hidden;
    background: #2c1a3d;
}

/* ===== 第1页 ===== */
.page-1 {
    justify-content: center;
    text-align: center;
}
.page-1 img {
    max-width: 260px;
    height: auto;
    display: block;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}
.page-1 .welcome-text {
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    color: #f0edf3;
    margin-bottom: 8px;
    min-height: 2.4rem;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.page-1 h1 {
    font-size: 2.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}

/* ===== 第2、4、5页 ===== */
.page-2 .page-content,
.page-4 .page-content,
.page-5 .page-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    flex-direction: column;
}
.page-4 h2,
.page-5 h2 {
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.page-4 p,
.page-5 p {
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}

/* ===== 第3页 ===== */
.page-3 {
    padding: 90px 0 60px 0;
    justify-content: center;
}
.page-3 .page-content {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    overflow: hidden;
}
.page-3 .page-content .header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    margin-bottom: 8px;
}
.page-3 .page-content h2 {
    font-weight: 400;
    font-size: 1.6rem;
    letter-spacing: 0.02em;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.page-3 .page-content .subtitle {
    color: #cdc4d9;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.admin-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
}
.admin-toolbar button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f0edf3;
    padding: 6px 16px;
    border-radius: 20px;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}
.admin-toolbar button:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* 树容器 */
.tree-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 4px 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.tree-wrapper::-webkit-scrollbar {
    width: 6px;
}
.tree-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
.tree-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 8px;
}

/* 树节点 */
.tree-node {
    margin-bottom: 2px;
}
.tree-node .node-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    user-select: none;
}
.tree-node .node-header:hover {
    background: rgba(255, 255, 255, 0.06);
}
.tree-node .node-header .toggle-icon {
    display: inline-block;
    width: 20px;
    font-size: 1rem;
    color: #b0a8c0;
    margin-right: 4px;
    text-align: center;
    flex-shrink: 0;
}
.tree-node .node-header .node-label {
    font-weight: 450;
    letter-spacing: 0.02em;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.node-header .delete-btn {
    margin-left: 12px;
    color: #f0a0a0;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
    display: none;
}
.admin-mode .node-header .delete-btn {
    display: inline-block;
}
.node-header .delete-btn:hover {
    color: #ff6b6b;
}

/* ===== 人员卡片 ===== */
.person-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px 8px 28px;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
    margin: 4px 0 4px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}
.person-card .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #4a2d5e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 1.1rem;
    color: #f0edf3;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* 首字母使用正常字体，不使用 HP 字体 */
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.person-card .info {
    flex: 1;
    min-width: 0;
}
.person-card .info .pname {
    font-weight: 500;
    font-size: 1rem;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.person-card .info .pbio {
    font-size: 0.85rem;
    color: #cdc4d9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}

/* 空缺卡片头像（? 占位） */
.person-card .avatar[style*="background:#3a2a4a"] {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* 子节点容器 */
.node-children {
    overflow: hidden;
    padding-left: 20px;
    transition: max-height 0.25s ease;
    max-height: 0;
}
.node-children.open {
    max-height: 2000px;
}
.root-node > .node-children {
    padding-left: 8px;
}

/* ===== 固定导航栏 ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 36px;
    background: transparent;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}
.navbar.visible {
    opacity: 1;
    pointer-events: auto;
}
.navbar .user-info {
    font-size: 0.9rem;
    color: #cdc4d9;
    margin-right: 20px;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.navbar .lang-toggle,
.navbar .login-link,
.navbar .register-link {
    font-size: 1rem;
    font-weight: 450;
    color: #f0edf3;
    text-decoration: none;
    margin-left: 28px;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
    letter-spacing: 0.02em;
    cursor: pointer;
    background: none;
    border: none;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.navbar .lang-toggle:hover,
.navbar .login-link:hover,
.navbar .register-link:hover {
    border-bottom-color: #f0edf3;
}
.navbar .lang-toggle {
    margin-left: 0;
    margin-right: 28px;
}
.navbar .login-link {
    margin-left: 28px;
}
.navbar .register-link {
    margin-left: 16px;
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active {
    display: flex;
}
.modal-box {
    background: #2c1a3d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 32px 40px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.modal-box h3 {
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
    font-size: 1.6rem;
    margin-bottom: 16px;
    text-align: center;
}
.modal-box label {
    display: block;
    margin-top: 12px;
    font-size: 0.9rem;
    color: #cdc4d9;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.modal-box input,
.modal-box select,
.modal-box textarea {
    width: 100%;
    padding: 8px 12px;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f0edf3;
    font-size: 0.95rem;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.modal-box input:focus,
.modal-box select:focus,
.modal-box textarea:focus {
    outline: none;
    border-color: #b0a8c0;
}
.modal-box .form-row {
    display: flex;
    gap: 12px;
}
.modal-box .form-row > div {
    flex: 1;
}
.modal-box .btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}
.modal-box .btn-group button {
    padding: 8px 24px;
    border-radius: 24px;
    border: none;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
}
.modal-box .btn-primary {
    background: #6a4a7a;
    color: #f0edf3;
}
.modal-box .btn-primary:hover {
    background: #7a5a8a;
}
.modal-box .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #cdc4d9;
}
.modal-box .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}
.modal-box .error-msg {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 8px;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}

/* ===== 占位 ===== */
.placeholder-hint {
    color: #7a6a88;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    font-weight: 350;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}

/* ===== 认证页面（登录/注册） ===== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #2c1a3d;
}
.auth-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 420px;
    width: 90%;
}
.auth-box h1 {
    text-align: center;
    margin-bottom: 24px;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
    color: #f0edf3;
}
.auth-box label {
    display: block;
    margin-top: 12px;
    color: #cdc4d9;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.auth-box input,
.auth-box select {
    width: 100%;
    padding: 8px 12px;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f0edf3;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.auth-box input:focus,
.auth-box select:focus {
    outline: none;
    border-color: #b0a8c0;
}
.auth-box .auth-type {
    margin-bottom: 16px;
}
.auth-box .auth-type label {
    display: inline-block;
    margin-right: 20px;
    margin-top: 0;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.auth-box .error-msg {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 8px;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.auth-box .btn-primary {
    background: #6a4a7a;
    color: #f0edf3;
    border: none;
    padding: 10px;
    border-radius: 24px;
    font-size: 1rem;
    cursor: pointer;
    font-family: 'HP', 'HP Fallback', system-ui, sans-serif;
}
.auth-box .btn-primary:hover {
    background: #7a5a8a;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    .page-1 h1 {
        font-size: 2.2rem;
    }
    .page-1 .welcome-text {
        font-size: 1.2rem;
        min-height: 1.8rem;
    }
    .page-1 img {
        max-width: 180px;
    }
    .navbar {
        padding: 0 18px;
        height: 56px;
    }
    .navbar .lang-toggle,
    .navbar .login-link,
    .navbar .register-link {
        font-size: 0.9rem;
        margin-left: 18px;
    }
    .navbar .lang-toggle {
        margin-right: 18px;
    }
    .navbar .user-info {
        font-size: 0.8rem;
        margin-right: 12px;
    }
    .page-3 {
        padding: 72px 0 40px 0;
    }
    .person-card {
        padding: 6px 8px 6px 16px;
        margin-left: 8px;
        gap: 10px;
    }
    .person-card .avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    .person-card .info .pname {
        font-size: 0.9rem;
    }
    .person-card .info .pbio {
        font-size: 0.75rem;
    }
    .node-children {
        padding-left: 10px;
    }
    .modal-box {
        padding: 24px 20px;
    }
    .modal-box .form-row {
        flex-direction: column;
        gap: 0;
    }
    .auth-box {
        padding: 24px 20px;
    }
}

@media (max-width: 420px) {
    .page-1 h1 {
        font-size: 1.7rem;
    }
    .page-1 .welcome-text {
        font-size: 1rem;
        min-height: 1.5rem;
    }
    .page-1 img {
        max-width: 130px;
        margin-bottom: 12px;
    }
    .navbar .lang-toggle,
    .navbar .login-link,
    .navbar .register-link {
        font-size: 0.8rem;
        margin-left: 14px;
    }
    .navbar .lang-toggle {
        margin-right: 14px;
    }
    .person-card .info .pbio {
        white-space: normal;
    }
    .admin-toolbar button {
        font-size: 0.75rem;
        padding: 4px 12px;
    }
    .auth-box .auth-type label {
        display: block;
        margin-bottom: 4px;
    }
}