*, *::before, *::after { box-sizing: border-box; } 

:root {
    --bg-color: #f0f2f5; --box-bg: #ffffff;
    --text-main: #333333; --text-sub: #888888;
    --theme-color: #ff3b30; --border-color: #e4e6eb;
}

body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color); color: var(--text-main); 
    overflow-x: auto; 
}
.box-style {
    background-color: var(--box-bg); border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04); padding: 20px; border: 1px solid var(--border-color);
}
.placeholder-text {
    color: var(--text-sub); font-size: 14px; display: flex; justify-content: center; align-items: center;
    height: 100px; background-color: #fafafa; border: 1px dashed #ccc; border-radius: 4px; margin-top: 15px;
}
.up { color: #ff3b30 !important; } .down { color: #34c759 !important; }

/* 宏观布局 */
.app-container {
    display: flex; max-width: 1500px; min-width: 1440px; margin: 20px auto;
    padding: 0 20px; gap: 20px; min-height: calc(100vh - 40px); 
}
.sidebar-left { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; }
.logo-box { text-align: center; } .logo-title { font-size: 48px; margin: 0; color: var(--theme-color); line-height: 1;}
.logo-subtitle { font-size: 18px; margin: 5px 0 0 0; color: var(--text-main); } b { font-weight: 900; }
.master-info { text-align: center; }
.master-info .avatar { width: 80px; height: 80px; border-radius: 50%; background-color: #eee; border: 2px solid var(--theme-color); margin: 0 auto 10px auto; }
.category-menu h3 { font-size: 14px; color: var(--text-sub); margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.category-menu ul { list-style: none; padding: 0; margin: 0; }
.category-menu li { padding: 12px 15px; margin-bottom: 8px; border-radius: 6px; cursor: pointer; transition: background 0.2s; }
.category-menu li:hover { background-color: #f5f5f5; }

/* 右侧复合区 */
.main-wrapper { flex: 1; display: flex; flex-direction: column; gap: 20px; }
/* ★ 核心修复：防止顶部栏被压缩 */
.top-header { 
    display: flex; justify-content: space-between; align-items: center; 
    flex-shrink: 0; /* 宁死不屈，禁止被 flex 压缩 */
}
.search-bar input { width: 400px; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 20px; outline: none; background-color: #f8f9fa; }
.user-info { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px; border-radius: 20px; transition: 0.2s;}
.user-info:hover { background-color: #f0f0f0; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background-color: var(--theme-color); display:flex; justify-content:center; align-items:center; color:white; font-weight:bold; font-size: 14px;}

/* SPA 路由 */
.spa-views-container { flex: 1; display: flex; flex-direction: column; }
.spa-view { width: 100%; padding-bottom: 20px; animation: fadeIn 0.3s ease; }
.hidden-view { display: none !important; }
.active-view { display: block !important; }

/* 首页 */
.content-layout { display: flex; gap: 20px; align-items: flex-start; } 
.content-center { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.top-widgets { display: flex; gap: 20px; }
.top-widgets .widget:first-child { flex: 0 0 460px; min-height: 280px;}
.top-widgets .widget:last-child { flex: 1; min-height: 280px;}
.price { font-size: 24px; font-weight: bold; margin: 5px 0; }
.chart-container { margin-top: 10px; border-top: 1px dashed #eee; padding-top: 10px; text-align: center;}
.chart-container img { width: 100%; max-width: 380px; height: auto; border-radius: 4px; mix-blend-mode: multiply; }
.posts-area { flex: 1; }
.posts-area .section-header h2 { font-size: 18px; margin: 0; }
.btn-post { background: var(--theme-color); color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: bold; }
.btn-post:hover { background: #e03228; }
.secure-post-list { list-style: none; padding: 0; margin: 15px 0 0 0; }
.post-item { cursor: pointer; padding: 15px; border-bottom: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s ease; }
.post-item:hover { background-color: #fafafa; padding-left: 20px;}
.post-title-link { color: #333; text-decoration: none; font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 8px;}
.post-category-tag { font-size: 12px; background: #eaf0f6; color: #4a7298; padding: 2px 6px; border-radius: 4px; font-weight: normal;}
.post-meta-text { color: #888; font-size: 13px; }

/* 右侧排行榜 (吸顶) */
.sidebar-right { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 20px; }
.widget-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.widget-header h3 { margin: 0; font-size: 15px; }
#sort-select { padding: 2px 6px; border-radius: 4px; border: 1px solid #ccc; outline: none; font-size: 12px;}
.sector-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.sector-list li { display: flex; justify-content: space-between; font-size: 14px; border-bottom: 1px dashed #f0f0f0; padding-bottom: 6px; font-weight: 500; }

/* ================= 帖子详情页 ================= */
.post-top-bar { display: flex; justify-content: space-between; margin-bottom: 20px;}
.back-btn { background: #f0f2f5; border: none; color: #555; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background 0.2s; }
.back-btn:hover { background: #e4e6eb; color: #333; }
.post-actions-bar button { background: none; border: 1px solid #ddd; color: #666; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-left: 5px; }
.post-actions-bar button:hover { background: #f5f5f5; color: #333;}
.post-actions-bar button.delete-btn:hover { color: #ff3b30; border-color: #ff3b30; background: #fff0f0;}
.post-detail-title { margin: 0 0 15px 0; font-size: 24px; color: #111;}
.post-detail-meta { color: var(--text-sub); font-size: 13px; margin-bottom: 25px; border-bottom: 1px solid #eee; padding-bottom: 15px;}
.post-detail-meta b { color: var(--theme-color); font-size: 14px; }
.post-detail-content { font-size: 16px; line-height: 1.8; color: #333; margin-bottom: 40px; }
.post-detail-content h3 { border-bottom: 1px solid #eee; padding-bottom: 8px; margin-top: 30px;}
.markdown-preview-area pre, .post-detail-content pre { position: relative; background-color: #282c34; color: #abb2bf; padding: 40px 16px 16px 16px; border-radius: 8px; overflow-x: auto; font-family: Consolas, Monaco, monospace; font-size: 14px; line-height: 1.6; }
.markdown-preview-area code, .post-detail-content code { font-family: Consolas, Monaco, monospace; background-color: rgba(27,31,35,0.06); color: #eb5757; padding: 2px 6px; border-radius: 4px; font-size: 90%; }
.markdown-preview-area pre code, .post-detail-content pre code { background-color: transparent; color: inherit; padding: 0; }
.copy-code-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.1); color: #ccc; border: 1px solid rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; transition: 0.2s;}
.copy-code-btn:hover { background: rgba(255,255,255,0.2); color: white; }

/* ================= 评论区升级：多行与计数器 ================= */
.comments-section { border-top: 4px solid #f0f2f5; padding-top: 25px; }
.comments-section h3 { margin-top: 0; font-size: 18px; margin-bottom: 20px;}
.comment-input-area { display: flex; gap: 10px; margin-bottom: 30px; align-items: flex-end;}
.textarea-wrapper { flex: 1; position: relative; }
.textarea-wrapper textarea { width: 100%; min-height: 80px; max-height: 250px; padding: 12px; padding-bottom: 30px; border: 1px solid #ddd; border-radius: 6px; outline: none; resize: vertical; font-family: inherit; font-size: 14px; line-height: 1.5; background: #fafafa;}
.textarea-wrapper textarea:focus { border-color: var(--theme-color); background: #fff; }
.char-counter { position: absolute; bottom: 8px; right: 12px; font-size: 13px; color: #888; font-weight: bold; pointer-events: none;}
.char-counter.error { color: #ff3b30; } 
.comment-input-area .btn-primary { height: 40px; padding: 0 20px; margin-bottom: 2px; }
.comment-list { list-style: none; padding: 0; margin: 0;}
.comment-item { display: flex; gap: 15px; margin-bottom: 20px; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; background: #4a7298; color: white; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 16px; flex-shrink: 0;}
.comment-body { flex: 1; background: #fafafa; padding: 15px; border-radius: 8px; border: 1px solid #eee; position: relative;}
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.comment-author-name { font-weight: bold; font-size: 14px; color: #333; }
.comment-time { font-size: 12px; color: #999; }
.comment-text { font-size: 14px; color: #444; margin: 0 0 10px 0; line-height: 1.6; white-space: pre-wrap; word-break: break-word;}
.comment-actions { display: flex; gap: 10px; }
.comment-actions button { background: none; border: none; color: #666; font-size: 12px; cursor: pointer; padding: 0;}
.comment-actions button:hover { color: var(--theme-color); }
.nested-replies { margin-top: 15px; border-top: 1px dashed #ddd; padding-top: 15px; display: flex; flex-direction: column; gap: 15px;}
.nested-reply-item { display: flex; gap: 12px; }
.nested-reply-item .comment-avatar { width: 30px; height: 30px; font-size: 12px; }
.nested-reply-item .comment-body { padding: 10px; background: #fff; }

/* ================= 发帖双栏编辑器 ================= */
.new-post-editor-area { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 15px;}
.editor-header h2 { margin: 0; }
.new-post-actions { display: flex; gap: 10px; }
.editor-meta { display: flex; gap: 15px; margin-bottom: 15px; }
.category-select { padding: 10px; border-radius: 6px; border: 1px solid #ddd; outline: none; background: #fafafa;}
.editor-meta input { flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 6px; outline: none; font-size: 16px; font-weight: bold;}
.md-toolbar { display: flex; gap: 5px; margin-bottom: 10px; background: #f8f9fa; padding: 8px; border-radius: 6px; border: 1px solid #ddd;}
.md-toolbar button { background: white; border: 1px solid #ccc; padding: 4px 10px; border-radius: 4px; cursor: pointer; color: #333; font-size: 13px; font-weight: 500;}
.md-toolbar button:hover { background: #e9ecef; }
.md-split-pane { display: flex; gap: 20px; flex: 1; min-height: 400px; }
.md-split-pane textarea { flex: 1; padding: 15px; border: 1px solid #ddd; border-radius: 6px; resize: none; outline: none; font-size: 15px; line-height: 1.6; font-family: Consolas, monospace; background: #fafafa;}
.md-split-pane textarea:focus { border-color: var(--theme-color); background: white;}
.markdown-preview-area { flex: 1; padding: 15px; border: 1px dashed #ccc; border-radius: 6px; background: #fff; overflow-y: auto; font-size: 15px; line-height: 1.8;}
.preview-hint { color: #aaa; font-style: italic; display: flex; justify-content: center; margin-top: 50px;}
.btn-secondary { background: #f0f0f0; color: #333; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn-secondary:hover { background: #e4e4e4; }
.btn-primary { background: var(--theme-color); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn-primary:hover { background: #e03228; }

/* ================= ★ 个人主页 (Profile Page) ★ ================= */
.profile-container { display: flex; flex-direction: column; gap: 20px; }
.profile-header { padding: 0; overflow: hidden; position: relative; }
/* 酷炫的深色极客风背景图 */
.profile-cover { height: 200px; background: linear-gradient(135deg, #2b5876 0%, #4e4376 100%); } 
.profile-info-wrap { display: flex; align-items: flex-end; padding: 0 30px 25px 30px; margin-top: -40px; }
/* 大悬浮头像 */
.profile-avatar-large { 
    width: 100px; height: 100px; border-radius: 50%; background: var(--theme-color); 
    border: 4px solid white; display: flex; justify-content: center; align-items: center; 
    font-size: 36px; color: white; font-weight: bold; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.profile-text { margin-left: 20px; flex: 1; padding-bottom: 5px;}
.profile-name-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px;}
.profile-username { font-size: 26px; font-weight: bold; color: #333; }
.profile-gender { font-size: 14px; color: #4a7298; background: #eaf0f6; padding: 2px 6px; border-radius: 4px;}
.profile-bio { font-size: 14px; color: #666; }

.profile-content { min-height: 500px; display: flex; flex-direction: column; }
.profile-tabs { display: flex; gap: 30px; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 15px; }
.profile-tab { 
    background: none; border: none; font-size: 16px; color: #666; cursor: pointer; 
    padding: 5px 0; font-weight: 500; position: relative; transition: 0.2s;
}
.profile-tab:hover { color: var(--theme-color); }
.profile-tab.active { color: var(--theme-color); font-weight: bold; }
/* 激活下划线特效 */
.profile-tab.active::after { 
    content: ''; position: absolute; bottom: -16px; left: 0; width: 100%; height: 3px; 
    background: var(--theme-color); border-radius: 3px;
}
.profile-list-area { flex: 1; overflow-y: auto; }
.empty-hint { text-align: center; color: #999; padding: 60px 0; font-size: 14px; }

/* 登录遮罩 */
.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(240, 242, 245, 0.4); backdrop-filter: blur(20px); z-index: 99999; display: flex; justify-content: center; align-items: center; }
.login-card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); width: 100%; max-width: 360px; text-align: center; border: 1px solid var(--border-color); }
.login-card h2 { margin-top: 0; color: var(--theme-color); font-size: 22px; }
.login-card p { color: var(--text-sub); font-size: 13px; margin-bottom: 25px; }
.input-group { margin-bottom: 15px; }
.input-group input { width: calc(100% - 24px); padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; outline: none; background-color: #f8f9fa; }
.error-msg { color: var(--theme-color); font-size: 12px; margin-bottom: 10px; text-align: left; height: 16px; font-weight: 500; }
#login-btn { width: 100%; padding: 12px; background-color: var(--theme-color); color: white; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; }
body.logged-in .login-overlay { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }