/* ========== Reset & Base ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-text-muted: #999999;
  --color-border: #e8e8e8;
  --color-accent: #2d6a4f;
  --color-accent-light: #40916c;
  --color-accent-bg: #d8f3dc;
  --color-tag-bg: #f0f0f0;
  --color-tag-text: #555555;
  --color-code-bg: #f5f5f5;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --max-width: 720px;
  --transition: 0.2s ease;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a1a;
    --color-surface: #242424;
    --color-text: #e0e0e0;
    --color-text-secondary: #b0b0b0;
    --color-text-muted: #777777;
    --color-border: #333333;
    --color-accent: #52b788;
    --color-accent-light: #74c69d;
    --color-accent-bg: #1b4332;
    --color-tag-bg: #2a2a2a;
    --color-tag-text: #b0b0b0;
    --color-code-bg: #2a2a2a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent-light);
}

img {
  max-width: 100%;
  height: auto;
}

/* ========== Layout ========== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== Header ========== */
.site-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 40px;
}

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

.site-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.site-title a {
  color: var(--color-text);
}

.site-title a:hover {
  color: var(--color-accent);
}

.site-nav {
  display: flex;
  gap: 24px;
  list-style: none;
}

.site-nav a {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  transition: color var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-accent);
}

/* ========== Hero ========== */
.hero {
  padding: 48px 0 40px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--color-text-secondary);
  font-size: 1.0625rem;
  line-height: 1.7;
}

/* ========== Section ========== */
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title a {
  font-size: 0.875rem;
  font-weight: 400;
}

/* ========== Post Card ========== */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 48px;
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card a {
  color: var(--color-text);
}

.post-card a:hover {
  color: var(--color-accent);
}

.post-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.5;
}

.post-meta {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.post-excerpt {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
  margin-top: 8px;
}

.post-tags {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--color-tag-text);
  background: var(--color-tag-bg);
  border-radius: 12px;
}

/* ========== Post Detail ========== */
.post-detail {
  padding-bottom: 48px;
}

.post-detail h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.post-detail .post-meta {
  margin-bottom: 32px;
}

.post-content {
  font-size: 1.0625rem;
  line-height: 2;
  color: var(--color-text);
}

.post-content p {
  margin-bottom: 1.5em;
}

.post-content h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin: 2em 0 1em;
}

.post-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.5em 0 0.75em;
}

.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 12px 20px;
  margin: 1.5em 0;
  color: var(--color-text-secondary);
  background: var(--color-accent-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content pre,
.post-content code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

.post-content code {
  background: var(--color-code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5em 0;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content img {
  border-radius: var(--radius);
  margin: 1.5em 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
  margin-top: 48px;
}

.post-nav a {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.post-nav a:hover {
  color: var(--color-accent);
}

/* ========== About Page ========== */
.about-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  flex-shrink: 0;
}

.about-name {
  font-size: 1.5rem;
  font-weight: 700;
}

.about-role {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

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

.about-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.about-section p {
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.about-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.about-section ul li {
  color: var(--color-text-secondary);
  padding-left: 16px;
  position: relative;
}

.about-section ul li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: bold;
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
}

.contact-list a {
  color: var(--color-accent);
}

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

/* ========== Back to top ========== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  font-size: 1.125rem;
  color: var(--color-text-secondary);
}

.back-to-top.visible {
  opacity: 1;
}

.back-to-top:hover {
  box-shadow: var(--shadow-md);
  color: var(--color-accent);
}

/* ========== RSS Link ========== */
.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.rss-link:hover {
  color: var(--color-accent);
}

/* ========== Filter Tabs ========== */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 16px;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-tab:hover,
.filter-tab.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* ========== Poetry Layout ========== */
.poem {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 0;
}

.poem .post-content p {
  font-size: 1.125rem;
  line-height: 2.4;
  letter-spacing: 0.08em;
  margin-bottom: 2em;
}

.poem .post-content p:last-child {
  margin-bottom: 0;
}

.poem-divider {
  width: 40px;
  height: 2px;
  background: var(--color-border);
  margin: 0 auto 32px;
  border-radius: 1px;
}

/* ========== Page Loading ========== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main.container {
  animation: fadeInUp 0.5s ease both;
}

/* ========== Selection ========== */
::selection {
  background: var(--color-accent-bg);
  color: var(--color-accent);
}

/* ========== Focus Visible ========== */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ========== 404 Page ========== */
.not-found {
  text-align: center;
  padding: 80px 0;
}

.not-found h1 {
  font-size: 6rem;
  font-weight: 700;
  color: var(--color-border);
  line-height: 1;
  margin-bottom: 16px;
}

.not-found p {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.not-found a {
  display: inline-block;
  padding: 10px 24px;
  background: var(--color-accent);
  color: white;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: background var(--transition);
}

.not-found a:hover {
  background: var(--color-accent-light);
  color: white;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.5rem;
  }

  .hero {
    padding: 32px 0 24px;
  }

  .site-header .container {
    flex-direction: column;
    gap: 12px;
  }

  .post-card {
    padding: 18px;
  }

  .post-nav {
    flex-direction: column;
  }

  .about-header {
    flex-direction: column;
    text-align: center;
  }

  .poem {
    padding: 24px 0;
  }

  .poem .post-content p {
    font-size: 1rem;
  }
}
