/* ================= BBS 论坛 · 前台样式 ================= */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --text: #1f2937;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --border: #e5e7eb;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --shadow: 0 2px 10px rgba(31, 41, 55, .06);
    --shadow-hover: 0 10px 28px rgba(99, 102, 241, .16);
    --topbar-bg: rgba(246, 247, 251, .85);
    --sidebar-w: 248px;
    --danger: #dc2626;
    --ok: #16a34a;
}
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #273449;
    --text: #e5e7eb;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --border: #334155;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --shadow: 0 2px 10px rgba(0, 0, 0, .25);
    --shadow-hover: 0 10px 28px rgba(129, 140, 248, .2);
    --topbar-bg: rgba(15, 23, 42, .85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.35; }

/* ---------- 侧栏 ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 120;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; transition: transform .25s ease;
}
.sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 26px; flex-shrink: 0; filter: drop-shadow(0 2px 6px rgba(99, 102, 241, .3)); }
.brand-text { min-width: 0; }
.brand-text strong {
    display: block; font-size: 15.5px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small {
    display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.side-nav {
    flex: 1; overflow-y: auto; padding: 10px;
    display: flex; flex-direction: column; gap: 2px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.side-link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 11px; border-radius: 9px; font-size: 13.5px; color: var(--text-2);
    transition: background .15s, box-shadow .15s;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}
.side-link.is-active .side-cnt { background: rgba(255, 255, 255, .22); color: #fff; }
.side-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-cnt {
    flex-shrink: 0; font-size: 11px; line-height: 1.5; color: var(--text-3);
    background: var(--surface-2); border-radius: 999px; padding: 0 7px;
    transition: background .15s;
}

.sidebar-user {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 14px; border-top: 1px solid var(--border);
}
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-chip-name {
    font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-admin {
    font-size: 10px; color: #fff; background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: 999px; padding: 0 6px; line-height: 1.6; flex-shrink: 0;
}
.logout-form { flex-shrink: 0; }
.link-btn {
    border: 0; background: none; color: var(--text-3); font-size: 12.5px;
    cursor: pointer; padding: 2px 4px; font-family: inherit;
}
.link-btn:hover { color: var(--danger); }
.guest-actions { display: flex; gap: 8px; width: 100%; }
.guest-actions .btn { flex: 1; }

.sidebar-foot {
    display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border);
}
.icon-btn {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); font-size: 15px; cursor: pointer; color: inherit;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); background: var(--surface-2); }

/* ---------- 主区域 ---------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 12px;
    padding: 13px 24px; background: var(--topbar-bg);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.menu-btn {
    display: none; width: 38px; height: 38px; flex-shrink: 0; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 17px; cursor: pointer;
}
.search-wrap { flex: 1; max-width: 720px; margin: 0 auto; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 16px; font-size: 14px; opacity: .6; pointer-events: none; }
#search {
    width: 100%; padding: 10px 16px 10px 42px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text); font-size: 14.5px; outline: none;
    transition: border-color .2s, box-shadow .2s;
}
#search::placeholder { color: var(--text-3); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
.topbar-post { flex-shrink: 0; }

.container { width: 100%; max-width: 1000px; margin: 0 auto; padding: 24px 24px 40px; flex: 1; }

/* ---------- 组件 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    border: 0; border-radius: 9px; padding: 9px 18px; font-size: 13.5px; cursor: pointer;
    transition: all .15s; text-decoration: none; font-family: inherit; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-primary:hover { opacity: .92; transform: translateY(-1px); }
.btn-plain { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-plain:hover { color: var(--text); }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.inline-form { display: inline; }

.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 600; }
.panel-text { font-size: 13.5px; color: var(--text-2); margin-bottom: 8px; }
.panel-text.muted { color: var(--text-3); font-size: 12.5px; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--text-3); }

.announce {
    background: linear-gradient(135deg, rgba(99, 102, 241, .1), rgba(139, 92, 246, .1));
    border: 1px solid rgba(99, 102, 241, .25); color: var(--text);
    border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 13.5px;
}

.section-title { font-size: 16px; font-weight: 600; margin: 24px 0 12px; }

/* 版块卡片 */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.board-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px; display: flex; flex-direction: column; gap: 10px;
    transition: transform .18s, box-shadow .18s, border-color .18s;
}
.board-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: transparent; }
.board-top { display: flex; gap: 12px; align-items: flex-start; }
.board-ico { font-size: 26px; line-height: 1; flex-shrink: 0; }
.board-info h3 { font-size: 15px; font-weight: 600; }
.board-info p { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.board-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); }
.board-latest {
    border-top: 1px dashed var(--border); padding-top: 8px;
    display: flex; flex-direction: column; gap: 2px; font-size: 12.5px;
}
.latest-title { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.latest-meta { font-size: 11.5px; color: var(--text-3); }

/* 主题列表 */
.topic-list {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    overflow: hidden; box-shadow: var(--shadow);
}
.topic-row {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px;
    border-bottom: 1px solid var(--border); transition: background .15s;
}
.topic-row:last-child { border-bottom: 0; }
.topic-row:hover { background: var(--surface-2); }
.topic-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topic-title {
    font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center; gap: 6px;
}
.topic-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-stats {
    flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
    font-size: 11.5px; color: var(--text-3); white-space: nowrap;
}
.empty-cell { text-align: center; color: var(--text-3); padding: 30px 0; font-size: 13.5px; }

.tag {
    display: inline-block; font-size: 10.5px; line-height: 1.7; padding: 0 7px;
    border-radius: 999px; font-weight: 600; flex-shrink: 0;
}
.tag-pin { background: rgba(239, 68, 68, .12); color: #ef4444; }
.tag-lock { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.tag-ok { background: rgba(22, 163, 74, .12); color: var(--ok); }

/* 头像 */
.avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    background: var(--c, var(--accent)); color: #fff;
    font-size: 17px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    text-transform: uppercase;
}
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; font-size: 26px; }

/* 面包屑 / 页头 */
.breadcrumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--accent); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head-main h1 { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.topic-page-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 帖子 */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post {
    display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.post-side {
    width: 92px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
    gap: 6px; text-align: center;
}
.post-author { font-size: 12.5px; font-weight: 600; word-break: break-all; }
.post-floor { font-size: 11px; color: var(--text-3); }
.post-body { flex: 1; min-width: 0; }
.post-meta {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    font-size: 11.5px; color: var(--text-3); margin-bottom: 8px;
    border-bottom: 1px dashed var(--border); padding-bottom: 8px;
}
.post-edited { color: var(--text-3); }
.post-edit { margin-left: auto; color: var(--accent); }
.post-content { font-size: 14.5px; line-height: 1.85; word-break: break-word; }

.notice {
    background: var(--surface-2); border: 1px dashed var(--border); border-radius: 12px;
    padding: 16px; text-align: center; color: var(--text-2); font-size: 13.5px;
}
.notice a { color: var(--accent); }

.reply-box { margin-top: 18px; }
.reply-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--text-3); }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
    font-size: 14px; outline: none; font-family: inherit; background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 100px; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.form-panel { max-width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.checkbox-field label.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox-field input[type=checkbox] { width: auto; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 18px 0 6px; }
.page-btn {
    padding: 6px 14px; border-radius: 8px; background: var(--surface);
    border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.is-disabled { opacity: .45; }
.page-info { font-size: 12.5px; color: var(--text-3); }

/* 提示 */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; }
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
[data-theme="dark"] .flash-success { background: rgba(16, 185, 129, .12); color: #6ee7b7; border-color: rgba(16, 185, 129, .3); }
[data-theme="dark"] .flash-error { background: rgba(239, 68, 68, .12); color: #fca5a5; border-color: rgba(239, 68, 68, .3); }

/* 个人主页 */
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-info h1 { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.profile-meta { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.profile-stats { display: flex; gap: 18px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.profile-stats b { color: var(--text); }

/* 页脚 */
.footer {
    text-align: center; padding: 24px 20px 30px; color: var(--text-3); font-size: 12.5px;
    border-top: 1px solid var(--border);
}
.footer-stat { margin-left: 8px; opacity: .8; }

/* 回到顶部 */
.to-top {
    position: fixed; right: 26px; bottom: 30px; z-index: 90;
    width: 42px; height: 42px; border-radius: 50%; border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-size: 18px; cursor: pointer;
    box-shadow: 0 6px 18px rgba(99, 102, 241, .4);
    transition: transform .15s;
}
.to-top:hover { transform: translateY(-3px); }

/* 登录/注册页 */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background: linear-gradient(135deg, #eef2ff, #f8fafc 50%, #ecfeff);
}
[data-theme="dark"] .auth-body { background: var(--bg); }
.auth-card {
    background: var(--surface); border-radius: 16px; box-shadow: 0 10px 40px rgba(30, 41, 59, .12);
    width: 100%; max-width: 380px; padding: 32px 28px;
}
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-sub { color: var(--text-3); font-size: 13px; text-align: center; margin: 4px 0 20px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 12.5px; color: var(--text-3); }
.auth-links a:hover { color: var(--accent); }
.auth-back { display: block; text-align: center; margin-top: 16px; font-size: 13px; color: var(--accent); }

/* 遮罩 */
.backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.backdrop[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .18); width: 264px; }
    .sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .menu-btn { display: flex; }
    html { scroll-padding-top: 74px; }
}
@media (max-width: 640px) {
    .container { padding: 16px 14px 30px; }
    .topbar { padding: 10px 12px; }
    .post { flex-direction: column; gap: 10px; }
    .post-side { width: auto; flex-direction: row; justify-content: flex-start; gap: 8px; text-align: left; }
    .board-grid { grid-template-columns: 1fr; }
    .topic-stats span:nth-child(2) { display: none; }
    .to-top { right: 14px; bottom: 18px; }
}
