* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===============================
   Theme Variables
================================ */

:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --link-bg: #f5f5f5;
    --link-hover: #000000;
    --avatar-border: #000000;

    /* ⭐ 光学对齐参数（关键） */
    --name-optical-shift: -0.35ch;
    --name-optical-shift-mobile: -0.25ch;
    --stack-gap: 16px;
    --optical-gap-correction: 2px; /* 视觉补偿：用于平衡 bio 与链接之间的感知间距 */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --text-color: #ffffff;
        --text-secondary: #999999;
        --border-color: #333333;
        --link-bg: #1a1a1a;
        --link-hover: #ffffff;
        --avatar-border: #ffffff;
    }
}

body:has(#theme-toggle:checked) {
    --bg-color: #000000;
    --text-color: #ffffff;
    --text-secondary: #999999;
    --border-color: #333333;
    --link-bg: #1a1a1a;
    --link-hover: #ffffff;
    --avatar-border: #ffffff;
}

@media (prefers-color-scheme: dark) {
    body:has(#theme-toggle:checked) {
        --bg-color: #ffffff;
        --text-color: #000000;
        --text-secondary: #666666;
        --border-color: #e0e0e0;
        --link-bg: #f5f5f5;
        --link-hover: #000000;
        --avatar-border: #000000;
    }
}

/* ===============================
   Base Layout
================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Roboto", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;

    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 500px;
    width: 100%;
    padding: 60px 40px;
    text-align: center;
}

/* ===============================
   Theme Toggle
================================ */

.theme-toggle {
    display: none;
}

.theme-toggle-label {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    background: var(--link-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
}

.theme-toggle-label:hover {
    background: var(--link-hover);
    color: var(--bg-color);
}

.theme-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.theme-toggle-label:hover .theme-icon {
    transform: rotate(15deg);
}

/* ===============================
   Info Section (视觉对齐核心)
================================ */

.info-section {
    margin-bottom: 0;

    /* ✅ 不使用任何宽度对齐 */
    display: flex;
    flex-direction: column;
    align-items: center; /* 统一视觉中轴 */
    gap: 12px;
}

/* ===== Name ===== */

.name {
    display: inline-block; /* 内容级居中，而不是块级撑满 */
    font-size: clamp(1.6rem, 2.6vw, 2rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0; /* 使用父级 gap 控制名字与简介的间距 */
    text-align: center;
    margin-bottom:16px;

    /* ⭐ 光学居中补偿 */
    transform: translateX(var(--name-optical-shift));
}

/* ===== Bio ===== */

.bio {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 300;
    line-height: 1.6;

    display: flex;
    justify-content: center;
    align-items: center;
}

.bio-word {
    position: relative;
    width: 9ch;
    height: 1.6em;
    overflow: hidden;
    text-align: center;
    cursor: pointer;
    flex: 0 0 9ch; /* 锁定列宽，防止窄屏时不同组件收缩比例不一致导致错位 */
}

.bio-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.bio-text-default {
    top: 0;
    opacity: 1;
}

.bio-text-hover {
    top: 0;
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
}

.bio-word:hover .bio-text-default {
    transform: translateX(-50%) translateY(-100%);
    opacity: 0;
}

.bio-word:hover .bio-text-hover {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===============================
   Links
================================ */

/* Links section alignment fix: ensure same ch basis as bio */
.links-section {
    display: flex;
    justify-content: center;
    margin-top: calc(var(--stack-gap) - var(--optical-gap-correction)); /* 视觉等距补偿 */
    font-size: 1rem; /* 与 .bio 一致，保证 9ch 宽度一致 */
    gap: 0; /* 取消链接之间的额外间距，确保与 bio 的间隔一致 */
}

.bio {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 300;
    line-height: 1.6;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0; /* 取消简介单词之间的间距，保证与链接列严格对齐 */
}

@media (max-width: 768px) {
    .bio {
        font-size: 0.95rem;
    }
    .links-section {
        font-size: 0.95rem; /* 与 .bio 一致 */
    }
}

@media (max-width: 480px) {
    .bio {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    .links-section {
        font-size: 0.9rem; /* 与 .bio 一致 */
    }
}

.social-link {
    width: 9ch;
    padding: 12px 0;
    color: var(--text-color);
    text-decoration: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    transition: color 0.3s ease;
    flex: 0 0 9ch; /* 锁定列宽，与 .bio-word 保持一致 */
}

.social-link svg {
    width: 20px;
    height: 20px;
    margin-bottom: 8px;
    transition: opacity 0.3s ease;
}

.social-link:hover {
    color: var(--text-secondary);
}

.social-link:hover svg {
    opacity: 0.7;
}

/* ===============================
   Responsive
================================ */

@media (max-width: 768px) {
    .container {
        padding: 50px 30px;
    }

    .name {
        transform: translateX(var(--name-optical-shift-mobile));
    }

    .bio {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 40px 20px;
    }

    .name {
        transform: translateX(var(--name-optical-shift-mobile));
        font-size: 1.5rem;
    }

    .bio {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .social-link svg {
        width: 18px;
        height: 18px;
    }
}
