/* ============ 基础 ============ */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #24292f;
  --muted: #6a737d;
  --border: #eaecef;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --tag-bg: #f0f2f5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
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.6;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
.container { max-width: 1320px; margin: 0 auto; padding: 0 16px; }

/* ============ 顶部导航 ============ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 24px;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; flex-shrink: 0; }
.logo-img {
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: cover; display: block;
}
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 16px;
}
.top-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top-nav a {
  padding: 6px 12px; border-radius: 6px;
  color: var(--muted); font-size: 15px; white-space: nowrap;
  transition: all .15s;
}
.top-nav a:hover { color: var(--primary); background: var(--primary-soft); }
.top-nav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.search-box { flex-shrink: 0; }
.search-box input {
  width: 200px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 17px;
  background: var(--bg); font-size: 14px; outline: none;
  transition: all .2s;
}
.search-box input:focus { width: 260px; border-color: var(--primary); background: #fff; }

/* ============ 布局：左栏 + 主体 + 右栏（主体占比 ≥ 60%）============ */
.layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 200px;
  gap: 20px;
  padding-top: 24px;
  padding-bottom: 40px;
  align-items: start;
}

/* ============ 侧边栏 ============ */
.sidebar { position: sticky; top: 84px; }
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.widget h3 {
  font-size: 14px; font-weight: 600; color: var(--muted);
  margin-bottom: 10px; letter-spacing: .05em;
}
.cat-list li { margin-bottom: 2px; }
.cat-list a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: 6px; font-size: 14px;
  transition: all .15s;
}
.cat-list a:hover { background: var(--primary-soft); color: var(--primary); }
.cat-list a.active { background: var(--primary); color: #fff; font-weight: 600; }
.cat-count {
  font-size: 12px; color: var(--muted);
  background: var(--tag-bg); padding: 0 8px; border-radius: 10px;
}
.cat-list a.active .cat-count { background: rgba(255,255,255,.25); color: #fff; }
.recent-list li {
  padding: 6px 0; border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.recent-list li:last-child { border-bottom: none; }
.recent-list a {
  display: block; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .15s;
}
.recent-list a:hover { color: var(--primary); }
.about-text { font-size: 13px; color: var(--muted); }

/* 左栏链接列表 */
.link-list li { margin-bottom: 2px; }
.link-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px; font-size: 14px;
  transition: all .15s;
}
.link-item:hover { background: var(--primary-soft); color: var(--primary); }
.link-icon { width: 20px; text-align: center; flex-shrink: 0; }

/* ============ 回到顶部悬浮按钮 ============ */
.back-to-top {
  position: fixed; right: 28px; bottom: 36px; z-index: 200;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card); color: var(--primary);
  font-size: 20px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: all .25s;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (max-width: 860px) {
  .back-to-top { right: 16px; bottom: 20px; width: 40px; height: 40px; }
}

/* ============ 右侧边栏（紧凑版）============ */
.sidebar-right { position: sticky; top: 84px; }
.sidebar-right .widget { padding: 12px 14px; margin-bottom: 12px; }
.sidebar-right .widget h3 { margin-bottom: 6px; }
.hot-list { counter-reset: hot; }
.hot-list li { counter-increment: hot; }
.hot-list a {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 4px 0; font-size: 12.5px; line-height: 1.45;
  border-bottom: 1px dashed var(--border);
}
.hot-list li:last-child a { border-bottom: none; }
.hot-list a::before {
  content: counter(hot);
  flex-shrink: 0;
  width: 16px; height: 16px; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; border-radius: 4px;
  background: var(--tag-bg); color: var(--muted);
}
.hot-list li:nth-child(-n+3) a::before { background: var(--primary); color: #fff; }
.hot-list a { color: var(--text); transition: color .15s; }
.hot-list a:hover { color: var(--primary); }
.hot-list li a {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-widget .ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border: 2px dashed #d0d7de; border-radius: 8px;
  background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f4f6f8 10px, #f4f6f8 20px);
}
.ad-label { font-size: 11px; color: #9ca3af; font-weight: 600; letter-spacing: .1em; }
.ad-size { font-size: 10px; color: #c4cbd4; }
.ad-slot-250 { width: 100%; height: 160px; }
.ad-slot-600 { width: 100%; height: 260px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .tag {
  font-size: 11.5px; padding: 2px 8px; border-radius: 10px;
  cursor: pointer; transition: all .15s;
}
.tag-cloud .tag:hover { background: var(--primary); color: #fff; }

/* ============ 文章列表 ============ */
.page-head { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.post-list { display: flex; flex-direction: column; gap: 14px; }
.post-card {
  display: flex; gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: all .2s;
  cursor: pointer;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); border-color: #d0d7de; }
.post-thumb {
  width: 160px; height: 100px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff;
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.post-tags { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.tag {
  font-size: 12px; padding: 1px 8px; border-radius: 4px;
  background: var(--tag-bg); color: var(--muted);
}
.tag.tag-cat { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.post-title {
  font-size: 16.5px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card:hover .post-title { color: var(--primary); }
.post-excerpt {
  font-size: 13.5px; color: var(--muted); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-meta { margin-top: auto; padding-top: 8px; font-size: 12.5px; color: #9ca3af; }
.empty-tip { text-align: center; color: var(--muted); padding: 60px 0; }

/* ============ 页脚 ============ */
.footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 20px 0;
  text-align: center; font-size: 13px; color: var(--muted);
}

/* ============ 详情页 ============ */
.article-wrap { max-width: 820px; margin: 0 auto; }
.article-hero {
  width: 100%; aspect-ratio: 16 / 7; object-fit: cover;
  border-radius: 10px; margin-bottom: 22px; display: block;
}
.article-head { margin-bottom: 20px; }
.article-title { font-size: 26px; line-height: 1.4; margin: 8px 0 12px; }
.article-meta { font-size: 13px; color: var(--muted); }
.article-content { font-size: 15.5px; }
.article-content h2 { font-size: 20px; margin: 24px 0 12px; }
.article-content p { margin: 12px 0; color: #374151; }
.article-content ul { padding-left: 22px; list-style: disc; margin: 12px 0; }
.article-content li { margin: 6px 0; color: #374151; }
.article-content code {
  background: var(--tag-bg); padding: 2px 6px; border-radius: 4px;
  font-size: 13.5px;
}
.back-link {
  display: inline-block; margin-bottom: 16px;
  font-size: 14px; color: var(--primary);
}
.back-link:hover { text-decoration: underline; }

/* ============ 移动端 ============ */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 180px minmax(0, 1fr); }
  .sidebar-right { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; order: 2; }
  .main { order: 1; }
  .top-nav { display: none; }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 160px; }
  .post-thumb { width: 120px; height: 84px; font-size: 20px; }
}

/* 移动端汉堡菜单 */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--text); margin: 4px 0; border-radius: 2px;
}
@media (max-width: 860px) {
  .hamburger { display: block; }
  .topbar-inner { gap: 12px; }
  .mobile-nav {
    display: none; background: var(--card);
    border-bottom: 1px solid var(--border); padding: 8px 16px;
  }
  .mobile-nav.open { display: block; }
  .mobile-nav a {
    display: block; padding: 10px 8px; font-size: 15px;
    border-radius: 6px;
  }
  .mobile-nav a:hover { background: var(--primary-soft); color: var(--primary); }
}
@media (min-width: 861px) { .mobile-nav { display: none !important; } }
