/* =========================================
   核心：富文本通用排版样式 (自动适配后台)
   ========================================= */
.rich-content {
    font-size: 16px;
    line-height: 1.85;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
/* 1. 仅对「直接包含图片」的 div 消除间距 */
.rich-content div:has(> img:only-child),
.rich-content div:has(> a > img:only-child) {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important; /* 只对纯图片容器生效 */
    font-size: 0 !important;   /* 双重保险消除间隙 */
}
/* 2. 其他所有 div 恢复正常文字排版 */
.rich-content div:not(:has(> img:only-child)):not(:has(> a > img:only-child)) {
    line-height: inherit !important; /* 继承父级 1.85 的行高 */
    font-size: inherit !important;
    margin-bottom: 0.8em; /* 恢复合理的段落间距 */
}

/* 段落与文本 */
.rich-content p { margin-bottom: 1.2em; text-align: justify; }
.rich-content strong, .rich-content b { font-weight: 600; color: #111; }
.rich-content em, .rich-content i { font-style: italic; color: #555; }
/* 3. 隐藏编辑器产生的纯空白段落 */
.rich-content p:has(> br:only-child),
.rich-content p:empty {
    display: none !important;
    margin: 0 !important;
}
/* 标题层级 */
.rich-content h2, .rich-content h3, .rich-content h4,
.rich-content h5, .rich-content h6 {
    margin: 2.2em 0 0.9em;
    line-height: 1.35;
    font-weight: 600;
    color: #111;
    padding-bottom: 0.4em;
    border-bottom: 1px solid #eee;
}
.rich-content h2 { font-size: 22px; }
.rich-content h3 { font-size: 19px; }
.rich-content h4 { font-size: 17px; border-bottom: none; }
.rich-content h5 { font-size: 16px; border-bottom: none; }
.rich-content h6 { font-size: 15px; border-bottom: none; color: #444; }

/* 链接 */
.rich-content a { 
    color: var(--primary, #a30001); 
    text-decoration: none; 
    border-bottom: 1px dashed transparent; 
    transition: all 0.2s; 
}
.rich-content a:hover { border-bottom-color: var(--primary, #a30001); }

/* 3. 图片样式保持不变 */
.rich-content img {
    height: auto !important;
    width: 80% !important;
    max-width: 100% !important;
    display: block !important;
    margin: 0 auto !important;
    vertical-align: bottom;
}
.rich-content img.alignleft, .rich-content img[style*="float: left"] { 
    float: left; margin: 0 1.5em 1em 0; max-width: 45%; 
}
.rich-content img.alignright, .rich-content img[style*="float: right"] { 
    float: right; margin: 0 0 1em 1.5em; max-width: 45%; 
}

/* 列表 */
.rich-content ul, .rich-content ol { margin-bottom: 1.2em; padding-left: 1.8em; }
.rich-content li { margin-bottom: 0.5em; }
.rich-content ul { list-style-type: disc; }
.rich-content ol { list-style-type: decimal; }
.rich-content ul ul, .rich-content ol ol { margin-top: 0.5em; margin-bottom: 0; }

/* 引用块 */
.rich-content blockquote {
    margin: 1.5em 0;
    padding: 16px 20px;
    background: #f8f9fa;
    border-left: 4px solid var(--primary, #a30001);
    border-radius: 0 6px 6px 0;
    color: #555;
    font-style: italic;
}

/* 表格 */
.rich-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 15px;
    overflow-x: auto;
}
.rich-content th, .rich-content td {
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: middle;
}
.rich-content th { background: #f5f7fa; font-weight: 600; }
.rich-content tr:nth-child(even) td { background: #fafafa; }

/* 代码块 */
.rich-content code, .rich-content pre {
    background: #f4f5f7;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    color: #c7254e;
}
.rich-content pre {
    padding: 16px;
    overflow-x: auto;
    margin: 1.5em 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #e0e0e0;
}

/* 分割线 */
.rich-content hr {
    border: none;
    border-top: 1px solid #e6e6e6;
    margin: 2em 0;
}

/* 底部声明 */
.detail-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #eee;
}
.disclaimer {
    font-size: 12px;
    line-height: 1.6;
    color: #888;
    background: #fafafa;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 24px;
    border-left: 3px solid #ddd;
    text-align: justify;
}

/* 上下页组件容器 */
.pagination-wrapper { text-align: center; padding: 10px 0; }

@media (max-width: 768px) {
    .carousel-item { flex: 0 0 calc(50% - 8px); } /* 假设容器 gap 为 16px，单边减 8px 防换行 */
    .page-header .banner { margin: 16px 0; }
    .carousel-btn { display: none; } /* 移动端隐藏箭头，支持滑动 */
     /* 补充：隐藏箭头后需支持手势滑动 */
  .carousel-track {
    scroll-snap-type: x mandatory;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox 隐藏滚动条 */
  }
  .carousel-track::-webkit-scrollbar { display: none; } /* Chrome/Safari 隐藏滚动条 */
  .carousel-item { scroll-snap-align: start; }
  .content-layout {
    flex-direction: column; /* 上下堆叠，内容自然在上 */
    gap: 16px;
  }
    .sidebar { width: 100%; display: none;}
    .category-nav { border-left: none; box-shadow: none; }
    .nav-toggle { padding: 12px 16px; }
    .nav-sublist { grid-template-columns: repeat(2, 1fr); padding: 6px 8px; }
    .nav-sublist li a { padding: 8px 10px 8px 20px; font-size: 13px; }
    
    .nav-grid.level-2 { grid-template-columns: repeat(2, 1fr); } /* 移动端仍保持双列 */
    .news-item { gap: 14px; padding: 16px 0; }
    .news-date-block { min-width: 52px; padding: 8px 6px; }
    .date-day { font-size: 22px; }
    .date-ym { font-size: 12px; }
    .news-title { font-size: 16px; }
    .news-excerpt { font-size: 13px; }
    
    .rightbar2 .detail-content { padding: 20px 16px; }
    .detail-title { font-size: 22px; }
    .detail-meta { flex-direction: column; gap: 8px; }
    .rich-content { font-size: 15px; line-height: 1.8; }
    .rich-content img.alignleft, .rich-content img.alignright { 
        float: none; max-width: 100%; margin: 1em 0; 
    }
    .rich-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .footer-keywords{ display: none;}
    
    .rightbar2 .title5 {
        font-size: 18px;
        margin: 28px 0 16px;
        padding-left: 10px;
        border-left-width: 3px;
    }
    
    .rightbar2 .list_news4 li {
        flex-direction: column-reverse; /* 移动端标题在上，日期在下 */
        align-items: flex-start;
        gap: 4px;
        padding: 12px 8px;
    }
    
    .rightbar2 .list_news4 li a {
        font-size: 15px;
        white-space: normal; /* 移动端允许换行显示完整标题 */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .rightbar2 .list_news4 li span {
        font-size: 12px;
        min-width: auto;
    }
    .site-footer { padding: 24px 0 0; }
}