:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #171717;
  --muted: #69635f;
  --accent: #ff4300;
  --accent-hover: #d93a00;
  --accent-soft: rgba(255, 67, 0, .12);
  --border: #ded8d4;
  --card: #faf8f6;
  --maxw: 920px;
  --contentw: 720px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #000000;
    --fg: #f3f0ed;
    --muted: #aaa19b;
    --accent: #ff4300;
    --accent-hover: #ff6a2a;
    --accent-soft: rgba(255, 67, 0, .18);
    --border: #27211e;
    --card: #0b0b0b;
  }
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #171717;
  --muted: #69635f;
  --accent: #ff4300;
  --accent-hover: #d93a00;
  --accent-soft: rgba(255, 67, 0, .12);
  --border: #ded8d4;
  --card: #faf8f6;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --fg: #f3f0ed;
  --muted: #aaa19b;
  --accent: #ff4300;
  --accent-hover: #ff6a2a;
  --accent-soft: rgba(255, 67, 0, .18);
  --border: #27211e;
  --card: #0b0b0b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }

/* layout */
.site-header, main, .site-footer { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 28px; padding-bottom: 28px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 20px; color: var(--fg); text-decoration: none; letter-spacing: 0;
}
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px; flex: 0 0 auto;
}
.site-nav { display: flex; align-items: center; gap: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.site-nav a:hover { color: var(--accent); }
.theme-toggle {
  font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 12px;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--accent); border-color: var(--accent); outline: 0;
}
main { min-height: 60vh; padding-bottom: 48px; }
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 13px;
  padding-top: 24px; padding-bottom: 48px; margin-top: 24px;
}
.state, .empty, .error { color: var(--muted); }
.error { color: #cf222e; }

/* post list */
.list-hero {
  display: flex; align-items: end; justify-content: space-between; gap: 20px;
  margin: 12px 0 22px;
}
.list-kicker {
  margin: 0 0 4px; color: var(--muted); font-size: 13px; letter-spacing: 0;
}
.list-hero h1 {
  margin: 0; font-size: 30px; line-height: 1.18;
}
.list-lang-switch { margin: 0; flex: 0 0 auto; }
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; min-width: 0; }
.post-card {
  width: 100%; max-width: 100%; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--bg);
}
.post-card:hover { border-color: var(--accent); }
.post-card-link {
  display: grid; grid-template-columns: minmax(168px, 30%) 1fr; gap: 18px; align-items: center;
  min-width: 0; min-height: 150px; padding: 14px; text-decoration: none; color: inherit;
}
.post-card-visual {
  width: 100%; max-width: 100%; aspect-ratio: 16 / 10; border-radius: 6px; display: block;
  background: var(--card);
}
.post-card-cover { object-fit: cover; }
.post-card-body { min-width: 0; }
.post-card-fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
}
.post-card-fallback span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; background: var(--fg); color: var(--bg);
  font-weight: 800; font-size: 22px; line-height: 1;
}
.post-card-fallback small {
  max-width: 80%; color: var(--muted); font-size: 12px; text-align: center; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.post-card h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.32; color: var(--fg); }
.post-card a:hover h2 { color: var(--accent); }
.post-meta { color: var(--muted); font-size: 13px; }
.post-summary {
  margin: 9px 0 0; color: var(--muted); font-size: 15px; line-height: 1.62;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* single post */
.post { max-width: var(--contentw); margin: 0 auto; }
.back { display: inline-block; margin-bottom: 18px; color: var(--accent); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent-hover); text-decoration: underline; }

/* 语言切换 */
.lang-switch { display: flex; gap: 8px; margin: 0 0 20px; }
.lang-switch button {
  font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 5px 13px;
}
.lang-switch button:hover { color: var(--accent); border-color: var(--accent); }
.lang-switch button.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.post-body h1 { font-size: 28px; line-height: 1.3; margin: 0 0 8px; }
.post-body h2 { font-size: 22px; margin: 38px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.post-body h3 { font-size: 18px; margin: 28px 0 10px; }
.post-body p { margin: 14px 0; }
.post-body a { color: var(--accent); }
.post-body a:hover { color: var(--accent-hover); }
.post-body img { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 18px auto; }
.post-body video {
  width: 100%; height: auto; display: block; margin: 20px auto;
  border-radius: 8px; background: #000;
}
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li { margin: 6px 0; }
.post-body blockquote {
  margin: 18px 0; padding: 2px 16px; color: var(--muted);
  border-left: 4px solid var(--accent); background: var(--card); border-radius: 0 8px 8px 0;
}
.post-body hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.post-body code {
  background: var(--card); padding: .15em .4em; border-radius: 6px;
  font-size: .88em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.post-body pre {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; overflow-x: auto; line-height: 1.5;
}
.post-body pre code { background: none; padding: 0; font-size: .85em; }
.post-body table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 14px; display: block; overflow-x: auto; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.post-body th { background: var(--card); }

/* 上一篇 / 下一篇 */
.post-nav {
  display: flex; gap: 16px; margin-top: 44px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.post-nav a { display: flex; flex-direction: column; gap: 4px; max-width: 48%; text-decoration: none; }
.post-nav .next { margin-left: auto; text-align: right; }
.post-nav-label { color: var(--muted); font-size: 12px; }
.post-nav-title { color: var(--accent); font-size: 15px; line-height: 1.4; }
.post-nav a:hover .post-nav-title { color: var(--accent-hover); text-decoration: underline; }

.giscus { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }

@media (max-width: 680px) {
  .site-header { padding-top: 20px; padding-bottom: 22px; }
  .list-hero { align-items: start; flex-direction: column; gap: 12px; margin-top: 4px; }
  .list-hero h1 { font-size: 26px; }
  .post-card-link { display: flex; flex-direction: column; align-items: stretch; gap: 12px; min-height: 0; }
  .post-card-visual { aspect-ratio: 16 / 9; }
  .post-card h2 { font-size: 18px; }
  .post-summary { -webkit-line-clamp: 3; }
}
