:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: rgba(79, 70, 229, 0.08);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 2px 14px rgba(17, 24, 39, 0.07);
  --shadow-hover: 0 10px 28px rgba(17, 24, 39, 0.13);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --card: #171a21;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --border: #262b36;
  --primary-soft: rgba(129, 140, 248, 0.12);
  --nav-bg: rgba(15, 17, 23, 0.85);
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo .logo-badge {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-links a.active { color: var(--primary); }

.theme-btn {
  background: var(--primary-soft);
  border: none;
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.theme-btn:hover { transform: rotate(20deg); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
  color: #fff;
  padding: 88px 20px 76px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.14) 0, transparent 40%),
              radial-gradient(circle at 80% 70%, rgba(255,255,255,0.10) 0, transparent 40%);
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 1px;
  position: relative;
}
.hero p {
  margin-top: 16px;
  font-size: 17px;
  opacity: 0.92;
  position: relative;
}
.hero .hero-tags {
  margin-top: 26px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}
.hero .hero-tags span {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
}
@media (max-width: 860px) {
  .container { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  width: 5px; height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
}

/* ---------- Post cards ---------- */
.post-grid { display: grid; gap: 18px; }
.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
  display: block;
  color: var(--text);
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.post-tag {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.post-card h2 { font-size: 20px; margin-bottom: 8px; }
.post-card p.excerpt {
  color: var(--text-secondary);
  font-size: 14.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card .read-more {
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
}

/* ---------- Sidebar ---------- */
.sidebar { display: grid; gap: 20px; align-content: start; }
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.widget h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.about-card { text-align: center; }
.avatar {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}
.about-card .name { font-weight: 700; font-size: 17px; }
.about-card .bio { color: var(--text-secondary); font-size: 13.5px; margin-top: 6px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 999px;
  transition: background 0.2s;
}
.tag-cloud a:hover { background: var(--primary); color: #fff; text-decoration: none; }

.friend-links a {
  display: block;
  font-size: 14px;
  padding: 6px 0;
  color: var(--text-secondary);
}
.friend-links a:hover { color: var(--primary); text-decoration: none; }

/* ---------- Article page ---------- */
.article-wrap { max-width: 780px; margin: 0 auto; padding: 40px 20px 60px; }
.article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px;
}
.article-card h1 { font-size: 30px; line-height: 1.35; margin-bottom: 14px; }
.article-meta {
  font-size: 13.5px;
  color: var(--text-secondary);
  padding-bottom: 20px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.article-content { font-size: 16px; }
.article-content h2 {
  font-size: 22px;
  margin: 32px 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}
.article-content p { margin-bottom: 16px; }
.article-content ul, .article-content ol { margin: 0 0 16px 24px; }
.article-content code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.article-content pre {
  background: #111827;
  color: #e5e7eb;
  padding: 18px 20px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 14px;
  margin-bottom: 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.article-content blockquote {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  padding: 12px 18px;
  border-radius: 0 10px 10px 0;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 26px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* ---------- Utilities ---------- */
.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff !important;
  padding: 10px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4); }
