:root {
  --text: #1a1a1a;
  --muted: #6b7280;
  --faint: #9ca3af;
  --link: #2563eb;
  --border: #e5e7eb;
  --bg: #ffffff;
  --max: 760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration: none; }

/* ---------- Header ---------- */
.site-header { margin-bottom: 56px; }

.identity {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.identity-text { flex: 1 1 280px; min-width: 0; }
.site-name {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.site-name a { color: var(--text); text-decoration: none; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 17px; }
.tagline a { color: var(--link); }

.social {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 6px;
}
.social a { color: var(--faint); display: inline-flex; text-decoration: none; transition: color .15s; }
.social a:hover { color: var(--text); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.search-trigger:hover { border-color: var(--faint); }

.main-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.main-nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: var(--link); }
.main-nav a.active { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Section labels ---------- */
.section-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  margin: 0 0 18px;
}

/* ---------- Latest ---------- */
.latest { margin-bottom: 56px; }
.latest-post { display: flex; gap: 24px; align-items: flex-start; }
.latest-thumb { flex: 0 0 160px; }
.latest-thumb img { width: 100%; border-radius: 8px; display: block; }
.latest-body { flex: 1 1 auto; min-width: 0; }
.latest-body h2 { margin: 0 0 8px; font-size: 27px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.latest-body h2 a { color: var(--link); text-decoration: none; }
.latest-body h2 a:hover { text-decoration: underline; }
.summary { margin: 0 0 12px; color: #374151; }
.read-more { font-weight: 500; text-decoration: none; }
.read-more:hover { text-decoration: underline; }

/* ---------- Post lists ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 16px 0; border-bottom: 1px solid var(--border); }
.post-list li:last-child { border-bottom: none; }
.post-list a { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; }
.post-list a:hover { text-decoration: underline; }
.post-date { display: inline-block; color: var(--faint); font-size: 14px; margin-right: 10px; }
.post-excerpt { margin: 6px 0 0; color: var(--muted); font-size: 15.5px; line-height: 1.55; }

.recent { margin-bottom: 40px; }
.more-link { margin-top: 22px; }
.more-link a { text-decoration: none; font-weight: 500; }
.more-link a:hover { text-decoration: underline; }

/* ---------- Archive ---------- */
.archive .year {
  font-size: 15px;
  color: var(--faint);
  font-weight: 600;
  margin: 36px 0 4px;
}
.page-intro { color: var(--muted); margin-bottom: 12px; }

/* ---------- Series ---------- */
.series { margin-bottom: 56px; }
.series-item { padding: 4px 0; }
.series-item h3 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.series-item h3 a { color: var(--link); text-decoration: none; }
.series-item h3 a:hover { text-decoration: underline; }
.series-count { color: var(--faint); font-size: 14px; font-weight: 400; margin-left: 6px; }
.series-desc { color: var(--muted); font-size: 16px; margin: 4px 0 0; }

/* series term + index pages */
.series-title { font-size: 32px; letter-spacing: -0.02em; margin: 0 0 8px; }
.series-list, .series-index { list-style: none; margin: 18px 0 0; padding: 0; }
.series-list li { padding: 16px 0; border-bottom: 1px solid var(--border); }
.series-list li:last-child { border-bottom: none; }
.series-list a { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; }
.series-list a:hover { text-decoration: underline; }
.series-index li { padding: 18px 0; border-bottom: 1px solid var(--border); }
.series-index li:last-child { border-bottom: none; }
.series-index h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.series-index h2 a { text-decoration: none; }
.series-index h2 a:hover { text-decoration: underline; }

/* "Part of the series" box on a post */
.series-box {
  margin: 44px 0 0;
  padding: 18px 20px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.series-box-label {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 11px; font-weight: 600; color: var(--faint);
  margin: 0 0 4px;
}
.series-box h3 { margin: 0 0 10px; font-size: 18px; letter-spacing: -0.01em; }
.series-box h3 a { color: var(--text); text-decoration: none; }
.series-box h3 a:hover { color: var(--link); }
.series-box ol { margin: 0; padding-left: 20px; color: var(--muted); }
.series-box li { padding: 3px 0; font-size: 16px; }
.series-box li a { text-decoration: none; }
.series-box li a:hover { text-decoration: underline; }
.series-box li.current { color: var(--text); font-weight: 600; }

/* ---------- Single post ---------- */
.post-header h1 { font-size: 36px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 10px; }
.post-meta { color: var(--faint); font-size: 15px; margin: 0 0 28px; }
.post-splash { width: 100%; border-radius: 10px; margin-bottom: 28px; }
.post-content { font-size: 18px; }
.post-content h2 { font-size: 25px; margin-top: 40px; letter-spacing: -0.01em; }
.post-content h3 { font-size: 20px; margin-top: 30px; }
.post-content img { max-width: 100%; border-radius: 8px; }
.post-content pre {
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-size: 14.5px;
}
.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #f1f3f5;
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.post-content pre code { background: none; padding: 0; }
.post-content blockquote {
  margin: 24px 0;
  padding-left: 18px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 14px;
}

/* ---------- Search modal ---------- */
.search-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12vh; z-index: 50;
}
.search-modal[hidden] { display: none; }
.search-box {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 12px; padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
#search-input {
  width: 100%; font: inherit; font-size: 18px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 8px; outline: none;
}
#search-input:focus { border-color: var(--link); }
.search-hint { color: var(--faint); font-size: 12px; margin: 8px 2px 0; }
.search-results { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.search-results li { border-top: 1px solid var(--border); }
.search-results a {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 4px; text-decoration: none; color: var(--text);
}
.search-results a:hover { background: #f9fafb; }
.r-title { font-weight: 500; }
.r-meta { color: var(--faint); font-size: 14px; white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  body { font-size: 17px; }
  .container { padding: 32px 18px 60px; }
  .site-name { font-size: 28px; }
  .latest-post { flex-direction: column; }
  .latest-thumb { flex-basis: auto; width: 100%; }
  .social { width: 100%; }
  .topbar { flex-direction: column; align-items: stretch; }
}
