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

:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1a1a1a;
    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --accent: #ffffff;
    --accent-gradient: linear-gradient(135deg, #333333, #555555);
    --border: #222222;
    --shadow: 0 4px 30px rgba(0,0,0,0.6);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== 顶部导航栏 ========== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 16px;
}

/* 左侧：用户信息 + 等级条 */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-info-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid var(--border);
}

.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.header-user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-nickname {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

/* 等级小条 */
.header-level-mini {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-exp-bar-bg {
    width: 60px;
    height: 4px;
    background: #222;
    border-radius: 2px;
    overflow: hidden;
}

.mini-exp-bar-fill {
    height: 100%;
    background: #555;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.mini-level-badge {
    font-size: 0.65rem;
    color: #999;
    font-weight: 700;
    white-space: nowrap;
}

/* 右侧导航链接 */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 20px;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid transparent;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: var(--bg-hover);
    border-color: var(--border);
}

.nav-btn {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 20px;
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.85rem;
}

.nav-btn:hover {
    color: #fff;
    background: var(--bg-hover);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.mini-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-nickname {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ========== 首页顶部等级信息栏（已移至header左侧） ========== */
.level-bar {
    display: none;
}

/* ========== 帖子网格 ========== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* 帖子卡片 */
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.post-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.8);
    border-color: #333;
}

.card-cover-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
    background: #0a0a0a;
}

.card-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-views {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.8);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    color: #ccc;
    backdrop-filter: blur(4px);
}

.card-body {
    padding: 16px;
}

.card-author-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.card-author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #333;
}

.card-author-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #e0e0e0;
}

.card-excerpt {
    font-size: 0.82rem;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== 悬浮发帖按钮 ========== */
.float-post-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(255,255,255,0.15);
    z-index: 999;
    transition: var(--transition);
    color: #000;
}

.float-post-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(255,255,255,0.25);
}

/* ========== 弹窗基础 - 加大 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    overflow-y: auto;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    margin: 4% auto;
    padding: 32px;
    border-radius: var(--radius);
    max-width: 500px;
    width: 92%;
    position: relative;
    border: 1px solid #222;
}

.modal-lg .modal-content {
    max-width: 800px;
}

.modal-detail .modal-content {
    max-width: 1100px;
    padding: 0;
    border-radius: var(--radius);
    overflow: hidden;
}

.close, .close-img {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #666;
    z-index: 10;
    transition: var(--transition);
}

.close:hover {
    color: #fff;
}

.close-img {
    top: 20px;
    right: 30px;
    font-size: 2.2rem;
    color: #fff;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: #e0e0e0;
}

.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 14px;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: var(--radius-sm);
    color: #e0e0e0;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.modal-content input:focus,
.modal-content textarea:focus {
    border-color: #444;
    background: #111;
}

.modal-content textarea {
    resize: vertical;
    min-height: 200px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #ddd;
}

.btn-secondary {
    padding: 10px 24px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: var(--radius-sm);
    color: #ccc;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #222;
    color: #fff;
}

.btn-sm {
    padding: 8px 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    color: #ccc;
    cursor: pointer;
    font-size: 0.82rem;
    transition: var(--transition);
}

.btn-sm:hover {
    background: #222;
    color: #fff;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* 发帖弹窗 */
.cover-upload {
    margin-bottom: 14px;
}

.cover-label {
    cursor: pointer;
    color: #999;
    font-size: 0.9rem;
}

#coverPreview {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.content-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.content-images-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #333;
}

/* ========== 帖子详情弹窗 ========== */
.detail-content {
    overflow: hidden;
}

.detail-wrapper {
    display: flex;
    min-height: 500px;
    max-height: 85vh;
}

.detail-cover {
    flex: 0 0 45%;
    max-width: 45%;
    background: #0a0a0a;
}

.detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-height: 400px;
}

.detail-body {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    max-height: 85vh;
    background: #111;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #333;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.85rem;
    color: #777;
}

.detail-author {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #fff;
}

.detail-text {
    line-height: 1.9;
    color: #ccc;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-text img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    cursor: pointer;
}

/* ========== 图片预览弹窗 ========== */
.image-preview-modal {
    display: none;
    align-items: center;
    justify-content: center;
}

.image-preview-modal img {
    max-width: 95%;
    max-height: 95vh;
    border-radius: 12px;
}

/* ========== 加载与空状态 ========== */
.loading {
    text-align: center;
    padding: 60px;
    color: #555;
    font-size: 1rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: #555;
}

.empty-state p {
    margin-top: 12px;
    font-size: 1.1rem;
}

.error-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid #222;
}

.no-posts {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    font-size: 1.2rem;
    color: #555;
}

/* ========== 响应式（手机端） ========== */
@media (max-width: 768px) {
    .header {
        padding: 8px 12px;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-left {
        order: 1;
        width: 100%;
        justify-content: space-between;
    }

    .header-right {
        order: 2;
        width: 100%;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .nav-link {
        font-size: 0.78rem;
        padding: 5px 10px;
    }

    .user-info-card {
        padding: 4px 10px;
    }

    .header-avatar {
        width: 28px;
        height: 28px;
    }

    .header-nickname {
        font-size: 0.75rem;
    }

    .mini-exp-bar-bg {
        width: 40px;
    }

    .post-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 0 4px;
    }

    .main-content {
        padding: 16px 12px;
    }

    /* 详情弹窗 - 上下结构 */
    .detail-wrapper {
        flex-direction: column;
        max-height: none;
    }

    .detail-cover {
        flex: 0 0 auto;
        max-width: 100%;
    }

    .detail-cover img {
        max-height: 250px;
        min-height: auto;
        width: 100%;
    }

    .detail-body {
        max-height: none;
        padding: 20px 16px;
    }

    .detail-title {
        font-size: 1.2rem;
    }

    /* 弹窗宽度适配 */
    .modal-content {
        margin: 2% auto;
        padding: 20px;
        max-width: 95%;
        width: 95%;
    }

    .modal-lg .modal-content {
        max-width: 95%;
    }

    .modal-detail .modal-content {
        max-width: 95%;
    }

    .float-post-btn {
        bottom: 20px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .card-title {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .header-right {
        gap: 4px;
    }

    .nav-link {
        font-size: 0.7rem;
        padding: 4px 8px;
        border-radius: 14px;
    }

    .post-grid {
        gap: 10px;
    }

    .modal-content {
        padding: 16px;
    }

    .detail-body {
        padding: 14px;
    }
}