:root {
  --max-w: 800px;
  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --color-border: #e5e7eb;
  --color-accent: #2563eb;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  font-size: 16px;
}

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

.site-header-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.site-header {
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: var(--max-w);
  margin: 0 auto;
}

.site-name { font-size: 1.25rem; font-weight: 700; color: var(--color-text); }

.lang-switcher { font-size: 0.875rem; }
.lang-switcher a { color: var(--color-muted); margin: 0 0.25rem; }
.lang-switcher a.active { color: var(--color-accent); font-weight: 600; }

.main-content {
  max-width: var(--max-w);
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 3rem;
}
.site-footer a { color: var(--color-muted); margin-left: 1rem; }

/* Homepage */
.home-intro { margin-bottom: 2.5rem; }
.home-intro h1 { font-size: 1.75rem; }
.site-description { margin-top: 0.5rem; font-size: 1rem; color: var(--color-muted); }

.category-section { margin-bottom: 3rem; }
.category-section > h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-accent);
  display: inline-block;
}
.category-section > h2 a { color: var(--color-text); }

.view-all { display: inline-block; margin-top: 1rem; font-size: 0.875rem; }

/* Post grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.post-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.post-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.post-card img { width: 100%; height: 180px; object-fit: cover; display: block; }
.post-card h2 { font-size: 1rem; padding: 0.75rem 1rem 0.5rem; line-height: 1.4; }
.post-card h2 a { color: var(--color-text); }
.post-card h2 a:hover { color: var(--color-accent); text-decoration: none; }
.post-card p { font-size: 0.875rem; color: var(--color-muted); padding: 0 1rem 1rem; line-height: 1.5; }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 1.25rem;
}
.back-link:hover { color: var(--color-accent); text-decoration: none; }

/* Breadcrumb */
.breadcrumb { font-size: 0.875rem; color: var(--color-muted); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-accent); }

/* Post page */
.post-article h1 { font-size: 2rem; line-height: 1.3; margin-bottom: 1rem; }

.post-meta { display: flex; gap: 1rem; font-size: 0.875rem; color: var(--color-muted); margin-bottom: 1.5rem; }

.post-content { font-size: 1rem; line-height: 1.8; }
.post-content h2 { font-size: 1.5rem; margin: 2rem 0 1rem; }
.post-content h3 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
.post-content p { margin-bottom: 1.25rem; }
.post-content ul, .post-content ol { margin-bottom: 1.25rem; padding-left: 1.5rem; }
.post-content li { margin-bottom: 0.5rem; }
.post-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5rem 0; }
.post-content blockquote {
  border-left: 4px solid var(--color-accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--color-muted);
  background: #f8fafc;
}
.post-content code { background: #f1f5f9; padding: 0.125rem 0.375rem; border-radius: 4px; font-size: 0.875em; }
.post-content pre { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow-x: auto; margin-bottom: 1.25rem; }
.post-content pre code { background: none; padding: 0; }

/* Scroll to top button */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover { transform: translateY(-2px); }

@media (max-width: 640px) {
  .post-grid { grid-template-columns: 1fr; }
  .post-article h1 { font-size: 1.5rem; }
  .back-to-top { bottom: 1rem; right: 1rem; }
}
