:root {
  color-scheme: light dark;
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-soft: #f4f0e9;
  --text: #22201d;
  --muted: #716b62;
  --line: #e7e1d6;
  --accent: #c2410c;
  --accent-contrast: #fff7ed;
  --accent-soft: #fdefe6;
  --code-bg: #f1ece3;
  --shadow: 0 1px 2px rgba(34, 32, 29, .04), 0 12px 32px rgba(34, 32, 29, .06);
  --radius: 16px;
  --maxw: 1120px;
  --font-body: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-head: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1c1916;
    --surface-soft: #241f1a;
    --text: #ece6dc;
    --muted: #a49b8e;
    --line: #312a23;
    --accent: #fb923c;
    --accent-contrast: #1b120b;
    --accent-soft: #2b1c12;
    --code-bg: #211c17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
button, input { font: inherit; }
::selection { background: var(--accent); color: var(--accent-contrast); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-contrast); padding: 10px 16px;
}
.skip-link:focus { left: 12px; top: 12px; border-radius: 8px; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: .01em;
}
.brand-mark { color: var(--accent); font-size: 17px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  padding: 7px 13px; border-radius: 999px; font-size: 14.5px; color: var(--muted);
  transition: color .15s ease, background .15s ease;
}
.nav a:hover { color: var(--text); background: var(--surface-soft); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
  position: relative;
}
.hero::after {
  content: "◈";
  position: absolute; right: 8px; top: 44px;
  font-size: 140px; line-height: 1; color: var(--accent);
  opacity: .08; pointer-events: none;
}
.hero-kicker a { color: inherit; }
.hero-kicker a:hover { text-decoration: underline; }
.subcats { margin: 0 0 30px; }
.hero-kicker {
  margin: 0 0 14px;
  color: var(--accent); font-size: 13px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
}
.hero h1 {
  margin: 0 0 14px;
  font-family: var(--font-head); font-size: clamp(38px, 6vw, 64px);
  line-height: 1.12; letter-spacing: -.015em; font-weight: 700;
}
.hero-desc { margin: 0 0 18px; max-width: 640px; color: var(--muted); font-size: 17px; }
.hero-stats { margin: 0; color: var(--muted); font-size: 13.5px; letter-spacing: .04em; }

/* ---------- Layout ---------- */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  align-items: start;
}
.post-grid { grid-template-columns: minmax(0, 1fr) 280px; }
.post-list { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.post-list.narrow { max-width: 780px; }

/* ---------- Cards ---------- */
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease;
}
.post-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.card-cover { display: block; aspect-ratio: 2 / 1; overflow: hidden; background: var(--surface-soft); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .card-cover img { transform: scale(1.03); }
.card-body { padding: 26px 28px 24px; }
.post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 13px; }
.post-meta .dot { opacity: .5; }
.post-meta .category { color: var(--accent); font-weight: 600; }
.post-meta .category:hover { text-decoration: underline; }
.card-title {
  margin: 12px 0 10px;
  font-family: var(--font-head); font-size: 25px; line-height: 1.35; font-weight: 700;
}
.card-title a:hover { color: var(--accent); }
.card-summary { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-row a, .tag-cloud a {
  color: var(--muted); font-size: 12.5px; padding: 3px 10px;
  background: var(--surface-soft); border-radius: 999px;
  border: 1px solid transparent; transition: all .15s ease;
}
.tag-row a:hover, .tag-cloud a:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: var(--accent-soft); }
.read-more { color: var(--accent); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.read-more:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 88px; }
.side-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 22px 20px;
}
.side-card h2 {
  margin: 0 0 14px; font-family: var(--font-head); font-size: 15px;
  letter-spacing: .02em; color: var(--text);
}
.term-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.term-list li { display: flex; flex-direction: column; gap: 2px; }
.term-list .term-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.term-list ul {
  list-style: none; margin: 2px 0 2px 7px; padding: 0 0 0 12px;
  border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
}
.term-list a { padding: 6px 0; color: var(--muted); font-size: 14px; }
.term-list a:hover { color: var(--accent); }
.term-list span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; opacity: .75; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-cloud.big { gap: 10px; }
.tag-cloud.big a { font-size: 14px; padding: 7px 14px; }
.tag-cloud.big a span { margin-left: 7px; opacity: .6; font-size: 12px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 18px 0 0; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13.5px;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.pagination .disabled { opacity: .45; }
.pagination .page-arrow { min-width: auto; }

/* ---------- Article ---------- */
.post-full, .page-full {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 52px clamp(24px, 5vw, 64px) 44px;
  box-shadow: var(--shadow); min-width: 0;
}
.page-full { max-width: 820px; }
.post-header { margin-bottom: 32px; }
.post-header h1 {
  margin: 14px 0 16px;
  font-family: var(--font-head); font-size: clamp(30px, 4.2vw, 44px);
  line-height: 1.25; letter-spacing: -.01em;
}
.post-summary {
  margin: 0 0 18px; padding-left: 16px; border-left: 3px solid var(--accent);
  color: var(--muted); font-size: 16px; line-height: 1.8;
}
.post-meta.extra { margin-bottom: 12px; }
.post-cover { margin: 0 0 34px; border-radius: 12px; overflow: hidden; background: var(--surface-soft); }
.prose { font-size: 16.5px; line-height: 1.85; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-head); line-height: 1.35; margin: 2em 0 .7em; scroll-margin-top: 88px;
}
.prose h2 { font-size: 27px; padding-bottom: .35em; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 21px; }
.prose h4 { font-size: 17.5px; }
.prose p { margin: 0 0 1.35em; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 1.35em; }
.prose li { margin: .4em 0; }
.prose blockquote {
  margin: 1.8em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent);
  color: var(--muted); font-family: var(--font-head); font-size: 17px;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose img { border-radius: 10px; margin: 1.5em 0; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2.4em 0; }
.prose code {
  font-family: var(--font-mono); font-size: .87em;
  background: var(--code-bg); padding: .18em .42em; border-radius: 5px;
}
.prose pre {
  position: relative; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; overflow-x: auto; margin: 1.6em 0;
  line-height: 1.65; font-size: 14px;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: 14.5px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 13px; text-align: left; }
.prose th { background: var(--surface-soft); font-weight: 600; }
.prose .footnotes { font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 2.5em; }

.adjacent {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line);
}
.adjacent a {
  display: flex; flex-direction: column; gap: 5px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft);
  transition: border-color .15s ease;
}
.adjacent a:hover { border-color: var(--accent); }
.adjacent a span { color: var(--muted); font-size: 12px; }
.adjacent a strong { font-family: var(--font-head); font-size: 15px; font-weight: 600; line-height: 1.45; }
.adjacent .next { text-align: right; align-items: flex-end; }

/* ---------- Page heads / archive / search / taxonomy ---------- */
.page-head { margin-bottom: 34px; }
.page-head h1 { margin: 10px 0 12px; font-family: var(--font-head); font-size: clamp(32px, 4.5vw, 46px); line-height: 1.2; }
.page-sub { margin: 0; color: var(--muted); }
.archive { display: flex; flex-direction: column; gap: 38px; max-width: 820px; }
.archive-year h2 {
  margin: 0 0 14px; font-family: var(--font-head); font-size: 26px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.archive-year h2 span { font-size: 13px; color: var(--muted); margin-left: 4px; }
.archive-year ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.archive-year li { display: flex; align-items: baseline; gap: 18px; padding: 7px 0 7px 22px; position: relative; }
.archive-year li::before {
  content: ""; position: absolute; left: -5px; top: 18px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
.archive-year time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 82px; }
.archive-year a { font-size: 15.5px; }
.archive-year a:hover { color: var(--accent); }

.search-form { display: flex; gap: 10px; max-width: 620px; margin-top: 22px; }
.search-form input {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-form button {
  padding: 12px 22px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-contrast); font-weight: 600;
}
.search-results { display: flex; flex-direction: column; gap: 8px; max-width: 820px; }
.result { padding: 20px 0; border-bottom: 1px solid var(--line); }
.result h2 { margin: 8px 0; font-family: var(--font-head); font-size: 22px; line-height: 1.4; }
.result h2 a:hover { color: var(--accent); }
.result p { margin: 0; color: var(--muted); font-size: 14.5px; }
.empty-state {
  padding: 56px 24px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 80px 24px 60px; }
.notfound-code {
  margin: 0; font-family: var(--font-head); font-size: clamp(90px, 18vw, 160px);
  line-height: 1; color: var(--accent); opacity: .18; font-weight: 700;
}
.notfound h1 { margin: 10px 0 12px; font-family: var(--font-head); font-size: 34px; }
.notfound p { color: var(--muted); }
.notfound-actions { display: flex; justify-content: center; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; padding: 11px 22px; border-radius: 999px;
  background: var(--accent); color: var(--accent-contrast); font-weight: 600; font-size: 14px;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface-soft); }
.site-footer .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 34px 24px 40px;
  color: var(--muted); font-size: 13.5px;
}
.site-footer p { margin: 0 0 8px; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 16px; opacity: .85; }
.footer-meta a:hover { color: var(--accent); }

/* ---------- Plugin markup ---------- */
.reading-time { color: var(--muted); font-size: 13px; }
.toc {
  margin: 0 0 2em; padding: 18px 22px; background: var(--surface-soft);
  border: 1px solid var(--line); border-radius: 12px; font-size: 14px;
}
.toc-title { margin: 0 0 10px; font-weight: 700; font-size: 13px; letter-spacing: .06em; color: var(--accent); }
.toc ol { margin: 0; padding-left: 1.25em; }
.toc li { margin: 4px 0; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); }
.related-posts { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.related-posts h2 { margin: 0 0 16px; font-family: var(--font-head); font-size: 21px; }
.related-list { display: grid; gap: 10px; }
.related-item { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; }
.related-item:hover { border-color: var(--accent); }
.related-item time { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.related-item strong { font-weight: 600; font-size: 15px; }

.comments { margin-top: 52px; padding-top: 32px; border-top: 1px solid var(--line); }
.comments h2 { font-family: var(--font-head); font-size: 22px; margin: 0 0 6px; }
.comments-note { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.comment { padding: 18px 0; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.comment-head strong { font-size: 14.5px; }
.comment-head time { color: var(--muted); font-size: 12.5px; }
.comment-body { margin: 8px 0 0; white-space: pre-wrap; font-size: 15px; color: var(--text); }
.comment-form { margin-top: 28px; padding: 22px; background: var(--surface-soft); border-radius: 12px; }
.comment-form h3 { margin: 0 0 14px; font-size: 16px; font-family: var(--font-head); }
.comment-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.comment-form input, .comment-form textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); outline: none;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--accent); }
.comment-form textarea { min-height: 120px; resize: vertical; margin-top: 12px; }
.comment-form .hp { position: absolute; left: -9999px; opacity: 0; }
.comment-form button {
  margin-top: 12px; padding: 10px 24px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-contrast); cursor: pointer; font-weight: 600;
}
.comment-flash { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.comment-flash.ok { background: var(--accent-soft); color: var(--accent); }
.comment-flash.err { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) { .comment-flash.err { background: #3b1212; color: #fca5a5; } }

.code-copy {
  position: absolute; top: 10px; right: 10px; padding: 4px 9px; font-size: 11.5px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s ease;
  font-family: var(--font-body);
}
.prose pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .content-grid, .post-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar > * { flex: 1 1 240px; }
}
@media (max-width: 640px) {
  .container { padding: 28px 16px 56px; }
  .site-header .inner { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
  .hero { padding: 34px 0 28px; margin-bottom: 28px; }
  .hero::after { display: none; }
  .post-full, .page-full { padding: 28px 20px 30px; }
  .card-body { padding: 20px; }
  .card-title { font-size: 21px; }
  .adjacent { grid-template-columns: 1fr; }
  .comment-form .row { grid-template-columns: 1fr; }
  .archive-year li { flex-direction: column; gap: 2px; }
  .sidebar { flex-direction: column; }
  .site-footer .inner { padding: 26px 16px 32px; }
}
