:root {
  --bg: #f6f7fb;
  --bg-card: #ffffff;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --border: #e5e7eb;
  --shadow: 0 4px 20px rgba(31, 36, 48, 0.08);
  --shadow-hover: 0 10px 30px rgba(31, 36, 48, 0.14);
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --text: #e6e8ef;
  --text-muted: #9aa3b2;
  --border: #2a2e3a;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.55);
}

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

html {
  scroll-behavior: smooth;
}

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

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--primary);
}

.theme-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
  color: var(--text);
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 96px 24px 64px;
}

.hero-avatar {
  width: 112px;
  height: 112px;
  margin: 0 auto 24px;
  font-size: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-hover);
}

.hero-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 16px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  box-shadow: var(--shadow-hover);
}

.btn-outline {
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

/* ---------- Sections ---------- */
section {
  padding: 56px 0;
}

.section-head {
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.6rem;
  margin-bottom: 20px;
}

.article-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.search-input {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-filter:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tag-filter.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* ---------- Article Grid ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.article-card .article-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.article-card h3 {
  font-size: 1.1rem;
  line-height: 1.4;
}

.article-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex: 1;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.article-tags span {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.empty-tip {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

/* ---------- About ---------- */
.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.about-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skills span {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gradient);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------- Contact ---------- */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.contact-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s, border-color 0.2s;
}

.contact-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-title {
  font-size: 1.4rem;
  margin-bottom: 8px;
  padding-right: 32px;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-body {
  color: var(--text);
  font-size: 0.98rem;
}

.modal-body h4 {
  margin: 18px 0 8px;
}

.modal-body p {
  margin-bottom: 10px;
}

.modal-body code {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.modal-body pre {
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 0.88rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero {
    padding: 64px 24px 40px;
  }

  .nav-links {
    gap: 14px;
    font-size: 0.85rem;
  }

  .article-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    max-width: 100%;
  }
}
