/* ========== 基础变量与重置 ========== */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 16px);
    --safe-top: env(safe-area-inset-top, 0px);
    --emerald: #10b981;
    --emerald-dark: #059669;
    --bg-body: linear-gradient(160deg, #05080f 0%, #0a0f1c 40%, #0d1520 100%);
    --card-bg: rgba(20, 26, 41, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.06);
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* 允许帖子正文和评论文字被选中（需在对应元素添加类名） */
.post-content, .comment-text {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-bottom: calc(80px + var(--safe-bottom));
    padding-top: var(--safe-top);
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    color: #e2e8f0;
}

/* ========== 通用隐藏类（不依赖第三方库） ========== */
.hidden {
    display: none !important;
}

/* ========== 顶部导航 ========== */
#topNav {
    background: rgba(8,12,22,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: var(--safe-top);
}

.nav-inner {
    max-width: 1024px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--emerald), #34d399);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

.logo-area h1 {
    font-size: 22px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.5px;
    margin: 0;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b0bec5;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.25s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* PC端发布按钮（默认隐藏） */
.top-publish-btn {
    display: none;
}

.tab-container {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0 8px;
}

.tab-btn {
    position: relative;
    color: #7c8aa0;
    transition: all 0.3s;
    font-weight: 500;
    padding: 12px 20px;
    font-size: 16px;
    white-space: nowrap;
    background: none;
    border: none;
    cursor: pointer;
}

.tab-btn.active {
    color: var(--emerald);
    font-weight: 700;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3.5px;
    background: var(--emerald);
    border-radius: 4px;
}

/* ========== 主内容区 ========== */
main {
    max-width: 600px;
    margin: 0 auto;
    padding: 14px 12px;
}

/* ========== 帖子卡片 ========== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 14px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

.card:active {
    transform: scale(0.985);
}

/* 不支持毛玻璃的降级背景 */
@supports not (backdrop-filter: blur(1px)) {
    .card,
    #topNav,
    .bottom-nav {
        background: rgba(8, 12, 22, 0.96);
    }
}

/* 图片网格 */
.tree-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    background: #1a1f2e;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.image-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.image-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
}

/* 视频 */
.limited-video {
    max-height: 180px;
    overflow: hidden;
    border-radius: 14px;
}

/* ========== 底部导航（移动端） ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(10, 14, 22, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 8px var(--safe-bottom);
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: calc(60px + var(--safe-bottom));
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #6b7d95;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.25s;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
}

.bottom-nav .nav-item.active {
    color: var(--emerald);
}

.bottom-nav .nav-item i {
    font-size: 20px;
    transition: transform 0.25s;
}

.bottom-nav .nav-item:active i {
    transform: scale(0.85);
}

.nav-publish {
    position: relative;
    top: -16px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
    transition: all 0.3s;
    cursor: pointer;
    border: none;
}

.nav-publish:active {
    transform: scale(0.9);
}

/* ========== 模态框通用 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: flex-end;           /* 移动端从底部弹出 */
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

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

.modal-sheet {
    background: #111827;
    border-radius: 22px 22px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 24px 20px 32px;
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.6);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

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

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-sheet input {
    width: 100%;
    background: #1f2937;
    border: 1.5px solid #374151;
    border-radius: 16px;
    padding: 15px 18px;
    font-size: 16px;
    color: #f1f5f9;
    outline: none;
    transition: border-color 0.3s;
    -webkit-appearance: none;
}

.modal-sheet input:focus {
    border-color: var(--emerald);
}

/* 修复自动填充时的浅色背景 */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #1f2937 inset !important;
    -webkit-text-fill-color: #f1f5f9 !important;
}

.modal-hint {
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    padding-left: 4px;
}

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

.btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.25s;
}

.btn-cancel {
    background: #1f2937;
    color: #d1d5db;
    border: 1px solid #374151;
}

.btn-cancel:active {
    background: #2d3645;
}

.btn-confirm {
    background: var(--emerald);
    color: #fff;
}

.btn-confirm:active {
    background: var(--emerald-dark);
}

/* ========== 图片画廊 ========== */
.gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.gallery-overlay img {
    max-width: 94vw;
    max-height: 75vh;
    border-radius: 16px;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: background 0.25s;
    z-index: 5;
}

.gallery-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.gallery-btn-prev { left: 12px; }
.gallery-btn-next { right: 12px; }

.gallery-close {
    position: absolute;
    top: max(16px, var(--safe-top));
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 5;
    transition: background 0.25s;
}

.gallery-close:active {
    background: rgba(255, 255, 255, 0.25);
}

.gallery-counter {
    position: absolute;
    bottom: max(30px, calc(30px + var(--safe-bottom)));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 5;
}

/* ========== 空状态 ========== */
#emptyState {
    text-align: center;
    padding: 60px 20px;
    color: #6b7d95;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease;   /* 添加淡入效果 */
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 17px;
    font-weight: 500;
    margin-bottom: 6px;
}

.empty-desc {
    font-size: 14px;
    color: #5a6d80;
}

/* ========== 评论区域 ========== */
.comment-list {
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;   /* iOS 平滑滚动 */
}

.comment-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.comment-input-row input {
    flex: 1;
    background: #1a2032;
    border: 1.5px solid #2a3345;
    border-radius: 14px;
    padding: 13px 16px;
    font-size: 15px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.3s;
}

.comment-input-row input:focus {
    border-color: var(--emerald);
}

.comment-input-row button {
    background: var(--emerald);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 13px 18px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.25s;
}

.comment-input-row button:active {
    background: var(--emerald-dark);
}

/* ========== 滚动条隐藏 ========== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ========== PC 端响应式覆盖 ========== */
@media (min-width: 1024px) {
    body {
        padding-bottom: 24px;
    }

    .bottom-nav {
        display: none !important;
    }

    .top-publish-btn {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
        color: white;
        padding: 0.6rem 1.8rem;
        border-radius: 16px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.3s;
    }

    .top-publish-btn:hover {
        filter: brightness(1.1);
    }

    main {
        max-width: 1024px;
    }

    .card {
        border-radius: 24px;
        padding: 24px;
    }

    .card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    .tree-image {
        aspect-ratio: 16 / 11;
        border-radius: 14px;
    }

    .tree-image:hover {
        transform: scale(1.03);
    }

    .limited-video {
        max-height: 260px;
    }

    .comment-list {
        max-height: 320px;
    }

    /* 模态框在PC端居中弹出 */
    .modal-overlay {
        align-items: center;
    }

    .modal-sheet {
        animation: fadeIn 0.3s ease;
        border-radius: 24px;
        max-width: 500px;
    }

    .gallery-btn { width: 50px; height: 50px; font-size: 30px; }
    .gallery-btn-prev { left: 24px; }
    .gallery-btn-next { right: 24px; }
}