body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    overflow-x: hidden; /* 防止水平滚动 */
    background: linear-gradient(to bottom, #1e3c72, #2a5298); /* 渐变背景 */
}
header {
    display: flex;
    justify-content: center; /* 居中对齐 */
    align-items: center;
    padding: 10px 20px;
    background-color: transparent;
    box-shadow: none; /* 初始状态无阴影 */
    position: fixed;
    width: 100%;
    top: 0;
    transition: background-color 0.3s, box-shadow 0.3s; /* 添加阴影的过渡效果 */
    z-index: 1000; /* 确保 header 在最上层 */
    flex-wrap: wrap; /* 允许内容换行 */
}
.logo {
    position: absolute; /* 固定 logo */
    left: 20px; /* 靠左对齐 */
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(90deg, red, red, orange, yellow, green, blue, indigo, violet, black, red); /* 增加开始的红色时长 */
    -webkit-background-clip: text;
    color: transparent;
    animation: gradient 3s infinite linear; /* 将动画速度加快到3秒 */
    background-size: 1000% 1000%; /* 增加背景尺寸以提高连贯性 */
}
@keyframes gradient {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}
nav {
    display: flex;
    flex-wrap: wrap; /* 允许导航按钮换行 */
    gap: 10px; /* 调整按钮间距 */
    justify-content: center; /* 居中对齐导航按钮 */
    max-width: 100%; /* 确保导航栏不会超出屏幕宽度 */
    overflow: hidden; /* 隐藏溢出内容 */
}
nav a {
    text-decoration: none;
    color: white; /* 初始状态为白色文字 */
    font-weight: bold;
    transition: color 0.3s; /* 添加颜色过渡效果 */
    white-space: nowrap; /* 防止按钮文字换行 */
}
nav a.active {
    color: lightblue; /* 初始状态为浅蓝色文字 */
}
.login-btn {
    background-color: #007bff;
    color: #fff;
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px; /* 调整左边距 */
    white-space: nowrap; /* 防止按钮文字换行 */
    position: absolute; /* 固定登录按钮 */
    right: 20px; /* 靠右对齐 */
}
#user-display {
    display: none;
    margin-left: 10px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px; /* 限制最大宽度 */
    color: white; /* 确保文字颜色与导航栏一致 */
}
.background-element {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 6s ease-in-out infinite;
}
@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0); }
}
/* 电脑屏幕背景设计 */
@media (min-width: 768px) {
    .background-element.large {
        width: 300px;
        height: 300px;
        top: 20%;
        left: 10%;
    }
    .background-element.medium {
        width: 200px;
        height: 200px;
        top: 50%;
        left: 70%;
    }
    .background-element.small {
        width: 100px;
        height: 100px;
        top: 80%;
        left: 30%;
    }
}
/* 手机屏幕背景设计 */
@media (max-width: 767px) {
    .background-element.large {
        width: 150px;
        height: 150px;
        top: 10%;
        left: 5%;
    }
    .background-element.medium {
        width: 100px;
        height: 100px;
        top: 40%;
        left: 60%;
    }
    .background-element.small {
        width: 50px;
        height: 50px;
        top: 70%;
        left: 20%;
    }
}
.content {
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 20px;
    margin: 80px auto; /* 确保内容在导航栏下方 */
    width: 80%;
    min-height: 200vh; /* 设置最小高度为两个屏幕高度 */
}
.footer {
    text-align: center;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 15px; /* 添加圆角效果 */
    margin: 20px auto; /* 添加外边距 */
    width: 80%; /* 设置宽度 */
}

.create-post-btn {
    background-color: #007bff; /* 蓝色 */
    color: white;
    padding: 10px 20px; /* 变大 */
    border: none;
    border-radius: 5px; /* 圆角矩形 */
    cursor: pointer;
    font-size: 16px;
    position: absolute;
    top: -10px; /* 向上移动 */
    right: 10px; /* 距离内容区域右侧 */
    z-index: 1000;
    transition: background-color 0.3s;
}

.create-post-btn:hover {
    background-color: #0056b3; /* 悬停时变深 */
}

.posts-container {
    margin-top: 60px; /* 向下移动以避免被按钮遮挡 */
}

.modal {
    display: none; /* 默认隐藏 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4); /* 半透明背景 */
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 10px; /* 圆角矩形 */
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#post-content-modal {
    width: 100%;
    height: 150px;
    margin-bottom: 20px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

#send-post-btn {
    background-color: #007bff; /* 蓝色 */
    color: white;
    padding: 10px 20px; /* 变大 */
    border: none;
    border-radius: 5px; /* 圆角矩形 */
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#send-post-btn:hover {
    background-color: #0056b3; /* 悬停时变深 */
}
