:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --text-secondary: #555;
  --link: #0066cc;
  --link-hover: #004499;
  --border: #e0e0e0;
  --code-bg: #f0f0f0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0d;
    --text: #e8e8e8;
    --text-secondary: #999;
    --link: #6db3f2;
    --link-hover: #9dcbf7;
    --border: #2a2a2a;
    --code-bg: #1a1a1a;
  }
}

[data-theme="dark"] {
  --bg: #0d0d0d;
  --text: #e8e8e8;
  --text-secondary: #999;
  --link: #6db3f2;
  --link-hover: #9dcbf7;
  --border: #2a2a2a;
  --code-bg: #1a1a1a;
}

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

html {
  font-size: 16px;
  background: var(--bg);
  transition: background 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: transparent;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: color 0.2s ease;
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.subtitle a {
  color: var(--text-secondary);
}

.subtitle a:hover {
  color: var(--link-hover);
}

/* Links */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: rgba(128, 128, 128, 0.4);
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

/* Navigation links */
.nav-links {
  margin-bottom: 1.5rem;
}

.nav-links a {
  margin-right: 1rem;
}

.nav-links a:last-child {
  margin-right: 0;
}

/* GPG / small text */
.meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.meta a {
  color: var(--text-secondary);
}

.meta a:hover {
  color: var(--link-hover);
}

code, .mono {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  font-size: 0.9em;
}

/* Blog page */
.posts-section {
  margin-bottom: 2rem;
}

.posts-section:last-child {
  margin-bottom: 0;
}

.year {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-list {
  list-style: none;
}

.post-list li {
  margin-bottom: 1.25rem;
}

.post-summary {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.post-list a {
  display: inline;
}

.external::after {
  content: " \2197";
  font-size: 0.8em;
}

/* 404 page */
.error-code {
  font-size: 6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-secondary);
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

/* Back link */
.back-link {
  margin-bottom: 2rem;
  display: block;
}

/* Pinned post */
.pinned {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.pinned-label {
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

/* GPG key */
.gpg {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--code-bg);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
}

.gpg-label {
  font-weight: 500;
}

.gpg-copy {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.gpg-copy:hover {
  opacity: 1;
}

.gpg-links {
  font-size: 0.75rem;
}

.gpg-links a {
  color: var(--text-secondary);
}

/* Game of Life background */
#gol-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 480px) {
  h1 {
    font-size: 1.75rem;
  }

  .error-code {
    font-size: 4rem;
  }
}
