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

:root {
  --bg: #fff;
  --text: #333;
  --text-hover: #000;
  --muted: #999;
  --border: #eee;
  --code-bg: #f5f5f5;
  --blockquote: #666;
  --blockquote-border: #ddd;
  --dot: #e0e0e0;
  --card-bg: #fafafa;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #d4d4d4;
  --text-hover: #fff;
  --muted: #777;
  --border: #333;
  --code-bg: #2a2a2a;
  --blockquote: #aaa;
  --blockquote-border: #555;
  --dot: #2a2a2a;
  --card-bg: #222;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 20px 20px;
  line-height: 1.6;
  padding: 2rem 1.5rem;
  max-width: 640px;
  margin: 0 auto;
}

a {
  color: var(--text);
}

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

header {
  margin-bottom: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav a {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--muted);
}

nav a:hover {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s, border-color 0.2s;
}

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

main {
  min-height: 60vh;
}

/* About section */
.about {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 3rem;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}

.about img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
}

.about p {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Post list */
.post-list {
  list-style: none;
}

.post-list li {
  margin-bottom: 0.4rem;
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.post-list .date {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 5.5rem;
}

.post-list a {
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
}

.year-group {
  margin-bottom: 2rem;
}

.year-group h2 {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 0.6rem;
  letter-spacing: 0.05em;
}

/* Post view */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: 1.6rem;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.post-header .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.75;
}

.post-body h1,
.post-body h2,
.post-body h3 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-body h2 { font-size: 1.3rem; }
.post-body h3 { font-size: 1.1rem; }

.post-body p {
  margin-bottom: 1rem;
}

.post-body ul,
.post-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.3rem;
}

.post-body blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding-left: 1rem;
  color: var(--blockquote);
  margin-bottom: 1rem;
}

.post-body code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-body pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

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

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem 0;
}

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

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.back-link {
  display: inline-block;
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

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

/* Projects page */
.projects-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .projects-list {
    grid-template-columns: 1fr 1fr;
  }
}

.projects-list li {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  overflow: hidden;
}

.project-media img,
.project-media video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.project-info {
  padding: 1rem 1.2rem;
}

.projects-list .project-name {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.projects-list .project-desc {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.projects-list a {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.projects-list a:hover {
  color: var(--text);
  text-decoration: underline;
}

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 1.5rem;
}

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

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