:root {
  --bg: #f7f4ec;
  --ink: #16140f;
  --soft: #4b463d;
  --faint: #8f8779;
  --line: #ddd6c6;
  --accent: #b4392b;
  --accent-soft: #ece6d8;
  --hero-bg: #16140f;
  --hero-ink: #fdfaf0;
  --hero-soft: #c3baa9;
  --hero-rule: #3a362c;
  --code-bg: #16140f;
  --code-ink: #ece6d8;
  --quote-bg: #efeade;
  --head-bg: rgba(247, 244, 236, 0.9);
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #111013;
  --ink: #ece6dc;
  --soft: #a8a29a;
  --faint: #6f6a66;
  --line: #2a282e;
  --accent: #e2a45e;
  --accent-soft: #231f26;
  --hero-bg: #191720;
  --hero-ink: #f7f3e8;
  --hero-soft: #a8a29a;
  --hero-rule: #332f3a;
  --code-bg: #16151a;
  --code-ink: #e8e2d8;
  --quote-bg: #1b1a1f;
  --head-bg: rgba(17, 16, 19, 0.86);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  transition: background 0.25s, color 0.25s;
}

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.wrap { max-width: 40rem; margin: 0 auto; padding: 0 1.6rem; }
.wrap-wide { max-width: 62rem; margin: 0 auto; padding: 0 1.6rem; }

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--head-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header.top .bar {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.95rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.22rem;
  letter-spacing: 0.24em;
  color: var(--ink);
  border: none;
  flex: 0 0 auto;
}
.brand:hover { color: var(--accent); }

nav.menu { display: flex; gap: 1.5rem; font-size: 0.92rem; letter-spacing: 0.08em; margin-left: auto; }
nav.menu a { color: var(--faint); border: none; }
nav.menu a.on { color: var(--ink); border-bottom: 2px solid var(--accent); padding-bottom: 3px; }
nav.menu a:hover { color: var(--accent); }

.theme-btn {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); transform: rotate(-12deg); }

.hero {
  margin: 0 calc(50% - 50vw);
  padding: 6rem max(1.6rem, calc(50vw - 20rem)) 5.5rem;
  background: var(--hero-bg);
  color: var(--hero-ink);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.hero::after {
  content: "";
  position: absolute;
  right: max(1.6rem, calc(50vw - 20rem));
  top: 6rem;
  width: 2.6rem;
  height: 2.6rem;
  background: var(--accent);
}
.hero .tag {
  display: inline-block;
  font-size: 0.76rem;
  letter-spacing: 0.34em;
  color: var(--hero-soft);
  margin-bottom: 1.6rem;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 4.2rem;
  line-height: 1.05;
  letter-spacing: 0.22em;
  margin: 0 0 1.6rem;
  color: var(--hero-ink);
}
.hero p {
  color: var(--hero-soft);
  margin: 0;
  max-width: 26rem;
  font-size: 1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--hero-rule);
}

.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.34em;
  color: var(--faint);
  margin: 4rem 0 0;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--ink);
}

ul.posts { list-style: none; margin: 0; padding: 0; }
ul.posts li { border-bottom: 1px solid var(--line); }
ul.posts li:last-child { border-bottom: none; }
ul.posts .head { display: flex; align-items: baseline; gap: 1rem; justify-content: space-between; padding: 1.6rem 0 0; }
ul.posts .head a {
  font-family: var(--serif);
  font-size: 1.42rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  border: none;
  transition: color 0.15s;
}
ul.posts .head a:hover { color: var(--accent); }
ul.posts time { font-size: 0.76rem; letter-spacing: 0.12em; color: var(--faint); white-space: nowrap; font-family: var(--mono); }
ul.posts .desc { color: var(--soft); font-size: 0.93rem; margin: 0.35rem 0 1.6rem; }

article.post { padding: 4rem 0 6rem; }
article.post .post-head { margin-bottom: 3rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line); }
article.post h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.3rem;
  line-height: 1.45;
  letter-spacing: 0.05em;
  margin: 0 0 1rem;
}
article.post .meta { font-size: 0.76rem; letter-spacing: 0.16em; color: var(--faint); font-family: var(--mono); }
article.post h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.32rem;
  letter-spacing: 0.05em;
  margin: 3rem 0 1rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--accent);
  line-height: 1.6;
}
article.post h3 { font-size: 1.04rem; font-weight: 600; margin: 2rem 0 0.7rem; color: var(--soft); }
article.post p { margin: 0 0 1.25rem; }
article.post ul, article.post ol { margin: 0 0 1.25rem; padding-left: 1.3rem; }
article.post li { margin-bottom: 0.4rem; }
article.post blockquote {
  margin: 2rem 0;
  padding: 1rem 1.3rem;
  background: var(--quote-bg);
  border-left: 3px solid var(--accent);
  color: var(--soft);
  font-family: var(--serif);
  font-size: 1.02rem;
}
article.post blockquote p:last-child { margin-bottom: 0; }
article.post img { max-width: 100%; height: auto; display: block; margin: 2rem 0; }
article.post code { font-family: var(--mono); font-size: 0.85em; background: var(--accent-soft); padding: 0.1em 0.4em; }
article.post pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 1.2rem 1.3rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
}
article.post pre code { background: none; color: inherit; padding: 0; }
article.post hr { border: none; border-top: 1px solid var(--line); margin: 2.8rem 0; }

.downloads { list-style: none; margin: 0; padding: 0; }
.downloads li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}
.downloads li:last-child { border-bottom: none; }
.downloads .fname { font-family: var(--serif); font-size: 1.05rem; word-break: break-all; }
.downloads .fsize { font-size: 0.78rem; letter-spacing: 0.1em; color: var(--faint); white-space: nowrap; font-family: var(--mono); }
.downloads a { color: var(--accent); border: none; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.8rem 1.4rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: 195px; object-fit: cover; display: block; filter: saturate(0.96); transition: filter 0.25s; border: 1px solid var(--line); }
.gallery figure:hover img { filter: none; }
.gallery figcaption { padding: 0.65rem 0 0; font-size: 0.78rem; letter-spacing: 0.1em; color: var(--faint); font-family: var(--serif); }

.empty { padding: 2rem 0; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 0.94rem; }

footer.bottom {
  border-top: 2px solid var(--ink);
  margin-top: 5rem;
  padding: 2rem 0 4rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--faint);
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .hero { padding: 3.6rem max(1.6rem, calc(50vw - 20rem)) 3rem; }
  .hero h1 { font-size: 2.6rem; letter-spacing: 0.16em; }
  .hero::after { width: 1.6rem; height: 1.6rem; top: 3.6rem; }
  article.post h1 { font-size: 1.7rem; }
  ul.posts .head { flex-direction: column; gap: 0.2rem; }
  ul.posts .head a { font-size: 1.22rem; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1.2rem 1rem; }
  .gallery img { height: 145px; }
  nav.menu { gap: 1rem; }
}

@media (max-width: 560px) {
  header.top .bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    row-gap: 0.5rem;
    column-gap: 0.8rem;
    padding: 0.8rem 1.2rem;
  }
  .brand { grid-column: 1 / -1; font-size: 1.1rem; letter-spacing: 0.18em; }
  nav.menu { margin-left: 0; gap: 1.1rem; font-size: 0.9rem; }
  .theme-btn { justify-self: end; margin-left: 0; width: 1.9rem; height: 1.9rem; }
  .hero { padding: 2.6rem 1.2rem 2.2rem; }
  .hero h1 { font-size: 2.2rem; }
  .hero::after { width: 1.2rem; height: 1.2rem; top: 2.6rem; right: 1.2rem; }
  .wrap, .wrap-wide { padding: 0 1.2rem; }
}
