/* ========== 基础变量 ========== */
:root {
    --bg: #f5f6fa;
    --card: #ffffff;
    --border: #e1e4ea;
    --text: #222;
    --muted: #8a8f99;
    --primary: #5865f2;
    --primary-hover: #4752c4;
    --accent: #10b981;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; background: var(--bg); color: var(--text);
    font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== 顶栏 ========== */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand a { color: inherit; }
.muted { color: var(--muted); font-size: 13px; }

.menu-btn {
    display: none; /* 默认桌面不显示 */
    background: transparent; border: 1px solid var(--border);
    color: var(--text); font-size: 18px; line-height: 1;
    padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.menu-btn:active { background: #eef0f6; }

/* 移动端抽屉遮罩（桌面隐藏） */
.sidebar-mask {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.35); z-index: 19;
}
.sidebar-mask.show { display: block; }

/* ========== 布局 ========== */
.layout {
    display: grid; grid-template-columns: 240px 1fr; gap: 16px;
    max-width: 1100px; margin: 16px auto; padding: 0 16px;
}
.layout.single { grid-template-columns: 1fr; max-width: 820px; }

/* ========== 侧边栏 ========== */
.sidebar {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; height: fit-content; position: sticky; top: 60px;
}
.sidebar h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li {
    padding: 8px 10px; border-radius: 6px; cursor: pointer;
    display: flex; justify-content: space-between;
}
.board-list li:hover { background: #eef0f6; }
.board-list li.active { background: var(--primary); color: #fff; }
.board-list li.active .cnt { color: #fff; opacity: .85; }
.board-list .cnt { color: var(--muted); font-size: 12px; }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }

/* ========== 帖子列表（桌面 3 列 grid） ========== */
.content {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px;
}
.content-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.content-header h2 { margin: 0; font-size: 18px; }
.sort-switch label { margin-left: 10px; font-size: 13px; cursor: pointer; }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li {
    padding: 12px 8px; border-bottom: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr 80px 130px; gap: 12px; align-items: center;
}
.post-list li:last-child { border-bottom: none; }
.post-list .title { font-weight: 600; min-width: 0; }
.post-list .title a { color: var(--text); word-break: break-word; }
.post-list .title .badge {
    display: inline-block; padding: 1px 6px; font-size: 11px; border-radius: 4px;
    background: #eef0f6; color: var(--primary); margin-right: 6px;
}
.post-list .meta { font-size: 12px; color: var(--muted); }
.post-list .rcount { text-align: center; color: var(--primary); font-weight: 600; }
.post-list .rcount small {
    display: block; color: var(--muted); font-weight: normal; font-size: 11px;
}

/* ========== 翻页 ========== */
.pager {
    display: flex; gap: 8px; align-items: center; justify-content: center;
    padding: 12px 0 4px;
}
.pager button {
    padding: 6px 14px; border: 1px solid var(--border); background: #fff;
    border-radius: 6px; cursor: pointer;
}
.pager button:disabled { color: var(--muted); cursor: not-allowed; }

/* ========== 帖子详情页 ========== */
.post-detail {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 24px; margin-bottom: 16px;
}
.post-detail h1 { margin: 8px 0 16px; font-size: 22px; }
.post-meta { font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.post-content { word-break: break-word; line-height: 1.8; }
.post-content > *:first-child { margin-top: 0; }
.post-content > *:last-child { margin-bottom: 0; }

/* ========== 回帖列表 ========== */
.replies {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px 24px;
}
.reply-list { list-style: none; margin: 0; padding: 0; }
.reply-list li { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.reply-list li:last-child { border-bottom: none; }
.reply-header {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 6px; font-size: 13px; flex-wrap: wrap;
}
.reply-header .nick { font-weight: 600; color: var(--primary); }
.reply-header .time { color: var(--muted); }
.reply-header .floor { color: var(--muted); font-size: 12px; }

.reply-body { word-break: break-word; line-height: 1.8; }
.reply-body > *:first-child { margin-top: 0; }
.reply-body > *:last-child { margin-bottom: 0; }

.reply-hint { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.reply-hint code { background: #eef0f6; padding: 2px 6px; border-radius: 4px; }

/* ========== 头像 ========== */
.avatar {
    display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
    background: #eef0f6; align-items: center; justify-content: center;
    font-size: 14px; margin-right: 4px; flex-shrink: 0;
}

/* ========== Markdown 内容（帖子正文） ========== */
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
    margin: 1.2em 0 0.6em; font-weight: 600; line-height: 1.4; color: var(--text);
}
.post-content h1 { font-size: 1.6em; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
.post-content h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.post-content h3 { font-size: 1.2em; }
.post-content p { margin: 0.8em 0; }
.post-content a { color: var(--primary); text-decoration: underline; }
.post-content a:hover { color: var(--primary-hover); }
.post-content strong { font-weight: 700; color: #111; }
.post-content em { font-style: italic; }
.post-content ul, .post-content ol { margin: 0.6em 0; padding-left: 1.8em; }
.post-content li { margin: 0.3em 0; line-height: 1.7; }
.post-content blockquote {
    margin: 0.8em 0; padding: 0.6em 1em;
    border-left: 4px solid var(--primary);
    background: #f7f7fc; color: var(--muted);
    border-radius: 0 6px 6px 0;
}
.post-content blockquote p { margin: 0.4em 0; }
.post-content code {
    background: #f0f1f5; padding: 2px 6px;
    border-radius: 4px; font-size: 0.92em;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    color: #d63384;
}
.post-content pre {
    margin: 0.8em 0; padding: 14px 16px;
    background: #1e1e2e; color: #cdd6f4;
    border-radius: 8px; overflow-x: auto;
    font-size: 13px; line-height: 1.6;
}
.post-content pre code {
    background: none; padding: 0; color: inherit;
    font-size: inherit; border-radius: 0;
}
.post-content table {
    width: 100%; margin: 0.8em 0; border-collapse: collapse;
    border: 1px solid var(--border); border-radius: 6px;
}
.post-content th, .post-content td {
    border: 1px solid var(--border); padding: 8px 12px;
    text-align: left; font-size: 13px;
}
.post-content th { background: #f7f7fc; font-weight: 600; }
.post-content img {
    max-width: 100%; height: auto; border-radius: 8px;
    margin: 0.8em 0;
}
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }

/* ========== Markdown 内容（回帖） ========== */
.reply-body h1, .reply-body h2, .reply-body h3,
.reply-body h4, .reply-body h5, .reply-body h6 {
    margin: 0.8em 0 0.4em; font-weight: 600; line-height: 1.4;
}
.reply-body h1 { font-size: 1.35em; }
.reply-body h2 { font-size: 1.18em; }
.reply-body h3 { font-size: 1.08em; }
.reply-body p { margin: 0.5em 0; }
.reply-body a { color: var(--primary); text-decoration: underline; }
.reply-body strong { font-weight: 700; }
.reply-body em { font-style: italic; }
.reply-body ul, .reply-body ol { margin: 0.4em 0; padding-left: 1.6em; }
.reply-body li { margin: 0.2em 0; line-height: 1.6; }
.reply-body blockquote {
    margin: 0.5em 0; padding: 0.4em 0.8em;
    border-left: 3px solid var(--primary);
    background: #f7f7fc; color: var(--muted);
    border-radius: 0 4px 4px 0; font-size: 13px;
}
.reply-body code {
    background: #f0f1f5; padding: 1px 5px;
    border-radius: 4px; font-size: 0.9em;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    color: #d63384;
}
.reply-body pre {
    margin: 0.6em 0; padding: 10px 14px;
    background: #1e1e2e; color: #cdd6f4;
    border-radius: 6px; overflow-x: auto;
    font-size: 12.5px; line-height: 1.55;
}
.reply-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; border-radius: 0; }
.reply-body table {
    width: 100%; margin: 0.5em 0; border-collapse: collapse;
    border: 1px solid var(--border); border-radius: 4px;
}
.reply-body th, .reply-body td {
    border: 1px solid var(--border); padding: 6px 10px;
    text-align: left; font-size: 12.5px;
}
.reply-body th { background: #f7f7fc; font-weight: 600; }
.reply-body img { max-width: 100%; height: auto; border-radius: 6px; margin: 0.5em 0; }
.reply-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

/* ========== 响应式：平板 ≤ 960px ========== */
@media (max-width: 960px) {
    .layout { max-width: 100%; padding: 0 12px; gap: 12px; }
    .layout.single { padding: 0 12px; }
}

/* ========== 响应式：手机 ≤ 720px ========== */
@media (max-width: 720px) {
    html, body { font-size: 15px; }

    /* 顶栏紧凑 */
    .topbar { padding: 10px 14px; }
    .brand { font-size: 16px; }
    .menu-btn { display: inline-flex; align-items: center; justify-content: center; }

    /* 主体改为单列 */
    .layout { grid-template-columns: 1fr; gap: 0; margin: 12px auto; padding: 0 12px; }
    .layout.single { max-width: 100%; margin: 12px auto; padding: 0 12px; }

    /* 侧边栏：左侧抽屉 */
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 78%; max-width: 300px;
        z-index: 20; border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar h3 { margin-top: 0; }
    .board-list li { padding: 10px 12px; font-size: 15px; }

    /* 内容区 */
    .content { padding: 12px; border-radius: 8px; }
    .content-header h2 { font-size: 16px; }
    .sort-switch label { margin-left: 0; margin-right: 10px; }

    /* 帖子列表：两行卡片式（第一行标题，第二行 作者 · 时间 · 💬 N） */
    .post-list li {
        display: block; /* 放弃 grid，改纯 block，避免复杂控制 */
        padding: 14px 4px;
    }
    .post-list .title {
        display: block; font-size: 15px; line-height: 1.45; margin-bottom: 8px;
    }
    .post-list .title a { display: inline; }
    .post-list .meta {
        display: inline-flex; flex-wrap: wrap; align-items: center;
        gap: 4px 10px; font-size: 12px; vertical-align: middle;
    }
    .post-list .meta br { display: none; }  /* 隐藏原 HTML 中的 <br> */
    .post-list .rcount {
        display: inline-flex; align-items: center; gap: 4px;
        text-align: left; font-size: 12px; font-weight: 500;
        color: var(--muted); margin-left: 10px; vertical-align: middle;
    }
    .post-list .rcount::before { content: "💬"; }
    .post-list .rcount small { display: none; } /* 移动端不显示 "回帖" 字样 */

    /* 详情页 */
    .post-detail { padding: 16px; }
    .post-detail h1 { font-size: 18px; margin: 6px 0 12px; }
    .post-meta { font-size: 12px; }

    .replies { padding: 12px 14px; }
    .reply-list li { padding: 10px 0; }
    .reply-header { font-size: 12px; }
    .reply-body { font-size: 14px; }

    /* Markdown 尺寸压缩 */
    .post-content { line-height: 1.75; }
    .post-content h1 { font-size: 1.35em; }
    .post-content h2 { font-size: 1.2em; }
    .post-content h3 { font-size: 1.08em; }
    .post-content pre { padding: 10px 12px; font-size: 12px; }
    .post-content table { font-size: 12px; }
    .post-content th, .post-content td { padding: 6px 8px; }
    .reply-body pre { padding: 8px 10px; font-size: 12px; }

    /* 翻页按钮更大 */
    .pager button { padding: 8px 16px; font-size: 14px; }

    /* 头像略小 */
    .avatar { width: 24px; height: 24px; font-size: 13px; }

    .hint { font-size: 12px; }
}

/* ========== 超小屏 ≤ 380px ========== */
@media (max-width: 380px) {
    .post-list .title { font-size: 14px; }
    .brand { font-size: 15px; gap: 6px; }
    .post-list .rcount { margin-left: 6px; }
}
