:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #2b2b2b;
  --muted: #6b6b6b;
  --header: #2d3238;
  --accent: #c0392b;
  --border: #e2e2de;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Open Sans", "Helvetica Neue", Arial, sans-serif;
}

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

/* Header */
.site-header { background: var(--header); }
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo img { display: block; height: 55px; width: auto; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  display: block;
  padding: 6px 12px;
  color: #e8e8e8;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-radius: 3px;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 32px 16px 48px; }
.tagline {
  text-align: center;
  font-size: 17px;
  font-style: italic;
  font-weight: 300;
  margin: 8px 0 32px;
}
h2 {
  font-weight: 400;
  font-size: 22px;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 24px;
}

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.columns .box { margin-bottom: 0; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }

/* Home: portfolio (left) + lifestream (right) */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}
.home-grid .box { margin-bottom: 0; }
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
}

/* Portfolio slideshow */
.slideshow { margin: 0 auto 24px; }
.slides {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  aspect-ratio: 3 / 2;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.slides img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .8s ease;
}
.slides img.active { opacity: 1; }
.slides-wrap {
  position: relative;
  max-width: 568px;
  margin: 0 auto;
  padding: 0 44px;
}
.slide-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  padding: 0 0 3px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.slide-arrow.prev { left: 0; }
.slide-arrow.next { right: 0; }
.slide-arrow:hover, .slide-arrow:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; }
.slide-caption {
  min-height: 1.5em;
  margin: 8px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.slide-caption a { white-space: nowrap; margin-left: 4px; }
.slide-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 8px; }
.slide-nav button {
  min-width: 26px;
  padding: 2px 4px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 3px;
  cursor: pointer;
}
.slide-nav button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Portfolio cards */
.portfolio { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.project {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.project h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.project p { margin: 0 0 12px; color: var(--muted); font-size: 14px; flex: 1; }
.project .meta { font-size: 13px; color: var(--muted); }

/* Posts */
.posts { list-style: none; margin: 0; padding: 0; }
.posts li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.posts li:last-child, .posts li.last-visible { border-bottom: 0; }
.posts time { display: block; font-size: 13px; color: var(--muted); }
.post-tags { margin-top: 4px; }
.post-tags .tag { margin: 2px 4px 2px 0; }
.tag-filter { margin: 16px 0 0; padding: 8px 12px; background: var(--bg); border-radius: 4px; font-size: 14px; }
.more { margin-top: 12px; font-size: 14px; }

/* Lifestream */
.lifestream { max-height: 900px; overflow-y: auto; }
.fallback { color: var(--muted); font-size: 14px; }

/* About */
.about { display: grid; grid-template-columns: 1fr 315px; gap: 24px; align-items: start; }
.about img { width: 100%; height: auto; border-radius: 4px; display: block; }
.about figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
@media (max-width: 760px) { .about { grid-template-columns: 1fr; } }
.links { columns: 2; padding-left: 20px; }
@media (max-width: 500px) { .links { columns: 1; } }

/* Projects page */
.case {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
  scroll-margin-top: 16px;
}
.case.no-image { grid-template-columns: minmax(0, 1fr); }
.case:first-of-type { padding-top: 8px; }
.case:last-of-type { border-bottom: 0; padding-bottom: 0; }
.case img { width: 100%; height: auto; max-height: 280px; object-fit: contain; border-radius: 4px; display: block; }
.case-figure { margin: 0; }
.case-media { display: flex; flex-direction: column; gap: 12px; }
.case-figure figcaption { margin-top: 6px; font-size: 12px; color: var(--muted); }
.case h3 { margin: 0 0 2px; font-size: 18px; font-weight: 600; }
.case p { margin: 0 0 10px; }
.case .case-meta { color: var(--muted); font-size: 14px; }
.case .case-links { font-size: 14px; margin-bottom: 0; }
@media (max-width: 640px) {
  .case { grid-template-columns: 1fr; gap: 12px; }
  .case img { max-width: 320px; }
}

/* Footer */
footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 24px 16px;
  border-top: 1px solid var(--border);
}

/* Blog page: posts (left) + tags (right) */
.blog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: start;
}
.blog-grid .box { margin-bottom: 0; }
.tags-box { padding: 20px; }
.tags-box h2 { font-size: 18px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 8px; }
a.tag[data-tag] { cursor: pointer; }
a.tag[data-tag]:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
a.tag.active { background: var(--accent); border-color: var(--accent); color: #fff; }
a.tag.active:hover { background: #9e2f23; border-color: #9e2f23; color: #fff; }
@media (max-width: 640px) {
  .blog-grid { grid-template-columns: 1fr; }
}

/* Blog list */
.year { margin: 24px 0 4px; font-weight: 600; font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; }

/* Post */
/* Keep post text at a comfortable reading width */
.box.post { max-width: 860px; margin-left: auto; margin-right: auto; }
.post-header h1 { font-weight: 400; font-size: 30px; line-height: 1.25; margin: 0 0 6px; }
.post-meta { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.tag {
  display: inline-block;
  margin: 2px 2px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
}
.post-content img { max-width: 100%; height: auto; }
.post-content h2 { border-bottom: 1px solid var(--border); }
.post-content pre, .post-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
}
.post-content code { background: var(--bg); padding: 1px 4px; border-radius: 3px; }
.post-content pre {
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 16px;
  overflow-x: auto;
}
.post-content pre code { background: none; padding: 0; }
.post-content table { border-collapse: collapse; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 4px 8px; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.post-nav a { max-width: 48%; }
.post-nav a span { display: block; font-size: 12px; color: var(--muted); }
.post-nav .next { text-align: right; margin-left: auto; }

/* Rouge syntax highlighting (light) */
.highlight .c, .highlight .c1, .highlight .cm { color: #6a737d; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc { color: #d73a49; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sd { color: #032f62; }
.highlight .m, .highlight .mi, .highlight .mf { color: #005cc5; }
.highlight .nf, .highlight .nc { color: #6f42c1; }
.highlight .nb, .highlight .bp { color: #005cc5; }
