* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "PingFang SC", "Hiragino Sans GB";
  line-height: 1.6;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  color: #333;
}

/* ===== Header & Nav ===== */
.site-header {
  border-bottom: 1px solid #eee;
  margin-bottom: 24px;
  padding: 16px 0;
}

.site-header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  text-decoration: none;
}

.nav-menu {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  font-size: 13px;
  color: #666;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: #f0f0f0;
  color: #333;
}

.nav-link.active {
  background: #111;
  color: #fff;
}

main {
  margin-bottom: 40px;
}

/* ===== Home Layout (two columns) ===== */
.home-layout {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}

.post-grid {
  flex: 1;
  display: grid;
  gap: 8px;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
}

.search-box {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.search-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: #333;
}

.search-btn {
  padding: 8px 14px;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.search-btn:hover {
  background: #333;
}

.tag-list h3 {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
  color: #555;
  transition: color 0.15s;
}

.tag-filter:hover {
  color: #111;
}

.tag-filter input[type="checkbox"] {
  accent-color: #333;
}

.tag-expand-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 0;
  font-size: 12px;
  color: #666;
  background: none;
  border: 1px dashed #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.tag-expand-btn:hover {
  color: #333;
  border-color: #999;
}

/* ===== Pagination ===== */
.pagination {
  margin: 20px 0;
  grid-column: 1 / -1;
}

.pagination-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

.page-link {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  color: #555;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.page-link:hover {
  color: #111;
  border-color: #999;
}

.page-link.active {
  color: #fff;
  background: #111;
  border-color: #111;
}

.page-link.disabled {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

/* ===== Post Card ===== */
.post-card {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.post-card:hover {
  border-color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.post-card a {
  display: block;
  padding: 14px;
  text-decoration: none;
  color: inherit;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 12px;
  margin-bottom: 8px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.sticky-icon {
  margin-right: 4px;
  display: inline-block;
}

.card-excerpt {
  color: #666;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  display: inline-block;
  background: #f5f5f5;
  color: #666;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* ===== Article Detail (post.html) ===== */
article {
  margin-bottom: 40px;
}

article h1 {
  margin-bottom: 10px;
}

article h2 {
  margin-top: 30px;
  margin-bottom: 15px;
}

article h3 {
  margin-top: 25px;
  margin-bottom: 10px;
}

article p {
  margin-bottom: 15px;
}

article ul, article ol {
  margin-bottom: 15px;
  padding-left: 25px;
}

article li {
  margin-bottom: 8px;
}

article pre {
  background: #f4f4f4;
  padding: 15px;
  overflow-x: auto;
  border-radius: 5px;
  margin-bottom: 15px;
}

article code {
  background: #f4f4f4;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

article blockquote {
  border-left: 4px solid #ddd;
  padding-left: 15px;
  margin-left: 0;
  color: #666;
}

article img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
}

article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
}

article th, article td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

article th {
  background: #f4f4f4;
}

/* ===== Legacy / Utility ===== */
.meta {
  color: #666;
  font-size: 0.9em;
  margin-bottom: 20px;
}

.post-footer {
  margin-top: 40px;
  padding-top: 20px;
}

.post-footer hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid #eee;
}

footer {
  border-top: 1px solid #eee;
  margin-top: 40px;
  padding-top: 20px;
  color: #666;
  font-size: 0.9em;
  text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .home-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
    order: -1;
  }

  .tag-filter {
    display: inline-flex;
    margin-right: 4px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .nav-menu {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  body {
    padding: 0 15px;
  }

  article pre {
    padding: 10px;
  }
}
