/* 情感树洞页面专属样式 —— 抽取自原 tree_hole.php 内联 CSS + 新增功能样式 */

.tree-hole-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.tree-hole-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tree-hole-header h1 {
    color: #ff6b6b;
    font-size: 2rem;
}

.btn-primary {
    background-color: #ff6b6b;
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
}

.tree-hole-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s;
}

.tree-hole-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.tree-hole-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.tree-hole-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.tree-hole-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.tree-hole-username {
    font-weight: bold;
    color: #333;
}

.tree-hole-content {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: #333;
}

.tree-hole-actions {
    display: flex;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.action-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.action-btn:hover {
    color: #ff6b6b;
}

.action-btn.liked {
    color: #ff6b6b;
}

.anonymous-badge {
    background-color: #e0f7fa;
    color: #00acc1;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.empty-state i {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 1rem;
}

/* 置顶标记样式 */
.top-badge {
    background-color: #f57c00;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 0.8rem;
    box-shadow: 0 2px 4px rgba(245, 124, 0, 0.2);
}

/* 评论样式 */
.comments-section {
    margin-top: 1.5rem;
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
}

.comments-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.2rem;
}

.comments-list {
    margin-bottom: 2rem;
}

.comment-item {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    color: #666;
}

.comment-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

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

.comment-username {
    font-weight: bold;
    color: #333;
}

.comment-content {
    margin-bottom: 0.8rem;
    line-height: 1.5;
    color: #333;
}

.comment-footer {
    font-size: 0.85rem;
    color: #999;
}

/* 评论表单样式 */
.comment-form {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: bold;
}

.form-group textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 100px;
    box-sizing: border-box;
    font-family: inherit;
    transition: all 0.3s;
}

.form-group textarea:focus {
    border-color: #ff6b6b;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.form-options {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.form-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ff6b6b;
}

.btn-primary {
    background-color: #ff6b6b;
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
}

/* 媒体文件样式 —— 微信朋友圈风格九宫格 */
.tree-hole-media.th-gallery {
    margin: 0.75rem 0 0.25rem;
    display: grid;
    gap: 6px;
}

/* 多图：每格正方形裁切 */
.th-gallery .media-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    aspect-ratio: 1 / 1;
    height: auto;
    cursor: pointer;
    box-shadow: none;
    background: #f5f5f5;
}
.th-gallery .media-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform .3s ease;
}
.th-gallery .media-item:hover img { transform: scale(1.03); }

/* 各数量布局：2 张横排 / 3 张横排 / 4 张田字 / 5+ 九宫格 */
.th-g2 { grid-template-columns: repeat(2, 1fr); max-width: 68%; }
.th-g3 { grid-template-columns: repeat(3, 1fr); max-width: 80%; }
.th-g4 { grid-template-columns: repeat(2, 1fr); max-width: 68%; }
.th-g9 { grid-template-columns: repeat(3, 1fr); max-width: 92%; }

/* 单图：保持原图比例，限制最大尺寸，左对齐 */
.th-g1 { grid-template-columns: 1fr; max-width: 75%; justify-items: start; }
.th-g1 .media-item { aspect-ratio: auto; border-radius: 8px; }
.th-g1 .media-item img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 300px;
}

/* 第 9 格 +N 遮罩（超过 9 张） */
.th-media-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
/* 第 10 张起默认隐藏，点 +N 展开 */
.th-gallery .th-media-beyond { display: none; }
.th-gallery.th-gallery-open { max-width: 92%; }
.th-gallery.th-gallery-open .th-media-beyond { display: block; }
.th-gallery.th-gallery-open .th-media-overlay { display: none; }

/* 语音播放器与图片网格之间留距 */
.media-item.voice-item { margin-top: .75rem; }

/* 随机阅读：图片固定尺寸裁切（同旧版，不保留原比例、不折叠） */
.th-random-media {
    margin: 1rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
    max-width: 100%;
}
.th-random-media .media-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    height: 150px;
    aspect-ratio: auto;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    background: none;
}
.th-random-media .media-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    max-height: none;
}
.th-random-media .media-item:hover img { transform: scale(1.03); }


/* 语音树洞播放器样式 */
.media-item.voice-item {
    width: 100%;
    max-width: 440px;
    background: linear-gradient(135deg, #fff8f8, #fff0f2);
    border: 1px solid #ffdfe3;
    border-radius: 16px;
    padding: 1rem 1.1rem;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.08);
}

.media-item.voice-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.16);
    border-color: #ffb3bb;
}

.media-item.voice-item .voice-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #ff6b6b;
    font-weight: bold;
    margin-bottom: 0.6rem;
}

.media-item.voice-item .voice-label .voice-label-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #ff9a9e);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
    flex-shrink: 0;
}

.media-item.voice-item .voice-label .voice-tag {
    font-size: 0.7rem;
    color: #fff;
    background: linear-gradient(135deg, #ff9a9e, #ffb3bb);
    border-radius: 10px;
    padding: 0.1rem 0.55rem;
    font-weight: normal;
    margin-left: auto;
}

.media-item.voice-item audio {
    width: 100%;
    height: 40px;
}

/* 图片放大模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* 加载更多按钮 */
.load-more {
    text-align: center;
    margin-top: 1.5rem;
}

.load-more-btn {
    background: none;
    border: 1px solid #ff6b6b;
    color: #ff6b6b;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.load-more-btn:hover {
    background-color: #ff6b6b;
    color: white;
}

/* ============ 新增功能样式 ============ */

/* 功能 1：正文截断 + 展开全文 */
.tree-hole-card .tree-hole-content {
    position: relative;
}
.th-toggle {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0;
    border: none;
    background: none;
    color: #ff6b6b;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}
.th-toggle:hover {
    text-decoration: underline;
}

/* 功能 2：匿名视觉强化 */
.tree-hole-card.th-anon {
    background: linear-gradient(135deg, #f8fbff, #f0f7ff);
    border-left: 3px solid #66b8e0;
}
.tree-hole-card.th-anon .tree-hole-avatar {
    background: linear-gradient(135deg, #a8d8ea, #66b8e0);
}

/* 功能 4：快捷发帖浮窗 */
.th-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: white;
    border: none;
    box-shadow: 0 6px 20px rgba(255, 107, 107, .4);
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform .2s ease;
}
.th-fab:hover {
    transform: scale(1.08);
}
.th-fab:active {
    transform: scale(.95);
}
.th-fab-mask {
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(0, 0, 0, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.th-fab-mask.show {
    opacity: 1;
    pointer-events: auto;
}
.th-fab-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .15);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
    padding-bottom: env(safe-area-inset-bottom);
}
.th-fab-drawer.show {
    transform: translateY(0);
}
.th-fab-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
}
.th-fab-head h3 {
    margin: 0;
    color: #ff6b6b;
    font-size: 1.1rem;
}
.th-fab-close {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}
.th-fab-body {
    padding: 0 20px 20px;
}
.th-fab-body textarea {
    width: 100%;
    border: 2px solid #ffe0e0;
    border-radius: 12px;
    padding: 14px;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
}
.th-fab-body textarea:focus {
    outline: none;
    border-color: #ff6b6b;
}
.th-fab-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.th-fab-options label {
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
}
.th-count {
    font-size: 0.78rem;
    color: #999;
}
.th-fab-submit {
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255, 107, 107, .3);
    transition: all .2s ease;
}
.th-fab-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 107, 107, .4);
}

/* ============ 第二批优化：二级评论 + 标签系统 ============ */

/* === 标签系统 === */
.th-tag-tabs {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1rem;
}
.th-tag-tab {
    border: 1px solid #ffdfe3; background: #fff; color: #666;
    padding: 6px 14px; border-radius: 999px; font-size: 0.82rem;
    cursor: pointer; transition: all .2s ease;
    font-family: inherit;
}
.th-tag-tab:hover { border-color: #ff6b6b; color: #ff6b6b; }
.th-tag-tab.active {
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: #fff; border-color: transparent;
}

/* 卡片上的小标签 */
.th-tag {
    display: inline-block; font-size: 0.72rem; padding: 2px 8px;
    border-radius: 999px; background: #fff0f2; color: #ff6b6b;
    margin-left: 6px;
}

/* FAB 浮窗里的标签选择 */
.th-fab-tags {
    margin-top: 10px;
    display: flex; flex-direction: column; gap: 6px;
}
.th-fab-tags-label {
    font-size: 0.82rem; color: #888;
}
.th-fab-tags-list {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.th-fab-tag-btn {
    border: 1px solid #ffe0e0; background: #fff; color: #888;
    padding: 4px 10px; border-radius: 999px; font-size: 0.78rem;
    cursor: pointer; transition: all .2s ease;
    font-family: inherit;
}
.th-fab-tag-btn:hover { border-color: #ff6b6b; color: #ff6b6b; }
.th-fab-tag-btn.active {
    background: #ff6b6b; color: #fff; border-color: #ff6b6b;
}

/* 发帖页（tree_hole_post.php）里的标签按钮组 */
.th-post-tags {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 4px 0;
}
.th-post-tag-btn {
    border: 1px solid #ffdfe3; background: #fff; color: #666;
    padding: 6px 14px; border-radius: 999px; font-size: 0.82rem;
    cursor: pointer; transition: all .2s ease;
    font-family: inherit;
}
.th-post-tag-btn:hover { border-color: #ff6b6b; color: #ff6b6b; }
.th-post-tag-btn.active {
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
    color: #fff; border-color: transparent;
}

/* === 二级评论 === */
.comment-reply-btn {
    background: none; border: none; color: #666;
    cursor: pointer; display: inline-flex; align-items: center;
    gap: 0.3rem; font-size: 0.8rem; transition: color .2s ease;
    padding: 2px 4px;
}
.comment-reply-btn:hover { color: #ff6b6b; }

.comment-reply-form {
    margin-top: 1rem; padding: 1rem;
    background: #f8f9fa; border-radius: 8px;
    border-left: 3px solid #ff6b6b;
}

/* 子评论缩进 + 淡灰背景 + 左侧粉色竖线 */
.comment-reply {
    margin-left: 2rem;
    background: #fafafa;
    border-left: 2px solid #ffdfe3;
    padding-left: 1rem;
}
.comment-reply .comment-header::before {
    content: '回复 ';
    color: #ff6b6b;
    font-size: 0.8rem;
    font-weight: normal;
}

/* ========== 第三批优化：精华推荐 + PC 双列 + 草稿清空按钮 ========== */

/* === 精华推荐（今日精选） === */
.th-featured {
    margin-bottom: 1.2rem;
    background: linear-gradient(135deg, #fff8f5, #fff3f0);
    border: 1px solid #ffe4d8;
    border-radius: 14px;
    padding: 14px 12px 12px;
    overflow: hidden;
}
.th-featured-head {
    font-size: 0.9rem; font-weight: 700; color: #ff6b6b;
    margin-bottom: 10px; padding-left: 4px;
}
.th-featured-track {
    display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
    scroll-snap-type: x mandatory;
}
.th-featured-card {
    flex: 0 0 240px; max-width: 240px; scroll-snap-align: start;
    display: flex; gap: 10px; padding: 10px 12px;
    background: #fff; border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
    text-decoration: none; color: inherit; transition: transform .2s ease;
}
.th-featured-card:hover { transform: translateY(-2px); }
.th-featured-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, #ff6b6b, #ff9a9e);
    color: #fff; font-size: 0.95rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.th-featured-body { flex: 1; min-width: 0; }
.th-featured-text {
    font-size: 0.8rem; color: #333; line-height: 1.5;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.th-featured-meta { font-size: 0.72rem; color: #ff6b6b; margin-top: 4px; }

/* === PC 双列瀑布流（>= 900px 两列，移动端保持单列） === */
/* PC 瀑布流（≥900px 双列，≥1200px 三列）：卡片不等高、不互相拉长、布满屏幕 */
@media (min-width: 900px) {
    .th-list-grid {
        display: block;
        column-count: 2;
        column-gap: 1rem;
    }
    .th-list-grid .tree-hole-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        display: inline-block;
        width: 100%;
    }
}
@media (min-width: 1200px) {
    .tree-hole-container { max-width: 1100px; }
    .th-list-grid { column-count: 3; }
}

/* === 草稿清空按钮 === */
.th-fab-clear-draft {
    background: none; border: none; color: #999; font-size: 0.8rem;
    cursor: pointer; padding: 0; margin-left: auto;
}
.th-fab-clear-draft:hover { color: #ff6b6b; }

/* =========================================================
   旧版布局模式（html.th-legacy）
   由 head 内联脚本根据 localStorage('th_view_mode') 提前挂载，
   一键回到改版前观感：单列、无浮窗/精华/标签、正文全显、卡片恢复白底
   ========================================================= */
html.th-legacy .th-fab,
html.th-legacy .th-fab-mask,
html.th-legacy .th-fab-drawer,
html.th-legacy .th-featured,
html.th-legacy .th-tag-tabs,
html.th-legacy .th-toggle,
html.th-legacy .th-tag,
html.th-legacy .th-fab-clear-draft { display: none !important; }

/* 旧版：图片恢复原自适应网格，不用九宫格，全部图片照常显示 */
html.th-legacy .tree-hole-media.th-gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    max-width: none;
    margin: 1rem 0;
}
html.th-legacy .th-gallery .media-item {
    aspect-ratio: auto;
    height: 150px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    background: none;
}
html.th-legacy .th-gallery .media-item img { height: 100%; }
html.th-legacy .th-g1 { justify-items: stretch; max-width: none; }
html.th-legacy .th-g1 .media-item { aspect-ratio: auto; }
html.th-legacy .th-g1 .media-item img { width: 100%; height: 100%; max-height: none; }
html.th-legacy .th-gallery .th-media-beyond { display: block; }
html.th-legacy .th-media-overlay { display: none !important; }

/* 恢复旧版容器宽度与单列列表 */
html.th-legacy .tree-hole-container { max-width: 800px !important; }
html.th-legacy .th-list-grid { display: block; column-count: 1 !important; }
html.th-legacy .th-list-grid .tree-hole-card { margin-bottom: 1.5rem; }

/* 恢复旧版卡片观感：取消匿名淡蓝渐变底与左侧色条 */
html.th-legacy .tree-hole-card.th-anon {
    background: white !important;
    border-left: none !important;
}
/* 匿名头像：新版 CSS 用 background-image 渐变盖住了内联的 background-color:#ff6b6b，
   旧版需清除 background-image 才能露出内联红底白字"匿" */
html.th-legacy .tree-hole-card.th-anon .tree-hole-avatar {
    background-image: none !important;
}

/* 恢复旧版卡片 hover：取消新版 translateY 上浮，阴影只做轻微加深 */
html.th-legacy .tree-hole-card:hover {
    transform: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

/* 恢复旧版按钮：取消新版渐变背景 */
html.th-legacy .th-fab-submit,
html.th-legacy .th-featured-avatar,
html.th-legacy .th-tag-tab.active {
    background: #ff6b6b !important;
    background-image: none !important;
}

/* 恢复旧版匿名标记：保持原来的淡青色（不要新版任何渐变） */
html.th-legacy .anonymous-badge {
    background-color: #e0f7fa !important;
    color: #00acc1 !important;
}

