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

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f1f1f;
  --text-soft: #4a4a4a;
  --muted: #8a8a8a;
  --accent: #b8311a;
  --accent-soft: #d96a52;
  --border: #e8e6e0;
  --rule: #ececea;
  --code-bg: #f5f3ee;
  --maxw: 720px;
  --wide: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1c1c1c;
    --text: #e8e4de;
    --text-soft: #c0bbb2;
    --muted: #888;
    --accent: #d9604a;
    --accent-soft: #b8442f;
    --border: #2a2a2a;
    --rule: #262626;
    --code-bg: #232323;
  }
}

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

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Site Header / Masthead ── */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.site-header-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-logo { height: 44px; width: auto; display: block; }
.site-title-word {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.site-title-word:hover { text-decoration: none; color: var(--accent); }

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 2rem;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
}
.site-nav a {
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.site-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

/* ── Splash (homepage masthead image) ── */
.splash {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.5rem 2rem 0;
}
.splash img { width: 100%; height: auto; display: block; border-radius: 2px; }

/* ── Main ── */
main {
  flex: 1;
  width: 100%;
}
.main-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

/* ── Homepage ── */
.home-intro {
  max-width: var(--maxw);
  margin: 0 auto 3rem;
  text-align: center;
}
.home-intro h1 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.section-label {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.series-list {
  max-width: var(--maxw);
  margin: 0 auto;
}
.series-summary {
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0;
}
.series-summary:first-child { padding-top: 0; }
.series-summary:last-child { border-bottom: none; }
.series-summary h2 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.4rem;
}
.series-summary h2 a { color: var(--text); }
.series-summary h2 a:hover { color: var(--accent); text-decoration: none; }
.series-summary p {
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 0.5rem;
}
.series-count {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
}
.series-page {
  max-width: var(--maxw);
  margin: 0 auto;
}
.series-page header { margin-bottom: 2rem; }
.series-page h1 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}
.series-page header p {
  color: var(--text-soft);
  font-size: 1.06rem;
  line-height: 1.65;
}
.series-overview {
  border-bottom: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  margin-bottom: 1rem;
  padding: 1rem 0;
}
.series-overview a { font-weight: 600; }
.series-posts {
  list-style: decimal-leading-zero;
  margin-left: 1.7rem;
}
.series-posts li {
  border-bottom: 1px solid var(--rule);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 0 0.9rem 0.35rem;
}
.series-posts li:last-child { border-bottom: none; }
.series-posts li::marker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ── Post list ── */
.post-list { list-style: none; max-width: var(--maxw); margin: 0 auto; }
.post-list li {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.post-list li:last-child { border-bottom: none; }
.post-list .pl-date {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  display: block;
}
.post-list .pl-title {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.post-list .pl-title a { color: var(--text); }
.post-list .pl-title a:hover { color: var(--accent); text-decoration: none; }
.post-list .pl-cats {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
}
.post-list .pl-cats a { color: var(--muted); }
.post-list .pl-cats a:hover { color: var(--accent); }

.see-all {
  max-width: var(--maxw);
  margin: 2.5rem auto 0;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

/* ── Article ── */
article.post {
  max-width: var(--maxw);
  margin: 0 auto;
}
article.post header { margin-bottom: 2.5rem; }
article.post h1 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
article.post .meta {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}
article.post .meta .cats a { color: var(--accent); }
article.post .meta .sep { color: var(--border); }

article.post .content { font-size: 1.06rem; line-height: 1.85; }
article.post .content p { margin-bottom: 1.4rem; }
article.post .content h2, article.post .content h3, article.post .content h4 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 2.2rem 0 0.8rem;
}
article.post .content h2 { font-size: 1.45rem; }
article.post .content h3 { font-size: 1.2rem; }
article.post .content blockquote {
  border-left: 3px solid var(--accent-soft);
  margin: 1.8rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  color: var(--text-soft);
  font-style: italic;
}
article.post .content blockquote p { margin-bottom: 0.5rem; }
article.post .content blockquote p:last-child { margin-bottom: 0; }
article.post .content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
article.post .content a:hover { color: var(--accent-soft); }
article.post .content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.8rem 0;
  border-radius: 2px;
}
article.post .content .alignright { float: right; margin: 0 0 1rem 1.5rem; max-width: 45%; }
article.post .content .alignleft { float: left; margin: 0 1.5rem 1rem 0; max-width: 45%; }
article.post .content .aligncenter { margin-left: auto; margin-right: auto; }
article.post .content pre {
  background: var(--code-bg);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
  font-size: 0.85rem;
  line-height: 1.6;
  border: 1px solid var(--border);
}
article.post .content code {
  font-size: 0.85em;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
article.post .content pre code { background: none; padding: 0; border: none; }
article.post .content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
article.post .content th, article.post .content td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  text-align: left;
}
article.post .content th {
  background: var(--code-bg);
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
}
article.post .content ul, article.post .content ol { margin: 1.2rem 0 1.4rem 1.5rem; }
article.post .content li { margin-bottom: 0.4rem; }

article.post footer.tags {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}
article.post footer.tags a {
  color: var(--text-soft);
  margin-right: 0.6rem;
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--code-bg);
  border-radius: 10px;
}
article.post footer.tags a:hover { color: var(--accent); text-decoration: none; background: var(--border); }

/* ── List page header ── */
.list-header {
  max-width: var(--maxw);
  margin: 0 auto 2rem;
}
.list-header h1 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.term-list {
  list-style: none;
  max-width: var(--maxw);
  margin: 0 auto;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.term-list li {
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 0;
}
.term-list li:last-child { border-bottom: none; }
.term-list a {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
}
.term-list a:hover { color: var(--accent); text-decoration: none; }
.term-list span {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Pagination ── */
.pagination {
  max-width: var(--maxw);
  margin: 2.5rem auto 0;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.pagination a { color: var(--accent); }
.pagination .disabled { color: var(--muted); opacity: 0.5; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  padding: 2rem 2rem;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Responsive ── */
@media (max-width: 720px) {
  html { font-size: 17px; }
  .site-header-inner { padding: 1.25rem 1.25rem; flex-wrap: wrap; gap: 1rem; }
  .site-nav { margin-left: 0; gap: 1.25rem; width: 100%; }
  .splash { padding: 1.5rem 1.25rem 0; }
  .main-inner { padding: 2rem 1.25rem 3rem; }
  .home-intro h1 { font-size: 1.9rem; }
  .series-page h1 { font-size: 1.7rem; }
  article.post h1 { font-size: 1.7rem; }
  .post-list .pl-title { font-size: 1.1rem; }
  article.post .content .alignright, article.post .content .alignleft {
    float: none; max-width: 100%; margin: 1.5rem 0;
  }
}
