:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #6b7269;
  --accent: #2f6f4f;
  --accent-soft: #e6f0ea;
  --border: #e6e4dd;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --radius: 14px;
  --maxw: 860px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  --bg: #14171a;
  --surface: #1c2125;
  --text: #e7e9e6;
  --muted: #9aa39c;
  --accent: #6fbf94;
  --accent-soft: #22322b;
  --border: #2b3236;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .5px;
}
.nav { display: flex; align-items: center; gap: 18px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
  transition: color .2s;
}
.nav a:hover, .nav a.active { color: var(--accent); }
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
  transition: transform .2s, border-color .2s;
}
.theme-toggle:hover { transform: rotate(-15deg); border-color: var(--accent); }

/* Hero */
.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
  margin: 0 0 12px;
  letter-spacing: -.5px;
  line-height: 1.2;
}
.hero p { color: var(--muted); font-size: 1.05rem; margin: 0 auto 28px; max-width: 520px; }

.search-box { max-width: 420px; margin: 0 auto; }
.search-box input {
  width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Post grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px 0 60px;
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s;
  overflow: hidden;
}
.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,.1);
}
.post-card a { display: block; padding: 24px; color: inherit; text-decoration: none; }
.tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.post-card h2 { font-size: 1.2rem; margin: 0 0 10px; line-height: 1.35; }
.post-card p { color: var(--muted); font-size: .92rem; margin: 0 0 16px; }
.post-card time { font-size: .8rem; color: var(--muted); }

.no-results { text-align: center; color: var(--muted); padding: 40px 0; }

/* Article */
.article { padding: 56px 0 80px; }
.article-header { margin-bottom: 36px; }
.article-header h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); line-height: 1.25; margin: 12px 0; letter-spacing: -.5px; }
.article-meta { color: var(--muted); font-size: .9rem; }
.article-body { font-size: 1.05rem; }
.article-body h2 { margin-top: 2em; font-size: 1.4rem; }
.article-body h3 { margin-top: 1.6em; font-size: 1.15rem; }
.article-body p { margin: 1.1em 0; }
.article-body a { color: var(--accent); }
.article-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.6;
}
.article-body code {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .88em;
}
.article-body pre code { background: none; padding: 0; }
.article-body blockquote {
  margin: 1.4em 0;
  padding: 4px 20px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
}
.back-link:hover { color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

@media (max-width: 600px) {
  .hero { padding: 48px 0 24px; }
  .post-grid { grid-template-columns: 1fr; }
}
