/* ===== 前台样式 ===== */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container { width: min(960px, 92vw); margin: 0 auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 头部 */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, .92);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.site-logo { font-size: 1.25rem; font-weight: 800; color: var(--text); letter-spacing: .5px; }
.site-logo:hover { text-decoration: none; }
.site-nav { display: flex; gap: 22px; }
.site-nav a { color: var(--muted); font-size: .95rem; font-weight: 500; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-nav a.active { color: var(--accent); font-weight: 700; }

/* 主区域 */
.main { flex: 1; padding: 34px 0 60px; }

/* 页头 */
.page-head { margin-bottom: 26px; }
.page-title { font-size: 2rem; font-weight: 800; letter-spacing: .5px; }
.page-desc { color: var(--muted); margin-top: 6px; }

/* 筛选栏 */
.filter-bar { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.search-form { display: flex; flex: 1; min-width: 260px; }
.search-form input {
  flex: 1; padding: 10px 16px; border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius); font-size: .95rem; outline: none;
  background: var(--card);
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
  padding: 10px 22px; border: none; background: var(--accent); color: #fff;
  border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-size: .95rem;
}
.category-select {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); font-size: .95rem; cursor: pointer; outline: none; color: var(--text);
}
.filter-hint { color: var(--muted); margin: -8px 0 18px; font-size: .9rem; }
.filter-clear { margin-left: 8px; font-size: .85rem; }

/* 列表卡片 */
.post-list { display: flex; flex-direction: column; gap: 18px; }
.post-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0, 0, 0, .08); }
.post-card-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }
.post-card-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .85rem; }
.meta-item { color: var(--muted); }
.post-card-summary { color: #4b5563; margin-top: 10px; font-size: .93rem; }
.post-card-tags { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* 徽章 */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
}
.badge.cat { background: var(--accent-soft); color: var(--accent); }
.badge.diff { background: #fdf2f8; color: #db2777; }
.badge.contest { background: #f5f3ff; color: #7c3aed; }
.badge.draft { background: #fef3c7; color: #b45309; }
.tag-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: #f3f4f6; color: var(--muted); font-size: .78rem;
  border: 1px solid var(--border);
}
.tag-badge:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* 比赛列表（前台） */
.contest-list { display: flex; flex-direction: column; gap: 16px; }
.contest-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.contest-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0, 0, 0, .08); }
.contest-card-main { flex: 1; min-width: 0; }
.contest-name { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.contest-card:hover .contest-name { color: var(--accent); }
.contest-card-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .85rem; }
.contest-card-desc { color: var(--muted); font-size: .88rem; margin-top: 8px; }
.contest-arrow {
  font-size: 1.4rem; color: var(--muted); flex-shrink: 0;
  transition: transform .18s ease, color .18s ease;
}
.contest-card:hover .contest-arrow { transform: translateX(4px); color: var(--accent); }

/* 比赛详情页（前台） */
.contest-head {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 32px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.contest-head-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: .88rem; }
.contest-head-desc { color: var(--muted); margin-top: 12px; font-size: .93rem; }

/* 分页 */
.pagination {
  display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 34px;
}
.pagination a {
  padding: 8px 18px; background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); font-size: .9rem;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-info { color: var(--muted); font-size: .88rem; }

.empty {
  text-align: center; padding: 70px 20px; color: var(--muted);
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ===== 详情页 ===== */
.post-detail {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 38px 42px; box-shadow: var(--shadow);
}
.post-detail-head { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 26px; }
.post-detail-title { font-size: 1.8rem; font-weight: 800; line-height: 1.35; margin-bottom: 14px; }
.post-detail-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .87rem; }
.problem-link { font-size: .87rem; }
.post-detail-tags { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.loading-tip { color: var(--muted); }

/* Markdown 正文排版 */
.markdown-body { font-size: 1rem; color: #24292f; word-wrap: break-word; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.6em 0 .7em; font-weight: 700; line-height: 1.4;
}
.markdown-body h1 { font-size: 1.6rem; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.35rem; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body p { margin: .8em 0; }
.markdown-body ul, .markdown-body ol { margin: .8em 0; padding-left: 1.8em; }
.markdown-body li { margin: .3em 0; }
.markdown-body blockquote {
  margin: 1em 0; padding: .6em 1.1em; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0; color: #374151;
}
.markdown-body code {
  background: #f3f4f6; padding: .15em .45em; border-radius: 6px;
  font-family: Consolas, 'Courier New', monospace; font-size: .88em; color: #c7254e;
}
.markdown-body pre {
  background: #f6f8fa; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; overflow-x: auto; margin: 1em 0; line-height: 1.55;
}
.markdown-body pre code { background: none; padding: 0; color: inherit; font-size: .88rem; }
.markdown-body table {
  border-collapse: collapse; margin: 1em 0; width: 100%;
  display: block; overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border); padding: 8px 14px; text-align: left;
}
.markdown-body th { background: #f6f8fa; font-weight: 600; }
.markdown-body tr:nth-child(even) td { background: #fafbfc; }
.markdown-body img { max-width: 100%; border-radius: 8px; }
.markdown-body a code { color: var(--accent); }
.markdown-body .katex-display { margin: 1.2em 0; overflow-x: auto; overflow-y: hidden; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* 上一篇/下一篇 */
.post-nav {
  display: flex; justify-content: space-between; gap: 14px; margin-top: 22px; flex-wrap: wrap;
}
.post-nav-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px; color: var(--text); font-size: .9rem; max-width: 46%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post-nav-item:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.post-nav-item.right { margin-left: auto; }

/* 归档 */
.archive-group { margin-bottom: 30px; }
.archive-month {
  font-size: 1.15rem; font-weight: 700; margin-bottom: 12px;
  padding-left: 12px; border-left: 4px solid var(--accent);
}
.archive-list {
  list-style: none; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 0;
}
.archive-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 22px; border-bottom: 1px solid #f0f1f3; gap: 12px;
}
.archive-list li:last-child { border-bottom: none; }
.archive-link { color: var(--text); font-size: .95rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-link:hover { color: var(--accent); }
.archive-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.archive-date { color: var(--muted); font-size: .82rem; }

/* 页脚 */
.site-footer {
  background: var(--card); border-top: 1px solid var(--border);
  padding: 22px 0; text-align: center; color: var(--muted); font-size: .85rem;
}
.footer-sub { opacity: .75; font-size: .78rem; margin-top: 2px; }

.page-404 h1 { font-size: 4rem; color: var(--accent); }
.btn-link { display: inline-block; margin-top: 12px; color: var(--accent); font-weight: 600; }

/* 响应式 */
@media (max-width: 640px) {
  .post-detail { padding: 24px 20px; }
  .post-detail-title { font-size: 1.4rem; }
  .site-nav { gap: 14px; }
  .post-nav-item { max-width: 100%; }
}
