:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --text: #171717;
  --text-muted: #5c5c66;
  --border: #e5e5e9;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --code-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg: #0e0f11;
  --surface: #17191d;
  --text: #ededf0;
  --text-muted: #9898a6;
  --border: #262930;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --code-bg: #181b21;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-brand {
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--text-muted);
}

.icon-sun {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* Main */
.main-content {
  flex: 1;
  padding: 2.75rem 0 4rem;
}

.intro {
  margin-bottom: 2.25rem;
}

.intro h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.08rem;
}

/* Tag filter */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.tag-pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-pill:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.tag-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.post-card {
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.post-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.post-card[hidden] {
  display: none;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-title {
  margin: 0.35rem 0 0.45rem;
  font-size: 1.32rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.post-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

.post-summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.97rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

/* Article page */
.back-link {
  display: inline-block;
  margin-bottom: 1.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--text);
}

.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.22;
  letter-spacing: -0.03em;
}

/* Prose typography */
.prose {
  font-size: 1.03rem;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.4rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.prose h3 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.prose p {
  margin: 1rem 0;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose ul,
.prose ol {
  margin: 1rem 0;
  padding-left: 1.4rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.16rem 0.4rem;
  border-radius: 5px;
}

.prose pre {
  margin: 1.4rem 0;
  padding: 1rem 1.15rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.87rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.prose th {
  font-weight: 600;
  background: var(--surface);
}

/* Prev/Next navigation */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.post-nav-link:hover {
  border-color: var(--text-muted);
}

.post-nav-link.next {
  text-align: right;
}

.post-nav-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-nav-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* 404 */
.not-found {
  text-align: center;
  padding: 3rem 0;
}

.not-found h1 {
  font-size: 3.5rem;
  margin: 0;
  letter-spacing: -0.04em;
}

.not-found p {
  color: var(--text-muted);
  margin: 0.5rem 0 1.5rem;
}

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

@media (max-width: 560px) {
  .site-header {
    padding: 1.4rem 0 1.1rem;
  }

  .main-content {
    padding: 2rem 0 3rem;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }
}
