:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --code-bg: #0f172a;
  --code-fg: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.72;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: inline-block;
}
.nav-links { display: flex; align-items: center; gap: 18px; font-size: .95rem; }
.nav-links a { color: var(--muted); font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.search-box { display: flex; gap: 6px; }
.search-box input {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .9rem;
  width: 200px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); background: #fff; }
.search-box button, .btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.search-box button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--text); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.container {
  max-width: 1180px;
  margin: 26px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
}
.list-header { margin-bottom: 16px; }
.list-header h1 { margin: 0 0 6px; font-size: 1.45rem; }
.list-header p { margin: 0; color: var(--muted); font-size: .95rem; }

.post-list { display: flex; flex-direction: column; gap: 14px; }
.post-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.post-item:hover { border-color: #bfdbfe; transform: translateY(-1px); }
.post-item h2 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.4; }
.post-item h2 a { color: var(--text); }
.post-item h2 a:hover { color: var(--accent); text-decoration: none; }
.post-excerpt { margin: 0 0 10px; color: #475569; font-size: .93rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: .83rem; color: var(--muted); }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: .78rem;
  font-weight: 500;
}
.badge-tag { background: var(--surface-2); color: #475569; }
.badge:hover { background: #dbeafe; text-decoration: none; }

.article-title { margin: 0 0 12px; font-size: 1.7rem; line-height: 1.35; }
.article-body {
  margin-top: 20px;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.article-body img { max-width: 100%; height: auto; border-radius: 8px; }
.article-body pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.55;
  position: relative;
}
.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .88em;
}
.article-body p > code, .article-body li > code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  color: #be123c;
}
.article-body table { width: 100%; border-collapse: collapse; margin: 16px 0; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-body blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--accent);
  background: #f8fafc;
  color: #334155;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.12); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; padding: 3px 9px; font-size: 12px; cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.22); }

.adjacent {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: .92rem;
}
.adjacent .next { text-align: right; }

.comments-box { margin-top: 20px; }
.comment-item { padding: 12px 0; border-top: 1px solid var(--border); }
.comment-item:first-child { border-top: none; }
.comment-author { font-weight: 600; font-size: .92rem; }
.comment-date { color: var(--muted); font-size: .8rem; margin-left: 8px; }
.comment-text { margin: 6px 0 0; font-size: .92rem; white-space: pre-wrap; }

.pagination {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
}
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sidebar { display: flex; flex-direction: column; gap: 16px; }
.widget h3 { margin: 0 0 12px; font-size: 1rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cat-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.cat-list li { display: flex; justify-content: space-between; align-items: center; font-size: .92rem; }
.cat-count { background: var(--surface-2); color: var(--muted); font-size: .78rem; padding: 1px 8px; border-radius: 999px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }

footer.site-footer {
  max-width: 1180px;
  margin: 36px auto 28px;
  padding: 18px 20px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .86rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* Admin styles */
.admin-wrap { max-width: 1100px; margin: 28px auto; padding: 0 20px; }
.admin-nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.admin-nav-links { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.form-group input[type=text], .form-group input[type=password], .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; font-family: inherit;
}
.form-group textarea { min-height: 300px; font-family: ui-monospace, monospace; font-size: .88rem; }
.flash { padding: 10px 14px; border-radius: 8px; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; margin-bottom: 14px; font-size: .92rem; }
.alert-err { padding: 10px 14px; border-radius: 8px; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; margin-bottom: 14px; font-size: .92rem; }

@media (max-width: 880px) {
  .container { grid-template-columns: 1fr; }
  .search-box input { width: 130px; }
  .adjacent { grid-template-columns: 1fr; }
}
