:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #24292f;
  --muted: #6b7280;
  --primary: #c0392b;
  --primary-dark: #96281b;
  --border: #e5e7eb;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.logo { font-size: 1.35rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.main-nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.main-nav a {
  padding: 6px 12px; border-radius: 8px; font-size: .95rem; white-space: nowrap;
  color: var(--muted);
}
.main-nav a:hover, .main-nav a.active { background: #f3f4f6; color: var(--primary); }

/* 手机端菜单按钮（桌面端隐藏） */
.menu-toggle {
  display: none; margin-left: auto; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 6px 14px; font-size: .95rem; cursor: pointer;
}
.menu-toggle:active { background: #f3f4f6; }
.search-form { display: flex; align-items: center; }
.search-form input {
  border: 1px solid var(--border); border-radius: 8px 0 0 8px;
  padding: 7px 12px; font-size: .9rem; width: 160px; outline: none; background: var(--bg);
}
.search-form input:focus { border-color: var(--primary); }
.search-form button {
  border: 1px solid var(--border); border-left: none; background: var(--card);
  border-radius: 0 8px 8px 0; padding: 6px 10px; cursor: pointer;
}

/* Post cards */
.site-main { padding: 28px 16px 48px; min-height: 60vh; }
.post-list { display: grid; gap: 16px; }
.post-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  transition: box-shadow .15s, transform .15s;
}
.post-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.post-card-title { font-size: 1.15rem; margin-bottom: 6px; }
.post-card-title a:hover { color: var(--primary); }
.post-card-meta { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; margin-bottom: 8px; }
.post-card-excerpt { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }
.read-more { color: var(--primary); font-size: .9rem; font-weight: 500; }

/* Pagination */
.pagination {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 28px; color: var(--muted); font-size: .92rem;
}
.pagination a {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px;
  background: var(--card);
}

/* Archive header */
.archive-header { margin-bottom: 22px; }
.archive-header h1 { font-size: 1.5rem; }
.archive-header p { color: var(--muted); font-size: .92rem; }

/* Post full */
.post-full {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 36px;
}
.post-header h1 { font-size: 1.7rem; line-height: 1.35; margin-bottom: 12px; }
.post-meta { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.badge {
  background: #fdecea; color: var(--primary); border-radius: 20px;
  padding: 2px 12px; font-size: .85rem;
}
.badge:hover { background: var(--primary); color: #fff; }
.post-content { margin-top: 24px; font-size: 1.02rem; overflow-wrap: break-word; }
.post-content p { margin: 14px 0; }
.post-content h2, .post-content h3 { margin: 26px 0 12px; }
.post-content img {
  max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 16px auto;
}
.post-content pre {
  background: #f6f8fa; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px; overflow-x: auto; white-space: pre-wrap; margin: 16px 0;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif; font-size: .98rem;
  line-height: 1.9;
}
.post-content blockquote {
  border-left: 4px solid var(--primary); padding: 8px 16px; margin: 16px 0;
  color: var(--muted); background: #fafafa; border-radius: 0 8px 8px 0;
}
.post-content a { color: var(--primary); text-decoration: underline; }
.video-embed {
  position: relative; width: 100%; padding-top: 56.25%; margin: 18px 0;
  border-radius: 8px; overflow: hidden; background: #000;
}
.video-embed iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.video-caption { text-align: center; color: var(--muted); font-size: .88rem; margin-top: -8px; }

/* Tags */
.post-tags { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  background: #f3f4f6; border-radius: 20px; padding: 3px 14px; font-size: .88rem;
  color: var(--muted);
}
.tag-chip:hover { background: var(--primary); color: #fff; }

/* Post nav */
.post-nav {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 28px;
  border-top: 1px solid var(--border); padding-top: 18px; font-size: .92rem;
}
.post-nav a { color: var(--muted); max-width: 48%; }
.post-nav a:hover { color: var(--primary); }
.related { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 18px; }
.related h2 { font-size: 1.15rem; margin-bottom: 10px; }
.related li { list-style: none; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.related li:last-child { border-bottom: none; }

/* 404 */
.not-found { text-align: center; padding: 80px 0; }
.not-found h1 { font-size: 4rem; color: var(--primary); }
.not-found p { color: var(--muted); margin: 10px 0 20px; }
.btn {
  background: var(--primary); color: #fff; border-radius: 8px; padding: 10px 24px;
  display: inline-block;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.load-more { border: none; cursor: pointer; font-size: .95rem; }
.load-more.htmx-request { opacity: .6; }
.load-end { color: var(--muted); font-size: .9rem; padding: 10px 0; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); background: var(--card);
  padding: 20px 0; color: var(--muted); font-size: .88rem; text-align: center;
}
.site-footer a { color: var(--muted); text-decoration: underline; }

/* 下载盒（网盘/下载链接） */
.download-box {
  margin-top: 28px; padding: 20px 22px; border-radius: 12px;
  background: #fff8f0; border: 1px solid #f5d9b8;
}
.download-box h2 { font-size: 1.1rem; margin: 0 0 14px; }
.download-list { list-style: none; margin: 0; padding: 0; }
.download-list li {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px dashed #f0e0c8;
}
.download-list li:last-child { border-bottom: none; }
.dl-name { font-weight: 600; }
.dl-btn {
  background: var(--primary); color: #fff; text-decoration: none;
  padding: 6px 16px; border-radius: 8px; font-size: .9rem;
}
.dl-btn:hover { background: var(--primary-dark); color: #fff; }
.dl-code { color: var(--muted); font-size: .88rem; }
.dl-code code { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }
.dl-tip { margin: 12px 0 0; font-size: .8rem; color: var(--muted); }

/* 搜索提示条 */
.search-notice {
  background: #fff7e6; border: 1px solid #ffd591; color: #ad6800;
  border-radius: 10px; padding: 14px 18px; margin-bottom: 18px;
}

/* 首页/列表页：主栏 + 侧栏布局 */
.page-layout { display: flex; gap: 28px; align-items: flex-start; }
.page-layout .content-col { flex: 1; min-width: 0; }
.sidebar { width: 280px; flex-shrink: 0; }
.side-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 16px; position: sticky; top: 76px;
}
.side-title {
  font-size: 1.02rem; margin: 0 0 12px; padding-bottom: 10px;
  border-bottom: 2px solid var(--primary); display: inline-block;
}
.hot-list { list-style: none; margin: 0; padding: 0; }
.hot-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.hot-item:last-child { border-bottom: none; }
.hot-rank {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 5px;
  background: #eee; color: #999; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.hot-rank.top3 { background: var(--primary); color: #fff; }
.hot-body { min-width: 0; }
.hot-link {
  display: block; font-size: .9rem; line-height: 1.45; color: var(--text);
  text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hot-link:hover { color: var(--primary); }
.hot-views { font-size: .76rem; color: var(--muted); }

@media (max-width: 900px) {
  .page-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .side-box { position: static; }
}

/* 文章封面图 */
.post-cover {
  width: 100%; max-height: 460px; object-fit: cover;
  border-radius: 10px; margin: 0 0 18px;
}

/* 列表卡片缩略图 */
.post-card.has-thumb {
  display: grid;
  grid-template-columns: 132px 1fr;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "thumb title" "thumb meta" "thumb excerpt" "thumb more";
  column-gap: 16px; row-gap: 4px; align-items: start;
}
.post-card.has-thumb .post-card-thumb { grid-area: thumb; }
.post-card.has-thumb .post-card-title { grid-area: title; margin-top: 0; }
.post-card.has-thumb .post-card-meta { grid-area: meta; }
.post-card.has-thumb .post-card-excerpt { grid-area: excerpt; }
.post-card.has-thumb .read-more { grid-area: more; }
.post-card .post-card-thumb img {
  width: 132px; height: 92px; object-fit: cover; border-radius: 8px; display: block;
}
@media (max-width: 640px) {
  .post-card.has-thumb { grid-template-columns: 1fr; grid-template-areas: "thumb" "title" "meta" "excerpt" "more"; }
  .post-card .post-card-thumb img { width: 100%; height: auto; max-height: 240px; }
}

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .menu-toggle { display: inline-flex; }
  /* 菜单改为下拉：默认隐藏，点击按钮展开 */
  .main-nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 2px; overflow: visible;
    background: var(--card); border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 18px rgba(0,0,0,.08);
    padding: 8px 16px 12px;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 12px; font-size: 1rem; }
  .search-form { width: 100%; order: 3; margin-top: 10px; }
  .search-form input { flex: 1; width: auto; }
  .post-full { padding: 22px 18px; }
  .post-header h1 { font-size: 1.4rem; }
}
