:root { 
    --primary: #6366f1; 
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --bg: #f8fafc; 
    --card-bg: #ffffff; 
    --text: #0f172a; 
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #f1f5f9;
    --border-hover: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.08);
    --radius: 14px;
}
/* 确保遮罩层允许点击 */
.image-modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.88); 
    z-index: 1000; 
    flex-direction: column; 
    justify-content: space-between; 
    align-items: center; 
    opacity: 0; 
    transition: opacity 0.3s ease; 
    cursor: pointer; /* 提示背景可点击关闭 */
}

/* 恢复舞台区域内部鼠标样式 */
.modal-body-wrap,
.modal-main-stage {
    cursor: default;
}

/* 优化右上角关闭按钮 */
.close-modal { 
    position: absolute; 
    top: 15px; 
    right: 25px; 
    color: #ffffff; 
    font-size: 36px; 
    font-weight: bold;
    cursor: pointer; 
    z-index: 1010; /* 确保层级在最上方 */
    padding: 10px;
    line-height: 1;
    user-select: none;
    transition: transform 0.2s, color 0.2s;
}

.close-modal:hover {
    color: #f43f5e;
    transform: scale(1.15);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; 
    background-color: var(--bg); 
    color: var(--text); 
    margin: 0; 
    padding: 0; 
    line-height: 1.7; 
    -webkit-tap-highlight-color: transparent;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 布局与辅助类 */
.layout-container { 
    max-width: 1200px; 
    margin: 25px auto 0 auto; 
    padding: 0 20px; 
    display: grid; 
    grid-template-columns: 1fr 280px; 
    gap: 25px; 
    width: 100%;
}
main { min-width: 0; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 15px 0; }
.text-center { text-align: center; }
.my-25 { margin-top: 25px; margin-bottom: 25px; }
.flex-between { justify-content: space-between; margin-bottom: 0; margin-top: 12px; }
.flex-row { display: flex; gap: 12px; align-items: center; }

/* 提示框类 */
.alert { padding: 10px; border-radius: 6px; margin-bottom: 15px; }
.alert-error { color: #ef4444; background: #fee2e2; }
.alert-success { color: #10b981; background: #d1fae5; }

/* 文章卡片 */
.post-card { 
    background: var(--card-bg); 
    border-radius: var(--radius); 
    padding: 24px; 
    margin-bottom: 20px; 
    box-shadow: var(--shadow-sm); 
    border: 1px solid var(--border); 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.post-card:hover { box-shadow: var(--shadow-lg); }

.post-card-inner { display: flex; gap: 15px; align-items: flex-start; }

.post-thumbnail {
    flex-shrink: 0;
    width: 160px;
    height: 100px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--border);
}
.post-thumbnail a { display: block; width: 100%; height: 100%; }
.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}
.post-thumbnail img:hover { transform: scale(1.08); }

.post-content-wrap { flex: 1; min-width: 0; }

.post-card .post-title { 
    margin: 0 0 6px 0; 
    font-size: 1.25rem; 
    font-weight: 700; 
    line-height: 1.4; 
    word-break: break-word; 
}
.post-card .post-title a { color: var(--text); text-decoration: none; transition: color 0.2s; }
.post-card .post-title a:hover { color: var(--primary); }

.post-card .post-excerpt {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 6px;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card .meta {
    font-size: 0.85rem; 
    color: var(--text-muted); 
    display: flex; 
    gap: 18px; 
    align-items: center; 
    flex-wrap: wrap; 
}

/* 富文本内容 */
.post-detail-content { 
    font-size: 1.05rem; 
    line-height: 1.85; 
    color: var(--text-secondary); 
    margin: 20px 0; 
    word-break: break-word; 
}
.post-detail-content p { margin-bottom: 1.6em; }
.post-detail-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; display: block; cursor: zoom-in; }

/* 侧边广告 */
.article-right-ad {
    float: right; margin: 10px 0 15px 20px; max-width: 260px; width: 100%;
    background: var(--card-bg); border: 1px solid var(--border-hover); border-radius: 10px;
    padding: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-align: center; position: relative;
}
.article-right-ad .ad-tag { position: absolute; top: 4px; right: 6px; font-size: 0.65rem; color: var(--text-muted); background: rgba(241, 245, 249, 0.9); padding: 1px 5px; border-radius: 4px; line-height: 1; border: 1px solid #e2e8f0; }
.article-right-ad img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 0 auto; }
.article-right-ad .ad-text-box { padding: 16px 10px 8px 10px; font-size: 0.95rem; color: var(--primary); font-weight: 600; line-height: 1.4; word-break: break-word; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; font-size: 0.75rem; border-radius: 6px; font-weight: 600; margin-right: 6px; }
.badge-top { background: #fef2f2; color: #ef4444; border: 1px solid #fee2e2; }
.badge-hot { background: #fff7ed; color: #f97316; border: 1px solid #ffedd5; }

/* 侧边栏 */
.sidebar { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.widget { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.widget-title { font-size: 1rem; font-weight: 700; margin: 0 0 12px 0; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.widget-list { list-style: none; padding: 0; margin: 0; }
.widget-list li { margin-bottom: 10px; font-size: 0.88rem; width: 100%; overflow: hidden; }
.widget-list a { color: var(--text-secondary); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.6; transition: color 0.2s; }
.widget-list a:hover { color: var(--primary); }
.ad-sidebar-img { width: 100%; border-radius: 8px; display: block; }

/* 按钮组 */
.like-section { text-align: center; margin: 40px 0 20px 0; display: flex; justify-content: center; gap: 16px; }
.btn-like, .btn-dislike {
    padding: 10px 24px; border-radius: 30px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: all 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 46px; flex: 1; max-width: 180px;
}
.btn-like { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary); }
.btn-like:hover { background: var(--primary); color: #fff; }
.btn-dislike { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.btn-dislike:hover { background: #64748b; color: #fff; }

.read-more-link {
    font-size: 0.82rem; font-weight: 600; color: var(--primary); text-decoration: none;
    background: var(--primary-light); padding: 4px 12px; border-radius: 20px; transition: all 0.2s;
}
.read-more-link:hover { background: var(--primary); color: #fff; }

.btn-load-more {
    background: var(--card-bg); color: var(--primary); border: 1px solid var(--primary);
    padding: 12px 35px; border-radius: 30px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.3s;
}
.btn-load-more:hover { background: var(--primary); color: #fff; }

/* 评论区 */
.comments-section { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); }
.comments-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.no-comments { color: var(--text-muted); text-align: center; padding: 20px 0; }
.comment-item { display: flex; gap: 15px; padding: 18px 0; border-bottom: 1px dashed var(--border); }
.comment-avatar img { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.comment-content-wrap { flex: 1; min-width: 0; }
.comment-meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.comment-user { font-weight: 600; color: var(--text); margin-right: 10px; }
.comment-body { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.65; word-break: break-word; }

.comment-form-box { background: var(--bg); padding: 20px; border-radius: 12px; margin-top: 30px; }
.user-avatar-sm { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.form-group { margin-bottom: 15px; }
.position-relative { position: relative; }
.form-control { 
    width: 100%; padding: 12px; border: 1px solid var(--border-hover); border-radius: 8px; 
    font-family: inherit; font-size: 0.95rem; background-color: var(--card-bg); color: var(--text); 
}
.form-control.readonly { background: #f1f5f9; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 110px; }

/* 表情选择器 */
.editor-toolbar { margin-bottom: 8px; }
.btn-emoji { background: transparent; border: 1px solid var(--border-hover); border-radius: 8px; cursor: pointer; padding: 8px 14px; }
.emoji-panel { 
    display: none; position: absolute; top: 45px; left: 0; background: var(--card-bg); 
    border: 1px solid var(--border-hover); box-shadow: var(--shadow-lg); padding: 10px; border-radius: 10px; 
    z-index: 100; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; width: 320px; max-height: 200px; overflow-y: auto; 
}
.emoji-panel.show { display: grid; }
.emoji-item { cursor: pointer; font-size: 1.25rem; text-align: center; padding: 6px; border-radius: 6px; }
.emoji-item:hover { background: var(--primary-light); transform: scale(1.15); }

.btn-submit { background: var(--primary); color: #fff; border: none; padding: 12px 28px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-submit:hover { background: var(--primary-hover); }

/* 图片弹窗 */
.image-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.88); z-index: 1000; flex-direction: column; justify-content: space-between; align-items: center; opacity: 0; transition: opacity 0.3s; }
.image-modal.active { display: flex; opacity: 1; }
.modal-body-wrap { position: relative; width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.modal-main-stage img { max-width: 90vw; max-height: 80vh; border-radius: 8px; object-fit: contain; }
.close-modal { position: absolute; top: 15px; right: 25px; color: #fff; font-size: 32px; cursor: pointer; }
.modal-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, 0.2); color: #fff; border: none; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; }
.modal-prev { left: 15px; } .modal-next { right: 15px; }
.modal-thumbs-bar { display: flex; gap: 10px; padding: 10px; max-width: 90%; overflow-x: auto; }
.modal-thumb-item { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; cursor: pointer; opacity: 0.5; }
.modal-thumb-item.active { opacity: 1; border: 2px solid var(--primary); }

/* 代码块容器：改为浅灰色背景 + 浅灰色边框 */
.code-block-wrapper { 
    margin: 1.6em 0; 
    border-radius: 8px; 
    background: #f8fafc; /* 浅灰/白底色 */
    border: 1px solid #e2e8f0; /* 细边框包裹 */
    overflow: hidden; 
}

/* 代码头部栏：改为稍微深一点点的浅灰，保持层次感 */
.code-block-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #f1f5f9; /* 顶部标题栏底色 */
    padding: 6px 14px; 
    font-size: 0.8rem; 
    color: #64748b; /* 语言文字颜色 */
    border-bottom: 1px solid #e2e8f0;
}

/* 复制按钮：改为白色微光按钮 */
.code-copy-btn { 
    background: #ffffff; 
    color: #475569; 
    border: 1px solid #cbd5e1; 
    padding: 4px 10px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 0.75rem;
    transition: all 0.2s ease;
}
.code-copy-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* 代码文字与 pre 标签重置：确保代码格式清晰、背景透明、文字为深灰色 */
.code-block-wrapper pre {
    margin: 0 !important;
    padding: 14px 16px !important;
    background: transparent !important;
    overflow-x: auto;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #1e293b !important; /* 强制深色代码文本 */
}

.code-block-wrapper code {
    color: inherit !important;
    background: transparent !important;
    font-family: inherit;
}

/* 响应式 */
@media (max-width: 768px) {
    .layout-container { grid-template-columns: 1fr; padding: 0 12px; }
    .article-right-ad { float: none; margin: 20px auto; }
    .btn-submit { width: 100%; }
}

/* 暗色模式 */
html.dark-mode {
    --bg: #0f172a; --card-bg: #1e293b; --text: #f8fafc; --text-secondary: #cbd5e1; --text-muted: #64748b; --border: #334155; --border-hover: #475569;

}
/* 验证码样式布局 */
.captcha-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.captcha-input {
    width: 140px !important;
    text-transform: uppercase; /* 建议自动大写显示提升体验 */
}

.captcha-img {
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-hover);
    transition: opacity 0.2s;
}

.captcha-img:hover {
    opacity: 0.85;
}
/* 暗色模式下的代码块适配 */
html.dark-mode .code-block-wrapper {
    background: #1e293b;
    border-color: #334155;
}
html.dark-mode .code-block-header {
    background: #0f172a;
    border-bottom-color: #334155;
    color: #94a3b8;
}
html.dark-mode .code-copy-btn {
    background: #334155;
    color: #f8fafc;
    border: none;
}
html.dark-mode .code-block-wrapper pre {
    color: #e2e8f0 !important;
}