:root {
  --bg: #F7F5F0;
  --surface: #FFFDF9;
  --text: #1F2933;
  --muted: #6B7280;
  --faint: #9AA1AB;
  --accent: #3D5A80;
  --accent-strong: #2F4A6B;
  --accent-soft: rgba(61, 90, 128, .10);
  --border: #E4DED2;
  --inline-code-bg: #EDF1F5;
  --inline-code-border: #DCE3EA;
  --code-bg: #202B36;
  --code-text: #E6EDF3;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1100px 380px at 50% -120px, rgba(61, 90, 128, .07), transparent 70%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #D8E3F0; }

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

.wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 245, 240, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
}

.brand-dot { color: var(--accent); }

.nav { display: flex; gap: 22px; align-items: center; }

.nav a {
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}

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

.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Hero */
.hero { padding: 60px 0 34px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: 42px;
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 700;
}

.tagline {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--muted);
}

.stats {
  margin: 0;
  font-size: 13px;
  color: var(--faint);
  letter-spacing: .02em;
}

/* Post list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.post-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 20px;
  padding: 26px 0;
  border-bottom: 1px solid var(--border);
}

.post-date {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
  padding-top: 6px;
  letter-spacing: .02em;
}

.post-main { min-width: 0; }

.post-title {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.45;
  font-weight: 650;
  letter-spacing: -.005em;
}

.post-title a { color: var(--text); }

.post-title a:hover { color: var(--accent); }

.post-excerpt {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: var(--faint);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.7;
  transition: background .15s ease, color .15s ease;
}

.chip:hover { background: var(--accent); color: #fff; }

.reading { color: var(--faint); }

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 42px 0 12px;
}

.pager a, .pager span {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface);
}

.pager a:hover { border-color: var(--accent); color: var(--accent); }

.pager-num.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager-arrow { font-size: 13px; }

.pager-arrow.disabled { opacity: .45; }

/* Article */
.post { padding: 48px 0 20px; }

.post-header { margin-bottom: 34px; }

.post-kicker { display: flex; gap: 8px; margin-bottom: 16px; }

.post-header h1 {
  margin: 0 0 14px;
  font-size: 34px;
  line-height: 1.35;
  letter-spacing: -.015em;
  font-weight: 700;
}

.dot { color: var(--faint); }

.post-content {
  font-size: 17px;
  line-height: 1.95;
  color: var(--text);
  word-wrap: break-word;
}

.post-content > p:first-child { margin-top: 0; }

.post-content p { margin: 1.1em 0; }

.post-content h2 {
  margin: 2.3em 0 .85em;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  font-size: 25px;
  line-height: 1.45;
  font-weight: 650;
  scroll-margin-top: 90px;
}

.post-content h3 {
  margin: 1.9em 0 .7em;
  font-size: 20px;
  line-height: 1.5;
  font-weight: 650;
  scroll-margin-top: 90px;
}

.post-content h4 {
  margin: 1.6em 0 .6em;
  font-size: 17px;
  font-weight: 650;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(61, 90, 128, .35);
}

.post-content a:hover {
  color: var(--accent-strong);
  text-decoration-color: var(--accent-strong);
}

.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(31, 41, 51, .05);
}

.post-content figure { margin: 1.8em 0; }

.post-content figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}

.post-content code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--inline-code-bg);
  border: 1px solid var(--inline-code-border);
  border-radius: 5px;
  padding: .12em .38em;
  color: #2F4A6B;
}

.post-content pre {
  position: relative;
  margin: 1.7em 0;
  padding: 18px 20px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}

.post-content pre code {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.post-content blockquote {
  margin: 1.8em 0;
  padding: 14px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: rgba(61, 90, 128, .06);
  color: #35424F;
}

.post-content blockquote p { margin: .4em 0; }

.post-content ul, .post-content ol { padding-left: 1.5em; margin: 1.1em 0; }

.post-content li { margin: .4em 0; }

.post-content hr {
  margin: 2.6em 0;
  border: 0;
  border-top: 1px dashed var(--border);
}

.post-content table {
  width: 100%;
  margin: 1.6em 0;
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.post-content th, .post-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.post-content th { background: #F0ECE4; font-weight: 600; }

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 9px;
  font-size: 12px;
  font-family: var(--sans);
  color: #CBD5E1;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}

.post-content pre:hover .copy-btn { opacity: 1; }

.copy-btn:hover { background: rgba(255, 255, 255, .16); }

@media (hover: none) {
  .copy-btn { opacity: 1; }
}

/* Post navigation */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 54px 0 20px;
}

.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s ease;
}

.post-nav-item:hover { border-color: var(--accent); }

.post-nav-item.next { text-align: right; }

.post-nav-label { font-size: 12px; color: var(--faint); }

.post-nav-title { font-size: 14.5px; color: var(--text); line-height: 1.55; }

/* Page headers */
.page-header { padding: 52px 0 28px; }

.page-header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.3;
  letter-spacing: -.015em;
}

.page-kicker {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.page-sub { margin: 0; font-size: 14px; color: var(--faint); }

/* Archive */
.year-block { margin: 34px 0 44px; }

.year-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 23px;
  color: var(--accent);
}

.year-count { font-size: 12px; color: var(--faint); font-weight: 400; }

.archive-list { list-style: none; margin: 0; padding: 0; }

.archive-list li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.archive-list time {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
}

.archive-list a { color: var(--text); font-size: 15.5px; }

.archive-list a:hover { color: var(--accent); }

.archive-cat { font-size: 12px; color: var(--faint); }

/* Categories */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 30px;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .15s ease, transform .15s ease;
}

.category-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.category-name { font-size: 16px; color: var(--text); font-weight: 600; }

.category-count { font-size: 13px; color: var(--faint); white-space: nowrap; }

/* Search */
.search-box { margin: 8px 0 18px; }

#search-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-status { margin: 0 0 8px; font-size: 13px; color: var(--faint); }

.result {
  display: block;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.result-title { font-size: 18px; color: var(--text); font-weight: 600; line-height: 1.5; }

.result:hover .result-title { color: var(--accent); }

.result-meta { margin-top: 4px; font-size: 12.5px; color: var(--faint); }

.result-excerpt {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result mark,
.result-title mark {
  background: rgba(61, 90, 128, .16);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* 404 */
.notfound { text-align: center; padding: 80px 0 60px; }

.notfound-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 72px;
  line-height: 1;
  color: var(--accent);
  opacity: .25;
}

.notfound h1 { margin: 18px 0 8px; font-size: 26px; }

.button {
  display: inline-block;
  margin-top: 14px;
  padding: 9px 18px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}

.button:hover { background: var(--accent-strong); }

/* Footer */
.site-footer {
  margin-top: 70px;
  border-top: 1px solid var(--border);
  padding: 26px 0 34px;
  font-size: 13px;
  color: var(--muted);
}

.footer-inner p { margin: 2px 0; }

.muted { color: var(--faint); }

.site-footer a { color: var(--muted); }

.site-footer a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 680px) {
  .wrap { padding: 0 18px; }

  .header-inner { height: 58px; }

  .nav { gap: 14px; }

  .nav a { font-size: 13px; }

  .hero { padding: 46px 0 26px; }

  .hero h1 { font-size: 33px; }

  .post-item {
    display: block;
    padding: 22px 0;
  }

  .post-date { display: block; padding: 0 0 6px; }

  .post-title { font-size: 19.5px; }

  .post-header h1 { font-size: 27px; }

  .post { padding-top: 36px; }

  .post-content { font-size: 16.5px; line-height: 1.9; }

  .post-content h2 { font-size: 22px; }

  .post-nav { grid-template-columns: 1fr; }

  .archive-list li { grid-template-columns: 56px minmax(0, 1fr); }

  .archive-cat { display: none; }

  .category-grid { grid-template-columns: 1fr; }

  .notfound-code { font-size: 56px; }
}

@media print {
  .site-header, .site-footer, .post-nav, .pager, .copy-btn { display: none !important; }
  body { background: #fff; }
  .post-content pre { background: #f4f4f4; color: #111; }
}