/* ==========================================================================
   论坛风格 Typecho 主题
   顶部导航（通栏背景）+ 左侧帖子列表 + 右侧热门帖子
   配色与内容区宽度由后台配置注入到 :root 变量
   ========================================================================== */

:root {
    /* 以下变量由 header.php 按后台配置覆盖 */
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, .12);
    --nav: #2563eb;
    --nav-text: #ffffff;
    --nav-soft: rgba(255, 255, 255, .14);
    --nav-strong: rgba(255, 255, 255, .24);
    --nav-line: rgba(255, 255, 255, .45);
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #24303f;
    --muted: #7b8794;
    --border: #e6e9ef;
    --head: #f8fafc;
    --hover: #f7faff;
    --chip: #eef1f5;
    --input: #fbfcfe;
    --content-max: 1280px;
    --side-w: 320px;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部导航：条带通栏，菜单跟随内容宽度 ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: var(--nav);
    color: var(--nav-text);
    box-shadow: 0 2px 12px rgba(16, 24, 40, .14);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-width: var(--content-max);
    min-height: 60px;
    margin: 0 auto;
    padding: 0 clamp(14px, 2.5vw, 36px);
}

.brand { flex: none; display: flex; align-items: center; }
.brand-name {
    color: var(--nav-text);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.brand-logo { height: 34px; width: auto; display: block; }

.site-nav {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.nav-item {
    flex: none;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--nav-text);
    opacity: .88;
    font-size: 14.5px;
    white-space: nowrap;
    transition: background .15s, color .15s, opacity .15s;
}
.nav-item:hover { background: var(--nav-soft); color: var(--nav-text); opacity: 1; }
.nav-item.is-current {
    background: var(--nav-strong);
    color: var(--nav-text);
    opacity: 1;
    font-weight: 600;
}

.header-actions { flex: none; display: flex; align-items: center; gap: 10px; }

.search-form {
    display: flex;
    align-items: center;
    padding: 3px 3px 3px 14px;
    background: var(--nav-soft);
    border-radius: 999px;
}
.search-input {
    width: 150px;
    border: none;
    background: transparent;
    color: var(--nav-text);
    font-size: 13.5px;
    outline: none;
}
.search-input::placeholder { color: var(--nav-text); opacity: .7; }
.search-btn {
    border: none;
    background: var(--nav-text);
    color: var(--nav);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
}

.action-btn {
    padding: 7px 14px;
    border: 1px solid var(--nav-line);
    border-radius: 8px;
    color: var(--nav-text);
    font-size: 13.5px;
    transition: background .15s;
}
.action-btn:hover { background: var(--nav-soft); }

.nav-toggle {
    display: none;
    border: 1px solid var(--nav-line);
    background: transparent;
    color: var(--nav-text);
    font-size: 18px;
    line-height: 1;
    padding: 6px 11px;
    border-radius: 8px;
}

/* ---------- 主体骨架：内容区与导航菜单同宽 ---------- */
.site-body {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 22px clamp(14px, 2.5vw, 36px) 40px;
}

.forum-wrap {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

.forum-primary { flex: 1 1 auto; min-width: 0; }

.forum-side {
    flex: 0 0 var(--side-w);
    width: var(--side-w);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 78px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.page-title {
    margin: 0 0 14px;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
    font-size: 19px;
    font-weight: 600;
    color: var(--text);
}

/* ---------- 帖子列表 ---------- */
.topic-head {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--head);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--muted);
}

.topic-row {
    position: relative;
    display: flex;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.topic-row:last-child { border-bottom: none; }
.topic-row::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: transparent;
    transition: background .15s;
}
.topic-row:hover { background: var(--hover); }
.topic-row:hover::before { background: var(--accent); }
.topic-row:hover .topic-title { color: var(--accent); }

.td-topic { flex: 1 1 auto; min-width: 0; }
/* 作者 / 回复 / 最后更新三列整体靠右收拢 */
.td-author {
    flex: 0 0 96px;
    font-size: 13px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-reply { flex: 0 0 64px; text-align: center; }
.td-time { flex: 0 0 104px; text-align: right; font-size: 12.5px; color: var(--muted); }

.topic-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topic-cat {
    flex: none;
    padding: 2px 8px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.td-author a { color: var(--muted); }
.td-author a:hover { color: var(--accent); }

.reply-badge {
    display: inline-block;
    min-width: 26px;
    padding: 2px 8px;
    background: var(--chip);
    color: var(--muted);
    border-radius: 999px;
    font-size: 12px;
}
.topic-row:hover .reply-badge { background: var(--accent-soft); color: var(--accent); }

.topic-empty { margin: 0; padding: 44px 20px; text-align: center; color: var(--muted); }

/* ---------- 右侧栏 ---------- */
.side-card {
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.side-title,
.comments-title,
.respond-title {
    position: relative;
    margin: 0 0 12px;
    padding-left: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.side-title::before,
.comments-title::before,
.respond-title::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 15px;
    border-radius: 2px;
    background: var(--accent);
}

.hot-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }

.hot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 6px;
    border-radius: 8px;
    transition: background .15s;
}
.hot-item:hover { background: var(--hover); }

.hot-rank {
    flex: none;
    width: 20px; height: 20px;
    line-height: 20px;
    text-align: center;
    background: var(--chip);
    color: var(--muted);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}
.hot-rank.is-top { background: var(--accent); color: #fff; }

.hot-title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text);
    font-size: 13.5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.hot-title:hover { color: var(--accent); }

.hot-num {
    flex: none;
    padding: 1px 8px;
    background: var(--chip);
    color: var(--muted);
    border-radius: 999px;
    font-size: 12px;
}

.side-empty { margin: 0; padding: 12px 0; text-align: center; color: var(--muted); font-size: 13px; }

.cat-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.cat-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 8px;
    border-radius: 8px;
}
.cat-list li:hover { background: var(--hover); }
.cat-list a { color: var(--text); font-size: 13.5px; }
.cat-list a:hover { color: var(--accent); }
.cat-count { color: var(--muted); font-size: 12px; }

.stat-list { margin: 0; padding: 0; list-style: none; display: flex; }
.stat-list li { flex: 1 1 0; text-align: center; padding: 6px 0; }
.stat-list li + li { border-left: 1px solid var(--border); }
.stat-list span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.stat-list b { color: var(--accent); font-size: 18px; }

/* ---------- 帖子详情 ---------- */
.post-single { padding: 22px 26px; }

.post-title { margin: 0 0 12px; font-size: 24px; line-height: 1.4; color: var(--text); }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}
.post-meta a:hover { text-decoration: underline; }

.post-content { color: var(--text); font-size: 15.5px; line-height: 1.85; word-wrap: break-word; }
.post-content p { margin: 0 0 1em; }
.post-content h2,
.post-content h3,
.post-content h4 { margin: 1.4em 0 .6em; line-height: 1.45; }
.post-content img { height: auto; border-radius: 8px; }
.post-content blockquote {
    margin: 1em 0;
    padding: 10px 16px;
    background: var(--head);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    color: var(--muted);
}
.post-content pre {
    padding: 14px 16px;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 8px;
    overflow: auto;
    font-size: 13.5px;
}
.post-content code {
    padding: 2px 6px;
    background: rgba(127, 127, 127, .16);
    border-radius: 4px;
    font-size: .9em;
}
.post-content pre code { padding: 0; background: none; }
.post-content table { width: 100%; border-collapse: collapse; }
.post-content th,
.post-content td { padding: 8px 10px; border: 1px solid var(--border); }

.post-tags {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.post-tags a {
    display: inline-block;
    margin: 0 6px 6px 0;
    padding: 3px 10px;
    background: var(--chip);
    color: var(--muted);
    border-radius: 999px;
}
.post-tags a:hover { background: var(--accent-soft); color: var(--accent); }

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 14px 20px;
    font-size: 13.5px;
}
.nav-next { text-align: right; }

/* ---------- 评论 ---------- */
.comments { margin-top: 18px; padding: 20px 26px; }

.comment-list { margin: 0; padding: 0; list-style: none; }

.comment-body {
    position: relative;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
}
.comment-body:last-child { border-bottom: none; }

.comment-children { margin: 0 0 0 44px; padding: 0; list-style: none; }

.comment-author { display: flex; align-items: center; gap: 10px; }
.comment-author img { width: 36px; height: 36px; border-radius: 50%; display: block; background: var(--chip); }
.comment-author cite,
.comment-author .fn { font-style: normal; font-weight: 600; font-size: 14px; color: var(--text); }

.comment-meta { margin: 4px 0 8px 44px; color: var(--muted); font-size: 12.5px; }
.comment-content { margin-left: 44px; color: var(--text); font-size: 14.5px; line-height: 1.75; word-wrap: break-word; }
.comment-content p { margin: 0 0 .7em; }
.comment-content p:last-child { margin-bottom: 0; }
.comment-reply { margin: 6px 0 0 44px; font-size: 12.5px; }
.comment-reply a { color: var(--muted); }
.comment-reply a:hover { color: var(--accent); }
.comment-awaiting-moderation { color: #b45309; font-size: 12px; }

.comment-children .comment-meta,
.comment-children .comment-content,
.comment-children .comment-reply { margin-left: 0; }

/* ---------- 评论表单 ---------- */
.respond { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-note { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.form-row .text { flex: 1 1 160px; }

.text,
.textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { resize: vertical; }
.text:focus,
.textarea:focus {
    background: var(--card);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.submit-btn {
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}
.submit-btn:hover { filter: brightness(.94); }

.comments-closed { color: var(--muted); font-size: 13px; }
.cancel-comment-reply { margin-bottom: 8px; font-size: 13px; }

/* ---------- 分页 ---------- */
.page-navigator {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}
.page-navigator li { list-style: none; }
.page-navigator a {
    display: inline-block;
    min-width: 34px;
    padding: 7px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13.5px;
    text-align: center;
    transition: .15s;
}
.page-navigator a:hover { border-color: var(--accent); color: var(--accent); }
.page-navigator .current a { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 404 ---------- */
.error-page { padding: 60px 20px; text-align: center; }
.error-code { margin: 0; color: var(--accent); font-size: 72px; line-height: 1; }
.error-text { margin: 12px 0 22px; color: var(--muted); }
.error-btn {
    display: inline-block;
    padding: 10px 26px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
}

/* ---------- 页脚 ---------- */
.site-footer {
    margin-top: auto;
    padding: 20px clamp(14px, 2.5vw, 36px);
    background: var(--card);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.footer-inner {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
}

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
    .forum-wrap { flex-direction: column; align-items: stretch; }
    .forum-side { position: static; width: 100%; flex: 0 0 auto; }

    .header-inner { flex-wrap: wrap; gap: 10px; }
    .brand { flex: 1 1 auto; }
    .nav-toggle { display: inline-block; }
    .site-nav {
        display: none;
        order: 3;
        flex: 1 1 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 6px 0 10px;
        overflow: visible;
    }
    .site-nav.is-open { display: flex; }
    .nav-item { padding: 10px 12px; }
}

@media (max-width: 720px) {
    .search-form { display: none; }
    .td-author { display: none; }
    .td-time { display: none; }
    .post-single,
    .comments { padding: 18px 16px; }
    .comment-children { margin-left: 20px; }
    .comment-meta,
    .comment-content,
    .comment-reply { margin-left: 0; }
    .comment-content { margin-top: 8px; }
}
