:root {
  --bg: #faf9f7;
  --bg-soft: #f1efea;
  --card: #ffffff;
  --text: #1f2430;
  --text-soft: #5c6470;
  --text-faint: #9299a6;
  --line: #e6e2da;
  --accent: #3b5bdb;
  --accent-soft: rgba(59, 91, 219, 0.1);
  --code-bg: #f1f2f6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #12141a;
  --bg-soft: #1a1d26;
  --card: #1c1f29;
  --text: #e8eaf0;
  --text-soft: #a6adbb;
  --text-faint: #6c7484;
  --line: #2c303c;
  --accent: #7b96ff;
  --accent-soft: rgba(123, 150, 255, 0.14);
  --code-bg: #242833;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 10px 28px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

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

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

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.header-inner { display: flex; align-items: center; gap: 18px; height: 64px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-family: var(--serif); font-weight: 700; font-size: 17px;
}

.brand-text { font-size: 18px; font-weight: 700; letter-spacing: .02em; }

.site-nav { display: flex; gap: 4px; margin-left: 8px; }
.site-nav a {
  color: var(--text-soft); padding: 6px 12px; border-radius: 8px; font-size: 15px;
}
.site-nav a:hover { color: var(--text); text-decoration: none; background: var(--bg-soft); }
.site-nav a.active { color: var(--accent); font-weight: 600; }

.theme-toggle {
  margin-left: auto;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text-soft);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: block; }

/* Hero */
.hero { padding: 64px 0 40px; }
.hero-kicker {
  display: inline-block; font-size: 13px; letter-spacing: .12em;
  color: var(--accent); text-transform: uppercase; font-weight: 600; margin: 0 0 14px;
}
.hero h1 {
  font-family: var(--serif); font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.25; margin: 0 0 14px; font-weight: 700;
}
.hero p { color: var(--text-soft); font-size: 17px; max-width: 640px; margin: 0; }

/* Section */
.section { padding: 18px 0 34px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 22px;
}
.section-title { font-family: var(--serif); font-size: 22px; margin: 0; }
.section-link { font-size: 14px; color: var(--text-faint); }
.section-link:hover { color: var(--accent); }

/* Cards grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,.1); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-title { font-family: var(--serif); font-size: 19px; margin: 0; line-height: 1.4; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); text-decoration: none; }
.card-excerpt { color: var(--text-soft); font-size: 14.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-faint); flex-wrap: wrap; }

/* Tags */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--accent-soft); color: var(--accent);
}
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text-soft);
  padding: 5px 14px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
}
.tag-btn:hover { border-color: var(--accent); color: var(--accent); }
.tag-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Layout two col */
.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 40px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } .two-col .side { order: 2; } }

/* Sidebar */
.side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 22px; }
.widget {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.widget h3 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 12px; font-weight: 600; }
.widget p { color: var(--text-soft); font-size: 14px; margin: 0; }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget ul li + li { margin-top: 9px; }
.widget ul a { color: var(--text-soft); font-size: 14.5px; }
.widget ul a:hover { color: var(--accent); }
.widget .recent-item { display: block; font-size: 14.5px; color: var(--text); }
.widget .recent-date { display: block; font-size: 12.5px; color: var(--text-faint); }

.avatar {
  width: 64px; height: 64px; border-radius: 50%; margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), #e07a5f);
  display: grid; place-items: center; color: #fff; font-family: var(--serif); font-size: 26px;
}

/* Post detail */
.post { max-width: 760px; margin: 0 auto; padding: 40px 0 56px; }
.post-header { text-align: center; margin-bottom: 30px; }
.post-title { font-family: var(--serif); font-size: clamp(26px, 4vw, 36px); line-height: 1.3; margin: 0 0 12px; }
.post-header .card-meta { justify-content: center; }
.post-body { font-size: 16.5px; }
.post-body h2 { font-family: var(--serif); font-size: 25px; margin: 40px 0 14px; padding-top: 6px; }
.post-body h3 { font-family: var(--serif); font-size: 20px; margin: 30px 0 10px; }
.post-body p { margin: 0 0 18px; }
.post-body ul, .post-body ol { padding-left: 26px; margin: 0 0 18px; }
.post-body li { margin-bottom: 6px; }
.post-body strong { color: var(--text); font-weight: 650; }
.post-body blockquote {
  margin: 22px 0; padding: 4px 20px; border-left: 3px solid var(--accent);
  color: var(--text-soft); font-style: italic; background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.post-body code {
  font-family: var(--mono); font-size: .88em; background: var(--code-bg);
  padding: 2px 6px; border-radius: 6px;
}
.post-body pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; overflow-x: auto; margin: 0 0 18px;
}
.post-body pre code { background: none; padding: 0; font-size: 14px; line-height: 1.6; }
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 34px 0; }
.post-body a { text-decoration: underline; text-underline-offset: 3px; }
.post-body img { max-width: 100%; border-radius: 10px; }

.post-foot { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.back-link { font-size: 14.5px; color: var(--text-faint); }
.back-link:hover { color: var(--accent); }

/* Archive search */
.search {
  width: 100%; padding: 12px 16px; border-radius: 12px; font-size: 15px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  margin-bottom: 24px; font-family: var(--sans);
}
.search:focus { outline: none; border-color: var(--accent); }

/* About page */
.about { max-width: 760px; margin: 0 auto; padding: 40px 0 56px; }
.about h1 { font-family: var(--serif); font-size: 32px; margin: 24px 0 8px; }
.about .role { color: var(--text-soft); margin: 0 0 26px; font-size: 17px; }
.about h2 { font-family: var(--serif); font-size: 21px; margin: 32px 0 10px; }
.about p, .about li { color: var(--text-soft); }
.about .avatar { width: 84px; height: 84px; font-size: 34px; margin-bottom: 4px; }

.empty { text-align: center; color: var(--text-faint); padding: 48px 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; background: var(--bg-soft); }
.footer-inner { padding: 26px 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.footer-inner p { margin: 0; font-size: 13.5px; color: var(--text-faint); }
.footer-meta { font-family: var(--sans); }
