body {
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    background-color: var(--background-white);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 三段式布局样式 - 無過渡效果 */
#content-container {
    min-height: 100vh;
    transition: none !important;
    overflow-y: auto;
    width: calc(100%);
}

body.detail-active #content-container {
    width: 50%;
}

.detail-wrapper {
    width: 50%;
    /* 預設寬度 */
    height: 100vh;
    overflow: hidden;
    transition: none !important;
    flex-shrink: 0;
    position: absolute;
    /* 初始定位 */
    top: 0;
    right: 0;
    visibility: hidden;
    /* 默認隱藏 */
    padding: 8px;
}

/* 立即顯示詳情面板，無過渡效果 */
body.detail-active .detail-wrapper {
    width: 50%;
    visibility: visible;
    position: sticky;
    /* 激活時固定 */
    overflow: visible;
}

/* 預先設置容器寬度，防止布局變動 */
@media screen {

    /* 預設在DOM載入時就設置好寬度，只是通過visibility隱藏 */
    .detail-wrapper {
        width: 50%;
        visibility: hidden;
        position: absolute;
        right: 0;
        top: 0;
    }

    body.detail-active .detail-wrapper {
        visibility: visible;
        position: sticky;
    }
}

.sidebar-container {
    max-width: 264px;
}

/* 媒體查詢也要移除過渡效果 */
@media (max-width: 1200px) {
    .sidebar-container {
        width: 200px;
    }
}

/* 中等屏幕優化 - 1280px 到 1051px */
@media (max-width: 1280px) and (min-width: 1051px) {
    .container {
        display: flex;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-container {
        width: 180px;
        flex-shrink: 0;
    }
    
    #content-container {
        flex: 1;
        min-width: 0;
        transition: none !important;
    }
    
    body.detail-active .container {
        display: flex;
    }
    
    body.detail-active #content-container {
        flex: 1;
        width: auto;
        min-width: 0;
    }
    
    body.detail-active .detail-wrapper {
        flex: 1;
        width: auto;
        min-width: 0;
        position: sticky;
        visibility: visible;
        height: 100vh;
        overflow-y: auto;
    }
    
    .detail-wrapper {
        flex: 1;
        width: auto;
        min-width: 0;
    }
}

@media (max-width: 1100px) and (min-width: 1051px) {
    .sidebar-container {
        width: 165px;
    }
}

/* 擴展1fr佈局到800px-1050px範圍 */
@media (max-width: 1050px) and (min-width: 801px) {
    .container {
        display: flex;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-container {
        width: 140px;
        flex-shrink: 0;
    }
    
    #content-container {
        flex: 1;
        min-width: 0;
        transition: none !important;
    }
    
    body.detail-active .container {
        display: flex;
    }
    
    body.detail-active #content-container {
        flex: 1;
        width: auto;
        min-width: 0;
    }
    
    body.detail-active .detail-wrapper {
        flex: 1;
        width: auto;
        min-width: 0;
        position: sticky;
        visibility: visible;
        height: 100vh;
        overflow-y: auto;
        top: 0;
    }
    
    .detail-wrapper {
        flex: 1;
        width: auto;
        min-width: 0;
    }
}

/* 小屏幕800px以下 - 只顯示Detail(1fr) */
@media (max-width: 800px) {
    #content-container {
        width: 100% !important;
        transition: none !important;
    }
    
    body.detail-active #content-container {
        display: none !important;
        width: 0 !important;
    }

    body.detail-active .detail-wrapper {
        width: 100% !important;
        flex: 1 !important;
        position: fixed !important;
        top: 60px !important; /* 頂部導航欄高度 */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: calc(100vh - 60px) !important; /* 正確計算高度 */
        max-height: calc(100vh - 60px) !important; /* 確保不超過螢幕 */
        z-index: 1009 !important; /* 確保高於bottomNavbar */
        visibility: visible !important;
        overflow: hidden !important; /* 防止整體滾動 */
        background: #FFFFFF !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .detail-wrapper {
        width: 100% !important;
        position: fixed !important;
        top: 60px !important; /* 頂部導航欄高度 */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: calc(100vh - 60px) !important; /* 正確計算高度 */
        max-height: calc(100vh - 60px) !important; /* 確保不超過螢幕 */
        z-index: 1009 !important; /* 確保高於bottomNavbar */
        visibility: hidden !important;
        background: #FFFFFF !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease, visibility 0.3s ease !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important; /* 防止整體滾動 */
    }
    
    body.detail-active .detail-wrapper {
        transform: translateX(0) !important;
    }

    /* 隱藏bottomNavbar當detail-container active時 */
    body.detail-active .bottom-navbar,
    body.detail-active .bottom-nav,
    body.detail-active .mobile-bottom-nav,
    body.detail-active [class*="bottom-nav"] {
        display: none !important;
        visibility: hidden !important;
    }

    /* 手機版貼文詳情容器優化 */
    body.detail-active .detail-wrapper .post-detail-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important; /* 使用100%高度，因為父容器已經是calc(100vh - 60px) */
        max-height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    /* 手機版頂部導航欄 */
    body.detail-active .detail-wrapper .mobile-header {
        position: relative !important; /* 改為relative避免重複fixed */
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 64px !important;
        min-height: 64px !important;
        max-height: 64px !important;
        background: #FFFFFF !important;
        border-bottom: 1px solid #E9EAEB !important;
        display: flex !important;
        align-items: center !important;
        padding: 12px 16px !important;
        z-index: 1010 !important;
        box-shadow: none !important; /* 去掉陰影 */
        border-radius: 0 !important; /* 去掉圓角 */
        flex-shrink: 0 !important; /* 防止收縮 */
        margin: 0 !important;
    }

    /* 手機版主內容區域 */
    body.detail-active .detail-wrapper .post-content-area {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 0 !important; /* 移除所有padding */
        margin: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        height: auto !important;
        min-height: 0 !important; /* 允許收縮 */
        position: relative !important;
    }

    /* 手機版留言輸入框容器 - 精確高度控制 */
    body.detail-active .detail-wrapper .comment-input-container,
    body.detail-active .detail-wrapper .footer-input-container {
        position: relative !important; /* 改為relative，作為flex子元素 */
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        background: #FFFFFF !important;
        border-top: 1px solid #E9EAEB !important;
        border-radius: 0 !important; /* 完全去掉圓角 */
        padding: 16px !important;
        z-index: 1010 !important; /* 高於header */
        box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.05) !important;
        min-height: 84px !important;
        height: auto !important; /* 自動高度 */
        max-height: 120px !important; /* 限制最大高度 */
        margin: 0 !important; /* 確保緊貼邊緣 */
        flex-shrink: 0 !important; /* 防止收縮 */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 手機版留言輸入框樣式 - 去掉圓角 */
    body.detail-active .detail-wrapper .comment-input-wrapper {
        display: flex !important;
        align-items: flex-end !important;
        gap: 8px !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.detail-active .detail-wrapper .comment-input-field {
        flex: 1 !important;
        min-height: 40px !important;
        max-height: 80px !important;
        height: auto !important;
        border: 1px solid #D5D7DA !important;
        border-radius: 0 !important; /* 完全去掉圓角 */
        padding: 12px 14px !important;
        font-size: 16px !important; /* 防止iOS縮放 */
        line-height: 1.5 !important;
        background: #FFFFFF !important;
        color: #181D27 !important;
        resize: none !important;
        outline: none !important;
        box-shadow: none !important; /* 去掉陰影 */
        font-family: 'Inter', 'Noto Sans TC', sans-serif !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
    }

    body.detail-active .detail-wrapper .comment-input-field:focus {
        border-color: var(--primary-color, #B89B5E) !important;
        box-shadow: none !important; /* 聚焦時也不要陰影 */
    }

    body.detail-active .detail-wrapper .comment-input-field::placeholder {
        color: #717680 !important;
        font-weight: 400 !important;
    }

    /* 手機版發送按鈕 - 去掉圓角 */
    body.detail-active .detail-wrapper .comment-send-button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 0 !important; /* 完全去掉圓角 */
        background: var(--primary-color, #B89B5E) !important;
        color: #FFFFFF !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
        font-weight: 600 !important;
        font-size: 14px !important;
        box-shadow: none !important; /* 去掉陰影 */
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.detail-active .detail-wrapper .comment-send-button:hover {
        background: var(--primary-dark, #8C7747) !important;
        transform: none !important; /* 去掉hover動畫 */
    }

    body.detail-active .detail-wrapper .comment-send-button:disabled {
        background: #E5E7EB !important;
        color: #9CA3AF !important;
        cursor: not-allowed !important;
        transform: none !important;
    }

    /* 手機版附件按鈕 - 去掉圓角 */
    body.detail-active .detail-wrapper .comment-attachment-button {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        border-radius: 0 !important; /* 去掉圓角 */
        background: transparent !important;
        color: #A4A7AE !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        margin-right: 4px !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.detail-active .detail-wrapper .comment-attachment-button:hover {
        background: rgba(164, 167, 174, 0.1) !important;
        color: var(--primary-color, #B89B5E) !important;
    }

    /* 手機版返回按鈕樣式 - 去掉圓角 */
    body.detail-active .detail-wrapper .mobile-back-button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 0 !important; /* 去掉圓角 */
        background: transparent !important;
        color: #414651 !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        margin-right: 12px !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.detail-active .detail-wrapper .mobile-back-button:hover {
        background: rgba(65, 70, 81, 0.1) !important;
    }

    /* 手機版標題區域 */
    body.detail-active .detail-wrapper .mobile-title {
        flex: 1 !important;
        font-size: 20px !important;
        font-weight: 600 !important;
        color: #181D27 !important;
        text-align: center !important;
        margin: 0 40px !important; /* 為左右按鈕預留空間 */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.2 !important;
        height: auto !important;
    }

    /* 確保底部導航欄永遠低於detail-container */
    .bottom-navbar,
    .bottom-nav,
    .mobile-bottom-nav,
    [class*="bottom-nav"] {
        z-index: 999 !important; /* 低於detail-wrapper的9999 */
    }

    /* 避免鍵盤彈出時的佈局問題 */
    body.detail-active .detail-wrapper.keyboard-active .comment-input-container {
        position: relative !important;
        bottom: auto !important;
    }

    /* 處理iOS Safari的特殊情況 */
    @supports (-webkit-touch-callout: none) {
        body.detail-active .detail-wrapper {
            height: 100vh !important;
            height: -webkit-fill-available !important;
        }
        
        body.detail-active .detail-wrapper .post-detail-container {
            height: 100vh !important;
            height: -webkit-fill-available !important;
        }
    }
}

/* 手機版響應式修復 - 確保內容居中 */
@media (max-width: 991px) {
    #content-container {
        width: 100% !important;
        margin-left: 0 !important;
        transition: none !important;
        display: flex;
        justify-content: center;
        padding: 0;
    }

    .main-content {
        width: 100%;
        /* max-width: 800px; */
        margin: 0 auto;
    }

    body.detail-active #content-container {
        width: 100% !important;
        display: flex;
        justify-content: center;
    }

    body.detail-active .detail-wrapper {
        width: 100%;
        transition: none !important;
        top: 64px;
        height: calc(100vh - 128px);
    }

    .detail-wrapper {
        width: 100%;
    }
}

@media (max-width: 768px) {
    #content-container {
        width: 100% !important;
        padding: 0;
    }
    

    body.detail-active #content-container {
        display: none;
    }

    body.detail-active .detail-wrapper {
        width: 100%;
        transition: none !important;
    }

    .detail-wrapper {
        width: 100%;
    }
}

/* 移除導致佈局問題的舊規則 */
@media (max-width: 900px) {
    /* 隱藏不需要的元素 */
    .sidebar-container { /* 假設這是側邊欄的 class */
        display: none !important; /* 使用 !important 確保覆蓋 */
    }
}

@media (max-width: 600px) {
    /* 確保 detail-wrapper 佔據可用空間 (如果需要) */
    #detail-wrapper {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important; /* 根據需要調整 */
    }

    /* 可能還需要調整 body 或外層容器的 padding/margin */
    body, .main-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}


/* 搜索输入框 */
.search-input {
    /* width: 200px; */
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.search-input:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.1);
    transform: translateY(-1px);
}

/* 标签 */
.badge {
    background-color: var(--primary-light);
    border: 1px solid rgba(0, 119, 181, 0.2);
    border-radius: 16px;
    padding: 2px 10px;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-normal);
}

.badge:hover {
    background-color: var(--primary-color);
    color: white;
}

.badge .close {
    padding: 2px;
    border-radius: 50%;
    transition: var(--transition-normal);
}

/* 发布按钮 */
.publish-button {
    background: var(--gradient-primary);
    color: white;
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
    border: none;
}

.publish-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.publish-button:active {
    transform: translateY(1px);
}

/* 标签按钮 */
.btn-tag {
    background-color: var(--background-light);
    color: var(--text-medium);
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition-normal);
    border: 1px solid transparent;
}

.btn-tag:hover:not(.active) {
    background-color: var(--primary-light);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-tag.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-weight: 600;
    border-color: rgba(0, 119, 181, 0.2);
    box-shadow: var(--shadow-sm);
}

/* 帖子卡片 */
.post-card {
    min-width: 280px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-card.active {
    border-color: var(--primary-color) !important;
    box-shadow: var(--shadow-md);
}

/* 渐入动画 - 移除动画效果 */
.fade-in {
    animation: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-medium);
    background-color: var(--background-gray);
    border: 1px solid var(--border-color);
    transition: var(--transition-normal);
}

.tag:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-color: rgba(0, 119, 181, 0.2);
}

/* 输入框 */
.enhanced-input {
    transition: var(--transition-normal);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    background-color: var(--background-white);
}

.enhanced-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.1);
    outline: none;
}

/* 分隔线 */
.elegant-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 16px 0;
}

/* 心形按钮 */
.heart-button {
    transition: var(--transition-normal);
    cursor: pointer;
    position: relative;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

.heart-button:hover {
    color: var(--primary-color);
}

.heart-button.active {
    color: var(--primary-color);
}

/* 帖子网格布局 */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

/* Comment Image Preview and Display Styles */
.comment-preview-image { /* For comment form preview */
    height: 80px;
    width: auto;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 8px;
    border: 1px solid #e2e8f0; /* Tailwind gray-300 */
}

#comment-image-preview-container {
    gap: 8px;
}

.comment-images-display-container {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.25rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.comment-images-display-container::-webkit-scrollbar {
    height: 6px;
}

.comment-images-display-container::-webkit-scrollbar-track {
    background: transparent;
}

.comment-images-display-container::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 6px;
}

.comment-image-item {
    /* height: 150px; */
    width: auto;
    /* max-width: 200px; */
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid #eeeeee;
    transition: transform 0.2s ease-in-out;
    cursor: pointer;
}


/* Ensure user avatar is round if not already by default by js */
.user-avatar {
    border-radius: 9999px; /* Tailwind rounded-full */
    /* width: 40px; height: 40px; -> defined in js or other css potentially */
}

.comment-item .user-avatar {
    width: 36px; /* specific for comment item */
    height: 36px;
}

.comment-bubble {
    position: relative; 
}

.comment-item .flex-1 > .flex.items-center.gap-4 { /* Action buttons container */
    padding-left: 2px; 
}

.whitespace-pre-wrap {
    white-space: pre-wrap; 
}

.reply-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.comment-action-menu {
    /* Styles were in JS, ensure they are here or in a consistent place */
    background-color: white;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.375rem; /* rounded-md */
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06); /* shadow-lg */
    padding-top: 0.25rem; /* py-1 */
    padding-bottom: 0.25rem; /* py-1 */
    position: absolute;
    right: 0;
    margin-top: 0.25rem; /* mt-1 */
    z-index: 10;
    min-width: 120px;
}

.comment-action-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment-action-menu li {
    padding: 0.5rem 0.75rem; /* px-3 py-2 */
    font-size: 0.875rem; /* text-sm */
    cursor: pointer;
}

.comment-action-menu li:hover {
    background-color: #f3f4f6; /* gray-100 */
}

.comment-action-menu li .fas,
.comment-action-menu li .far {
    margin-right: 0.5rem; /* mr-2 */
}

.comment-action-menu li.danger {
    color: #ef4444; /* red-500 */
}

.comment-action-menu li.danger:hover {
    background-color: #fee2e2; /* red-50 */
    color: #dc2626; /* red-600 */
}

/* 媒体查看器 */
.media-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.media-viewer.active {
    opacity: 1;
    visibility: visible;
}

.media-viewer-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-viewer-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.media-viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.media-viewer-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* 心跳点赞动画 */
@keyframes heart-beat {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.animate-heart {
    animation: heart-beat 0.6s ease-in-out;
    color: #ef4444;
}