:root {
    --primary: #4f772d;
    --accent: #90a955;
    --bg: #f7f9f7;
    --card-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-main: #31572c;
    --text-sub: #606c38;
    --lock-color: #bc4749;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, #f7f9f7 0%, #e9f5db 100%);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    min-height: 100vh;
}

.container { max-width: 500px; margin: 0 auto; padding: 0 20px 110px; }
.header { text-align: center; padding: 50px 20px 20px; }
.header h1 { font-size: 1.8rem; letter-spacing: 2px; margin-bottom: 5px; color: var(--primary); }
.header p { font-size: 0.85rem; color: var(--text-sub); opacity: 0.8; }

/* 左上角隐形入口 */
#secret-entry {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 60px; 
    height: 60px; 
    z-index: 9999; 
    opacity: 0; 
    cursor: default;
    -webkit-tap-highlight-color: transparent; /* 手机点击不闪烁 */
}

/* 管理员状态指示灯 */
#admin-indicator {
    position: fixed; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%;
    background: #ccc; z-index: 9999; box-shadow: 0 0 5px rgba(0,0,0,0.2);
}
#admin-indicator.active { background: #4f772d; box-shadow: 0 0 8px #4f772d; }

/* 通用卡片 */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    animation: fadeIn 0.5s;
    position: relative;
    overflow: hidden; /* 核心：防止子元素物理越界 */
}

/* 管理员按钮 */
.admin-btn-add {
    border: 2px dashed var(--accent);
    background: rgba(255,255,255,0.4);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-weight: bold; cursor: pointer;
    transition: 0.3s;
    min-height: 100px; border-radius: 16px;
}
.admin-btn-add:hover { background: rgba(255,255,255,0.8); }

.admin-controls {
    position: absolute; right: 5px; top: 5px; z-index: 10; display: flex; gap: 5px;
}
.admin-icon-btn {
    width: 24px; height: 24px; border-radius: 50%;
    text-align: center; line-height: 24px; font-size: 12px;
    cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.btn-del { background: #ffe5ec; color: #bc4749; }
.btn-edit { background: #e0fbfc; color: #0077b6; }

/* 弹窗样式 */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); z-index: 2000; backdrop-filter: blur(5px);
    align-items: center; justify-content: center;
}
.modal-card {
    background: #fff; width: 90%; max-width: 400px; border-radius: 20px; padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-height: 90vh; overflow-y: auto;
}
.form-group { margin-bottom: 15px; }
.form-label { display: block; font-size: 0.8rem; color: #666; margin-bottom: 5px; }
.form-input { 
    width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; 
    font-size: 0.95rem; font-family: inherit; outline: none;
}

/* 筛选工具条 */
.filter-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 2px 15px 2px;
    margin-bottom: 10px;
    /* 隐藏滚动条但保留功能 */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.filter-btn {
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.8);
    font-size: 0.8rem;
    color: var(--text-sub);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
}
.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(79, 119, 45, 0.3);
}


/* --- 新增：筛选面板样式 --- */
.toolbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}

.filter-toggle-btn {
    background: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.8);
    padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; color: var(--text-main);
    cursor: pointer; display: flex; align-items: center; gap: 5px; transition: 0.3s;
}
.filter-toggle-btn.active { background: var(--primary); color: white; }

/* 隐藏的筛选抽屉 */
#filter-panel {
    display: none; /* 默认隐藏 */
    background: rgba(255,255,255,0.9);
    border-radius: 16px; padding: 15px; margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    animation: fadeIn 0.3s;
}

.filter-section-title { font-size: 0.75rem; color: #888; margin-bottom: 8px; font-weight: bold; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; }

.chip {
    padding: 5px 12px; border-radius: 8px; font-size: 0.8rem;
    background: #f0f0f0; color: #555; cursor: pointer; transition: 0.2s;
    border: 1px solid transparent; user-select: none;
}
/* 选中状态 */
.chip.selected {
    background: #e9f5db; color: var(--primary); border-color: var(--primary); font-weight: bold;
}

/* 探索区头部 (提示语 + 刷新按钮) */
.discovery-header {
    display: flex; justify-content: space-between; align-items: center;
    margin: 10px 0 8px 0;
    font-size: 0.8rem; color: #888;
}
.refresh-btn {
    color: var(--primary); cursor: pointer; display: flex; align-items: center; gap: 4px;
    transition: 0.3s; user-select: none;
}
.refresh-btn:active { transform: rotate(180deg); }
.refresh-btn:hover { opacity: 0.8; }

/* 分隔线 */
.filter-divider {
    height: 1px; background: #eee; margin: 15px 0;
}

/* 书籍卡片 */
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-bottom: 20px; }
.book-card {
    background: rgba(255, 255, 255, 0.9); border-radius: 10px; padding: 12px 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); cursor: pointer; border: 1px solid rgba(255,255,255,0.8);
    transition: all 0.2s; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 110px;
}
.book-card:active { transform: scale(0.98); background: #fff; }
.book-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent); }
/* 推荐样式应用 */
.book-card.status-like {
    border-left-color: #4f772d !important; /* 强制应用森林绿 */
}

/* 弃文样式应用 */
.book-card.status-drop {
    border-left-color: #94a3b8 !important; /* 强制应用冷灰色 */
    background: #f1f5f9 !important; /* 稍微变灰的背景 */
    opacity: 0.9;
}

/* 弃文卡片内的文字颜色微调 */
.book-card.status-drop .b-title {
    color: #64748b !important;
}
.b-title { font-weight: bold; font-size: 0.95rem; color: #222; margin-bottom: 2px; line-height: 1.3; }
.b-author { font-size: 0.8rem; color: #666; margin-bottom: 8px; }
.b-info-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: auto; }
.b-tags { font-size: 0.7rem; color: #888; background: #f4f4f4; padding: 2px 6px; border-radius: 4px; }
.b-wordcount { font-size: 0.7rem; color: #aaa; font-family: monospace; }
/* 书籍页悬浮返回按钮 */
.floating-back-btn {
    display: none; /* 默认隐藏 */
    position: fixed; bottom: 90px; right: 20px; /* 在导航栏上方 */
    width: 45px; height: 45px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--primary);
    border-radius: 50%;
    color: var(--primary);
    font-size: 1.2rem;
    align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 999; cursor: pointer;
    transition: transform 0.2s;
}
.floating-back-btn:active { transform: scale(0.9); }

/* 详情页通用 */
.back-link {
    display: inline-flex; align-items: center; color: var(--text-sub); font-size: 0.9rem; font-weight: bold;
    margin-bottom: 15px; cursor: pointer; transition: 0.3s; padding: 5px 0;
}
.back-link::before { content: '‹'; font-size: 1.4rem; margin-right: 4px; line-height: 1; }
.detail-header { border-bottom: 1px dashed var(--accent); padding-bottom: 15px; margin-bottom: 15px; }
.detail-title { font-size: 1.4rem; color: var(--primary); margin: 0 0 5px 0; }
.detail-meta { font-size: 0.85rem; color: #666; display: flex; gap: 10px; }
.detail-note { font-size: 0.95rem; line-height: 1.8; color: #333; text-align: justify; white-space: pre-wrap; }

/* 观影网格布局 */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 20px;
}

/* 电影票根效果 */
.movie-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    cursor: pointer;
    position: relative;
}

.movie-card:hover {
    transform: translateY(-5px) rotate(1deg); /* 悬停时轻微倾斜，模拟票根质感 */
}

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.movie-info {
    padding: 10px;
    border-top: 2px dashed #eee; /* 票根撕裂线效果 */
}

.movie-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.movie-stars {
    color: #ffb800;
    font-size: 0.8rem;
}

/* --- 笔尖互动区样式 --- */
.interaction-bar {
    margin-top: 15px; padding-top: 10px;
    border-top: 1px dashed rgba(0,0,0,0.1);
    display: flex; gap: 20px; align-items: center;
    font-size: 0.85rem; color: var(--text-sub);
}
.action-btn {
    cursor: pointer; display: flex; align-items: center; gap: 5px; transition: 0.2s;
    user-select: none;
}
.action-btn:active { transform: scale(1.2); }
.action-btn.liked { color: #e63946; } /* 点赞后的颜色 */

.writing-body {
    word-break: break-all;
    width: 100%; /* 确保网格不超出父容器 */
    overflow-wrap: break-word; /* 确保长文字不会撑破卡片 */
    white-space: pre-wrap; /* 保持换行 */
}
/* 图片网格容器 */
.writing-img-grid {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    /* 默认 3 列，自动换行 */
    grid-template-columns: repeat(3, 1fr); 
    width: 100%; /* 确保网格不超出父容器 */
    box-sizing: border-box;
}

/* 根据图片数量自动调整列数 */
/* 1张图：满宽，2张图：1行2列，3张图及以上：1行3列 */
.writing-img-grid[data-count="1"] { grid-template-columns: 1fr; }
.writing-img-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.writing-img-grid[data-count="3"] { grid-template-columns: 1fr 1fr 1fr; }
.writing-img-grid[data-count="4"] { grid-template-columns: 1fr 1fr; } /* 4张图田字格更好看 */

/* 强制缩略图为 1:1 正方形且不超出容器 */
.writing-img {
    width: 100%;
    aspect-ratio: 1 / 1; /* 核心：强制比例 */
    object-fit: cover;   /* 核心：裁切中心，不拉伸 */
    border-radius: 8px;
    cursor: pointer;
}

/* 只有 1 张图时，保持原比例或稍微大一点 */
.writing-img-grid[data-count="1"] .writing-img {
    aspect-ratio: auto; 
    max-height: 350px;
    width: auto;
    max-width: 100%;
}

/* 悬停特效 */
.writing-img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* 评论折叠区 */
.comment-section {
    display: none; /* 默认隐藏 */
    margin-top: 10px; 
    background: rgba(255,255,255,0.5);
    border-radius: 8px; 
    padding: 10px;
    animation: fadeIn 0.3s;
}
.comment-list { margin-bottom: 10px; max-height: 200px; overflow-y: auto; }
.comment-item {
    font-size: 0.8rem; border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 5px 0; display: flex; justify-content: space-between;
}
.comment-input-row { display: flex; gap: 5px; }

/* --- 新增：评论区温馨提示样式 --- */
.comment-notice {
    background: rgba(255, 250, 240, 0.8); /* 暖米色背景，半透明 */
    border: 1px solid rgba(245, 158, 11, 0.2); /* 淡淡的琥珀色边框 */
    border-left: 3px solid #f59e0b; /* 左侧加粗，起到强调作用 */
    border-radius: 6px;
    padding: 8px 10px;
    margin: 10px 0; /* 上下留白 */
    font-size: 0.75rem; /* 小字号，不喧宾夺主 */
    color: #926c43; /* 树皮褐，比纯黑更柔和 */
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.comment-notice i {
    font-style: normal;
    font-size: 0.85rem;
}
.comment-del-btn { color: #bc4749; cursor: pointer; margin-left: 10px; font-weight: bold; }
.comment-pics img { max-width: 100px; border-radius: 4px; margin-top: 5px; cursor: zoom-in; }
.comment-meta { font-size: 0.75rem; color: #aaa; margin-top: 4px; display: flex; justify-content: space-between; }



.mini-input {
    flex: 1; border: 1px solid #ddd; border-radius: 20px; padding: 5px 10px;
    font-size: 0.8rem; outline: none;
}

.mini-input:focus {
    border-color: var(--primary);
    outline: none;
}

.comment-item:last-child {
    border-bottom: none;
}

.mini-btn {
    background: var(--primary); color: white; border: none; 
    border-radius: 20px; padding: 5px 12px; font-size: 0.75rem; cursor: pointer;
}

.w-tag { margin-right: 5px; border-radius: 50px; padding: 3px 10px; font-size: 0.75rem; font-weight: bold; }
.w-tag.心得 { background: #caf0f8; color: #0077b6; }
.w-tag.脑洞 { background: #fdf0d5; color: #c1121f; }
.w-tag.碎碎念 { background: #e9edc9; color: #588157; }

.primary-btn { background: var(--primary); color: white; border: none; padding: 12px; border-radius: 15px; width: 100%; cursor: pointer; font-size: 1rem; transition:0.3s; }
.pass-btn { background: var(--lock-color); color: white; border: none; padding: 8px 25px; border-radius: 50px; cursor: pointer; font-weight: bold; margin-top:10px; }

/* 树洞专属CSS */
.hollow-intro-box { background: rgba(255, 255, 255, 0.5); border-left: 4px solid var(--primary); border-radius: 8px; padding: 15px; margin-bottom: 20px; font-size: 0.85rem; color: #555; line-height: 1.8; white-space: pre-wrap; }
.hollow-footer { margin-top: 10px; font-size: 0.8rem; color: var(--primary); opacity: 0.8; font-weight: bold; text-align: right; }
/* 树洞卡片特有的朦胧感 */
.hollow-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
    padding: 20px;
    border-radius: 18px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
}

#mail-success-msg {
    animation: fadeInDown 0.5s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 自定义上传按钮样式 */
.custom-file-upload {
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.8);
    border: 1px dashed var(--primary);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--primary);
    transition: 0.3s;
}

.custom-file-upload:hover {
    background: var(--primary);
    color: white;
}

/* 隐藏原始 input */
#hollow-file {
    display: none;
}

/* 文件夹 (作品集) */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 移动端双列 */
    gap: 15px;
    padding: 10px;
}
.folder-card {
    background: #fff;
    padding: 20px 15px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: transform 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.folder-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(79, 119, 45, 0.1); }
.folder-icon { font-size: 2.5rem; margin-bottom: 10px; display: block; }
.folder-name { font-weight: bold; font-size: 0.95rem; margin-bottom: 5px; color: var(--primary); }
.folder-desc { font-size: 0.75rem; color: var(--text-sub); }

/* 画廊与图片 */
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery-item { overflow: hidden; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: #ddd; cursor: zoom-in; position: relative;}

/* 灯箱 (大图预览) - 升级版 */
#lightbox {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 10000;
    align-items: center; justify-content: center; animation: fadeIn 0.3s;
    cursor: zoom-out;
    user-select: none; /* 防止连点选中文字 */
}
#lightbox img { 
    max-width: 90%; max-height: 85%; 
    border-radius: 4px; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5); 
    cursor: default; 
    transition: opacity 0.2s; /* 切换时的淡入淡出感 */
}

/* 左右切换按钮 */
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    color: rgba(255,255,255,0.6); font-size: 3rem; font-weight: bold;
    cursor: pointer; padding: 20px; z-index: 10001;
    transition: 0.2s;
}
.lightbox-nav:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-prev { left: 0; }
.nav-next { right: 0; }

/* 底部页码指示器 */
#lightbox-counter {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,0.8); font-size: 0.9rem; font-family: monospace;
    background: rgba(0,0,0,0.5); padding: 4px 12px; border-radius: 20px;
}

/* Tabs & Nav */
.common-tabs { display: flex; margin-bottom: 20px; background: rgba(255,255,255,0.5); border-radius: 15px; padding: 4px; overflow-x: auto; }
.c-tab { flex: 1; text-align: center; padding: 8px; border-radius: 12px; cursor: pointer; font-size: 0.9rem; color: var(--text-sub); transition: 0.3s; white-space: nowrap; min-width: 60px;}
.c-tab.active { background: white; color: var(--primary); font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* 底部导航 (修改版) */
.nav-island {
    position: fixed; 
    bottom: 20px; 
    left: 50%; 
    /* 这里把原来的 transform 拆分了，配合JS控制 */
    transform: translateX(-50%) translateY(0); 
    background: rgba(49, 87, 44, 0.9); 
    backdrop-filter: blur(20px);
    padding: 8px 10px; 
    border-radius: 35px;
    display: flex; 
    gap: 2px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1000; 
    width: 90%; 
    max-width: 400px; 
    justify-content: space-between;
    
    /* ✨ 新增：平滑过渡动画 */
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ✨ 新增：隐藏状态 (向下位移 150% + 保持水平居中) */
.nav-island.nav-hidden {
    transform: translateX(-50%) translateY(150%);
}
.nav-btn {
    color: rgba(255,255,255,0.5); padding: 8px 0; flex: 1; text-align: center;
    border-radius: 25px; cursor: pointer; font-size: 0.75rem; transition: all 0.3s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.nav-btn span:first-child { font-size: 1.2rem; margin-bottom: 2px; }
.nav-btn.active { color: #fff; background: rgba(255,255,255,0.15); }

.page-content { display: none; animation: slideUp 0.4s ease-out; }
.page-content.active { display: block; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.view-section { display: none; animation: fadeIn 0.3s; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
