:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666666;
  --accent: #0070f3;
  --border: #e5e5e5;
  --max-width: 720px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --border: #30363d;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Header / Nav ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 2rem;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Main ── */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: 4rem;
}

/* ── Post list ── */
.post-list .section-heading {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-list ul {
  list-style: none;
}

.post-list li {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.post-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  color: var(--text);
}

.post-title {
  font-size: 1rem;
}

.post-date {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Post article ── */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.post-meta {
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.category {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  background: var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ── Post content typography ── */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 1.5rem 0;
}

.post-content video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

.post-content pre {
  background: var(--border);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--border);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content ul,
.post-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.post-content li {
  margin-bottom: 0.25rem;
}

.post-content blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  margin: 1.5rem 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.post-content table td,
.post-content table th {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}

.post-content table th {
  background: var(--border);
  font-weight: 600;
  text-align: left;
}

.post-content table tr:nth-child(even) td {
  background: color-mix(in srgb, var(--border) 40%, transparent);
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 2rem;
}

footer p {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

footer a {
  color: var(--muted);
}

/* ── Shared section heading ── */
.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  padding: 0.3rem;
  border-radius: 4px;
  transition: color 0.15s;
  text-decoration: none;
}

.icon-link:hover {
  color: var(--text);
  text-decoration: none;
}

/* ── Project cards (home page) ── */
.projects-section {
  margin-bottom: 3rem;
}

.project-cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.project-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-card-body h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.project-card-body h3 a {
  color: var(--text);
}

.project-card-body p {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

/* ── Project page ── */
.project-page .project-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.project-page .project-header h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

.project-tagline {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.project-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.project-body {
  line-height: 1.75;
}

.project-body p {
  margin-bottom: 1.25rem;
}

.project-body strong {
  font-weight: 600;
}

.related-posts {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.related-posts ul {
  list-style: none;
}

.related-posts li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.related-posts li:last-child {
  border-bottom: none;
}

.related-posts time {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.8rem;
}

/* ── Post list section heading ── */
.post-list .section-heading {
  margin-top: 0;
}
