:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #16161a);
  --fg: light-dark(#1a1a1a, #d4d4d8);
  --muted: light-dark(#8a8a8a, #71717a);
  --rule: light-dark(#e6e6e6, #2a2a30);
  --accent: light-dark(#1a1a1a, #d4d4d8);
  --code-bg: light-dark(#f6f6f6, #1e1e24);
  --hl-keyword: light-dark(#a626a4, #c678dd);
  --hl-string: light-dark(#50a14f, #98c379);
  --hl-number: light-dark(#986801, #d19a66);
  --hl-comment: light-dark(#a0a1a7, #5c6370);
  --hl-func: light-dark(#4078f2, #61afef);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
  margin: 0 auto;

  padding: 3rem 1.5rem 3rem;
  max-width: 44rem;
  background: var(--bg);
  color: var(--fg);

  font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC",
        "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;

  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}
header .site { font-weight: 600; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
header nav { display: flex; align-items: baseline; gap: 1rem; }
header nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
header nav a:hover { color: var(--fg); }

.lang-switch { display: inline-flex; align-items: baseline; }
.lang-on { color: var(--fg); }
.lang-sep { margin: 0 0.15em; color: var(--muted); opacity: 0.5; }
.lang-off { font-size: 0.72rem; color: var(--muted); }
.lang-switch:hover .lang-off { color: var(--fg); text-decoration: underline; text-underline-offset: 0.2em; }

#theme-toggle {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--muted);
}
#theme-toggle:hover { color: var(--fg); }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, h4 { line-height: 1.3; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }

.item h2 { font-size: 1.15rem; margin: 0; font-weight: 600; }
.item h2 a { color: var(--fg); text-decoration: none; }
.item h2 a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.list { display: flex; flex-direction: column; }
.item { padding: 1.5rem 0; }

.item + .item { border-top: 1px solid var(--rule); }
.item:first-child { padding-top: 0; }
.item time, .meta time {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.35rem;
}

.item .desc {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags { margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tag { font-size: 0.78rem; color: var(--muted); text-decoration: none; }
.tag::before { content: "#"; }
.tag:hover { color: var(--fg); text-decoration: underline; }

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

.post h1 { margin-bottom: 0.75rem; }
.meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 2.5rem; display: flex; gap: 0.75rem; align-items: baseline; }
.meta time { margin: 0; display: inline; }
.meta .tags { margin: 0; }
.body { margin-top: 2rem; }

.body p, .body ul, .body ol { margin: 1.25rem 0; }
.body p { text-wrap: pretty; }
.body > :first-child { margin-top: 0; }
.body ul, .body ol { padding-left: 1.5rem; }
.body li { margin: 0.3rem 0; }
.body li > ul, .body li > ol { margin: 0.3rem 0; }
.body h1, .body h2, .body h3, .body h4 { margin: 2.5rem 0 0.75rem; font-weight: 600; }
.body h1 { font-size: 1.4rem; }
.body h2 { font-size: 1.2rem; }
.body h3 { font-size: 1.05rem; }
.body h4 { font-size: 1rem; color: var(--muted); }

.body img { max-width: 100%; height: auto; border-radius: 4px; display: block; }

.body img + img { margin-top: 0.6rem; }

.body figure { margin: 1.75rem 0; }
.body figure img { margin-inline: auto; }
.body figcaption {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.body figcaption:empty { display: none; }
.body blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 2px solid var(--rule); color: var(--muted); }
.body hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.body table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.body th, .body td { border-bottom: 1px solid var(--rule); padding: 0.5rem 0.75rem; text-align: left; }

code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875em; }
:not(pre) > code { background: var(--code-bg); padding: 0.15em 0.35em; border-radius: 3px; }
pre { background: var(--code-bg); padding: 1rem 1.15rem; border-radius: 5px; overflow-x: auto; line-height: 1.6; }
pre code { background: none; padding: 0; font-size: 0.85rem; }

.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: var(--hl-keyword); }
.hljs-string, .hljs-attr, .hljs-regexp { color: var(--hl-string); }
.hljs-number, .hljs-symbol { color: var(--hl-number); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-function, .hljs-name { color: var(--hl-func); }
.hljs-variable, .hljs-template-variable { color: var(--fg); }

.archive h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin: 2.25rem 0 0.6rem;
}
.archive h2:first-child { margin-top: 0; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { display: flex; gap: 1rem; align-items: baseline; padding: 0.3rem 0; }
.archive-list time {
  flex: 0 0 3rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.archive-list a { color: var(--fg); text-decoration: none; }
.archive-list a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.tag-index { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; }
.tag-index a { text-decoration: none; color: var(--fg); }
.tag-index a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.tag-index .count { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.back { margin-top: 3rem; font-size: 0.9rem; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--fg); text-decoration: underline; }
.page-title { font-size: 1.25rem; }

footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}
footer p { margin: 0; }
